Re: Retrieving an existing workflow instance variables?
Hani Suleiman <[email protected]>
| Newsgroups | gmane.comp.java.open-symphony.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tuesday, May 27, 2003, at 02:02 PM, Jon Wilmoth wrote:
> 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?
>
'variables' is gone from the current cvs version, it's all propertyset
now. The import concept here is that we have 3 different sets of
collections. One is a PropertySet which is a persistent collection of
properties, the other (transientVars) is a collection of transient
variables, that can be set as a way to pass information around during
the execution of a step. They are not stored in a database or
persisted. Inputs is the third type, which is a map of input parameters
that the caller can send to the workflow when initialising it or
executing an action. The inputs are copied to transientVars, and that's
how code can access them.
> 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>
>
Yep!
>
> 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?
>
All the interfaces take in a PropertySet parameter, which you can add
stuff to as the urge takes you. You also get the inputs as a parameter.
This is for function providers and suchlike. For 'client' code, you
would call getPropertySet(). There is no equivelant for
inputs/transientVars because it would be meaningless, as these do not
exist outside of a single workflow invocation.
> java.util.Map
> com.opensymphony.workflow.Workflow.getVariableMap(long
> id)
> and
> com.opensymphony.module.propertyset.PropertySet
> com.opensymphony.workflow.spi.WorkflowStore.getPropertySet(long
> entryId)
>
>
getVariableMap is gone, the latest CVS version replaces this with
getPropertySet(). The functionality they provide is identical, except
that the variable maap code was terrible for performance so it was
scrapped and the propertyset directly exposed.
-------------------------------------------------------
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