Examples of TimeEntry


Examples of com.taskadapter.redmineapi.bean.TimeEntry

    }
  }

  @Test
  public void testTimeEntryDefaults() throws RedmineException {
    final TimeEntry template = TimeEntryFactory.create();

    final Issue tmp = IssueFactory.createWithSubject("aaabbbccc");
    final Issue tmpIssue = issueManager.createIssue(projectKey, tmp);
    try {
      template.setHours(123.f);
      template.setActivityId(ACTIVITY_ID);
      template.setIssueId(tmpIssue.getId());
      final TimeEntry result = issueManager.createTimeEntry(template);
      try {
        Assert.assertNotNull(result.getId());
        Assert.assertNotNull(result.getIssueId());
        Assert.assertNotNull(result.getProjectId());
        Assert.assertNotNull(result.getProjectName());
        Assert.assertNotNull(result.getUserName());
        Assert.assertNotNull(result.getUserId());
        Assert.assertNotNull(result.getActivityName());
        Assert.assertNotNull(result.getActivityId());
        Assert.assertEquals(Float.valueOf(123.0f), result.getHours());
        Assert.assertEquals("", result.getComment());
        Assert.assertNotNull(result.getSpentOn());
        Assert.assertNotNull(result.getCreatedOn());
        Assert.assertNotNull(result.getUpdatedOn());
      } finally {
        issueManager.deleteTimeEntry(result.getId());
      }
    } finally {
            issueManager.deleteIssue(tmpIssue.getId());
    }
  }
View Full Code Here

Examples of com.taskadapter.redmineapi.bean.TimeEntry

  }

  @Test
  public void testTimeEntryDefaults() throws JSONException {
    final String MINIMAL_TIME_ENTRY = "{\"time_entry\":{\"issue\":{\"id\":1931},\"created_on\":\"2012/05/16 01:40:29 -0700\",\"project\":{\"name\":\"test project\",\"id\":1072},\"updated_on\":\"2012/05/16 01:40:29 -0700\",\"user\":{\"name\":\"Redmine Admin\",\"id\":1},\"hours\":123.0,\"id\":166,\"spent_on\":\"2012/05/16\",\"activity\":{\"name\":\"Design\",\"id\":8}}}";
    final TimeEntry entry = parse(MINIMAL_TIME_ENTRY, "time_entry",
        RedmineJSONParser.TIME_ENTRY_PARSER);
    Assert.assertEquals("", entry.getComment());
  }
View Full Code Here

Examples of net.sf.redmine_mylyn.api.model.TimeEntry

    return attachment;
  }
 
  @SuppressWarnings({ "rawtypes", "unchecked" })
  static TimeEntry buildTimeEntry(int id, float hours, int activityId, int userId, String spentOn, String comments, CustomValue... values) throws Exception {
    TimeEntry te = new TimeEntry();
    setId(te, id);
    te.setHours(hours);
    te.setActivityId(activityId);
    te.setUserId(userId);
    te.setSpentOn(df.parse(spentOn));
    te.setComments(comments);
    te.setCustomValues(new CustomValues());
    List lst = getList(te.getCustomValues());
    for (CustomValue v : values) {
      lst.add(v);
    }
    return te;
  }
View Full Code Here

Examples of net.sf.redmine_mylyn.api.model.TimeEntry

    /* TimeEntries + sum*/
    /* affected by TaskAttributeMapper, RedmineTaskAttributeMapper, TaskTimeEntryMapper */
//    assertEquals(""+issue.getTimeEntries().getSum(), root.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_TOTAL).getValue());
    assertEquals("4.25", root.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_TOTAL).getValue());
   
    TimeEntry te = issue.getTimeEntries().get(1);
    attribute = root.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_PREFIX + te.getId());
    assertNotNull(attribute);
    assertEquals(""+te.getId(), attribute.getValue());

    assertEquals(""+te.getUserId(), attribute.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_AUTHOR).getValue());
    assertEquals(""+te.getActivityId(), attribute.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_ACTIVITY).getValue());
    assertEquals(""+te.getHours(), attribute.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_HOURS).getValue());
    assertEquals(""+te.getComments(), attribute.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_COMMENTS).getValue());
    assertEquals(""+te.getSpentOn().getTime(), attribute.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_SPENTON).getValue());
    assertEquals("1", attribute.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_CF+"7").getValue());
   
    fail("Not finished yet implemented");
  }
View Full Code Here

