Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2013-12-09 16:59:20 +0000
committerdonald.g.dunne2013-12-17 16:17:34 +0000
commitd30b41abb454f0e3270bd0ac573c3278f5660eb9 (patch)
tree13c2740182cce287c2cef22af9576a23e1983ed9 /plugins
parent65a43c0dddbb92cda910fc0d99a5f8b8a3b10fce (diff)
downloadorg.eclipse.osee-d30b41abb454f0e3270bd0ac573c3278f5660eb9.tar.gz
org.eclipse.osee-d30b41abb454f0e3270bd0ac573c3278f5660eb9.tar.xz
org.eclipse.osee-d30b41abb454f0e3270bd0ac573c3278f5660eb9.zip
feature[ats_4SCN5]: Add unit tests for StateManager classes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateManager.java4
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsWorkStateFactory.java32
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/SMAPromptChangeStatusTest.java6
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/review/ValidateReviewManager.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsCore_Internal_State_Suite.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactoryTest.java107
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/StateManagerTest.java34
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/AtsCore_Workflow_JT_Suite.java3
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/TestState.java25
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/AtsCore_Workflow_State_Suite.java27
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/SimpleTeamStateTest.java30
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtilityTest.java268
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/StateTypeAdapterTest.java (renamed from plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/StateTypeAdapterTest.java)19
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/TeamStateTest.java50
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/AtsCore.java12
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsStateFactory.java11
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactory.java115
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManager.java17
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerReader.java12
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerStore.java20
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerWriter.java18
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/UsersByIds.java (renamed from plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/UsersByIds.java)10
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/AtsWorkStateFactory.java66
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtility.java81
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/StateCompletedColumn.java17
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/history/column/EventColumn.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java6
27 files changed, 788 insertions, 220 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateManager.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateManager.java
index 05fdd68997..9bd3e9db05 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateManager.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateManager.java
@@ -140,8 +140,6 @@ public interface IAtsStateManager extends WorkStateFactory {
void validateNoBootstrapUser() throws OseeCoreException;
- boolean isSame(WorkState workState) throws OseeCoreException;
-
@Override
String getId();
@@ -155,4 +153,6 @@ public interface IAtsStateManager extends WorkStateFactory {
void setPercentCompleteValue(Integer percentComplete);
+ WorkState getState(String string);
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsWorkStateFactory.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsWorkStateFactory.java
new file mode 100644
index 0000000000..52109c314a
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsWorkStateFactory.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.workflow.state;
+
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.ats.api.user.IAtsUser;
+import org.eclipse.osee.ats.api.workflow.WorkState;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface IAtsWorkStateFactory {
+
+ public abstract String toStoreStr(IAtsStateManager stateMgr, String stateName) throws OseeCoreException;
+
+ public abstract WorkState fromStoreStr(String xml) throws OseeCoreException;
+
+ public abstract String getStorageString(Collection<IAtsUser> users) throws OseeCoreException;
+
+ public abstract List<IAtsUser> getUsers(String sorageString);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/SMAPromptChangeStatusTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/SMAPromptChangeStatusTest.java
index bf1c499f06..8ba13d8a80 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/SMAPromptChangeStatusTest.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/SMAPromptChangeStatusTest.java
@@ -17,19 +17,19 @@ import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.workflow.WorkState;
import org.eclipse.osee.ats.api.workflow.transition.TransitionOption;
import org.eclipse.osee.ats.api.workflow.transition.TransitionResults;
import org.eclipse.osee.ats.client.integration.tests.ats.core.client.AtsTestUtil;
import org.eclipse.osee.ats.client.integration.tests.util.DemoTestUtil;
+import org.eclipse.osee.ats.core.AtsCore;
import org.eclipse.osee.ats.core.client.task.TaskArtifact;
import org.eclipse.osee.ats.core.client.task.TaskStates;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.util.AtsChangeSet;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
-import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
import org.eclipse.osee.ats.core.util.HoursSpentUtil;
import org.eclipse.osee.ats.core.util.PercentCompleteTotalUtil;
-import org.eclipse.osee.ats.core.workflow.state.AtsWorkStateFactory;
import org.eclipse.osee.ats.core.workflow.state.TeamState;
import org.eclipse.osee.ats.core.workflow.transition.TransitionHelper;
import org.eclipse.osee.ats.core.workflow.transition.TransitionManager;
@@ -179,7 +179,7 @@ public class SMAPromptChangeStatusTest {
0.0);
for (String xml : awa.getAttributesToStringList(AtsAttributeTypes.State)) {
- WorkStateImpl state = AtsWorkStateFactory.getFromXml(xml);
+ WorkState state = AtsCore.getWorkStateFactory().fromStoreStr(xml);
boolean isCompletedCancelledState = isCompletedCancelledState(awa, state.getName());
if (isCompletedCancelledState) {
assertTrue("completed/cancelled ats.State [" + xml + "] wrong " + awa.getAtsId(), xml.endsWith(";;;"));
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/review/ValidateReviewManager.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/review/ValidateReviewManager.java
index 8062a9f932..19efc73e59 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/review/ValidateReviewManager.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/review/ValidateReviewManager.java
@@ -24,6 +24,7 @@ import org.eclipse.osee.ats.api.workdef.ReviewBlockType;
import org.eclipse.osee.ats.api.workdef.RuleDefinitionOption;
import org.eclipse.osee.ats.api.workflow.transition.TransitionOption;
import org.eclipse.osee.ats.api.workflow.transition.TransitionResults;
+import org.eclipse.osee.ats.core.AtsCore;
import org.eclipse.osee.ats.core.client.internal.Activator;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.workflow.state.TeamState;
@@ -107,7 +108,8 @@ public class ValidateReviewManager {
public static String getValidateReviewFollowupUsersStr(TeamWorkFlowArtifact teamArt) {
try {
- return org.eclipse.osee.ats.core.users.UsersByIds.getStorageString(getValidateReviewFollowupUsers(teamArt));
+ Collection<IAtsUser> users = getValidateReviewFollowupUsers(teamArt);
+ return AtsCore.getWorkStateFactory().getStorageString(users);
} catch (Exception ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
return ex.getLocalizedMessage();
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsCore_Internal_State_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsCore_Internal_State_Suite.java
index a72487bc6c..95b545f1b4 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsCore_Internal_State_Suite.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsCore_Internal_State_Suite.java
@@ -14,7 +14,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-@Suite.SuiteClasses({StateManagerTest.class})
+@Suite.SuiteClasses({AtsWorkStateFactoryTest.class, StateManagerTest.class})
/**
* @author Donald G. Dunne
*/
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactoryTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactoryTest.java
new file mode 100644
index 0000000000..b31b73c5e9
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactoryTest.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.internal.state;
+
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.osee.ats.api.user.IAtsUser;
+import org.eclipse.osee.ats.api.user.IAtsUserService;
+import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
+import org.eclipse.osee.ats.core.internal.state.AtsWorkStateFactory;
+import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test unit for {@link AtsWorkStateFactory}
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsWorkStateFactoryTest {
+
+ // @formatter:off
+ @Mock IAtsStateManager stateMgr;
+ @Mock IAtsUser Joe, Kay;
+ @Mock IAtsUserService userService;
+ // @formatter:on
+
+ @Before
+ public void setup() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testToXml() {
+ AtsWorkStateFactory atsWorkStateFactory = new AtsWorkStateFactory(userService);
+ String xml = atsWorkStateFactory.toStoreStr(stateMgr, "Implement");
+ Assert.assertEquals("Implement;;;", xml);
+
+ when(Joe.getUserId()).thenReturn("asdf");
+ when(Kay.getUserId()).thenReturn("qwer");
+ List<IAtsUser> asList = Arrays.asList(Joe, Kay);
+ when(stateMgr.getAssignees("Implement")).thenReturn(asList);
+
+ xml = atsWorkStateFactory.toStoreStr(stateMgr, "Implement");
+ Assert.assertEquals("Implement;<asdf><qwer>;;", xml);
+
+ when(stateMgr.getHoursSpent("Implement")).thenReturn(1.3);
+ when(stateMgr.getHoursSpentStr("Implement")).thenReturn("1.3");
+ xml = atsWorkStateFactory.toStoreStr(stateMgr, "Implement");
+ Assert.assertEquals("Implement;<asdf><qwer>;1.3;", xml);
+
+ when(stateMgr.getPercentComplete("Implement")).thenReturn(23);
+ xml = atsWorkStateFactory.toStoreStr(stateMgr, "Implement");
+ Assert.assertEquals("Implement;<asdf><qwer>;1.3;23", xml);
+ when(stateMgr.getPercentComplete("Implement")).thenReturn(0);
+ xml = atsWorkStateFactory.toStoreStr(stateMgr, "Implement");
+ Assert.assertEquals("Implement;<asdf><qwer>;1.3;", xml);
+ }
+
+ @Test
+ public void testGetFromXml() {
+ AtsWorkStateFactory atsWorkStateFactory = new AtsWorkStateFactory(userService);
+
+ WorkStateImpl state = atsWorkStateFactory.fromStoreStr("");
+ Assert.assertEquals("Unknown", state.getName());
+ Assert.assertEquals(0, state.getHoursSpent(), 0.01);
+ Assert.assertEquals(0, state.getAssignees().size());
+ Assert.assertEquals(0, state.getPercentComplete());
+
+ when(userService.getUserById(eq("asdf"))).thenReturn(Joe);
+ when(userService.getUserById(eq("qwer"))).thenReturn(Kay);
+ state = atsWorkStateFactory.fromStoreStr("Implement;<asdf><qwer>;1.3;20");
+ Assert.assertEquals("Implement", state.getName());
+ Assert.assertEquals(1.3, state.getHoursSpent(), 0.01);
+
+ Assert.assertEquals(2, state.getAssignees().size());
+ Assert.assertEquals(20, state.getPercentComplete());
+
+ state = atsWorkStateFactory.fromStoreStr("Implement;;;");
+ Assert.assertEquals("Implement", state.getName());
+ Assert.assertEquals(0, state.getHoursSpent(), 0.01);
+ Assert.assertEquals(0, state.getAssignees().size());
+ Assert.assertEquals(0, state.getPercentComplete());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testGetFromXml_Exception() {
+ AtsWorkStateFactory atsWorkStateFactory = new AtsWorkStateFactory(userService);
+ atsWorkStateFactory.fromStoreStr("asdfa;");
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/StateManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/StateManagerTest.java
index dbca19899f..2e88b97527 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/StateManagerTest.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/state/StateManagerTest.java
@@ -408,40 +408,6 @@ public class StateManagerTest {
}
@Test
- public void testIsSame() {
- WorkStateImpl endorse = new WorkStateImpl("endorse");
- stateMgr.addState(endorse);
-
- WorkStateImpl endorse2 = new WorkStateImpl("endorse");
-
- Assert.assertTrue(stateMgr.isSame(endorse2));
- endorse.setHoursSpent(4);
- endorse.setPercentComplete(23);
- endorse2.setHoursSpent(4);
- endorse2.setPercentComplete(23);
- Assert.assertTrue(stateMgr.isSame(endorse2));
-
- endorse2.setHoursSpent(5);
- Assert.assertFalse(stateMgr.isSame(endorse2));
- endorse2.setHoursSpent(4);
- Assert.assertTrue(stateMgr.isSame(endorse2));
-
- endorse2.setPercentComplete(5);
- Assert.assertFalse(stateMgr.isSame(endorse2));
- endorse2.setPercentComplete(23);
- Assert.assertTrue(stateMgr.isSame(endorse2));
-
- endorse2.addAssignee(joe);
- Assert.assertFalse(stateMgr.isSame(endorse2));
- endorse.addAssignee(joe);
- Assert.assertTrue(stateMgr.isSame(endorse2));
-
- WorkStateImpl analyze = new WorkStateImpl("blah");
- Assert.assertFalse(stateMgr.isSame(analyze));
-
- }
-
- @Test
public void testIsHoursEqual() {
IAtsWorkItem awa = Mockito.mock(IAtsWorkItem.class);
StateManager mgr = new StateManager(awa);
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/AtsCore_Workflow_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/AtsCore_Workflow_JT_Suite.java
index 66dee0899c..17268d7aaf 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/AtsCore_Workflow_JT_Suite.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/AtsCore_Workflow_JT_Suite.java
@@ -10,11 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.workflow;
+import org.eclipse.osee.ats.core.workflow.state.AtsCore_Workflow_State_Suite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-@Suite.SuiteClasses({WorkflowManagerCoreTest.class, StateTypeAdapterTest.class, StateTypeTest.class})
+@Suite.SuiteClasses({AtsCore_Workflow_State_Suite.class, WorkflowManagerCoreTest.class, StateTypeTest.class})
/**
* This test suite contains tests that can be run as stand-alone JUnit tests (JT)
*
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/TestState.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/TestState.java
new file mode 100644
index 0000000000..eb844ed81a
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/TestState.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.workflow;
+
+import org.eclipse.osee.ats.api.workdef.StateType;
+import org.eclipse.osee.ats.core.workflow.state.StateTypeAdapter;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class TestState extends StateTypeAdapter {
+
+ public TestState(String pageName, StateType StateType) {
+ super(TestState.class, pageName, StateType);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/AtsCore_Workflow_State_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/AtsCore_Workflow_State_Suite.java
new file mode 100644
index 0000000000..290a2f4830
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/AtsCore_Workflow_State_Suite.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.workflow.state;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ StateManagerUtilityTest.class,
+ TeamStateTest.class,
+ SimpleTeamStateTest.class,
+ StateTypeAdapterTest.class})
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Workflow_State_Suite {
+ // TestSuite
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/SimpleTeamStateTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/SimpleTeamStateTest.java
new file mode 100644
index 0000000000..eaac7a352d
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/SimpleTeamStateTest.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.workflow.state;
+
+import org.eclipse.osee.ats.api.workdef.StateType;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test Unit for {@link SimpleTeamState}
+ *
+ * @author Donald G. Dunne
+ */
+public class SimpleTeamStateTest {
+
+ @Test
+ public void testGetName() {
+ SimpleTeamState state = new SimpleTeamState("Analyze", StateType.Working);
+ Assert.assertEquals(StateType.Working, state.getStateType());
+ Assert.assertEquals("Analyze", state.getName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtilityTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtilityTest.java
new file mode 100644
index 0000000000..4ffbff74b4
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtilityTest.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.workflow.state;
+
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.notify.AtsNotifyType;
+import org.eclipse.osee.ats.api.notify.IAtsNotificationService;
+import org.eclipse.osee.ats.api.user.IAtsUser;
+import org.eclipse.osee.ats.api.user.IAtsUserService;
+import org.eclipse.osee.ats.api.util.IAtsChangeSet;
+import org.eclipse.osee.ats.api.util.IExecuteListener;
+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.StateType;
+import org.eclipse.osee.ats.api.workflow.WorkState;
+import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
+import org.eclipse.osee.ats.core.internal.state.AtsWorkStateFactory;
+import org.eclipse.osee.ats.core.internal.state.StateManager;
+import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
+import org.eclipse.osee.ats.core.workflow.TestState;
+import org.eclipse.osee.framework.core.util.Result;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link StateManagerUtility}
+ *
+ * @author Donald G. Dunne
+ */
+public class StateManagerUtilityTest {
+
+ // @formatter:off
+ @Mock IAtsWorkItem workItem;
+ @Mock IAtsUser Joe, Kay;
+ @Mock IAtsChangeSet changes;
+ @Mock IAtsWorkDefinition workDef;
+ @Mock IAtsStateDefinition analyzeState, completedState;
+ @Mock IAttributeResolver attrResolver;
+ @Mock IAtsStateManager stateMgr;
+ @Mock IAtsWorkStateFactory workStateFactory;
+ @Mock IAtsUserService userService;
+ @Mock IAtsNotificationService notifyService;
+ // @formatter:on
+
+ @Before
+ public void setup() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ when(workItem.getWorkDefinition()).thenReturn(workDef);
+ when(workItem.getStateMgr()).thenReturn(stateMgr);
+
+ when(workDef.getStateByName("Analyze")).thenReturn(analyzeState);
+ when(analyzeState.getStateType()).thenReturn(StateType.Working);
+ when(workDef.getStateByName("Completed")).thenReturn(completedState);
+ when(completedState.getStateType()).thenReturn(StateType.Completed);
+
+ }
+
+ @Test
+ public void testConstructor() {
+ new StateManagerUtility();
+ }
+
+ @Test
+ public void testInitializeStateMachine() {
+ StateManager stateMgr = new StateManager(workItem);
+ TestState state = new TestState("Analyze", StateType.Working);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, Arrays.asList(Joe, Kay), Joe, changes);
+ Assert.assertEquals("Analyze", stateMgr.getCurrentStateName());
+ Assert.assertEquals(2, stateMgr.getAssignees().size());
+
+ state = new TestState("Analyze", StateType.Working);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, null, Joe, changes);
+ Assert.assertEquals("Analyze", stateMgr.getCurrentStateName());
+ Assert.assertEquals(1, stateMgr.getAssignees().size());
+ Assert.assertEquals(Joe, stateMgr.getAssignees().iterator().next());
+
+ state = new TestState("Completed", StateType.Completed);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, Arrays.asList(Joe, Kay), Joe, changes);
+ Assert.assertEquals("Completed", stateMgr.getCurrentStateName());
+ Assert.assertEquals(0, stateMgr.getAssignees().size());
+ }
+
+ @Test
+ public void testIsDirtyResult() {
+ AtsWorkStateFactory workStateFactory = new AtsWorkStateFactory(userService);
+
+ // test current state new
+ when(attrResolver.getAttributeCount(workItem, AtsAttributeTypes.CurrentState)).thenReturn(0);
+ Result result = StateManagerUtility.isDirtyResult(workItem, stateMgr, attrResolver, workStateFactory);
+ Assert.assertTrue(result.getText().contains("Current State new"));
+
+ // test current state modified
+ when(attrResolver.getAttributeCount(workItem, AtsAttributeTypes.CurrentState)).thenReturn(1);
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, null)).thenReturn("this");
+ when(stateMgr.getCurrentStateName()).thenReturn("Analyze");
+ result = StateManagerUtility.isDirtyResult(workItem, stateMgr, attrResolver, workStateFactory);
+ Assert.assertTrue(result.getText().contains("Current State modified"));
+
+ // test no visited states
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, null)).thenReturn("Analyze;;;");
+ List<String> emptyVisitedNames = new ArrayList<String>();
+ when(stateMgr.getVisitedStateNames()).thenReturn(emptyVisitedNames);
+ result = StateManagerUtility.isDirtyResult(workItem, stateMgr, attrResolver, workStateFactory);
+ Assert.assertFalse(result.isTrue());
+
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, null)).thenReturn("Analyze;;;");
+ when(stateMgr.getVisitedStateNames()).thenReturn(Arrays.asList("Implement"));
+ when(attrResolver.getAttributesToStringList(workItem, AtsAttributeTypes.State)).thenReturn(
+ new ArrayList<String>());
+ result = StateManagerUtility.isDirtyResult(workItem, stateMgr, attrResolver, workStateFactory);
+ Assert.assertTrue(result.getText().contains("State [Implement] added"));
+
+ // test state added
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, null)).thenReturn("Analyze;;;");
+ when(stateMgr.getVisitedStateNames()).thenReturn(Arrays.asList("Implement"));
+ when(attrResolver.getAttributesToStringList(workItem, AtsAttributeTypes.State)).thenReturn(
+ new ArrayList<String>());
+ result = StateManagerUtility.isDirtyResult(workItem, stateMgr, attrResolver, workStateFactory);
+ Assert.assertTrue(result.getText().contains("State [Implement] added"));
+
+ // test state unmodified
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, null)).thenReturn("Analyze;;;");
+ when(stateMgr.getVisitedStateNames()).thenReturn(Arrays.asList("Implement"));
+ when(attrResolver.getAttributesToStringList(workItem, AtsAttributeTypes.State)).thenReturn(
+ Arrays.asList("Implement;;;"));
+ result = StateManagerUtility.isDirtyResult(workItem, stateMgr, attrResolver, workStateFactory);
+ Assert.assertFalse(result.isTrue());
+
+ // test state modified
+ when(stateMgr.getVisitedStateNames()).thenReturn(Arrays.asList("Analyze", "Implement"));
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, null)).thenReturn("Analyze;;;");
+ when(attrResolver.getAttributesToStringList(workItem, AtsAttributeTypes.State)).thenReturn(
+ Arrays.asList("Endorse;;;", "Implement;;;"));
+ WorkState workState = Mockito.mock(WorkState.class);
+ when(stateMgr.getHoursSpent("Implement")).thenReturn(1.3);
+ when(stateMgr.getHoursSpentStr("Implement")).thenReturn("1.3");
+ when(stateMgr.getState("Implement")).thenReturn(workState);
+
+ result = StateManagerUtility.isDirtyResult(workItem, stateMgr, attrResolver, workStateFactory);
+ Assert.assertTrue(result.getText().contains(
+ "StateManager: State [Implement] modified was [Implement;;;] is [Implement;;1.3;]"));
+
+ }
+
+ @Test
+ public void testWriteToStore() {
+ StateManager stateMgr = new StateManager(workItem);
+ TestState state = new TestState("Analyze", StateType.Working);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, Arrays.asList(Joe, Kay), Joe, changes);
+ Assert.assertEquals("Analyze", stateMgr.getCurrentStateName());
+ Assert.assertEquals(2, stateMgr.getAssignees().size());
+ when(workStateFactory.toStoreStr(stateMgr, "Analyze")).thenReturn("Analyze;<Joe><Kay>;;");
+ StateManagerUtility.writeToStore(workItem, stateMgr, attrResolver, changes, workStateFactory, notifyService);
+
+ verify(attrResolver).setSoleAttributeValue(eq(workItem), eq(AtsAttributeTypes.CurrentState),
+ eq("Analyze;<Joe><Kay>;;"), eq(changes));
+ }
+
+ @Test
+ public void testLoad() {
+ StateManager stateMgr = new StateManager(workItem);
+ stateMgr.setCurrentStateName("Analyze");
+ TestState state = new TestState("Analyze", StateType.Working);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, Arrays.asList(Joe, Kay), Joe, changes);
+ Assert.assertEquals("Analyze", stateMgr.getCurrentStateName());
+ Assert.assertEquals(2, stateMgr.getAssignees().size());
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, "")).thenReturn(
+ "Analyze;<Joe><Kay>;;");
+ WorkState currentState = new WorkStateImpl("Analyze", Arrays.asList(Joe, Kay), 0, 0);
+ when(workStateFactory.fromStoreStr(eq("Analyze;<Joe><Kay>;;"))).thenReturn(currentState);
+
+ StateManagerUtility.load(workItem, stateMgr, attrResolver, workStateFactory);
+
+ verify(attrResolver).getSoleAttributeValue(eq(workItem), eq(AtsAttributeTypes.CurrentState), eq(""));
+ }
+
+ @Test
+ public void testPostPersistNotifyReset() {
+ StateManager stateMgr = new StateManager(workItem);
+ stateMgr.setCurrentStateName("Analyze");
+ TestState state = new TestState("Analyze", StateType.Working);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, Arrays.asList(Joe, Kay), Joe, changes);
+ Assert.assertEquals("Analyze", stateMgr.getCurrentStateName());
+ Assert.assertEquals(2, stateMgr.getAssignees().size());
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, "")).thenReturn(
+ "Analyze;<Joe><Kay>;;");
+ WorkState currentState = new WorkStateImpl("Analyze", Arrays.asList(Joe, Kay), 0, 0);
+ when(workStateFactory.fromStoreStr(eq("Analyze;<Joe><Kay>;;"))).thenReturn(currentState);
+
+ StateManagerUtility.postPersistNotifyReset(workItem, stateMgr, attrResolver, workStateFactory, notifyService);
+
+ List<IAtsUser> assigneesAdded = Arrays.asList(Joe, Kay);
+ verify(notifyService).notify(workItem, assigneesAdded, AtsNotifyType.Assigned);
+ }
+
+ @Test
+ public void testGetPostPersistExecutionListener() {
+ StateManager stateMgr = new StateManager(workItem);
+ stateMgr.setCurrentStateName("Analyze");
+ TestState state = new TestState("Analyze", StateType.Working);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, Arrays.asList(Joe, Kay), Joe, changes);
+ Assert.assertEquals("Analyze", stateMgr.getCurrentStateName());
+ Assert.assertEquals(2, stateMgr.getAssignees().size());
+
+ when(workItem.getStateMgr()).thenReturn(stateMgr);
+ List<Object> objects = new ArrayList<Object>();
+ when(changes.getObjects()).thenReturn(objects);
+ IExecuteListener listener =
+ StateManagerUtility.getPostPersistExecutionListener(attrResolver, workStateFactory, notifyService);
+
+ when(attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, "")).thenReturn(
+ "Analyze;<Joe><Kay>;;");
+ WorkState currentState = new WorkStateImpl("Analyze", Arrays.asList(Joe, Kay), 0, 0);
+ when(workStateFactory.fromStoreStr(eq("Analyze;<Joe><Kay>;;"))).thenReturn(currentState);
+
+ objects.add(workItem);
+ objects.add("now");
+
+ listener = StateManagerUtility.getPostPersistExecutionListener(attrResolver, workStateFactory, notifyService);
+ listener.changesStored(changes);
+
+ List<IAtsUser> assigneesAdded = Arrays.asList(Joe, Kay);
+ verify(notifyService).notify(workItem, assigneesAdded, AtsNotifyType.Assigned);
+ }
+
+ @Test
+ public void testGetPostPersistExecutionListener_exception() {
+ StateManager stateMgr = new StateManager(workItem);
+ stateMgr.setCurrentStateName("Analyze");
+ TestState state = new TestState("Analyze", StateType.Working);
+ StateManagerUtility.initializeStateMachine(stateMgr, state, Arrays.asList(Joe, Kay), Joe, changes);
+ Assert.assertEquals("Analyze", stateMgr.getCurrentStateName());
+ Assert.assertEquals(2, stateMgr.getAssignees().size());
+
+ when(workItem.getStateMgr()).thenReturn(stateMgr);
+ List<Object> objects = new ArrayList<Object>();
+ when(changes.getObjects()).thenReturn(objects);
+
+ objects.add(workItem);
+
+ IExecuteListener listener =
+ StateManagerUtility.getPostPersistExecutionListener(attrResolver, workStateFactory, notifyService);
+ listener.changesStored(changes);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/StateTypeAdapterTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/StateTypeAdapterTest.java
index 642576b60b..a933bb695e 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/StateTypeAdapterTest.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/StateTypeAdapterTest.java
@@ -8,10 +8,12 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ats.core.workflow;
+package org.eclipse.osee.ats.core.workflow.state;
import org.eclipse.osee.ats.api.workdef.StateType;
-import org.eclipse.osee.ats.core.workflow.state.StateTypeAdapter;
+import org.eclipse.osee.ats.core.workflow.OneStates;
+import org.eclipse.osee.ats.core.workflow.OrderedStates;
+import org.eclipse.osee.ats.core.workflow.TestState;
import org.junit.Assert;
import org.junit.Test;
@@ -79,11 +81,12 @@ public class StateTypeAdapterTest {
Assert.assertEquals("[Endorse][Working]", state.toString());
}
- private class TestState extends StateTypeAdapter {
-
- public TestState(String pageName, StateType StateType) {
- super(TestState.class, pageName, StateType);
- }
-
+ @Test
+ public void testDescription() {
+ TestState state = new TestState("Endorse", StateType.Working);
+ Assert.assertNull(state.getDescription());
+ state.setDescription("description");
+ Assert.assertEquals("description", state.getDescription());
}
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/TeamStateTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/TeamStateTest.java
new file mode 100644
index 0000000000..2cfbd14428
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/state/TeamStateTest.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.workflow.state;
+
+import org.eclipse.osee.ats.api.workdef.StateType;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test Unit for {@link TeamState}
+ *
+ * @author Donald G. Dunne
+ */
+public class TeamStateTest {
+
+ @Test
+ public void test() {
+ Assert.assertEquals(StateType.Working, TeamState.Endorse.getStateType());
+ Assert.assertEquals("Endorse", TeamState.Endorse.getName());
+ Assert.assertEquals(StateType.Working, TeamState.Analyze.getStateType());
+ Assert.assertEquals("Analyze", TeamState.Analyze.getName());
+ Assert.assertEquals(StateType.Working, TeamState.Authorize.getStateType());
+ Assert.assertEquals("Authorize", TeamState.Authorize.getName());
+ Assert.assertEquals(StateType.Working, TeamState.Implement.getStateType());
+ Assert.assertEquals("Implement", TeamState.Implement.getName());
+ Assert.assertEquals(StateType.Completed, TeamState.Completed.getStateType());
+ Assert.assertEquals("Completed", TeamState.Completed.getName());
+ Assert.assertEquals(StateType.Cancelled, TeamState.Cancelled.getStateType());
+ Assert.assertEquals("Cancelled", TeamState.Cancelled.getName());
+ }
+
+ @Test
+ public void testValueOf() {
+ Assert.assertEquals(TeamState.Analyze, TeamState.valueOf("Analyze"));
+ }
+
+ @Test
+ public void testValues() {
+ Assert.assertEquals(6, TeamState.values().size());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/AtsCore.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/AtsCore.java
index 03a8d1354d..2d37567a89 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/AtsCore.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/AtsCore.java
@@ -23,6 +23,7 @@ import org.eclipse.osee.ats.api.workflow.IAtsWorkItemService;
import org.eclipse.osee.ats.api.workflow.IAtsWorkItemServiceProvider;
import org.eclipse.osee.ats.api.workflow.log.IAtsLogFactory;
import org.eclipse.osee.ats.api.workflow.state.IAtsStateFactory;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
import org.eclipse.osee.ats.core.column.IAtsColumnUtilities;
import org.eclipse.osee.ats.core.config.IAtsConfig;
import org.eclipse.osee.ats.core.internal.AtsConfigUtility;
@@ -30,6 +31,7 @@ import org.eclipse.osee.ats.core.internal.AtsEarnedValueService;
import org.eclipse.osee.ats.core.internal.column.ev.AtsColumnUtilities;
import org.eclipse.osee.ats.core.internal.log.AtsLogFactory;
import org.eclipse.osee.ats.core.internal.state.AtsStateFactory;
+import org.eclipse.osee.ats.core.internal.state.AtsWorkStateFactory;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
@@ -51,6 +53,7 @@ public class AtsCore {
private static IAtsWorkItemServiceProvider workItemServiceProvider;
private static IAtsBranchServiceProvider branchServiceProvider;
private static IAtsReviewServiceProvider reviewServiceProvider;
+ private static AtsWorkStateFactory workStateFactory;
public void setAtsUserService(IAtsUserService userService) {
AtsCore.userService = userService;
@@ -134,11 +137,18 @@ public class AtsCore {
public static IAtsStateFactory getStateFactory() {
if (stateFactory == null) {
- stateFactory = new AtsStateFactory(attrResolver);
+ stateFactory = new AtsStateFactory(attrResolver, getWorkStateFactory());
}
return stateFactory;
}
+ public static IAtsWorkStateFactory getWorkStateFactory() {
+ if (workStateFactory == null) {
+ workStateFactory = new AtsWorkStateFactory(getUserService());
+ }
+ return workStateFactory;
+ }
+
public static IAtsLogFactory getLogFactory() {
if (logFactory == null) {
logFactory = new AtsLogFactory();
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsStateFactory.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsStateFactory.java
index b2b8f158c1..d571b2871a 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsStateFactory.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsStateFactory.java
@@ -15,6 +15,7 @@ import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workflow.state.IAtsStateFactory;
import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
/**
@@ -23,9 +24,11 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
public class AtsStateFactory implements IAtsStateFactory {
private final IAttributeResolver attrResolver;
+ private final IAtsWorkStateFactory workStateFactory;
- public AtsStateFactory(IAttributeResolver attrResolver) {
+ public AtsStateFactory(IAttributeResolver attrResolver, IAtsWorkStateFactory workStateFactory) {
this.attrResolver = attrResolver;
+ this.workStateFactory = workStateFactory;
}
@Override
@@ -38,19 +41,19 @@ public class AtsStateFactory implements IAtsStateFactory {
public IAtsStateManager getStateManager(IAtsWorkItem workItem, boolean load) throws OseeCoreException {
IAtsStateManager stateMgr = getStateManager(workItem);
if (load) {
- StateManagerStore.load(workItem, stateMgr, attrResolver);
+ StateManagerStore.load(workItem, stateMgr, attrResolver, workStateFactory);
}
return stateMgr;
}
@Override
public void writeToStore(IAtsWorkItem workItem, IAtsChangeSet changes) throws OseeCoreException {
- (new StateManagerStore()).writeToStore(workItem, attrResolver, changes);
+ (new StateManagerStore()).writeToStore(workItem, attrResolver, changes, workStateFactory);
}
@Override
public void load(IAtsWorkItem workItem, IAtsStateManager stateMgr) {
- StateManagerStore.load(workItem, stateMgr, attrResolver);
+ StateManagerStore.load(workItem, stateMgr, attrResolver, workStateFactory);
}
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactory.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactory.java
new file mode 100644
index 0000000000..9945264047
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsWorkStateFactory.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.internal.state;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.osee.ats.api.user.IAtsUser;
+import org.eclipse.osee.ats.api.user.IAtsUserService;
+import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
+import org.eclipse.osee.ats.core.AtsCore;
+import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsWorkStateFactory implements IAtsWorkStateFactory {
+
+ public Pattern storagePattern = Pattern.compile("^(.*?);(.*?);(.*?);(.*?)$");
+ public Pattern userPattern = Pattern.compile("<(.*?)>");
+ private final IAtsUserService userService;
+
+ public AtsWorkStateFactory(IAtsUserService userService) {
+ this.userService = userService;
+ }
+
+ @Override
+ public String toStoreStr(IAtsStateManager stateMgr, String stateName) throws OseeCoreException {
+ StringBuffer sb = new StringBuffer(stateName);
+ sb.append(";");
+ sb.append(getStorageString(stateMgr.getAssignees(stateName)));
+ sb.append(";");
+ double hoursSpent = stateMgr.getHoursSpent(stateName);
+ if (hoursSpent > 0) {
+ sb.append(stateMgr.getHoursSpentStr(stateName));
+ }
+ sb.append(";");
+ int percentComplete = stateMgr.getPercentComplete(stateName);
+ if (percentComplete > 0) {
+ sb.append(percentComplete);
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public WorkStateImpl fromStoreStr(String xml) throws OseeCoreException {
+ WorkStateImpl state = new WorkStateImpl("Unknown");
+ if (Strings.isValid(xml)) {
+ Matcher m = storagePattern.matcher(xml);
+ if (m.find()) {
+ state.setName(m.group(1));
+ if (!m.group(3).equals("")) {
+ state.setHoursSpent(new Float(m.group(3)).doubleValue());
+ }
+ if (!m.group(4).equals("")) {
+ state.setPercentComplete(Integer.valueOf(m.group(4)).intValue());
+ }
+ String userStr = m.group(2);
+ List<IAtsUser> users = getUsers(userStr);
+ state.setAssignees(users);
+ } else {
+ throw new OseeArgumentException("Can't unpack state data [%s]", xml);
+ }
+ }
+ return state;
+ }
+
+ @Override
+ public String getStorageString(Collection<IAtsUser> users) throws OseeCoreException {
+ StringBuffer sb = new StringBuffer();
+ for (IAtsUser u : users) {
+ sb.append("<" + u.getUserId() + ">");
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public List<IAtsUser> getUsers(String sorageString) {
+ List<IAtsUser> users = new ArrayList<IAtsUser>();
+ Matcher m = userPattern.matcher(sorageString);
+ while (m.find()) {
+ String userId = m.group(1);
+ if (!Strings.isValid(userId)) {
+ throw new IllegalArgumentException("Blank userId specified.");
+ }
+ try {
+ String uId = m.group(1);
+ IAtsUser u = userService.getUserById(uId);
+ Conditions.checkNotNull(u, "userById " + uId);
+ users.add(u);
+ } catch (Exception ex) {
+ OseeLog.log(AtsCore.class, Level.SEVERE, ex);
+ }
+ }
+ return users;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManager.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManager.java
index a2923c7521..a37335e004 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManager.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManager.java
@@ -333,7 +333,8 @@ public class StateManager implements IAtsStateManager {
return dirty;
}
- private WorkState getState(String string) {
+ @Override
+ public WorkState getState(String string) {
for (WorkState state : states) {
if (state.getName().equals(string)) {
return state;
@@ -580,20 +581,6 @@ public class StateManager implements IAtsStateManager {
}
@Override
- public boolean isSame(WorkState workState) {
- WorkState thisState = getState(workState.getName());
- if (thisState == null) {
- return false;
- } else if (thisState.getHoursSpent() != workState.getHoursSpent()) {
- return false;
- } else if (thisState.getPercentComplete() != workState.getPercentComplete()) {
- return false;
- }
- return org.eclipse.osee.framework.jdk.core.util.Collections.isEqual(thisState.getAssignees(),
- workState.getAssignees());
- }
-
- @Override
public String getId() {
return workItem.getAtsId();
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerReader.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerReader.java
index 96609fdb7c..e4b1395ca7 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerReader.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerReader.java
@@ -13,8 +13,8 @@ package org.eclipse.osee.ats.core.internal.state;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
-import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
-import org.eclipse.osee.ats.core.workflow.state.AtsWorkStateFactory;
+import org.eclipse.osee.ats.api.workflow.WorkState;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -26,21 +26,23 @@ public class StateManagerReader {
private final StateManager stateMgr;
private final IAttributeResolver attrResolver;
private final IAtsWorkItem workItem;
+ private final IAtsWorkStateFactory workStateFactory;
- public StateManagerReader(IAtsWorkItem workItem, StateManager stateMgr, IAttributeResolver attrResolver) {
+ public StateManagerReader(IAtsWorkItem workItem, StateManager stateMgr, IAttributeResolver attrResolver, IAtsWorkStateFactory workStateFactory) {
this.workItem = workItem;
this.stateMgr = stateMgr;
this.attrResolver = attrResolver;
+ this.workStateFactory = workStateFactory;
}
public synchronized void load() throws OseeCoreException {
String currentStateXml = attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, "");
if (Strings.isValid(currentStateXml)) {
- WorkStateImpl currentState = AtsWorkStateFactory.getFromXml(currentStateXml);
+ WorkState currentState = workStateFactory.fromStoreStr(currentStateXml);
stateMgr.setCurrentStateName(currentState.getName());
stateMgr.addState(currentState);
for (String stateXml : attrResolver.getAttributesToStringList(workItem, AtsAttributeTypes.State)) {
- WorkStateImpl state = AtsWorkStateFactory.getFromXml(stateXml);
+ WorkState state = workStateFactory.fromStoreStr(stateXml);
if (!state.getName().equals(currentState.getName())) {
if (!state.getName().equals(currentState.getName())) {
stateMgr.addState(state);
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerStore.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerStore.java
index 9743c1eec9..fc02bcd72b 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerStore.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerStore.java
@@ -19,6 +19,7 @@ import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.util.IExecuteListener;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
import org.eclipse.osee.ats.core.AtsCore;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -28,20 +29,20 @@ import org.eclipse.osee.framework.logging.OseeLog;
*/
public class StateManagerStore {
- public void writeToStore(IAtsWorkItem workItem, IAttributeResolver attrResolver, IAtsChangeSet changes) throws OseeCoreException {
+ public void writeToStore(IAtsWorkItem workItem, IAttributeResolver attrResolver, IAtsChangeSet changes, IAtsWorkStateFactory workStateFactory) throws OseeCoreException {
StateManager stateMgr = (StateManager) workItem.getStateMgr();
- StateManagerWriter writer = new StateManagerWriter(workItem, stateMgr, attrResolver, changes);
+ StateManagerWriter writer = new StateManagerWriter(workItem, stateMgr, attrResolver, changes, workStateFactory);
List<IAtsUser> assigneesAdded = stateMgr.getAssigneesAdded();
writer.writeToStore();
- changes.addExecuteListener(getPostPersistExecutionListener(assigneesAdded));
+ changes.addExecuteListener(getPostPersistExecutionListener(assigneesAdded, workStateFactory));
}
- public static void postPersistNotifyReset(IAtsWorkItem workItem, IAttributeResolver attrResolver, List<IAtsUser> assigneesAdded) throws OseeCoreException {
+ public static void postPersistNotifyReset(IAtsWorkItem workItem, IAttributeResolver attrResolver, List<IAtsUser> assigneesAdded, IAtsWorkStateFactory workStateFactory) throws OseeCoreException {
AtsCore.getNotifyService().notify(workItem, assigneesAdded, AtsNotifyType.Assigned);
- load(workItem, workItem.getStateMgr(), attrResolver);
+ load(workItem, workItem.getStateMgr(), attrResolver, workStateFactory);
}
- public static IExecuteListener getPostPersistExecutionListener(final List<IAtsUser> assigneesAdded) {
+ public static IExecuteListener getPostPersistExecutionListener(final List<IAtsUser> assigneesAdded, final IAtsWorkStateFactory workStateFactory) {
return new IExecuteListener() {
@Override
@@ -49,7 +50,8 @@ public class StateManagerStore {
for (Object obj : changes.getObjects()) {
if (obj instanceof IAtsWorkItem) {
try {
- postPersistNotifyReset((IAtsWorkItem) obj, AtsCore.getAttrResolver(), assigneesAdded);
+ postPersistNotifyReset((IAtsWorkItem) obj, AtsCore.getAttrResolver(), assigneesAdded,
+ workStateFactory);
} catch (OseeCoreException ex) {
OseeLog.log(AtsCore.class, Level.SEVERE, ex);
}
@@ -59,10 +61,10 @@ public class StateManagerStore {
};
}
- public static void load(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver) throws OseeCoreException {
+ public static void load(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver, IAtsWorkStateFactory workStateFactory) throws OseeCoreException {
StateManager stateManager = (StateManager) stateMgr;
stateManager.clear();
- StateManagerReader reader = new StateManagerReader(workItem, stateManager, attrResolver);
+ StateManagerReader reader = new StateManagerReader(workItem, stateManager, attrResolver, workStateFactory);
reader.load();
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerWriter.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerWriter.java
index 553e45fd72..3bb0a3e35a 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerWriter.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/StateManagerWriter.java
@@ -17,8 +17,8 @@ import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workdef.StateType;
import org.eclipse.osee.ats.api.workflow.IAttribute;
-import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
-import org.eclipse.osee.ats.core.workflow.state.AtsWorkStateFactory;
+import org.eclipse.osee.ats.api.workflow.WorkState;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
/**
@@ -30,19 +30,21 @@ public class StateManagerWriter {
private final IAtsWorkItem workItem;
private final StateManager stateMgr;
private final IAtsChangeSet changes;
+ private final IAtsWorkStateFactory workStateFactory;
- public StateManagerWriter(IAtsWorkItem workItem, StateManager stateMgr, IAttributeResolver attrResolver, IAtsChangeSet changes) {
+ public StateManagerWriter(IAtsWorkItem workItem, StateManager stateMgr, IAttributeResolver attrResolver, IAtsChangeSet changes, IAtsWorkStateFactory workStateFactory) {
this.workItem = workItem;
this.stateMgr = stateMgr;
this.attrResolver = attrResolver;
this.changes = changes;
+ this.workStateFactory = workStateFactory;
}
public void writeToStore() throws OseeCoreException {
String currentStateName = stateMgr.getCurrentStateName();
attrResolver.setSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState,
- AtsWorkStateFactory.toXml(stateMgr, currentStateName), changes);
+ workStateFactory.toStoreStr(stateMgr, currentStateName), changes);
removeCurrentStateAttributeIfExists(currentStateName, changes);
@@ -64,7 +66,7 @@ public class StateManagerWriter {
// Else, doesn't exist yet, create
if (!updated) {
attrResolver.addAttribute(workItem, AtsAttributeTypes.State,
- AtsWorkStateFactory.toXml(workItem.getStateMgr(), stateName), changes);
+ workStateFactory.toStoreStr(workItem.getStateMgr(), stateName), changes);
}
}
}
@@ -73,7 +75,7 @@ public class StateManagerWriter {
private void removeCurrentStateAttributeIfExists(String stateName, IAtsChangeSet changes) throws OseeCoreException {
Collection<IAttribute<String>> attrs = attrResolver.getAttributes(workItem, AtsAttributeTypes.State);
for (IAttribute<String> attr : attrs) {
- WorkStateImpl storedState = AtsWorkStateFactory.getFromXml(attr.getValue());
+ WorkState storedState = workStateFactory.fromStoreStr(attr.getValue());
if (stateName.equals(storedState.getName())) {
attrResolver.deleteAttribute(workItem, attr, changes);
}
@@ -84,10 +86,10 @@ public class StateManagerWriter {
// Update attribute if it already exists
Collection<IAttribute<String>> attrs = attrResolver.getAttributes(workItem, AtsAttributeTypes.State);
for (IAttribute<String> attr : attrs) {
- WorkStateImpl storedState = AtsWorkStateFactory.getFromXml(attr.getValue());
+ WorkState storedState = workStateFactory.fromStoreStr(attr.getValue());
if (stateName.equals(storedState.getName())) {
attrResolver.setValue(workItem, attr, AtsAttributeTypes.State,
- AtsWorkStateFactory.toXml(workItem.getStateMgr(), stateName), changes);
+ workStateFactory.toStoreStr(workItem.getStateMgr(), stateName), changes);
return true;
}
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/UsersByIds.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/UsersByIds.java
index 0bdf5251a8..f84051c0c3 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/UsersByIds.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/UsersByIds.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ats.core.users;
+package org.eclipse.osee.ats.core.internal.state;
import java.util.ArrayList;
import java.util.Collection;
@@ -23,13 +23,15 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
/**
+ * Pack and unpack userIds denoted by <userid><userid> string
+ *
* @author Donald G. Dunne
*/
public class UsersByIds {
- public static Pattern userPattern = Pattern.compile("<(.*?)>");
+ public Pattern userPattern = Pattern.compile("<(.*?)>");
- public static String getStorageString(Collection<IAtsUser> users) throws OseeCoreException {
+ public String getStorageString(Collection<IAtsUser> users) throws OseeCoreException {
StringBuffer sb = new StringBuffer();
for (IAtsUser u : users) {
sb.append("<" + u.getUserId() + ">");
@@ -37,7 +39,7 @@ public class UsersByIds {
return sb.toString();
}
- public static List<IAtsUser> getUsers(String sorageString) {
+ public List<IAtsUser> getUsers(String sorageString) {
List<IAtsUser> users = new ArrayList<IAtsUser>();
Matcher m = userPattern.matcher(sorageString);
while (m.find()) {
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/AtsWorkStateFactory.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/AtsWorkStateFactory.java
deleted file mode 100644
index 02ecf50956..0000000000
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/AtsWorkStateFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.core.workflow.state;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
-import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
-import org.eclipse.osee.ats.core.users.UsersByIds;
-import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Donald G. Dunne
- */
-public class AtsWorkStateFactory {
-
- public static Pattern storagePattern = Pattern.compile("^(.*?);(.*?);(.*?);(.*?)$");
-
- public static String toXml(IAtsStateManager stateMgr, String stateName) throws OseeCoreException {
- StringBuffer sb = new StringBuffer(stateName);
- sb.append(";");
- sb.append(UsersByIds.getStorageString(stateMgr.getAssignees(stateName)));
- sb.append(";");
- double hoursSpent = stateMgr.getHoursSpent(stateName);
- if (hoursSpent > 0) {
- sb.append(stateMgr.getHoursSpentStr(stateName));
- }
- sb.append(";");
- int percentComplete = stateMgr.getPercentComplete(stateName);
- if (percentComplete > 0) {
- sb.append(percentComplete);
- }
- return sb.toString();
- }
-
- public static WorkStateImpl getFromXml(String xml) throws OseeCoreException {
- WorkStateImpl state = new WorkStateImpl("Unknown");
- if (Strings.isValid(xml)) {
- Matcher m = storagePattern.matcher(xml);
- if (m.find()) {
- state.setName(m.group(1));
- if (!m.group(3).equals("")) {
- state.setHoursSpent(new Float(m.group(3)).doubleValue());
- }
- if (!m.group(4).equals("")) {
- state.setPercentComplete(Integer.valueOf(m.group(4)).intValue());
- }
- state.setAssignees(UsersByIds.getUsers(m.group(2)));
- } else {
- throw new OseeArgumentException("Can't unpack state data [%s]", xml);
- }
- }
- return state;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtility.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtility.java
index 85c203a137..b359ba7533 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtility.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/state/StateManagerUtility.java
@@ -11,31 +11,27 @@
package org.eclipse.osee.ats.core.workflow.state;
import java.util.Arrays;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.notify.AtsNotifyType;
+import org.eclipse.osee.ats.api.notify.IAtsNotificationService;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.util.IExecuteListener;
-import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workdef.IStateToken;
-import org.eclipse.osee.ats.api.workflow.IAttribute;
-import org.eclipse.osee.ats.api.workflow.log.IAtsLogItem;
-import org.eclipse.osee.ats.api.workflow.log.LogType;
+import org.eclipse.osee.ats.api.workflow.WorkState;
import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
+import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
import org.eclipse.osee.ats.core.AtsCore;
import org.eclipse.osee.ats.core.internal.state.StateManager;
import org.eclipse.osee.ats.core.internal.state.StateManagerReader;
import org.eclipse.osee.ats.core.internal.state.StateManagerWriter;
-import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.DateUtil;
import org.eclipse.osee.framework.logging.OseeLog;
/**
@@ -43,8 +39,6 @@ import org.eclipse.osee.framework.logging.OseeLog;
*/
public class StateManagerUtility {
- private static IExecuteListener postPersistExecutionListener;
-
/**
* Initializes state machine and sets the current state to stateName
*/
@@ -63,11 +57,11 @@ public class StateManagerUtility {
}
}
- public static Result isDirtyResult(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver) throws OseeCoreException {
+ public static Result isDirtyResult(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver, IAtsWorkStateFactory workStateFactory) throws OseeCoreException {
if (attrResolver.getAttributeCount(workItem, AtsAttributeTypes.CurrentState) == 0) {
return new Result(true, "StateManager: Current State new");
}
- if (!AtsWorkStateFactory.toXml(stateMgr, stateMgr.getCurrentStateName()).equals(
+ if (!workStateFactory.toStoreStr(stateMgr, stateMgr.getCurrentStateName()).equals(
attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.CurrentState, null))) {
return new Result(true, "StateManager: Current State modified");
}
@@ -75,15 +69,14 @@ public class StateManagerUtility {
if (!stateName.equals(stateMgr.getCurrentStateName())) {
boolean found = false;
// Update attribute if it already exists
- Collection<IAttribute<String>> attrs = attrResolver.getAttributes(workItem, AtsAttributeTypes.State);
- for (IAttribute<String> attr : attrs) {
- String attrValue = attr.getValue();
- WorkStateImpl storedState = AtsWorkStateFactory.getFromXml(attrValue);
+ for (String storedStateXml : attrResolver.getAttributesToStringList(workItem, AtsAttributeTypes.State)) {
+ WorkState storedState = workStateFactory.fromStoreStr(storedStateXml);
if (stateName.equals(storedState.getName())) {
found = true;
- if (!workItem.getStateMgr().isSame(storedState)) {
+ String currentStateXml = workStateFactory.toStoreStr(stateMgr, stateName);
+ if (!currentStateXml.equals(storedStateXml)) {
return new Result(true, String.format("StateManager: State [%s] modified was [%s] is [%s]",
- stateName, attrValue, AtsWorkStateFactory.toXml(workItem.getStateMgr(), stateName)));
+ stateName, storedStateXml, currentStateXml));
}
}
}
@@ -96,51 +89,43 @@ public class StateManagerUtility {
return Result.FalseResult;
}
- public static void writeToStore(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver, IAtsChangeSet changes) throws OseeCoreException {
- StateManagerWriter writer = new StateManagerWriter(workItem, (StateManager) stateMgr, attrResolver, changes);
+ public static void writeToStore(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver, IAtsChangeSet changes, IAtsWorkStateFactory workStateFactory, IAtsNotificationService notifyService) throws OseeCoreException {
+ StateManagerWriter writer =
+ new StateManagerWriter(workItem, (StateManager) stateMgr, attrResolver, changes, workStateFactory);
writer.writeToStore();
- changes.addExecuteListener(getPostPersistExecutionListener(attrResolver));
+ changes.addExecuteListener(getPostPersistExecutionListener(attrResolver, workStateFactory, notifyService));
}
- public static void postPersistNotifyReset(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver) throws OseeCoreException {
- AtsCore.getNotifyService().notify(workItem, stateMgr.getAssigneesAdded(), AtsNotifyType.Assigned);
- load(workItem, stateMgr, attrResolver);
+ static void postPersistNotifyReset(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver, IAtsWorkStateFactory workStateFactory, IAtsNotificationService notifyService) throws OseeCoreException {
+ notifyService.notify(workItem, stateMgr.getAssigneesAdded(), AtsNotifyType.Assigned);
+ load(workItem, stateMgr, attrResolver, workStateFactory);
}
- public static void load(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver) throws OseeCoreException {
+ public static void load(IAtsWorkItem workItem, IAtsStateManager stateMgr, IAttributeResolver attrResolver, IAtsWorkStateFactory workStateFactory) throws OseeCoreException {
StateManager stateManager = (StateManager) stateMgr;
stateManager.clear();
- StateManagerReader reader = new StateManagerReader(workItem, stateManager, attrResolver);
+ StateManagerReader reader = new StateManagerReader(workItem, stateManager, attrResolver, workStateFactory);
reader.load();
}
- public static IExecuteListener getPostPersistExecutionListener(final IAttributeResolver attrResolver) {
- if (postPersistExecutionListener == null) {
- postPersistExecutionListener = new IExecuteListener() {
+ static IExecuteListener getPostPersistExecutionListener(final IAttributeResolver attrResolver, final IAtsWorkStateFactory workStateFactory, final IAtsNotificationService notifyService) {
+ return new IExecuteListener() {
- @Override
- public void changesStored(IAtsChangeSet changes) {
- for (Object obj : changes.getObjects()) {
- if (obj instanceof IAtsWorkItem) {
- try {
- StateManagerUtility.postPersistNotifyReset((IAtsWorkItem) obj,
- ((IAtsWorkItem) obj).getStateMgr(), attrResolver);
- } catch (OseeCoreException ex) {
- OseeLog.log(AtsCore.class, Level.SEVERE, ex);
- }
+ @Override
+ public void changesStored(IAtsChangeSet changes) {
+ for (Object obj : changes.getObjects()) {
+ if (obj instanceof IAtsWorkItem) {
+ try {
+ IAtsWorkItem workItem = (IAtsWorkItem) obj;
+ StateManagerUtility.postPersistNotifyReset(workItem, workItem.getStateMgr(), attrResolver,
+ workStateFactory, notifyService);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AtsCore.class, Level.SEVERE, ex);
}
}
}
- };
- }
- return postPersistExecutionListener;
+ }
+ };
}
- public static String getCompletedDateByState(IAtsWorkItem workItem, IAtsStateDefinition state) throws OseeCoreException {
- IAtsLogItem stateEvent = workItem.getLog().getStateEvent(LogType.StateComplete, state.getName());
- if (stateEvent != null && stateEvent.getDate() != null) {
- return DateUtil.getMMDDYYHHMM(stateEvent.getDate());
- }
- return "";
- }
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/StateCompletedColumn.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/StateCompletedColumn.java
index 2e7c109148..f0918fbfa1 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/StateCompletedColumn.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/StateCompletedColumn.java
@@ -14,16 +14,19 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.nebula.widgets.xviewer.IXViewerValueColumn;
import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
+import org.eclipse.osee.ats.api.workflow.log.IAtsLogItem;
+import org.eclipse.osee.ats.api.workflow.log.LogType;
import org.eclipse.osee.ats.core.client.action.ActionManager;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
import org.eclipse.osee.ats.core.util.AtsObjects;
-import org.eclipse.osee.ats.core.workflow.state.StateManagerUtility;
import org.eclipse.osee.ats.util.xviewer.column.XViewerAtsColumn;
import org.eclipse.osee.ats.world.WorldXViewerFactory;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.DateUtil;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.framework.ui.skynet.util.LogUtil;
@@ -61,7 +64,7 @@ public class StateCompletedColumn extends XViewerAtsColumn implements IXViewerVa
AbstractWorkflowArtifact awa = (AbstractWorkflowArtifact) element;
IAtsStateDefinition state = awa.getStateDefinitionByName(stateName);
if (state != null) {
- String date = StateManagerUtility.getCompletedDateByState(awa, state);
+ String date = getCompletedDateByState(awa, state);
return date;
}
} else if (Artifacts.isOfType(element, AtsArtifactTypes.Action)) {
@@ -69,7 +72,7 @@ public class StateCompletedColumn extends XViewerAtsColumn implements IXViewerVa
for (TeamWorkFlowArtifact team : ActionManager.getTeams(element)) {
IAtsStateDefinition state = team.getStateDefinitionByName(stateName);
if (state != null) {
- String date = StateManagerUtility.getCompletedDateByState(team, state);
+ String date = getCompletedDateByState(team, state);
if (Strings.isValid(date)) {
dates.add(date);
}
@@ -84,6 +87,14 @@ public class StateCompletedColumn extends XViewerAtsColumn implements IXViewerVa
return "";
}
+ String getCompletedDateByState(IAtsWorkItem workItem, IAtsStateDefinition state) throws OseeCoreException {
+ IAtsLogItem stateEvent = workItem.getLog().getStateEvent(LogType.StateComplete, state.getName());
+ if (stateEvent != null && stateEvent.getDate() != null) {
+ return DateUtil.getMMDDYYHHMM(stateEvent.getDate());
+ }
+ return "";
+ }
+
public String getStateName() {
return stateName;
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/history/column/EventColumn.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/history/column/EventColumn.java
index c9364b08a8..9c4fac75b8 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/history/column/EventColumn.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/history/column/EventColumn.java
@@ -20,10 +20,10 @@ import org.eclipse.osee.ats.AtsImage;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.workdef.StateType;
-import org.eclipse.osee.ats.core.model.impl.WorkStateImpl;
+import org.eclipse.osee.ats.api.workflow.WorkState;
+import org.eclipse.osee.ats.core.AtsCore;
import org.eclipse.osee.ats.core.util.AtsObjects;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
-import org.eclipse.osee.ats.core.workflow.state.AtsWorkStateFactory;
import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -107,8 +107,8 @@ public class EventColumn extends XViewerValueColumn {
public String processCurrentStateChange(Change change) {
try {
- WorkStateImpl was = AtsWorkStateFactory.getFromXml(change.getWasValue());
- WorkStateImpl is = AtsWorkStateFactory.getFromXml(change.getIsValue());
+ WorkState was = AtsCore.getWorkStateFactory().fromStoreStr(change.getWasValue());
+ WorkState is = AtsCore.getWorkStateFactory().fromStoreStr(change.getIsValue());
if (change.getWasValue().equals("")) {
return "Created in [" + is.getName() + "] state";
} else if (!was.getName().equals(is.getName())) {
@@ -144,11 +144,11 @@ public class EventColumn extends XViewerValueColumn {
return "";
}
- private String getHoursSpent(WorkStateImpl state) {
+ private String getHoursSpent(WorkState state) {
return Strings.isValid(getHoursSpentStr(state)) ? getHoursSpentStr(state) : "0";
}
- public static String getHoursSpentStr(WorkStateImpl state) {
+ public static String getHoursSpentStr(WorkState state) {
return AtsUtilCore.doubleToI18nString(state.getHoursSpent(), true);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java
index 0f2650577d..25da4b486a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java
@@ -54,10 +54,14 @@ public class AttributeLoadProcessor extends LoadProcessor<AttributeData, Attribu
version.setStripeId(chStmt.getInt("stripe_transaction_id"));
}
- long typeId = chStmt.getLong("attr_type_id");
+ long typeId = chStmt.getLong("attr_type_id");
String value = chStmt.getString("value");
String uri = chStmt.getString("uri");
+ if (typeId == 167) {
+ System.err.println(String.format("Loading artId[%s] attrTypeId[%s] value[%s]", artId, typeId, value));
+ System.out.println("here");
+ }
toReturn = factory.createAttributeData(version, attrId, typeId, modType, artId, value, uri);

Back to the top