diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContextTest.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContextTest.java deleted file mode 100644 index 4275ad123..000000000 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContextTest.java +++ /dev/null @@ -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 + - '}'; - } -} \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/FileInfo.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/FileInfo.java index 6e5810d06..c44545c1b 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/FileInfo.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/FileInfo.java @@ -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 + '\'' + + '}'; + } } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationIssue.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationIssue.java index d29a54595..011f8a335 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationIssue.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationIssue.java @@ -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; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java index 582ffc8b1..6af689124 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java @@ -13,6 +13,13 @@ public class ValidationOutcome { @JsonProperty("issues") private List issues = new ArrayList<>(); + public ValidationOutcome() {} + + public ValidationOutcome(FileInfo fileInfo, List 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; } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationRequest.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationRequest.java index 2ed14f2d1..bf0ee6ed7 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationRequest.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationRequest.java @@ -18,6 +18,13 @@ public class ValidationRequest { return cliContext; } + public ValidationRequest() {} + + public ValidationRequest(CliContext cliContext, List filesToValidate) { + this.cliContext = cliContext; + this.filesToValidate = filesToValidate; + } + @JsonProperty("cliContext") public ValidationRequest setCliContext(CliContext cliContext) { this.cliContext = cliContext; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationResponse.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationResponse.java index 4c97a8984..c509e7c7e 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationResponse.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationResponse.java @@ -10,6 +10,12 @@ public class ValidationResponse { @JsonProperty("outcomes") public List outcomes = new ArrayList<>(); + public ValidationResponse() {} + + public ValidationResponse(List outcomes) { + this.outcomes = outcomes; + } + @JsonProperty("outcomes") public List getOutcomes() { return outcomes; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java index 17ba71877..08c9e4741 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java @@ -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);