Search in sources :

Example 26 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class HumanTaskStore method createAxisService.

// Creates the AxisService object from the provided ServiceBuilder object.
private AxisService createAxisService(WSDL11ToAxisServiceBuilder serviceBuilder, HumanTaskBaseConfiguration config) throws AxisFault {
    AxisService axisService;
    axisService = serviceBuilder.populateService();
    axisService.setParent(getTenantAxisConfig());
    axisService.setWsdlFound(true);
    axisService.setCustomWsdl(true);
    // axisService.setFileName(new URL(taskConfig.getWsdlDefLocation()));
    axisService.setClassLoader(getTenantAxisConfig().getServiceClassLoader());
    Utils.setEndpointsToAllUsedBindings(axisService);
    axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
    /* Setting service type to use in service management*/
    axisService.addParameter(ServerConstants.SERVICE_TYPE, "humantask");
    /* Fix for losing of security configuration  when updating human-task package*/
    axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
    Iterator operations = axisService.getOperations();
    AxisHumanTaskMessageReceiver msgReceiver = new AxisHumanTaskMessageReceiver();
    msgReceiver.setHumanTaskEngine(HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine());
    // Setting the task configuration to the message receiver. Hence no need to search for task configuration, when
    // the actual task invocation happens, we will already have the task configuration attached to the message receiver
    // itself
    msgReceiver.setTaskBaseConfiguration(config);
    while (operations.hasNext()) {
        AxisOperation operation = (AxisOperation) operations.next();
        // Setting Message Receiver even if operation has a message receiver specified.
        // This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
        // is set to operations).
        operation.setMessageReceiver(msgReceiver);
        getTenantAxisConfig().getPhasesInfo().setOperationPhases(operation);
    }
    Set<String> exposedTransports = getTenantAxisConfig().getTransportsIn().keySet();
    // Add the transports to axis2 service by reading from the tenant transport config
    for (String transport : exposedTransports) {
        axisService.addExposedTransport(transport);
    }
    if (HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isHtCoordinationEnabled() && HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isTaskRegistrationEnabled() && config.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
        // Only Engage coordination module in-case of Tasks. Coordination module is not required for notifications
        axisService.engageModule(getConfigContext().getAxisConfiguration().getModule("htcoordination"));
    }
    return axisService;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) Iterator(java.util.Iterator) Parameter(org.apache.axis2.description.Parameter) AxisHumanTaskMessageReceiver(org.wso2.carbon.humantask.core.integration.AxisHumanTaskMessageReceiver)

Example 27 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class HumanTaskStore method deploy.

/**
 * This will simply deploy the new task and will not perform removal of existing tasks, which should be done prior to
 * deploying this task
 * @param humanTaskDU
 * @return List of task configuration Qnames deployed
 * @throws HumanTaskDeploymentException
 */
