diff options
| author | abranson <andrew.branson@cern.ch> | 2012-03-13 15:56:08 +0100 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2012-03-13 15:56:08 +0100 |
| commit | 1cc31e428b2e52898ca7b77cb3b4b51779810ab5 (patch) | |
| tree | 3eca2a79c1e786f932f8344ae9a77583f574beac /source/com | |
| parent | 6775b5fc7de8884577533fa84ac703366539e043 (diff) | |
Imply 'Name' property on instantiation if not explicity declared
Diffstat (limited to 'source/com')
| -rw-r--r-- | source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java b/source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java index 71c468d..8c55f3a 100644 --- a/source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java +++ b/source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java @@ -35,7 +35,6 @@ import com.c2kernel.persistency.TransactionManager; import com.c2kernel.process.Gateway;
import com.c2kernel.property.Property;
import com.c2kernel.property.PropertyArrayList;
-import com.c2kernel.property.PropertyDescription;
import com.c2kernel.property.PropertyDescriptionList;
import com.c2kernel.property.PropertyUtility;
import com.c2kernel.utils.CastorXMLUtility;
@@ -116,14 +115,16 @@ public class CreateItemFromDescription extends PredefinedStep // copy properties -- intend to create from propdesc
PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(myPath.getSysKey());
- for (int i = 0; i < pdList.list.size(); i++) {
- PropertyDescription pd = pdList.list.get(i);
- String propName = pd.getName();
- String propVal = pd.getDefaultValue();
- if (propName.equals("Name"))
- propVal = newName;
- props.list.add( new Property(propName, propVal));
- }
+ props = pdList.instanciate();
+ // set Name prop or create if not present
+ boolean foundName = false;
+ for (Property prop : props.list) {
+ if (prop.getName().equals("Name")) {
+ foundName = true;
+ prop.setValue(newName);
+ }
+ }
+ if (!foundName) props.list.add(new Property("Name", newName));
props.list.add( new Property("Creator", agent.getAgentName()));
/* ITEM CREATION */
|
