use of org.wso2.carbon.humantask.client.api.IllegalStateFault in project carbon-business-process by wso2.
the class TaskOperationsImpl method deleteFault.
/**
* Deletes the fault name and fault data of the task.
* @param taskIdURI : task identifier
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public void deleteFault(final URI taskIdURI) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
final Long taskId = validateTaskId(taskIdURI);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
DeleteFault deleteFaultCommand = new DeleteFault(getCaller(), taskId);
deleteFaultCommand.execute();
return null;
}
});
} catch (Exception ex) {
handleException(ex);
}
}
use of org.wso2.carbon.humantask.client.api.IllegalStateFault in project carbon-business-process by wso2.
the class TaskOperationsImpl method skip.
/**
* Skip the task.
* @param taskIdURI : task identifier
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public void skip(URI taskIdURI) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
final Long taskId = validateTaskId(taskIdURI);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
Skip skipCommand = new Skip(getCaller(), taskId);
skipCommand.execute();
return null;
}
});
} catch (Exception ex) {
handleException(ex);
}
}
use of org.wso2.carbon.humantask.client.api.IllegalStateFault in project carbon-business-process by wso2.
the class TaskOperationServiceImpl method start.
public void start(final URI taskId) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
validateTaskId(taskId);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
Start startCommand = new Start(getCaller(), new Long(taskId.toString()));
startCommand.execute();
return null;
}
});
} catch (Exception ex) {
handleException(ex);
}
}
use of org.wso2.carbon.humantask.client.api.IllegalStateFault in project carbon-business-process by wso2.
the class HTQueryBuildHelperImpl method getTaskInstanceCountsByState.
/**
* @param taskName
* @return
* @throws IllegalAccessFault
* @throws IllegalArgumentFault
* @throws IllegalStateFault
* @throws IllegalOperationFault
*/
public String[] getTaskInstanceCountsByState(String taskName) throws Exception {
int statusCount = 0;
TPredefinedStatus.Enum[] statuses;
int statusesSize = TPredefinedStatus.Enum.table.lastInt();
statuses = new TPredefinedStatus.Enum[statusesSize];
String[] statusCounts = new String[statusesSize];
for (int i = 0; i < statusesSize; i++) {
statuses[i] = TPredefinedStatus.Enum.forInt(i + 1);
}
Boolean isTaskName = false;
Pattern p = Pattern.compile("-[0-9]+$");
Matcher m = p.matcher(taskName);
isTaskName = m.find();
if (isTaskName) {
for (int i = 0; i < statuses.length; i++) {
statusCount = getTaskCountsForStateAndTaskName(taskName, statuses[i]);
statusCounts[i] = " " + statuses[i].toString() + " " + statusCount;
}
} else {
for (int i = 0; i < statuses.length; i++) {
statusCount = getTaskCountsForStateAndTaskDefName(taskName, statuses[i]);
statusCounts[i] = " " + statuses[i].toString() + " " + statusCount;
}
}
return statusCounts;
}
use of org.wso2.carbon.humantask.client.api.IllegalStateFault in project carbon-business-process by wso2.
the class HTRenderingApiImpl method getRenderingOutputElements.
/**
* Function to retrieve output rendering elements
*
* @param taskIdentifier interested task identifier
* @return set of output renderings wrapped within OutputType
* @throws IllegalArgumentFault error occured while retrieving renderings from task definition
* @throws IOException If an error occurred while reading from the input source
* @throws SAXException If the xml content in the input source is invalid
* @throws IllegalOperationFault
* @throws IllegalAccessFault
* @throws IllegalStateFault
* @throws XPathExpressionException If error occurred while xpath evaluation
* @throws GetRenderingsFaultException If unable to find unique id for the wso2:output rendering element
*/
private OutputType getRenderingOutputElements(URI taskIdentifier) throws IllegalArgumentFault, IOException, SAXException, IllegalOperationFault, IllegalAccessFault, IllegalStateFault, XPathExpressionException, GetRenderingsFaultException {
QName renderingType = new QName(htRenderingNS, "output", "wso2");
String outputRenderings = (String) taskOps.getRendering(taskIdentifier, renderingType);
// create output element
OutputType renderingOutputs = null;
// check availability of output renderings
if (outputRenderings != null && outputRenderings.length() > 0) {
// parse output renderings
Element outputRenderingsElement = DOMUtils.stringToDOM(outputRenderings);
// retrieve output rendering elements
NodeList outputElementList = outputRenderingsElement.getElementsByTagNameNS(htRenderingNS, "element");
if (outputElementList != null && outputElementList.getLength() > 0) {
int outputElementNum = outputElementList.getLength();
OutputElementType[] outputElements = new OutputElementType[outputElementNum];
// TODO get task output message from the cache
// (if not in the cache) retrieve saved output using HumanTaskClientAPI
String savedOutputMsg = (String) taskOps.getOutput(taskIdentifier, null);
// Element to hold parsed saved output message
Element savedOutputElement = null;
if (savedOutputMsg != null && savedOutputMsg.length() > 0) {
savedOutputElement = DOMUtils.stringToDOM(savedOutputMsg);
}
for (int i = 0; i < outputElementNum; i++) {
Element tempElement = (Element) outputElementList.item(i);
if (tempElement.hasAttribute("id")) {
// Retrieve element data
String elementID = tempElement.getAttribute("id");
String label = tempElement.getElementsByTagNameNS(htRenderingNS, "label").item(0).getTextContent();
String xpath = tempElement.getElementsByTagNameNS(htRenderingNS, "xpath").item(0).getTextContent();
String defaultValue = tempElement.getElementsByTagNameNS(htRenderingNS, "default").item(0).getTextContent();
// set the readOnly attribute if Exists, default false
String readOnly = "false";
if (tempElement.hasAttribute("readOnly")) {
readOnly = tempElement.getAttribute("readOnly");
}
// set element data in the response message
outputElements[i] = new OutputElementType();
// set ID
outputElements[i].setId(elementID);
// set label
outputElements[i].setLabel(label);
// set xpath
outputElements[i].setXpath(xpath);
// set value
Element valueElement = (Element) tempElement.getElementsByTagNameNS(htRenderingNS, "value").item(0);
outputElements[i].setValue(createOutRenderElementValue(valueElement));
if (readOnly.equals("true")) {
outputElements[i].setReadOnly(true);
} else {
outputElements[i].setReadOnly(false);
}
if (savedOutputElement != null) {
// resolve default value
String savedOutMessageValue = evaluateXPath(xpath, savedOutputElement, outputRenderingsElement.getOwnerDocument());
if (savedOutMessageValue == null) {
outputElements[i].set_default(defaultValue);
} else {
outputElements[i].set_default(savedOutMessageValue);
}
} else {
// add default value specified in the HT rendering definition
outputElements[i].set_default(defaultValue);
}
} else {
// no unique id for the element
log.error("Unable to find unique id for the wso2:output rendering element");
throw new GetRenderingsFaultException("Unable to find unique id for the wso2:output rendering element");
}
}
renderingOutputs = new OutputType();
renderingOutputs.setElement(outputElements);
}
}
return renderingOutputs;
}
Aggregations