Skip to content

Commit

Permalink
MORE-350 extend confiuration for visibility values in observation fac…
Browse files Browse the repository at this point in the history
…tories
  • Loading branch information
Thomas Kurz committed Oct 6, 2023
1 parent 0bd7391 commit cdc7f3e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.redlink.more.studymanager.core.component.Observation;
import io.redlink.more.studymanager.core.exception.ConfigurationValidationException;
import io.redlink.more.studymanager.core.io.Visibility;
import io.redlink.more.studymanager.core.measurement.MeasurementSet;
import io.redlink.more.studymanager.core.properties.ObservationProperties;
import io.redlink.more.studymanager.core.sdk.MoreObservationSDK;
Expand All @@ -16,7 +17,12 @@ public Class<ObservationProperties> getPropertyClass() {

public abstract MeasurementSet getMeasurementSet();

@Deprecated
public Boolean getHidden() {
return true;
}

public Visibility getVisibility() {
return Visibility.DEFAULT;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.redlink.more.studymanager.core.io;

public class Visibility {

public static final Visibility DEFAULT = new Visibility(true, false);
boolean changeable;
boolean hiddenByDefault;

public Visibility() {
}

public Visibility(boolean changeable, boolean hiddenByDefault) {
this.changeable = changeable;
this.hiddenByDefault = hiddenByDefault;
}

public boolean isChangeable() {
return changeable;
}

public Visibility setChangeable(boolean changeable) {
this.changeable = changeable;
return this;
}

public boolean isHiddenByDefault() {
return hiddenByDefault;
}

public Visibility setHiddenByDefault(boolean hiddenByDefault) {
this.hiddenByDefault = hiddenByDefault;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import io.redlink.more.studymanager.core.component.Observation;
import io.redlink.more.studymanager.core.exception.ConfigurationValidationException;
import io.redlink.more.studymanager.core.factory.ObservationFactory;
import io.redlink.more.studymanager.core.io.Visibility;
import io.redlink.more.studymanager.core.measurement.MeasurementSet;
import io.redlink.more.studymanager.core.properties.ObservationProperties;
import io.redlink.more.studymanager.core.sdk.MoreObservationSDK;

public class ExternalObservationFactory<C extends Observation<P>, P extends ObservationProperties>
extends ObservationFactory<C, P> {

private static final Visibility visibility = new Visibility(false, true);

@Override
public String getId() {
return "external-observation";
Expand Down Expand Up @@ -39,4 +43,9 @@ public MeasurementSet getMeasurementSet() {
public Boolean getHidden() {
return false;
}

@Override
public Visibility getVisibility() {
return visibility;
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package io.redlink.more.studymanager.controller.studymanager;

import com.fasterxml.jackson.databind.JsonNode;
import io.redlink.more.studymanager.api.v1.model.ComponentFactoryDTO;
import io.redlink.more.studymanager.api.v1.model.ComponentFactoryMeasurementsInnerDTO;
import io.redlink.more.studymanager.api.v1.model.ValidationReportDTO;
import io.redlink.more.studymanager.api.v1.model.ValidationReportItemDTO;
import io.redlink.more.studymanager.api.v1.model.*;
import io.redlink.more.studymanager.api.v1.webservices.ComponentsApi;
import io.redlink.more.studymanager.core.exception.ApiCallException;
import io.redlink.more.studymanager.core.exception.ConfigurationValidationException;
import io.redlink.more.studymanager.core.factory.ActionFactory;
import io.redlink.more.studymanager.core.factory.ComponentFactory;
import io.redlink.more.studymanager.core.factory.ObservationFactory;
import io.redlink.more.studymanager.core.factory.TriggerFactory;
import io.redlink.more.studymanager.core.io.Visibility;
import io.redlink.more.studymanager.core.model.User;
import io.redlink.more.studymanager.core.properties.ComponentProperties;
import io.redlink.more.studymanager.core.webcomponent.WebComponent;
Expand Down Expand Up @@ -146,11 +144,18 @@ private ComponentFactoryDTO toComponentDTO(ComponentFactory factory) {
.description(factory.getDescription())
.hasWebComponent(factory.hasWebComponent());
if(ObservationFactory.class.isAssignableFrom(factory.getClass())) {
return c.hidden(((ObservationFactory) factory).getHidden());
c.hidden(((ObservationFactory) factory).getHidden());
c.visibility(toVisibilityDTO(((ObservationFactory) factory).getVisibility()));
}
return c;
}

private VisibilityDTO toVisibilityDTO(Visibility visibility) {
return new VisibilityDTO()
.changeable(visibility.isChangeable())
.hiddenByDefault(visibility.isHiddenByDefault());
}

private List<ComponentFactoryMeasurementsInnerDTO> getMeasurements(ComponentFactory factory) {
if(ObservationFactory.class.isAssignableFrom(factory.getClass())) {
return ((ObservationFactory) factory).getMeasurementSet().values()
Expand Down
10 changes: 10 additions & 0 deletions studymanager/src/main/resources/openapi/StudyManagerAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,16 @@ components:
type: boolean
hidden:
type: boolean
visibility:
$ref: '#/components/schemas/Visibility'

Visibility:
type: object
properties:
changeable:
type: boolean
hiddenByDefault:
type: boolean

ValidationReport:
type: object
Expand Down

0 comments on commit cdc7f3e

Please sign in to comment.