Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java36
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java67
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java53
3 files changed, 97 insertions, 59 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index 5a0540266..52cba1874 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -611,33 +611,21 @@ public class BugzillaClient {
BugzillaTaskDataHandler.createAttribute(existingReport, element);
}
String useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE);
- if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
- BugzillaTaskDataHandler.createAttribute(existingReport, BugzillaAttribute.TARGET_MILESTONE);
- }
+ BugzillaUtil.addAttributeIfUsed(BugzillaAttribute.TARGET_MILESTONE,
+ IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE, taskRepository, existingReport, true);
for (BugzillaAttribute element : reportElements2) {
BugzillaTaskDataHandler.createAttribute(existingReport, element);
}
- useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USEQACONTACT);
- if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
- BugzillaTaskDataHandler.createAttribute(existingReport, BugzillaAttribute.QA_CONTACT);
- }
- useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USESTATUSWHITEBOARD);
- if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
- BugzillaTaskDataHandler.createAttribute(existingReport, BugzillaAttribute.STATUS_WHITEBOARD);
- }
- useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USEBUGALIASES);
- if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
- BugzillaTaskDataHandler.createAttribute(existingReport, BugzillaAttribute.ALIAS);
- }
- useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USECLASSIFICATION);
- if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
- BugzillaTaskDataHandler.createAttribute(existingReport, BugzillaAttribute.CLASSIFICATION);
- }
- useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USE_SEE_ALSO);
- if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
- BugzillaTaskDataHandler.createAttribute(existingReport, BugzillaAttribute.SEE_ALSO);
- }
-
+ BugzillaUtil.addAttributeIfUsed(BugzillaAttribute.QA_CONTACT, IBugzillaConstants.BUGZILLA_PARAM_USEQACONTACT,
+ taskRepository, existingReport, true);
+ BugzillaUtil.addAttributeIfUsed(BugzillaAttribute.STATUS_WHITEBOARD,
+ IBugzillaConstants.BUGZILLA_PARAM_USESTATUSWHITEBOARD, taskRepository, existingReport, true);
+ BugzillaUtil.addAttributeIfUsed(BugzillaAttribute.ALIAS, IBugzillaConstants.BUGZILLA_PARAM_USEBUGALIASES,
+ taskRepository, existingReport, false);
+ BugzillaUtil.addAttributeIfUsed(BugzillaAttribute.CLASSIFICATION,
+ IBugzillaConstants.BUGZILLA_PARAM_USECLASSIFICATION, taskRepository, existingReport, false);
+ BugzillaUtil.addAttributeIfUsed(BugzillaAttribute.SEE_ALSO, IBugzillaConstants.BUGZILLA_PARAM_USE_SEE_ALSO,
+ taskRepository, existingReport, false);
}
public static String getBugUrlWithoutLogin(String repositoryUrl, String id) {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java
new file mode 100644
index 000000000..055fbf614
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.core;
+
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+public class BugzillaUtil {
+ public static void addAttributeIfUsed(BugzillaAttribute constant, String propertyName,
+ TaskRepository taskRepository, TaskData existingReport, boolean createWhenNull) {
+ String useParam = taskRepository.getProperty(propertyName);
+ if (createWhenNull) {
+ if (useParam == null || (useParam != null && useParam.equals("true"))) { //$NON-NLS-1$
+ BugzillaTaskDataHandler.createAttribute(existingReport, constant);
+ }
+ } else {
+ if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
+ BugzillaTaskDataHandler.createAttribute(existingReport, constant);
+ }
+
+ }
+ }
+
+ public static void createAttributeWithKindDefaultIfUsed(String parsedText, BugzillaAttribute tag,
+ TaskData repositoryTaskData, String propertyName, boolean defaultWhenNull) {
+
+ TaskAttribute attribute = repositoryTaskData.getRoot().getMappedAttribute(tag.getKey());
+ if (attribute == null) {
+ attribute = BugzillaTaskDataHandler.createAttribute(repositoryTaskData, tag);
+ attribute.setValue(parsedText);
+ } else {
+ attribute.addValue(parsedText);
+ }
+// TaskRepository repository = repositoryTaskData.getAttributeMapper().getTaskRepository();
+// repository.removeProperty(IBugzillaConstants.BUGZILLA_PARAM_USE_SEE_ALSO);
+// repository.removeProperty(IBugzillaConstants.BUGZILLA_PARAM_USEBUGALIASES);
+// repository.removeProperty(IBugzillaConstants.BUGZILLA_PARAM_USEQACONTACT);
+// repository.removeProperty(IBugzillaConstants.BUGZILLA_PARAM_USESTATUSWHITEBOARD);
+// repository.removeProperty(IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE);
+// repository.removeProperty(IBugzillaConstants.BUGZILLA_PARAM_USECLASSIFICATION);
+ String useParam = repositoryTaskData.getAttributeMapper().getTaskRepository().getProperty(propertyName);
+ if (defaultWhenNull) {
+ if (useParam == null || (useParam != null && useParam.equals("true"))) { //$NON-NLS-1$
+ attribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
+ } else {
+ attribute.getMetaData().setKind(null);
+ }
+ } else {
+ if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
+ attribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
+ } else {
+ attribute.getMetaData().setKind(null);
+ }
+ }
+
+ }
+}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
index 051b93fc8..16ec0811c 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
@@ -487,46 +487,29 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
attachment.setAuthor(author);
}
break;
- case CLASSIFICATION:
case TARGET_MILESTONE:
+ BugzillaUtil.createAttributeWithKindDefaultIfUsed(parsedText, tag, repositoryTaskData,
+ IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE, true);
+ break;
case QA_CONTACT:
+ BugzillaUtil.createAttributeWithKindDefaultIfUsed(parsedText, tag, repositoryTaskData,
+ IBugzillaConstants.BUGZILLA_PARAM_USEQACONTACT, true);
+ break;
case STATUS_WHITEBOARD:
+ BugzillaUtil.createAttributeWithKindDefaultIfUsed(parsedText, tag, repositoryTaskData,
+ IBugzillaConstants.BUGZILLA_PARAM_USESTATUSWHITEBOARD, true);
+ break;
+ case CLASSIFICATION:
+ BugzillaUtil.createAttributeWithKindDefaultIfUsed(parsedText, tag, repositoryTaskData,
+ IBugzillaConstants.BUGZILLA_PARAM_USECLASSIFICATION, false);
+ break;
case ALIAS:
+ BugzillaUtil.createAttributeWithKindDefaultIfUsed(parsedText, tag, repositoryTaskData,
+ IBugzillaConstants.BUGZILLA_PARAM_USEBUGALIASES, false);
+ break;
case SEE_ALSO:
- TaskAttribute suppressAttribute = createAttrribute(parsedText, tag);
- String propertyName = null;
- switch (tag) {
- case CLASSIFICATION:
- propertyName = IBugzillaConstants.BUGZILLA_PARAM_USECLASSIFICATION;
- break;
- case TARGET_MILESTONE:
- propertyName = IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE;
- break;
- case QA_CONTACT:
- propertyName = IBugzillaConstants.BUGZILLA_PARAM_USEQACONTACT;
- break;
- case STATUS_WHITEBOARD:
- propertyName = IBugzillaConstants.BUGZILLA_PARAM_USESTATUSWHITEBOARD;
- break;
- case ALIAS:
- propertyName = IBugzillaConstants.BUGZILLA_PARAM_USEBUGALIASES;
- break;
- case SEE_ALSO:
- propertyName = IBugzillaConstants.BUGZILLA_PARAM_USE_SEE_ALSO;
- break;
- default:
- propertyName = null;
- break;
- }
- String useParam = repositoryTaskData.getAttributeMapper().getTaskRepository().getProperty(propertyName);
- if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
- suppressAttribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
- if (BugzillaAttribute.CLASSIFICATION.equals(tag)) {
- suppressAttribute.getMetaData().setReadOnly(true);
- }
- } else {
- suppressAttribute.getMetaData().setKind(null);
- }
+ BugzillaUtil.createAttributeWithKindDefaultIfUsed(parsedText, tag, repositoryTaskData,
+ IBugzillaConstants.BUGZILLA_PARAM_USE_SEE_ALSO, false);
break;
default:
createAttrribute(parsedText, tag);

Back to the top