Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ documentation.

The list of available profiles is available at
[[server]/gazelle/validation/profiles](https://test.ahdis.ch/matchboxv3/gazelle/validation/profiles), and the
validation request is sent to `POST [server]/gazelle/validation/validate`.
validation request is sent to `POST [server]/gazelle/validation/v2/validate`.

To configure a Matchbox instance in the EVSClient, the following actions shall be done:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import ch.ahdis.matchbox.validation.gazelle.models.metadata.Service;
import ch.ahdis.matchbox.validation.gazelle.models.validation.*;

import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.slf4j.Logger;
Expand Down Expand Up @@ -47,7 +46,7 @@ public class GazelleValidationWs {
*/
private static final String METADATA_PATH = "/metadata";
private static final String PROFILES_PATH = "/validation/profiles";
private static final String VALIDATE_PATH = "/validation/validate";
private static final String VALIDATE_PATH = "/validation/v2/validate";

private final MatchboxEngineSupport matchboxEngineSupport;

Expand Down Expand Up @@ -112,6 +111,7 @@ public List<ValidationProfile> getProfiles() {
// PATCHed: filename contains the StructureDefinition title.
profile.setProfileName("%s (%s)".formatted(packageVersionResource.getFilename(), version));
profile.setDomain(packageVersionResource.getPackageVersion().getPackageId());
profile.setVersion(version);
profiles.add(profile);

// If the package is current, we also add it version-less
Expand All @@ -121,6 +121,7 @@ public List<ValidationProfile> getProfiles() {
// PATCHed: filename contains the StructureDefinition title.
profile2.setProfileName(packageVersionResource.getFilename());
profile2.setDomain(packageVersionResource.getPackageVersion().getPackageId());
profile2.setVersion(version);
profiles.add(profile2);
}
});
Expand All @@ -140,15 +141,16 @@ public ValidationReport postValidate(@RequestBody final ValidationRequest valida
final CliContext cliContext = new CliContext(this.baseCliContext);

final var report = new ValidationReport();
report.setValidationItems(new ArrayList<>(validationRequest.getValidationItems().size()));
report.setReports(new ArrayList<>(validationRequest.getValidationItems().size()));
report.setValidationItems(new ArrayList<>(validationRequest.getInputs().size()));
report.setReports(new ArrayList<>(validationRequest.getInputs().size()));
report.setDisclaimer("Matchbox disclaims");

String profileCanonical = validationRequest.getValidationProfileId();

// Response: create the validation method now, with the info we already have
final var method = new ValidationMethod();
method.setValidationProfileID(validationRequest.getValidationProfileId());
method.setValidationProfileName("FHIR " + validationRequest.getValidationProfileId());
method.setValidationServiceName("Matchbox");
method.setValidationServiceVersion(VersionUtil.getVersion());
report.setValidationMethod(method);
Expand Down Expand Up @@ -212,10 +214,10 @@ public ValidationReport postValidate(@RequestBody final ValidationRequest valida
}

// Response: add the validation items (requests) to the response
report.getValidationItems().addAll(validationRequest.getValidationItems());
report.getValidationItems().addAll(validationRequest.getInputs());

// Perform the validation of all items with the given engine
for (final var item : validationRequest.getValidationItems()) {
for (final var item : validationRequest.getInputs()) {
try {
report.addValidationSubReport(this.validateItem(engine, item, profileCanonical));
} catch (final Exception exception) {
Expand Down Expand Up @@ -257,7 +259,7 @@ MatchboxEngine getEngine(final String canonicalWithVersion,
* Performs the validation of the given item with the given engine.
*/
ValidationSubReport validateItem(final MatchboxEngine engine,
final ValidationItem item,
final Input item,
final String profile) {
final String content = new String(item.getContent(), StandardCharsets.UTF_8);
final var encoding = EncodingEnum.detectEncoding(content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,40 @@
* The model of a validation item.
* <p>
* Copy-pasted from
* https://gitlab.inria.fr/gazelle/library/validation-service-api/-/blob/master/validation-api/src/main/java/net/ihe/gazelle/validation/api/domain/request/structure/ValidationItem.java?ref_type=heads
* https://gitlab.inria.fr/gazelle/public/core/validation-service-api/-/blob/2.0.0/validation-v2-api/src/main/java/net/ihe/gazelle/validation/v2/api/business/Input.java?ref_type=tags
*
* @author Achraf Achkari
* @author Quentin Ligier
**/
@JsonRootName(value = "validationItem")
public class ValidationItem {
public class Input {

@JsonProperty(value = "id")
private String id;

@JsonProperty(value = "itemId")
private String itemId;

@JsonProperty(value = "content")
private byte[] content;

@JsonProperty(value = "role")
private String role;

@JsonProperty(value = "location")
private String location;

public String getId() {
return this.id;
}

public Input setId(final String id) {
this.id = id;
return this;
}

public String getItemId() {
return itemId;
}

public ValidationItem setItemId(String itemId) {
public Input setItemId(String itemId) {
this.itemId = itemId;
return this;
}
Expand All @@ -43,25 +52,16 @@ public byte[] getContent() {
return content;
}

public ValidationItem setContent(byte[] content) {
public Input setContent(byte[] content) {
this.content = content;
return this;
}

public String getRole() {
return role;
}

public ValidationItem setRole(String role) {
this.role = role;
return this;
}

public String getLocation() {
return location;
}

public ValidationItem setLocation(String location) {
public Input setLocation(String location) {
this.location = location;
return this;
}
Expand All @@ -81,16 +81,6 @@ public boolean isLocationValid(){
return location == null || isURLValid(location);
}

@JsonIgnore
public boolean isRoleValid(){
return role == null || !role.isBlank();
}

@JsonIgnore
public boolean isRoleDefined(){
return role != null && !role.isBlank();
}

@JsonIgnore
public boolean isURLValid(String url) {
try {
Expand All @@ -103,14 +93,14 @@ public boolean isURLValid(String url) {

@JsonIgnore
public boolean isValid(){
return isContentValid() && isItemIdValid() && isLocationValid() && isRoleValid();
return isContentValid() && isItemIdValid() && isLocationValid();
}

public static ValidationItem clone(ValidationItem validationItem) {
return new ValidationItem()
.setItemId(validationItem.getItemId())
.setContent(validationItem.getContent() != null ? validationItem.getContent().clone():null)
.setRole(validationItem.getRole())
.setLocation(validationItem.getLocation());
public static Input clone(Input input) {
return new Input()
.setId(input.getId())
.setItemId(input.getItemId())
.setContent(input.getContent() != null ? input.getContent().clone():null)
.setLocation(input.getLocation());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package ch.ahdis.matchbox.validation.gazelle.models.validation;

public class SupportedInput {

private String id;
private String label;
private boolean required = true;

/**
* Default constructor.
*/
public SupportedInput() {
// Default constructor
}

/**
* Gets the id of the input.
*
* @return the id
*/
public String getId() {
return id;
}

/**
* Sets the id of the input.
*
* @param id the id
*
* @return the current SupportedInput instance
*/
public SupportedInput setId(String id) {
this.id = id;
return this;
}

/**
* Gets the human-readable label of the input.
*
* @return the label
*/
public String getLabel() {
return label;
}

/**
* Sets the human-readable label of the input.
*
* @param label the label
*
* @return the current SupportedInput instance
*/
public SupportedInput setLabel(String label) {
this.label = label;
return this;
}

/**
* Indicates whether the input is required.
*
* @return true if the input is required, false if optional.
*/
public boolean isRequired() {
return required;
}

/**
* Sets whether the input is required (true by default).
*
* @param required true if the input is required, false if optional.
*
* @return the current SupportedInput instance
*/
public SupportedInput setRequired(boolean required) {
this.required = required;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ public class ValidationCounters {
private Integer numberOfFailedWithWarnings = 0;
private Integer numberOfFailedWithErrors = 0;
private Integer numberOfUnexpectedErrors = 0;
private Integer numberOfUndefined = 0;


public ValidationCounters() {
}

public Integer getNumberOfUndefined() {
return numberOfUndefined;
}

public ValidationCounters setNumberOfUndefined(Integer numberOfUndefined) {
this.numberOfUndefined = numberOfUndefined;
return this;
}


public Integer getNumberOfUnexpectedErrors() {
return this.numberOfUnexpectedErrors;
}
Expand Down Expand Up @@ -89,12 +101,18 @@ public void incrementUnexpectedErrors() {
this.numberOfUnexpectedErrors = this.numberOfUnexpectedErrors + 1;
}

public void incrementUndefined() {
Integer var1 = this.numberOfUndefined;
this.numberOfUndefined = this.numberOfUndefined + 1;
}

public void addNumbersFromSubCounters(ValidationCounters subCounters) {
this.numberOfAssertions = this.numberOfAssertions + subCounters.getNumberOfAssertions();
this.numberOfFailedWithInfos = this.numberOfFailedWithInfos + subCounters.getNumberOfFailedWithInfos();
this.numberOfFailedWithWarnings = this.numberOfFailedWithWarnings + subCounters.getNumberOfFailedWithWarnings();
this.numberOfFailedWithErrors = this.numberOfFailedWithErrors + subCounters.getNumberOfFailedWithErrors();
this.numberOfUnexpectedErrors = this.numberOfUnexpectedErrors + subCounters.getNumberOfUnexpectedErrors();
this.numberOfUndefined = this.numberOfUndefined + subCounters.getNumberOfUndefined();
}

@JsonIgnore
Expand Down Expand Up @@ -142,14 +160,16 @@ public boolean equals(Object o) {
&& Objects.equals(this.numberOfFailedWithInfos, that.numberOfFailedWithInfos)
&& Objects.equals(this.numberOfFailedWithWarnings, that.numberOfFailedWithWarnings)
&& Objects.equals(this.numberOfFailedWithErrors, that.numberOfFailedWithErrors)
&& Objects.equals(this.numberOfUnexpectedErrors, that.numberOfUnexpectedErrors);
&& Objects.equals(this.numberOfUnexpectedErrors, that.numberOfUnexpectedErrors)
&& Objects.equals(this.numberOfUndefined, that.numberOfUndefined);
}
}

public int hashCode() {
return Objects.hash(
new Object[]{
this.numberOfAssertions, this.numberOfFailedWithInfos, this.numberOfFailedWithWarnings, this.numberOfFailedWithErrors, this.numberOfUnexpectedErrors
this.numberOfAssertions, this.numberOfFailedWithInfos, this.numberOfFailedWithWarnings,
this.numberOfFailedWithErrors, this.numberOfUnexpectedErrors, this.numberOfUndefined
}
);
}
Expand All @@ -162,6 +182,7 @@ static ValidationCounters clone(ValidationCounters validationCounters) {
.setNumberOfFailedWithInfos(validationCounters.getNumberOfFailedWithInfos())
.setNumberOfFailedWithWarnings(validationCounters.getNumberOfFailedWithWarnings())
.setNumberOfFailedWithErrors(validationCounters.getNumberOfFailedWithErrors())
.setNumberOfUnexpectedErrors(validationCounters.getNumberOfUnexpectedErrors());
.setNumberOfUnexpectedErrors(validationCounters.getNumberOfUnexpectedErrors())
.setNumberOfUndefined(validationCounters.getNumberOfUndefined());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ValidationMethod {
private String validationServiceVersion;
private String validationProfileID;
private String validationProfileVersion;
private String validationProfileName;

public ValidationMethod() {
}
Expand Down Expand Up @@ -52,6 +53,15 @@ public ValidationMethod setValidationProfileVersion(String validationProfileVers
return this;
}

public String getValidationProfileName() {
return this.validationProfileName;
}

public ValidationMethod setValidationProfileName(final String validationProfileName) {
this.validationProfileName = validationProfileName;
return this;
}

@JsonIgnore
public boolean isValidationServiceNameValid() {
return this.validationServiceName != null && !this.validationServiceName.isBlank();
Expand Down Expand Up @@ -87,6 +97,7 @@ static ValidationMethod clone(ValidationMethod validationMethod) {
.setValidationServiceName(validationMethod.getValidationServiceName())
.setValidationServiceVersion(validationMethod.getValidationServiceVersion())
.setValidationProfileID(validationMethod.getValidationProfileID())
.setValidationProfileVersion(validationMethod.getValidationProfileVersion());
.setValidationProfileVersion(validationMethod.getValidationProfileVersion())
.setValidationProfileName(validationMethod.getValidationProfileName());
}
}
Loading