Skip to content

Commit

Permalink
Add severityLevel to JSON response
Browse files Browse the repository at this point in the history
-SITESITE-3013 - This flag can be used to determine whether the results
returned are 0 because there are no issues or because they were limited
by severityLevel
  • Loading branch information
drbgfc committed Jul 3, 2019
1 parent 5e62f96 commit 248052e
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 113 deletions.
231 changes: 120 additions & 111 deletions src/main/java/org/sitenv/referenceccda/dto/ValidationResultsMetaData.java
Original file line number Diff line number Diff line change
@@ -1,111 +1,120 @@
package org.sitenv.referenceccda.dto;

import org.sitenv.referenceccda.validators.enums.ValidationResultType;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;


public class ValidationResultsMetaData {
private String ccdaDocumentType;
private String ccdaVersion;
private String objectiveProvided;
private boolean serviceError;
private String serviceErrorMessage;
private String ccdaFileName;
private String ccdaFileContents;
private final Map<String, AtomicInteger> errorCounts = new LinkedHashMap<String, AtomicInteger>();
private List<ResultMetaData> resultMetaData;
private int vocabularyValidationConfigurationsCount;

public ValidationResultsMetaData() {
for (ValidationResultType resultType : ValidationResultType.values()) {
errorCounts.put(resultType.getTypePrettyName(), new AtomicInteger(0));
}
}

public String getCcdaDocumentType() {
return ccdaDocumentType;
}

public void setCcdaDocumentType(String ccdaDocumentType) {
this.ccdaDocumentType = ccdaDocumentType;
}

public void setCcdaVersion(String ccdaVersion) {
this.ccdaVersion = ccdaVersion;
}

public String getCcdaVersion() {
return ccdaVersion;
}

public String getObjectiveProvided() {
return objectiveProvided;
}


public void setObjectiveProvided(String objectiveProvided) {
this.objectiveProvided = objectiveProvided;
}


public boolean isServiceError() {
return serviceError;
}

public void setServiceError(boolean serviceError) {
this.serviceError = serviceError;
}

public String getServiceErrorMessage() {
return serviceErrorMessage;
}

public void setServiceErrorMessage(String serviceErrorMessage) {
this.serviceErrorMessage = serviceErrorMessage;
}

public List<ResultMetaData> getResultMetaData() {
resultMetaData = new ArrayList<ResultMetaData>();
for (Map.Entry<String, AtomicInteger> entry : errorCounts.entrySet()) {
resultMetaData.add(new ResultMetaData(entry.getKey(), entry.getValue().intValue()));
}
return resultMetaData;
}

public String getCcdaFileName() {
return ccdaFileName;
}

public void setCcdaFileName(String ccdaFileName) {
this.ccdaFileName = ccdaFileName;
}

public String getCcdaFileContents() {
return ccdaFileContents;
}

public void setCcdaFileContents(String ccdaFileContents) {
this.ccdaFileContents = ccdaFileContents;
}

public void addCount(ValidationResultType resultType) {
if (errorCounts.containsKey(resultType.getTypePrettyName())) {
errorCounts.get(resultType.getTypePrettyName()).addAndGet(1);
} else {
errorCounts.put(resultType.getTypePrettyName(), new AtomicInteger(1));
}
}

public int getVocabularyValidationConfigurationsCount() {
return vocabularyValidationConfigurationsCount;
}

public void setVocabularyValidationConfigurationsCount(int vocabularyValidationConfigurationsCount) {
this.vocabularyValidationConfigurationsCount = vocabularyValidationConfigurationsCount;
}
}
package org.sitenv.referenceccda.dto;

import org.sitenv.referenceccda.validators.enums.ValidationResultType;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;


