diff options
author | donald.g.dunne | 2017-04-27 21:16:24 +0000 |
---|---|---|
committer | Donald Dunne | 2017-04-28 17:56:29 +0000 |
commit | 1146c449adb5a2e30c43f083a3caed63eb856243 (patch) | |
tree | 2516d5306f65177cb0b3373ed60ca8b17b8a1975 /plugins/org.eclipse.osee.ats.core.client | |
parent | 15b4bdf2f0ceaaf53e2be83d9aac5bf84724fbc0 (diff) | |
download | org.eclipse.osee-1146c449adb5a2e30c43f083a3caed63eb856243.tar.gz org.eclipse.osee-1146c449adb5a2e30c43f083a3caed63eb856243.tar.xz org.eclipse.osee-1146c449adb5a2e30c43f083a3caed63eb856243.zip |
bug[ats_ATS367724]: Duplicate ATS notification records
Change-Id: I5c73ff6d698a0f9ac79f67b206a878bf22ba8c8e
Diffstat (limited to 'plugins/org.eclipse.osee.ats.core.client')
-rw-r--r-- | plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/store/AtsChangeSet.java | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/store/AtsChangeSet.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/store/AtsChangeSet.java index 69d345d91d4..a836fa012d6 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/store/AtsChangeSet.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/store/AtsChangeSet.java @@ -69,15 +69,15 @@ public class AtsChangeSet extends AbstractAtsChangeSet { @Override public TransactionId execute() throws OseeCoreException { Conditions.checkNotNull(comment, "comment"); - if (objects.isEmpty() && deleteObjects.isEmpty() && execptionIfEmpty) { + if (isEmpty() && execptionIfEmpty) { throw new OseeArgumentException("objects/deleteObjects cannot be empty"); } SkynetTransaction transaction = TransactionManager.createTransaction(AtsClientService.get().getAtsBranch(), comment); // First, create or update any artifacts that changed - for (Object obj : new ArrayList<>(objects)) { - if (obj instanceof IAtsWorkItem) { - IAtsWorkItem workItem = (IAtsWorkItem) obj; + for (IAtsObject atsObject : new ArrayList<>(atsObjects)) { + if (atsObject instanceof IAtsWorkItem) { + IAtsWorkItem workItem = (IAtsWorkItem) atsObject; if (workItem.getStateMgr().isDirty()) { AtsClientService.get().getStateFactory().writeToStore(asUser, workItem, this); } @@ -86,27 +86,26 @@ public class AtsChangeSet extends AbstractAtsChangeSet { AtsClientService.get().getAttributeResolver(), this); } } - - if (obj instanceof Artifact) { - transaction.addArtifact((Artifact) obj); - } else if (obj instanceof IAtsObject && ((IAtsObject) obj).getStoreObject() instanceof Artifact) { - transaction.addArtifact((Artifact) ((IAtsObject) obj).getStoreObject()); + transaction.addArtifact((Artifact) atsObject.getStoreObject()); + } + for (ArtifactId artifact : artifacts) { + if (artifact instanceof Artifact) { + transaction.addArtifact((Artifact) artifact); } } // Second, add or delete any relations; this has to be done separate so all artifacts are created - for (Object obj : objects) { - if (obj instanceof AtsRelationChange) { - execute((AtsRelationChange) obj, transaction); - } + for (AtsRelationChange rel : relations) { + execute(rel, transaction); } // Third, delete any desired objects - for (Object obj : deleteObjects) { - if (obj instanceof Artifact) { - ((Artifact) obj).deleteAndPersist(transaction); - } else { - throw new OseeArgumentException("ATsChangeSet: Unhandled deleteObject type: " + obj); + for (ArtifactId artifact : deleteArtifacts) { + if (artifact instanceof Artifact) { + ((Artifact) artifact).deleteAndPersist(transaction); } } + for (IAtsObject atsObject : deleteAtsObjects) { + ((Artifact) atsObject.getStoreObject()).deleteAndPersist(transaction); + } TransactionId transactionRecord = transaction.execute(); for (IExecuteListener listener : listeners) { listener.changesStored(this); @@ -175,17 +174,6 @@ public class AtsChangeSet extends AbstractAtsChangeSet { return art; } - public void addTo(SkynetTransaction transaction) throws OseeCoreException { - Conditions.checkNotNull(transaction, "transaction"); - for (Object obj : objects) { - if (obj instanceof Artifact) { - ((Artifact) obj).persist(transaction); - } else { - throw new OseeArgumentException("Unhandled object type"); - } - } - } - public static TransactionId execute(String comment, Object object, Object... objects) throws OseeCoreException { IAtsChangeSet changes = AtsClientService.get().createChangeSet(comment); changes.add(object); |