Skip to content

Commit

Permalink
Send severityLevel to the Content Validator
Browse files Browse the repository at this point in the history
-SITE-3015 Ref Val / Content Val: Suport Content validation process
limiting using severityLevel
  • Loading branch information
drbgfc committed Jul 17, 2019
1 parent 248052e commit a4627d1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 65 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<code.validator.version>1.0.22-SNAPSHOT</code.validator.version>
<content.validator.version>1.0.19</content.validator.version>
<content.validator.version>1.0.20-SNAPSHOT</content.validator.version>
<!-- MDHT properties -->
<mdht.models.version>3.0.8.20180531</mdht.models.version>
<mdht.plugins.version>3.0.0.201805310501</mdht.plugins.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private List<RefCCDAValidationResult> runValidators(String validationObjective,
}
if (objectiveAllowsContentValidation(validationObjective)) {
List<RefCCDAValidationResult> contentResults = doContentValidation(validationObjective,
referenceFileName, ccdaFileContents);
referenceFileName, ccdaFileContents, severityLevel);
if (contentResults != null && !contentResults.isEmpty()) {
logger.info("Adding Content results");
validatorResults.addAll(contentResults);
Expand Down Expand Up @@ -212,9 +212,9 @@ private ArrayList<RefCCDAValidationResult> doVocabularyValidation(String validat
}

private List<RefCCDAValidationResult> doContentValidation(String validationObjective, String referenceFileName,
String ccdaFileContents) throws SAXException {
String ccdaFileContents, SeverityLevel severityLevel) throws SAXException {
logger.info("Attempting Content validation...");
return goldMatchingValidator.validateFile(validationObjective, referenceFileName, ccdaFileContents);
return goldMatchingValidator.validateFile(validationObjective, referenceFileName, ccdaFileContents, severityLevel);
}

private ValidationResultsMetaData buildValidationMedata(List<RefCCDAValidationResult> validatorResults,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,61 +1,72 @@
package org.sitenv.referenceccda.validators.content;

import java.util.ArrayList;
import java.util.List;

import org.sitenv.contentvalidator.dto.ContentValidationResult;
import org.sitenv.contentvalidator.service.ContentValidatorService;
import org.sitenv.referenceccda.validators.BaseCCDAValidator;
import org.sitenv.referenceccda.validators.CCDAValidator;
import org.sitenv.referenceccda.validators.RefCCDAValidationResult;
import org.sitenv.referenceccda.validators.enums.ValidationResultType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.xml.sax.SAXException;


/**
* Created by Brian on 8/15/2016.
*/
@Component
public class ReferenceContentValidator extends BaseCCDAValidator implements CCDAValidator {
private ContentValidatorService contentValidatorService;

@Autowired
public ReferenceContentValidator(ContentValidatorService contentValidatorService) {
this.contentValidatorService = contentValidatorService;
}

@Override
public ArrayList<RefCCDAValidationResult> validateFile(String validationObjective, String referenceFileName, String ccdaFile) throws SAXException {
ArrayList<RefCCDAValidationResult> results = null;
if (ccdaFile != null) {
results = doValidation(validationObjective, referenceFileName, ccdaFile);
}
return results;
}

private ArrayList<RefCCDAValidationResult> doValidation(String validationObjective, String referenceFileName, String ccdaFile) throws SAXException {
List<ContentValidationResult> validationResults = contentValidatorService.validate(validationObjective, referenceFileName, ccdaFile);
ArrayList<RefCCDAValidationResult> results = new ArrayList<>();
for (ContentValidationResult result : validationResults) {
results.add(createValidationResult(result));
}
return results;
}

private RefCCDAValidationResult createValidationResult(ContentValidationResult result) {
ValidationResultType type;
switch(result.getContentValidationResultLevel()){
case ERROR: type = ValidationResultType.REF_CCDA_ERROR;
break;
case WARNING: type = ValidationResultType.REF_CCDA_WARN;
break;
default: type = ValidationResultType.REF_CCDA_INFO;
break;
}

return new RefCCDAValidationResult.RefCCDAValidationResultBuilder(result.getMessage(), null, null, type, "0")
.build();
}
}
package org.sitenv.referenceccda.validators.content;

import java.util.ArrayList;
import java.util.List;

import org.sitenv.contentvalidator.dto.ContentValidationResult;
import org.sitenv.contentvalidator.service.ContentValidatorService;
import org.sitenv.referenceccda.validators.BaseCCDAValidator;
import org.sitenv.referenceccda.validators.CCDAValidator;
import org.sitenv.referenceccda.validators.RefCCDAValidationResult;
import org.sitenv.referenceccda.validators.enums.ValidationResultType;
import org.sitenv.vocabularies.constants.VocabularyConstants.SeverityLevel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.xml.sax.SAXException;


/**
* Created by Brian on 8/15/2016.
*/
@Component
public class ReferenceContentValidator extends BaseCCDAValidator implements CCDAValidator {
private ContentValidatorService contentValidatorService;

@Autowired
public ReferenceContentValidator(ContentValidatorService contentValidatorService) {
this.contentValidatorService = contentValidatorService;
}

@Override
public ArrayList<RefCCDAValidationResult> validateFile(String validationObjective, String referenceFileName,
String ccdaFile) throws SAXException {
return validateFile(validationObjective, referenceFileName, ccdaFile, SeverityLevel.INFO);
}

public ArrayList<RefCCDAValidationResult> validateFile(String validationObjective, String referenceFileName,
String ccdaFile, SeverityLevel severityLevel) throws SAXException {
ArrayList<RefCCDAValidationResult> results = null;
if (ccdaFile != null) {
results = doValidation(validationObjective, referenceFileName, ccdaFile, severityLevel);
}
return results;
}

private ArrayList<RefCCDAValidationResult> doValidation(String validationObjective, String referenceFileName,
String ccdaFile, SeverityLevel severityLevel) throws SAXException {
org.sitenv.contentvalidator.dto.enums.SeverityLevel userSeverityLevelForContentValidation =
org.sitenv.contentvalidator.dto.enums.SeverityLevel.valueOf(severityLevel.name());
List<ContentValidationResult> validationResults = contentValidatorService.validate(validationObjective,
referenceFileName, ccdaFile, userSeverityLevelForContentValidation);
ArrayList<RefCCDAValidationResult> results = new ArrayList<>();
for (ContentValidationResult result : validationResults) {
results.add(createValidationResult(result));
}
return results;
}

private RefCCDAValidationResult createValidationResult(ContentValidationResult result) {
ValidationResultType type;
switch(result.getContentValidationResultLevel()){
case ERROR: type = ValidationResultType.REF_CCDA_ERROR;
break;
case WARNING: type = ValidationResultType.REF_CCDA_WARN;
break;
default: type = ValidationResultType.REF_CCDA_INFO;
break;
}

return new RefCCDAValidationResult.RefCCDAValidationResultBuilder(result.getMessage(), null, null, type, "0")
.build();
}
}

0 comments on commit a4627d1

Please sign in to comment.