Search in sources :

Example 26 with IllegalStateFault

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);
    }
}
Also used : DeleteFault(org.wso2.carbon.humantask.core.engine.commands.DeleteFault) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 27 with IllegalStateFault

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);
    }
}
Also used : Skip(org.wso2.carbon.humantask.core.engine.commands.Skip) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 28 with IllegalStateFault

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);
    }
}
Also used : Start(org.wso2.carbon.humantask.core.engine.commands.Start)

Example 29 with IllegalStateFault

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;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) TPredefinedStatus(org.wso2.carbon.humantask.types.TPredefinedStatus)

Example 30 with IllegalStateFault

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;
}
Also used : OutputElementType(org.wso2.carbon.humantask.rendering.api.OutputElementType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) GetRenderingsFaultException(org.wso2.carbon.humantask.rendering.api.GetRenderingsFaultException) OutputType(org.wso2.carbon.humantask.rendering.api.OutputType)

Aggregations

HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)22 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)22 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)22 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)22 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)22 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)22 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)22 UserStoreException (org.wso2.carbon.user.core.UserStoreException)22 Element (org.w3c.dom.Element)8 HumanTaskCommand (org.wso2.carbon.humantask.core.engine.HumanTaskCommand)5 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)3 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)3 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)3 QName (javax.xml.namespace.QName)2 URI (org.apache.axis2.databinding.types.URI)2 NodeList (org.w3c.dom.NodeList)2 Complete (org.wso2.carbon.humantask.core.engine.commands.Complete)2 Start (org.wso2.carbon.humantask.core.engine.commands.Start)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1