use of org.apache.ofbiz.entity.condition.EntityExpr in project ofbiz-framework by apache.
the class WorkEffortServices method getWorkEffortAssignedActivitiesByRole.
public static Map<String, Object> getWorkEffortAssignedActivitiesByRole(DispatchContext ctx, Map<String, ? extends Object> context) {
Delegator delegator = ctx.getDelegator();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Locale locale = (Locale) context.get("locale");
List<GenericValue> roleWorkEfforts = null;
if (userLogin != null && userLogin.get("partyId") != null) {
try {
List<EntityExpr> constraints = new LinkedList<>();
constraints.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
constraints.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
constraints.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
constraints.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
constraints.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
constraints.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
constraints.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PRTYASGN_UNASSIGNED"));
constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_COMPLETED"));
constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED"));
constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED"));
roleWorkEfforts = EntityQuery.use(delegator).from("WorkEffortPartyAssignByRole").where(constraints).orderBy("priority").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "WorkEffortNotFound", UtilMisc.toMap("errorString", e.toString()), locale));
}
}
Map<String, Object> result = new HashMap<>();
if (roleWorkEfforts == null) {
roleWorkEfforts = new LinkedList<>();
}
result.put("roleActivities", roleWorkEfforts);
return result;
}
use of org.apache.ofbiz.entity.condition.EntityExpr in project ofbiz-framework by apache.
the class WorkEffortServices method getDefaultWorkEffortExprList.
private static List<EntityCondition> getDefaultWorkEffortExprList(String calendarType, Collection<String> partyIds, String workEffortTypeId, List<EntityCondition> cancelledCheckAndList) {
List<EntityCondition> entityExprList = new LinkedList<>();
if (cancelledCheckAndList != null) {
entityExprList.addAll(cancelledCheckAndList);
}
List<EntityExpr> typesList = new LinkedList<>();
if (UtilValidate.isNotEmpty(workEffortTypeId)) {
typesList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, workEffortTypeId));
}
if ("CAL_PERSONAL".equals(calendarType)) {
// public events are always included to the "personal calendar"
List<EntityCondition> publicEvents = UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("scopeEnumId", EntityOperator.EQUALS, "WES_PUBLIC"), EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "EVENT"));
if (UtilValidate.isNotEmpty(partyIds)) {
entityExprList.add(EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("partyId", EntityOperator.IN, partyIds), EntityCondition.makeCondition(publicEvents, EntityJoinOperator.AND)), EntityJoinOperator.OR));
}
}
if ("CAL_MANUFACTURING".equals(calendarType)) {
entityExprList.add(EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_HEADER"), EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK")), EntityJoinOperator.OR));
}
EntityCondition typesCondition = null;
if (typesList.size() == 0) {
return entityExprList;
} else if (typesList.size() == 1) {
typesCondition = typesList.get(0);
} else {
typesCondition = EntityCondition.makeCondition(typesList, EntityJoinOperator.OR);
}
entityExprList.add(typesCondition);
return entityExprList;
}
Aggregations