Search in sources :

Example 6 with HumanTaskEngine

use of org.wso2.carbon.humantask.core.engine.HumanTaskEngine in project carbon-business-process by wso2.

the class HumanTaskStore method removeMatchingPackageAfterTaskObsoletion.

private boolean removeMatchingPackageAfterTaskObsoletion(String packageName) {
    final HumanTaskEngine taskEngine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
    boolean matchingPackagesFound = false;
    final int tId = this.tenantId;
    List<HumanTaskBaseConfiguration> matchingTaskConfigurations = new ArrayList<HumanTaskBaseConfiguration>();
    for (final HumanTaskBaseConfiguration configuration : this.getTaskConfigurations()) {
        if (configuration.getPackageName().equals(packageName)) {
            matchingTaskConfigurations.add(configuration);
            try {
                taskEngine.getScheduler().execTransaction(new Callable<Object>() {

                    public Object call() throws Exception {
                        taskEngine.getDaoConnectionFactory().getConnection().obsoleteTasks(configuration.getName().toString(), tId);
                        return null;
                    }
                });
            } catch (Exception e) {
                String errMsg = "Error occurred while making tasks obsolete";
                log.error(errMsg);
                throw new HumanTaskRuntimeException(errMsg, e);
            }
            // we don't want the associated service once the task configuration is removed!
            removeAxisServiceForTaskConfiguration(configuration);
            matchingPackagesFound = true;
        }
    }
    // remove the task configurations with the matching package name.
    for (HumanTaskBaseConfiguration removableConfiguration : matchingTaskConfigurations) {
        this.getTaskConfigurations().remove(removableConfiguration);
    }
    return matchingPackagesFound;
}
Also used : HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine) ArrayList(java.util.ArrayList) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 7 with HumanTaskEngine

use of org.wso2.carbon.humantask.core.engine.HumanTaskEngine in project carbon-business-process by wso2.

the class TaskOperationsImpl method loadTask.

/**
 * Return Task Abstract details for give Task ID. (Custom API) Similar to getMyTaskAbstracts method in HumanTask API
 * @param taskIdURI : task identifier
 * @return Task Abstract
 * @throws IllegalAccessFault
 */
public TTaskAbstract loadTask(URI taskIdURI) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);
        TaskDAO task = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<TaskDAO>() {

            public TaskDAO call() throws Exception {
                HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
                HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
                TaskDAO task = daoConn.getTask(taskId);
                validateTaskTenant(task);
                authoriseToLoadTask(task);
                return task;
            }
        });
        return TransformerUtils.transformTask(task, getCaller());
    } catch (Exception ex) {
        log.error("Error occurred while loading task: " + taskIdURI, ex);
        handleException(ex);
    }
    return null;
}
Also used : HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine) TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO) HumanTaskDAOConnection(org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection) 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 8 with HumanTaskEngine

use of org.wso2.carbon.humantask.core.engine.HumanTaskEngine in project carbon-business-process by wso2.

the class TaskOperationsImpl method getRenderingTypes.

/**
 * Applies to both tasks and notifications.
 * Returns the rendering  types available for the task or notification.
 *
 * @param taskIdURI : task identifier
 * @return : Array of QNames
 * @throws IllegalArgumentFault
 */
public QName[] getRenderingTypes(URI taskIdURI) throws IllegalArgumentFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);
        TaskDAO task = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<TaskDAO>() {

            public TaskDAO call() throws Exception {
                HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
                HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
                TaskDAO task = daoConn.getTask(taskId);
                validateTaskTenant(task);
                return task;
            }
        });
        HumanTaskBaseConfiguration taskConfiguration = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(task.getTenantId()).getTaskConfiguration(QName.valueOf(task.getName()));
        List<QName> renderingTypes = taskConfiguration.getRenderingTypes();
        QName[] types = new QName[renderingTypes.size()];
        types = renderingTypes.toArray(types);
        return types;
    } catch (Exception ex) {
        log.error(ex);
        throw new IllegalArgumentFault(ex);
    }
}
Also used : HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine) QName(javax.xml.namespace.QName) TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration) HumanTaskDAOConnection(org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection) 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 9 with HumanTaskEngine

use of org.wso2.carbon.humantask.core.engine.HumanTaskEngine in project carbon-business-process by wso2.

the class TransformerUtils method transformOrganizationalEntityList.

/**
 * Transforms the TOrganizationalEntity type to OrganizationalEntity.
 *
 * @param tOEntity : The object to be transformed.
 * @return : The transformed object list.
 */
public static List<OrganizationalEntityDAO> transformOrganizationalEntityList(TOrganizationalEntity tOEntity) {
    HumanTaskEngine taskEngine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
    HumanTaskDAOConnection daoConn = taskEngine.getDaoConnectionFactory().getConnection();
    List<OrganizationalEntityDAO> organizationalEntities = new ArrayList<OrganizationalEntityDAO>();
    TOrganizationalEntityChoice[] usersAndGroups = tOEntity.getTOrganizationalEntityChoice();
    for (TOrganizationalEntityChoice userOrGroup : usersAndGroups) {
        String userName = null;
        OrganizationalEntityDAO.OrganizationalEntityType type = null;
        if (userOrGroup.getUser() != null) {
            TUser user = userOrGroup.getUser();
            userName = user.getTUser().trim();
            type = OrganizationalEntityDAO.OrganizationalEntityType.USER;
        } else if (userOrGroup.getGroup() != null) {
            TGroup group = userOrGroup.getGroup();
            userName = group.getTGroup().trim();
            type = OrganizationalEntityDAO.OrganizationalEntityType.GROUP;
        }
        if (org.h2.util.StringUtils.isNullOrEmpty(userName) || type == null) {
            throw new HumanTaskRuntimeException("Cannot extract OrganizationalEntity from :" + tOEntity);
        }
        OrganizationalEntityDAO orgEntity = daoConn.createNewOrgEntityObject(userName, type);
        organizationalEntities.add(orgEntity);
    }
    return organizationalEntities;
}
Also used : HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine) ArrayList(java.util.ArrayList) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 10 with HumanTaskEngine

use of org.wso2.carbon.humantask.core.engine.HumanTaskEngine in project carbon-business-process by wso2.

the class HumanTaskServer method initHumanTaskEngine.

// Initialises the human task engine.
private void initHumanTaskEngine() {
    HumanTaskEngine humanTaskEngine = new HumanTaskEngine();
    humanTaskEngine.setDaoConnectionFactory(this.daoConnectionFactory);
    humanTaskEngine.setEventProcessor(this.eventProcessor);
    this.taskEngine = humanTaskEngine;
}
Also used : HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine)

Aggregations

HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)10 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)6 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)5 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)5 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)5 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)5 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)4 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)4 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)4 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)4 UserStoreException (org.wso2.carbon.user.core.UserStoreException)4 ArrayList (java.util.ArrayList)2 IllegalAccessFault (org.wso2.carbon.humantask.client.api.IllegalAccessFault)2 IOException (java.io.IOException)1 Callable (java.util.concurrent.Callable)1 QName (javax.xml.namespace.QName)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 URI (org.apache.axis2.databinding.types.URI)1 Element (org.w3c.dom.Element)1 GenericHumanRoleDAO (org.wso2.carbon.humantask.core.dao.GenericHumanRoleDAO)1