Package org.eclipse.mylyn.tasks.core.data

Examples of org.eclipse.mylyn.tasks.core.data.TaskAttribute


        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) {
      throw new CoreException(e.getStatus());
    }
View Full Code Here


      IStatus status = RedmineCorePlugin.toStatus(IStatus.ERROR, Messages.ERRMSG_TASK_INITIALIZATION_FALED_INSUFFICENT_DATA_X_X, issue.getId(), "Settings" );
      StatusHandler.log(status);
      throw new RedmineStatusException(status);
    }

    TaskAttribute attribute;
   
    createAttribute(data, RedmineAttribute.SUMMARY);
    createAttribute(data, RedmineAttribute.DESCRIPTION);
    createAttribute(data, RedmineAttribute.PRIORITY, cfg.getIssuePriorities().getAll());
   
    if(existingTask) {
      attribute = createAttribute(data, RedmineAttribute.PROJECT, cfg.getProjects().getMoveAllowed(project));
      attribute.getMetaData().setReadOnly(true);
    } else {
      createAttribute(data, RedmineAttribute.PROJECT, cfg.getProjects().getNewAllowed());
    }
   
    createAttribute(data, RedmineAttribute.PARENT);
    createAttribute(data, RedmineAttribute.SUBTASKS);
    createAttribute(data, RedmineAttribute.TRACKER, cfg.getTrackers().getById(project.getTrackerIds()));

    if (existingTask) {
      createAttribute(data, RedmineAttribute.REPORTER);
      createAttribute(data, RedmineAttribute.DATE_SUBMITTED);
      createAttribute(data, RedmineAttribute.DATE_UPDATED);
     
      createAttribute(data, RedmineAttribute.COMMENT);
     
      createAttribute(data, RedmineAttribute.STATUS, cfg.getIssueStatuses().getById(issue.getAvailableStatusId()));
      createAttribute(data, RedmineAttribute.STATUS_CHG, cfg.getIssueStatuses().getById(issue.getAvailableStatusId()));

////      createAttribute(data, RedmineAttribute.RELATION, ticket.getRelations(), false);
//     
    } else {
      createAttribute(data, RedmineAttribute.STATUS, cfg.getIssueStatuses().getAll());
      createAttribute(data, RedmineAttribute.STATUS_CHG, cfg.getIssueStatuses().getAll());

    }
   
    createAttribute(data, RedmineAttribute.CATEGORY, cfg.getIssueCategories().getById(project.getIssueCategoryIds()), true);
    createAttribute(data, RedmineAttribute.VERSION, cfg.getVersions().getOpenById(project.getVersionIds()), true);
   
    attribute = createAttribute(data, RedmineAttribute.PROGRESS, ProgressValues.availableValues());
    if (!cfg.getSettings().isUseIssueDoneRatio()) {
      attribute.getMetaData().setReadOnly(true);
      attribute.getMetaData().setType(null);
    }
   
    //Planning
    createAttribute(data, RedmineAttribute.ESTIMATED);
    createAttribute(data, RedmineAttribute.DATE_DUE);
    createAttribute(data, RedmineAttribute.DATE_START);

    createAttribute(data, RedmineAttribute.ASSIGNED_TO, cfg.getUsers().getById(project.getAssignableMemberIds()), !existingTask);

    //Attributes for a new TimeEntry
    if(existingTask) {
      if (issue.getTimeEntries()!=null && issue.getTimeEntries().isNewAllowed()) {
        createAttribute(data, RedmineAttribute.TIME_ENTRY_HOURS);
        createAttribute(data, RedmineAttribute.TIME_ENTRY_ACTIVITY, project.getTimeEntryActivities().getAll());
        createAttribute(data, RedmineAttribute.TIME_ENTRY_COMMENTS);
       
        for (IRedmineExtensionField additionalField : RedmineCorePlugin.getDefault().getExtensionManager().getAdditionalTimeEntryFields(repository)) {
          createAttribute(data, additionalField, IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_EX);
        }
       
        createCustomAttributes(data, cfg, issue, cfg.getCustomFields().getTimeEntryCustomFields(), IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_CF, true);
      }
    }

    //Watchers
    if(existingTask) {
      if(issue.isWatchersViewAllowed()) {
        attribute = createAttribute(data, RedmineAttribute.WATCHERS, cfg.getUsers().getAll());
       
        if(issue.isWatchersAddAllowed()) {
          TaskAttribute addWatcherAttribute = attribute.createAttribute(RedmineAttribute.WATCHERS_ADD.getTaskKey());
          addWatcherAttribute.getMetaData().setLabel(RedmineAttribute.WATCHERS_ADD.getLabel());
          addOptions(addWatcherAttribute, cfg.getUsers().getById(project.getMemberIds()));
        }

        if(issue.isWatchersDeleteAllowed()) {
          attribute.createAttribute(RedmineAttribute.WATCHERS_REMOVE.getTaskKey());
View Full Code Here

      }
    }
  }
 
  private static TaskAttribute createAttribute(TaskData data, RedmineAttribute redmineAttribute) {
    TaskAttribute attr = data.getRoot().createAttribute(redmineAttribute.getTaskKey());
    attr.getMetaData().setType(redmineAttribute.getType());
    attr.getMetaData().setKind(redmineAttribute.getKind());
    attr.getMetaData().setLabel(redmineAttribute.toString());
    attr.getMetaData().setReadOnly(redmineAttribute.isReadOnly());
    return attr;
  }
View Full Code Here

  private static TaskAttribute createAttribute(TaskData data, RedmineAttribute redmineAttribute, List<? extends Property> values) {
    return createAttribute(data, redmineAttribute, values, false);
  }

  private static TaskAttribute createAttribute(TaskData data, RedmineAttribute redmineAttribute, List<? extends Property> properties, boolean allowEmtpy) {
    TaskAttribute attr = createAttribute(data, redmineAttribute);

    if (properties != null && properties.size() > 0) {
      if (allowEmtpy) {
        attr.putOption("", ""); //$NON-NLS-1$ //$NON-NLS-2$
      }
      addOptions(attr, properties);
    }
    return attr;
  }
View Full Code Here

  private static void createCustomAttributes(TaskData taskData, Configuration configuration, Issue issue , List<CustomField> customFields, String prefix, boolean hidden) throws RedmineStatusException {
    Project project = configuration.getProjects().getById(issue.getProjectId());
   
    for (CustomField customField : customFields) {
      TaskAttribute taskAttribute = createAttribute(taskData, customField, prefix);
      if(hidden) {
        taskAttribute.getMetaData().setKind(null);
      }
      if (customField.getFieldFormat().isListType()) {
        if (!customField.isRequired()) {
          taskAttribute.putOption("", ""); //$NON-NLS-1$ //$NON-NLS-2$
        }
       
        switch (customField.getFieldFormat()) {
        case VERSION:
          for( Version version : configuration.getVersions().getById(project.getVersionIds()) ) {
            taskAttribute.putOption(""+version.getId(), version.getName()); //$NON-NLS-1$
          }
          break;
        case USER:
          for( Member member : project.getMembers() ) {
            User user = configuration.getUsers().getById(member.getUserId());
            if (user != null) {
              taskAttribute.putOption(""+user.getId(), user.getName()); //$NON-NLS-1$
            }
          }
          break;
        default:
          for (String option : customField.getPossibleValues()) {
            taskAttribute.putOption(option, option);
          }
        }
      }
     
    }
View Full Code Here

    f.setBoolean(cfg.getSettings(), false);
   
    Issue issue = TestData.issue2;
    TaskData taskData = buildEmptyTaskData(issue);
   
    TaskAttribute root = taskData.getRoot();
    IssueMapper.updateTaskData(repository, taskData, cfg, issue);

    assertEquals("", root.getAttribute(RedmineAttribute.PROGRESS.getTaskKey()).getValue());
  }
View Full Code Here

    Issue issue = new Issue();
    issue.setProjectId(1);
    issue.setTrackerId(1);
    TaskData taskData = buildEmptyTaskData(issue);
   
    TaskAttribute root = taskData.getRoot();
    IssueMapper.updateTaskData(repository, taskData, cfg, issue);
   
    assertEquals("", root.getAttribute(RedmineAttribute.SUMMARY.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.DESCRIPTION.getTaskKey()).getValue());
    assertEquals("1", root.getAttribute(RedmineAttribute.TRACKER.getTaskKey()).getValue());
    assertEquals("1", root.getAttribute(RedmineAttribute.PROJECT.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.STATUS.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.STATUS_CHG.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.PRIORITY.getTaskKey()).getValue());
    //TODO watched
    //new task - watchers is empty
    assertEquals("", root.getAttribute(RedmineAttribute.DATE_START.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.DATE_DUE.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.PROGRESS.getTaskKey()).getValue());
//    assertEquals("", root.getAttribute(RedmineAttribute.ESTIMATED.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.CATEGORY.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.ASSIGNED_TO.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.VERSION.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.PARENT.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.SUBTASKS.getTaskKey()).getValue());
    //TODO available Status
  }
View Full Code Here

  public void createIssue_statusChanged() throws Exception {
    TaskData taskData = buildEmptyTaskData(TestData.issue2);
    fillTaskData(taskData, TestData.issue2);

    //Change Status (mark as)
    TaskAttribute attribute = taskData.getRoot().getAttribute(TaskAttribute.OPERATION);
    attribute.setValue(RedmineOperation.markas.getTaskKey());

    attribute = taskData.getRoot().getAttribute(RedmineAttribute.STATUS_CHG.getTaskKey());
    attribute.setValue("4");
   
    Issue issue = IssueMapper.createIssue(repository, taskData, null, cfg);
    assertNotNull(issue);
   
    assertEquals(2, issue.getId());
View Full Code Here

  public void createIssue_watchersChanged() throws Exception {
    TaskData taskData = buildEmptyTaskData(TestData.issue2);
    fillTaskData(taskData, TestData.issue2);

    //Old watchers
    TaskAttribute watchers = taskData.getRoot().getAttribute(RedmineAttribute.WATCHERS.getTaskKey());
    watchers.setValue("1");
    watchers.addValue("2");
   
    //Add a new watcher
    watchers.getAttribute(RedmineAttribute.WATCHERS_ADD.getTaskKey()).setValue("3");

    //Remove a watcher
    watchers.getAttribute(RedmineAttribute.WATCHERS_REMOVE.getTaskKey()).setValue("1");
   
    //expected 2,3
    Issue issue = IssueMapper.createIssue(repository, taskData, null, cfg);
    assertNotNull(issue);
View Full Code Here

   
    return taskData;
  }
 
  void fillTaskData(TaskData taskData, Issue issue) {
    TaskAttribute root = taskData.getRoot();

    setAttributeValue(root, RedmineAttribute.SUMMARY, issue.getSubject());
    setAttributeValue(root, RedmineAttribute.DESCRIPTION, issue.getDescription());
    setAttributeValue(root, RedmineAttribute.PROJECT, issue.getProjectId());
    setAttributeValue(root, RedmineAttribute.TRACKER, issue.getTrackerId());
    setAttributeValue(root, RedmineAttribute.STATUS, issue.getStatusId());
    setAttributeValue(root, RedmineAttribute.STATUS_CHG, issue.getStatusId());
    setAttributeValue(root, RedmineAttribute.PARENT, issue.getParentId());
    setAttributeValue(root, RedmineAttribute.PRIORITY, issue.getPriorityId());
    setAttributeValue(root, RedmineAttribute.CATEGORY, issue.getCategoryId());
    setAttributeValue(root, RedmineAttribute.REPORTER, issue.getAuthorId());
    setAttributeValue(root, RedmineAttribute.ASSIGNED_TO, issue.getAssignedToId());
    setAttributeValue(root, RedmineAttribute.VERSION, issue.getFixedVersionId());
    setAttributeValue(root, RedmineAttribute.DATE_SUBMITTED, issue.getCreatedOn());
    setAttributeValue(root, RedmineAttribute.DATE_UPDATED, issue.getUpdatedOn());
    setAttributeValue(root, RedmineAttribute.DATE_START, issue.getStartDate());
    setAttributeValue(root, RedmineAttribute.DATE_DUE, issue.getDueDate());
    setAttributeValue(root, RedmineAttribute.ESTIMATED, issue.getEstimatedHours());
    setAttributeValue(root, RedmineAttribute.PROGRESS, issue.getDoneRatio());
//    setAttributeValue(root, RedmineAttribute.COMMENT, "");
   
    //new time entry
    root.getAttribute(RedmineAttribute.TIME_ENTRY_HOURS.getTaskKey()).setValue("5400000");
    root.getAttribute(RedmineAttribute.TIME_ENTRY_ACTIVITY.getTaskKey()).setValue("1");
    root.getAttribute(RedmineAttribute.TIME_ENTRY_COMMENTS.getTaskKey()).setValue("hard work");
    root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_CF+"7").setValue("TRUE");
    root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_CF+"10").setValue("1282255200000");
   
    //CustomFields
    for (CustomValue cv : issue.getCustomValues().getAll()) {
      TaskAttribute attribute = root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_ISSUE_CF + cv.getCustomFieldId());
      attribute.setValue(cv.getValue()==null ? "" : cv.getValue());
    }
    root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_ISSUE_CF+"9").setValue("1259622000000");
   
   
    //operation
View Full Code Here

TOP

Related Classes of org.eclipse.mylyn.tasks.core.data.TaskAttribute

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.