Package net.sf.redmine_mylyn.api.model

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


    /* 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

  @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

      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

      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

    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

    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

TOP

Related Classes of net.sf.redmine_mylyn.api.model.TimeEntry

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.