Skip to content

Commit dfccd5b

Browse files
committed
Merge branch 'release/0.4.2'
2 parents 62718fe + b702f2a commit dfccd5b

File tree

134 files changed

+3224
-1011
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+3224
-1011
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Shimmer [![Build Status](https://travis-ci.org/openmhealth/shimmer.svg?branch=master)](https://travis-ci.org/openmhealth/shimmer)
1+
# Shimmer [![Build Status](https://travis-ci.org/openmhealth/shimmer.svg?branch=develop)](https://travis-ci.org/openmhealth/shimmer)
22

33
Shimmer is an application that makes it easy to pull health data from popular third-party APIs like Runkeeper and Fitbit.
44
It converts that data into an [Open mHealth](http://www.openmhealth.org) compliant format, letting your application work with clean and clinically meaningful data.
@@ -98,6 +98,7 @@ If you want to build and run the code natively, in a terminal
9898
1. Run the `./run-natively.sh` script and follow the instructions.
9999
1. When the script blocks with the message `Started Application`, the components are running.
100100
* Press Ctrl-C to stop them.
101+
* The script creates a WAR file which you can alternatively drop into an application server. [This issue](https://github.com/openmhealth/shimmer/issues/31) has details.
101102
1. Visit `http://localhost:8083` in a browser.
102103

103104
If you want to build and run the code in Docker, in a terminal

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ subprojects {
1010

1111
ext {
1212
javaVersion = 1.8
13-
shimmerVersion = '0.4.1'
13+
shimmerVersion = '0.4.2'
1414
omhSchemaSdkVersion = '1.0.3'
1515
}
1616

java-shim-sdk/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ archivesBaseName = 'omh-shim-sdk'
3131
version = '1.0.0'
3232

3333
ext {
34-
jacksonVersion = '2.5.3'
34+
jacksonVersion = '2.6.1'
3535
}
3636

3737
dependencies {
3838
compile "com.google.guava:guava:18.0"
3939
compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
4040
compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
41-
compile "joda-time:joda-time:2.5" // TODO remove this when refactored to java.time
4241
compile "org.openmhealth.schema:omh-schema-sdk:${omhSchemaSdkVersion}"
4342
compile 'org.slf4j:slf4j-api:1.7.12'
4443

java-shim-sdk/src/main/java/org/openmhealth/shim/ShimDataRequest.java

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616

1717
package org.openmhealth.shim;
1818

19-
import org.joda.time.DateTime;
20-
2119
import java.time.OffsetDateTime;
22-
import java.util.List;
20+
2321

2422
/**
25-
* A wrapper for encapsulating data requests sent
26-
* to shims. Prevents from having long method signatures.
23+
* A wrapper for encapsulating data requests sent to shims. Prevents from having long method signatures.
2724
*
2825
* @author Danilo Bonilla
2926
*/
@@ -34,15 +31,14 @@ public class ShimDataRequest {
3431
*/
3532
private String dataTypeKey;
3633
/**
37-
* parameters required for acessing data, this
38-
* will likely be oauth token + any extras or some
39-
* kind of trusted access.
34+
* parameters required for acessing data, this will likely be oauth token + any extras or some kind of trusted
35+
* access.
4036
*/
4137
private AccessParameters accessParameters;
4238

4339
/**
44-
* // TODO replace this with filters on effective time, using the Data Point API
45-
* The start date for the data being retrieved
40+
* // TODO replace this with filters on effective time, using the Data Point API The start date for the data being
41+
* retrieved
4642
*/
4743
private OffsetDateTime startDateTime;
4844

@@ -52,47 +48,10 @@ public class ShimDataRequest {
5248
private OffsetDateTime endDateTime;
5349

5450
/**
55-
* List of columns required
56-
*/
57-
private List<String> columnList;
58-
59-
/**
60-
* The starting row for the data (for pagination purposes)
61-
*/
62-
private Long numToSkip;
63-
64-
/**
65-
* Number of rows to return
66-
*/
67-
private Long numToReturn;
68-
69-
/**
70-
* If true, returns normalized results
71-
* from the external data provider, otherwise
72-
* returns raw data.
51+
* If true, returns normalized results from the external data provider, otherwise returns raw data.
7352
*/
7453
private boolean normalize = true;
7554

76-
public ShimDataRequest() {
77-
}
78-
79-
public ShimDataRequest(String dataTypeKey,
80-
AccessParameters accessParameters,
81-
OffsetDateTime startDateTime,
82-
OffsetDateTime endDateTime,
83-
List<String> columnList,
84-
Long numToSkip,
85-
Long numToReturn,
86-
boolean normalize) {
87-
this.dataTypeKey = dataTypeKey;
88-
this.accessParameters = accessParameters;
89-
this.startDateTime = startDateTime;
90-
this.endDateTime = endDateTime;
91-
this.columnList = columnList;
92-
this.numToSkip = numToSkip;
93-
this.numToReturn = numToReturn;
94-
this.normalize = false;
95-
}
9655

9756
public void setDataTypeKey(String dataTypeKey) {
9857
this.dataTypeKey = dataTypeKey;
@@ -106,10 +65,6 @@ public OffsetDateTime getStartDateTime() {
10665
return startDateTime;
10766
}
10867

109-
public DateTime getStartDate() {
110-
return getStartDateTime() == null ? null : new DateTime(getStartDateTime().toInstant());
111-
}
112-
11368
public void setStartDateTime(OffsetDateTime startDateTime) {
11469
this.startDateTime = startDateTime;
11570
}
@@ -118,25 +73,10 @@ public OffsetDateTime getEndDateTime() {
11873
return endDateTime;
11974
}
12075

121-
public DateTime getEndDate() {
122-
return getStartDateTime() == null ? null : new DateTime(getStartDateTime().toInstant());
123-
}
124-
12576
public void setEndDateTime(OffsetDateTime endDateTime) {
12677
this.endDateTime = endDateTime;
12778
}
12879

129-
public void setColumnList(List<String> columnList) {
130-
this.columnList = columnList;
131-
}
132-
133-
public void setNumToSkip(Long numToSkip) {
134-
this.numToSkip = numToSkip;
135-
}
136-
137-
public void setNumToReturn(Long numToReturn) {
138-
this.numToReturn = numToReturn;
139-
}
14080

14181
public String getDataTypeKey() {
14282
return dataTypeKey;
@@ -146,18 +86,6 @@ public AccessParameters getAccessParameters() {
14686
return accessParameters;
14787
}
14888

149-
public List<String> getColumnList() {
150-
return columnList;
151-
}
152-
153-
public Long getNumToSkip() {
154-
return numToSkip;
155-
}
156-
157-
public Long getNumToReturn() {
158-
return numToReturn;
159-
}
160-
16189
public boolean getNormalize() {
16290
return normalize;
16391
}

java-shim-sdk/src/main/java/org/openmhealth/shim/common/mapper/DataPointMapper.java

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22

33

44
import org.openmhealth.schema.domain.omh.DataPoint;
5+
import org.openmhealth.schema.domain.omh.SchemaId;
6+
import org.openmhealth.schema.domain.omh.SchemaSupport;
57

8+
import java.lang.reflect.Constructor;
9+
import java.lang.reflect.InvocationTargetException;
10+
import java.lang.reflect.ParameterizedType;
611
import java.util.List;
712

13+
import static java.util.Collections.singletonList;
14+
815

916
/**
1017
* A mapper that creates data points from one or more inputs.
@@ -13,15 +20,46 @@
1320
* @param <I> the input type
1421
* @author Emerson Farrugia
1522
*/
16-
public interface DataPointMapper<B, I> {
23+
public interface DataPointMapper<B extends SchemaSupport, I> {
1724

1825
/**
19-
* Maps one or more inputs into one or more data points. This cardinality allows a mapper to use different inputs
20-
* to assemble a data point, e.g. combining a user profile API response and a blood pressure API response to build
21-
* an identified blood pressure data point.
26+
* Maps one or more inputs into one or more data points. The parameter cardinality allows a mapper to use different
27+
* inputs to assemble a data point, e.g. combining a user profile API response and a blood pressure API response to
28+
* build an identified blood pressure data point.
2229
*
2330
* @param inputs the list of inputs
24-
* @return the list of data points
31+
* @return the list of data points mapped from those inputs
2532
*/
2633
List<DataPoint<B>> asDataPoints(List<I> inputs);
34+
35+
/**
36+
* @see #asDataPoints(List)
37+
*/
38+
default List<DataPoint<B>> asDataPoints(I input) {
39+
40+
return asDataPoints(singletonList(input));
41+
}
42+
43+
/**
44+
* Gets the schema identifier of the data point body that this mapper creates. This default implementation assumes
45+
* that body classes have a default constructor used for serialization, and must be overridden if they don't.
46+
*
47+
* @return the schema identifier of the body type
48+
*/
49+
@SuppressWarnings("unchecked")
50+
default SchemaId getBodySchemaId() {
51+
52+
try {
53+
Class<B> bodyClass = (Class<B>)
54+
((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
55+
56+
Constructor<B> bodyClassConstructor = bodyClass.getDeclaredConstructor();
57+
bodyClassConstructor.setAccessible(true);
58+
59+
return bodyClassConstructor.newInstance().getSchemaId();
60+
}
61+
catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) {
62+
throw new RuntimeException(e);
63+
}
64+
}
2765
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.openmhealth.shim.common.mapper;
22

33
import com.fasterxml.jackson.databind.JsonNode;
4+
import org.openmhealth.schema.domain.omh.SchemaSupport;
45

56

67
/**
@@ -9,6 +10,6 @@
910
* @param <B> the body type of the data points to create
1011
* @author Emerson Farrugia
1112
*/
12-
public interface JsonNodeDataPointMapper<B> extends DataPointMapper<B, JsonNode> {
13+
public interface JsonNodeDataPointMapper<B extends SchemaSupport> extends DataPointMapper<B, JsonNode> {
1314

1415
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div ng-controller="MainCtrl">
2-
<div class="authorization-complete-message">
3-
<span ng-show="error">We're sorry, </span>
4-
<span ng-show="!error">Great, </span>
5-
authorization was <span ng-show="error">not </span>successful.<br/>
6-
<br/>
7-
This window should now close automatically.<br/>
8-
</div>
9-
</div>
2+
<div class="authorization-complete-message">
3+
<span ng-show="error">We're sorry, </span>
4+
<span ng-show="!error">Great, </span>
5+
authorization was <span ng-show="error">not </span>successful.<br/>
6+
<br/>
7+
This window should now close automatically.<br/>
8+
</div>
9+
</div>

shim-server-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "shim-server-ui",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"dependencies": {},
55
"devDependencies": {
66
"grunt": "~0.4.5",

0 commit comments

Comments
 (0)