use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.
the class TaskSummaryQueryCriteriaUtil method taskImplSpecificGetEntityField.
@SuppressWarnings("unchecked")
public static <T> Expression taskImplSpecificGetEntityField(CriteriaQuery<T> query, Root<TaskImpl> taskRoot, Join<TaskImpl, TaskDataImpl> taskDataJoin, Join<TaskImpl, PeopleAssignmentsImpl> peopleAssignJoin, String listId, Attribute attr) {
Expression entityField = null;
if (attr != null) {
if (listId.equals(TASK_DESCRIPTION_LIST) || listId.equals(TASK_NAME_LIST) || listId.equals(TASK_SUBJECT_LIST)) {
// we can *not* query on @LOB annotated fields (and it would be inefficient for a query api to do this?)
// so we query on the (max 255 char length) string equivalent fields
entityField = getJoinedEntityField(taskRoot, (Attribute<TaskImpl, I18NTextImpl>) attr, I18NTextImpl_.shortText);
} else if (listId.equals(ACTUAL_OWNER_ID_LIST) || listId.equals(CREATED_BY_LIST)) {
if (taskDataJoin == null) {
taskDataJoin = taskRoot.join(TaskImpl_.taskData);
}
// task -> taskData -> (actualOwn/createdBy) UserImpl -> id
entityField = getJoinedEntityField(taskDataJoin, (Attribute<TaskDataImpl, UserImpl>) attr, UserImpl_.id);
} else if (listId.equals(BUSINESS_ADMIN_ID_LIST) || listId.equals(POTENTIAL_OWNER_ID_LIST) || listId.equals(STAKEHOLDER_ID_LIST) || listId.equals(EXCLUDED_OWNER_ID_LIST)) {
if (peopleAssignJoin == null) {
peopleAssignJoin = taskRoot.join(TaskImpl_.peopleAssignments);
}
// task -> peopleAssignments -> (bus admin/pot owner/stake holder/excl user) OrganizationalEntityImpl -> id
entityField = getJoinedEntityField(peopleAssignJoin, (Attribute<PeopleAssignmentsImpl, OrganizationalEntityImpl>) attr, OrganizationalEntityImpl_.id);
} else {
if (taskDataJoin == null) {
taskDataJoin = taskRoot.join(TaskImpl_.taskData);
}
Class attrType = attr.getDeclaringType().getJavaType();
From[] taskRoots = { taskRoot, taskDataJoin };
for (From from : taskRoots) {
if (from.getJavaType().equals(attrType)) {
if (attr != null) {
if (attr instanceof SingularAttribute) {
entityField = from.get((SingularAttribute) attr);
} else if (attr instanceof PluralAttribute) {
entityField = from.get((PluralAttribute) attr);
} else {
throw new IllegalStateException("Unexpected attribute type when processing criteria with list id " + listId + ": " + attr.getClass().getName());
}
break;
}
}
}
}
}
return entityField;
}
use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.
the class TaskSummaryQueryCriteriaUtil method getEntityField.
/*
* (non-Javadoc)
* @see org.jbpm.query.jpa.impl.QueryCriteriaUtil#getEntityField(javax.persistence.criteria.CriteriaQuery, java.lang.Class, java.lang.String)
*/
@Override
protected <T> Expression getEntityField(CriteriaQuery<T> query, String listId, Attribute attr) {
if (attr == null) {
return null;
}
Root<TaskImpl> taskRoot = null;
Join<TaskImpl, TaskDataImpl> taskDataJoin = null;
Join<TaskImpl, PeopleAssignmentsImpl> peopAssignJoin = null;
for (Root root : query.getRoots()) {
if (TaskImpl.class.equals(root.getJavaType())) {
taskRoot = (Root<TaskImpl>) root;
for (Join<TaskImpl, ?> join : taskRoot.getJoins()) {
if (TaskDataImpl.class.equals(join.getJavaType())) {
taskDataJoin = (Join<TaskImpl, TaskDataImpl>) join;
} else if (PeopleAssignmentsImpl.class.equals(join.getJavaType())) {
peopAssignJoin = (Join<TaskImpl, PeopleAssignmentsImpl>) join;
}
}
}
}
assert taskRoot != null : "Unable to find TaskImpl Root in query!";
if (taskDataJoin == null) {
taskDataJoin = taskRoot.join(TaskImpl_.taskData);
}
assert taskDataJoin != null : "Unable to find TaskDataImpl Join in query!";
return taskImplSpecificGetEntityField(query, taskRoot, taskDataJoin, peopAssignJoin, listId, attr);
}
Aggregations