Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-05-24 05:42:13 +0000
committerspingel2008-05-24 05:42:13 +0000
commite7d2a163cb9fdfbbf90c04cb9aac82e9a9657bb8 (patch)
tree7468036fef1a2a693141b3ace1e4e232101de913 /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data
parenta32ca2e45154e9dc45e975063173cc918800b3a8 (diff)
downloadorg.eclipse.mylyn.tasks-e7d2a163cb9fdfbbf90c04cb9aac82e9a9657bb8.tar.gz
org.eclipse.mylyn.tasks-e7d2a163cb9fdfbbf90c04cb9aac82e9a9657bb8.tar.xz
org.eclipse.mylyn.tasks-e7d2a163cb9fdfbbf90c04cb9aac82e9a9657bb8.zip
NEW - bug 225033: [api] ensure consistent naming of API classes and methods
https://bugs.eclipse.org/bugs/show_bug.cgi?id=225033
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java52
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java40
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java16
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java87
4 files changed, 139 insertions, 56 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java
index 97b4a92c8..961ba9435 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java
@@ -28,15 +28,15 @@ public class TaskAttachmentMapper {
private Date creationDate;
- private boolean deprecated;
+ private Boolean deprecated;
private String description;
private String fileName;
- private long length;
+ private Long length;
- private boolean patch;
+ private Boolean patch;
private String url;
@@ -73,7 +73,7 @@ public class TaskAttachmentMapper {
return fileName;
}
- public long getLength() {
+ public Long getLength() {
return length;
}
@@ -81,11 +81,11 @@ public class TaskAttachmentMapper {
return url;
}
- public boolean isDeprecated() {
+ public Boolean isDeprecated() {
return deprecated;
}
- public boolean isPatch() {
+ public Boolean isPatch() {
return patch;
}
@@ -109,7 +109,7 @@ public class TaskAttachmentMapper {
this.creationDate = creationDate;
}
- public void setDeprecated(boolean deprecated) {
+ public void setDeprecated(Boolean deprecated) {
this.deprecated = deprecated;
}
@@ -121,11 +121,11 @@ public class TaskAttachmentMapper {
this.fileName = fileName;
}
- public void setLength(long length) {
+ public void setLength(Long length) {
this.length = length;
}
- public void setPatch(boolean patch) {
+ public void setPatch(Boolean patch) {
this.patch = patch;
}
@@ -213,19 +213,25 @@ public class TaskAttachmentMapper {
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_SHORT_TEXT).applyTo(child);
mapper.setValue(child, getFileName());
}
+ if (isDeprecated() != null) {
+ TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
+ TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
+ mapper.setBooleanValue(child, isDeprecated());
+ }
+ if (isPatch() != null) {
+ TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_PATCH);
+ TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
+ mapper.setBooleanValue(child, isPatch());
+ }
+ if (getLength() != null) {
+ TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_SIZE);
+ mapper.setLongValue(child, getLength());
+ }
if (getUrl() != null) {
TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_URL);
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_URL).applyTo(child);
mapper.setValue(child, getUrl());
}
- TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
- TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
- mapper.setBooleanValue(child, isDeprecated());
- child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_PATCH);
- TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
- mapper.setBooleanValue(child, isPatch());
- child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_SIZE);
- mapper.setLongValue(child, getLength());
}
public void applyTo(ITaskAttachment taskAttachment) {
@@ -245,12 +251,18 @@ public class TaskAttachmentMapper {
if (getFileName() != null) {
taskAttachment.setFileName(getFileName());
}
+ if (isDeprecated() != null) {
+ taskAttachment.setDeprecated(isDeprecated());
+ }
+ if (isPatch() != null) {
+ taskAttachment.setPatch(isPatch());
+ }
+ if (getLength() != null) {
+ taskAttachment.setLength(getLength());
+ }
if (url != null) {
taskAttachment.setUrl(getUrl());
}
- taskAttachment.setDeprecated(isDeprecated());
- taskAttachment.setPatch(isPatch());
- taskAttachment.setLength(getLength());
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
index 3f8815963..91101c731 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
@@ -23,7 +23,6 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
* @author Steffen Pingel
* @since 3.0
*/
-// TODO EDITOR return null if attribute value invalid for primitive types?
public class TaskAttributeMapper {
private final TaskRepository taskRepository;
@@ -47,10 +46,21 @@ public class TaskAttributeMapper {
public TaskAttribute getAssoctiatedAttribute(TaskAttribute taskAttribute) {
String id = taskAttribute.getMetaData(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID);
if (id != null) {
- if (TaskAttribute.TYPE_OPERATION.equals(TaskAttributeProperties.from(taskAttribute).getType())) {
- return taskAttribute.getTaskData().getRoot().getAttribute(id);
+ // look up as nested attribute first
+ TaskAttribute associatedAttribute = taskAttribute.getAttribute(id);
+ if (associatedAttribute != null) {
+ return associatedAttribute;
}
- return taskAttribute.getAttribute(id);
+ // fall back to root
+ return taskAttribute.getTaskData().getRoot().getAttribute(id);
+ }
+ return null;
+ }
+
+ public TaskAttribute getAssoctiatedAttribute(TaskOperation taskOperation) {
+ TaskAttribute taskAttribute = taskOperation.getTaskAttribute();
+ if (taskAttribute != null) {
+ return getAssoctiatedAttribute(taskAttribute);
}
return null;
}
@@ -135,7 +145,21 @@ public class TaskAttributeMapper {
return person;
}
- public TaskOperation getTaskOperation(TaskAttribute taskAttribute) {
+ public TaskOperation[] getTaskOperations(TaskAttribute operationsAttribute) {
+ Assert.isNotNull(operationsAttribute);
+ TaskData taskData = operationsAttribute.getTaskData();
+ List<TaskOperation> result = new ArrayList<TaskOperation>();
+ for (TaskAttribute taskAttribute : taskData.getRoot().getAttributes().values()) {
+ if (TaskAttribute.TYPE_OPERATION.equals(taskAttribute.getProperties().getType())
+ && !taskAttribute.getId().equals(mapToRepositoryKey(taskData.getRoot(), TaskAttribute.OPERATION))) {
+ result.add(TaskOperation.createFrom(taskAttribute));
+ }
+ }
+ return result.toArray(new TaskOperation[0]);
+ }
+
+ public TaskOperation getTaskOperationValue(TaskAttribute taskAttribute) {
+ Assert.isNotNull(taskAttribute);
return TaskOperation.createFrom(taskAttribute);
}
@@ -226,8 +250,10 @@ public class TaskAttributeMapper {
}
}
- public void setTaskOperation(TaskAttribute taskAttribute, TaskOperation taskOperation) {
- taskOperation.applyTo(taskAttribute);
+ public void setTaskOperationValue(TaskAttribute taskAttribute, TaskOperation taskOperation) {
+ Assert.isNotNull(taskAttribute);
+ Assert.isNotNull(taskOperation);
+ TaskOperation.applyTo(taskAttribute, taskOperation.getOperationId(), taskOperation.getLabel());
}
public void setValue(TaskAttribute attribute, String value) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java
index 735a1264c..f60e68187 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java
@@ -23,15 +23,13 @@ import org.eclipse.mylyn.tasks.core.ITaskComment;
*/
public class TaskCommentMapper {
- private static final int DEFAULT_NUMBER = -1;
-
private IRepositoryPerson author;
private String commentId;
private Date creationDate;
- private int number;
+ private Integer number;
private String text;
@@ -52,7 +50,7 @@ public class TaskCommentMapper {
return creationDate;
}
- public int getNumber() {
+ public Integer getNumber() {
return number;
}
@@ -76,7 +74,7 @@ public class TaskCommentMapper {
this.creationDate = creationDate;
}
- public void setNumber(int number) {
+ public void setNumber(Integer number) {
this.number = number;
}
@@ -88,6 +86,7 @@ public class TaskCommentMapper {
this.url = url;
}
+ @SuppressWarnings("deprecation")
public static TaskCommentMapper createFrom(TaskAttribute taskAttribute) {
Assert.isNotNull(taskAttribute);
TaskData taskData = taskAttribute.getTaskData();
@@ -111,8 +110,7 @@ public class TaskCommentMapper {
}
child = taskAttribute.getMappedAttribute(TaskAttribute.COMMENT_NUMBER);
if (child != null) {
- Integer value = mapper.getIntegerValue(child);
- comment.setNumber((value != null) ? value : DEFAULT_NUMBER);
+ comment.setNumber(mapper.getIntegerValue(child));
}
child = taskAttribute.getMappedAttribute(TaskAttribute.COMMENT_URL);
if (child != null) {
@@ -143,7 +141,7 @@ public class TaskCommentMapper {
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_DATE).applyTo(child);
mapper.setDateValue(child, getCreationDate());
}
- if (getNumber() != DEFAULT_NUMBER) {
+ if (getNumber() != null) {
TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.COMMENT_NUMBER);
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_INTEGER).applyTo(child);
mapper.setIntegerValue(child, getNumber());
@@ -169,7 +167,7 @@ public class TaskCommentMapper {
if (getCreationDate() != null) {
taskComment.setCreationDate(getCreationDate());
}
- if (getNumber() != DEFAULT_NUMBER) {
+ if (getNumber() != null) {
taskComment.setNumber(getNumber());
}
if (getUrl() != null) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java
index f16585f0f..45aa6e9bd 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java
@@ -17,6 +17,23 @@ import org.eclipse.core.runtime.Assert;
*/
public class TaskOperation {
+ public static void applyTo(TaskAttribute taskAttribute, String operationId, String label) {
+ TaskData taskData = taskAttribute.getTaskData();
+ taskData.getAttributeMapper().setValue(taskAttribute, operationId);
+ TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_OPERATION).setLabel(label).applyTo(taskAttribute);
+ }
+
+ public static TaskOperation createFrom(TaskAttribute taskAttribute) {
+ Assert.isNotNull(taskAttribute);
+ TaskData taskData = taskAttribute.getTaskData();
+ TaskOperation operation = new TaskOperation(taskData.getRepositoryUrl(), taskData.getConnectorKind(),
+ taskData.getTaskId(), taskAttribute.getValue());
+ TaskAttributeProperties properties = TaskAttributeProperties.from(taskAttribute);
+ operation.setLabel(properties.getLabel());
+ operation.setTaskAttribute(taskAttribute);
+ return operation;
+ }
+
private final String connectorKind;
private String label;
@@ -25,15 +42,48 @@ public class TaskOperation {
private final String repositoryUrl;
+ private TaskAttribute taskAttribute;
+
private final String taskId;
public TaskOperation(String connectorKind, String repositoryUrl, String taskId, String operationId) {
+ Assert.isNotNull(connectorKind);
+ Assert.isNotNull(repositoryUrl);
+ Assert.isNotNull(taskId);
+ Assert.isNotNull(operationId);
this.connectorKind = connectorKind;
this.repositoryUrl = repositoryUrl;
this.taskId = taskId;
this.operationId = operationId;
}
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TaskOperation other = (TaskOperation) obj;
+ if (!connectorKind.equals(other.connectorKind)) {
+ return false;
+ }
+ if (!operationId.equals(other.operationId)) {
+ return false;
+ }
+ if (!repositoryUrl.equals(other.repositoryUrl)) {
+ return false;
+ }
+ if (!taskId.equals(other.taskId)) {
+ return false;
+ }
+ return true;
+ }
+
public String getConnectorKind() {
return connectorKind;
}
@@ -50,34 +100,31 @@ public class TaskOperation {
return repositoryUrl;
}
- public String getTaskId() {
- return taskId;
+ public TaskAttribute getTaskAttribute() {
+ return taskAttribute;
}
- public void setLabel(String label) {
- this.label = label;
+ public String getTaskId() {
+ return taskId;
}
- public static TaskOperation createFrom(TaskAttribute taskAttribute, String operationId) {
- Assert.isNotNull(taskAttribute);
- Assert.isNotNull(operationId);
- TaskData taskData = taskAttribute.getTaskData();
- TaskOperation operation = new TaskOperation(taskData.getRepositoryUrl(), taskData.getConnectorKind(),
- taskData.getTaskId(), operationId);
- TaskAttributeProperties properties = TaskAttributeProperties.from(taskAttribute);
- operation.setLabel(properties.getLabel());
- return operation;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + connectorKind.hashCode();
+ result = prime * result + operationId.hashCode();
+ result = prime * result + repositoryUrl.hashCode();
+ result = prime * result + taskId.hashCode();
+ return result;
}
- public static TaskOperation createFrom(TaskAttribute taskAttribute) {
- return createFrom(taskAttribute, taskAttribute.getValue());
+ public void setLabel(String label) {
+ this.label = label;
}
- public void applyTo(TaskAttribute taskAttribute) {
- TaskData taskData = taskAttribute.getTaskData();
- taskData.getAttributeMapper().setValue(taskAttribute, getOperationId());
- TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_OPERATION).setLabel(getLabel()).applyTo(
- taskAttribute);
+ public void setTaskAttribute(TaskAttribute taskAttribute) {
+ this.taskAttribute = taskAttribute;
}
}

Back to the top