Re: {Spam?} RE: Starting Process
| Newsgroups | gmane.comp.java.enhydra.shark |
|---|---|
| Message-ID | <OF28D5BAE5.006C897C-ON85257047.005E388A-85257047.005EC3A8@intellicare.com> |
Hi Frans,
Here are two methods I wrote in my JSPAdmin class which creates a prcoess
and updates variables with values (given in a Map). This is of course
basically the same as what Neville has already given you, but it may be a
bit easier to use..
/**
* creates a process and sets some process variables
*
* @param packageId id of package
* @param processId id of process
* @param variablesAndValues Map of vars and vals
* @exception BaseException, InvalidData, UpdateNotAllowed,
AlreadyRunning, CannotStart
*/
public void createProcessAndUpdateVariables(
String packageId, String processId, Map
variablesAndValues) throws BaseException, InvalidData, UpdateNotAllowed,
AlreadyRunning, CannotStart{
WfProcess process = processCreate(packageId, processId);
Map processContext = process.process_context();
Set allKeys = variablesAndValues.keySet();
Iterator iterator = allKeys.iterator();
while (iterator.hasNext()) {
String nextVariable = (String) iterator.next();
if (processContext.containsKey(nextVariable)){
processContext.put(nextVariable,
variablesAndValues.get(nextVariable));
process.set_process_context(processContext);
}
else {
throw new BaseException("variable " +
nextVariable + " not found as a variable for this process");
}
}
process.start();
}
public WfProcess processCreate(String pkgId, String pDefId) throws
BaseException {
SharkConnection sConn = null; WfProcess process = null;
sConn = Shark.getInstance().getSharkConnection();
try {
//if (!isProcessRunning(pkgId, pDefId)) {
sConn.connect(userName, password,
engineName, null);
process = sConn.createProcess(pkgId,
pDefId);
sConn.disconnect();
//}
}
catch (Exception e) {
e.printStackTrace();
throw new BaseException(e);
}
return process;
}
hth,
Geeta
"Neville van Deventer" <[email protected]>
07/23/2005 10:21 AM
Please respond to
[email protected]
To
<[email protected]>
cc
Subject
{Spam?} RE: [shark] Starting Process
Hi Frans,
I'll Zap you a code snippet here, and put in a few comments on starting a
process with some variables ...
private static SharkMessage userNewProcess(
SharkConnection sConn,
SharkMessage sharkMessage ) {
String pkgId =
sharkMessage.getPackagename();
try { // This Part ensures that a
the package is loaded
if(!sharkPa.isPackageOpened(
sharkMessage.getPackagename() ))
pkgId =
sharkLoadPackage(
sharkMessage.getPackagename() );
else
pkgId =
sharkMessage.getPackagename();
} catch (Exception e3) {
pkgId = null;
}
if(pkgId == null) { // If the package is
now loaded,
terminate ...
sharkMessage.setResponse(
"ERROR" );
sharkMessage.setResult(
"Package failed to Open" );
return sharkMessage;
}
// This calls my participant mapping
generator, to ensure I
Have Mappings for every role in the XPDL
// as our role - participant
specifications.
if( !sharkCheckParticipantMappings(
pkgId,
sharkMessage.getProcessname() )){
logDebug("Missing
Mappings in Participants for
Package, Attempting to generate.");
sharkGenerateParticipantMappings();
if(!sharkCheckParticipantMappings( pkgId,
sharkMessage.getProcessname() )){
logDebug("Cannot Start Process, not all
participants are mapped.");
sharkMessage.setResponse( "ERROR" );
sharkMessage.setResult( "Package is missing
Participants" );
return
sharkMessage;
}
}
try {
// Create the process for
the user connection
WfProcess userProcess =
sConn.createProcess(pkgId,
sharkMessage.getProcessname());
// Create a new Map for
the variables which are
going onto the process
Map messageData = new
HashMap();
// Try to add pIn
Variable to the process
messageData.put("pIn",
sharkMessage.getRequest() );
try {
userProcess.set_process_context( messageData
);
} catch (Exception e) {}
messageData =
userProcess.process_context();
// Try to add pUser
Variable to the Process
messageData.put("pUser",
sharkMessage.getUsername()
);
try {
userProcess.set_process_context( messageData
);
} catch (Exception e) {}
// Start the Process
userProcess.start();
// Get the resultant
Variables after the process has
started
messageData =
userProcess.process_context();
// Sets my message
variables which get returnes via
a webservice, back to my MVC
sharkMessage.setProcesskey( userProcess.key() );
sharkMessage.setActivitykey( "" );
sharkMessage.setResponse(
(String)messageData.get("pStat"));
sharkMessage.setResult(
(String)messageData.get("pOut"));
sharkMessage.setRequest(
"" );
} catch (Exception e) { // Of course if
anything goes wrong,
there is a error ....
sharkMessage.setResponse(
"ERROR" );
sharkMessage.setResult(
"Could not start process: "
+ e.getMessage() );
return sharkMessage;
}
return sharkMessage;
}
Hope this snippet helps with starting your processes ...
Neville van Deventer
-----Original Message-----
From: Frans Thamura [mailto:[email protected]]
Sent: 23 July 2005 01:00 PM
To: [email protected]
Subject: [shark] Starting Process
Hi All,
Now I am starting to create an instantiation.
i got there is 3 procedure in processStart
public static void processStart(String mgrName) public static void
processStart(String mgrName, SharkConnection sConn) public static void
processStart(String pkgId, String pDefId)
because i am still new in Shark, anyone can help?
I want to make an instantiate with automatic start this mean will make the
state open.running.
and after the state running, i want to inject the variable, so all the
next
user for approval just approve.
i got this procedure
public static void variableSet(SharkConnection sConn,
String activityId,
String vName,
String vValue)
but i still cannot understand, what happen if all the variable in XPDL
is more than 1,
anyone can help this concept?
Frans
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
You receive this message as a subscriber of the [email protected]
mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
CONFIDENTIALITY NOTICE:This email is intended solely for the person or
entity to which it is addressed and may contain confidential and/or
protected health information. Any duplication, dissemination, action
taken in reliance upon, or other use of this information by persons or
entities other than the intended recipient is prohibited and may violate
applicable laws. If this email has been received in error, please notify
the sender and delete the information from your system. The views
expressed in this email are those of the sender and may not necessarily
represent the views of IntelliCare.
message-footer.txt
(text/plain, 271 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws