Re: Retrieving an existing workflow instance variables?
Jon Wilmoth <[email protected]>
| Newsgroups | gmane.comp.java.open-symphony.devel |
|---|---|
| Message-ID | <[email protected]> |
First of all how do the "transientVars" and the
"propertySet" you used in your examples relate to the
three variables (inputs, args, and variables) that are
described in the documentation? Are they additional
variables that are available to all functions? Only
available in an initial action function? What type
are these variables?
Is it possible to copy all inputs in the initial
action with a prefunction definition like this
(assumes the "propertySet" variable is of type
com.opensymphony.module.propertyset.PropertySet)?
<pre-functions>
<function type="beanshell">
<arg name="script">
import java.util.Iterator;
Iterator keysIterator =
transientVars.keySet().iterator();
String currentKey = null;
while (keysIterator.hasNext()) {
currentKey = keysIterator.hasNext();
propertySet.setAsActualType(currentKey,
transientVars.get(currentKey));
}
</arg>
</function>
</pre-functions>
Also, your example describes how to access these
persisted values within the workflow definition
document, but how do you access them from the java
api's? I see there are two methods that could be used
to retrieved persisted values, but I'm not sure of the
difference/intent of each. Is one from persistence
and the other from memory? If it's from memory, where
is it initialized?
Can someone describe the difference between these two
apis:
java.util.Map
com.opensymphony.workflow.Workflow.getVariableMap(long
id)
and
com.opensymphony.module.propertyset.PropertySet
com.opensymphony.workflow.spi.WorkflowStore.getPropertySet(long
entryId)
Thanks,
Jon
p.s. I truly impressed with the implementation so far.
The questions I'm asking are merely efforts to get up
to speed and perhaps make it easier for others along
the way.
Date: Sun, 25 May 2003 12:00:19 +0200
From: "Hubert Felber" <[email protected]>
To: <[email protected]>
Subject: Re: [Opensymphony-developers] Retrieving an
existing workflow instance variables?
>>> Jon Wilmoth <[email protected]> 05/23/03
09:44pm >>>
>I need to store information with a particular
workflow
>instance. If I'm correct in my assessment of the
API,
>it appears that workflow instances can be saved with
>data via the Workflow.initialize(long, int,
>java.util.Map) method. I would assume the Map of
>inputs is stored in the OS_PROPERTYENTRY table. Is
>this true? =20
No, the initialize function copies all variables from
the inputs map to
=
the transientVars map. They can be accessed only
within the initial
action =
by their names in the form of: ${variable}
make them persistent with:
<pre-functions>
<function type=3D"beanshell">
<arg name=3D"script">
propertySet.setString("myvariable","${variablename}");
// assumes =
string variable here
</arg>
</function>
</pre-functions>
copy it to the transientVars map where you need it,
for strings this
can =
be done with
<function type=3D"beanshell">
<arg name=3D"script">
transientVars.put("myvariable",propertySet.GetString("myvariable"));
</arg>
</function>
Then you can access it in the the workflow with
${myvariable}.
Remember, =
variables in the transientVars map are only existent
within the same =
sequence. For every transition, the transientVars map
is cleared and =
populated again. Check AbstractWorkflow.java for more
info.
Hubert
=====
Thanks,
Jon Wilmoth
======================
[email protected] (text msg),
[email protected]
206-369-5669
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge