Skip to content

Commit

Permalink
Merge pull request #121 from RADAR-base/release-0.3
Browse files Browse the repository at this point in the history
Release 0.3
  • Loading branch information
nivemaham authored Sep 13, 2018
2 parents 0b855a1 + a4b1c77 commit a9c654f
Show file tree
Hide file tree
Showing 61 changed files with 1,485 additions and 751 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To run the application do:
- `/usr/share/conf/radar/rest-api`
- `/usr/local/conf/radar/rest-api`
- run `./gradlew build`
- Run the `radar-restapi-0.2.1.jar` located at `build/libs/`
- Run the `radar-restapi-0.3.jar` located at `build/libs/`

By default, log messages are redirected to the `STDOUT`.

Expand Down
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ plugins {
}

group 'org.radarcns'
version '0.2.1'
version '0.3'

targetCompatibility = '1.8'
sourceCompatibility = '1.8'

ext.grizzly = '2.4.3'
ext.jersey = '2.26'
ext.jersey = '2.27'
ext.junitVersion = '4.12'
ext.hamcrestVersion = '1.3'
ext.logback = '1.2.2'
ext.mongodb = '3.6.0'
ext.radarCommons = '0.7'
ext.swagger = '2.0.0-rc4'
ext.tomcat = '8.0.47'
ext.radarAuthVersion = '0.3.3-SNAPSHOT'
ext.managmentPortalClientVersion = '0.3.4'
ext.radarAuthVersion = '0.5.0'
ext.wireMockVersion = '2.5.1'
ext.jacksonVersion = '2.9.3'
ext.mockitoVersion = '2.2.29'
Expand Down Expand Up @@ -76,3 +75,8 @@ if (!hasProperty('profile')) {
}

apply from: "gradle/profile.${profile}.gradle"


wrapper {
gradleVersion '4.9'
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
10 changes: 5 additions & 5 deletions src/endToEndTest/java/org/radarcns/EndToEndTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import org.radarcns.domain.restapi.dataset.Dataset;
import org.radarcns.domain.restapi.format.Acceleration;
import org.radarcns.domain.restapi.format.Quartiles;
import org.radarcns.domain.restapi.header.DataSetHeader;
import org.radarcns.domain.restapi.header.DescriptiveStatistic;
import org.radarcns.domain.restapi.header.Header;
import org.radarcns.integration.util.ApiClient;
import org.radarcns.integration.util.ExpectedDataSetFactory;
import org.radarcns.integration.util.Utility;
Expand Down Expand Up @@ -258,10 +258,10 @@ private static Map<MockDataConfig, Dataset> getReceivedMessage(

Dataset dataset = Utility.cloneDataset(expectedCount.get(config));

Header updatedHeader = dataset.getHeader();
updatedHeader.setDescriptiveStatistic(DescriptiveStatistic.RECEIVED_MESSAGES);
updatedHeader.setUnit("PERCENTAGE");
dataset.setHeader(updatedHeader);
DataSetHeader updatedHeader = (DataSetHeader) dataset.getHeader()
.descriptiveStatistic(DescriptiveStatistic.RECEIVED_MESSAGES)
.unit("PERCENTAGE");
dataset.header(updatedHeader);

for (DataItem item : dataset.getDataset()) {
if (item.getValue() instanceof Double) {
Expand Down
4 changes: 3 additions & 1 deletion src/integrationTest/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ services:
- simplestack
ports:
- "8080:8080"
environment:
RADAR_IS_CONFIG_LOCATION: /volumes/radar/radar-is.yml
volumes:
- ./volumes/radar:/usr/local/conf/radar/rest-api
- ../test/resources/org/radarcns/status/hdfs/bins.csv:/var/lib/hdfs/output/bins.csv
Expand All @@ -40,7 +42,7 @@ services:
# Management Portal #
#---------------------------------------------------------------------------#
managementportal-app:
image: radarcns/management-portal:0.3.3
image: radarbase/management-portal:0.5.0
networks:
- default
- simplestack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import org.radarcns.domain.restapi.dataset.Dataset;
import org.radarcns.domain.restapi.format.Acceleration;
import org.radarcns.domain.restapi.format.Quartiles;
import org.radarcns.domain.restapi.header.DataSetHeader;
import org.radarcns.domain.restapi.header.DescriptiveStatistic;
import org.radarcns.domain.restapi.header.Header;
import org.radarcns.domain.restapi.header.TimeFrame;
import org.radarcns.mock.model.ExpectedValue;
import org.radarcns.stream.collector.DoubleArrayCollector;
import org.radarcns.stream.collector.DoubleValueCollector;
import org.radarcns.util.RadarConverter;
import org.radarcns.util.TimeScale;

/**
* Produces {@link Dataset} and {@link org.bson.Document} for {@link ExpectedValue}.
Expand All @@ -57,8 +58,8 @@ public Dataset getDataset(ExpectedValue expectedValue, String projectName, Strin
String sourceId, String sourceType, String sensorType, DescriptiveStatistic statistic,
TimeWindow timeWindow) {

Header header = getHeader(expectedValue, projectName, subjectId, sourceId, sourceType,
sensorType, statistic, timeWindow);
DataSetHeader header = getHeader(expectedValue, projectName, subjectId, sourceId,
sourceType, sensorType, statistic, timeWindow);

return new Dataset(header, getItem(expectedValue, header));
}
Expand All @@ -75,11 +76,11 @@ public Dataset getDataset(ExpectedValue expectedValue, String projectName, Strin
* @param timeWindow time interval between two consecutive samples
* @return {@link Header} for a {@link Dataset}
*/
public Header getHeader(ExpectedValue expectedValue, String projectName, String subjectId,
String sourceId, String sourceType, String sensorType, DescriptiveStatistic statistic,
TimeWindow timeWindow) {
return new Header(projectName, subjectId, sourceId, sourceType, sensorType, statistic,
null, timeWindow, null,
public DataSetHeader getHeader(ExpectedValue expectedValue, String projectName,
String subjectId, String sourceId, String sourceType, String sensorType,
DescriptiveStatistic statistic, TimeWindow timeWindow) {
return new DataSetHeader(projectName, subjectId, sourceId, sourceType, sensorType,
statistic, null, timeWindow, null,
getEffectiveTimeFrame(expectedValue, timeWindow));
}

Expand All @@ -97,7 +98,7 @@ public TimeFrame getEffectiveTimeFrame(ExpectedValue<?> expectedValue, TimeWindo
return new TimeFrame(
Instant.ofEpochMilli(windows.get(0)),
Instant.ofEpochMilli(windows.get(windows.size() - 1))
.plus(RadarConverter.getDuration(timeWindow)));
.plus(TimeScale.getDuration(timeWindow)));
}


Expand All @@ -108,7 +109,7 @@ public TimeFrame getEffectiveTimeFrame(ExpectedValue<?> expectedValue, TimeWindo
* @return {@code List<Item>} for a {@link Dataset}
* @see DataItem
**/
public List<DataItem> getItem(ExpectedValue<?> expectedValue, Header header) {
public List<DataItem> getItem(ExpectedValue<?> expectedValue, DataSetHeader header) {

if (expectedValue.getSeries().isEmpty()) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.radarcns.mongo.util.MongoHelper.Stat;
import org.radarcns.stream.collector.DoubleArrayCollector;
import org.radarcns.stream.collector.DoubleValueCollector;
import org.radarcns.util.RadarConverter;
import org.radarcns.util.TimeScale;

/**
* It computes the expected Documents for a test case i.e. {@link ExpectedValue}.
Expand Down Expand Up @@ -120,7 +120,7 @@ private List<Document> getDocumentsBySingle(ExpectedValue<?> expectedValue,
DoubleValueCollector doubleValueCollector = (DoubleValueCollector) expectedValue
.getSeries().get(timestamp);
Instant start = Instant.ofEpochMilli(timestamp);
Instant end = start.plus(RadarConverter.getDuration(timeWindow));
Instant end = start.plus(TimeScale.getDuration(timeWindow));
list.add(buildDocument(expectedValue.getLastKey().getProjectId(),
expectedValue.getLastKey().getUserId(),
expectedValue.getLastKey().getSourceId(), start, end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package org.radarcns.integration.util;

import static org.radarcns.mongo.data.monitor.ApplicationStatusRecordCounter.RECORD_COLLECTION;
import static org.radarcns.mongo.data.monitor.ApplicationStatusServerStatus.STATUS_COLLECTION;
import static org.radarcns.mongo.data.monitor.ApplicationStatusUpTime.UPTIME_COLLECTION;
import static java.time.temporal.ChronoUnit.SECONDS;
import static org.radarcns.mongo.data.monitor.application.ApplicationStatusRecordCounter.RECORD_COLLECTION;
import static org.radarcns.mongo.data.monitor.application.ApplicationStatusServerStatus.STATUS_COLLECTION;
import static org.radarcns.mongo.data.monitor.application.ApplicationStatusUpTime.UPTIME_COLLECTION;
import static org.radarcns.mongo.util.MongoHelper.ID;
import static org.radarcns.mongo.util.MongoHelper.KEY;
import static org.radarcns.mongo.util.MongoHelper.PROJECT_ID;
Expand All @@ -42,7 +43,7 @@
import org.radarcns.monitor.application.ServerStatus;
import org.radarcns.stream.collector.DoubleArrayCollector;
import org.radarcns.stream.collector.DoubleValueCollector;
import org.radarcns.util.RadarConverter;
import org.radarcns.util.TimeScale;

/**
* All supported sources specifications.
Expand All @@ -59,29 +60,31 @@ public class RandomInput {
new ExpectedDataSetFactory();

private static ExpectedValue<DoubleValueCollector> randomDoubleValue(
ObservationKey key, TimeWindow timeWindow, int numberOfRecords, Instant startTime) {
ObservationKey key, TimeWindow timeWindow, int numberOfRecords, Instant endTime) {
ExpectedDoubleValue instance = new ExpectedDoubleValue();

Instant timeStamp = startTime;
Instant timeStamp = endTime.minus(
TimeScale.getSeconds(timeWindow) * numberOfRecords, SECONDS);
ThreadLocalRandom random = ThreadLocalRandom.current();
for (int i = 0; i < numberOfRecords; i++) {
instance.add(key, timeStamp.toEpochMilli(), random.nextDouble());
timeStamp = timeStamp.plus(RadarConverter.getDuration(timeWindow));
timeStamp = timeStamp.plus(TimeScale.getDuration(timeWindow));
}

return instance;
}

private static ExpectedValue<DoubleArrayCollector> randomArrayValue(ObservationKey key,
TimeWindow timeWindow, int numberOfRecords, Instant startTime) {
TimeWindow timeWindow, int numberOfRecords, Instant endTime) {
ExpectedArrayValue instance = new ExpectedArrayValue();

ThreadLocalRandom random = ThreadLocalRandom.current();
Instant timeStamp = startTime;
Instant timeStamp = endTime.minus(
TimeScale.getSeconds(timeWindow) * numberOfRecords, SECONDS);
for (int i = 0; i < numberOfRecords; i++) {
instance.add(key, timeStamp.toEpochMilli(), random.nextDouble(), random.nextDouble(),
random.nextDouble());
timeStamp = timeStamp.plus(RadarConverter.getDuration(timeWindow));
timeStamp = timeStamp.plus(TimeScale.getDuration(timeWindow));
}

return instance;
Expand All @@ -94,7 +97,7 @@ private static ExpectedValue<DoubleArrayCollector> randomArrayValue(ObservationK
@SuppressWarnings("PMD.ExcessiveParameterList")
public static Map<String, Object> getDatasetAndDocumentsRandom(String project, String user,
String source, String sourceType, String sourceDataName, DescriptiveStatistic stat,
TimeWindow timeWindow, int samples, boolean singleWindow, Instant startTime) {
TimeWindow timeWindow, int samples, boolean singleWindow, Instant endTime) {
ObservationKey key = new ObservationKey(project, user, source);

int numberOfRecords = samples;
Expand All @@ -104,7 +107,7 @@ public static Map<String, Object> getDatasetAndDocumentsRandom(String project, S

if (SUPPORTED_SOURCE_TYPE.equals(sourceType)) {
return getBoth(key, sourceType, sourceDataName, stat,
timeWindow, numberOfRecords, startTime);
timeWindow, numberOfRecords, endTime);
}

throw new UnsupportedOperationException(sourceType + " is not"
Expand All @@ -114,14 +117,14 @@ public static Map<String, Object> getDatasetAndDocumentsRandom(String project, S
@SuppressWarnings("PMD.ExcessiveParameterList")
private static Map<String, Object> getBoth(ObservationKey key,
String sourceType, String sourceDataName, DescriptiveStatistic stat,
TimeWindow timeWindow, int numberOfRecords, Instant startTime) {
TimeWindow timeWindow, int numberOfRecords, Instant endTime) {
ExpectedValue<?> expectedValue;
switch (sourceDataName) {
case "EMPATICA_E4_v1_ACCELEROMETER":
expectedValue = randomArrayValue(key, timeWindow, numberOfRecords, startTime);
expectedValue = randomArrayValue(key, timeWindow, numberOfRecords, endTime);
break;
default:
expectedValue = randomDoubleValue(key, timeWindow, numberOfRecords, startTime);
expectedValue = randomDoubleValue(key, timeWindow, numberOfRecords, endTime);
break;
}

Expand All @@ -136,6 +139,28 @@ private static Map<String, Object> getBoth(ObservationKey key,
return map;
}

/**
* Generates and returns a randomly generated
* {@link org.radarcns.domain.restapi.monitor.QuestionnaireCompletionStatus} mock data
* sent by RADAR-CNS aRMT.
**/
public static Document getRandomQuestionnaireCompletionLog(String project,
String user, String source) {

ThreadLocalRandom random = ThreadLocalRandom.current();

double timestamp = random.nextDouble();
double completionPercentage = random.nextDouble(0d,100d);
String name = "PHQ8";
Document completionDoc = new Document()
.append("time", timestamp)
.append("name", name)
.append("completionPercentage", completionPercentage);

return buildDocumentWithObservationKey(project, user, source, completionDoc);

}

/**
* Generates and returns a randomly generated {@code ApplicationStatus} mocking data sent by
* RADAR-CNS pRMT.
Expand Down Expand Up @@ -181,9 +206,12 @@ public static Map<String, Document> getRandomApplicationStatus(String project, S
.append("recordsUnsent", recordsUnsent);

Map<String, Document> documents = new HashMap<>();
documents.put(STATUS_COLLECTION, buildAppStatusDocument(project, user, source, statusDoc));
documents.put(RECORD_COLLECTION, buildAppStatusDocument(project, user, source, recordsDoc));
documents.put(UPTIME_COLLECTION, buildAppStatusDocument(project, user, source, uptimeDoc));
documents.put(STATUS_COLLECTION,
buildDocumentWithObservationKey(project, user, source, statusDoc));
documents.put(RECORD_COLLECTION,
buildDocumentWithObservationKey(project, user, source, recordsDoc));
documents.put(UPTIME_COLLECTION,
buildDocumentWithObservationKey(project, user, source, uptimeDoc));
return documents;
}

Expand All @@ -194,7 +222,7 @@ private static Document buildKeyDocument(String projectName, String subjectId,
.append(SOURCE_ID, sourceId);
}

private static Document buildAppStatusDocument(String projectName, String subjectId,
private static Document buildDocumentWithObservationKey(String projectName, String subjectId,
String sourceId,
Document value) {
return new Document().append(ID, "{"
Expand Down
Loading

0 comments on commit a9c654f

Please sign in to comment.