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

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


    this.task = task;
  }
 
  @Override
  protected String getValue(RedmineAttribute attribute, TaskData taskData) {
    TaskAttributeMapper taskAttributeMapper = taskData.getAttributeMapper();
    TaskAttribute taskAttribute = taskData.getRoot().getAttribute(attribute.getTaskKey());

    switch (attribute) {
    case TIME_ENTRY_HOURS:

      long milisec = RedmineUiPlugin.getDefault().getSpentTimeManager().getAndClearUncapturedSpentTime(task);
     
      String oldValue = taskAttribute.getValue();
      if(!oldValue.isEmpty()) {
        milisec += Long.parseLong(oldValue);
      }
     
      return Long.toString(milisec);
     
    case TIME_ENTRY_ACTIVITY:
      /*
       * Priority:
       * 1 - current value
       * 2 - default value
       * 3 - first value
       */
     
      String value = ""; //$NON-NLS-1$
      Integer activityId = taskAttributeMapper.getIntegerValue(taskAttribute);

      if(activityId==null) {
        AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(RedmineCorePlugin.REPOSITORY_KIND);
        if (connector!=null && connector instanceof RedmineRepositoryConnector){
         
          Configuration conf = ((RedmineRepositoryConnector) connector)
          .getRepositoryConfiguration(TasksUi
              .getRepositoryManager().getRepository(
                  task.getConnectorKind(),
                  task.getRepositoryUrl()));       
         
          Integer projectId = taskAttributeMapper.getIntegerValue(taskData.getRoot().getAttribute(RedmineAttribute.PROJECT.getTaskKey()));
          Project project = conf.getProjects().getById(projectId.intValue());
         
          if(project!=null) {
            TimeEntryActivities activities = project.getTimeEntryActivities();
            TimeEntryActivity activity = activities.getDefault();
View Full Code Here


      StringBuilder sb = new StringBuilder();

      //Author
      TaskAttribute authorAttribute = RedmineTaskTimeEntryMapper.getAuthorAttribute(attribute);
      if(authorAttribute != null) {
        TaskAttributeMapper attributeMapper = attribute.getTaskData().getAttributeMapper();
        IRepositoryPerson author = attributeMapper.getRepositoryPerson(authorAttribute);
        formHyperlink.setImage(Images.getImage(Images.PERSON_NARROW));
        if (author != null) {
          if (author.getName() != null) {
            sb.append(author.getName());
          } else {
            sb.append(author.getPersonId());
          }
        }
      }
     
      //Date
      TaskAttributeMapper attributeMapper = attribute.getTaskData().getAttributeMapper();
      Date spentOnDate = attributeMapper.getDateValue(RedmineTaskTimeEntryMapper.getSpentOnAttribute(attribute));
      if (spentOnDate!=null) {
        if(sb.length()>0) {
          sb.append(", "); //$NON-NLS-1$
        }
        sb.append(DateFormat.getDateInstance(DateFormat.MEDIUM).format(spentOnDate));
View Full Code Here

 
  public void applyTo(TaskAttribute taskAttribute, Configuration configuration) {
    Assert.isNotNull(taskAttribute);
   
    TaskData taskData = taskAttribute.getTaskData();
    TaskAttributeMapper mapper = taskData.getAttributeMapper();
   
    String projectVal = taskData.getRoot().getAttribute(RedmineAttribute.PROJECT.getTaskKey()).getValue();
    Project project = configuration.getProjects().getById(RedmineUtil.parseIntegerId(projectVal));
   
    taskAttribute.getMetaData().defaults().setType(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY);
    if (getTimeEntryId() > 0) {
      mapper.setIntegerValue(taskAttribute, getTimeEntryId());
    }
    if (getHours() > 0f) {
      TaskAttribute child = taskAttribute.createMappedAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_HOURS);
      child.getMetaData().defaults().setType(RedmineAttribute.TIME_ENTRY_HOURS.getType());
      child.getMetaData().setLabel(RedmineAttribute.TIME_ENTRY_HOURS.getLabel());
      mapper.setValue(child, ""+getHours()); //$NON-NLS-1$
    }
    if (getActivityId()>0) {
      TaskAttribute child = taskAttribute.createMappedAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_ACTIVITY);
      child.getMetaData().defaults().setType(RedmineAttribute.TIME_ENTRY_ACTIVITY.getType());
      child.getMetaData().setLabel(RedmineAttribute.TIME_ENTRY_ACTIVITY.getLabel());
      mapper.setIntegerValue(child, getActivityId());

      //Option for ActivityId
      if(project!=null) {
        TimeEntryActivity activity = project.getTimeEntryActivities().getById(getActivityId());
        if (activity!=null) {
          child.putOption(""+activity.getId(), activity.getName()); //$NON-NLS-1$
        }
      }
    }
    if (getUser() != null) {
      TaskAttribute child = taskAttribute.createMappedAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_AUTHOR);
      mapper.setRepositoryPerson(child, getUser());
    }
    if (getSpentOn()!=null) {
      TaskAttribute child = taskAttribute.createMappedAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_SPENTON);
      child.getMetaData().defaults().setType(TaskAttribute.TYPE_DATE);
      mapper.setDateValue(child, getSpentOn());
    }
    if (getComments()!=null) {
      TaskAttribute child = taskAttribute.createMappedAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_COMMENTS);
      child.getMetaData().defaults().setType(RedmineAttribute.TIME_ENTRY_COMMENTS.getType());
      child.getMetaData().setLabel(RedmineAttribute.TIME_ENTRY_COMMENTS.getLabel());
      mapper.setValue(child, getComments());
    }
    if (getCustomValues()!=null) {
      for (CustomValue customValue : getCustomValues()) {
        TaskAttribute child = taskAttribute.createMappedAttribute(IRedmineConstants.TASK_KEY_PREFIX_TIMEENTRY_CF + customValue.getCustomFieldId());
       
View Full Code Here

        this.connector = connector;
    }

    @Override
    public TaskAttributeMapper getAttributeMapper(TaskRepository repository) {
        return new TaskAttributeMapper(repository);
    }
View Full Code Here

        TaskAttribute oldBlockedOnAttribute = getOldAttribute(GoogleCodeAttribute.BLOCKED_ON,
                oldAttributes);

        List<String> oldBlockedOns = null;
        if (oldBlockedOnAttribute != null) {
            TaskAttributeMapper attributeMapper = taskData.getAttributeMapper();
            oldBlockedOns = attributeMapper.getValues(oldBlockedOnAttribute);
        } else {
            oldBlockedOns = Collections.emptyList();
        }

        return new ArrayList<String>(oldBlockedOns);
View Full Code Here

TOP

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

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.