Search in sources :

Example 6 with HumanTaskDAOConnection

use of org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection 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 7 with HumanTaskDAOConnection

use of org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection 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 8 with HumanTaskDAOConnection

use of org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection 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 9 with HumanTaskDAOConnection

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

the class RemovableTaskCleanupJob method execute.

/**
 * The task clean up execution logic.
 */
public void execute() {
    HumanTaskServerConfiguration serverConfiguration = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getServerConfig();
    final SimpleQueryCriteria queryCriteria = createQueryCriteria(serverConfiguration);
    log.info("Running the task cleanup service.....");
    try {
        HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                HumanTaskDAOConnection daoConnection = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getDaoConnectionFactory().getConnection();
                daoConnection.removeTasks(queryCriteria);
                return null;
            }
        });
    } catch (Exception ex) {
        String errMsg = "Task Cleanup operation failed! :";
        log.error(errMsg, ex);
        throw new HumanTaskRuntimeException(errMsg, ex);
    }
}
Also used : HumanTaskServerConfiguration(org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) HumanTaskDAOConnection(org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) SimpleQueryCriteria(org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)

Aggregations

HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)7 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)7 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)6 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)5 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)4 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)3 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)3 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)3 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)3 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)3 UserStoreException (org.wso2.carbon.user.core.UserStoreException)3 ArrayList (java.util.ArrayList)2 IllegalAccessFault (org.wso2.carbon.humantask.client.api.IllegalAccessFault)2 SimpleQueryCriteria (org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 QName (javax.xml.namespace.QName)1