log error ids
This commit is contained in:
@@ -135,6 +135,22 @@ public class ValidationContext {
|
||||
return String.join(",", errorcodes);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return the unique error IDs as comma separated string
|
||||
*/
|
||||
public String getCSVIDResult() {
|
||||
final ArrayList<String> errorIDs = new ArrayList<>();
|
||||
for (final ValidationResultItem validationResultItem : results) {
|
||||
if (!validationResultItem.getID().isEmpty()) {
|
||||
final String errorID=validationResultItem.getID();
|
||||
errorIDs.add(errorID);
|
||||
|
||||
}
|
||||
}
|
||||
return String.join(",", errorIDs);
|
||||
}
|
||||
|
||||
public void setInvalid() {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class ValidationResultItem {
|
||||
|
||||
protected String message, location=null;
|
||||
protected int section =-1;
|
||||
protected String id =""; // e.g. "FX-SCH-A-000026"
|
||||
|
||||
|
||||
private ESeverity severity=ESeverity.error;
|
||||
@@ -103,6 +104,15 @@ public class ValidationResultItem {
|
||||
return severity;
|
||||
}
|
||||
|
||||
public ValidationResultItem setID(String id) {
|
||||
this.id=id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
@@ -453,6 +453,7 @@ public class XMLValidator extends Validator {
|
||||
|
||||
String thisFailText = "";
|
||||
String thisFailID = "";
|
||||
String thisFailIDStr = "";
|
||||
String thisFailTest = "";
|
||||
String thisFailLocation = "";
|
||||
if (failedAsserts.getLength() > 0) {
|
||||
@@ -461,7 +462,8 @@ public class XMLValidator extends Validator {
|
||||
//nodes.item(i).getTextContent())) {
|
||||
Node currentFailNode = failedAsserts.item(nodeIndex);
|
||||
if (currentFailNode.getAttributes().getNamedItem("id") != null) {
|
||||
thisFailID = " [ID " + currentFailNode.getAttributes().getNamedItem("id").getNodeValue() + "]";
|
||||
thisFailID = currentFailNode.getAttributes().getNamedItem("id").getNodeValue();
|
||||
thisFailIDStr = " [ID " + thisFailID + "]";
|
||||
}
|
||||
if (currentFailNode.getAttributes().getNamedItem("test") != null) {
|
||||
thisFailTest = currentFailNode.getAttributes().getNamedItem("test").getNodeValue();
|
||||
@@ -494,8 +496,8 @@ public class XMLValidator extends Validator {
|
||||
|
||||
LOGGER.info("FailedAssert ", thisFailText);
|
||||
|
||||
context.addResultItem(new ValidationResultItem(severity, thisFailText + thisFailID + " from " + xsltFilename + ")")
|
||||
.setLocation(thisFailLocation).setCriterion(thisFailTest).setSection(section)
|
||||
context.addResultItem(new ValidationResultItem(severity, thisFailText + thisFailIDStr + " from " + xsltFilename + ")")
|
||||
.setLocation(thisFailLocation).setCriterion(thisFailTest).setSection(section).setID(thisFailID)
|
||||
.setPart(EPart.fx));
|
||||
failedRules++;
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ public class ZUGFeRDValidator {
|
||||
LOGGER.info("Parsed PDF:" + pdfResult + " XML:" + (xmlValidity ? "valid" : "invalid")
|
||||
+ " Signature:" + Signature + " Checksum:" + sha1Checksum + " Profile:" + context.getProfile()
|
||||
+ " Version:" + context.getGeneration() + " Took:" + duration + "ms Errors:[" + context.getCSVResult()
|
||||
+ "] " + toBeAppended);
|
||||
+ "] ErrorIDs: [" + context.getCSVIDResult() + "]" + toBeAppended);
|
||||
wasCompletelyValid = ((pdfValidity) && (xmlValidity));
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user