use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.
the class AttachmentMgtDAOFactoryImpl method removeAttachment.
@Override
public boolean removeAttachment(final String id) throws AttachmentMgtException {
try {
boolean isRemoved = false;
isRemoved = jobExecutor.execTransaction(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
Query query = entityManager.createQuery("DELETE FROM org.wso2.carbon.attachment.mgt.core.dao.impl" + ".jpa.openjpa.entity.AttachmentDAOImpl x WHERE x.id = " + ":attachmentID");
query.setParameter("attachmentID", Long.parseLong(id));
int noOfRowsUpdated = query.executeUpdate();
// entityManager.remove(getAttachmentInfo(id));
if (noOfRowsUpdated == 1) {
return true;
} else {
return false;
}
}
});
return isRemoved;
} catch (Exception e) {
String errorMsg = "org.wso2.carbon.attachment.mgt.core.dao.impl.jpa.openjpa.AttachmentMgtDAOFactoryImpl.removeAttachment operation failed. " + "Reason: " + e.getLocalizedMessage();
log.error(errorMsg, e);
throw new AttachmentMgtException(errorMsg, e);
}
}
use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.
the class HumanTaskJPQLQueryBuilder method buildRemoveTasksQuery.
private Query buildRemoveTasksQuery() {
boolean hasStatus = false;
List<TaskStatus> statuses = queryCriteria.getStatuses();
if (statuses != null && !statuses.isEmpty()) {
hasStatus = true;
}
boolean hasTaskName = false;
if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
hasTaskName = true;
}
Query removeTasksQuery = em.createQuery(" DELETE FROM org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task t " + " WHERE t.status in :removableStatuses" + (hasTaskName ? AND + FILTER_BY_TASKNAME : ""));
removeTasksQuery.setParameter("removableStatuses", queryCriteria.getStatuses());
if (hasTaskName) {
removeTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
}
return removeTasksQuery;
}
use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.
the class HumanTaskDAOConnectionImpl method getDeploymentUnitByName.
public DeploymentUnitDAO getDeploymentUnitByName(int tenantId, String packageName) {
Query q = entityManager.createQuery("select hu from org.wso2.carbon.humantask.core.dao.jpa.openjpa.model" + ".DeploymentUnit hu WHERE hu.status=?1 and hu.tenantId=?2 and hu.packageName=?3");
q.setParameter(1, TaskPackageStatus.ACTIVE);
q.setParameter(2, tenantId);
q.setParameter(3, packageName);
List<DeploymentUnit> resultList = q.getResultList();
DeploymentUnit deploymentUnit = null;
if (resultList.size() != 0) {
deploymentUnit = resultList.get(0);
}
return deploymentUnit;
}
use of org.wso2.carbon.humantask.client.api.types in project jaggery by wso2.
the class RegistryHostObject method jsFunction_addComment.
public static void jsFunction_addComment(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws ScriptException {
String functionName = "addComment";
int argsCount = args.length;
if (argsCount != 2) {
HostObjectUtil.invalidNumberOfArgs(hostObjectName, functionName, argsCount, false);
}
if (!(args[0] instanceof String)) {
HostObjectUtil.invalidArgsError(hostObjectName, functionName, "1", "string", args[0], false);
}
if (!(args[1] instanceof String)) {
HostObjectUtil.invalidArgsError(hostObjectName, functionName, "2", "string", args[1], false);
}
RegistryHostObject registryHostObject = (RegistryHostObject) thisObj;
try {
registryHostObject.registry.addComment((String) args[0], new org.wso2.carbon.registry.core.Comment((String) args[1]));
} catch (RegistryException e) {
throw new ScriptException(e);
}
}
use of org.wso2.carbon.humantask.client.api.types in project jaggery by wso2.
the class RegistryHostObject method isAuthorized.
private boolean isAuthorized(UserRegistry registry, String resourcePath, String action) throws RegistryException {
UserRealm userRealm = registry.getUserRealm();
String userName = registry.getUserName();
try {
if (!userRealm.getAuthorizationManager().isUserAuthorized(userName, resourcePath, action)) {
return false;
}
} catch (UserStoreException e) {
throw new org.wso2.carbon.registry.core.exceptions.RegistryException("Error at Authorizing " + resourcePath + " with user " + userName + ":" + e.getMessage(), e);
}
return true;
}
Aggregations