public List<QName> deploy(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException {
    List<QName> taskConfigsInPackage = new ArrayList<QName>();
    TTask[] tasks = humanTaskDU.getTasks();
    List<HumanTaskBaseConfiguration> configurations = new ArrayList<HumanTaskBaseConfiguration>();
    if (tasks != null) {
        for (TTask task : tasks) {
            QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
            if (log.isDebugEnabled()) {
                log.debug(" Adding task " + task.getName() + "to task configuration");
            }
            TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            taskConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(taskConf);
            if (!taskConf.isErroneous()) {
                createCallBackService(taskConf);
                if (taskConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(taskConf);
                // activeTaskConfigurationQNameMap.put(taskQName, taskConf.getName());
                }
            }
        }
    }
    TNotification[] notifications = humanTaskDU.getNotifications();
    if (notifications != null) {
        for (TNotification notification : notifications) {
            QName notificationQName = new QName(humanTaskDU.getNamespace(), notification.getName());
            NotificationConfiguration notificationConf = new NotificationConfiguration(notification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(notificationConf);
            if (!notificationConf.isErroneous()) {
                // Deploy the axis2 service only for the active version of the task/notification
                if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(notificationConf);
                // activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
                }
            }
        }
    }
    // condition if a service name is deployed with same name outside of this task package
    for (HumanTaskBaseConfiguration configuration : configurations) {
        taskConfigurations.add(configuration);
        taskBaseConfigurationHashMap.put(configuration.getName(), configuration);
        taskConfigsInPackage.add(configuration.getName());
        if (configuration.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(configuration.getDefinitionName(), configuration.getName());
        }
    }
    for (TNotification inlineNotification : humanTaskDU.getInlineNotifications()) {
        QName notificationQName = new QName(humanTaskDU.getNamespace(), inlineNotification.getName());
        NotificationConfiguration notificationConf = new NotificationConfiguration(inlineNotification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
        notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
        taskConfigurations.add(notificationConf);
        taskConfigsInPackage.add(notificationConf.getName());
        taskBaseConfigurationHashMap.put(notificationConf.getName(), notificationConf);
        if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
        }
    }
    taskConfigurationsInTaskPackage.put(humanTaskDU.getName(), taskConfigsInPackage);
    return taskConfigsInPackage;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TNotification(org.wso2.carbon.humantask.TNotification) TTask(org.wso2.carbon.humantask.TTask)

Example 28 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class CommonTaskUtil method calculateRole.

/**
 * Calculates the Role.
 *
 * @param evalCtx    : The evaluation context.
 * @param  roleExpression : the role expression
 * @param expressionLanguage : Expression language associated with the argument named "role"
 * @return : The task priority
 */
public static String calculateRole(EvaluationContext evalCtx, String roleExpression, String expressionLanguage) {
    ExpressionLanguageRuntime expLangRuntime = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getExpressionLanguageRuntime(expressionLanguage);
    String role = expLangRuntime.evaluateAsString(roleExpression, evalCtx);
    if (role == null) {
        log.warn(String.format("Role cannot be  null"));
    }
    return role;
}
Also used : ExpressionLanguageRuntime(org.wso2.carbon.humantask.core.engine.runtime.api.ExpressionLanguageRuntime)

Example 29 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class CommonTaskUtil method createNewTaskEvent.

/**
 * Creates a new TaskEventInfo object for the task creation event.
 *
 * @param task : The newly created task object.
 *
 * @return : The respective TaskEventInfo object for the task creation event.
 */
public static TaskEventInfo createNewTaskEvent(TaskDAO task) {
    TaskEventInfo createTaskEvent = new TaskEventInfo();
    createTaskEvent.setEventType(TaskEventType.CREATE);
    createTaskEvent.setTimestamp(task.getCreatedOn());
    // TODO - how to handle the event initiator for create task event ?
    // createTaskEvent.setEventInitiator(null);
    createTaskEvent.setTaskInfo(populateTaskInfo(task));
    return createTaskEvent;
}
Also used : TaskEventInfo(org.wso2.carbon.humantask.core.api.event.TaskEventInfo)

Example 30 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class CommonTaskUtil method populateTaskInfo.

/**
 * Creates the TaskInfo object from the provided TaskDAO object.
 *
 * @param taskDAO : The original task dao object
 * @return : The representational TaskInfo.
 */
public static TaskInfo populateTaskInfo(TaskDAO taskDAO) {
    TaskInfo taskInfo = new TaskInfo();
    taskInfo.setId(taskDAO.getId());
    taskInfo.setCreatedDate(taskDAO.getCreatedOn());
    taskInfo.setName(taskDAO.getName());
    if (getDefaultPresentationDescription(taskDAO) != null) {
        taskInfo.setDescription(getDefaultPresentationDescription(taskDAO).getValue());
    }
    if (getActualOwner(taskDAO) != null) {
        taskInfo.setOwner(getActualOwner(taskDAO).getName());
    }
    if (getDefaultPresentationName(taskDAO) != null) {
        taskInfo.setName(getDefaultPresentationName(taskDAO).getValue());
    }
    if (getDefaultPresentationSubject(taskDAO) != null) {
        taskInfo.setSubject(getDefaultPresentationSubject(taskDAO).getValue());
    }
    taskInfo.setStatus(taskDAO.getStatus());
    taskInfo.setType(taskDAO.getType());
    taskInfo.setModifiedDate(taskDAO.getUpdatedOn());
    taskInfo.setStatusBeforeSuspension(taskDAO.getStatusBeforeSuspension());
    return taskInfo;
}
Also used : TaskInfo(org.wso2.carbon.humantask.core.api.event.TaskInfo)

Aggregations

HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)41 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)35 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)28 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)28 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)28 UserStoreException (org.wso2.carbon.user.core.UserStoreException)28 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)27 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)27 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)25 BaseTaskService (org.wso2.carbon.bpmn.rest.service.base.BaseTaskService)25 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)25 ArrayList (java.util.ArrayList)14 RestVariable (org.wso2.carbon.bpmn.rest.engine.variable.RestVariable)13 Element (org.w3c.dom.Element)12 QName (javax.xml.namespace.QName)11 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)11 IOException (java.io.IOException)9 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)9 AxisFault (org.apache.axis2.AxisFault)8 HumanTaskDeploymentException (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)8