Skip to content

Commit

Permalink
Merge branch 'release/0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonf committed Dec 23, 2015
2 parents 62718fe + b702f2a commit dfccd5b
Show file tree
Hide file tree
Showing 134 changed files with 3,224 additions and 1,011 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Shimmer [![Build Status](https://travis-ci.org/openmhealth/shimmer.svg?branch=master)](https://travis-ci.org/openmhealth/shimmer)
# Shimmer [![Build Status](https://travis-ci.org/openmhealth/shimmer.svg?branch=develop)](https://travis-ci.org/openmhealth/shimmer)

Shimmer is an application that makes it easy to pull health data from popular third-party APIs like Runkeeper and Fitbit.
It converts that data into an [Open mHealth](http://www.openmhealth.org) compliant format, letting your application work with clean and clinically meaningful data.
Expand Down Expand Up @@ -98,6 +98,7 @@ If you want to build and run the code natively, in a terminal
1. Run the `./run-natively.sh` script and follow the instructions.
1. When the script blocks with the message `Started Application`, the components are running.
* Press Ctrl-C to stop them.
* 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.
1. Visit `http://localhost:8083` in a browser.

If you want to build and run the code in Docker, in a terminal
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ subprojects {

ext {
javaVersion = 1.8
shimmerVersion = '0.4.1'
shimmerVersion = '0.4.2'
omhSchemaSdkVersion = '1.0.3'
}

Expand Down
3 changes: 1 addition & 2 deletions java-shim-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ archivesBaseName = 'omh-shim-sdk'
version = '1.0.0'

ext {
jacksonVersion = '2.5.3'
jacksonVersion = '2.6.1'
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@

package org.openmhealth.shim;

import org.joda.time.DateTime;

import java.time.OffsetDateTime;
import java.util.List;


/**
* A wrapper for encapsulating data requests sent
* to shims. Prevents from having long method signatures.
* A wrapper for encapsulating data requests sent to shims. Prevents from having long method signatures.
*
* @author Danilo Bonilla
*/
Expand All @@ -34,15 +31,14 @@ public class ShimDataRequest {
*/
private String dataTypeKey;
/**
* parameters required for acessing data, this
* will likely be oauth token + any extras or some
* kind of trusted access.
* parameters required for acessing data, this will likely be oauth token + any extras or some kind of trusted
* access.
*/
private AccessParameters accessParameters;

/**
* // TODO replace this with filters on effective time, using the Data Point API
* The start date for the data being retrieved
* // TODO replace this with filters on effective time, using the Data Point API The start date for the data being
* retrieved
*/
private OffsetDateTime startDateTime;

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

/**
* List of columns required
*/
private List<String> columnList;

/**
* The starting row for the data (for pagination purposes)
*/
private Long numToSkip;

/**
* Number of rows to return
*/
private Long numToReturn;

/**
* If true, returns normalized results
* from the external data provider, otherwise
* returns raw data.
* If true, returns normalized results from the external data provider, otherwise returns raw data.
*/
private boolean normalize = true;

public ShimDataRequest() {
}

public ShimDataRequest(String dataTypeKey,
AccessParameters accessParameters,
OffsetDateTime startDateTime,
OffsetDateTime endDateTime,
List<String> columnList,
Long numToSkip,
Long numToReturn,
boolean normalize) {
this.dataTypeKey = dataTypeKey;
this.accessParameters = accessParameters;
this.startDateTime = startDateTime;
this.endDateTime = endDateTime;
this.columnList = columnList;
this.numToSkip = numToSkip;
this.numToReturn = numToReturn;
this.normalize = false;
}

public void setDataTypeKey(String dataTypeKey) {
this.dataTypeKey = dataTypeKey;
Expand All @@ -106,10 +65,6 @@ public OffsetDateTime getStartDateTime() {
return startDateTime;
}

public DateTime getStartDate() {
return getStartDateTime() == null ? null : new DateTime(getStartDateTime().toInstant());
}

public void setStartDateTime(OffsetDateTime startDateTime) {
this.startDateTime = startDateTime;
}
Expand All @@ -118,25 +73,10 @@ public OffsetDateTime getEndDateTime() {
return endDateTime;
}

public DateTime getEndDate() {
return getStartDateTime() == null ? null : new DateTime(getStartDateTime().toInstant());
}

public void setEndDateTime(OffsetDateTime endDateTime) {
this.endDateTime = endDateTime;
}

public void setColumnList(List<String> columnList) {
this.columnList = columnList;
}

public void setNumToSkip(Long numToSkip) {
this.numToSkip = numToSkip;
}

public void setNumToReturn(Long numToReturn) {
this.numToReturn = numToReturn;
}

public String getDataTypeKey() {
return dataTypeKey;
Expand All @@ -146,18 +86,6 @@ public AccessParameters getAccessParameters() {
return accessParameters;
}

public List<String> getColumnList() {
return columnList;
}

public Long getNumToSkip() {
return numToSkip;
}

public Long getNumToReturn() {
return numToReturn;
}

public boolean getNormalize() {
return normalize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@


import org.openmhealth.schema.domain.omh.DataPoint;
import org.openmhealth.schema.domain.omh.SchemaId;
import org.openmhealth.schema.domain.omh.SchemaSupport;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.util.List;

import static java.util.Collections.singletonList;


/**
* A mapper that creates data points from one or more inputs.
Expand All @@ -13,15 +20,46 @@
* @param <I> the input type
* @author Emerson Farrugia
*/
public interface DataPointMapper<B, I> {
public interface DataPointMapper<B extends SchemaSupport, I> {

/**
* Maps one or more inputs into one or more data points. This cardinality allows a mapper to use different inputs
* to assemble a data point, e.g. combining a user profile API response and a blood pressure API response to build
* an identified blood pressure data point.
* Maps one or more inputs into one or more data points. The parameter cardinality allows a mapper to use different
* inputs to assemble a data point, e.g. combining a user profile API response and a blood pressure API response to
* build an identified blood pressure data point.
*
* @param inputs the list of inputs
* @return the list of data points
* @return the list of data points mapped from those inputs
*/
List<DataPoint<B>> asDataPoints(List<I> inputs);

/**
* @see #asDataPoints(List)
*/
default List<DataPoint<B>> asDataPoints(I input) {

return asDataPoints(singletonList(input));
}

/**
* Gets the schema identifier of the data point body that this mapper creates. This default implementation assumes
* that body classes have a default constructor used for serialization, and must be overridden if they don't.
*
* @return the schema identifier of the body type
*/
@SuppressWarnings("unchecked")
default SchemaId getBodySchemaId() {

try {
Class<B> bodyClass = (Class<B>)
((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];

Constructor<B> bodyClassConstructor = bodyClass.getDeclaredConstructor();
bodyClassConstructor.setAccessible(true);

return bodyClassConstructor.newInstance().getSchemaId();
}
catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openmhealth.shim.common.mapper;

import com.fasterxml.jackson.databind.JsonNode;
import org.openmhealth.schema.domain.omh.SchemaSupport;


/**
Expand All @@ -9,6 +10,6 @@
* @param <B> the body type of the data points to create
* @author Emerson Farrugia
*/
public interface JsonNodeDataPointMapper<B> extends DataPointMapper<B, JsonNode> {
public interface JsonNodeDataPointMapper<B extends SchemaSupport> extends DataPointMapper<B, JsonNode> {

}
16 changes: 8 additions & 8 deletions shim-server-ui/app/views/authorizationComplete.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div ng-controller="MainCtrl">
<div class="authorization-complete-message">
<span ng-show="error">We're sorry, </span>
<span ng-show="!error">Great, </span>
authorization was <span ng-show="error">not </span>successful.<br/>
<br/>
This window should now close automatically.<br/>
</div>
</div>
<div class="authorization-complete-message">
<span ng-show="error">We're sorry, </span>
<span ng-show="!error">Great, </span>
authorization was <span ng-show="error">not </span>successful.<br/>
<br/>
This window should now close automatically.<br/>
</div>
</div>
2 changes: 1 addition & 1 deletion shim-server-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shim-server-ui",
"version": "0.4.1",
"version": "0.4.2",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.5",
Expand Down
Loading

0 comments on commit dfccd5b

Please sign in to comment.