-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send severityLevel to the Content Validator
-SITE-3015 Ref Val / Content Val: Suport Content validation process limiting using severityLevel
- Loading branch information
Showing
3 changed files
with
76 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 72 additions & 61 deletions
133
src/main/java/org/sitenv/referenceccda/validators/content/ReferenceContentValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |