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());