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