Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2015-08-26 16:13:58 +0000
committerAngel Avila2015-09-12 01:05:33 +0000
commitd38b497340bc98f195282ac75e81c9caec1984e3 (patch)
treeb2fc09e914b3b8d13a2564a4b6fff29fffa31869
parent2a815eda4fba0fc9beed1dc6805a2399cdeac4ae (diff)
downloadorg.eclipse.osee-d38b497340bc98f195282ac75e81c9caec1984e3.tar.gz
org.eclipse.osee-d38b497340bc98f195282ac75e81c9caec1984e3.tar.xz
org.eclipse.osee-d38b497340bc98f195282ac75e81c9caec1984e3.zip
feature[ats_ATS217737]: TC - 1. Add work def and attr to server tasks
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/AbstractAtsTaskService.java17
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/IAtsTaskService.java7
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAtsTask.java38
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAttribute.java50
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java3
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsDeleteManagerTest.java2
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTaskEndpointImplTest.java38
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DemoTestUtil.java3
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/task/AtsTaskService.java3
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java7
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java14
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/IAtsActionFactory.java3
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java8
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsTaskService.java7
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/workitem/CreateTasksOperation.java64
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java3
16 files changed, 224 insertions, 43 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/AbstractAtsTaskService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/AbstractAtsTaskService.java
index 88fdd794a2c..48be45d9144 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/AbstractAtsTaskService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/AbstractAtsTaskService.java
@@ -8,6 +8,8 @@ package org.eclipse.osee.ats.api.task;
import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.workflow.IAtsTask;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
@@ -21,13 +23,14 @@ public abstract class AbstractAtsTaskService implements IAtsTaskService {
}
@Override
- public Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String commitComment) {
- NewTaskData newTaskData = getNewTaskData(teamWf, titles, assignees, createdDate, createdBy, relatedToState);
+ public Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String taskWorkDef, Map<String, List<String>> attributes, String commitComment) {
+ NewTaskData newTaskData =
+ getNewTaskData(teamWf, titles, assignees, createdDate, createdBy, relatedToState, taskWorkDef, attributes);
return createTasks(newTaskData);
}
@Override
- public NewTaskData getNewTaskData(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState) {
+ public NewTaskData getNewTaskData(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String taskWorkDef, Map<String, List<String>> attributes) {
NewTaskData newTaskData = new NewTaskData();
newTaskData.setCommitComment("Import Tasks from Simple List");
newTaskData.setAsUserId(createdBy.getUserId());
@@ -51,7 +54,15 @@ public abstract class AbstractAtsTaskService implements IAtsTaskService {
}
task.setCreatedByUserId(createdBy.getUserId());
task.setCreatedDate(createdDate);
+ if (Strings.isValid(taskWorkDef)) {
+ task.setTaskWorkDef(taskWorkDef);
+ }
newTaskData.getNewTasks().add(task);
+ if (attributes != null) {
+ for (Entry<String, List<String>> entry : attributes.entrySet()) {
+ task.addAttributes(entry.getKey(), entry.getValue());
+ }
+ }
}
return newTaskData;
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/IAtsTaskService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/IAtsTaskService.java
index 12da1600c63..997c362419b 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/IAtsTaskService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/IAtsTaskService.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.ats.api.task;
import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.workflow.IAtsTask;
@@ -23,12 +24,12 @@ import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
*/
public interface IAtsTaskService {
- Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String commitComment);
+ Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String taskWorkDef, Map<String, List<String>> attributes, String commitComment);
Collection<IAtsTask> createTasks(NewTaskData newTaskData);
- Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, IAtsChangeSet changes);
+ Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String taskWorkDef, IAtsChangeSet changes, Map<String, List<String>> attributes);
- NewTaskData getNewTaskData(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState);
+ NewTaskData getNewTaskData(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String taskWorkDef, Map<String, List<String>> attributes);
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAtsTask.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAtsTask.java
index 35f9131be80..44dae70420f 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAtsTask.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAtsTask.java
@@ -10,11 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.ats.api.task;
+import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.osee.ats.api.config.JaxAtsObject;
@@ -28,10 +27,11 @@ public class JaxAtsTask extends JaxAtsObject {
private Date createdDate;
private String createdByUserId;
private String relatedToState;
- Map<String, Object> attrTypeToObject;
+ private String taskWorkDef;
+ List<JaxAttribute> attributes;
public JaxAtsTask() {
- attrTypeToObject = new HashMap<>();
+ attributes = new ArrayList<>();
}
public Date getCreatedDate() {
@@ -71,12 +71,34 @@ public class JaxAtsTask extends JaxAtsObject {
this.assigneeUserIds = assigneeUserIds;
}
- public Map<String, Object> getAttrTypeToObject() {
- return attrTypeToObject;
+ public String getTaskWorkDef() {
+ return taskWorkDef;
}
- public void setAttrTypeToObject(Map<String, Object> attrTypeToObject) {
- this.attrTypeToObject = attrTypeToObject;
+ public void setTaskWorkDef(String taskWorkDef) {
+ this.taskWorkDef = taskWorkDef;
+ }
+
+ public List<JaxAttribute> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(List<JaxAttribute> attributes) {
+ this.attributes = attributes;
+ }
+
+ public void addAttributes(String attrTypeName, List<String> values) {
+ JaxAttribute attr = new JaxAttribute();
+ attr.setAttrTypeName(attrTypeName);
+ attr.getValues().addAll(values);
+ attributes.add(attr);
+ }
+
+ public void addAttribute(String attrTypeName, String value) {
+ JaxAttribute attr = new JaxAttribute();
+ attr.setAttrTypeName(attrTypeName);
+ attr.getValues().add(value);
+ attributes.add(attr);
}
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAttribute.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAttribute.java
new file mode 100644
index 00000000000..e831e78f92a
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/task/JaxAttribute.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.api.task;
+
+import java.util.LinkedList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class JaxAttribute {
+
+ private String attrTypeName;
+ private List<String> values;
+
+ public String getAttrTypeName() {
+ return attrTypeName;
+ }
+
+ public void setAttrTypeName(String attrTypeName) {
+ this.attrTypeName = attrTypeName;
+ }
+
+ public List<String> getValues() {
+ if (values == null) {
+ values = new LinkedList<>();
+ }
+ return values;
+ }
+
+ public void setValues(List<String> values) {
+ this.values = values;
+ }
+
+ @Override
+ public String toString() {
+ return "JaxAttribute [attrTypeName=" + attrTypeName + ", values=" + values + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java
index dc27d64c711..5ef81749ab1 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.ats.api.util;
import java.util.Collection;
+import java.util.List;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.notify.AtsNotificationCollector;
@@ -85,4 +86,6 @@ public interface IAtsChangeSet {
void deleteArtifact(IAtsWorkItem workItem);
+ void setValues(IAtsObject atsObject, IAttributeType attrType, List<String> values);
+
}
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsDeleteManagerTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsDeleteManagerTest.java
index 22197ed872d..3bd774cb5da 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsDeleteManagerTest.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsDeleteManagerTest.java
@@ -206,7 +206,7 @@ public class AtsDeleteManagerTest {
AtsClientService.get().getTaskService().createTasks(teamArt,
Arrays.asList(testName.name() + " Task 1", testName.name() + " Task 2"), (List<IAtsUser>) null, createdDate,
- createdBy, null, getClass().getSimpleName());
+ createdBy, null, null, null, getClass().getSimpleName());
return teamArt;
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTaskEndpointImplTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTaskEndpointImplTest.java
index 60c542b0d54..f649da447c2 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTaskEndpointImplTest.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTaskEndpointImplTest.java
@@ -14,10 +14,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import java.util.Map.Entry;
import javax.ws.rs.core.Response;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.task.AtsTaskEndpointApi;
import org.eclipse.osee.ats.api.task.JaxAtsTask;
+import org.eclipse.osee.ats.api.task.JaxAttribute;
import org.eclipse.osee.ats.api.task.NewTaskData;
import org.eclipse.osee.ats.client.demo.DemoUsers;
import org.eclipse.osee.ats.client.demo.DemoUtil;
@@ -68,6 +69,7 @@ public class AtsTaskEndpointImplTest {
data.setTeamWfUuid(codeTeamWfUuid);
JaxAtsTask task = createJaxAtsTask(taskUuid1, "Task 1", "description", createdByUserId, createdDate, null);
+ task.setTaskWorkDef("WorkDef_Task_Default");
data.getNewTasks().add(task);
JaxAtsTask task2 = createJaxAtsTask(taskUuid2, "Task 2", "description", createdByUserId, createdDate, null);
@@ -75,7 +77,7 @@ public class AtsTaskEndpointImplTest {
JaxAtsTask task3 = createJaxAtsTask(taskUuid3, "Task 3", null, createdByUserId, createdDate,
Arrays.asList(DemoUsers.Alex_Kay.getUserId()));
- task3.getAttrTypeToObject().put(CoreAttributeTypes.StaticId.getName(), "my static id");
+ task3.addAttribute(CoreAttributeTypes.StaticId.getName(), "my static id");
data.getNewTasks().add(task3);
Response response = taskEp.create(data);
@@ -94,6 +96,19 @@ public class AtsTaskEndpointImplTest {
Assert.assertEquals(createdDateStr, taskDateStr);
Assert.assertEquals(1, task1R.getAssigneeUserIds().size());
Assert.assertEquals(AtsCoreUsers.UNASSIGNED_USER.getUserId(), task1R.getAssigneeUserIds().iterator().next());
+ List<JaxAttribute> attributes = task1R.getAttributes();
+ // Work Definition should be set
+ boolean found = false;
+ for (JaxAttribute attr : attributes) {
+ if (attr.getAttrTypeName().equals(AtsAttributeTypes.WorkflowDefinition.getName())) {
+ found = true;
+ Assert.assertEquals("Expected Attribute WorkDefintiion WorkDef_Task_Default", "WorkDef_Task_Default",
+ attr.getValues().iterator().next());
+ }
+ }
+ if (!found) {
+ Assert.fail("Attribute WorkDefintiion wasn't found");
+ }
JaxAtsTask task2R = taskEp.get(taskUuid2).readEntity(JaxAtsTask.class);
Assert.assertNotNull(task2R);
@@ -104,6 +119,15 @@ public class AtsTaskEndpointImplTest {
Assert.assertEquals(true, task2R.isActive());
Assert.assertEquals(1, task2R.getAssigneeUserIds().size());
Assert.assertEquals(AtsCoreUsers.UNASSIGNED_USER.getUserId(), task2R.getAssigneeUserIds().iterator().next());
+ // Work Definition attribute should NOT be set
+ attributes = task2R.getAttributes();
+ found = false;
+ for (JaxAttribute attr : attributes) {
+ if (attr.getAttrTypeName().equals(AtsAttributeTypes.WorkflowDefinition.getName())) {
+ Assert.fail(
+ String.format("WorkDefintiion should not be set but is [%s]", attr.getValues().iterator().next()));
+ }
+ }
JaxAtsTask task3R = taskEp.get(taskUuid3).readEntity(JaxAtsTask.class);
Assert.assertNotNull(task3R);
@@ -113,11 +137,11 @@ public class AtsTaskEndpointImplTest {
Assert.assertEquals("", task3R.getDescription());
Assert.assertEquals(true, task3R.isActive());
Assert.assertEquals(1, task3R.getAssigneeUserIds().size());
- Assert.assertEquals(9, task3R.getAttrTypeToObject().size());
- boolean found = false;
- for (Entry<String, Object> entry : task3R.getAttrTypeToObject().entrySet()) {
- if (entry.getKey().equals(CoreAttributeTypes.StaticId.getName())) {
- Assert.assertEquals("my static id", entry.getValue().toString());
+ Assert.assertEquals(9, task3R.getAttributes().size());
+ found = false;
+ for (JaxAttribute attribute : task3R.getAttributes()) {
+ if (attribute.getAttrTypeName().equals(CoreAttributeTypes.StaticId.getName())) {
+ Assert.assertEquals("my static id", attribute.getValues().iterator().next());
found = true;
break;
}
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DemoTestUtil.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DemoTestUtil.java
index 721c7a011c8..5e449b1e065 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DemoTestUtil.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DemoTestUtil.java
@@ -150,7 +150,8 @@ public class DemoTestUtil {
}
Collection<IAtsTask> createTasks = AtsClientService.get().getTaskService().createTasks(teamArt, names,
Arrays.asList(AtsClientService.get().getUserService().getCurrentUser()), new Date(),
- AtsClientService.get().getUserService().getCurrentUser(), relatedToState, "DemoTestUtil.creatSimpleTasks");
+ AtsClientService.get().getUserService().getCurrentUser(), relatedToState, null, null,
+ "DemoTestUtil.creatSimpleTasks");
return Collections.castAll(createTasks);
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/task/AtsTaskService.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/task/AtsTaskService.java
index 45c461ba773..a0bca3c2fd4 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/task/AtsTaskService.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/task/AtsTaskService.java
@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import javax.ws.rs.core.Response;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.data.AtsRelationTypes;
@@ -104,7 +105,7 @@ public class AtsTaskService extends AbstractAtsTaskService {
}
@Override
- public Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, IAtsChangeSet changes) {
+ public Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String taskWorkDef, IAtsChangeSet changes, Map<String, List<String>> attributes) {
throw new UnsupportedOperationException("Not Supported on Client");
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java
index 391fb19844c..81b45d81812 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java
@@ -303,4 +303,11 @@ public class AtsChangeSet extends AbstractAtsChangeSet {
add(getArtifact(artifact));
}
+ @Override
+ public void setValues(IAtsObject atsObject, IAttributeType attrType, List<String> values) {
+ Artifact artifact = getArtifact(atsObject);
+ artifact.setAttributeValues(attrType, values);
+ add(artifact);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java
index 75f98d4ed75..75431a09108 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java
@@ -34,6 +34,7 @@ import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.util.IAtsUtilService;
import org.eclipse.osee.ats.api.util.ISequenceProvider;
import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
+import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinition;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workdef.IRelationResolver;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
@@ -250,10 +251,21 @@ public class ActionFactory implements IAtsActionFactory {
@Override
public void initializeNewStateMachine(IAtsWorkItem workItem, List<? extends IAtsUser> assignees, Date createdDate, IAtsUser createdBy, IAtsChangeSet changes) throws OseeCoreException {
+ initializeNewStateMachine(workItem, assignees, createdDate, createdBy, null, changes);
+ }
+
+ @Override
+ public void initializeNewStateMachine(IAtsWorkItem workItem, List<? extends IAtsUser> assignees, Date createdDate, IAtsUser createdBy, IAtsWorkDefinition workDefinition, IAtsChangeSet changes) {
Conditions.checkNotNull(createdDate, "createdDate");
Conditions.checkNotNull(createdBy, "createdBy");
Conditions.checkNotNull(changes, "changes");
- IAtsStateDefinition startState = workItem.getWorkDefinition().getStartState();
+ IAtsStateDefinition startState = null;
+ if (workDefinition == null) {
+ startState = workItem.getWorkDefinition().getStartState();
+ } else {
+ startState = workDefinition.getStartState();
+ changes.addAttribute(workItem, AtsAttributeTypes.WorkflowDefinition, workDefinition.getName());
+ }
IAtsStateManager stateManager = stateFactory.getStateManager(workItem);
workItem.setStateManager(stateManager);
StateManagerUtility.initializeStateMachine(workItem.getStateMgr(), startState, assignees,
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/IAtsActionFactory.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/IAtsActionFactory.java
index d1228a8b6b0..4a1cb8b4134 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/IAtsActionFactory.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/IAtsActionFactory.java
@@ -20,6 +20,7 @@ import org.eclipse.osee.ats.api.team.CreateTeamOption;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.util.IAtsChangeSet;
+import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinition;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.api.workflow.INewActionListener;
@@ -49,4 +50,6 @@ public interface IAtsActionFactory {
IAtsAction getAction(IAtsTeamWorkflow teamWf);
+ void initializeNewStateMachine(IAtsWorkItem workItem, List<? extends IAtsUser> assignees, Date createdDate, IAtsUser createdBy, IAtsWorkDefinition workDefinition, IAtsChangeSet changes);
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java
index 44f110298e6..32a6f52d79f 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.ats.impl.internal.util;
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.api.IAtsWorkItem;
@@ -267,4 +268,11 @@ public class AtsChangeSet extends AbstractAtsChangeSet {
add(artifact);
}
+ @Override
+ public void setValues(IAtsObject atsObject, IAttributeType attrType, List<String> values) {
+ ArtifactReadable artifact = getArtifact(atsObject);
+ getTransaction().setAttributesFromValues(artifact, attrType, values);
+ add(artifact);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsTaskService.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsTaskService.java
index 2dab36ed758..672dbd372f2 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsTaskService.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsTaskService.java
@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import org.eclipse.osee.ats.api.task.AbstractAtsTaskService;
import org.eclipse.osee.ats.api.task.JaxAtsTask;
import org.eclipse.osee.ats.api.task.NewTaskData;
@@ -57,9 +58,9 @@ public class AtsTaskService extends AbstractAtsTaskService {
}
@Override
- public Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, IAtsChangeSet changes) {
- NewTaskData tasks =
- atsServer.getTaskService().getNewTaskData(teamWf, titles, assignees, createdDate, createdBy, relatedToState);
+ public Collection<IAtsTask> createTasks(IAtsTeamWorkflow teamWf, List<String> titles, List<IAtsUser> assignees, Date createdDate, IAtsUser createdBy, String relatedToState, String taskWorkDef, IAtsChangeSet changes, Map<String, List<String>> attributes) {
+ NewTaskData tasks = atsServer.getTaskService().getNewTaskData(teamWf, titles, assignees, createdDate, createdBy,
+ relatedToState, taskWorkDef, attributes);
return createTasks(tasks);
}
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/workitem/CreateTasksOperation.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/workitem/CreateTasksOperation.java
index aa37fa003bd..10c77af00b4 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/workitem/CreateTasksOperation.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/workitem/CreateTasksOperation.java
@@ -13,16 +13,18 @@ package org.eclipse.osee.ats.impl.workitem;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.LinkedList;
import java.util.List;
-import java.util.Map.Entry;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.task.JaxAtsTask;
+import org.eclipse.osee.ats.api.task.JaxAttribute;
import org.eclipse.osee.ats.api.task.NewTaskData;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.util.IAtsChangeSet;
+import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinition;
import org.eclipse.osee.ats.api.workflow.IAtsTask;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
@@ -32,7 +34,6 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.util.XResultData;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -124,11 +125,29 @@ public class CreateTasksOperation {
task);
}
- for (Entry<String, Object> entry : task.getAttrTypeToObject().entrySet()) {
- IAttributeType attrType = getAttributeType(atsServer, entry);
+ IAtsWorkDefinition workDefinition = null;
+ if (Strings.isValid(task.getTaskWorkDef())) {
+ try {
+ XResultData rd = new XResultData();
+ workDefinition = atsServer.getWorkDefService().getWorkDef(task.getTaskWorkDef(), rd);
+ if (rd.isErrors()) {
+ resultData.logErrorWithFormat("Error finding Task Work Def [%s]. Exception: %s",
+ task.getTaskWorkDef(), rd.toString());
+ }
+ } catch (Exception ex) {
+ resultData.logErrorWithFormat("Exception finding Task Work Def [%s]. Exception: %s",
+ task.getTaskWorkDef(), ex.getMessage());
+ }
+ if (workDefinition == null) {
+ resultData.logErrorWithFormat("Task Work Def [%s] does not exist", task.getTaskWorkDef());
+ }
+ }
+
+ for (JaxAttribute attribute : task.getAttributes()) {
+ IAttributeType attrType = getAttributeType(atsServer, attribute.getAttrTypeName());
if (attrType == null) {
- resultData.logErrorWithFormat("Attribute Type [%s] not valid for Task creation in %s", entry.getKey(),
- task);
+ resultData.logErrorWithFormat("Attribute Type [%s] not valid for Task creation in %s",
+ attribute.getAttrTypeName(), task);
}
}
}
@@ -136,10 +155,10 @@ public class CreateTasksOperation {
return resultData;
}
- private static IAttributeType getAttributeType(IAtsServer atsServer, Entry<String, Object> entry) {
+ private static IAttributeType getAttributeType(IAtsServer atsServer, String attrTypeName) {
for (IAttributeType attrType : atsServer.getOrcsApi().getOrcsTypes().getArtifactTypes().getAttributeTypes(
AtsArtifactTypes.Task, AtsUtilCore.getAtsBranch())) {
- if (attrType.getName().equals(entry.getKey())) {
+ if (attrType.getName().equals(attrTypeName)) {
return attrType;
}
}
@@ -194,24 +213,38 @@ public class CreateTasksOperation {
assignees.addAll(atsServer.getUserService().getUsersByUserIds(jaxTask.getAssigneeUserIds()));
}
+ IAtsWorkDefinition workDefinition = null;
+ if (Strings.isValid(jaxTask.getTaskWorkDef())) {
+ try {
+ workDefinition = atsServer.getWorkDefService().getWorkDef(jaxTask.getTaskWorkDef(), new XResultData());
+ } catch (Exception ex) {
+ throw new OseeArgumentException("Exception finding Task Work Def [%s]", jaxTask.getTaskWorkDef(), ex);
+ }
+ }
if (Strings.isValid(jaxTask.getDescription())) {
changes.setSoleAttributeValue(task, AtsAttributeTypes.Description, jaxTask.getDescription());
}
- atsServer.getActionFactory().initializeNewStateMachine(task, assignees, createdByDate, asUser, changes);
+ atsServer.getActionFactory().initializeNewStateMachine(task, assignees, createdByDate, asUser, workDefinition,
+ changes);
// Set parent state task is related to if set
if (Strings.isValid(jaxTask.getRelatedToState())) {
changes.setSoleAttributeValue(task, AtsAttributeTypes.RelatedToState, jaxTask.getRelatedToState());
}
- for (Entry<String, Object> entry : jaxTask.getAttrTypeToObject().entrySet()) {
- IAttributeType attrType = getAttributeType(atsServer, entry);
- changes.setSoleAttributeValue(task, attrType, entry.getValue());
+ for (JaxAttribute attribute : jaxTask.getAttributes()) {
+ IAttributeType attrType = getAttributeType(atsServer, attribute.getAttrTypeName());
+ if (attrType == null) {
+ resultData.logErrorWithFormat("Attribute Type [%s] not valid for Task creation in %s",
+ attribute.getAttrTypeName(), task);
+ }
+ changes.setValues(task, attrType, attribute.getValues());
}
changes.add(taskArt);
}
+
}
public static JaxAtsTask createNewJaxTask(Long uuid, IAtsServer atsServer) {
@@ -231,8 +264,11 @@ public class CreateTasksOperation {
newJaxTask.getAssigneeUserIds().add(user.getUserId());
}
for (IAttributeType type : taskArt.getExistingAttributeTypes()) {
- newJaxTask.getAttrTypeToObject().put(type.getName(),
- Collections.toString(", ", taskArt.getAttributeValues(type)));
+ List<String> attributeValues = new LinkedList<>();
+ for (Object value : taskArt.getAttributeValues(type)) {
+ attributeValues.add(value.toString());
+ }
+ newJaxTask.addAttributes(type.getName(), attributeValues);
}
return newJaxTask;
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java
index 87c61e02243..bde1f4ca854 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java
@@ -100,7 +100,8 @@ public class ImportTasksFromSimpleList extends AbstractBlam {
try {
IAtsTeamWorkflow teamWf = AtsClientService.get().getWorkItemFactory().getTeamWf(artifact);
AtsClientService.get().getTaskService().createTasks(teamWf, titles, assignees, null,
- AtsClientService.get().getUserService().getCurrentUser(), null, getClass().getSimpleName());
+ AtsClientService.get().getUserService().getCurrentUser(), null, null, null,
+ getClass().getSimpleName());
} catch (Exception ex) {
OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
return;

Back to the top