25
25
import java .util .Map ;
26
26
import java .util .stream .Collectors ;
27
27
28
- import de .kosit .validationtool .model .xvrl .Timestamp ;
29
- import de .kosit .validationtool .model .xvrl .XVRLMetadata ;
30
- import de .kosit .validationtool .model .xvrl .XVRLReportSummary ;
28
+ import de .kosit .validationtool .impl .tasks .*;
29
+ import de .kosit .validationtool .impl .xvrl .XVRLUtil ;
30
+ import de .kosit .validationtool .impl .xvrl .XmlErrorImpl ;
31
+ import de .kosit .validationtool .model .xvrl .*;
31
32
import lombok .Getter ;
32
33
import lombok .extern .slf4j .Slf4j ;
33
34
36
37
import de .kosit .validationtool .api .Input ;
37
38
import de .kosit .validationtool .api .Result ;
38
39
import de .kosit .validationtool .api .XmlError ;
39
- import de .kosit .validationtool .impl .tasks .CheckAction ;
40
40
import de .kosit .validationtool .impl .tasks .CheckAction .Process ;
41
- import de .kosit .validationtool .impl .tasks .ComputeAcceptanceAction ;
42
- import de .kosit .validationtool .impl .tasks .CreateDocumentIdentificationAction ;
43
- import de .kosit .validationtool .impl .tasks .CreateReportAction ;
44
- import de .kosit .validationtool .impl .tasks .DocumentParseAction ;
45
- import de .kosit .validationtool .impl .tasks .ScenarioSelectionAction ;
46
- import de .kosit .validationtool .impl .tasks .SchemaValidationAction ;
47
- import de .kosit .validationtool .impl .tasks .SchematronValidationAction ;
48
- import de .kosit .validationtool .impl .tasks .ValidateReportInputAction ;
49
41
import de .kosit .validationtool .impl .xml .ProcessorProvider ;
50
42
import de .kosit .validationtool .model .reportInput .CreateReportInput ;
51
43
import de .kosit .validationtool .model .reportInput .EngineType ;
@@ -95,6 +87,7 @@ public DefaultCheck(final Processor processor, final Configuration... configurat
95
87
this .checkSteps .add (new SchemaValidationAction (processor ));
96
88
this .checkSteps .add (new SchematronValidationAction (this .conversionService ));
97
89
this .checkSteps .add (new ValidateReportInputAction (this .conversionService , SchemaProvider .getReportInputSchema ()));
90
+ this .checkSteps .add (new ValidateXVRLReportSummaryAction (this .conversionService , SchemaProvider .getXVRLSchema ()));
98
91
this .checkSteps .add (new CreateReportAction (processor , this .conversionService ));
99
92
this .checkSteps .add (new ComputeAcceptanceAction ());
100
93
}
@@ -112,9 +105,16 @@ protected static CreateReportInput createReport() {
112
105
protected static XVRLReportSummary createXVRLXvrlReportSummary () {
113
106
final XVRLReportSummary xvrlReportSummary = new XVRLReportSummary ();
114
107
XVRLMetadata metadata = new XVRLMetadata ();
108
+
115
109
Timestamp timestamp = new Timestamp ();
116
110
timestamp .setValue (createTimestamp ());
117
111
metadata .getTimestamps ().add (timestamp );
112
+
113
+ Validator validator = new Validator ();
114
+ validator .setName (EngineInformation .getName ());
115
+ validator .setVersion (EngineInformation .getVersion ());
116
+ metadata .getValidators ().add (validator );
117
+
118
118
xvrlReportSummary .setMetadata (metadata );
119
119
return xvrlReportSummary ;
120
120
}
@@ -125,7 +125,7 @@ protected boolean isSuccessful(final Map<String, Result> results) {
125
125
126
126
@ Override
127
127
public Result checkInput (final Input input ) {
128
- final Process checkProcess = new Process (input , createReport ());
128
+ final Process checkProcess = new Process (input , createReport (), createXVRLXvrlReportSummary () );
129
129
return runCheckInternal (checkProcess );
130
130
}
131
131
@@ -141,7 +141,9 @@ protected Result runCheckInternal(final Process checkProcess) {
141
141
}
142
142
checkProcess .setFinished (true );
143
143
log .info ("Finished check of {} in {}ms\n " , checkProcess .getInput ().getName (), System .currentTimeMillis () - started );
144
- return createResult (checkProcess );
144
+ Result result = createResult (checkProcess );
145
+ Result xvrlResult = createXVRLResult (checkProcess );
146
+ return result ;
145
147
}
146
148
147
149
private Result createResult (final Process t ) {
@@ -157,9 +159,40 @@ private Result createResult(final Process t) {
157
159
return result ;
158
160
}
159
161
162
+ private Result createXVRLResult (final Process process ) {
163
+
164
+ final XVRLResult xvrlResult = new XVRLResult (process .getXvrlFinalReport (), process .getAcceptStatus (),
165
+ new HtmlExtractor (this .processor ));
166
+
167
+ XVRLReport parserReport = process .getReport (DocumentParseAction .class );
168
+ xvrlResult .setWellformed ("true" .equals (parserReport .getDigest ().getValid ()));
169
+
170
+ xvrlResult .setReportSummary (process .getXvrlReportSummary ());
171
+ xvrlResult .setSchemaViolations (convertErrorsFromXVRLDetections (XVRLUtil .getAllErrorDetections (process .getXvrlReportSummary ())));
172
+
173
+ xvrlResult .setProcessingSuccessful (!process .isStopped () && process .isFinished ());
174
+
175
+ // TODO MM add SchematronResult
176
+ // XVRLReport schematronValidationReport = process.getReport(SchematronValidationAction.class);
177
+ // xvrlResult.setSchematronResult(t.getReportInput().getValidationResultsSchematron().stream()
178
+ // .filter(e -> e.getResults() != null).map(e ->
179
+ // e.getResults().getSchematronOutput()).collect(Collectors.toList()));
180
+
181
+ return xvrlResult ;
182
+ }
183
+
160
184
private static List <XmlError > convertErrors (final Collection <XMLSyntaxError > errors ) {
161
185
// noinspection unchecked
162
186
return (List <XmlError >) (List <?>) errors ;
163
187
}
164
188
189
+ private static List <XmlError > convertErrorsFromXVRLDetections (final Collection <XVRLDetection > errors ) {
190
+ List <XmlError > xmlErrorList = new ArrayList <>();
191
+ errors .forEach (xvrlDetection -> {
192
+ XmlError xmlError = new XmlErrorImpl (xvrlDetection );
193
+ xmlErrorList .add (xmlError );
194
+ });
195
+ return xmlErrorList ;
196
+ }
197
+
165
198
}
0 commit comments