Skip to content

Commit

Permalink
Merge pull request #348 from MORE-Platform/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
alireza-dhp authored Oct 17, 2024
2 parents 64e15c8 + c204f1c commit 234343d
Show file tree
Hide file tree
Showing 108 changed files with 2,241 additions and 490 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>17</java.version>
<spring-boot.version>3.3.1</spring-boot.version>
<testcontainers.version>1.19.8</testcontainers.version>
<spring-boot.version>3.3.3</spring-boot.version>
<testcontainers.version>1.20.1</testcontainers.version>

<docker.namespace>more-project</docker.namespace>

Expand Down Expand Up @@ -84,7 +84,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -408,7 +408,7 @@
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.13.4</version>
<version>8.14.3</version>
</dependency>
<dependency>
<groupId>com.google.firebase</groupId>
Expand Down
2 changes: 1 addition & 1 deletion studymanager-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
<version>2.0.16</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
package io.redlink.more.studymanager.core.component;

import io.redlink.more.studymanager.core.exception.ConfigurationValidationException;
import io.redlink.more.studymanager.core.io.TimeRange;
import io.redlink.more.studymanager.core.properties.ObservationProperties;
import io.redlink.more.studymanager.core.sdk.MoreObservationSDK;
import io.redlink.more.studymanager.core.ui.DataView;
import io.redlink.more.studymanager.core.ui.DataViewInfo;

public abstract class Observation<C extends ObservationProperties> extends Component<C> {

Expand All @@ -20,6 +23,29 @@ protected Observation(MoreObservationSDK sdk, C properties) throws Configuration
this.sdk = sdk;
}

/**
* Gets an array of DataViewInfo, which represents all possibilities to show this observation data.
*
* @return an array of DataViewInfo representing all possible views of the observation data
*/
public DataViewInfo[] listViews() {
return new DataViewInfo[0];
}

/**
* Retrieves a specific DataView based on the given parameters.
*
* @param viewName the name of the view to retrieve
* @param studyGroupId the ID of the study group for filter reasons
* @param participantId the ID of the participant for filter reasons
* @param timerange the time range for the data view for filter reasons
* @return the requested DataView, or null if not found
*/
public DataView getView(String viewName, Integer studyGroupId, Integer participantId, TimeRange timerange) {
return null;
}


