Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2017-08-21 20:36:45 -0400
committerdonald.g.dunne2017-08-28 17:15:23 -0400
commit2097e9ca7f9bf4cc4e2b08d8fe56e8df60179ee1 (patch)
tree13e499ce6cf4fd9c864fce61b30383d0425b6886
parent204a669ba0d50e5ff55cd32530653b1da9bf0d52 (diff)
downloadorg.eclipse.osee-2097e9ca7f9bf4cc4e2b08d8fe56e8df60179ee1.tar.gz
org.eclipse.osee-2097e9ca7f9bf4cc4e2b08d8fe56e8df60179ee1.tar.xz
org.eclipse.osee-2097e9ca7f9bf4cc4e2b08d8fe56e8df60179ee1.zip
refinement: Remove duplicate AtsStateManager in WorkItems
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java2
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateFactory.java5
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsTestUtilTest.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java10
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java16
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/state/AtsStateFactory.java28
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkItem.java8
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java10
8 files changed, 60 insertions, 23 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java
index 40b3e9f390..ad133e6224 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java
@@ -80,4 +80,6 @@ public interface IAtsStoreService {
boolean isDeleted(ArtifactId artifact);
+ TransactionId getTransactionId(IAtsWorkItem workItem);
+
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateFactory.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateFactory.java
index 3eb4ba64b0..9d42b2e5c3 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateFactory.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/state/IAtsStateFactory.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.ats.api.workflow.state;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.util.IAtsChangeSet;
+import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
/**
@@ -26,4 +27,8 @@ public interface IAtsStateFactory {
void load(IAtsWorkItem workItem, IAtsStateManager stateMgr);
+ void clearStateManager(Id id);
+
+ void setStateMgr(IAtsWorkItem workItem, IAtsStateManager stateMgr);
+
}
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsTestUtilTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsTestUtilTest.java
index 9435c4563c..51029d2a91 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsTestUtilTest.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsTestUtilTest.java
@@ -178,13 +178,13 @@ public class AtsTestUtilTest extends AtsTestUtil {
AtsTestUtil.transitionTo(AtsTestUtilState.Implement, AtsClientService.get().getUserService().getCurrentUser(),
changes, TransitionOption.OverrideAssigneeCheck, TransitionOption.OverrideTransitionValidityCheck);
Assert.assertEquals(Result.TrueResult, result);
- Assert.assertEquals(teamArt.getCurrentStateName(), TeamState.Implement.getName());
+ Assert.assertEquals(TeamState.Implement.getName(), teamArt.getCurrentStateName());
result =
AtsTestUtil.transitionTo(AtsTestUtilState.Completed, AtsClientService.get().getUserService().getCurrentUser(),
changes, TransitionOption.OverrideAssigneeCheck, TransitionOption.OverrideTransitionValidityCheck);
Assert.assertEquals(Result.TrueResult, result);
- Assert.assertEquals(teamArt.getCurrentStateName(), TeamState.Completed.getName());
+ Assert.assertEquals(TeamState.Completed.getName(), teamArt.getCurrentStateName());
teamArt.reloadAttributesAndRelations();
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
index 6df2b9d20d..90b7f6bb1a 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
@@ -221,4 +221,14 @@ public class AtsStoreService implements IAtsStoreService {
return true;
}
+ @Override
+ public TransactionId getTransactionId(IAtsWorkItem workItem) {
+ TransactionId transId = TransactionId.SENTINEL;
+ ArtifactId artifact = services.getArtifact(workItem.getStoreObject());
+ if (artifact instanceof Artifact) {
+ transId = ((Artifact) artifact).getTransaction();
+ }
+ return transId;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java
index 284c849903..ec401efc82 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java
@@ -86,8 +86,6 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple
protected ActionArtifact parentAction;
private IAtsLog atsLog;
private TransactionId atsLogTx;
- private TransactionId stateMgrTransactionNumber;
- private IAtsStateManager stateMgr;
public AbstractWorkflowArtifact(Long id, String guid, BranchId branch, ArtifactTypeId artifactType) {
super(id, guid, branch, artifactType);
@@ -156,7 +154,7 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple
parentAction = null;
parentAwa = null;
parentTeamArt = null;
- stateMgr = null;
+ AtsClientService.get().getStateFactory().clearStateManager(this);
atsLog = null;
}
@@ -670,15 +668,7 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple
@Override
public IAtsStateManager getStateMgr() {
- if (stateMgr == null || (getTransaction().isValid() && getTransaction().notEqual(stateMgrTransactionNumber))) {
- try {
- stateMgr = AtsClientService.get().getStateFactory().getStateManager(this);
- stateMgrTransactionNumber = getTransaction();
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- return stateMgr;
+ return AtsClientService.get().getStateFactory().getStateManager(this);
}
@Override
@@ -815,7 +805,7 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple
@Override
public void setStateMgr(IAtsStateManager stateMgr) {
- this.stateMgr = stateMgr;
+ AtsClientService.get().getStateFactory().setStateMgr(this, stateMgr);
}
}
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 5140123218..760aa41e08 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.internal.state;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.osee.ats.api.IAtsServices;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.user.IAtsUser;
@@ -18,6 +20,8 @@ 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.IAtsStateManager;
import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory;
+import org.eclipse.osee.framework.core.data.TransactionId;
+import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
/**
@@ -28,6 +32,8 @@ public class AtsStateFactory implements IAtsStateFactory {
private final IAtsWorkStateFactory workStateFactory;
private final IAtsLogFactory logFactory;
private final IAtsServices services;
+ Map<Id, IAtsStateManager> idToStateManager = new HashMap<>();
+ Map<Id, TransactionId> idToTransactionId = new HashMap<>();
public AtsStateFactory(IAtsServices services, IAtsWorkStateFactory workStateFactory, IAtsLogFactory logFactory) {
this.services = services;
@@ -37,8 +43,15 @@ public class AtsStateFactory implements IAtsStateFactory {
@Override
public IAtsStateManager getStateManager(IAtsWorkItem workItem) {
- StateManager stateMgr = new StateManager(workItem, logFactory, services);
- StateManagerStore.load(workItem, stateMgr, services.getAttributeResolver(), workStateFactory);
+ IAtsStateManager stateMgr = idToStateManager.get(workItem);
+ TransactionId transId = idToTransactionId.get(workItem);
+ TransactionId workItemTransaction = services.getStoreService().getTransactionId(workItem);
+ if (stateMgr == null || (workItemTransaction.isValid() && workItemTransaction.notEqual(transId))) {
+ stateMgr = new StateManager(workItem, logFactory, services);
+ idToStateManager.put(workItem, stateMgr);
+ idToTransactionId.put(workItem, services.getStoreService().getTransactionId(workItem));
+ StateManagerStore.load(workItem, stateMgr, services.getAttributeResolver(), workStateFactory);
+ }
return stateMgr;
}
@@ -53,4 +66,15 @@ public class AtsStateFactory implements IAtsStateFactory {
StateManagerStore.load(workItem, stateMgr, services.getAttributeResolver(), workStateFactory);
}
+ @Override
+ public void clearStateManager(Id id) {
+ idToStateManager.put(id, null);
+ }
+
+ @Override
+ public void setStateMgr(IAtsWorkItem workItem, IAtsStateManager stateMgr) {
+ idToStateManager.put(workItem, stateMgr);
+ idToTransactionId.put(workItem, services.getStoreService().getTransactionId(workItem));
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkItem.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkItem.java
index c7fc4d3114..224aebe0af 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkItem.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkItem.java
@@ -42,7 +42,6 @@ import org.eclipse.osee.logger.Log;
public class WorkItem extends AtsObject implements IAtsWorkItem {
protected final ArtifactToken artifact;
- private IAtsStateManager stateMgr;
private IAtsLog atsLog;
protected final IAtsServices services;
protected final Log logger;
@@ -128,10 +127,7 @@ public class WorkItem extends AtsObject implements IAtsWorkItem {
@Override
public IAtsStateManager getStateMgr() {
- if (stateMgr == null) {
- stateMgr = services.getStateFactory().getStateManager(this);
- }
- return stateMgr;
+ return services.getStateFactory().getStateManager(this);
}
@Override
@@ -276,7 +272,7 @@ public class WorkItem extends AtsObject implements IAtsWorkItem {
@Override
public void setStateMgr(IAtsStateManager stateMgr) {
- this.stateMgr = stateMgr;
+ services.getStateFactory().setStateMgr(this, stateMgr);
}
}
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java
index f5c407238e..e79e18fcf8 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java
@@ -206,4 +206,14 @@ public class AtsStoreServiceImpl implements IAtsStoreService {
return atsServer.getArtifact(artifact).isDeleted();
}
+ @Override
+ public TransactionId getTransactionId(IAtsWorkItem workItem) {
+ TransactionId transId = TransactionId.SENTINEL;
+ ArtifactId artifact = atsServer.getArtifact(workItem.getStoreObject());
+ if (artifact instanceof ArtifactReadable) {
+ transId = ((ArtifactReadable) artifact).getTransaction();
+ }
+ return transId;
+ }
+
}

Back to the top