on 04-26-2016 5:29 PM
Hello,
the following Import Action is working for one Job, but if I have a car-File with more than one JobDefinition I get an error message (attached file). What I have to Change so that the Action is working also for a bundle of JobDefinitions?
Import Action:
{
for (Java.util.Iterator it = jcsImportRuleSet.getObjects().iterator(); it.hasNext();)
{
Object o = (Object) it.next();
if (o instanceof JobDefinition)
{
JobDefinition jd = (JobDefinition) o;
JobDefinition jdNeu = jd.duplicate();
jdNeu.setName(jd.getName().replace("FIG","FIW"));
jdNeu.setDescription(jd.getDescription().replace("FIG";"FIW"));
jdNeu.setParentApplication(jcsSession.getApplicationByName(jd.getParentApplication().getName()replace("FIG","FIW")));
}
}
}
Best regards
Dana Ullrich
Hi Dana,
In this case I would use an array, jcsImportRuleSet.size() will give you the total number of objects, even if not all are JobDefinitions, should be fine to initialize as the size of the List.
so:
Object[] jd = new Object[jcsImportRuleSet.size()];
int i = 0;
for(....
{
Object jd[i] = (Object) it.next();
if ( jd[i].instanceOf JobDefinition )
{
...
}
i++;
}
}
It does not work because you are overwriting o each time, that creates a dirty dirty list ... 😉
Regards,
HP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dana,
My suspicion is that some of the object you try to create already exist in the target system. You cannot overwrite them like this. Maybe if you change your code like this it will work, but I would still doubt it. It is not really the way to do this.
{
for (Java.util.Iterator it = jcsImportRuleSet.getObjects().iterator(); it.hasNext();)
{
Object o = (Object) it.next();
if (o instanceof JobDefinition)
{
JobDefinition jd = (JobDefinition) o;
String neuName = jd.getName().replace("FIG","FIW");
JobDefinition jdNeu = jcsSession.getJobDefinitionByName(jd.getPartition(), neuName);
if (jdNeu != null)
{
jdNeu.deleteObject();
}
jdNeu = jd.duplicate();
jdNeu.setName(jd.getName().replace("FIG","FIW"));
jdNeu.setDescription(jd.getDescription().replace("FIG";"FIW"));
jdNeu.setParentApplication(jcsSession.getApplicationByName(jd.getParentApplication().getName()replace("FIG","FIW")));
}
}
}
Regards Gerben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.