@Override
public void activate() {
// no action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
package io.redlink.more.studymanager.core.exception;

import io.redlink.more.studymanager.core.validation.ConfigurationValidationReport;
import io.redlink.more.studymanager.core.validation.ValidationIssue;
import java.util.List;

public class ConfigurationValidationException extends RuntimeException {

private final ConfigurationValidationReport report;

public ConfigurationValidationException(ConfigurationValidationReport report) {
this.report = report;
}
Expand All @@ -24,4 +28,20 @@ public ConfigurationValidationReport getReport() {
public String getMessage() {
return report.toString();
}

public static ConfigurationValidationException of(ConfigurationValidationReport report) {
return new ConfigurationValidationException(report);
}

public static ConfigurationValidationException of(ValidationIssue issue) {
return of(ConfigurationValidationReport.of(issue));
}

public static ConfigurationValidationException of(List<ValidationIssue> issues) {
return of(ConfigurationValidationReport.of(issues));
}

public static ConfigurationValidationException ofError(String message) {
return of(ConfigurationValidationReport.ofError(message));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright LBI-DHP and/or licensed to LBI-DHP under one or more
* contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute
* for Digital Health and Prevention -- A research institute of the
* Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur
* Förderung der wissenschaftlichen Forschung).
* Licensed under the Elastic License 2.0.
*/
package io.redlink.more.studymanager.core.io;

import java.time.Instant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public record MeasurementSet(String id, Set<Measurement> values) {

public MeasurementSet {
if (id == null || values == null) {
throw new IllegalArgumentException("Is and values must not be null");
throw new IllegalArgumentException("Id and values must not be null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public Class<Integer> getValueType() {
}

@Override
public ValidationIssue validate(Integer integer) {
if(integer != null && (integer < getMin() || integer > getMax())) {
public ValidationIssue doValidate(Integer integer) {
if (integer != null && (integer < getMin() || integer > getMax())) {
return ValidationIssue.error(this, "Value must between " + getMin() + " and " + getMax());
}
return validationFunction != null ? validationFunction.apply(integer) : ValidationIssue.NONE;
return ValidationIssue.NONE;
}

public int getMin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@
*/
package io.redlink.more.studymanager.core.properties.model;

import io.redlink.more.studymanager.core.validation.ValidationIssue;

public class StringValue extends Value<String> {
public StringValue(String id) {
super(id);
}

@Override
protected ValidationIssue doValidate(String s) {
if (isRequired() && (s == null || s.trim().isEmpty())) {
return ValidationIssue.requiredMissing(this);
}
return super.doValidate(s);
}

@Override
public String getType() {
return "STRING";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,54 @@
import io.redlink.more.studymanager.core.exception.ValueNonNullException;
import io.redlink.more.studymanager.core.properties.ComponentProperties;
import io.redlink.more.studymanager.core.validation.ValidationIssue;

import java.util.function.Function;

public abstract class Value<T> {
private String id;
private final String id;
private String name;
private String description;
private T defaultValue;
private boolean required = false;
private boolean immutable = false;
protected Function<T, ValidationIssue> validationFunction = (T t) -> null;
private Function<T, ValidationIssue> validationFunction = (T t) -> ValidationIssue.NONE;

public Value(String id) {
this.id = id;
}

public ValidationIssue validate(T t) {
return validationFunction != null ? validationFunction.apply(t) : ValidationIssue.NONE;
public final ValidationIssue validate(T t) {
if (required) {
if (t == null) {
return ValidationIssue.requiredMissing(this);
}
}

final ValidationIssue subResult = doValidate(t);
if (subResult != null && subResult.getType() != ValidationIssue.Type.None) {
return subResult;
}

final ValidationIssue result = validationFunction.apply(t);
if (result == null) {
return ValidationIssue.NONE;
} else {
return result;
}
}

protected ValidationIssue doValidate(T t) {
return ValidationIssue.NONE;
}

public T getValue(ComponentProperties properties) {
if(properties.containsKey(id)) {
if (properties.containsKey(id)) {
try {
return getValueType().cast(properties.get(id));
} catch (ClassCastException e) {
throw new ValueCastException(this, getValueType());
}
} else {
if(required && defaultValue == null) {
if (required && defaultValue == null) {
throw new ValueNonNullException(this);
} else {
return defaultValue;
Expand All @@ -57,6 +76,7 @@ public T getValue(ComponentProperties properties) {
public String getId() {
return id;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
*/
package io.redlink.more.studymanager.core.sdk;

import io.redlink.more.studymanager.core.io.TimeRange;
import io.redlink.more.studymanager.core.properties.ObservationProperties;
import io.redlink.more.studymanager.core.ui.DataViewData;
import io.redlink.more.studymanager.core.ui.DataViewRow;
import io.redlink.more.studymanager.core.ui.ViewConfig;

import java.util.Map;
import java.util.Optional;
Expand All @@ -22,5 +26,7 @@ public interface MoreObservationSDK extends MorePlatformSDK {

void storeDataPoint(Integer participantId, String observationType, Map data);

DataViewData queryData(ViewConfig viewConfig, Integer studyGroupId, Integer participantId, TimeRange timerange);

int getObservationId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright LBI-DHP and/or licensed to LBI-DHP under one or more
* contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute
* for Digital Health and Prevention -- A research institute of the
* Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur
* Förderung der wissenschaftlichen Forschung).
* Licensed under the Elastic License 2.0.
*/
package io.redlink.more.studymanager.core.ui;

/**
* Represents a data view with information, chart type, and data.
*
* @param viewInfo the information about the data view
* @param chartType the type of chart to be displayed
* @param data the data to be displayed in the view
*/
public record DataView(
DataViewInfo viewInfo,
ChartType chartType,
DataViewData data
) {
/**
* Enumeration of possible chart types.
*/
public enum ChartType {
LINE,
BAR,
PIE
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright LBI-DHP and/or licensed to LBI-DHP under one or more
* contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute
* for Digital Health and Prevention -- A research institute of the
* Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur
* Förderung der wissenschaftlichen Forschung).
* Licensed under the Elastic License 2.0.
*/
package io.redlink.more.studymanager.core.ui;

import java.util.List;

/**
* Represents the data in a data view.
*
* @param labels the labels for the data
* @param rows the rows of data
*/
public record DataViewData(
List<String> labels,
List<DataViewRow> rows
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright LBI-DHP and/or licensed to LBI-DHP under one or more
* contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute
* for Digital Health and Prevention -- A research institute of the
* Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur
* Förderung der wissenschaftlichen Forschung).
* Licensed under the Elastic License 2.0.
*/
package io.redlink.more.studymanager.core.ui;

public interface DataViewInfo {
/**
* Gets the name of the data view.
* The name is the identifier of a specific view.
*
* @return the name of the data view
*/
String name();

/**
* Gets the label of the data view.
* The label is a short indicator to differ between multiple views.
*
* @return the label of the data view
*/
String label();

/**
* Gets the title of the data view.
* The title is a short textual information about the observation data.
*
* @return the title of the data view
*/
String title();

/**
* Gets the description of the data view.
* The description explains what the given observation data shows.
*
* @return the description of the data view
*/
String description();

/**
* Gets the chart type of the data view.
* The chartType indicates how the given observation data is visually shown.
*
* @return the chart type of the data view
*/
DataView.ChartType chartType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright LBI-DHP and/or licensed to LBI-DHP under one or more
* contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute
* for Digital Health and Prevention -- A research institute of the
* Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur
* Förderung der wissenschaftlichen Forschung).
* Licensed under the Elastic License 2.0.
*/
package io.redlink.more.studymanager.core.ui;

import java.util.List;

/**
* Represents a row of data in a data view.
*
* @param label the label of the data row
* @param values the list of values in the data row
*/
public record DataViewRow(
String label,
List<Double> values
) {
}
Loading

0 comments on commit 234343d

Please sign in to comment.