diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (diff) | |
More code cleanup:
Refactored Entity Proxy Subscription to handle generics better
Rewrote RemoteMap to use TreeMap instead of the internal array for
order. It now sorts its keys by number if they parse, else as strings.
Removed a no-longer-in-progress outcome form class
Diffstat (limited to 'source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java')
| -rw-r--r-- | source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java index 32ca623..339e294 100644 --- a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java +++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java @@ -2,7 +2,6 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation; import java.util.ArrayList;
-import java.util.Iterator;
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.CannotManageException;
@@ -22,7 +21,7 @@ import com.c2kernel.utils.Logger; /**
* Complete Structure for new item
- *
+ *
* @version $Revision: 1.8 $ $Date: 2006/03/03 13:52:21 $
*/
public class NewItem {
@@ -48,31 +47,30 @@ public class NewItem { /**
* Field _aggregationList
*/
- public ArrayList aggregationList;
+ public ArrayList<?> aggregationList;
/**
* Field _dependencyList
*/
- public ArrayList dependencyList;
+ public ArrayList<?> dependencyList;
public NewItem() {
super();
propertyList = new ArrayList<Property>();
- aggregationList = new ArrayList();
- dependencyList = new ArrayList();
+ aggregationList = new ArrayList<Object>();
+ dependencyList = new ArrayList<Object>();
}
-
+
public NewItem(String name, String initialPath, String wf) {
this();
this.name = name;
this.initialPath = initialPath;
this.workflow = wf;
}
-
+
public void setProperty(String name, String value) {
- for (Iterator iter = propertyList.iterator(); iter.hasNext();) {
- Property prop = (Property) iter.next();
+ for (Property prop : propertyList) {
if (prop.name.equals(name)) {
prop.value = value;
return;
@@ -80,30 +78,29 @@ public class NewItem { }
propertyList.add(new Property(name, value));
}
-
+
protected void create(int agentId) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException {
DomainPath domPath = new DomainPath(new DomainPath(initialPath), name);
if (domPath.exists())
throw new ObjectAlreadyExistsException(domPath+" already exists!", "");
-
+
// create item
EntityPath entPath = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey();
TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entPath);
Gateway.getLDAPLookup().add(entPath);
-
+
// assemble properties
PropertyArrayList propList = new PropertyArrayList();
propList.list.add(new com.c2kernel.property.Property("Name", name));
- for (Iterator iter = propertyList.iterator(); iter.hasNext();) {
- Property element = (Property) iter.next();
+ for (Property element : propertyList) {
propList.list.add(new com.c2kernel.property.Property(element.name, element.value));
}
// init the new item
try {
-
+
// find workflow def
CompositeActivityDef compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, "last");
-
+
newItem.initialise(
agentId,
CastorXMLUtility.marshall(propList),
@@ -113,11 +110,11 @@ public class NewItem { Logger.error(ex);
throw new CannotManageException("Problem initialising new item. See server log.", "");
}
-
+
// create collections
-
- for (Iterator iter = dependencyList.iterator(); iter.hasNext();) {
- Dependency element = (Dependency) iter.next();
+
+ for (Object name2 : dependencyList) {
+ Dependency element = (Dependency) name2;
try {
Gateway.getStorage().put(entPath.getSysKey(), element.create(), null);
} catch (ClusterStorageException ex) {
@@ -128,9 +125,9 @@ public class NewItem { throw new CannotManageException("A specified member is not of the correct type in "+element.name, "");
}
}
-
- for (Iterator iter = aggregationList.iterator(); iter.hasNext();) {
- Aggregation element = (Aggregation) iter.next();
+
+ for (Object name2 : aggregationList) {
+ Aggregation element = (Aggregation) name2;
try {
Gateway.getStorage().put(entPath.getSysKey(), element.create(), null);
} catch (ClusterStorageException ex) {
@@ -140,6 +137,6 @@ public class NewItem { }
// register domain path
domPath.setEntity(entPath);
- Gateway.getLDAPLookup().add(domPath);
+ Gateway.getLDAPLookup().add(domPath);
}
}
|
