|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 3 of 7
package workflow.example;
/* Generated by Together */
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.*;
import java.util.*;
import java.io.*;
import workflow.*;
/**
* The XMLDispatcher uses its transformer to determine workflow
*/
public class XMLDispatcher extends AbstractDispatcher{
public XMLDispatcher(Transformer transformer)
{
this.transformer = transformer;
}
/**
* The implementation of the next method uses XML that represents
* the dispatchable object and the XSL transformation to determine
* the next step in a workflow.
* @param parameters any parameters that need to be handed
* to the transformer by the client
* @param obj the dispatchable object
* @param current the current screen the user is on (that
* keeps this process stateless).
* @return the name of the next step of the workflow
*/
public String next(HashMap parameters, Dispatchable obj,
String current) throws Exception {
transformer.clearParameters();
String next = "";
StringWriter writer = new StringWriter();
//If there aren't any parameters, we'll create our own default ones
if ( parameters == null )
{
parameters = new HashMap();
parameters.put("usercurrent", current);
}
System.out.println(parameters);
System.out.println(obj.toXML());
//Add the parameters to the transformer
Iterator paramKeys = parameters.keySet().iterator();
while (paramKeys.hasNext())
{
String key = (String)paramKeys.next();
transformer.setParameter(key, parameters.get(key));
}
//Perform the transformation
transformer.transform(new StreamSource
(new StringReader(obj.toXML())), new StreamResult(writer) );
next = writer.getBuffer().toString();
//Strip excess information
if ( next.indexOf("?>") > 0 )
next = next.substring(next.indexOf("?>") + 2, next.length());
next = next.trim();
//Return the next screen
return next;
}
private Transformer transformer;
}
To demonstrate the XMLDispatcher in practice, consider the following scenario:
To attract less computer-savvy employment candidates, a company wants to replace its old, complicated Web-based employment application with an easier-to-use form. With its original Web application, candidates filled out an online form at a kiosk at the company's main office. Candidates, however, complained that the form's great length and the effort involved in filling it out prompted them to give up in frustration.
To improve the candidate experience, the original single application will be broken into several pages, allowing the candidate to step through them and finally submit her application. Moreover, as a system requirement, the new application must be easily modifiable so it won't be difficult to add or remove screens. Reusability will also come into play when the company recreates several of its long, Web-based forms.
Based on those considerations, the redesigned employment form's workflow will be:
Figure 4 shows the flow graphically.