use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIORestConfiguration method updateInitialTaskData.
public void updateInitialTaskData(TaskData data) throws CoreException {
setSpaceOptions(data, getSpaces());
updateSpaceOptions(data);
for (String key : data.getRoot().getAttributes().keySet()) {
if (key.equals(OSIORestTaskSchema.getDefault().NEW_COMMENT.getKey()) || key.equals(TaskAttribute.OPERATION) || key.equals(OSIORestTaskSchema.getDefault().DATE_MODIFICATION.getKey())) {
continue;
}
TaskAttribute attribute = data.getRoot().getAttribute(key);
if (key.equals(OSIORestTaskSchema.getDefault().STATUS.getKey())) {
if (attribute.getOptions().isEmpty()) {
for (String status : statusValues) {
attribute.putOption(status, status);
}
}
}
if (key.equals(OSIORestTaskSchema.getDefault().ASSIGNEES.getKey())) {
if (attribute.getOptions().isEmpty()) {
attribute.putOption(userName, userName);
}
continue;
}
if (!key.equals(SCHEMA.SPACE.getKey())) {
String configName = mapTaskAttributeKey2ConfigurationFields(key);
if (configName.equals("baseType")) {
if (attribute.getOptions().size() == 1 && attribute.getValue().isEmpty()) {
attribute.setValue((String) attribute.getOptions().values().toArray()[0]);
}
}
}
}
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIORestConnector method updateTaskFromTaskData.
@Override
public void updateTaskFromTaskData(TaskRepository taskRepository, ITask task, TaskData taskData) {
TaskMapper scheme = getTaskMapping(taskData);
scheme.applyTo(task);
task.setUrl(taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().TASK_URL.getKey()).getValue());
boolean isComplete = false;
TaskAttribute attributeStatus = taskData.getRoot().getMappedAttribute(TaskAttribute.STATUS);
if (attributeStatus != null) {
String statusValue = attributeStatus.getValue();
isComplete = (statusValue.equals(IOSIORestConstants.RESOLVED) || statusValue.equals(IOSIORestConstants.CLOSED));
}
if (taskData.isPartial()) {
if (isComplete) {
if (task.getCompletionDate() == null) {
task.setCompletionDate(new Date(0));
}
} else {
task.setCompletionDate(null);
}
} else {
inferCompletionDate(task, taskData, scheme, isComplete);
}
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIORestConnector method hasTaskChanged.
@Override
public boolean hasTaskChanged(TaskRepository taskRepository, ITask task, TaskData taskData) {
String lastKnownLocalModValue = task.getAttribute(OSIORestTaskSchema.getDefault().DATE_MODIFICATION.getKey());
TaskAttribute latestRemoteModAttribute = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION);
String latestRemoteModValue = latestRemoteModAttribute != null ? latestRemoteModAttribute.getValue() : null;
return !Objects.equal(latestRemoteModValue, lastKnownLocalModValue);
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIORestTaskAttributeMapper method getOptions.
@Override
public Map<String, String> getOptions(@NonNull TaskAttribute attribute) {
OSIORestTaskSchema taskSchema = OSIORestTaskSchema.getDefault();
if (attribute.getId().equals(taskSchema.WORKITEM_TYPE.getKey()) || attribute.getId().equals(taskSchema.AREA.getKey()) || attribute.getId().equals(taskSchema.ASSIGNEES.getKey()) || attribute.getId().equals(taskSchema.STATUS.getKey()) || attribute.getId().equals(taskSchema.ITERATION.getKey())) {
TaskAttribute spaceIdAttribute = attribute.getParentAttribute().getAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey());
TaskAttribute spaceAttribute = attribute.getParentAttribute().getAttribute(OSIORestCreateTaskSchema.getDefault().SPACE.getKey());
OSIORestConfiguration repositoryConfiguration;
try {
repositoryConfiguration = connector.getRepositoryConfiguration(this.getTaskRepository());
// TODO: change this when we have offline cache for the repository configuration so we build the options in an temp var
if (repositoryConfiguration != null) {
if (spaceIdAttribute != null && !spaceIdAttribute.getValue().equals("")) {
// $NON-NLS-1$
attribute.clearOptions();
for (String spaceId : spaceIdAttribute.getValues()) {
Space actualSpace = connector.getClient(getTaskRepository()).getSpaceById(spaceId, getTaskRepository());
internalSetAttributeOptions4Space(attribute, actualSpace.getMapFor(attribute.getId()));
}
} else {
attribute.clearOptions();
for (String spaceName : spaceAttribute.getValues()) {
Space actualSpace = repositoryConfiguration.getSpaceWithName(spaceName);
internalSetAttributeOptions4Space(attribute, actualSpace.getMapFor(attribute.getId()));
}
if (attribute.getOptions().size() == 0) {
if (attribute.getId().equals(taskSchema.ASSIGNEES.getKey())) {
String userName = repositoryConfiguration.getUserName();
attribute.putOption(userName, userName);
}
}
}
}
} catch (CoreException e) {
StatusHandler.log(new RepositoryStatus(getTaskRepository(), IStatus.ERROR, OSIORestCore.ID_PLUGIN, 0, "Failed to obtain repository configuration", // $NON-NLS-1$
e));
}
}
return super.getOptions(attribute);
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIORestTaskEditorAttributePart method initialize.
private void initialize() {
attributeEditors = new ArrayList<AbstractAttributeEditor>();
hasIncoming = false;
Collection<TaskAttribute> attributes = getAttributes();
for (TaskAttribute attribute : attributes) {
AbstractAttributeEditor attributeEditor = createAttributeEditor(attribute);
if (attributeEditor != null) {
attributeEditors.add(attributeEditor);
if (getModel().hasIncomingChanges(attribute)) {
hasIncoming = true;
}
}
}
Comparator<AbstractAttributeEditor> attributeSorter = createAttributeEditorSorter();
if (attributeSorter != null) {
Collections.sort(attributeEditors, attributeSorter);
}
}
Aggregations