Permalink
Browse files

Merge branch 'runkeeper'

  • Loading branch information...
2 parents 3ee5809 + 01e1108 commit b981394d63d44996cc69a34e9c7a2706badd71ff @ckemmler ckemmler committed Jan 16, 2013
Showing with 2,577 additions and 116 deletions.
  1. +1 −0 .idea/artifacts/fluxtream_web_war_exploded.xml
  2. +13 −0 .idea/libraries/Maven__junit_junit_4_8_2.xml
  3. +13 −0 .idea/libraries/Maven__org_scribe_scribe_1_3_3.xml
  4. +2 −1 fluxtream-connectors/fluxtream-connectors.iml
  5. +6 −1 fluxtream-connectors/pom.xml
  6. +87 −0 fluxtream-connectors/src/main/java/com/fluxtream/connectors/evernote/EvernoteController.java
  7. +24 −0 fluxtream-connectors/src/main/java/com/fluxtream/connectors/evernote/EvernoteUpdater.java
  8. +0 −1 fluxtream-connectors/src/main/java/com/fluxtream/connectors/fitbit/FitBitTSUpdater.java
  9. +2 −2 ...ream-connectors/src/main/java/com/fluxtream/connectors/google_latitude/GoogleLatitudeUpdater.java
  10. +16 −0 fluxtream-connectors/src/main/java/com/fluxtream/connectors/runkeeper/HeartRateMeasure.java
  11. +85 −0 fluxtream-connectors/src/main/java/com/fluxtream/connectors/runkeeper/RunKeeperController.java
  12. +113 −0 ...onnectors/src/main/java/com/fluxtream/connectors/runkeeper/RunKeeperFitnessActivityExtractor.java
  13. +54 −0 ...am-connectors/src/main/java/com/fluxtream/connectors/runkeeper/RunKeeperFitnessActivityFacet.java
  14. +44 −0 ...-connectors/src/main/java/com/fluxtream/connectors/runkeeper/RunKeeperFitnessActivityFacetVO.java
  15. +118 −0 fluxtream-connectors/src/main/java/com/fluxtream/connectors/runkeeper/RunKeeperUpdater.java
  16. +0 −2 fluxtream-connectors/src/main/java/com/fluxtream/connectors/zeo/ZeoSleepStatsFacetVO.java
  17. +1 −0 fluxtream-core/fluxtream-core.iml
  18. +9 −2 fluxtream-core/src/main/java/com/fluxtream/connectors/google_latitude/LocationFacet.java
  19. +0 −1 fluxtream-core/src/main/java/com/fluxtream/mvc/models/DurationModel.java
  20. +1 −2 fluxtream-core/src/main/java/com/fluxtream/services/ApiDataService.java
  21. +2 −16 fluxtream-core/src/main/java/com/fluxtream/services/impl/ApiDataServiceImpl.java
  22. +6 −5 fluxtream-core/src/main/java/com/fluxtream/services/impl/GuestServiceImpl.java
  23. +10 −0 fluxtream-core/src/main/java/com/fluxtream/services/impl/SystemServiceImpl.java
  24. +57 −0 fluxtream-web/db/0.9.0006/runkeeper.sql
  25. +1,781 −0 fluxtream-web/db/0.9.0006/schema-after-0.9.0006.sql
  26. +1 −0 fluxtream-web/fluxtream-web.iml
  27. +8 −7 fluxtream-web/src/main/resources/messages/connectors.properties
  28. +1 −1 fluxtream-web/src/main/webapp/WEB-INF/applicationContext.xml
  29. +1 −1 fluxtream-web/src/main/webapp/css/connectors.css
  30. +1 −1 fluxtream-web/src/main/webapp/css/flx.css
  31. BIN fluxtream-web/src/main/webapp/images/connectors/connector-evernote.jpg
  32. BIN fluxtream-web/src/main/webapp/images/connectors/connector-evernote@2x.jpg
  33. BIN fluxtream-web/src/main/webapp/images/connectors/connector-runkeeper.jpg
  34. BIN fluxtream-web/src/main/webapp/images/connectors/connector-runkeeper@2x.jpg
  35. BIN fluxtream-web/src/main/webapp/images/devices-ic.png
  36. BIN fluxtream-web/src/main/webapp/images/devices-ic.pxm
  37. BIN fluxtream-web/src/main/webapp/images/devices-ic@2x.png
  38. BIN fluxtream-web/src/main/webapp/images/mapicons/cup.png
  39. +6 −6 fluxtream-web/src/main/webapp/js/App.js
  40. +12 −0 fluxtream-web/src/main/webapp/js/ConnectorConfig.js
  41. +3 −4 fluxtream-web/src/main/webapp/js/ManageConnectors.js
  42. +1 −1 fluxtream-web/src/main/webapp/js/applications/calendar/App.js
  43. +44 −18 fluxtream-web/src/main/webapp/js/applications/calendar/facetTemplates.html
  44. +9 −7 fluxtream-web/src/main/webapp/js/core/TabInterface.js
  45. +36 −33 fluxtream-web/src/main/webapp/less/connectors.less
  46. +3 −4 fluxtream-web/src/main/webapp/less/flx.less
  47. +1 −0 maven/install.sh
  48. BIN maven/scribe-1.3.3.jar
  49. +5 −0 pom.xml
