Package com.pc.dailymile.domain

Examples of com.pc.dailymile.domain.Workout


                return 0;
            }
           
            while ((nextLine = reader.readNext()) != null) {
                // nextLine[] is an array of values from the line
                Workout wo = createWorkout(nextLine);
                client.addWorkout(wo, nextLine[RunKeeperField.NOTE.getFieldIndex()]);
                migrated++;
            }
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here


        return migrated;
    }

    // scoped for testing
    protected Workout createWorkout(String[] entry) {
        Workout wo = new Workout();
        wo.setType(parseWorkoutType(entry[RunKeeperField.TYPE.getFieldIndex()]));

        wo.setDuration(parseDuration(entry[RunKeeperField.DURATION.getFieldIndex()]));
        // only supporting km currently
        wo.setDistanceUnits(Units.kilometers);
        wo.setDistanceValue(entry[RunKeeperField.DISTANCE.getFieldIndex()]);
        wo.setCompletedDate(parseCompletionDate(entry[RunKeeperField.DATE.getFieldIndex()]));

        return wo;
    }
View Full Code Here

      Document doc = ParseUtil.parse(new InputSource(is));
      NodeList runs = doc.getElementsByTagName("run");
      //there should only be 2 runs in the test data
      assertEquals(2, runs.getLength());
      //test the parsing of the first one
      Workout wo = nc.createWorkout(runs.item(0));
     
      assertEquals(Type.Running, wo.getType());
      assertEquals(1163L, wo.getDuration().longValue());
      assertEquals(Units.kilometers, wo.getDistanceUnits());
      assertEquals("3.4144", wo.getDistanceValue());
     
      Calendar cal = Calendar.getInstance();
      cal.set(Calendar.MONTH, Calendar.AUGUST);
      cal.set(Calendar.DAY_OF_MONTH, 21);
      cal.set(Calendar.YEAR, 2008);
      cal.set(Calendar.HOUR_OF_DAY, 18);
      cal.set(Calendar.MINUTE, 50);
      cal.set(Calendar.SECOND, 18);
      cal.set(Calendar.MILLISECOND, 0);
     
      //assertEquals(cal.getTime(), wo.getCompletedDate());
     
      //test the parsing of the second one
      wo = nc.createWorkout(runs.item(1));
      assertEquals(Type.Running, wo.getType());
      assertEquals(1732L, wo.getDuration().longValue());
      assertEquals(Units.kilometers, wo.getDistanceUnits());
      assertEquals("5.1584", wo.getDistanceValue());
     
      cal = Calendar.getInstance();
      cal.set(Calendar.MONTH, Calendar.AUGUST);
      cal.set(Calendar.DAY_OF_MONTH, 22);
      cal.set(Calendar.YEAR, 2008);
View Full Code Here

    try {
      is = new FileInputStream(getInputFilePath());
      Document doc = ParseUtil.parse(new InputSource(is));
      NodeList runs = doc.getElementsByTagName("run");
      for (int i = 0; i < runs.getLength(); i++) {
        Workout wo = createWorkout(runs.item(i));
        client.addWorkout(wo, "Migrated from Nike+");
        migrated++;
      }
     
    } catch (Exception e) {
View Full Code Here

    return migrated;
  }
 
  //scoped for testing
  protected Workout createWorkout(Node run) {
    Workout wo = new Workout();
    //only support running
    wo.setType(Type.Running);
    wo.setDuration(parseDuration(run));
    //nike plus keeps dist in kilometers
    wo.setDistanceUnits(Units.kilometers);
    wo.setDistanceValue(parseDistance(run));
    wo.setCompletedDate(parseCompletionDate(run));

    return wo;
  }
View Full Code Here

            Document doc = ParseUtil.parse(new InputSource(is));

            NodeList runs = doc.getElementsByTagName("Event");
            for (int i = 0; i < runs.getLength(); i++) {
                Node event = runs.item(i);
                Workout wo = createWorkout(runs.item(i));
                client.addWorkout(wo, parseNotes(event));

                migrated++;
            }
            for (String foo : tmp) {
View Full Code Here

        return migrated;
    }

    // scoped for testing
    protected Workout createWorkout(Node event) {
        Workout wo = new Workout();
        wo.setType(parseWorkoutType((Element)event));

        wo.setDuration(parseDuration(event));
        // only supporting miles currently
        wo.setDistanceUnits(Units.miles);
        wo.setDistanceValue(parseDistance(event));
        wo.setCompletedDate(parseCompletionDate((Element) event));

        return wo;
    }
View Full Code Here

               
            //first row is headers, so start at 1
            String[] nextLine = lines.get(1);
           
            Workout wo = rkc.createWorkout(nextLine);
            assertEquals(Type.Running, wo.getType());
            assertEquals(1740L, wo.getDuration().longValue());
            assertEquals(Units.kilometers, wo.getDistanceUnits());
            assertEquals("1.17", wo.getDistanceValue());
           
            nextLine = lines.get(2);
            wo = rkc.createWorkout(nextLine);
            assertEquals(Type.Walking, wo.getType());
            assertEquals(1241L, wo.getDuration().longValue());
            assertEquals(Units.kilometers, wo.getDistanceUnits());
            assertEquals("0.96", wo.getDistanceValue());

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
View Full Code Here

            Document doc = ParseUtil.parse(new InputSource(is));
            NodeList events = doc.getElementsByTagName("Event");
            // there should only be 8 events in the test data
            assertEquals(8, events.getLength());
            // test the parsing of the first one
            Workout wo = nc.createWorkout(events.item(0));

            assertEquals(Type.Running, wo.getType());
            assertEquals(1901L, wo.getDuration().longValue());
            assertEquals(Units.miles, wo.getDistanceUnits());
            assertEquals("3.46", wo.getDistanceValue());

            // 2008-04-28T10:27:36Z
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.MONTH, Calendar.APRIL);
            cal.set(Calendar.DAY_OF_MONTH, 28);
            cal.set(Calendar.YEAR, 2008);
            cal.set(Calendar.HOUR_OF_DAY, 6);
            cal.set(Calendar.MINUTE, 27);
            cal.set(Calendar.SECOND, 36);
            cal.set(Calendar.MILLISECOND, 0);

            assertEquals(cal.getTime(), wo.getCompletedDate());

            // test the parsing of the second one
            wo = nc.createWorkout(events.item(1));
            assertEquals(Type.Yoga, wo.getType());
            assertEquals(5400L, wo.getDuration().longValue());

            wo = nc.createWorkout(events.item(2));
            assertEquals(Type.Cycling, wo.getType());
            assertEquals(3600L, wo.getDuration().longValue());
            assertEquals(Units.miles, wo.getDistanceUnits());
            assertEquals("20.80", wo.getDistanceValue());
           
            wo = nc.createWorkout(events.item(3));
            assertEquals(Type.Fitness, wo.getType());
            assertEquals(4200L, wo.getDuration().longValue());
           
            wo = nc.createWorkout(events.item(4));
            assertEquals(Type.Walking, wo.getType());
            assertEquals(6351L, wo.getDuration().longValue());
            assertEquals(Units.miles, wo.getDistanceUnits());
            assertEquals("3.75", wo.getDistanceValue());
           
            wo = nc.createWorkout(events.item(5));
            assertEquals(Type.Weights, wo.getType());
            assertEquals(3600L, wo.getDuration().longValue());
           
            wo = nc.createWorkout(events.item(6));
            assertEquals(Type.CrossTraining, wo.getType());
            assertEquals(7200L, wo.getDuration().longValue());
           
            wo = nc.createWorkout(events.item(7));
            assertEquals(Type.Hiking, wo.getType());
            assertEquals(11400L, wo.getDuration().longValue());
            assertEquals(Units.miles, wo.getDistanceUnits());
            assertEquals("5.97", wo.getDistanceValue());

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (is != null) {
View Full Code Here

TOP

Related Classes of com.pc.dailymile.domain.Workout

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.