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