Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2015-02-19 19:26:57 +0000
committerFrank Becker2015-06-11 01:46:09 +0000
commit8440f0cb25a6b5a1072d692aa29c790e08b53041 (patch)
treea1b172828ad8f0663f6d6af4f44ef6345bfc74f3 /connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core
parent7d62d00eab65b37124ad0736054996d0ceecb3fe (diff)
downloadorg.eclipse.mylyn.tasks-8440f0cb25a6b5a1072d692aa29c790e08b53041.tar.gz
org.eclipse.mylyn.tasks-8440f0cb25a6b5a1072d692aa29c790e08b53041.tar.xz
org.eclipse.mylyn.tasks-8440f0cb25a6b5a1072d692aa29c790e08b53041.zip
426644: add TaskDataSchema for Task Creation (with UI Part)
Change-Id: I94a3879289d0ac86ab5515facdedbf4aa305d701 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=414360
Diffstat (limited to 'connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core')
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java322
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConnector.java7
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java73
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskAttributeMapper.java87
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskDataHandler.java12
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java67
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Component.java23
7 files changed, 555 insertions, 36 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
index 87fb1571f..19d4b8225 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
@@ -12,11 +12,24 @@
package org.eclipse.mylyn.internal.bugzilla.rest.core;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Component;
import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Field;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.FieldValues;
import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Parameters;
import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Product;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.SortableActiveEntry;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.StatusTransition;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskOperation;
import com.google.common.base.Function;
import com.google.common.base.Functions;
@@ -25,7 +38,7 @@ import com.google.common.collect.Ordering;
public class BugzillaRestConfiguration implements Serializable {
- private static final long serialVersionUID = 4078343382335204804L;
+ private static final long serialVersionUID = 4173223872076958202L;
private final String repositoryId;
@@ -89,4 +102,309 @@ public class BugzillaRestConfiguration implements Serializable {
return parameters;
}
-}
+ private Component getProductComponentWithName(Product product, String name) {
+ for (Component componentEntry : product.getComponents()) {
+ if (componentEntry.getName().equals(name)) {
+ return componentEntry;
+ }
+ }
+ return null;
+ }
+
+ public void updateInitialTaskData(TaskData data) throws CoreException {
+ for (String key : data.getRoot().getAttributes().keySet()) {
+ if (key.equals(BugzillaRestTaskSchema.getDefault().ADD_SELF_CC.getKey())
+ || key.equals(BugzillaRestTaskSchema.getDefault().NEW_COMMENT.getKey())
+ || key.equals(TaskAttribute.OPERATION)) {
+ continue;
+ }
+ TaskAttribute attribute = data.getRoot().getAttribute(key);
+ if (key.equals(BugzillaRestCreateTaskSchema.getDefault().PRODUCT.getKey())) {
+ List<String> products = new ArrayList<String>();
+ Field configFieldComponent = getFieldWithName("component");
+ FieldValues[] val = configFieldComponent.getValues();
+ if (val != null && val.length > 0) {
+ for (FieldValues fieldValues : val) {
+ fieldValues.getVisibilityValues();
+ for (String visibilityValue : fieldValues.getVisibilityValues()) {
+ if (!products.contains(visibilityValue)) {
+ products.add(visibilityValue);
+ }
+ }
+ }
+ attribute.clearOptions();
+ for (String productName : products) {
+ attribute.putOption(productName, productName);
+ }
+ }
+ } else {
+ String configName = mapTaskAttributeKey2ConfigurationFields(key);
+ Field configField = getFieldWithName(configName);
+ if (configField == null) {
+ continue;
+ }
+ FieldValues[] val = configField.getValues();
+ if (val != null && val.length > 0) {
+ for (FieldValues fieldValues : val) {
+ if (configName.equals("bug_status")) {
+ if (fieldValues.getName() == null) {
+ for (StatusTransition bugzillaRestBugStatusTransition : fieldValues.getCanChangeTo()) {
+ attribute.putOption(bugzillaRestBugStatusTransition.getName(),
+ bugzillaRestBugStatusTransition.getName());
+ }
+ }
+ } else if (configName.equals("component") || configName.equals("version")
+ || configName.equals("target_milestone")) {
+ TaskAttribute productAttribute = data.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().PRODUCT.getKey());
+ String productValue = productAttribute.getValue();
+ for (String visibilityValue : fieldValues.getVisibilityValues()) {
+ if (visibilityValue.equals(productValue) || productValue.equals("")) {
+ attribute.putOption(fieldValues.getName(), fieldValues.getName());
+ }
+ }
+ } else {
+ attribute.putOption(fieldValues.getName(), fieldValues.getName());
+ }
+
+ }
+ if ((configName.equals("component") || configName.equals("version")
+ || configName.equals("target_milestone")) && attribute.getOptions().size() == 1
+ && attribute.getValue().equals("")) {
+ attribute.setValue((String) attribute.getOptions().values().toArray()[0]);
+ }
+ if ("".equals(attribute.getValue())) {
+ attribute.setValue(getValueFromParameter(key));
+ }
+ }
+ }
+ }
+ for (Field Field : fields.values()) {
+ if (Field.isCustom() && Field.isOnBugEntry()) {
+ TaskAttribute attribute = data.getRoot().createAttribute(Field.getName());
+ if (attribute != null) {
+ attribute.getMetaData().defaults().setLabel(Field.getDisplayName());
+ attribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
+ String type = getAttributeTypFromFieldTyp(Field.getType());
+ attribute.getMetaData().setType(type);
+ if (type.equals(TaskAttribute.TYPE_SINGLE_SELECT)) {
+ attribute.getMetaData().setRequired(true);
+ }
+
+ FieldValues[] values1 = Field.getValues();
+ if (values1 != null) {
+ for (FieldValues FieldValues : values1) {
+ attribute.putOption(FieldValues.getName(), FieldValues.getName());
+ }
+ }
+ attribute.getMetaData().setReadOnly(false);
+ }
+ }
+ }
+ }
+
+ private String getValueFromParameter(String attributeId) {
+ if (attributeId.equals(TaskAttribute.PRIORITY)) {
+ return getParameters().getDefaultpriority();
+ } else if (attributeId.equals(TaskAttribute.SEVERITY)) {
+ return getParameters().getDefaultseverity();
+ } else if (attributeId.equals("platform")) {
+ if (getParameters().getDefaultplatform() == null || getParameters().getDefaultplatform().equals("")) {
+ return "All";
+ } else {
+ return getParameters().getDefaultplatform();
+ }
+ } else if (attributeId.equals("os")) {
+ if (getParameters().getDefaultopsys() == null || getParameters().getDefaultopsys().equals("")) {
+ return "All";
+ } else {
+ return getParameters().getDefaultopsys();
+ }
+ }
+ return "";
+ }
+
+ private String getAttributeTypFromFieldTyp(int fieldTyp) throws CoreException {
+ switch (fieldTyp) {
+ case 1://Free Text
+ return TaskAttribute.TYPE_SHORT_TEXT;
+ case 2: //DropDown
+ return TaskAttribute.TYPE_SINGLE_SELECT;
+ case 3: //Multiple-Selection Box
+ return TaskAttribute.TYPE_MULTI_SELECT;
+ case 4: //Large Text Box
+ return TaskAttribute.TYPE_LONG_TEXT;
+ case 5: //Date/Time
+ return TaskAttribute.TYPE_DATETIME;
+ case 6: //Bug Id
+ return TaskAttribute.TYPE_INTEGER;
+ case 7: //Bug URLs
+ return TaskAttribute.TYPE_URL;
+ default:
+ Status status = new Status(IStatus.INFO, BugzillaRestCore.ID_PLUGIN,
+ "unknown custom field type " + fieldTyp);
+ StatusHandler.log(status);
+ throw new CoreException(status);
+ }
+ }
+
+ private String mapTaskAttributeKey2ConfigurationFields(String taskAttributeKey) {
+ String resultString;
+ if (taskAttributeKey.equals("task.common.summary")) {
+ resultString = "short_desc";
+ } else if (taskAttributeKey.equals(TaskAttribute.PRODUCT) //
+ || taskAttributeKey.equals(TaskAttribute.RESOLUTION) //
+ || taskAttributeKey.equals(TaskAttribute.PRIORITY) //
+ || taskAttributeKey.equals(TaskAttribute.COMPONENT) //
+ || taskAttributeKey.equals(TaskAttribute.VERSION)) {
+ resultString = taskAttributeKey.substring(12);
+ } else if (taskAttributeKey.equals(TaskAttribute.STATUS)) {
+ resultString = "bug_status";
+ } else if (taskAttributeKey.equals(TaskAttribute.USER_ASSIGNED)) {
+ resultString = "assigned_to";
+ } else if (taskAttributeKey.equals(TaskAttribute.USER_CC)) {
+ resultString = "cc";
+ } else if (taskAttributeKey.equals(TaskAttribute.DESCRIPTION)) {
+ resultString = "longdesc";
+ } else if (taskAttributeKey.equals("comment_is_private")) {
+ resultString = "longdescs.isprivate";
+ } else if (taskAttributeKey.equals("os")) {
+ resultString = "op_sys";
+ } else if (taskAttributeKey.equals("platform")) {
+ resultString = "rep_platform";
+ } else if (taskAttributeKey.equals(TaskAttribute.SEVERITY)) {
+ resultString = "bug_severity";
+ } else if (taskAttributeKey.equals("comment")) {
+ resultString = "longdesc";
+ } else {
+ resultString = taskAttributeKey;
+ }
+ return resultString;
+ }
+
+ private void setAttributeOptionsForProduct(TaskAttribute taskAttribute, Product actualProduct) {
+ taskAttribute.clearOptions();
+ if (taskAttribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())) {
+ internalSetAttributeOptions(taskAttribute, actualProduct.getMilestones());
+ } else if (taskAttribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().VERSION.getKey())) {
+ internalSetAttributeOptions(taskAttribute, actualProduct.getVersions());
+ } else if (taskAttribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().COMPONENT.getKey())) {
+ internalSetAttributeOptions(taskAttribute, actualProduct.getComponents());
+ }
+ }
+
+ private void internalSetAttributeOptions(TaskAttribute taskAttribute, SortableActiveEntry[] actualProductEntry) {
+ boolean found = false;
+ String actualValue = taskAttribute.getValue();
+ for (SortableActiveEntry SortableActiveEntry : actualProductEntry) {
+ if (SortableActiveEntry.isActive()) {
+ taskAttribute.putOption(SortableActiveEntry.getName(), SortableActiveEntry.getName());
+ if (!found) {
+ found = actualValue.equals(SortableActiveEntry.getName());
+ }
+ }
+ }
+ if (!found) {
+ taskAttribute.setValue(""); //$NON-NLS-1$
+ }
+ }
+
+ public boolean updateAfterComponentChange(TaskAttribute taskAttribute) {
+ if (taskAttribute != null) {
+ if (taskAttribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().COMPONENT.getKey())) {
+ TaskAttribute rootAttribute = taskAttribute.getTaskData().getRoot();
+ TaskAttribute productAttribute = taskAttribute.getTaskData()
+ .getRoot()
+ .getMappedAttribute(BugzillaRestCreateTaskSchema.getDefault().PRODUCT.getKey());
+ Product actualProduct = getProductWithName(productAttribute.getValue());
+ Component actualComponent = getProductComponentWithName(actualProduct, taskAttribute.getValue());
+ if (actualComponent != null) {
+ taskAttribute.getMetaData().putValue(TaskAttribute.META_DESCRIPTION,
+ actualComponent.getDescription());
+ TaskAttribute attributeQaContact = rootAttribute
+ .getMappedAttribute(BugzillaRestCreateTaskSchema.getDefault().QA_CONTACT.getKey());
+ if (attributeQaContact != null) {
+ attributeQaContact.setValue(actualComponent.getDefaultQaContact());
+ }
+ TaskAttribute attributeAssignedTo = rootAttribute
+ .getMappedAttribute(BugzillaRestCreateTaskSchema.getDefault().ASSIGNED_TO.getKey());
+ if (attributeAssignedTo != null) {
+ attributeAssignedTo.setValue(actualComponent.getDefaultAssignedTo());
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean updateProductOptions(TaskAttribute taskAttribute) {
+ if (taskAttribute != null) {
+ if (taskAttribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().PRODUCT.getKey())) {
+ TaskAttribute rootAttribute = taskAttribute.getTaskData().getRoot();
+ Product actualProduct = getProductWithName(taskAttribute.getValue());
+
+ TaskAttribute attributeComponent = rootAttribute
+ .getMappedAttribute(BugzillaRestCreateTaskSchema.getDefault().COMPONENT.getKey());
+ if (attributeComponent != null) {
+ setAttributeOptionsForProduct(attributeComponent, actualProduct);
+ }
+ TaskAttribute attributeVersion = rootAttribute
+ .getMappedAttribute(BugzillaRestCreateTaskSchema.getDefault().VERSION.getKey());
+ if (attributeVersion != null) {
+ setAttributeOptionsForProduct(attributeVersion, actualProduct);
+ }
+ TaskAttribute attributeTargetMilestone = rootAttribute
+ .getMappedAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey());
+ if (attributeTargetMilestone != null) {
+ setAttributeOptionsForProduct(attributeTargetMilestone, actualProduct);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public void addValidOperations(TaskData bugReport) {
+ TaskAttribute attributeStatus = bugReport.getRoot().getMappedAttribute(TaskAttribute.STATUS);
+ String attributeStatusValue = attributeStatus.getValue();
+ TaskAttribute operationAttribute = bugReport.getRoot().getAttribute(TaskAttribute.OPERATION);
+ if (operationAttribute == null) {
+ operationAttribute = bugReport.getRoot().createAttribute(TaskAttribute.OPERATION);
+ }
+ TaskAttribute attribute = bugReport.getRoot()
+ .createAttribute(TaskAttribute.PREFIX_OPERATION + attributeStatusValue);
+ TaskOperation.applyTo(attribute, attributeStatusValue, attributeStatusValue);
+ // set as default
+ TaskOperation.applyTo(operationAttribute, attributeStatusValue, attributeStatusValue);
+ Field status = getFieldWithName("bug_status");
+ for (FieldValues fieldValues : status.getValues()) {
+ if (((attributeStatusValue == null || attributeStatusValue.equals("")) && fieldValues.getName() == null)
+ || (attributeStatusValue != null && attributeStatusValue.equals(fieldValues.getName()))) {
+ for (StatusTransition statusTransition : fieldValues.getCanChangeTo()) {
+ attribute = bugReport.getRoot()
+ .createAttribute(TaskAttribute.PREFIX_OPERATION + statusTransition.name);
+ TaskOperation.applyTo(attribute, statusTransition.name, statusTransition.name);
+ if (statusTransition.name != null && statusTransition.name.equals("RESOLVED")) {
+ TaskAttribute attrResolvedInput = attribute.getTaskData()
+ .getRoot()
+ .createAttribute("resolutionInput");
+ attrResolvedInput.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
+ attribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID, "resolutionInput");
+ Field resolution = getFieldWithName("resolution");
+ for (FieldValues resolutionValues : resolution.getValues()) {
+ if (resolutionValues.getName().compareTo("DUPLICATE") != 0) {
+ attrResolvedInput.putOption(resolutionValues.getName(), resolutionValues.getName());
+ }
+ }
+ }
+ }
+ }
+ }
+ attribute = bugReport.getRoot().createAttribute(TaskAttribute.PREFIX_OPERATION + "duplicate");
+ TaskOperation.applyTo(attribute, "duplicate", "Mark as Duplicate");
+ TaskAttribute attrResolvedInput = attribute.getTaskData().getRoot().createAttribute("dup_id");
+ attrResolvedInput.getMetaData().setType(TaskAttribute.TYPE_TASK_DEPENDENCY);
+ attribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID, "dup_id");
+ }
+} \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConnector.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConnector.java
index 2de0da3a3..7fb1e1e2b 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConnector.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConnector.java
@@ -14,8 +14,6 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.eclipse.core.runtime.CoreException;
@@ -56,8 +54,6 @@ public class BugzillaRestConnector extends AbstractRepositoryConnector {
public static final Duration CONFIGURATION_CACHE_REFRESH_AFTER_WRITE_DURATION = new Duration(1, TimeUnit.DAYS);
- private final ExecutorService executor = Executors.newFixedThreadPool(3);
-
private static final ThreadLocal<IOperationMonitor> context = new ThreadLocal<IOperationMonitor>();
private boolean ignoredProperty(String propertyName) {
@@ -135,7 +131,8 @@ public class BugzillaRestConnector extends AbstractRepositoryConnector {
public ListenableFuture<Optional<BugzillaRestConfiguration>> reload(final RepositoryKey key,
Optional<BugzillaRestConfiguration> oldValue) throws Exception {
// asynchronous!
- ListenableFutureJob<Optional<BugzillaRestConfiguration>> job = new ListenableFutureJob("") {
+ ListenableFutureJob<Optional<BugzillaRestConfiguration>> job = new ListenableFutureJob<Optional<BugzillaRestConfiguration>>(
+ "") {
@Override
protected IStatus run(IProgressMonitor monitor) {
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java
new file mode 100644
index 000000000..2e83dda91
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Frank Becker and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.rest.core;
+
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskSchema;
+import org.eclipse.mylyn.tasks.core.data.DefaultTaskSchema;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+
+public class BugzillaRestCreateTaskSchema extends AbstractTaskSchema {
+
+ private static final BugzillaRestCreateTaskSchema instance = new BugzillaRestCreateTaskSchema();
+
+ public static BugzillaRestCreateTaskSchema getDefault() {
+ return instance;
+ }
+
+ private final DefaultTaskSchema parent = DefaultTaskSchema.getInstance();
+
+ public final Field PRODUCT = inheritFrom(parent.PRODUCT).addFlags(Flag.REQUIRED).create();
+
+ public final Field COMPONENT = inheritFrom(parent.COMPONENT).addFlags(Flag.REQUIRED)
+ .dependsOn(PRODUCT.getKey())
+ .create();
+
+ public final Field SUMMARY = inheritFrom(parent.SUMMARY).addFlags(Flag.REQUIRED).create();
+
+ public final Field VERSION = createField(TaskAttribute.VERSION, "Version", TaskAttribute.TYPE_SINGLE_SELECT, null,
+ PRODUCT.getKey(), Flag.ATTRIBUTE, Flag.REQUIRED);
+
+ public final Field DESCRIPTION = inheritFrom(parent.DESCRIPTION).addFlags(Flag.REQUIRED).create();
+
+ public final Field OS = createField("os", "OS", TaskAttribute.TYPE_SINGLE_SELECT, Flag.ATTRIBUTE);
+
+ public final Field PLATFORM = createField("platform", "Platform", TaskAttribute.TYPE_SINGLE_SELECT, Flag.ATTRIBUTE);
+
+ public final Field PRIORITY = inheritFrom(parent.PRIORITY).create();
+
+ public final Field SEVERITY = inheritFrom(parent.SEVERITY).create();
+
+ public final Field ALIAS = createField("alias", "Alias", TaskAttribute.TYPE_SHORT_TEXT, Flag.ATTRIBUTE);
+
+ public final Field ASSIGNED_TO = inheritFrom(parent.USER_ASSIGNED).label("Assigned to")
+ .dependsOn(COMPONENT.getKey())
+ .create();
+
+ public final Field CC = createField(TaskAttribute.USER_CC, "CC", TaskAttribute.TYPE_PERSON, Flag.PEOPLE);
+
+ public final Field ADD_SELF_CC = inheritFrom(parent.ADD_SELF_CC).addFlags(Flag.PEOPLE).create();
+
+ public final Field COMMENT_IS_PRIVATE = createField("comment_is_private", "Description is private",
+ TaskAttribute.TYPE_BOOLEAN, Flag.ATTRIBUTE);
+
+ public final Field QA_CONTACT = createField("qa_contact", "QA Contact", TaskAttribute.TYPE_PERSON, null,
+ COMPONENT.getKey(), Flag.PEOPLE);
+
+ public final Field TARGET_MILESTONE = createField("target_milestone", "Target milestone",
+ TaskAttribute.TYPE_SINGLE_SELECT, null, PRODUCT.getKey(), Flag.ATTRIBUTE);
+
+ public final Field RESOLUTION = inheritFrom(parent.RESOLUTION).create();
+
+ public final Field OPERATION = createField(TaskAttribute.OPERATION, "Operation", TaskAttribute.TYPE_OPERATION);
+
+ public final Field STATUS = inheritFrom(parent.STATUS).create();
+}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskAttributeMapper.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskAttributeMapper.java
new file mode 100644
index 000000000..8c4535ab8
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskAttributeMapper.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Frank Becker and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.rest.core;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Product;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.SortableActiveEntry;
+import org.eclipse.mylyn.tasks.core.RepositoryStatus;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+
+public class BugzillaRestTaskAttributeMapper extends TaskAttributeMapper {
+
+ private final BugzillaRestConnector connector;
+
+ public BugzillaRestTaskAttributeMapper(TaskRepository taskRepository, BugzillaRestConnector connector) {
+ super(taskRepository);
+ this.connector = connector;
+ }
+
+ @Override
+ public Map<String, String> getOptions(@NonNull TaskAttribute attribute) {
+ if (attribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
+ || attribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().VERSION.getKey())
+ || attribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().COMPONENT.getKey())) {
+ TaskAttribute productAttribute = attribute.getParentAttribute()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().PRODUCT.getKey());
+ BugzillaRestConfiguration repositoryConfiguration;
+ try {
+ repositoryConfiguration = connector.getRepositoryConfiguration(this.getTaskRepository());
+ if (repositoryConfiguration != null) {
+ if (!productAttribute.getValue().equals("")) { //$NON-NLS-1$
+ Product actualProduct = repositoryConfiguration.getProductWithName(productAttribute.getValue());
+ if (attribute.getId()
+ .equals(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())) {
+ internalSetAttributeOptions(attribute, actualProduct.getMilestones());
+ } else
+ if (attribute.getId().equals(BugzillaRestCreateTaskSchema.getDefault().VERSION.getKey())) {
+ internalSetAttributeOptions(attribute, actualProduct.getVersions());
+ } else if (attribute.getId()
+ .equals(BugzillaRestCreateTaskSchema.getDefault().COMPONENT.getKey())) {
+ internalSetAttributeOptions(attribute, actualProduct.getComponents());
+ }
+ }
+ }
+ } catch (CoreException e) {
+ StatusHandler.log(new RepositoryStatus(getTaskRepository(), IStatus.ERROR, BugzillaRestCore.ID_PLUGIN,
+ 0, "Failed to obtain repository configuration", e)); //$NON-NLS-1$
+ }
+ }
+ return super.getOptions(attribute);
+ }
+
+ private void internalSetAttributeOptions(TaskAttribute taskAttribute, SortableActiveEntry[] actualProductEntry) {
+ boolean found = false;
+ String actualValue = taskAttribute.getValue();
+ taskAttribute.clearOptions();
+ for (SortableActiveEntry SortableActiveEntry : actualProductEntry) {
+ if (SortableActiveEntry.isActive()) {
+ // TODO: remove when we have offline cache for the repository configuration
+ taskAttribute.putOption(SortableActiveEntry.getName(), SortableActiveEntry.getName());
+ if (!found) {
+ found = actualValue.equals(SortableActiveEntry.getName());
+ }
+ }
+ }
+ if (!found) {
+ taskAttribute.setValue(""); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskDataHandler.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskDataHandler.java
index d99ec950e..99769e47d 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskDataHandler.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskDataHandler.java
@@ -45,16 +45,24 @@ public class BugzillaRestTaskDataHandler extends AbstractTaskDataHandler {
// fresh from the repository (not locally stored data that may not have
// been migrated).
data.setVersion("0"); //$NON-NLS-1$
- BugzillaRestTaskSchema.getDefault().initialize(data);
+ if (data.isNew()) {
+ BugzillaRestCreateTaskSchema.getDefault().initialize(data);
+ } else {
+ BugzillaRestTaskSchema.getDefault().initialize(data);
+ }
if (initializationData != null) {
connector.getTaskMapping(data).merge(initializationData);
}
+ BugzillaRestConfiguration config = connector.getRepositoryConfiguration(repository);
+ if (config != null) {
+ config.updateInitialTaskData(data);
+ }
return true;
}
@Override
public TaskAttributeMapper getAttributeMapper(TaskRepository repository) {
- return new TaskAttributeMapper(repository);
+ return new BugzillaRestTaskAttributeMapper(repository, connector);
}
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
index b620c141d..aac11f875 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
@@ -14,6 +14,7 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskSchema;
import org.eclipse.mylyn.tasks.core.data.DefaultTaskSchema;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
public class BugzillaRestTaskSchema extends AbstractTaskSchema {
@@ -25,15 +26,69 @@ public class BugzillaRestTaskSchema extends AbstractTaskSchema {
private final DefaultTaskSchema parent = DefaultTaskSchema.getInstance();
- public final Field DESCRIPTION = inheritFrom(parent.DESCRIPTION).create();
+ public final Field BUG_ID = createField("bug_id", "ID:", TaskAttribute.TYPE_SHORT_TEXT, Flag.REQUIRED);
- public final Field SUMMARY = inheritFrom(parent.SUMMARY).create();
+ public final Field PRODUCT = inheritFrom(parent.PRODUCT).addFlags(Flag.REQUIRED).create();
+
+ public final Field COMPONENT = inheritFrom(parent.COMPONENT).addFlags(Flag.REQUIRED)
+ .dependsOn(PRODUCT.getKey())
+ .create();
+
+ public final Field SUMMARY = inheritFrom(parent.SUMMARY).addFlags(Flag.REQUIRED).create();
+
+ public final Field VERSION = createField("version", "Version", TaskAttribute.TYPE_SINGLE_SELECT, null,
+ PRODUCT.getKey(), Flag.ATTRIBUTE, Flag.REQUIRED);
+
+ public final Field DESCRIPTION = inheritFrom(parent.DESCRIPTION).addFlags(Flag.REQUIRED, Flag.READ_ONLY).create();
+
+ public final Field OS = createField("os", "OS", TaskAttribute.TYPE_SINGLE_SELECT, Flag.ATTRIBUTE);
+
+ public final Field PLATFORM = createField("platform", "Platform", TaskAttribute.TYPE_SINGLE_SELECT, Flag.ATTRIBUTE);
+
+ public final Field PRIORITY = inheritFrom(parent.PRIORITY).create();
+
+ public final Field SEVERITY = inheritFrom(parent.SEVERITY).create();
+
+ public final Field STATUS = inheritFrom(parent.STATUS).create();
+
+ public final Field ALIAS = createField("alias", "Alias", TaskAttribute.TYPE_SHORT_TEXT, Flag.ATTRIBUTE);
+
+ public final Field ASSIGNED_TO = inheritFrom(parent.USER_ASSIGNED).label("Assigned to")
+ .dependsOn(COMPONENT.getKey())
+ .create();
+
+ public final Field CC = createField(TaskAttribute.USER_CC, "CC", TaskAttribute.TYPE_PERSON, Flag.PEOPLE);
+
+ public final Field ADD_SELF_CC = inheritFrom(parent.ADD_SELF_CC).addFlags(Flag.PEOPLE).create();
+
+ public final Field COMMENT_ISPRIVATE = inheritFrom(parent.COMMENT_ISPRIVATE).addFlags(Flag.ATTRIBUTE).create();
+
+ public final Field COMMENT_NUMBER = inheritFrom(parent.COMMENT_NUMBER).addFlags(Flag.ATTRIBUTE).create();
+
+ public final Field QA_CONTACT = createField("qa_contact", "QA Contact", TaskAttribute.TYPE_PERSON, null,
+ COMPONENT.getKey(), Flag.PEOPLE);
public final Field NEW_COMMENT = inheritFrom(parent.NEW_COMMENT).create();
- public final Field COMPONENT = inheritFrom(parent.COMPONENT).create();
+ public final Field RESOLUTION = inheritFrom(parent.RESOLUTION).create();
+
+ public final Field TARGET_MILESTONE = createField("target_milestone", "Target milestone",
+ TaskAttribute.TYPE_SINGLE_SELECT, null, PRODUCT.getKey(), Flag.ATTRIBUTE);
- public final Field DUMMYATTRIBUTE = createField("task.bugzilla.dummy.attribute", "Dummy Attribute", //$NON-NLS-1$ //$NON-NLS-2$
- TaskAttribute.TYPE_SHORT_TEXT, Flag.ATTRIBUTE);
+ public final Field OPERATION = createField(TaskAttribute.OPERATION, "Operation", TaskAttribute.TYPE_OPERATION);
+
+ @Override
+ public void initialize(TaskData taskData) {
+ for (Field field : getFields()) {
+ if (field.equals(COMMENT_ISPRIVATE) || field.equals(COMMENT_NUMBER)) {
+ continue;
+ }
+ TaskAttribute newField = field.createAttribute(taskData.getRoot());
+ if (field.equals(DESCRIPTION)) {
+ COMMENT_ISPRIVATE.createAttribute(newField);
+ COMMENT_NUMBER.createAttribute(newField);
+ }
+ }
+ }
-}
+} \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Component.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Component.java
index ca52da95c..cf0500cbc 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Component.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Component.java
@@ -11,35 +11,24 @@
package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data;
-import java.io.Serializable;
+public class Component extends SortableActiveEntry {
-public class Component implements Serializable {
- private static final long serialVersionUID = -3420463254677859338L;
+ private static final long serialVersionUID = -285913855003802343L;
private int id;
- private String name;
-
private String description;
private String default_assigned_to;
private String default_qa_contact;
- private int sort_key;
-
- private boolean is_active;
-
private FlagTypes flag_types;
public int getId() {
return id;
}
- public String getName() {
- return name;
- }
-
public String getDescription() {
return description;
}
@@ -52,14 +41,6 @@ public class Component implements Serializable {
return default_qa_contact;
}
- public int getSortKey() {
- return sort_key;
- }
-
- public boolean isActive() {
- return is_active;
- }
-
public FlagTypes getFlagTypes() {
return flag_types;
}

Back to the top