Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pollyvolk committed Dec 19, 2022
1 parent 1841b3f commit f39f49b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
35 changes: 14 additions & 21 deletions src/main/java/org/cqfn/reportwine/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void run()
try {
ext = new ExtensionHandler(this.template, this.output).getExtension();
} catch (final ExpectedSimilarExtensions exception) {
LOG.severe(exception.getErrorMessage());
LOG.warning(exception.getErrorMessage());
}
if (!ext.isEmpty()) {
final BandData data = this.convertYamlToBandData();
Expand All @@ -156,22 +156,15 @@ private void run()
break;
case "pptx":
final YargToDocx4jConverter docxfj = new YargToDocx4jConverter(data);
PptxGenerator pptx = null;
final PptxGenerator pptx =
new PptxGenerator(docxfj.convert(), docxfj.getTables());
try {
pptx =
new PptxGenerator(docxfj.convert(), docxfj.getTables());
} catch (final BaseException exception) {
LOG.severe("Cannot cast data to pptx bindings");
}
if (pptx != null) {
try {
pptx.renderDocument(this.template, this.output);
LOG.info("PPTX Report generated");
} catch (final Docx4JException exception) {
LOG.severe("Cannot load pptx template");
} catch (final Pptx4jException exception) {
LOG.severe("Cannot load pptx template slides");
}
pptx.renderDocument(this.template, this.output);
LOG.info("PPTX Report generated");
} catch (final Docx4JException exception) {
LOG.warning("Cannot load pptx template");
} catch (final Pptx4jException exception) {
LOG.warning("Cannot load pptx template slides");
}
break;
default:
Expand Down Expand Up @@ -199,11 +192,11 @@ private BandData convertYamlToBandData() throws BaseException, IOException {
info = merger.merge(info, settings);
}
} catch (final BaseException exception) {
LOG.severe("Cannot parse YAML data");
LOG.severe(exception.getErrorMessage());
LOG.warning("Cannot parse YAML data");
LOG.warning(exception.getErrorMessage());
throw exception;
} catch (final IOException exception) {
LOG.severe("Cannot read YAML file");
LOG.warning("Cannot read YAML file");
throw exception;
}
final CodeHandler handler = new CodeHandler(info);
Expand All @@ -213,8 +206,8 @@ private BandData convertYamlToBandData() throws BaseException, IOException {
try {
data = converter.convert();
} catch (final BaseException exception) {
LOG.severe("Cannot cast data to docx bindings");
LOG.severe(exception.getErrorMessage());
LOG.warning("Cannot cast data to docx bindings");
LOG.warning(exception.getErrorMessage());
throw exception;
}
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ private void processArrayAsTable(
private static void generateArrayException(final Value child)
throws ExpectedTextArray, ExpectedPairArray, ExpectedArrayList {
if (child instanceof Text) {
throw new ExpectedTextArray(child.toString());
throw new ExpectedTextArray(child.toJsonString());
}
if (child instanceof Pair) {
throw new ExpectedPairArray(child.toString());
throw new ExpectedPairArray(child.toJsonString());
}
if (child instanceof Array) {
throw new ExpectedArrayList(child.toString());
throw new ExpectedArrayList(child.toJsonString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void processYamlSequence(
throw new ExpectedScalarException(seq.toString());
}
}
if (list) {
if (list || node.type().equals(Node.SCALAR)) {
values.add(
YamlToIrConverter.processYamlScalar(
node.asScalar().value(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.cqfn.reportwine.exceptions.BaseException;

/**
* Converter from the YARG {@link BandData} representation to mappings
Expand Down Expand Up @@ -65,9 +64,8 @@ public YargToDocx4jConverter(final BandData root) {
/**
* Converts YARG objects into Docx4j bindings for variable replacement in pptx template.
* @return The mapping for Docx4j variable bindings
* @throws BaseException If an error occurs during IR parsing
*/
public Map<String, String> convert() throws BaseException {
public Map<String, String> convert() {
this.processBandData(this.root);
this.processBandChildren(this.root);
return this.mappings;
Expand Down

0 comments on commit f39f49b

Please sign in to comment.