Package org.joda.time

Examples of org.joda.time.DateTimeComparator


     * @throws Exception If either storing the data fails or if the rate limit is reached on Bodymedia's api
     */
    private void retrieveHistory(UpdateInfo updateInfo, ObjectType ot, DateTime start, DateTime end) throws Exception {
        final String urlExtension = url.get(ot);
        final int increment = maxIncrement.get(ot);
        DateTimeComparator comparator = DateTimeComparator.getDateOnlyInstance();
        DateTime current = start;

        // Setup the rate delay if we haven't already
        Long rateDelay = getRateDelay(updateInfo);

        try {
            //  Loop from start to end, incrementing by the max number of days you can
            //  specify for a given type of query.  This is 1 for burn and sleep, and 31 for steps.
            //@ loop_invariant date.compareTo(userRegistrationDate) >= 0;
            while (comparator.compare(current, end) < 0)
            {
                if (guestService.getApiKey(updateInfo.apiKey.getId())==null) {
                    logger.info("Not updating BodyMedia connector instance with a deleted apiKeyId");
                    return;
                }
View Full Code Here


    // Update the start date for next time.  The parameter the updateProgressDate is the date
    // of that retrieveHistory had gotten to when it completed or gave up.
    // If lastSync is set and is < updateProgressDate we will use that, and otherwise use updateProgressDate.
    void updateStartDate(UpdateInfo updateInfo, ObjectType ot, DateTime updateProgressTime)
    {
        DateTimeComparator comparator = DateTimeComparator.getDateOnlyInstance();

        // Calculate the name of the key in the ApiAttributes table
        // where the next start of update for this object type is
        // stored and retrieve the stored value.  This stored value
        // may potentially be null if something happened to the attributes table
        String updateKeyName = "BodyMedia." + ot.getName() + ".updateStartDate";
        String storedUpdateStartDate = guestService.getApiKeyAttribute(updateInfo.apiKey, updateKeyName);

        // Retrieve the lastSync date if it has been added to the
        // updateInfo context by an extractor
        DateTime lastSync = (DateTime)updateInfo.getContext("lastSync");


        // Check which is earlier: the lastSync time returned from Bodymedia or the
        // point we were in the update that just ended.  Store the lesser of the two
        // in nextUpdateStartDate
        String nextUpdateStartDate = storedUpdateStartDate;
        if (lastSync != null) {
            if (comparator.compare(updateProgressTime, lastSync) > 0) {
                // lastSync from Bodymedia is less than the update progress
                nextUpdateStartDate = lastSync.toString(formatter);
            }
            else {
                // the update progress is less than lastSync from Bodymedia
View Full Code Here

TOP

Related Classes of org.joda.time.DateTimeComparator

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.