19
19
import java .util .Collections ;
20
20
import java .util .Optional ;
21
21
22
- import de .kosit .validationtool .impl .xvrl .XVRLBuilder ;
22
+ import de .kosit .validationtool .impl .xvrl .XVRLDetectionBuilder ;
23
+ import de .kosit .validationtool .impl .xvrl .XVRLReportBuilder ;
24
+ import de .kosit .validationtool .model .xvrl .XVRLDetection ;
23
25
import de .kosit .validationtool .model .xvrl .XVRLReport ;
24
26
25
27
import lombok .RequiredArgsConstructor ;
46
48
public class ComputeAcceptanceAction implements CheckAction {
47
49
48
50
@ Override
49
- public ProcessStepResult check (final Process results ) {
51
+ public ProcessStepResult check (final Process process ) {
50
52
final ProcessStepResult stepResult = new ProcessStepResult ();
51
53
Result <AcceptRecommendation , XMLSyntaxError > result = new Result <>(AcceptRecommendation .UNDEFINED );
52
- if (!results .isStopped () && results .getResult (DocumentParseAction .class ).isValid ()) {
53
- if (preCondtionsMatch (results )) {
54
- final Result <Scenario , String > scenarioSelection = results .getResult (ScenarioSelectionAction .class );
54
+ if (!process .isStopped () && process .getResult (DocumentParseAction .class ).isValid ()) {
55
+ if (preCondtionsMatch (process )) {
56
+ final Result <Scenario , String > scenarioSelection = process .getResult (ScenarioSelectionAction .class );
55
57
final Optional <XPathSelector > acceptMatch = scenarioSelection .getObject ().getAcceptSelector ();
56
- if (results .getResult (SchemaValidationAction .class ).isValid () && acceptMatch .isPresent ()) {
57
- result = evaluateAcceptanceMatch (results , acceptMatch .get ());
58
+ if (process .getResult (SchemaValidationAction .class ).isValid () && acceptMatch .isPresent ()) {
59
+ result = evaluateAcceptanceMatch (process , acceptMatch .get ());
58
60
} else {
59
- result = evaluateSchemaAndSchematron (results );
61
+ result = evaluateSchemaAndSchematron (process );
60
62
}
61
63
} else {
62
64
XMLSyntaxError xmlSyntaxError = new XMLSyntaxError ();
@@ -71,8 +73,15 @@ public ProcessStepResult check(final Process results) {
71
73
}
72
74
73
75
private static XVRLReport generateXVRLReport (final Result <AcceptRecommendation , XMLSyntaxError > currentResult ) {
74
- // TODO create report here
75
- return XVRLBuilder .builder ().name ("Compute Acceptance Validator" ).addErrors (currentResult .getErrors ()).build ();
76
+ return XVRLReportBuilder .builder ()
77
+ .name ("Compute Acceptance Validator" )
78
+ .addErrors (currentResult .getErrors ())
79
+ .addDetections (Collections .singletonList (XVRLDetectionBuilder .builder ()
80
+ .setSeverity (XVRLDetection .Severity .INFO )
81
+ .addMessageString (currentResult .getObject ().name ())
82
+ .build ()))
83
+ .setValid ("" + currentResult .getErrors ().isEmpty ())
84
+ .build ();
76
85
}
77
86
78
87
private static Result <AcceptRecommendation , XMLSyntaxError > evaluateSchemaAndSchematron (final Process results ) {
@@ -95,11 +104,13 @@ private static boolean hasSchematronErrors(final Process results) {
95
104
return !report .getAllErrors ().isEmpty ();
96
105
}
97
106
98
- private static Result <AcceptRecommendation , XMLSyntaxError > evaluateAcceptanceMatch (final Process results , final XPathSelector selector ) {
107
+ private static Result <AcceptRecommendation , XMLSyntaxError > evaluateAcceptanceMatch (final Process results ,
108
+ final XPathSelector selector ) {
99
109
try {
100
110
final Result <XdmNode , XMLSyntaxError > report = results .getResult (CreateReportAction .class );
101
111
selector .setContextItem (report .getObject ());
102
- AcceptRecommendation effectiveBooleanValue = selector .effectiveBooleanValue () ? AcceptRecommendation .ACCEPTABLE : AcceptRecommendation .REJECT ;
112
+ AcceptRecommendation effectiveBooleanValue = selector .effectiveBooleanValue () ? AcceptRecommendation .ACCEPTABLE
113
+ : AcceptRecommendation .REJECT ;
103
114
return new Result <>(effectiveBooleanValue );
104
115
} catch (final SaxonApiException e ) {
105
116
final String msg = String .format ("Error evaluating accept recommendation: %s" , selector .getUnderlyingXPathContext ().toString ());
0 commit comments