Package org.fluxtream.core.domain

Examples of org.fluxtream.core.domain.AbstractFacet


            }
            if (minTime < Long.MAX_VALUE)
                return minTime;
        }
        //if we couldn't get the minTime from ApiKey Attributes fallback to oldest facet
        AbstractFacet facet;
        if (objectTypes == null || objectTypes.length == 0){
            facet = apiDataService.getOldestApiDataFacet(apiKey,null);
        }
        else{
            facet = null;
            for (ObjectType objectType : objectTypes){
                AbstractFacet potentialFacet = apiDataService.getOldestApiDataFacet(apiKey,objectType);
                if (facet == null || facet.start > potentialFacet.start)
                    facet = potentialFacet;
            }
        }
        if (facet != null)
View Full Code Here


            }
            if (maxTime > Long.MIN_VALUE)
                return maxTime;
        }
        //if we couldn't get the minTime from ApiKey Attributes fallback to oldest facet
        AbstractFacet facet;
        if (objectTypes == null || objectTypes.length == 0){
            facet = apiDataService.getLatestApiDataFacet(apiKey,null);
        }
        else{
            facet = null;
            for (ObjectType objectType : objectTypes){
                AbstractFacet potentialFacet = apiDataService.getLatestApiDataFacet(apiKey,objectType);
                if (potentialFacet != null && (facet == null || facet.end < potentialFacet.end))
                    facet = potentialFacet;
            }
        }
        if (facet != null)
