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;
}
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;
}
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));
}
}
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;
}
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();
}
Aggregations