Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
schaefba committed Dec 2, 2015
2 parents ac6eb79 + eee35c7 commit 85aaebc
Show file tree
Hide file tree
Showing 72 changed files with 4,173 additions and 578 deletions.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ sudo: false
cache:
directories:
- $HOME/.gradle/wrapper/dists/gradle-2.6-bin
- $HOME/.gradle/caches/modules-2/files-2.1
- $HOME/.gradle/caches/modules-2/files-2.1

# TODO enable this once Travis builds the console
#deploy:
# provider: script
# script: resources/docker-hub/deploy-to-docker-hub.sh
# on:
# tags: true
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ We currently support the following APIs
* [Misfit](http://misfit.com/)
* [RunKeeper](https://runkeeper.com/index)
* [Withings](http://www.withings.com/)
* [iHealth](http://www.ihealthlabs.com/)

And the following APIs are in the works

* [FatSecret](https://www.fatsecret.com/)
* [Ginsberg](https://www.ginsberg.io/)
* [iHealth](http://www.ihealthlabs.com/)
* [Strava](https://www.strava.com/)

This README should have everything you need to get started. If you have any questions, feel free to [open an issue](https://github.com/openmhealth/shimmer/issues), [email us](mailto://[email protected]), [post on our form](https://groups.google.com/forum/#!forum/omh-developers), or [visit our website](http://www.openmhealth.org/documentation/#/data-providers/get-started).
Expand Down Expand Up @@ -122,6 +122,11 @@ You need to obtain client credentials for any shim you'd like to use. These cred
* [Misfit](https://build.misfit.com/)
* [RunKeeper](http://developer.runkeeper.com/healthgraph) ([application management portal](http://runkeeper.com/partner))
* [Withings](http://oauth.withings.com/api)
* [iHealth](http://developer.ihealthlabs.com/index.htm) (see below for setting up special iHealth application specific credentials)

> If you are using the iHealth shim, you must uncomment and replace the SC and SV values for each endpoint in the `iHealth:serialValues` map in the `application.yaml` file.
These values are uniquely associated with each project you have and can be found in your project details on the [application management page](http://developer.ihealthlabs.com/developermanagepage.htm)
of the iHealth developers site.

If any of the links are incorrect or out of date, please [submit an issue](https://github.com/openmhealth/shimmer/issues) to let us know.

Expand Down Expand Up @@ -218,7 +223,7 @@ The currently supported shims are:
| shim | endPoint | OmH data produced by endpoint |
| ------------ | ----------------- | -------------------------- |
| fitbit<sup>1</sup> | activity | [omh:physical-activity](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_physical-activity) |
| fitbit<sup>1</sup> | steps | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count) |
| fitbit<sup>1</sup> | steps<sup>2</sup> | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count) |
| fitbit<sup>1</sup> | weight | [omh:body-weight](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-weight) |
| fitbit<sup>1</sup> | body_mass_index | [omh:body-mass-index](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-mass-index)|
| fitbit<sup>1</sup> | sleep | [omh:sleep-duration](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_sleep-duration) |
Expand All @@ -229,11 +234,11 @@ The currently supported shims are:
| googlefit | step_count | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count)
| googlefit | calories_burned | [omh:calories-burned](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_calories-burned) |
| jawbone | activity | [omh:physical-activity](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_physical-activity) |
| jawbone | weight<sup>2</sup> | [omh:body-weight](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-weight)
| jawbone | body_mass_index<sup>2</sup> | [omh:body-mass-index](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-mass-index) |
| jawbone | weight | [omh:body-weight](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-weight)
| jawbone | body_mass_index | [omh:body-mass-index](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-mass-index) |
| jawbone | steps | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count) |
| jawbone | sleep | [omh:sleep-duration](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_sleep-duration) |
| jawbone | heart_rate<sup>2</sup> | [omh:heart-rate](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_heart-rate) |
| jawbone | heart_rate<sup>3</sup> | [omh:heart-rate](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_heart-rate) |
| misfit | activities | [omh:physical-activity](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_physical-activity) |
| misfit | steps | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count)
| misfit | sleep | [omh:sleep-duration](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_sleep-duration) |
Expand All @@ -243,18 +248,27 @@ The currently supported shims are:
| withings | body_height | [omh:body-height](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-height)|
| withings | body_weight | [omh:body-weight](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-weight) |
| withings | heart_rate | [omh:heart-rate](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_heart-rate) |
| withings | steps<sup>3</sup> | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count) |
| withings | calories<sup>3</sup> | [omh:calories-burned](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_calories-burned) |
| withings | sleep<sup>4</sup> | [omh:sleep-duration](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_sleep-duration) |

| withings | steps<sup>4</sup> | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count) |
| withings | calories<sup>4</sup> | [omh:calories-burned](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_calories-burned) |
| withings | sleep<sup>5</sup> | [omh:sleep-duration](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_sleep-duration) |
| ihealth | physical_activity | [omh:physical-activity](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_physical-activity) |
| ihealth | blood_glucose | [omh:blood-glucose](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_blood-glucose) |
| ihealth | blood_pressure | [omh:blood-pressure](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_blood-pressure) |
| ihealth | body_weight | [omh:body-weight](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-weight) |
| ihealth | body_mass_index | [omh:body-mass-index](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_body-mass-index) |
| ihealth | heart_rate | [omh:heart-rate](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_heart-rate) |
| ihealth | step_count | [omh:step-count](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_step-count) |
| ihealth | sleep_duration | [omh:sleep-duration](http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_sleep-duration) |

<sup>1</sup> *The Fitbit API does not provide time zone information for the data points it returns. Furthermore, it is not possible to infer the time zone from any of the information provided. Because Open mHealth schemas require timestamps to have a time zone, we need to assign a time zone to timestamps. We set the time zone of all timestamps to UTC for consistency, even if the data may not have occurred in that time zone. This means that unless the event actually occurred in UTC, the timestamps will be incorrect. Please consider this when working with data normalized into OmH schemas that are retrieved from the Fitbit shim. We will fix this as soon as Fitbit makes changes to their API to provide time zone information.*

<sup>2</sup> *Body weight, body mass index, and heart rate mappers have not been tested on real data from Jawbone devices. They have been tested on example data provided in Jawbone API documentation. Please help us out by testing Shimmer with real-world data of one of these types from a Jawbone device and letting us know whether or not it works correctly.*
<sup>2</sup> *Uses the daily step summary when partner access is disabled (default) and uses intraday step count (at 1 minute granularity) when partner access is enabled. Intraday activity requests are limited to 24 hours worth of data per request. See the YAML configuration file (application.yaml) to enable partner access if your API credentials have been granted partner access. Attempting to generate normalized data with the partner access property set to true, but when your API credentials have not been granted partner access will result in an error.*

<sup>3</sup> *The Heart rate mapper has not been tested on real data from Jawbone devices. They have been tested on example data provided in Jawbone API documentation. Please help us out by testing Shimmer with real-world data of one of these types from a Jawbone device and letting us know whether or not it works correctly.*

<sup>3</sup> *Uses the daily activity summary when partner access is disabled (default) and uses intraday activity when partner access is enabled. See the YAML configuration file for details. Intraday activity requests are limited to 24 hours worth of data per request.*
<sup>4</sup> *Uses the daily activity summary when partner access is disabled (default) and uses intraday activity when partner access is enabled. See the YAML configuration file for details. Intraday activity requests are limited to 24 hours worth of data per request.*

<sup>4</sup> *Sleep data has not been tested using real data directly from a device. It has been tested with example data provided in the Withings API documentation. Please help us out by testing real-world Withings sleep data with Shimmer and letting us know whether or not it works correctly.*
<sup>5</sup> *Sleep data has not been tested using real data directly from a device. It has been tested with example data provided in the Withings API documentation. Please help us out by testing real-world Withings sleep data with Shimmer and letting us know whether or not it works correctly.*

### Contributing

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.3.2'
shimmerVersion = '0.4.0'
omhSchemaSdkVersion = '1.0.3'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ public static Double asRequiredDouble(JsonNode parentNode, String path) {
return asRequiredValue(parentNode, path, JsonNode::isNumber, JsonNode::doubleValue, Double.class);
}

/**
* @param parentNode a parent node
* @param path the path to a child node
* @return the value of the child node as a BigDecimal
* @throws MissingJsonNodeMappingException if the child doesn't exist
* @throws IncompatibleJsonNodeMappingException if the value of the child node isn't numeric
*/
public static BigDecimal asRequiredBigDecimal(JsonNode parentNode, String path) {

return asRequiredValue(parentNode, path, JsonNode::isNumber, JsonNode::decimalValue, BigDecimal.class);
}

/**
* @param parentNode a parent node
* @param path the path to a child node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.testng.annotations.Test;

import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
Expand Down Expand Up @@ -608,4 +609,51 @@ public void asOptionalIntegerShouldReturnIntegerWhenPresent() {
assertThat(value.isPresent(), equalTo(true));
assertThat(value.get(), equalTo(2));
}

@Test
public void asOptionalBigDecimalShouldReturnBigDecimalForInteger() {

Optional<BigDecimal> value = asOptionalBigDecimal(testNode, "integer");

assertThat(value, notNullValue());
assertThat(value.isPresent(), equalTo(true));
assertThat(value.get().intValue(), equalTo(2));
}

@Test
public void asOptionalBigDecimalShouldReturnBigDecimalForDecimalValue() {

Optional<BigDecimal> value = asOptionalBigDecimal(testNode, "number");

assertThat(value, notNullValue());
assertThat(value.isPresent(), equalTo(true));
assertThat(value.get().doubleValue(), equalTo(2.3));
}

@Test
public void asOptionalBigDecimalShouldReturnEmptyOnMissingNode() {

Optional<BigDecimal> value = asOptionalBigDecimal(testNode, "foo");

assertThat(value, notNullValue());
assertThat(value.isPresent(), equalTo(false));
}

@Test
public void asOptionalBigDecimalShouldReturnEmptyOnNullNode() {

Optional<BigDecimal> value = asOptionalBigDecimal(testNode, "empty");

assertThat(value, notNullValue());
assertThat(value.isPresent(), equalTo(false));
}

@Test
public void asOptionalBigDecimalShouldReturnEmptyOnNonNumberNode() {

Optional<BigDecimal> value = asOptionalBigDecimal(testNode, "string");

assertThat(value, notNullValue());
assertThat(value.isPresent(), equalTo(false));
}
}
23 changes: 23 additions & 0 deletions resources/docker-hub/deploy-to-docker-hub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

BASEDIR=$(pwd)
TAG=$(git describe --exact-match)

if [[ ! ${TAG} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "The tag ${TAG} isn't a valid version tag."
exit
fi

VERSION=${TAG#v}

cd ${BASEDIR}/shim-server/docker
docker build -t "openmhealth/shimmer-resource-server:latest" .
docker build -t "openmhealth/shimmer-resource-server:${VERSION}" .
docker push "openmhealth/shimmer-resource-server:latest"
docker push "openmhealth/shimmer-resource-server:${VERSION}"

cd ${BASEDIR}/shim-server-ui/docker
docker build -t "openmhealth/shimmer-console:latest" .
docker build -t "openmhealth/shimmer-console:${VERSION}" .
docker push "openmhealth/shimmer-console:latest"
docker push "openmhealth/shimmer-console:${VERSION}"
4 changes: 4 additions & 0 deletions shim-server-ui/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ angular
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/authorizationComplete/:errorState', {
templateUrl: 'views/authorizationComplete.html',
controller: 'AuthorizationCompleteCtrl'
})
.otherwise({
redirectTo: '/'
});
Expand Down
6 changes: 6 additions & 0 deletions shim-server-ui/app/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
* Simple UI for managing shim data on the shim server.
*/
angular.module('sandboxConsoleApp')
.controller('AuthorizationCompleteCtrl', ['$scope', '$http', '$window', '$timeout','$routeParams', function ($scope, $http, $window, $timeout, $routeParams) {
$timeout(function() {
$window.close();
}, 3000);
$scope.error = $routeParams.errorState=='failure';
}])
.controller('MainCtrl', ['$scope', '$http', '$window', function ($scope, $http, $window) {

var API_ROOT_URL = "/omh-shims-api";
Expand Down
6 changes: 6 additions & 0 deletions shim-server-ui/app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,10 @@ body {
.jumbotron {
border-bottom: 0;
}

.authorization-complete-message {
padding: 40px;
text-align: center;
}

}
9 changes: 9 additions & 0 deletions shim-server-ui/app/views/authorizationComplete.html
Original file line number Diff line number Diff line change
@@ -0,0 +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>
2 changes: 1 addition & 1 deletion shim-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

ext {
springBootVersion = "1.2.5.RELEASE"
springBootVersion = "1.2.6.RELEASE"
}

dependencies {
Expand Down
19 changes: 18 additions & 1 deletion shim-server/src/main/java/org/openmhealth/shim/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
@RestController
public class Application extends WebSecurityConfigurerAdapter {

private static final String AUTH_SUCCESS_URL = "/#authorizationComplete/success";
private static final String AUTH_FAILURE_URL = "/#authorizationComplete/failure";
@Autowired
private AccessParametersRepo accessParametersRepo;

Expand Down Expand Up @@ -266,6 +268,21 @@ public AuthorizationResponse approve(
}
return null;
}

String authorizationStatusURL = AUTH_FAILURE_URL;
if(response.getType().equals(AuthorizationResponse.Type.AUTHORIZED)){

authorizationStatusURL = AUTH_SUCCESS_URL;
}

try{
servletResponse.sendRedirect(authorizationStatusURL);
}
catch (IOException e) {
e.printStackTrace();
throw new ShimException("Error occurred in redirecting to completion URL");
}

return response;
}
}
Expand Down Expand Up @@ -294,7 +311,7 @@ public ShimDataResponse data(

shimDataRequest.setDataTypeKey(dataTypeKey);

if(!normalize.equals("")){
if (!normalize.equals("")) {
shimDataRequest.setNormalize(Boolean.parseBoolean(normalize));
}

Expand Down
Loading

0 comments on commit 85aaebc

Please sign in to comment.