RE: Starting Process

"Neville van Deventer" <[email protected]>
Newsgroups gmane.comp.java.enhydra.shark
Message-ID <[email protected]>
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
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.