コード例 #1
0
ファイル: TimeTrack.java プロジェクト: haninaguib/gvmax
 public long mark(String label, long time) {
   TimeEntry entry = new TimeEntry();
   entry.label = label;
   entry.time = time;
   entries.add(entry);
   return entry.time;
 }
コード例 #2
0
  public void addEntry(TimeEntry entry) {
    ContentValues values = new ContentValues();
    values.put(TimeEntryContract.TimeEntry.COLUMN_NAME_DATE, entry.getFormattedDate());
    values.put(TimeEntryContract.TimeEntry.COLUMN_NAME_HOURS, entry.getHours());

    getDb().insert(TimeEntryContract.TimeEntry.TABLE_NAME, null, values);
  }
コード例 #3
0
ファイル: TimeTrack.java プロジェクト: haninaguib/gvmax
 public long mark(String label) {
   TimeEntry entry = new TimeEntry();
   entry.label = label;
   entry.time = System.currentTimeMillis();
   entries.add(entry);
   return entry.time;
 }
コード例 #4
0
ファイル: JTogglTest.java プロジェクト: ppalex7/jtoggl
  @Test
  public void updateTimeEntry() {
    final String DESCRIPTION = "ABC";

    timeEntry.setDescription(DESCRIPTION);
    TimeEntry te = jToggl.updateTimeEntry(timeEntry);

    Assert.assertNotNull(te);
    Assert.assertEquals(DESCRIPTION, te.getDescription());
  }
コード例 #5
0
ファイル: Simple.java プロジェクト: grundid/redmine-java-api
 private static void generateXMLForTimeEntry() {
   TimeEntry o = new TimeEntry();
   o.setId(13);
   o.setIssueId(45);
   o.setActivityId(3);
   o.setProjectId(55);
   o.setUserId(66);
   o.setHours(123f);
   o.setComment("text here");
   o.setSpentOn(new Date());
   String xml = RedmineXMLGenerator.toXML(o);
   logger.debug(xml);
 }
コード例 #6
0
 public void resume() {
   switch (status) {
     case PAUSED:
       long now = now();
       global.resume(now);
       for (TimeEntry entry : splitStack) {
         entry.resume(now);
       }
       status = Status.RUN;
       break;
     case RUN:
       // no-op;
       break;
     default:
       throw new IllegalArgumentException("unknow status: " + status);
   }
 }
コード例 #7
0
ファイル: JTogglTest.java プロジェクト: ppalex7/jtoggl
 @AfterClass
 public static void afterClass() throws Exception {
   jToggl.destroyTimeEntry(timeEntry.getId());
   jToggl.destroyClient(client.getId());
   try {
     jToggl.destroyTask(task.getId());
   } catch (Exception e) {
     // Ignore because Task is only for paying customers
   }
 }
コード例 #8
0
 public void split(String name) {
   TimeEntry entry = new TimeEntry();
   entry.name = name;
   if (!splitNameCache.contains(name)) {
     splitNameCache.add(name);
   }
   switch (status) {
     case PAUSED:
       entry.reset();
       splitStack.add(entry);
       break;
     case RUN:
       splitStack.add(entry);
       // set time later
       entry.resume(now());
       break;
     default:
       throw new IllegalArgumentException("unknow status: " + status);
   }
 }
コード例 #9
0
 private long[] getSplitsByName(String name, long now) {
   List<Long> list = times.get(name);
   TimeEntry inSplitting = null;
   for (TimeEntry entry : splitStack) {
     if (entry.name.equals(name)) {
       inSplitting = entry;
     }
   }
   long[] ret = new long[(list == null ? 0 : list.size()) + (inSplitting == null ? 0 : 1)];
   if (list != null) {
     int i = 0;
     for (long l : list) {
       ret[i] = l;
       i++;
     }
   }
   if (inSplitting != null) {
     ret[ret.length - 1] = inSplitting.total(now);
   }
   return ret;
 }
