Package org.fluxtream.core

Examples of org.fluxtream.core.TimezoneMap


        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
        final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
        final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        ArbitraryTimespanMetadata info = new ArbitraryTimespanMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, start, end);
        return info;
    }
View Full Code Here


            }
        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        TreeMap<String, TimeZone> consensusTimezoneMap = new TreeMap<String, TimeZone>();
        consensusTimezoneMap.put(date, TimeZone.getTimeZone(consensusVisitedCity.city.geo_timezone));
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        List<VisitedCity> consensusVisitedCities = Arrays.asList(consensusVisitedCity);
        DayMetadata info = new DayMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusVisitedCities, date);
        return info;
    }
View Full Code Here

        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
        final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
        final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        WeekMetadata info = new WeekMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, year, week);
        return info;
    }
View Full Code Here

        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
        final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
        final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        MonthMetadata info = new MonthMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, year, month);
        return info;
    }
View Full Code Here

        if(bodymediaResponse.has("days") && bodymediaResponse.has("lastSync"))
        {
            DateTime d = form.parseDateTime(bodymediaResponse.getJSONObject("lastSync").getString("dateTime"));

            // Get timezone map from UpdateInfo context
            TimezoneMap tzMap = (TimezoneMap)updateInfo.getContext("tzMap");

            // Insert lastSync into the updateInfo context so it's accessible to the updater
            updateInfo.setContext("lastSync", d);

            JSONArray daysArray = bodymediaResponse.getJSONArray("days");
            for(Object o : daysArray)
            {
                if(o instanceof JSONObject)
                {
                    JSONObject day = (JSONObject) o;
                    BodymediaBurnFacet burn = new BodymediaBurnFacet(apiData.updateInfo.apiKey.getId());
                    //The following call must be made to load data about he facets
                    super.extractCommonFacetData(burn, apiData);
                    burn.setTotalCalories(day.getInt("totalCalories"));
                    burn.date = day.getString("date");
                    burn.setEstimatedCalories(day.getInt("estimatedCalories"));
                    burn.setPredictedCalories(day.getInt("predictedCalories"));
                    burn.json = day.getString("minutes");
                    burn.lastSync = d.getMillis();

                    DateTime date = formatter.parseDateTime(day.getString("date"));
                    burn.date = TimeUtils.dateFormatter.print(date.getMillis());

                    if(tzMap!=null)
                    {
                        // Create a LocalDate object which just captures the date without any
                        // timezone assumptions
                        LocalDate ld = new LocalDate(date.getYear(),date.getMonthOfYear(),date.getDayOfMonth());
                        // Use tzMap to convert date into a datetime with timezone information
                        DateTime realDateStart = tzMap.getStartOfDate(ld);
                        // Set the start and end times for the facet.  The start time is the leading midnight
                        // of burn.date according to BodyMedia's idea of what timezone you were in then.
                        // End should, I think, be start + the number of minutes in the minutes array *
                        // the number of milliseconds in a minute.
                        burn.start = realDateStart.getMillis();
View Full Code Here

            if(bodymediaResponse.has("lastSync"))
            {
                DateTime d = form.parseDateTime(bodymediaResponse.getJSONObject("lastSync").getString("dateTime"));

                // Get timezone map from UpdateInfo context
                TimezoneMap tzMap = (TimezoneMap)updateInfo.getContext("tzMap");

                // Insert lastSync into the updateInfo context so it's accessible to the updater
                updateInfo.setContext("lastSync", d);

                for(Object o : daysArray)
                {
                    if(o instanceof JSONObject)
                    {
                        JSONObject day = (JSONObject) o;
                        BodymediaSleepFacet sleep = new BodymediaSleepFacet(updateInfo.apiKey.getId());
                        super.extractCommonFacetData(sleep, apiData);
                        sleep.efficiency = day.getDouble("efficiency");
                        sleep.totalLying = day.getInt("totalLying");
                        sleep.totalSleeping = day.getInt("totalSleep");
                        sleep.json = day.getString("sleepPeriods");
                        sleep.lastSync = d.getMillis();

                        //https://developer.bodymedia.com/docs/read/api_reference_v2/Sleep_Service
                        //  sleep data is from noon the previous day to noon the current day,
                        //  so subtract MILLIS_IN_DAY/2 from midnight

                        long MILLIS_IN_DAY = 86400000l;
                        DateTime date = formatter.parseDateTime(day.getString("date"));

                        if(tzMap!=null)
                        {
                            // Create a LocalDate object which just captures the date without any
                            // timezone assumptions
                            LocalDate ld = new LocalDate(date.getYear(),date.getMonthOfYear(),date.getDayOfMonth());
                            // Use tzMap to convert date into a datetime with timezone information
                            DateTime realDateStart = tzMap.getStartOfDate(ld);
                            // Set the start and end times for the facet.  The start time is the leading midnight
                            // of burn.date according to BodyMedia's idea of what timezone you were in then.
                            // End should, I think, be start + the number of minutes in the minutes array *
                            // the number of milliseconds in a minute.
                            sleep.date = TimeUtils.dateFormatter.print(realDateStart.getMillis());
View Full Code Here

        if(bodymediaResponse.has("lastSync"))
        {
            DateTime d = form.parseDateTime(bodymediaResponse.getJSONObject("lastSync").getString("dateTime"));

            // Get timezone map from UpdateInfo context
            TimezoneMap tzMap = (TimezoneMap)updateInfo.getContext("tzMap");

            // Insert lastSync into the updateInfo context so it's accessible to the updater
            updateInfo.setContext("lastSync", d);

            for(Object o : daysArray)
            {
                if(o instanceof JSONObject)
                {
                    JSONObject day = (JSONObject) o;
                    BodymediaStepsFacet steps = new BodymediaStepsFacet(apiData.updateInfo.apiKey.getId());
                    super.extractCommonFacetData(steps, apiData);
                    steps.totalSteps = day.getInt("totalSteps");
                    steps.date = day.getString("date");
                    steps.json = day.getString("hours");
                    steps.lastSync = d.getMillis();

                    DateTime date = formatter.parseDateTime(day.getString("date"));
                    steps.date = TimeUtils.dateFormatter.print(date.getMillis());
                    if(tzMap!=null)
                    {
                        // Create a LocalDate object which just captures the date without any
                        // timezone assumptions
                        LocalDate ld = new LocalDate(date.getYear(),date.getMonthOfYear(),date.getDayOfMonth());
                        // Use tzMap to convert date into a datetime with timezone information
                        DateTime realDateStart = tzMap.getStartOfDate(ld);
                        // Set the start and end times for the facet.  The start time is the leading midnight
                        // of date according to BodyMedia's idea of what timezone you were in then.
                        // Need to figure out what end should be...
                        steps.start = realDateStart.getMillis();
                        int minutesLength = 1440;
View Full Code Here

        }
        // Check if the token has expired, and if so try to exchange it
        checkAndReplaceOauthToken(updateInfo);

        // Get timezone map for this user
        TimezoneMap tzMap = getTimezoneMap(updateInfo);

        // Insert tzMap into the updateInfo context so it's accessible to the extractors
        updateInfo.setContext("tzMap", tzMap);

        for (ObjectType ot : connector().objectTypes()) {
View Full Code Here

                if(bodymediaResponse.has("lastSync"))
                {
                    DateTime d = form.parseDateTime(bodymediaResponse.getJSONObject("lastSync").getString("dateTime"));

                    // Get timezone map from UpdateInfo context
                    TimezoneMap tzMap = (TimezoneMap)updateInfo.getContext("tzMap");

                    // Insert lastSync into the updateInfo context so it's accessible to the updater
                    updateInfo.setContext("lastSync", d);
                    List<AbstractFacet> newFacets = new ArrayList<AbstractFacet>();
                    for(Object o : daysArray)
View Full Code Here

    public TimezoneMap getTimezoneMap(UpdateInfo updateInfo) throws Exception {
            OAuthConsumer consumer = setupConsumer(updateInfo.apiKey);
            String api_key = guestService.getApiKeyAttribute(updateInfo.apiKey, "bodymediaConsumerKey");
            JSONArray timezoneMapJson = getUserTimezoneHistory(updateInfo, api_key, consumer);
            TimezoneMap ret= new TimezoneMap();

            try{
                for(int i=0; i<timezoneMapJson.size(); i++) {
                    JSONObject jsonRecord = timezoneMapJson.getJSONObject(i);
                    final String tzName = jsonRecord.getString("value");
                    final String startDateStr = jsonRecord.getString("startDate");
                    final String endDateStr = jsonRecord.optString("endDate");
                    DateTime startDate;
                    DateTime endDate;
                    DateTimeZone tz;

                    tz = DateTimeZone.forID(tzName);
                    startDate = tzmapFormatter.parseDateTime(startDateStr);
                    if(endDateStr.equals("")) {
                        // Last entry in table has no endDate, set it to be one day in the future
                        endDate=new DateTime(tz).plusDays(1);
                    }
                    else {
                        endDate = tzmapFormatter.parseDateTime(endDateStr);
                    }

                    ret.add(startDate.getMillis(), endDate.getMillis(),tz);
                }

            } catch (Throwable e){
                StringBuilder sb = new StringBuilder("module=updateQueue component=updater action=BodymediaUpdater.getTimezoneMap")
                                    .append(" message=\"exception while getting timezone map\" connector=")
View Full Code Here

TOP

Related Classes of org.fluxtream.core.TimezoneMap

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.