Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core
This commit is contained in:
commit
4995134716
|
@ -1,80 +0,0 @@
|
|||
package org.hl7.fhir.validation.cli.model;
|
||||
|
||||
/**
|
||||
* A POJO for storing the flags/values for the CLI validator.
|
||||
*/
|
||||
public class CliContextTest {
|
||||
|
||||
private boolean doNative = false;
|
||||
private boolean anyExtensionsAllowed = true;
|
||||
private boolean hintAboutNonMustSupport = false;
|
||||
private boolean recursive = false;
|
||||
private boolean doDebug = false;
|
||||
private boolean assumeValidRestReferences = false;
|
||||
|
||||
public boolean isDoNative() {
|
||||
return doNative;
|
||||
}
|
||||
|
||||
public CliContextTest setDoNative(boolean doNative) {
|
||||
this.doNative = doNative;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAnyExtensionsAllowed() {
|
||||
return anyExtensionsAllowed;
|
||||
}
|
||||
|
||||
public CliContextTest setAnyExtensionsAllowed(boolean anyExtensionsAllowed) {
|
||||
this.anyExtensionsAllowed = anyExtensionsAllowed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isHintAboutNonMustSupport() {
|
||||
return hintAboutNonMustSupport;
|
||||
}
|
||||
|
||||
public CliContextTest setHintAboutNonMustSupport(boolean hintAboutNonMustSupport) {
|
||||
this.hintAboutNonMustSupport = hintAboutNonMustSupport;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isRecursive() {
|
||||
return recursive;
|
||||
}
|
||||
|
||||
public CliContextTest setRecursive(boolean recursive) {
|
||||
this.recursive = recursive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDoDebug() {
|
||||
return doDebug;
|
||||
}
|
||||
|
||||
public CliContextTest setDoDebug(boolean doDebug) {
|
||||
this.doDebug = doDebug;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAssumeValidRestReferences() {
|
||||
return assumeValidRestReferences;
|
||||
}
|
||||
|
||||
public CliContextTest setAssumeValidRestReferences(boolean assumeValidRestReferences) {
|
||||
this.assumeValidRestReferences = assumeValidRestReferences;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CliContext{" +
|
||||
", doNative=" + doNative +
|
||||
", anyExtensionsAllowed=" + anyExtensionsAllowed +
|
||||
", hintAboutNonMustSupport=" + hintAboutNonMustSupport +
|
||||
", recursive=" + recursive +
|
||||
", doDebug=" + doDebug +
|
||||
", assumeValidRestReferences=" + assumeValidRestReferences +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -19,6 +19,14 @@ public class FileInfo {
|
|||
return fileName;
|
||||
}
|
||||
|
||||
public FileInfo() {}
|
||||
|
||||
public FileInfo(String fileName, String fileContent, String fileType) {
|
||||
this.fileName = fileName;
|
||||
this.fileContent = fileContent;
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
@JsonProperty("fileName")
|
||||
public FileInfo setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
|
@ -37,8 +45,8 @@ public class FileInfo {
|
|||
}
|
||||
|
||||
@JsonProperty("fileType")
|
||||
public Manager.FhirFormat getFileType() {
|
||||
return Manager.FhirFormat.JSON;
|
||||
public String getFileType() {
|
||||
return fileType;
|
||||
}
|
||||
|
||||
@JsonProperty("fileType")
|
||||
|
@ -46,4 +54,13 @@ public class FileInfo {
|
|||
this.fileType = fileType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileInfo{" +
|
||||
"fileName='" + fileName + '\'' +
|
||||
", fileContent='" + fileContent + '\'' +
|
||||
", fileType='" + fileType + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -8,6 +8,13 @@ public class ValidationIssue {
|
|||
@JsonProperty("details")
|
||||
private String details;
|
||||
|
||||
public ValidationIssue() {}
|
||||
|
||||
public ValidationIssue(String severity, String details) {
|
||||
this.severity = severity;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
@JsonProperty("severity")
|
||||
public String getSeverity() {
|
||||
return severity;
|
||||
|
|
|
@ -13,6 +13,13 @@ public class ValidationOutcome {
|
|||
@JsonProperty("issues")
|
||||
private List<ValidationIssue> issues = new ArrayList<>();
|
||||
|
||||
public ValidationOutcome() {}
|
||||
|
||||
public ValidationOutcome(FileInfo fileInfo, List<ValidationIssue> issues) {
|
||||
this.fileInfo = fileInfo;
|
||||
this.issues = issues;
|
||||
}
|
||||
|
||||
@JsonProperty("fileInfo")
|
||||
public FileInfo getFileInfo() {
|
||||
return fileInfo;
|
||||
|
@ -38,9 +45,7 @@ public class ValidationOutcome {
|
|||
public ValidationOutcome addIssue(OperationOutcome.OperationOutcomeIssueComponent outcome) {
|
||||
String text = outcome.getDetails().getText();
|
||||
text.replace("\'", "\"");
|
||||
issues.add(new ValidationIssue()
|
||||
.setSeverity(outcome.getSeverity().getDisplay())
|
||||
.setDetails(outcome.getDetails().getText()));
|
||||
issues.add(new ValidationIssue(outcome.getSeverity().getDisplay(), outcome.getDetails().getText()));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,13 @@ public class ValidationRequest {
|
|||
return cliContext;
|
||||
}
|
||||
|
||||
public ValidationRequest() {}
|
||||
|
||||
public ValidationRequest(CliContext cliContext, List<FileInfo> filesToValidate) {
|
||||
this.cliContext = cliContext;
|
||||
this.filesToValidate = filesToValidate;
|
||||
}
|
||||
|
||||
@JsonProperty("cliContext")
|
||||
public ValidationRequest setCliContext(CliContext cliContext) {
|
||||
this.cliContext = cliContext;
|
||||
|
|
|
@ -10,6 +10,12 @@ public class ValidationResponse {
|
|||
@JsonProperty("outcomes")
|
||||
public List<ValidationOutcome> outcomes = new ArrayList<>();
|
||||
|
||||
public ValidationResponse() {}
|
||||
|
||||
public ValidationResponse(List<ValidationOutcome> outcomes) {
|
||||
this.outcomes = outcomes;
|
||||
}
|
||||
|
||||
@JsonProperty("outcomes")
|
||||
public List<ValidationOutcome> getOutcomes() {
|
||||
return outcomes;
|
||||
|
|
|
@ -21,6 +21,14 @@ import java.util.Set;
|
|||
|
||||
public class ValidationService {
|
||||
|
||||
/*
|
||||
* TEMPORARY METHOD
|
||||
*/
|
||||
public static void validateFileInfo(FileInfo f) {
|
||||
System.out.println("success");
|
||||
}
|
||||
|
||||
|
||||
public static ValidationResponse validateSources(ValidationRequest request, ValidationEngine validator) throws Exception {
|
||||
if (request.getCliContext().getProfiles().size() > 0) {
|
||||
System.out.println(" .. validate " + request.listSourceFiles() + " against " + request.getCliContext().getProfiles().toString());
|
||||
|
@ -31,12 +39,12 @@ public class ValidationService {
|
|||
|
||||
ValidationResponse response = new ValidationResponse();
|
||||
for (FileInfo fp : request.getFilesToValidate()) {
|
||||
OperationOutcome operationOutcome = validator.validate(fp.getFileContent().getBytes(), fp.getFileType(),
|
||||
OperationOutcome operationOutcome = validator.validate(fp.getFileContent().getBytes(), Manager.FhirFormat.getFhirFormat(fp.getFileType()),
|
||||
request.getCliContext().getProfiles());
|
||||
ValidationOutcome outcome = new ValidationOutcome();
|
||||
|
||||
// Need to set file content to null as server can't handle json in json
|
||||
fp.setFileContent(null);
|
||||
//fp.setFileContent(null);
|
||||
outcome.setFileInfo(fp);
|
||||
operationOutcome.getIssue().forEach(outcome::addIssue);
|
||||
response.addOutcome(outcome);
|
||||
|
|
Loading…
Reference in New Issue