@@ -183,6 +183,7 @@
<element id="library" level="project" name="Maven: com.sun.jersey:jersey-servlet:1.11" />
<element id="library" level="project" name="Maven: com.sun.jersey:jersey-server:1.11" />
<element id="library" level="project" name="Maven: org.aspectj:aspectjrt:1.5.4" />
+ <element id="library" level="project" name="Maven: org.scribe:scribe:1.3.3" />
<element id="archive" name="fluxtream-connectors-1.0.jar">
<element id="module-output" name="fluxtream-connectors" />
</element>
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+ <library name="Maven: junit:junit:4.8.2">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.8.2/junit-4.8.2.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.8.2/junit-4.8.2-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.8.2/junit-4.8.2-sources.jar!/" />
+ </SOURCES>
+ </library>
+</component>
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+ <library name="Maven: org.scribe:scribe:1.3.3">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/org/scribe/scribe/1.3.3/scribe-1.3.3.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/org/scribe/scribe/1.3.3/scribe-1.3.3-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/org/scribe/scribe/1.3.3/scribe-1.3.3-sources.jar!/" />
+ </SOURCES>
+ </library>
+</component>
@@ -31,7 +31,7 @@
<orderEntry type="library" name="Maven: com.ocpsoft:ocpsoft-pretty-time:1.0.7" level="project" />
<orderEntry type="library" name="Maven: com.postmark:postmark-client:0.3.1" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:1.7.1" level="project" />
- <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.8.1" level="project" />
+ <orderEntry type="library" name="Maven: junit:junit:4.8.2" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:1.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.0.1" level="project" />
@@ -191,6 +191,7 @@
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-servlet:1.11" level="project" />
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-server:1.11" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.5.4" level="project" />
+ <orderEntry type="library" name="Maven: org.scribe:scribe:1.3.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.easymock:easymock:2.5.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-servlet-api:7.0.6" level="project" />
@@ -13,5 +13,10 @@
<artifactId>fluxtream-core</artifactId>
<version>1.0</version>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ </dependency>
+ </dependencies>
</project>
@@ -0,0 +1,87 @@
+package com.fluxtream.connectors.evernote;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import com.fluxtream.Configuration;
+import com.fluxtream.auth.AuthHelper;
+import com.fluxtream.connectors.Connector;
+import com.fluxtream.domain.Guest;
+import com.fluxtream.services.GuestService;
+import org.scribe.builder.ServiceBuilder;
+import org.scribe.builder.api.EvernoteApi;
+import org.scribe.model.Token;
+import org.scribe.model.Verifier;
+import org.scribe.oauth.OAuthService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ *
+ * @author Candide Kemmler (candide@fluxtream.com)
+ */
+@Controller
+@RequestMapping(value = "/evernote")
+public class EvernoteController {
+
+ private static final String EVERNOTE_SERVICE = "evernoteService";
+ private static final String EVERNOTE_REQUEST_TOKEN = "evernoteRequestToken";
+
+ @Autowired
+ Configuration env;
+
+ @Autowired
+ GuestService guestService;
+
+
+ @RequestMapping(value = "/token")
+ public String getEvernoteToken(HttpServletRequest request) throws IOException, ServletException {
+ OAuthService service = new ServiceBuilder()
+ .provider(EvernoteApi.Sandbox.class)
+ .apiKey(getConsumerKey())
+ .apiSecret(getConsumerSecret())
+ .callback(env.get("homeBaseUrl") + "evernote/upgradeToken")
+ .build();
+ request.getSession().setAttribute(EVERNOTE_SERVICE, service);
+
+ // Obtain the Authorization URL
+ Token requestToken = service.getRequestToken();
+ request.getSession().setAttribute(EVERNOTE_REQUEST_TOKEN, requestToken);
+ String authorizationUrl = service.getAuthorizationUrl(requestToken);
+
+ return "redirect:" + authorizationUrl;
+ }
+
+ @RequestMapping(value = "/upgradeToken")
+ public String upgradeToken(HttpServletRequest request) throws IOException {
+ final String code = request.getParameter("oauth_verifier");
+ Verifier verifier = new Verifier(code);
+ OAuthService service = (OAuthService)request.getSession().getAttribute(EVERNOTE_SERVICE);
+
+ Token requestToken = (Token)request.getSession().getAttribute(EVERNOTE_REQUEST_TOKEN);
+ Token accessToken = service.getAccessToken(requestToken, verifier);
+
+ final String token = accessToken.getToken();
+ final String secret = accessToken.getSecret();
+
+ Guest guest = AuthHelper.getGuest();
+
+ guestService.setApiKeyAttribute(guest.getId(), Connector.getConnector("evernote"), "accessToken", token);
+ guestService.setApiKeyAttribute(guest.getId(), Connector.getConnector("evernote"), "tokenSecret", secret);
+
+ request.getSession().removeAttribute(EVERNOTE_REQUEST_TOKEN);
+ request.getSession().removeAttribute(EVERNOTE_SERVICE);
+ return "redirect:/app/from/evernote";
+ }
+
+ String getConsumerKey() {
+ return env.get("evernoteConsumerKey");
+ }
+
+ String getConsumerSecret() {
+ return env.get("evernoteConsumerSecret");
+ }
+
+
+}
@@ -0,0 +1,24 @@
+package com.fluxtream.connectors.evernote;
+
+import com.fluxtream.connectors.annotations.Updater;
+import com.fluxtream.connectors.updaters.AbstractUpdater;
+import com.fluxtream.connectors.updaters.UpdateInfo;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * @author Candide Kemmler (candide@fluxtream.com)
+ */
+@Component
+@Updater(prettyName = "Evernote", value = 17, objectTypes ={})
+public class EvernoteUpdater extends AbstractUpdater {
+
+ @Override
+ protected void updateConnectorDataHistory(final UpdateInfo updateInfo) throws Exception {
+ }
+
+ @Override
+ protected void updateConnectorData(final UpdateInfo updateInfo) throws Exception {
+ }
+
+}
@@ -90,7 +90,6 @@
final ObjectType loggedActivityOT = ObjectType.getObjectType(
connector(), "logged_activity");
-
static {
ObjectType.registerCustomObjectType(GET_STEPS_CALL);
ObjectType.registerCustomObjectType(GET_USER_PROFILE_CALL);
@@ -69,10 +69,10 @@ private void loadHistory(UpdateInfo updateInfo, long from, long to)
continue;
locationResource.start = locationResource.timestampMs;
locationResource.end = locationResource.timestampMs;
+ locationResource.source = LocationFacet.Source.GOOGLE_LATITUDE;
apiDataService.addGuestLocation(updateInfo.getGuestId(),
- locationResource,
- LocationFacet.Source.GOOGLE_LATITUDE);
+ locationResource);
storedLocations.add(locationResource);
}
@@ -0,0 +1,16 @@
+package com.fluxtream.connectors.runkeeper;
+
+import javax.persistence.Embeddable;
+
+/**
+ *
+ * @author Candide Kemmler (candide@fluxtream.com)
+ */
+
+@Embeddable
+public class HeartRateMeasure {
+
+ public double heartRate;
+ public double timestamp;
+
+}
@@ -0,0 +1,85 @@
+package com.fluxtream.connectors.runkeeper;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import com.fluxtream.Configuration;
+import com.fluxtream.auth.AuthHelper;
+import com.fluxtream.connectors.Connector;
+import com.fluxtream.domain.Guest;
+import com.fluxtream.services.GuestService;
+import org.scribe.builder.ServiceBuilder;
+import org.scribe.builder.api.RunKeeperApi;
+import org.scribe.model.Token;
+import org.scribe.model.Verifier;
+import org.scribe.oauth.OAuthService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ *
+ * @author Candide Kemmler (candide@fluxtream.com)
+ */
+@Controller
+@RequestMapping(value = "/runkeeper")
+public class RunKeeperController {
+
+ private static final String RUNKEEPER_SERVICE = "runkeeperService";
+
+ @Autowired
+ Configuration env;
+
+ @Autowired
+ GuestService guestService;
+
+ private static final Token EMPTY_TOKEN = null;
+
+ @RequestMapping(value = "/token")
+ public String getRunkeeperToken(HttpServletRequest request) throws IOException, ServletException {
+
+ OAuthService service = getOAuthService();
+ request.getSession().setAttribute(RUNKEEPER_SERVICE, service);
+
+ // Obtain the Authorization URL
+ String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
+
+ return "redirect:" + authorizationUrl;
+ }
+
+ public OAuthService getOAuthService() {
+ return new ServiceBuilder()
+ .provider(RunKeeperApi.class)
+ .apiKey(getConsumerKey())
+ .apiSecret(getConsumerSecret())
+ .callback(env.get("homeBaseUrl") + "runkeeper/upgradeToken")
+ .build();
+ }
+
+ @RequestMapping(value = "/upgradeToken")
+ public String upgradeToken(HttpServletRequest request) throws IOException {
+ final String code = request.getParameter("code");
+ Verifier verifier = new Verifier(code);
+ OAuthService service = (OAuthService)request.getSession().getAttribute(RUNKEEPER_SERVICE);
+
+ Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
+ final String token = accessToken.getToken();
+
+ Guest guest = AuthHelper.getGuest();
+
+ guestService.setApiKeyAttribute(guest.getId(), Connector.getConnector("runkeeper"), "accessToken", token);
+
+ request.getSession().removeAttribute(RUNKEEPER_SERVICE);
+ return "redirect:/app/from/runkeeper";
+ }
+
+ String getConsumerKey() {
+ return env.get("runkeeperConsumerKey");
+ }
+
+ String getConsumerSecret() {
+ return env.get("runkeeperConsumerSecret");
+ }
+
+
+}
Oops, something went wrong.

0 comments on commit b981394

Please sign in to comment.