View Full Code Here

    private AbstractFacet getFacet(final ApiKey apiKey, final ObjectType objectType, final String methodName) {
        if (!apiKey.getConnector().hasFacets()) {
            return null;
        }

        AbstractFacet facet = null;
        if (objectType != null) {
            try {
                Class c = objectType.facetClass();
                Method m = c.getMethod(methodName, EntityManager.class, ApiKey.class, ObjectType.class);
                facet = (AbstractFacet)m.invoke(null, em, apiKey, objectType);
            }
            catch (Exception ignored) {
                if (logger.isInfoEnabled()) {
                    logger.info("JPAFacetDao.getFacet(): ignoring exception '" + ignored.getClass() + "' while trying to invoke method '" + methodName + "'");
                }
            }
        }
        else {
            if (apiKey.getConnector().objectTypes() != null) {
                for (ObjectType type : apiKey.getConnector().objectTypes()) {
                    AbstractFacet fac = null;
                    try {
                        Class c = type.facetClass();
                        Method m = c.getMethod(methodName, EntityManager.class, ApiKey.class, ObjectType.class);
                        fac = (AbstractFacet)m.invoke(null, em, apiKey, type);
                    }
View Full Code Here

    }

    private void deleteFacetsOneByOne(final ApiKey apiKey, final Class<? extends AbstractFacet> facetClass) {
        List<? extends AbstractFacet> facets = getAllFacets(apiKey, facetClass);
        for (AbstractFacet facet : facets) {
            final AbstractFacet merged = em.merge(facet);
            em.remove(merged);
        }
    }
View Full Code Here

  }

    @Override
    @Transactional(readOnly=false)
    public void delete(AbstractFacet facet) {
        AbstractFacet merged = em.merge(facet);
        em.remove(merged);
    }
View Full Code Here

    Map<String, List<AbstractFacet>> facetsByFacetName = sortFacetsByFacetName(facets);
        for (final String facetName : facetsByFacetName.keySet()) {
            List<BodyTrackHelper.BodyTrackUploadResult> results = storeDeviceData(guestId, facetsByFacetName, facetName);
            if (!results.isEmpty()){
                AbstractFacet facet = facetsByFacetName.get(facetName).get(0);
                long apiKeyId = facet.apiKeyId;
                long objectTypeId = facet.objectType;
                for (BodyTrackHelper.BodyTrackUploadResult result : results){
                    if (!(result instanceof BodyTrackHelper.ParsedBodyTrackUploadResult))
                        continue;
View Full Code Here

     * Returns the {@link SimpleTimeInterval} for the oldest and newest facets.  Returns <code>null</code> if no facets exist.
     */
    private TimeInterval constructTimeIntervalFromOldestAndNewestFacets(final ApiKey apiKey,
                                                                        final ObjectType objectType) {
        final PhotoFacetFinderStrategy photoFacetFinderStrategy = getPhotoFacetFinderStrategyFromObjectType(objectType);
        final AbstractFacet oldestFacet = photoFacetFinderStrategy.findOldest(apiKey, objectType);
        final AbstractFacet newestFacet = photoFacetFinderStrategy.findLatest(apiKey, objectType);

        if (oldestFacet != null && newestFacet != null) {
            return new SimpleTimeInterval(oldestFacet.start, newestFacet.start, TimeUnit.ARBITRARY, TimeZone.getTimeZone("UTC"));
        }

View Full Code Here

    private void loadIntradayDataForOneDay(UpdateInfo updateInfo, String dateString)
            throws AuthExpiredException, RateLimitReachedException, UpdateFailedException, NoSuchFieldException, IllegalAccessException, UnexpectedResponseCodeException {
        if (!isIntradayDataEnabled()) return;
        final List<AbstractFacet> facetsByDates = facetDao.getFacetsByDates(updateInfo.apiKey, ObjectType.getObjectType(connector(), 1), Arrays.asList(dateString));
        if (facetsByDates.size()>0) {
            final AbstractFacet facet = facetsByDates.get(0);
            if (facet!=null) {
                FitbitTrackerActivityFacet activityFacet = (FitbitTrackerActivityFacet) facet;
                updateIntradayMetrics(updateInfo, activityFacet);
                bodyTrackStorageService.storeApiData(updateInfo.getGuestId(), Arrays.asList(facet));
            } else {
View Full Code Here

                    if (measuresMap.get(FAT_RATIO)!=null)
                        facet.fatRatio = measuresMap.get(FAT_RATIO);
                    return facet;
                }
            };
            final AbstractFacet createdOrModifiedFacet = apiDataService.createOrReadModifyWrite(WithingsBodyScaleMeasureFacet.class, facetQuery, facetModifier, updateInfo.apiKey.getId());
            bodyTrackStorageService.storeApiData(updateInfo.apiKey.getGuestId(), Arrays.asList(createdOrModifiedFacet));
        }
        if (measuresMap.containsKey(DIASTOLIC_BLOOD_PRESSURE) &&
            measuresMap.containsKey(SYSTOLIC_BLOOD_PRESSURE) &&
            measuresMap.get(DIASTOLIC_BLOOD_PRESSURE)>0f &&
            measuresMap.get(SYSTOLIC_BLOOD_PRESSURE)>0f) {
            final ApiDataService.FacetModifier<WithingsBPMMeasureFacet> facetModifier = new ApiDataService.FacetModifier<WithingsBPMMeasureFacet>() {
                @Override
                public WithingsBPMMeasureFacet createOrModify(WithingsBPMMeasureFacet facet, final Long apiKeyId) {
                    if (facet==null)
                        facet = new WithingsBPMMeasureFacet(updateInfo.apiKey.getId());
                    extractCommonFacetData(facet, updateInfo);
                    facet.objectType = ObjectType.getObjectType(connector, "blood_pressure").value();
                    facet.measureTime = date;
                    facet.start = date;
                    facet.end = date;
                    facet.systolic = measuresMap.get(SYSTOLIC_BLOOD_PRESSURE);
                    facet.diastolic = measuresMap.get(DIASTOLIC_BLOOD_PRESSURE);
                    if (measuresMap.get(HEART_PULSE)!=null)
                       facet.heartPulse = measuresMap.get(HEART_PULSE);
                    return facet;
                }
            };
            final AbstractFacet createdOrModifiedFacet = apiDataService.createOrReadModifyWrite(WithingsBPMMeasureFacet.class, facetQuery, facetModifier, updateInfo.apiKey.getId());
            bodyTrackStorageService.storeApiData(updateInfo.apiKey.getGuestId(), Arrays.asList(createdOrModifiedFacet));
        }
        if (measuresMap.containsKey(HEART_PULSE)) {
            final ApiDataService.FacetModifier<WithingsHeartPulseMeasureFacet> facetModifier = new ApiDataService.FacetModifier<WithingsHeartPulseMeasureFacet>() {
                @Override
                public WithingsHeartPulseMeasureFacet createOrModify(WithingsHeartPulseMeasureFacet facet, final Long apiKeyId) {
                    if (facet==null)
                        facet = new WithingsHeartPulseMeasureFacet(updateInfo.apiKey.getId());
                    extractCommonFacetData(facet, updateInfo);
                    facet.objectType = ObjectType.getObjectType(connector, "heart_pulse").value();
                    facet.start = date;
                    facet.end = date;
                    facet.heartPulse = measuresMap.get(HEART_PULSE);
                    return facet;
                }
            };
            final AbstractFacet createdOrModifiedFacet = apiDataService.createOrReadModifyWrite(WithingsHeartPulseMeasureFacet.class, facetQuery, facetModifier, updateInfo.apiKey.getId());
            bodyTrackStorageService.storeApiData(updateInfo.apiKey.getGuestId(), Arrays.asList(createdOrModifiedFacet));
        }
    }
View Full Code Here

                if (activityData.has("elevation"))
                    facet.elevation = (float) activityData.getDouble("elevation");
                return facet;
            };
        };
        final AbstractFacet createdOrModifiedFacet = apiDataService.createOrReadModifyWrite(WithingsActivityFacet.class, facetQuery, facetModifier, updateInfo.apiKey.getId());
        bodyTrackStorageService.storeApiData(updateInfo.apiKey.getGuestId(), Arrays.asList(createdOrModifiedFacet));
    }
View Full Code Here

TOP

Related Classes of org.fluxtream.core.domain.AbstractFacet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.