making changes to accommodate front end code (#286)

* making changes to accomodate front end code

* removing unescessary comments

* kotlin don't take no nulls
This commit is contained in:
Mark Iantorno 2020-07-29 15:28:53 -04:00 committed by GitHub
parent a154f454b4
commit 9c044e5bb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 87 deletions

View File

@ -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 +
'}';
}
}

View File

@ -19,6 +19,14 @@ public class FileInfo {
return fileName; return fileName;
} }
public FileInfo() {}
public FileInfo(String fileName, String fileContent, String fileType) {
this.fileName = fileName;
this.fileContent = fileContent;
this.fileType = fileType;
}
@JsonProperty("fileName") @JsonProperty("fileName")
public FileInfo setFileName(String fileName) { public FileInfo setFileName(String fileName) {
this.fileName = fileName; this.fileName = fileName;
@ -37,8 +45,8 @@ public class FileInfo {
} }
@JsonProperty("fileType") @JsonProperty("fileType")
public Manager.FhirFormat getFileType() { public String getFileType() {
return Manager.FhirFormat.JSON; return fileType;
} }
@JsonProperty("fileType") @JsonProperty("fileType")
@ -46,4 +54,13 @@ public class FileInfo {
this.fileType = fileType; this.fileType = fileType;
return this; return this;
} }
@Override
public String toString() {
return "FileInfo{" +
"fileName='" + fileName + '\'' +
", fileContent='" + fileContent + '\'' +
", fileType='" + fileType + '\'' +
'}';
}
} }

View File

@ -8,6 +8,13 @@ public class ValidationIssue {
@JsonProperty("details") @JsonProperty("details")
private String details; private String details;
public ValidationIssue() {}
public ValidationIssue(String severity, String details) {
this.severity = severity;
this.details = details;
}
@JsonProperty("severity") @JsonProperty("severity")
public String getSeverity() { public String getSeverity() {
return severity; return severity;

View File

@ -13,6 +13,13 @@ public class ValidationOutcome {
@JsonProperty("issues") @JsonProperty("issues")
private List<ValidationIssue> issues = new ArrayList<>(); private List<ValidationIssue> issues = new ArrayList<>();
public ValidationOutcome() {}
public ValidationOutcome(FileInfo fileInfo, List<ValidationIssue> issues) {
this.fileInfo = fileInfo;
this.issues = issues;
}
@JsonProperty("fileInfo") @JsonProperty("fileInfo")
public FileInfo getFileInfo() { public FileInfo getFileInfo() {
return fileInfo; return fileInfo;
@ -38,9 +45,7 @@ public class ValidationOutcome {
public ValidationOutcome addIssue(OperationOutcome.OperationOutcomeIssueComponent outcome) { public ValidationOutcome addIssue(OperationOutcome.OperationOutcomeIssueComponent outcome) {
String text = outcome.getDetails().getText(); String text = outcome.getDetails().getText();
text.replace("\'", "\""); text.replace("\'", "\"");
issues.add(new ValidationIssue() issues.add(new ValidationIssue(outcome.getSeverity().getDisplay(), outcome.getDetails().getText()));
.setSeverity(outcome.getSeverity().getDisplay())
.setDetails(outcome.getDetails().getText()));
return this; return this;
} }

View File

@ -18,6 +18,13 @@ public class ValidationRequest {
return cliContext; return cliContext;
} }
public ValidationRequest() {}
public ValidationRequest(CliContext cliContext, List<FileInfo> filesToValidate) {
this.cliContext = cliContext;
this.filesToValidate = filesToValidate;
}
@JsonProperty("cliContext") @JsonProperty("cliContext")
public ValidationRequest setCliContext(CliContext cliContext) { public ValidationRequest setCliContext(CliContext cliContext) {
this.cliContext = cliContext; this.cliContext = cliContext;

View File

@ -10,6 +10,12 @@ public class ValidationResponse {
@JsonProperty("outcomes") @JsonProperty("outcomes")
public List<ValidationOutcome> outcomes = new ArrayList<>(); public List<ValidationOutcome> outcomes = new ArrayList<>();
public ValidationResponse() {}
public ValidationResponse(List<ValidationOutcome> outcomes) {
this.outcomes = outcomes;
}
@JsonProperty("outcomes") @JsonProperty("outcomes")
public List<ValidationOutcome> getOutcomes() { public List<ValidationOutcome> getOutcomes() {
return outcomes; return outcomes;

View File

@ -21,6 +21,14 @@ import java.util.Set;
public class ValidationService { 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 { public static ValidationResponse validateSources(ValidationRequest request, ValidationEngine validator) throws Exception {
if (request.getCliContext().getProfiles().size() > 0) { if (request.getCliContext().getProfiles().size() > 0) {
System.out.println(" .. validate " + request.listSourceFiles() + " against " + request.getCliContext().getProfiles().toString()); System.out.println(" .. validate " + request.listSourceFiles() + " against " + request.getCliContext().getProfiles().toString());
@ -31,12 +39,12 @@ public class ValidationService {
ValidationResponse response = new ValidationResponse(); ValidationResponse response = new ValidationResponse();
for (FileInfo fp : request.getFilesToValidate()) { 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()); request.getCliContext().getProfiles());
ValidationOutcome outcome = new ValidationOutcome(); ValidationOutcome outcome = new ValidationOutcome();
// Need to set file content to null as server can't handle json in json // Need to set file content to null as server can't handle json in json
fp.setFileContent(null); //fp.setFileContent(null);
outcome.setFileInfo(fp); outcome.setFileInfo(fp);
operationOutcome.getIssue().forEach(outcome::addIssue); operationOutcome.getIssue().forEach(outcome::addIssue);
response.addOutcome(outcome); response.addOutcome(outcome);