Search in sources :

Example 21 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class JPATaskUtil method processGenericHumanRoles.

public static void processGenericHumanRoles(TaskDAO task, HumanTaskBaseConfiguration taskConfiguration, PeopleQueryEvaluator peopleQueryEvaluator, EvaluationContext evaluationContext) throws HumanTaskException {
    if (taskConfiguration.isTask()) {
        // Task
        TTask tTask = ((TaskConfiguration) taskConfiguration).getTask();
        // TODO move the reading of configuration file in to the TaskConfiguration class
        // Reading Excluded users
        TGenericHumanRoleAssignment[] tExcludedOwners = tTask.getPeopleAssignments().getExcludedOwnersArray();
        if (tExcludedOwners != null && tExcludedOwners.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tExcludedOwners[0], GenericHumanRoleDAO.GenericHumanRoleType.EXCLUDED_OWNERS, evaluationContext);
        }
        // Reading potential owners
        TPotentialOwnerAssignment[] tPotentialOwners = tTask.getPeopleAssignments().getPotentialOwnersArray();
        if (tPotentialOwners != null && tPotentialOwners.length > 0) {
            TPotentialOwnerAssignment tPotentialOwner = tPotentialOwners[0];
            OrganizationalEntityProvider provider = OrganizationalEntityProviderFactory.getOrganizationalEntityProvider(tPotentialOwner.getFrom());
            List<OrganizationalEntityDAO> orgEntities = provider.getOrganizationalEntities(peopleQueryEvaluator, tPotentialOwner.getFrom(), evaluationContext);
            if (tExcludedOwners != null && tExcludedOwners.length > 0) {
                GenericHumanRoleDAO excludedOwners = task.getGenericHumanRole(GenericHumanRoleDAO.GenericHumanRoleType.EXCLUDED_OWNERS);
                for (OrganizationalEntityDAO excludedEntity : excludedOwners.getOrgEntities()) {
                    for (OrganizationalEntityDAO ownerEntity : orgEntities) {
                        if (excludedEntity.getOrgEntityType() == ownerEntity.getOrgEntityType() && excludedEntity.getName().equals(ownerEntity.getName())) {
                            orgEntities.remove(ownerEntity);
                            break;
                        }
                    }
                }
            }
            GenericHumanRole potentialOwnersGHRole = new GenericHumanRole();
            potentialOwnersGHRole.setType(GenericHumanRole.GenericHumanRoleType.POTENTIAL_OWNERS);
            potentialOwnersGHRole.setOrgEntities(orgEntities);
            potentialOwnersGHRole.setTask(task);
            for (OrganizationalEntityDAO oe : orgEntities) {
                oe.addGenericHumanRole(potentialOwnersGHRole);
            }
            task.addHumanRole(potentialOwnersGHRole);
        }
        // Reading Stake holders
        TGenericHumanRoleAssignment[] tStakeHolders = tTask.getPeopleAssignments().getTaskStakeholdersArray();
        if (tStakeHolders != null && tStakeHolders.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tStakeHolders[0], GenericHumanRoleDAO.GenericHumanRoleType.STAKEHOLDERS, evaluationContext);
        }
        // Reading Business administrators
        TGenericHumanRoleAssignment[] tBusinessAdministrators = tTask.getPeopleAssignments().getBusinessAdministratorsArray();
        if (tBusinessAdministrators != null && tBusinessAdministrators.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tBusinessAdministrators[0], GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS, evaluationContext);
        }
    } else {
        // Notification
        TNotification tNotification = ((NotificationConfiguration) taskConfiguration).getNotificationDefinition();
        // Reading Notification recipients
        TGenericHumanRoleAssignment[] tRecipients = tNotification.getPeopleAssignments().getRecipientsArray();
        if (tRecipients != null && tRecipients.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tRecipients[0], GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS, evaluationContext);
        }
    }
}
Also used : OrganizationalEntityProvider(org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.provider.OrganizationalEntityProvider) NotificationConfiguration(org.wso2.carbon.humantask.core.store.NotificationConfiguration) TaskConfiguration(org.wso2.carbon.humantask.core.store.TaskConfiguration)

Example 22 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class Complete method execute.

/**
 * The method to execute the business logic for the specific command.
 */
public void execute() {
    authorise();
    TaskDAO task = getTask();
    checkPreConditions();
    checkState();
    task.complete(createMessage());
    TaskConfiguration taskConf = (TaskConfiguration) HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(task.getTenantId()).getTaskConfiguration(QName.valueOf(task.getName()));
    try {
        taskConf.getCallBackService().invoke(XMLUtils.toOM(taskOutput), task.getId());
    } catch (Exception e) {
        throw new HumanTaskRuntimeException("Error occurred while invoking callback service", e);
    }
    processTaskEvent();
    checkPostConditions();
}
Also used : TaskConfiguration(org.wso2.carbon.humantask.core.store.TaskConfiguration) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 23 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class DeleteFault method execute.

@Override
public void execute() {
    TaskDAO task = getTask();
    authorise();
    checkPreConditions();
    checkState();
    task.deleteFault();
    processTaskEvent();
    checkPostConditions();
}
Also used : TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO)

Example 24 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class Exit method execute.

@Override
public void execute() {
    authorise();
    TaskDAO task = getTask();
    checkPreConditions();
    checkState();
    task.exit();
    processTaskEvent();
    checkPostConditions();
}
Also used : TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO)

Example 25 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class Forward method createTaskEvent.

@Override
protected EventDAO createTaskEvent() {
    TaskDAO task = getTask();
    EventDAO taskEvent = super.createTaskEvent();
    taskEvent.setDetails("");
    processTaskEvent();
    return taskEvent;
}
Also used : EventDAO(org.wso2.carbon.humantask.core.dao.EventDAO) TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO)

Aggregations

TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)27 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)16 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)7 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)7 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)7 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)7 UserStoreException (org.wso2.carbon.user.core.UserStoreException)7 Element (org.w3c.dom.Element)6 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)6 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)6 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)6 QName (javax.xml.namespace.QName)5 HumanTaskBaseConfiguration (org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)5 TaskConfiguration (org.wso2.carbon.humantask.core.store.TaskConfiguration)5 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)4 URI (org.apache.axis2.databinding.types.URI)3 NodeList (org.w3c.dom.NodeList)3 PeopleQueryEvaluator (org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator)3 ExpressionEvaluationContext (org.wso2.carbon.humantask.core.engine.runtime.ExpressionEvaluationContext)3 EvaluationContext (org.wso2.carbon.humantask.core.engine.runtime.api.EvaluationContext)3