public class ValidationResultsMetaData {
private String ccdaDocumentType;
private String ccdaVersion;
private String objectiveProvided;
private boolean serviceError;
private String serviceErrorMessage;
private String ccdaFileName;
private String ccdaFileContents;
private final Map<String, AtomicInteger> errorCounts = new LinkedHashMap<String, AtomicInteger>();
private List<ResultMetaData> resultMetaData;
private int vocabularyValidationConfigurationsCount;
private String severityLevel;

public ValidationResultsMetaData() {
for (ValidationResultType resultType : ValidationResultType.values()) {
errorCounts.put(resultType.getTypePrettyName(), new AtomicInteger(0));
}
}

public String getCcdaDocumentType() {
return ccdaDocumentType;
}

public void setCcdaDocumentType(String ccdaDocumentType) {
this.ccdaDocumentType = ccdaDocumentType;
}

public void setCcdaVersion(String ccdaVersion) {
this.ccdaVersion = ccdaVersion;
}

public String getCcdaVersion() {
return ccdaVersion;
}

public String getObjectiveProvided() {
return objectiveProvided;
}


public void setObjectiveProvided(String objectiveProvided) {
this.objectiveProvided = objectiveProvided;
}


public boolean isServiceError() {
return serviceError;
}

public void setServiceError(boolean serviceError) {
this.serviceError = serviceError;
}

public String getServiceErrorMessage() {
return serviceErrorMessage;
}

public void setServiceErrorMessage(String serviceErrorMessage) {
this.serviceErrorMessage = serviceErrorMessage;
}

public List<ResultMetaData> getResultMetaData() {
resultMetaData = new ArrayList<ResultMetaData>();
for (Map.Entry<String, AtomicInteger> entry : errorCounts.entrySet()) {
resultMetaData.add(new ResultMetaData(entry.getKey(), entry.getValue().intValue()));
}
return resultMetaData;
}

public String getCcdaFileName() {
return ccdaFileName;
}

public void setCcdaFileName(String ccdaFileName) {
this.ccdaFileName = ccdaFileName;
}

public String getCcdaFileContents() {
return ccdaFileContents;
}

public void setCcdaFileContents(String ccdaFileContents) {
this.ccdaFileContents = ccdaFileContents;
}

public void addCount(ValidationResultType resultType) {
if (errorCounts.containsKey(resultType.getTypePrettyName())) {
errorCounts.get(resultType.getTypePrettyName()).addAndGet(1);
} else {
errorCounts.put(resultType.getTypePrettyName(), new AtomicInteger(1));
}
}

public int getVocabularyValidationConfigurationsCount() {
return vocabularyValidationConfigurationsCount;
}

public void setVocabularyValidationConfigurationsCount(int vocabularyValidationConfigurationsCount) {
this.vocabularyValidationConfigurationsCount = vocabularyValidationConfigurationsCount;
}

public String getSeverityLevel() {
return severityLevel;
}

public void setSeverityLevel(String severityLevel) {
this.severityLevel = severityLevel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private ValidationResultsDto validateCCDAImplementation(String validationObjecti
try {
validatorResults = runValidators(validationObjective, referenceFileName, ccdaFile, vocabularyConfig,
severityLevel);
resultsMetaData = buildValidationMedata(validatorResults, validationObjective);
resultsMetaData = buildValidationMedata(validatorResults, validationObjective, severityLevel);
resultsMetaData.setCcdaFileName(ccdaFile.getOriginalFilename());
resultsMetaData.setCcdaFileContents(new String(ccdaFile.getBytes()));
} catch (IOException ioE) {
Expand Down Expand Up @@ -218,14 +218,15 @@ private List<RefCCDAValidationResult> doContentValidation(String validationObjec
}

private ValidationResultsMetaData buildValidationMedata(List<RefCCDAValidationResult> validatorResults,
String validationObjective) {
String validationObjective, SeverityLevel severityLevel) {
ValidationResultsMetaData resultsMetaData = new ValidationResultsMetaData();
for (RefCCDAValidationResult result : validatorResults) {
resultsMetaData.addCount(result.getType());
}
resultsMetaData.setObjectiveProvided(validationObjective);
resultsMetaData.setCcdaDocumentType(referenceCCDAValidator.getCcdaDocumentType());
resultsMetaData.setCcdaVersion(referenceCCDAValidator.getCcdaVersion().getVersion());
resultsMetaData.setSeverityLevel(severityLevel.name());
GlobalCodeValidatorResults globalCodeValidatorResults = vocabularyCCDAValidator.getGlobalCodeValidatorResults();
resultsMetaData.setVocabularyValidationConfigurationsCount(
globalCodeValidatorResults.getVocabularyValidationConfigurationsCount());
Expand Down

0 comments on commit 248052e

Please sign in to comment.