Search in sources :

Example 56 with EntityExpr

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;
}
Also used : Locale(java.util.Locale) GenericValue(org.apache.ofbiz.entity.GenericValue) HashMap(java.util.HashMap) LinkedList(java.util.LinkedList) Delegator(org.apache.ofbiz.entity.Delegator) GenericEntityException(org.apache.ofbiz.entity.GenericEntityException) EntityExpr(org.apache.ofbiz.entity.condition.EntityExpr)

Example 57 with EntityExpr

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;
}
Also used : EntityCondition(org.apache.ofbiz.entity.condition.EntityCondition) LinkedList(java.util.LinkedList) EntityExpr(org.apache.ofbiz.entity.condition.EntityExpr)

Aggregations

EntityExpr (org.apache.ofbiz.entity.condition.EntityExpr)57 GenericValue (org.apache.ofbiz.entity.GenericValue)51 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)47 Delegator (org.apache.ofbiz.entity.Delegator)29 LinkedList (java.util.LinkedList)27 HashMap (java.util.HashMap)24 Locale (java.util.Locale)23 BigDecimal (java.math.BigDecimal)19 EntityCondition (org.apache.ofbiz.entity.condition.EntityCondition)18 GenericServiceException (org.apache.ofbiz.service.GenericServiceException)16 LocalDispatcher (org.apache.ofbiz.service.LocalDispatcher)15 Timestamp (java.sql.Timestamp)13 ArrayList (java.util.ArrayList)11 GeneralException (org.apache.ofbiz.base.util.GeneralException)7 List (java.util.List)6 Map (java.util.Map)6 EntityListIterator (org.apache.ofbiz.entity.util.EntityListIterator)6 Calendar (com.ibm.icu.util.Calendar)4 LinkedHashSet (java.util.LinkedHashSet)4 EntityConditionList (org.apache.ofbiz.entity.condition.EntityConditionList)4