コード例 #10
0
 public void unsplit() {
   long now = now();
   TimeEntry timeEntry = splitStack.peek();
   if (timeEntry != null) {
     splitStack.pop();
   } else {
     return;
   }
   switch (status) {
     case RUN:
       timeEntry.pause(now);
     case PAUSED:
       List<Long> list = times.get(timeEntry.name);
       if (list == null) {
         list = new ArrayList<Long>();
         times.put(timeEntry.name, list);
       }
       list.add(timeEntry.total(now));
       break;
     default:
       throw new IllegalArgumentException("unknow status: " + status);
   }
 }
コード例 #11
0
 private long total(String name, long now, TimeUnit unit) {
   switch (status) {
     case PAUSED:
     case RUN:
       long d = 0L;
       if (name == null) {
         d = global.total(now);
       } else {
         long[] entries = getSplitsByName(name, now);
         for (long entry : entries) {
           d += entry;
         }
       }
       return unit.convert(d, UNIT);
     default:
       throw new IllegalArgumentException("unknow status: " + status);
   }
 }
コード例 #12
0
ファイル: JTogglTest.java プロジェクト: ppalex7/jtoggl
  private static TimeEntry createTimeEntry() throws Exception {
    TimeEntry entry = new TimeEntry();
    entry.setDuration(480);
    entry.setBillable(true);
    ZoneId tz = TimeZone.getTimeZone("Europe/Moscow").toZoneId();
    ZonedDateTime start = ZonedDateTime.of(2011, 10, 15, 8, 0, 0, 0, tz);
    entry.setStart(start);
    ZonedDateTime stop = ZonedDateTime.of(2011, 10, 15, 16, 0, 0, 0, tz);
    entry.setStop(stop);
    entry.setDescription("From JUnit Test");
    entry.setCreated_with("JUnit");

    entry = jToggl.createTimeEntry(entry);
    Assert.assertNotNull(entry);

    return entry;
  }
コード例 #13
0
ファイル: JTogglTest.java プロジェクト: ppalex7/jtoggl
  @Test
  public void getTimeEntriesWithRange2() {
    List<TimeEntry> entries = jToggl.getTimeEntries(timeEntry.getStart(), timeEntry.getStop());

    Assert.assertTrue(!entries.isEmpty());
  }
コード例 #14
0
ファイル: JTogglTest.java プロジェクト: ppalex7/jtoggl
  @Test
  public void startStopTimeEntry() throws Exception {
    TimeEntry current = jToggl.getCurrentTimeEntry();
    Assert.assertNull(current);

    TimeEntry timeEntry = new TimeEntry();
    timeEntry.setWorkspace(workspace);
    timeEntry.setProject(project);
    timeEntry.setDescription("ABCD");
    timeEntry.setCreated_with("JToggl Unit Test");

    TimeEntry te = jToggl.startTimeEntry(timeEntry);

    try {
      Assert.assertNotNull(te.getId()); // created
      Assert.assertTrue(te.getDuration() < 0); // running

      current = jToggl.getCurrentTimeEntry();
      Assert.assertNotNull(current);
      Assert.assertEquals(current.getId(), te.getId());

      Thread.sleep(2000);

      TimeEntry stoppedTe = jToggl.stopTimeEntry(te);

      Assert.assertEquals(te.getId(), stoppedTe.getId());
      Assert.assertTrue(stoppedTe.toJSONString(), stoppedTe.getDuration() > 1); // stopped

      current = jToggl.getCurrentTimeEntry();
      Assert.assertNull(current);
    } finally {
      jToggl.destroyTimeEntry(te.getId());
    }
  }
コード例 #15
0
ファイル: JTogglTest.java プロジェクト: ppalex7/jtoggl
  @Test
  public void getTimeEntry() {
    TimeEntry te = jToggl.getTimeEntry(timeEntry.getId());

    Assert.assertNotNull(te);
  }
コード例 #16
0
 public void reset() {
   status = Status.PAUSED;
   global.reset();
   times.clear();
   splitStack.clear();
 }