Examples of net.sf.redmine_mylyn.api.model.TimeEntry

  @Test
  public void createTimeEntry() throws Exception {
    TaskData taskData = buildEmptyTaskData(TestData.issue2);
    fillTaskData(taskData, TestData.issue2);
   
    TimeEntry timeEntry = IssueMapper.createTimeEntry(repository, taskData, null, cfg);
    assertNotNull(timeEntry);
   
    assertEquals(1.5, timeEntry.getHours(), 0.0);
    assertEquals(1, timeEntry.getActivityId());
    assertEquals("hard work", timeEntry.getComments());

    //CustomValues
    CustomValues customValues = timeEntry.getCustomValues();
    assertNotNull(customValues);
    assertNotNull(customValues.getAll());
    assertEquals(2, customValues.getAll().size());
    assertEquals("1", customValues.getByCustomFieldId(7).getValue());
    assertEquals("2010-08-20", customValues.getByCustomFieldId(10).getValue());
View Full Code Here

Examples of net.sf.redmine_mylyn.api.model.TimeEntry

      if(taskData.isNew() || taskId.isEmpty()) {
        Issue issue = IssueMapper.createIssue(repository, taskData, oldAttributes, cfg);
        taskId += client.createIssue(issue, monitor);
      } else {
        Issue issue = IssueMapper.createIssue(repository, taskData, oldAttributes, cfg);
        TimeEntry timeEntry = IssueMapper.createTimeEntry(repository, taskData, oldAttributes, cfg);
        TaskAttribute commentAttribute = taskData.getRoot().getAttribute(RedmineAttribute.COMMENT.getTaskKey());
        String comment = commentAttribute==null ? null : commentAttribute.getValue();
        client.updateIssue(issue, comment, timeEntry, monitor);
      }
    } catch (RedmineStatusException e) {
View Full Code Here

Examples of net.sf.redmine_mylyn.api.model.TimeEntry

      kind.setValue(cfg.getTrackers().getById(issue.getTrackerId()).getName());
    }
  }

  public static TimeEntry createTimeEntry(TaskRepository repository, TaskData taskData, Set<TaskAttribute> oldAttributes, Configuration cfg) throws CoreException {
    TimeEntry timeEntry = null;
   
    try {
      String val = getValue(taskData, RedmineAttribute.TIME_ENTRY_HOURS);
      if(!val.isEmpty()) {
        timeEntry = new TimeEntry();
       
        /* Default Attributes */
        long milisec = Long.parseLong(val);
        long minutes = milisec/60000;
        float hours = minutes/60;
        hours += ((float)(minutes%60))/60.0;
       
        timeEntry.setHours(hours);
        timeEntry.setActivityId(Integer.parseInt(getValue(taskData, RedmineAttribute.TIME_ENTRY_ACTIVITY)));
        timeEntry.setComments(getValue(taskData, RedmineAttribute.TIME_ENTRY_COMMENTS));
       
        /* Custom Attributes */
        List<CustomField> customFields = cfg.getCustomFields().getTimeEntryCustomFields();
        if(customFields!=null && customFields.size()>0) {
          CustomValues customValues = new CustomValues();
          timeEntry.setCustomValues(customValues);
          for (CustomField customField : customFields) {
            String value = getValue(taskData, IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_CF+customField.getId());
            customValues.setCustomValue(customField.getId(), formatCustomValue(value, customField.getId(), cfg));
          }
        }
       
        /* Extension/Additional Attributes */
        IRedmineExtensionField additionalFields[] = RedmineCorePlugin.getDefault().getExtensionManager().getAdditionalTimeEntryFields(repository);
        for (IRedmineExtensionField additionalField : additionalFields) {
          String value = getValue(taskData, IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_EX+additionalField.getTaskKey());
          timeEntry.addExtensionValue(additionalField.getSubmitKey(), value);
        }
       
      }
    } catch (NumberFormatException e) {
      timeEntry = null;
View Full Code Here

Examples of net.sf.redmine_mylyn.api.model.TimeEntry

    issueCustomValues.put("2", TestData.issue2.getCustomValues().get(5).getValue());
    issueCustomValues.put("6", TestData.issue2.getCustomValues().get(11).getValue());
    issueCustomValues.put("1", TestData.issue2.getCustomValues().get(12).getValue());
    issueCustomValues.put("9", TestData.issue2.getCustomValues().get(13).getValue());
   
    TimeEntry timeEntry = TestData.issue2.getTimeEntries().getAll().get(0);
    timeValues = new LinkedHashMap<String, String>();
    timeValues.put("hours", ""+timeEntry.getHours());
    timeValues.put("activity_id", ""+timeEntry.getActivityId());
    timeValues.put("comments", timeEntry.getComments());
   
    timeCutomValues = new LinkedHashMap<String, String>();
    timeCutomValues.put("7", timeEntry.getCustomValues().get(5).getValue());
   
    timeEntry.addExtensionValue("extKey", "extVal");
  }
View Full Code Here

Examples of net.sf.redmine_mylyn.api.model.TimeEntry

    assertEquals(builder.toString(), result);
  }
 
  @Test
  public void testWriteIssueIssueStringTimeEntry() throws Exception {
    TimeEntry timeEntry = TestData.issue2.getTimeEntries().getAll().get(0);
    timeEntry.addExtensionValue("extKey", "extVal");
    String comment = "comment without content";

    StringBuilder builder = new StringBuilder();
    builder.append("{\"issue\":{");
    append(builder, issueValues);
View Full Code Here

Examples of org.nxplanner.domain.TimeEntry

        Collection timeEntries = task.getTimeEntries();
        if (timeEntries != null) {
            Iterator iter = timeEntries.iterator();

            while (iter.hasNext()) {
                TimeEntry entry = (TimeEntry)iter.next();
                Date endTime = entry.getEndTime();

                // This is a fix for duration-only entries
                // It may not be quite right.
                if (endTime == null && entry.getDuration() > 0) {
                    endTime = entry.getLastUpdateTime();
                }

                if (endTime != null) {
                    if ((completedTime == null) || (endTime.after(completedTime))) {
                        completedTime = endTime;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.