Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2016-10-09 11:08:45 +0000
committerGerrit Code Review @ Eclipse.org2016-12-02 17:28:14 +0000
commite7fabafd1aea0f492090868a1a1d3aac8a6d6a41 (patch)
tree5a57a026cf43b3966cb55baca5a424e60c0b5228
parentb471fc77846cc1e314b1ff73aa87553020b93fd5 (diff)
downloadorg.eclipse.mylyn.tasks-e7fabafd1aea0f492090868a1a1d3aac8a6d6a41.tar.gz
org.eclipse.mylyn.tasks-e7fabafd1aea0f492090868a1a1d3aac8a6d6a41.tar.xz
org.eclipse.mylyn.tasks-e7fabafd1aea0f492090868a1a1d3aac8a6d6a41.zip
499382: add Flag support for bugs and attachments (only core part)
Change-Id: Idaa2e596211430f36adda3eced4cce7ec2a232a3 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=499382
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java2
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java662
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestFlagMapperTest.java163
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskDataFlags.txt17
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskDataFlags.txt17
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.json1
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.txt7
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.json1
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.txt8
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java7
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java1
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java156
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestFlagMapper.java226
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java13
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskData.java12
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java23
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java11
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java1
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskAttributeMapper.java22
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java5
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Product.java9
21 files changed, 1327 insertions, 37 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java
index 6f829bfc0..ca5d011a3 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java
@@ -22,7 +22,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(ManagedSuite.class)
-@Suite.SuiteClasses({ RepositoryKeyTest.class })
+@Suite.SuiteClasses({ RepositoryKeyTest.class, BugzillaRestFlagMapperTest.class })
@TestConfigurationProperty()
public class AllBugzillaRestCoreTests {
static {
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java
index b98fb489c..813942f5d 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java
@@ -12,6 +12,7 @@
package org.eclipse.mylyn.bugzilla.rest.core.tests;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -48,6 +49,7 @@ import org.eclipse.mylyn.commons.sdk.util.ConditionalIgnoreRule;
import org.eclipse.mylyn.commons.sdk.util.IFixtureJUnitClass;
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner;
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner.FixtureDefinition;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestAttachmentMapper;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestClient;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector;
@@ -539,6 +541,15 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
taskDataGet.getRoot().removeAttribute(BugzillaRestTaskSchema.getDefault().RESET_QA_CONTACT.getKey());
taskDataGet.getRoot().removeAttribute(BugzillaRestTaskSchema.getDefault().RESET_ASSIGNED_TO.getKey());
taskDataGet.getRoot().removeAttribute(BugzillaRestTaskSchema.getDefault().ADD_SELF_CC.getKey());
+ ArrayList<TaskAttribute> flags = new ArrayList<>();
+ for (TaskAttribute attribute : taskDataGet.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ flags.add(attribute);
+ }
+ }
+ for (TaskAttribute taskAttribute : flags) {
+ taskDataGet.getRoot().removeAttribute(taskAttribute.getId());
+ }
// attributes for operations
taskDataGet.getRoot().removeAttribute("task.common.operation-CONFIRMED");
@@ -549,7 +560,10 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
taskDataGet.getRoot().removeAttribute(BugzillaRestTaskSchema.getDefault().DUPE_OF.getKey());
assertEquals(taskData.getRoot().toString(), taskDataGet.getRoot().toString());
- }
+ assertEquals(
+ IOUtils.toString(
+ CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskDataFlags.txt")),
+ flags.toString()); }
@Test
public void testUpdateTaskData() throws Exception {
@@ -1210,4 +1224,650 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
assertEquals(taskIdRel[1], dependsOnAttrib.getValues().get(1));
assertEquals(taskIdRel[2], dependsOnAttrib.getValues().get(2));
}
+
+ @Test
+ public void testFlagsSet() throws Exception {
+ String taskId = harness.getNewTaksId4TestProduct();
+
+ TaskData taskDataGet = harness.getTaskFromServer(taskId);
+
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ TaskData taskDataOld = TaskDataState.createCopy(taskDataGet);
+ for (TaskAttribute attribute : taskDataGet.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ boolean found;
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ state.setValue("-");
+ found = true;
+ break;
+ case "BugFlag2":
+ state.setValue("?");
+ found = true;
+ break;
+ case "BugFlag3":
+ state.setValue("+");
+ found = true;
+ break;
+ case "BugFlag4":
+ state.setValue("?");
+ attribute.getAttribute("requestee").setValue("admin@mylyn.eclipse.org");
+ found = true;
+ break;
+ default:
+ found = false;
+ break;
+ }
+ if (found) {
+ changed.add(taskDataOld.getRoot().getAttribute(attribute.getId()));
+ }
+ }
+ }
+ }
+
+ //Act
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
+ changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ TaskData taskDataUpdate = harness.getTaskFromServer(taskId);
+ int flagcount = 0;
+ for (TaskAttribute attribute : taskDataUpdate.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
+ flagcount++;
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ assertEquals("-", state.getValue());
+ assertEquals("[, -, +]", state.getOptions().values().toString());
+ assertEquals("1", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ break;
+ case "BugFlag2":
+ assertEquals("?", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("2", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ break;
+ case "BugFlag3":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("+", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("5", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ break;
+ case "BugFlag4":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("?", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals("admin@mylyn.eclipse.org", attribute.getAttribute("requestee").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("6", attribute.getAttribute("typeId").getValue());
+ break;
+ default:
+ fail("No flag with name " + state.getMetaData().getLabel());
+ break;
+ }
+ }
+ }
+ }
+ assertEquals(6, flagcount);
+ }
+
+ @Test
+ public void testFlagsReset() throws Exception {
+ String taskId = harness.getNewTaksId4TestProduct();
+
+ TaskData taskDataGet = harness.getTaskFromServer(taskId);
+
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ TaskData taskDataOld = TaskDataState.createCopy(taskDataGet);
+ for (TaskAttribute attribute : taskDataGet.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ boolean found;
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ state.setValue("-");
+ found = true;
+ break;
+ case "BugFlag2":
+ state.setValue("?");
+ found = true;
+ break;
+ case "BugFlag3":
+ state.setValue("+");
+ found = true;
+ break;
+ case "BugFlag4":
+ state.setValue("?");
+ attribute.getAttribute("requestee").setValue("admin@mylyn.eclipse.org");
+ found = true;
+ break;
+ default:
+ found = false;
+ break;
+ }
+ if (found) {
+ changed.add(taskDataOld.getRoot().getAttribute(attribute.getId()));
+ }
+ }
+ }
+ }
+
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
+ changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ TaskData taskDataUpdate = harness.getTaskFromServer(taskId);
+ Set<TaskAttribute> changedUpdate = new HashSet<TaskAttribute>();
+ TaskData taskDataOldUpdate = TaskDataState.createCopy(taskDataUpdate);
+ for (TaskAttribute attribute : taskDataUpdate.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ boolean found;
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ assertEquals("-", state.getValue());
+ assertEquals("[, -, +]", state.getOptions().values().toString());
+ assertEquals("1", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue(" ");
+ found = true;
+ break;
+ case "BugFlag2":
+ assertEquals("?", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("2", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue(" ");
+ found = true;
+ break;
+ case "BugFlag3":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("+", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue(" ");
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("5", attribute.getAttribute("typeId").getValue());
+ found = true;
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ break;
+ case "BugFlag4":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("?", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals("admin@mylyn.eclipse.org", attribute.getAttribute("requestee").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue(" ");
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("6", attribute.getAttribute("typeId").getValue());
+ found = true;
+ break;
+ default:
+ fail("No flag with name " + state.getMetaData().getLabel());
+ found = false;
+ break;
+ }
+ if (found) {
+ changedUpdate.add(taskDataOldUpdate.getRoot().getAttribute(attribute.getId()));
+ }
+ }
+ }
+ }
+ //Act
+ reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataUpdate, changedUpdate, null);
+ //Assert
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ taskDataUpdate = harness.getTaskFromServer(taskId);
+ int flagcount = 0;
+ for (TaskAttribute attribute : taskDataUpdate.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
+ flagcount++;
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ assertEquals(IBugzillaRestConstants.KIND_FLAG_TYPE + "1", attribute.getId());
+ assertEquals(" ", state.getValue());
+ assertEquals("[, -, +]", state.getOptions().values().toString());
+ assertEquals("1", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ break;
+ case "BugFlag2":
+ assertEquals(IBugzillaRestConstants.KIND_FLAG_TYPE + "2", attribute.getId());
+ assertEquals(" ", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("2", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ break;
+ case "BugFlag3":
+ assertEquals(IBugzillaRestConstants.KIND_FLAG_TYPE + "5", attribute.getId());
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("5", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ break;
+ case "BugFlag4":
+ assertEquals(IBugzillaRestConstants.KIND_FLAG_TYPE + "6", attribute.getId());
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("6", attribute.getAttribute("typeId").getValue());
+ break;
+ default:
+ fail("No flag with name " + state.getMetaData().getLabel());
+ break;
+ }
+ }
+ }
+ }
+ assertEquals(4, flagcount);
+ }
+
+ @Test
+ public void testFlagsChange() throws Exception {
+ String taskId = harness.getNewTaksId4TestProduct();
+
+ TaskData taskDataGet = harness.getTaskFromServer(taskId);
+
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ TaskData taskDataOld = TaskDataState.createCopy(taskDataGet);
+ for (TaskAttribute attribute : taskDataGet.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ boolean found;
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ state.setValue("-");
+ found = true;
+ break;
+ case "BugFlag2":
+ state.setValue("?");
+ found = true;
+ break;
+ case "BugFlag3":
+ state.setValue("+");
+ found = true;
+ break;
+ case "BugFlag4":
+ state.setValue("?");
+ attribute.getAttribute("requestee").setValue("admin@mylyn.eclipse.org");
+ found = true;
+ break;
+ default:
+ found = false;
+ break;
+ }
+ if (found) {
+ changed.add(taskDataOld.getRoot().getAttribute(attribute.getId()));
+ }
+ }
+ }
+ }
+
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
+ changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ TaskData taskDataUpdate = harness.getTaskFromServer(taskId);
+ Set<TaskAttribute> changedUpdate = new HashSet<TaskAttribute>();
+ TaskData taskDataOldUpdate = TaskDataState.createCopy(taskDataUpdate);
+ for (TaskAttribute attribute : taskDataUpdate.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ boolean found;
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ assertEquals("-", state.getValue());
+ assertEquals("[, -, +]", state.getOptions().values().toString());
+ assertEquals("1", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue("+");
+ found = true;
+ break;
+ case "BugFlag2":
+ assertEquals("?", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("2", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue("-");
+ found = true;
+ break;
+ case "BugFlag3":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("+", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue("-");
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("5", attribute.getAttribute("typeId").getValue());
+ found = true;
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ break;
+ case "BugFlag4":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("?", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals("admin@mylyn.eclipse.org", attribute.getAttribute("requestee").getValue());
+ assertEquals(attribute.getAttribute("creationDate").getValue(),
+ attribute.getAttribute("modificationDate").getValue());
+ state.setValue("+");
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("6", attribute.getAttribute("typeId").getValue());
+ found = true;
+ break;
+ default:
+ fail("No flag with name " + state.getMetaData().getLabel());
+ found = false;
+ break;
+ }
+ if (found) {
+ changedUpdate.add(taskDataOldUpdate.getRoot().getAttribute(attribute.getId()));
+ }
+ }
+ }
+ }
+ //Act
+ reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataUpdate, changedUpdate, null);
+ //Assert
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ taskDataUpdate = harness.getTaskFromServer(taskId);
+ int flagcount = 0;
+ for (TaskAttribute attribute : taskDataUpdate.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
+ flagcount++;
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ switch (state.getMetaData().getLabel()) {
+ case "BugFlag1":
+ assertEquals("+", state.getValue());
+ assertEquals("[, -, +]", state.getOptions().values().toString());
+ assertEquals("1", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertThat(attribute.getAttribute("modificationDate").getValue(),
+ greaterThan(attribute.getAttribute("creationDate").getValue()));
+ break;
+ case "BugFlag2":
+ assertEquals("-", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("2", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertThat(attribute.getAttribute("modificationDate").getValue(),
+ greaterThan(attribute.getAttribute("creationDate").getValue()));
+ break;
+ case "BugFlag3":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("-", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertThat(attribute.getAttribute("modificationDate").getValue(),
+ greaterThan(attribute.getAttribute("creationDate").getValue()));
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("5", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ break;
+ case "BugFlag4":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("", attribute.getAttribute("setter").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertNull(attribute.getAttribute("creationDate"));
+ assertNull(attribute.getAttribute("modificationDate"));
+ } else {
+ assertEquals("+", state.getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertThat(attribute.getAttribute("modificationDate").getValue(),
+ greaterThan(attribute.getAttribute("creationDate").getValue()));
+ }
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("6", attribute.getAttribute("typeId").getValue());
+ break;
+ default:
+ fail("No flag with name " + state.getMetaData().getLabel());
+ break;
+ }
+ }
+ }
+ }
+ assertEquals(6, flagcount);
+ }
+
+ @Test
+ public void testTextAttachmentWithFlags() throws Exception {
+ TaskAttribute attachmentAttribute = null;
+ TaskRepository repository = actualFixture.repository();
+
+ final TaskMapping taskMappingInit = new TaskMapping() {
+ @Override
+ public String getSummary() {
+ return "Bug for Text Attachment with Flags";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The bug is used to test that text attachments with flags can be put and get correctly!";
+ }
+
+ @Override
+ public String getProduct() {
+ return "ManualTest";
+ }
+
+ @Override
+ public String getComponent() {
+ return "ManualC1";
+ }
+
+ @Override
+ public String getVersion() {
+ return "R1";
+ }
+ };
+
+ String taskId = harness.getNewTaksIdFromInitMapping(taskMappingInit, harness.taskInitializationData);
+ TaskData taskData = harness.getTaskFromServer(taskId);
+ assertNotNull(taskData);
+
+ for (Entry<String, TaskAttribute> entry : taskData.getRoot().getAttributes().entrySet()) {
+ if (TaskAttribute.TYPE_ATTACHMENT.equals(entry.getValue().getMetaData().getType())) {
+ attachmentAttribute = entry.getValue();
+ }
+ }
+ assertNull(attachmentAttribute);
+
+ BugzillaRestTaskAttachmentHandler attachmentHandler = new BugzillaRestTaskAttachmentHandler(connector);
+ ITask task = new TaskTask(actualFixture.repository().getConnectorKind(),
+ actualFixture.repository().getRepositoryUrl(), taskId);
+
+ InputStream in = CommonTestUtil.getResource(this, "testdata/AttachmentTest.txt");
+ File file = File.createTempFile("attachment", null);
+ file.deleteOnExit();
+ OutputStream out = new FileOutputStream(file);
+ try {
+ IOUtils.copy(in, out);
+ } finally {
+ in.close();
+ out.close();
+ }
+
+ FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(file);
+ attachment.setContentType("text/plain");
+ attachment.setDescription("My Attachment 2");
+ attachment.setName("Attachment 2.txt");
+
+ attachmentAttribute = taskData.getRoot().createMappedAttribute(TaskAttribute.NEW_ATTACHMENT);
+
+ BugzillaRestAttachmentMapper attachmentMapper = BugzillaRestAttachmentMapper.createFrom(attachmentAttribute);
+ BugzillaRestAttachmentMapper.createFrom(attachmentAttribute);
+ attachmentMapper.setContentType("text/plain");
+ attachmentMapper.setDescription("My Attachment 2");
+ attachmentMapper.setFileName("Attachment 2.txt");
+ attachmentMapper.applyTo(attachmentAttribute);
+ attachmentMapper.addMissingFlags(attachmentAttribute);
+ TaskAttribute flag3 = attachmentAttribute.getAttribute(IBugzillaRestConstants.KIND_FLAG_TYPE + "3");
+ TaskAttribute state3 = attachmentAttribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(flag3);
+ state3.setValue("+");
+ TaskAttribute flag4 = attachmentAttribute.getAttribute(IBugzillaRestConstants.KIND_FLAG_TYPE + "4");
+ TaskAttribute state4 = attachmentAttribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(flag4);
+ state4.setValue("-");
+
+ attachmentHandler.postContent(repository, task, attachment, "comment", attachmentAttribute, null);
+ taskData = getTaskData(taskId);
+ assertNotNull(taskData);
+ for (Entry<String, TaskAttribute> entry : taskData.getRoot().getAttributes().entrySet()) {
+ if (TaskAttribute.TYPE_ATTACHMENT.equals(entry.getValue().getMetaData().getType())) {
+ attachmentAttribute = entry.getValue();
+ }
+ }
+ assertNotNull(attachmentAttribute);
+ int flagcount = 0;
+ for (TaskAttribute attribute : attachmentAttribute.getAttributes().values()) {
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
+ flagcount++;
+ TaskAttribute state = attribute.getTaskData().getAttributeMapper().getAssoctiatedAttribute(attribute);
+ if (state != null) {
+ switch (state.getMetaData().getLabel()) {
+ case "AttachmentFlag1":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("3", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ } else {
+ assertEquals("+", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("3", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ }
+ break;
+ case "AttachmentFlag2":
+ if (attribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ assertEquals(" ", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("4", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ } else {
+ assertEquals("-", state.getValue());
+ assertEquals("[, ?, -, +]", state.getOptions().values().toString());
+ assertEquals("4", attribute.getAttribute("typeId").getValue());
+ assertEquals("", attribute.getAttribute("requestee").getValue());
+ assertEquals("tests@mylyn.eclipse.org", attribute.getAttribute("setter").getValue());
+ }
+ break;
+ default:
+ fail("No flag with name " + state.getMetaData().getLabel());
+ break;
+ }
+ }
+ }
+ }
+ assertEquals(4, flagcount);
+ InputStream instream = attachmentHandler.getContent(actualFixture.repository(), task, attachmentAttribute,
+ null);
+ InputStream instream2 = CommonTestUtil.getResource(this, "testdata/AttachmentTest.txt");
+ assertTrue(IOUtils.contentEquals(instream, instream2));
+ }
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestFlagMapperTest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestFlagMapperTest.java
new file mode 100644
index 000000000..17bb225d8
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestFlagMapperTest.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.bugzilla.rest.core.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestFlagMapper;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.IBugzillaRestConstants;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+
+public class BugzillaRestFlagMapperTest {
+
+ private TaskData mockTestData;
+
+ @Before
+ public void setUp() throws Exception {
+ TaskAttributeMapper mapper = new TaskAttributeMapper(new TaskRepository("", ""));
+
+ mockTestData = new TaskData(mapper, "", "", "");
+ }
+
+ @Test
+ public void testReadFromJson() throws IOException {
+ String jsonElement = IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag.json"));
+
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(jsonElement, BugzillaRestFlagMapper.class);
+ assertThat(flagMapper.getCreationDate(), is("2016-10-22T14:19:13Z"));
+ assertNull(flagMapper.getDescription());
+ assertThat(flagMapper.getModificationDate(), is("2016-10-22T14:19:33Z"));
+ assertThat(flagMapper.getName(), is("BugFlag1"));
+ assertThat(flagMapper.getNumber(), is(11));
+ assertNull(flagMapper.getRequestee());
+ assertThat(flagMapper.getSetter(), is("tests@mylyn.eclipse.org"));
+ assertThat(flagMapper.getState(), is("-"));
+ assertThat(flagMapper.getTypeId(), is(1));
+ }
+
+ @Test
+ public void testReadFromJson1() throws IOException {
+ String jsonElement = IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag1.json"));
+
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(jsonElement, BugzillaRestFlagMapper.class);
+ assertThat(flagMapper.getCreationDate(), is("2016-10-22T14:19:13Z"));
+ assertThat(flagMapper.getDescription(), is("Description of FlagType 1"));
+ assertThat(flagMapper.getModificationDate(), is("2016-10-22T14:19:33Z"));
+ assertThat(flagMapper.getName(), is("BugFlag1"));
+ assertThat(flagMapper.getNumber(), is(11));
+ assertThat(flagMapper.getRequestee(), is("admin@mylyn.eclipse.org"));
+ assertThat(flagMapper.getSetter(), is("tests@mylyn.eclipse.org"));
+ assertThat(flagMapper.getState(), is("?"));
+ assertThat(flagMapper.getTypeId(), is(1));
+ }
+
+ @Test
+ public void testWrite2Json() throws IOException {
+ BugzillaRestFlagMapper flagMapper = new BugzillaRestFlagMapper();
+ flagMapper.setCreationDate("2016-10-22T14:19:13Z");
+ flagMapper.setDescription(null);
+ flagMapper.setModificationDate("2016-10-22T14:19:33Z");
+ flagMapper.setName("BugFlag1");
+ flagMapper.setNumber(11);
+ flagMapper.setRequestee(null);
+ flagMapper.setSetter("tests@mylyn.eclipse.org");
+ flagMapper.setState("-");
+ flagMapper.setTypeId(1);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag.json")),
+ new Gson().toJson(flagMapper));
+ }
+
+ @Test
+ public void testWrite2Json1() throws IOException {
+ BugzillaRestFlagMapper flagMapper = new BugzillaRestFlagMapper();
+ flagMapper.setCreationDate("2016-10-22T14:19:13Z");
+ flagMapper.setDescription("Description of FlagType 1");
+ flagMapper.setModificationDate("2016-10-22T14:19:33Z");
+ flagMapper.setName("BugFlag1");
+ flagMapper.setNumber(11);
+ flagMapper.setRequestee("admin@mylyn.eclipse.org");
+ flagMapper.setSetter("tests@mylyn.eclipse.org");
+ flagMapper.setState("?");
+ flagMapper.setTypeId(1);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag1.json")),
+ new Gson().toJson(flagMapper));
+ }
+
+ @Test
+ public void testApplyToTaskAttribute() throws IOException {
+ String jsonElement = IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag.json"));
+
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(jsonElement, BugzillaRestFlagMapper.class);
+ TaskAttribute taskAttribute = mockTestData.getRoot()
+ .createAttribute(IBugzillaRestConstants.KIND_FLAG_TYPE + "11");
+ flagMapper.applyTo(taskAttribute);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag.txt")), taskAttribute.toString());
+ }
+
+ @Test
+ public void testApplyToTaskAttribute1() throws IOException {
+ String jsonElement = IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag1.json"));
+
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(jsonElement, BugzillaRestFlagMapper.class);
+ TaskAttribute taskAttribute = mockTestData.getRoot()
+ .createAttribute(IBugzillaRestConstants.KIND_FLAG_TYPE + "11");
+ flagMapper.applyTo(taskAttribute);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag1.txt")),
+ taskAttribute.toString());
+ }
+
+ @Test
+ public void testCreateFromTaskAttribute() throws IOException {
+ String jsonElement = IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag.json"));
+
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(jsonElement, BugzillaRestFlagMapper.class);
+ TaskAttribute taskAttribute = mockTestData.getRoot()
+ .createAttribute(IBugzillaRestConstants.KIND_FLAG_TYPE + "11");
+ flagMapper.applyTo(taskAttribute);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag.txt")), taskAttribute.toString());
+
+ flagMapper = BugzillaRestFlagMapper.createFrom(taskAttribute);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag.json")),
+ new Gson().toJson(flagMapper));
+ }
+
+ @Test
+ public void testCreateFromTaskAttribute1() throws IOException {
+ String jsonElement = IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag1.json"));
+
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(jsonElement, BugzillaRestFlagMapper.class);
+ TaskAttribute taskAttribute = mockTestData.getRoot()
+ .createAttribute(IBugzillaRestConstants.KIND_FLAG_TYPE + "11");
+ flagMapper.applyTo(taskAttribute);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag1.txt")),
+ taskAttribute.toString());
+
+ flagMapper = BugzillaRestFlagMapper.createFrom(taskAttribute);
+ assertEquals(IOUtils.toString(CommonTestUtil.getResource(this, "testdata/flag1.json")),
+ new Gson().toJson(flagMapper));
+ }
+
+}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskDataFlags.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskDataFlags.txt
new file mode 100644
index 000000000..cdce1232c
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskDataFlags.txt
@@ -0,0 +1,17 @@
+[TaskAttribute[id=task.common.kind.flag_type1,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=1, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=1}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag1}]
+ TaskAttribute[id=typeId,values=[1],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}], TaskAttribute[id=task.common.kind.flag_type2,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=2, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=2}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, ?=?, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag2}]
+ TaskAttribute[id=typeId,values=[2],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}], TaskAttribute[id=task.common.kind.flag_type5,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=3, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=3}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, ?=?, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag3}]
+ TaskAttribute[id=typeId,values=[5],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}], TaskAttribute[id=task.common.kind.flag_type6,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=4, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=4}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, ?=?, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag4}]
+ TaskAttribute[id=typeId,values=[6],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}]] \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskDataFlags.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskDataFlags.txt
new file mode 100644
index 000000000..cdce1232c
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskDataFlags.txt
@@ -0,0 +1,17 @@
+[TaskAttribute[id=task.common.kind.flag_type1,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=1, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=1}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag1}]
+ TaskAttribute[id=typeId,values=[1],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}], TaskAttribute[id=task.common.kind.flag_type2,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=2, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=2}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, ?=?, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag2}]
+ TaskAttribute[id=typeId,values=[2],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}], TaskAttribute[id=task.common.kind.flag_type5,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=3, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=3}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, ?=?, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag3}]
+ TaskAttribute[id=typeId,values=[5],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}], TaskAttribute[id=task.common.kind.flag_type6,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=4, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state, task.meta.description=4}]
+ TaskAttribute[id=requestee,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[ ],options={=, ?=?, -=-, +=+},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag4}]
+ TaskAttribute[id=typeId,values=[6],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}]] \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.json b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.json
new file mode 100644
index 000000000..5ad9b7b7e
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.json
@@ -0,0 +1 @@
+{"setter":"tests@mylyn.eclipse.org","status":"-","name":"BugFlag1","id":11,"type_id":1,"creation_date":"2016-10-22T14:19:13Z","modification_date":"2016-10-22T14:19:33Z"} \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.txt
new file mode 100644
index 000000000..e91e9612d
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag.txt
@@ -0,0 +1,7 @@
+TaskAttribute[id=task.common.kind.flag_type11,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state}]
+ TaskAttribute[id=number,values=[11],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[tests@mylyn.eclipse.org],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[-],options=null,metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag1}]
+ TaskAttribute[id=typeId,values=[1],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}]
+ TaskAttribute[id=creationDate,values=[2016-10-22T14:19:13Z],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=modificationDate,values=[2016-10-22T14:19:33Z],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}] \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.json b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.json
new file mode 100644
index 000000000..15baf08ef
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.json
@@ -0,0 +1 @@
+{"requestee":"admin@mylyn.eclipse.org","setter":"tests@mylyn.eclipse.org","status":"?","name":"BugFlag1","id":11,"description":"Description of FlagType 1","type_id":1,"creation_date":"2016-10-22T14:19:13Z","modification_date":"2016-10-22T14:19:33Z"} \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.txt
new file mode 100644
index 000000000..2cedd2f2d
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/flag1.txt
@@ -0,0 +1,8 @@
+TaskAttribute[id=task.common.kind.flag_type11,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=bugzilla.editor.flag, task.meta.required=false, task.meta.label=Description of FlagType 1, task.meta.attributeKind=task.common.kind.flag, task.meta.associated.attribute=state}]
+ TaskAttribute[id=number,values=[11],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}]
+ TaskAttribute[id=requestee,values=[admin@mylyn.eclipse.org],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=setter,values=[tests@mylyn.eclipse.org],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=state,values=[?],options=null,metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=false, task.meta.label=BugFlag1}]
+ TaskAttribute[id=typeId,values=[1],options=null,metaData={task.meta.readOnly=true, task.meta.type=integer, task.meta.required=false}]
+ TaskAttribute[id=creationDate,values=[2016-10-22T14:19:13Z],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}]
+ TaskAttribute[id=modificationDate,values=[2016-10-22T14:19:33Z],options=null,metaData={task.meta.readOnly=true, task.meta.type=shortText, task.meta.required=false}] \ 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/BugzillaRestAttachmentMapper.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java
index 1a8cb3070..36d0c6fd1 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java
@@ -164,4 +164,11 @@ public class BugzillaRestAttachmentMapper extends TaskAttachmentMapper {
this.deltaDate = deltaDate;
}
+ public void addMissingFlags(TaskAttribute taskAttribute) {
+ Assert.isNotNull(taskAttribute);
+ TaskData taskData = taskAttribute.getTaskData();
+ BugzillaRestTaskAttributeMapper mapper = (BugzillaRestTaskAttributeMapper) taskData.getAttributeMapper();
+ mapper.updateNewAttachmentAttribute(taskAttribute);
+ }
+
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java
index 001dc545c..a3fc737d0 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java
@@ -199,6 +199,7 @@ public class BugzillaRestClient {
new BugzillaRestGetTaskAttachments(getClient(), taskData).run(monitor);
config.updateProductOptions(taskData);
config.addValidOperations(taskData);
+ config.updateFlags(taskData);
collector.accept(taskData);
}
} catch (RuntimeException e) {
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 49c3f7842..85156437b 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,6 +12,8 @@
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 java.util.SortedSet;
import java.util.TreeSet;
@@ -24,6 +26,8 @@ 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.FlagType;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.FlagTypes;
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;
@@ -105,13 +109,8 @@ 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;
+ private Component getProductComponentWithName(@NonNull Product product, String name) {
+ return product.getComponentWithName(name);
}
public void updateInitialTaskData(TaskData data) throws CoreException {
@@ -305,38 +304,11 @@ public class BugzillaRestConfiguration implements Serializable {
}
}
- public boolean updateAfterComponentChange(TaskAttribute taskAttribute) {
- if (taskAttribute != null) {
- if (taskAttribute.getId().equals(SCHEMA.COMPONENT.getKey())) {
- TaskAttribute rootAttribute = taskAttribute.getTaskData().getRoot();
- TaskAttribute productAttribute = taskAttribute.getTaskData()
- .getRoot()
- .getMappedAttribute(SCHEMA.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(SCHEMA.QA_CONTACT.getKey());
- if (attributeQaContact != null) {
- attributeQaContact.setValue(actualComponent.getDefaultQaContact());
- }
- TaskAttribute attributeAssignedTo = rootAttribute.getMappedAttribute(SCHEMA.ASSIGNED_TO.getKey());
- if (attributeAssignedTo != null) {
- attributeAssignedTo.setValue(actualComponent.getDefaultAssignedTo());
- }
- }
- }
- return true;
- }
- return false;
- }
-
public boolean setProductOptions(@NonNull TaskData taskData) {
TaskAttribute attributeProduct = taskData.getRoot().getMappedAttribute(SCHEMA.PRODUCT.getKey());
if (attributeProduct != null) {
SortedSet<String> products = new TreeSet<String>();
- Field configFieldComponent = getFieldWithName("component");
+ Field configFieldComponent = getFieldWithName("component"); //$NON-NLS-1$
FieldValues[] val = configFieldComponent.getValues();
if (val != null && val.length > 0) {
for (FieldValues fieldValues : val) {
@@ -465,4 +437,118 @@ public class BugzillaRestConfiguration implements Serializable {
attrResolvedInput.getMetaData().setType(TaskAttribute.TYPE_TASK_DEPENDENCY);
attribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID, attrResolvedInput.getId());
}
+
+ public boolean updateFlags(@NonNull TaskData taskData) {
+ List<String> existingFlags = new ArrayList<String>();
+ TaskAttribute attributeProduct = taskData.getRoot().getMappedAttribute(SCHEMA.PRODUCT.getKey());
+ TaskAttribute attributeComponent = taskData.getRoot().getMappedAttribute(SCHEMA.COMPONENT.getKey());
+ Product actualProduct = getProductWithName(attributeProduct.getValue());
+ Component actualComponent = getProductComponentWithName(actualProduct, attributeComponent.getValue());
+ FlagTypes flagTypes = actualComponent.getFlagTypes();
+
+ for (TaskAttribute attribute : taskData.getRoot().getAttributes().values()) {
+ if (attribute.getId().startsWith(TaskAttribute.PREFIX_ATTACHMENT)
+ || attribute.getId().equals(TaskAttribute.NEW_ATTACHMENT)) {
+ List<String> existingAttachmentFlags = new ArrayList<String>();
+ for (TaskAttribute attachmentAttribute : attribute.getAttributes().values()) {
+ updateFlag(flagTypes.getAttachment(), existingAttachmentFlags, attachmentAttribute);
+ }
+ addMissingFlagsInternal(attribute, flagTypes.getAttachment(), existingAttachmentFlags);
+ } else {
+ updateFlag(flagTypes.getBug(), existingFlags, attribute);
+ }
+ }
+ addMissingFlagsInternal(taskData.getRoot(), flagTypes.getBug(), existingFlags);
+
+ return false;
+ }
+
+ private void updateFlag(FlagType[] flagTypes, List<String> existingAttachmentFlags, TaskAttribute flagAttribute) {
+ if (flagAttribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
+ TaskAttribute stateAttribute = flagAttribute.getAttribute("state"); //$NON-NLS-1$))
+ stateAttribute.putOption("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ String flagName = stateAttribute.getMetaData().getLabel();
+ if (!existingAttachmentFlags.contains(flagName)) {
+ existingAttachmentFlags.add(flagName);
+ }
+ for (FlagType flagType : flagTypes) {
+ if (flagType.getName().equals(flagName)) {
+ if (flagType.isRequestable()) {
+ stateAttribute.putOption("?", "?"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ updateRequestee(flagAttribute, flagType);
+ break;
+ }
+ }
+ stateAttribute.putOption("-", "-"); //$NON-NLS-1$ //$NON-NLS-2$
+ stateAttribute.putOption("+", "+"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void addMissingFlags(TaskData taskData) {
+ List<String> existingFlags = new ArrayList<String>();
+ TaskAttribute attributeProduct = taskData.getRoot().getMappedAttribute(SCHEMA.PRODUCT.getKey());
+ TaskAttribute attributeComponent = taskData.getRoot().getMappedAttribute(SCHEMA.COMPONENT.getKey());
+ if (attributeProduct.getValue().equals("") || attributeComponent.getValue().equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+ Product actualProduct = getProductWithName(attributeProduct.getValue());
+ Component actualComponent = getProductComponentWithName(actualProduct, attributeComponent.getValue());
+ FlagTypes flagTypes = actualComponent.getFlagTypes();
+ addMissingFlagsInternal(taskData.getRoot(), flagTypes.getBug(), existingFlags);
+ }
+
+ private void addMissingFlagsInternal(TaskAttribute rootTaskAttribute, FlagType[] flagTypes,
+ List<String> existingFlags) {
+ for (FlagType flagType : flagTypes) {
+ if (existingFlags.contains(flagType.getName()) && !flagType.isMultiplicable()) {
+ continue;
+ }
+ BugzillaRestFlagMapper mapper = new BugzillaRestFlagMapper();
+ mapper.setRequestee(""); //$NON-NLS-1$
+ mapper.setSetter(""); //$NON-NLS-1$
+ mapper.setState(" "); //$NON-NLS-1$
+ mapper.setName(flagType.getName());
+ mapper.setNumber(0);
+ mapper.setDescription(flagType.getDescription());
+ mapper.setTypeId(flagType.getId());
+ TaskAttribute attribute = rootTaskAttribute
+ .createAttribute(IBugzillaRestConstants.KIND_FLAG_TYPE + flagType.getId());
+ mapper.applyTo(attribute);
+ TaskAttribute stateAttribute = attribute.getAttribute("state"); //$NON-NLS-1$))
+ stateAttribute.putOption("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ if (flagType.isRequestable()) {
+ stateAttribute.putOption("?", "?"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ updateRequestee(attribute, flagType);
+ attribute.getMetaData().putValue(TaskAttribute.META_DESCRIPTION, flagType.getDescription());
+ stateAttribute.putOption("-", "-"); //$NON-NLS-1$ //$NON-NLS-2$
+ stateAttribute.putOption("+", "+"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void updateRequestee(TaskAttribute attribute, FlagType flagType) {
+ TaskAttribute requestee = attribute.getAttribute("requestee"); //$NON-NLS-1$
+ if (requestee == null) {
+ requestee = attribute.createMappedAttribute("requestee"); //$NON-NLS-1$
+ requestee.getMetaData().defaults().setType(TaskAttribute.TYPE_PERSON);
+ requestee.setValue(""); //$NON-NLS-1$
+ }
+ requestee.getMetaData().setReadOnly(!flagType.isRequesteeble());
+ }
+
+ public void updateAttachmentFlags(@NonNull TaskAttribute attribute) {
+ TaskAttribute attributeProduct = attribute.getParentAttribute().getMappedAttribute(SCHEMA.PRODUCT.getKey());
+ TaskAttribute attributeComponent = attribute.getParentAttribute().getMappedAttribute(SCHEMA.COMPONENT.getKey());
+ Product actualProduct = getProductWithName(attributeProduct.getValue());
+ Component actualComponent = getProductComponentWithName(actualProduct, attributeComponent.getValue());
+ FlagTypes flagTypes = actualComponent.getFlagTypes();
+
+ List<String> existingAttachmentFlags = new ArrayList<String>();
+ for (TaskAttribute attachmentAttribute : attribute.getAttributes().values()) {
+ updateFlag(flagTypes.getAttachment(), existingAttachmentFlags, attachmentAttribute);
+ }
+ addMissingFlagsInternal(attribute, flagTypes.getAttachment(), existingAttachmentFlags);
+ }
+
} \ 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/BugzillaRestFlagMapper.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestFlagMapper.java
new file mode 100644
index 000000000..13718e592
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestFlagMapper.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.io.IOException;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+import com.google.gson.annotations.SerializedName;
+import com.google.gson.stream.JsonWriter;
+
+public class BugzillaRestFlagMapper {
+
+ private String requestee;
+
+ private String setter;
+
+ @SerializedName("status")
+ private String state;
+
+ private String name;
+
+ @SerializedName("id")
+ private int number;
+
+ private String description;
+
+ @SerializedName("type_id")
+ private int typeId;
+
+ @SerializedName("creation_date")
+ private String creationDate;
+
+ @SerializedName("modification_date")
+ private String modificationDate;
+
+ public BugzillaRestFlagMapper() {
+ }
+
+ public String getRequestee() {
+ return requestee;
+ }
+
+ public void setRequestee(String requestee) {
+ this.requestee = requestee;
+ }
+
+ public String getSetter() {
+ return setter;
+ }
+
+ public void setSetter(String setter) {
+ this.setter = setter;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(int typeId) {
+ this.typeId = typeId;
+ }
+
+ public String getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(String creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getModificationDate() {
+ return modificationDate;
+ }
+
+ public void setModificationDate(String modificationDate) {
+ this.modificationDate = modificationDate;
+ }
+
+ public void applyTo(TaskAttribute taskAttribute) {
+ Assert.isNotNull(taskAttribute);
+ TaskData taskData = taskAttribute.getTaskData();
+ TaskAttributeMapper mapper = taskData.getAttributeMapper();
+ TaskAttributeMetaData meta = taskAttribute.getMetaData().defaults();
+ meta.setType(IBugzillaRestConstants.EDITOR_TYPE_FLAG);
+ meta.setLabel(getDescription());
+ meta.setKind(IBugzillaRestConstants.KIND_FLAG);
+ meta.setReadOnly(false);
+
+ if (getNumber() != 0) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("number"); //$NON-NLS-1$
+ child.getMetaData().defaults().setType(TaskAttribute.TYPE_INTEGER);
+ mapper.setIntegerValue(child, getNumber());
+ }
+ if (getRequestee() != null) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("requestee"); //$NON-NLS-1$
+ child.getMetaData().defaults().setType(TaskAttribute.TYPE_SHORT_TEXT);
+ mapper.setValue(child, getRequestee());
+ }
+ if (getSetter() != null) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("setter"); //$NON-NLS-1$
+ child.getMetaData().defaults().setType(TaskAttribute.TYPE_SHORT_TEXT);
+ mapper.setValue(child, getSetter());
+ }
+ if (getState() != null) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("state"); //$NON-NLS-1$
+ child.getMetaData().defaults().setType(TaskAttribute.TYPE_SINGLE_SELECT);
+ child.getMetaData().setLabel(getName());
+ child.getMetaData().setReadOnly(false);
+ mapper.setValue(child, getState());
+ taskAttribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID, "state"); //$NON-NLS-1$
+ }
+ if (getTypeId() != 0) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("typeId"); //$NON-NLS-1$
+ child.getMetaData().defaults().setType(TaskAttribute.TYPE_INTEGER);
+ mapper.setIntegerValue(child, getTypeId());
+ }
+ if (getCreationDate() != null) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("creationDate"); //$NON-NLS-1$
+ child.getMetaData().defaults().setType(TaskAttribute.TYPE_SHORT_TEXT);
+ mapper.setValue(child, getCreationDate());
+ }
+ if (getModificationDate() != null) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("modificationDate"); //$NON-NLS-1$
+ child.getMetaData().defaults().setType(TaskAttribute.TYPE_SHORT_TEXT);
+ mapper.setValue(child, getModificationDate());
+ }
+ }
+
+ public static BugzillaRestFlagMapper createFrom(TaskAttribute taskAttribute) {
+ Assert.isNotNull(taskAttribute);
+ TaskAttributeMapper mapper = taskAttribute.getTaskData().getAttributeMapper();
+ BugzillaRestFlagMapper flag = new BugzillaRestFlagMapper();
+ flag.setDescription(taskAttribute.getMetaData().getLabel());
+ TaskAttribute child = taskAttribute.getMappedAttribute("number");
+ if (child != null) {
+ flag.setNumber(mapper.getIntegerValue(child));
+ }
+ child = taskAttribute.getMappedAttribute("requestee");
+ if (child != null) {
+ flag.setRequestee(mapper.getValue(child));
+ }
+ child = taskAttribute.getMappedAttribute("setter");
+ if (child != null) {
+ flag.setSetter(mapper.getValue(child));
+ }
+ child = taskAttribute.getMappedAttribute("state");
+ if (child != null) {
+ flag.setName(child.getMetaData().getLabel());
+ flag.setState(mapper.getValue(child));
+ }
+ child = taskAttribute.getMappedAttribute("typeId");
+ if (child != null) {
+ flag.setTypeId(mapper.getIntegerValue(child));
+ }
+ child = taskAttribute.getMappedAttribute("creationDate");
+ if (child != null) {
+ flag.setCreationDate(mapper.getValue(child));
+ }
+ child = taskAttribute.getMappedAttribute("modificationDate");
+ if (child != null) {
+ flag.setModificationDate(mapper.getValue(child));
+ }
+
+ return flag;
+ }
+
+ public void applyTo(JsonWriter out) throws IOException {
+ out.beginObject();
+ if (getNumber() != 0) {
+ out.name("id").value(getNumber());
+ } else {
+ out.name("name").value(getName());
+ out.name("new").value(true);
+ }
+ out.name("status").value(StringUtils.defaultIfBlank(getState(), "X"));
+ out.name("requestee").value(getRequestee());
+ out.endObject();
+ }
+}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java
index 7afeeacd7..fce79265f 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java
@@ -29,7 +29,9 @@ import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
+import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
@@ -100,6 +102,17 @@ public class BugzillaRestGetTaskAttachments extends BugzillaRestGetRequest<Array
attachmentMapper
.setPatch(attachmentObject.get("is_patch").getAsString().equals(Integer.valueOf(1))); //$NON-NLS-1$
attachmentMapper.applyTo(attachmentAttribute);
+ JsonArray flags = attachmentObject.get("flags").getAsJsonArray(); //$NON-NLS-1$
+ if (flags.size() > 0) {
+ for (JsonElement flagTmp : flags) {
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(flagTmp,
+ BugzillaRestFlagMapper.class);
+ TaskAttribute attribute = attachmentAttribute
+ .createAttribute(IBugzillaRestConstants.KIND_FLAG + flagMapper.getNumber());
+ flagMapper.applyTo(attribute);
+ }
+ }
+ attachmentMapper.addMissingFlags(attachmentAttribute);
}
}
return response;
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskData.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskData.java
index e08d4774d..0e2884f63 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskData.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskData.java
@@ -38,6 +38,7 @@ import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.osgi.util.NLS;
+import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
@@ -150,6 +151,17 @@ public class BugzillaRestGetTaskData extends BugzillaRestGetRequest<List<TaskDat
"Can not parse Date (" + value.getAsString() + ")"))); //$NON-NLS-1$ //$NON-NLS-2$
}
}
+ } else if (entry.getKey().equals("flags")) { //$NON-NLS-1$
+ JsonArray array = entry.getValue().getAsJsonArray();
+ if (!array.isJsonNull()) {
+ for (JsonElement jsonElement : array) {
+ BugzillaRestFlagMapper flagMapper = new Gson().fromJson(jsonElement,
+ BugzillaRestFlagMapper.class);
+ TaskAttribute attribute = taskData.getRoot()
+ .createAttribute(IBugzillaRestConstants.KIND_FLAG + flagMapper.getNumber());
+ flagMapper.applyTo(attribute);
+ }
+ }
}
TaskAttribute attribute = taskData.getRoot().getAttribute(attributeId);
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
index 6d6b0459e..b6dc5ded6 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
@@ -17,6 +17,8 @@ import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
@@ -151,4 +153,25 @@ public class BugzillaRestGsonUtil {
gson.toJson(test, RemoveAddIntegerHelper.class, out);
}
+ public static void buildFlags(JsonWriter out, Set<TaskAttribute> oldAttributes, TaskAttribute rootTaskData)
+ throws IOException {
+ boolean flagFound = false;
+ for (TaskAttribute element : oldAttributes) {
+ TaskAttribute taskAttribute = rootTaskData.getAttribute(element.getId());
+ String id = taskAttribute.getId();
+ if (id.startsWith(IBugzillaRestConstants.KIND_FLAG)
+ || id.startsWith(IBugzillaRestConstants.KIND_FLAG_TYPE)) {
+ if (!flagFound) {
+ out.name("flags").beginArray(); //$NON-NLS-1$
+ }
+ BugzillaRestFlagMapper flagMapper = BugzillaRestFlagMapper.createFrom(taskAttribute);
+ flagMapper.applyTo(out);
+ flagFound = true;
+ }
+ }
+ if (flagFound) {
+ out.endArray();
+ }
+ }
+
} \ 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/BugzillaRestPostNewAttachment.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java
index 1eaa1c7e4..893dca566 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java
@@ -17,7 +17,9 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.HttpURLConnection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
@@ -135,6 +137,15 @@ public class BugzillaRestPostNewAttachment extends BugzillaRestPostRequest<Bugzi
out.name("data").value(dataBase64); //$NON-NLS-1$
out.name("file_name").value(filename); //$NON-NLS-1$
out.name("is_private").value(false); //$NON-NLS-1$
+ if (attachmentAttribute != null) {
+ attachmentAttribute.getAttributes().values();
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ for (TaskAttribute taskAttribute : attachmentAttribute.getAttributes().values()) {
+ changed.add(taskAttribute);
+ }
+
+ BugzillaRestGsonUtil.buildFlags(out, changed, attachmentAttribute);
+ }
out.endObject();
out.close();
StringEntity requestEntity = new StringEntity(stringWriter.toString());
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
index 9e394ae61..bda2e8d90 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
@@ -195,6 +195,7 @@ public class BugzillaRestPutUpdateTask extends BugzillaRestPutRequest<PutUpdateR
HashSet<String> setNew = new HashSet<String>(Arrays.asList(addCC.getValue().split("\\s*,\\s*"))); //$NON-NLS-1$
BugzillaRestGsonUtil.getDefault().buildAddRemoveHash(out, "cc", setOld, setNew); //$NON-NLS-1$
}
+ BugzillaRestGsonUtil.buildFlags(out, oldValues.oldAttributes, taskData.getRoot());
out.endObject();
}
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
index 6b899dc42..1357a1df3 100644
--- 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
@@ -15,6 +15,7 @@ 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.jdt.annotation.NonNull;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Product;
@@ -88,4 +89,25 @@ public class BugzillaRestTaskAttributeMapper extends TaskAttributeMapper {
}
}
+ @Override
+ public String mapToRepositoryKey(@NonNull TaskAttribute parent, @NonNull String key) {
+ if (key.equals(TaskAttribute.TASK_KEY)) {
+ return BugzillaRestTaskSchema.getDefault().BUG_ID.getKey();
+ } else {
+ return super.mapToRepositoryKey(parent, key);
+ }
+ }
+
+ public void updateNewAttachmentAttribute(TaskAttribute attachmentAttribute) {
+ BugzillaRestConfiguration repositoryConfiguration;
+ try {
+ repositoryConfiguration = connector.getRepositoryConfiguration(this.getTaskRepository());
+ repositoryConfiguration.updateAttachmentFlags(attachmentAttribute);
+ } catch (CoreException e) {
+ StatusHandler.log(
+ new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, "Eerror in updateNewAttachmentAttribute", e)); //$NON-NLS-1$
+ }
+
+ }
+
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java
index 91e331241..f7534778c 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java
@@ -22,4 +22,9 @@ public interface IBugzillaRestConstants {
public static final String REPOSITORY_API_KEY = "bugzilla.rest.apikey"; //$NON-NLS-1$
+ public static final String KIND_FLAG = "task.common.kind.flag"; //$NON-NLS-1$
+
+ public static final String KIND_FLAG_TYPE = "task.common.kind.flag_type"; //$NON-NLS-1$
+
+ public static final String EDITOR_TYPE_FLAG = "bugzilla.editor.flag"; //$NON-NLS-1$
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Product.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Product.java
index d87f4269b..83322794b 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Product.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Product.java
@@ -73,4 +73,13 @@ public class Product implements Named {
return milestones;
}
+ public Component getComponentWithName(String name) {
+ for (Component componentEntry : getComponents()) {
+ if (componentEntry.getName().equals(name)) {
+ return componentEntry;
+ }
+ }
+ return null;
+ }
+
}

Back to the top