Search in sources :

Example 1 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class TransformerUtils method transformToSimpleQueryRow.

// /**
// * @param matchingTasks :
// * @return :
// */
// public static TTaskSimpleQueryResultSet createSimpleQueryResultSet(
// List<TaskDAO> matchingTasks) {
// 
// TTaskSimpleQueryResultSet resultSet = new TTaskSimpleQueryResultSet();
// 
// for (TaskDAO matchingTask : matchingTasks) {
// resultSet.addRow(transformToSimpleQueryRow(matchingTask));
// }
// 
// return resultSet;
// }
/**
 * @param matchingTask :
 * @return :
 */
public static TTaskSimpleQueryResultRow transformToSimpleQueryRow(TaskDAO matchingTask) {
    TTaskSimpleQueryResultRow row = new TTaskSimpleQueryResultRow();
    row.setName(QName.valueOf(matchingTask.getDefinitionName()));
    row.setTaskType(matchingTask.getType().toString());
    try {
        row.setId(new URI(matchingTask.getId().toString()));
    } catch (URI.MalformedURIException e) {
        throw new HumanTaskRuntimeException("The task id :[" + matchingTask.getId() + "] is invalid", e);
    }
    Calendar createdTime = Calendar.getInstance();
    createdTime.setTime(matchingTask.getCreatedOn());
    row.setCreatedTime(createdTime);
    // set the task priority.
    TPriority priority = new TPriority();
    priority.setTPriority(BigInteger.valueOf(matchingTask.getPriority()));
    row.setPriority(priority);
    // set the task status
    TStatus taskStatus = new TStatus();
    taskStatus.setTStatus(matchingTask.getStatus().toString());
    row.setStatus(taskStatus);
    row.setPresentationSubject((transformPresentationSubject(CommonTaskUtil.getDefaultPresentationSubject(matchingTask))));
    row.setPresentationName(transformPresentationName(CommonTaskUtil.getDefaultPresentationName(matchingTask)));
    return row;
}
Also used : Calendar(java.util.Calendar) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) URI(org.apache.axis2.databinding.types.URI)

Example 2 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class TaskOperationsImpl method getCaller.

private String getCaller() {
    // TODO - remove hard coded user name value once moved to task view page.
    String userName = "admin";
    PeopleQueryEvaluator pqe = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
    if (StringUtils.isNotEmpty(pqe.getLoggedInUser())) {
        userName = pqe.getLoggedInUser();
    }
    // logged in user.
    if (StringUtils.isEmpty(userName)) {
        throw new HumanTaskRuntimeException("Cannot determine the user name of the user " + "performing the task operation!");
    }
    return userName;
}
Also used : PeopleQueryEvaluator(org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 3 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class CarbonUserManagerBasedPeopleQueryEvaluator method createGHRForUsername.

public GenericHumanRoleDAO createGHRForUsername(String username, GenericHumanRoleDAO.GenericHumanRoleType type) {
    if (isExistingUser(username)) {
        GenericHumanRoleDAO ghr = getConnection().createNewGHRObject(type);
        List<OrganizationalEntityDAO> orgEntities = new ArrayList<OrganizationalEntityDAO>();
        OrganizationalEntityDAO orgEntity = getConnection().createNewOrgEntityObject(username, OrganizationalEntityDAO.OrganizationalEntityType.USER);
        orgEntity.addGenericHumanRole(ghr);
        orgEntities.add(orgEntity);
        ghr.setOrgEntities(orgEntities);
        return ghr;
    } else {
        throw new HumanTaskRuntimeException(String.format("The username [%s] does not exist.", username));
    }
}
Also used : OrganizationalEntityDAO(org.wso2.carbon.humantask.core.dao.OrganizationalEntityDAO) ArrayList(java.util.ArrayList) GenericHumanRoleDAO(org.wso2.carbon.humantask.core.dao.GenericHumanRoleDAO) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 4 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class LogicalPeopleGroupBasedOrgEntityProvider method getOrganizationalEntities.

public List<OrganizationalEntityDAO> getOrganizationalEntities(PeopleQueryEvaluator peopleQueryEvaluator, TFrom tFrom, EvaluationContext evaluationContext) throws HumanTaskException {
    String roleName = null;
    for (TArgument tArgument : tFrom.getArgumentArray()) {
        String expressionLanguage = (tArgument.getExpressionLanguage() == null) ? tFrom.getExpressionLanguage() : tArgument.getExpressionLanguage();
        if (expressionLanguage == null) {
            expressionLanguage = HumanTaskConstants.WSHT_EXP_LANG_XPATH20;
        }
        // TODO what about expression language
        if ("role".equals(tArgument.getName())) {
            roleName = tArgument.newCursor().getTextValue();
            if (roleName != null && roleName.contains("htd:getInput")) {
                roleName = CommonTaskUtil.calculateRole(evaluationContext, roleName, expressionLanguage);
            }
            break;
        }
    }
    if (roleName == null || StringUtils.isEmpty(roleName)) {
        throw new HumanTaskRuntimeException("The role name cannot be empty: " + tFrom.toString());
    } else {
        roleName = roleName.trim();
    }
    List<OrganizationalEntityDAO> orgEnties = new ArrayList<OrganizationalEntityDAO>();
    orgEnties.add(peopleQueryEvaluator.createGroupOrgEntityForRole(roleName));
    return orgEnties;
}
Also used : OrganizationalEntityDAO(org.wso2.carbon.humantask.core.dao.OrganizationalEntityDAO) ArrayList(java.util.ArrayList) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) TArgument(org.wso2.carbon.humantask.TArgument)

Example 5 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException 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)

Aggregations

HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)20 ArrayList (java.util.ArrayList)7 PeopleQueryEvaluator (org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator)4 OrganizationalEntityDAO (org.wso2.carbon.humantask.core.dao.OrganizationalEntityDAO)3 UserStoreException (org.wso2.carbon.user.core.UserStoreException)3 Calendar (java.util.Calendar)2 List (java.util.List)2 URI (org.apache.axis2.databinding.types.URI)2 GenericHumanRoleDAO (org.wso2.carbon.humantask.core.dao.GenericHumanRoleDAO)2 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)2 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)2 TaskConfiguration (org.wso2.carbon.humantask.core.store.TaskConfiguration)2 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)2 Date (java.util.Date)1 AxisFault (org.apache.axis2.AxisFault)1 AxisService (org.apache.axis2.description.AxisService)1 TArgument (org.wso2.carbon.humantask.TArgument)1 HumanTaskServerConfiguration (org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration)1 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)1 SimpleQueryCriteria (org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)1