Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2013-12-13 21:48:04 +0000
committerRoberto E. Escobar2014-01-08 18:31:11 +0000
commit0d2bed8fa12797be66054d1b5989677460e48caf (patch)
treefcae152bfa1f9861aed245472e5d3da3b0b78050 /plugins
parenteaaa2acffbef0240b2c5e0c575c547d002c33fd8 (diff)
downloadorg.eclipse.osee-0d2bed8fa12797be66054d1b5989677460e48caf.tar.gz
org.eclipse.osee-0d2bed8fa12797be66054d1b5989677460e48caf.tar.xz
org.eclipse.osee-0d2bed8fa12797be66054d1b5989677460e48caf.zip
bug[ats_ATS4869]: Create AbstractAtsChangeSet
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java68
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java102
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java70
3 files changed, 109 insertions, 131 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java
index 50ba8907ce6..bcbbaad24cb 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java
@@ -10,15 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.client.util;
-import java.util.HashSet;
-import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.osee.ats.api.IAtsWorkItem;
-import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.util.IExecuteListener;
import org.eclipse.osee.ats.api.workflow.IAttribute;
import org.eclipse.osee.ats.core.AtsCore;
import org.eclipse.osee.ats.core.client.internal.AtsClientService;
+import org.eclipse.osee.ats.core.util.AbstractAtsChangeSet;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
@@ -32,38 +30,10 @@ import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
/**
* @author Donald G. Dunne
*/
-public class AtsChangeSet implements IAtsChangeSet {
-
- private String comment;
- private final Set<Object> objects = new HashSet<Object>();
- private final Set<Object> deleteObjects = new HashSet<Object>();
- private final Set<IExecuteListener> listeners = new HashSet<IExecuteListener>();
+public class AtsChangeSet extends AbstractAtsChangeSet {
public AtsChangeSet(String comment) {
- this.comment = comment;
- }
-
- @Override
- public void add(Object obj) throws OseeCoreException {
- Conditions.checkNotNull(obj, "object");
- objects.add(obj);
- }
-
- @Override
- public void addAll(Object... objects) throws OseeCoreException {
- Conditions.checkNotNull(objects, "objects");
- for (Object obj : objects) {
- if (obj == null) {
- throw new OseeArgumentException("object can't be null");
- }
- this.objects.add(obj);
- }
- }
-
- @Override
- public void addToDelete(Object obj) throws OseeCoreException {
- Conditions.checkNotNull(obj, "object");
- deleteObjects.add(obj);
+ super(comment, null);
}
@Override
@@ -104,22 +74,6 @@ public class AtsChangeSet implements IAtsChangeSet {
}
}
- @Override
- public Set<Object> getObjects() {
- return objects;
- }
-
- public void setComment(String comment) {
- this.comment = comment;
- }
-
- @Override
- public void clear() {
- objects.clear();
- deleteObjects.clear();
- listeners.clear();
- }
-
public void addTo(SkynetTransaction transaction) throws OseeCoreException {
Conditions.checkNotNull(transaction, "transaction");
for (Object obj : objects) {
@@ -131,22 +85,6 @@ public class AtsChangeSet implements IAtsChangeSet {
}
}
- public void reset(String comment) {
- clear();
- this.comment = comment;
- }
-
- @Override
- public boolean isEmpty() {
- return objects.isEmpty() && deleteObjects.isEmpty();
- }
-
- @Override
- public void addExecuteListener(IExecuteListener listener) {
- Conditions.checkNotNull(listener, "listener");
- listeners.add(listener);
- }
-
public static void execute(String comment, Object object, Object... objects) throws OseeCoreException {
AtsChangeSet changes = new AtsChangeSet(comment);
changes.add(object);
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java
new file mode 100644
index 00000000000..f648586c621
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+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.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+
+/**
+ * @author Donald G. Dunne
+ */
+public abstract class AbstractAtsChangeSet implements IAtsChangeSet {
+
+ protected String comment;
+ protected final Set<Object> objects = new HashSet<Object>();
+ protected final Set<Object> deleteObjects = new HashSet<Object>();
+ protected final Set<IExecuteListener> listeners = new HashSet<IExecuteListener>();
+ protected final IAtsUser user;
+
+ public AbstractAtsChangeSet(String comment, IAtsUser user) {
+ this.comment = comment;
+ this.user = user;
+ }
+
+ @Override
+ public void add(Object obj) throws OseeCoreException {
+ Conditions.checkNotNull(obj, "object");
+ if (obj instanceof Collection) {
+ objects.addAll((Collection<?>) obj);
+ } else {
+ objects.add(obj);
+ }
+ }
+
+ @Override
+ public void addAll(Object... objects) throws OseeCoreException {
+ Conditions.checkNotNull(objects, "objects");
+ for (Object obj : objects) {
+ add(obj);
+ }
+ }
+
+ @Override
+ public Set<Object> getObjects() {
+ return objects;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public void clear() {
+ objects.clear();
+ deleteObjects.clear();
+ listeners.clear();
+ }
+
+ public void reset(String comment) {
+ clear();
+ this.comment = comment;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return objects.isEmpty() && deleteObjects.isEmpty();
+ }
+
+ @Override
+ public void addExecuteListener(IExecuteListener listener) {
+ Conditions.checkNotNull(listener, "listener");
+ listeners.add(listener);
+ }
+
+ @Override
+ public void addToDelete(Object obj) throws OseeCoreException {
+ Conditions.checkNotNull(obj, "object");
+ if (obj instanceof Collection) {
+ deleteObjects.addAll((Collection<?>) obj);
+ } else {
+ deleteObjects.add(obj);
+ }
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java
index e7c3850a262..b35d93f6730 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java
@@ -10,16 +10,14 @@
*******************************************************************************/
package org.eclipse.osee.ats.impl.internal.util;
-import java.util.HashSet;
-import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
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.ats.api.util.IExecuteListener;
import org.eclipse.osee.ats.api.workflow.IAttribute;
import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
import org.eclipse.osee.ats.core.AtsCore;
+import org.eclipse.osee.ats.core.util.AbstractAtsChangeSet;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.impl.internal.AtsServerService;
import org.eclipse.osee.framework.core.data.IAttributeType;
@@ -33,24 +31,12 @@ import org.eclipse.osee.orcs.transaction.TransactionBuilder;
/**
* @author Donald G. Dunne
*/
-public class AtsChangeSet implements IAtsChangeSet {
+public class AtsChangeSet extends AbstractAtsChangeSet {
- private String comment;
- private final Set<Object> objects = new HashSet<Object>();
- private final Set<Object> deleteObjects = new HashSet<Object>();
private TransactionBuilder transaction;
- private final Set<IExecuteListener> listeners = new HashSet<IExecuteListener>();
- private final IAtsUser user;
public AtsChangeSet(String comment, IAtsUser user) {
- this.comment = comment;
- this.user = user;
- }
-
- @Override
- public void add(Object obj) throws OseeCoreException {
- Conditions.checkNotNull(obj, "object");
- objects.add(obj);
+ super(comment, user);
}
public TransactionBuilder getTransaction() throws OseeCoreException {
@@ -70,10 +56,6 @@ public class AtsChangeSet implements IAtsChangeSet {
user.getGuid()).getResults().getExactlyOne();
}
- public IAtsStateManager getStateMgr(IAtsWorkItem workItem) {
- return workItem.getStateMgr();
- }
-
@Override
public void execute() throws OseeCoreException {
Conditions.checkNotNull(comment, "comment");
@@ -83,7 +65,7 @@ public class AtsChangeSet implements IAtsChangeSet {
for (Object obj : new CopyOnWriteArrayList<Object>(objects)) {
if (obj instanceof IAtsWorkItem) {
IAtsWorkItem workItem = (IAtsWorkItem) obj;
- IAtsStateManager stateMgr = getStateMgr(workItem);
+ IAtsStateManager stateMgr = workItem.getStateMgr();
if (stateMgr.isDirty()) {
AtsCore.getStateFactory().writeToStore(workItem, this);
}
@@ -116,32 +98,6 @@ public class AtsChangeSet implements IAtsChangeSet {
}
@Override
- public Set<Object> getObjects() {
- return objects;
- }
-
- public void setComment(String comment) {
- this.comment = comment;
- }
-
- @Override
- public void clear() {
- objects.clear();
- }
-
- public void reset(String comment) {
- clear();
- this.comment = comment;
- this.transaction = null;
- this.objects.clear();
- }
-
- @Override
- public boolean isEmpty() {
- return objects.isEmpty();
- }
-
- @Override
public void deleteSoleAttribute(IAtsWorkItem workItem, IAttributeType attributeType) throws OseeCoreException {
getTransaction().deleteSoleAttribute(AtsUtilCore.toArtifactId(workItem), attributeType);
}
@@ -178,24 +134,6 @@ public class AtsChangeSet implements IAtsChangeSet {
}
@Override
- public void addExecuteListener(IExecuteListener listener) {
- listeners.add(listener);
- }
-
- @Override
- public void addToDelete(Object obj) throws OseeCoreException {
- Conditions.checkNotNull(obj, "object");
- deleteObjects.add(obj);
- }
-
- @Override
- public void addAll(Object... objects) throws OseeCoreException {
- for (Object obj : objects) {
- this.objects.add(obj);
- }
- }
-
- @Override
public boolean isAttributeTypeValid(IAtsWorkItem workItem, IAttributeType attributeType) {
ArtifactReadable artifact = AtsServerService.get().getArtifact(workItem);
return artifact.getValidAttributeTypes().contains(attributeType);

Back to the top