Search in sources :

Example 31 with IllegalArgumentFault

use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault 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 32 with IllegalArgumentFault

use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault 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 33 with IllegalArgumentFault

use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault 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

HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)25 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)24 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)24 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)24 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)24 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)24 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)24 UserStoreException (org.wso2.carbon.user.core.UserStoreException)24 Element (org.w3c.dom.Element)9 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)5 HumanTaskCommand (org.wso2.carbon.humantask.core.engine.HumanTaskCommand)5 QName (javax.xml.namespace.QName)4 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)4 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)4 HumanTaskBaseConfiguration (org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)3 URI (org.apache.axis2.databinding.types.URI)2 NodeList (org.w3c.dom.NodeList)2 IllegalArgumentFault (org.wso2.carbon.humantask.client.api.IllegalArgumentFault)2 Complete (org.wso2.carbon.humantask.core.engine.commands.Complete)2 IOException (java.io.IOException)1