Author: ashish
Date: Sat Nov 29 08:02:05 2014 New Revision: 1642400 URL: http://svn.apache.org/r1642400 Log: Applied patch from jira issue OFBIZ-5844 - Convert java files to EntityQuery. Thanks Arun for the contribution. Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java?rev=1642400&r1=1642399&r2=1642400&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java Sat Nov 29 08:02:05 2014 @@ -30,14 +30,12 @@ import org.ofbiz.content.content.Content import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.util.EntityQuery; -import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.entity.model.ModelUtil; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.cache.UtilCache; @@ -314,8 +312,12 @@ public class WorkEffortContentWrapper im } public static List<String> getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { - List<GenericValue> partyContentList = delegator.findByAnd("WorkEffortContent", UtilMisc.toMap("workEffortId", workEffort.getString("partyId"), "workEffortContentTypeId", workEffortContentTypeId), UtilMisc.toList("-fromDate"), true); - partyContentList = EntityUtil.filterByDate(partyContentList); + List<GenericValue> partyContentList = EntityQuery.use(delegator).from("WorkEffortContent") + .where("workEffortId", workEffort.getString("partyId"), "workEffortContentTypeId", workEffortContentTypeId) + .orderBy("-fromDate") + .cache(true) + .filterByDate() + .queryList(); List<String> contentList = FastList.newInstance(); if (partyContentList != null) { @@ -345,19 +347,18 @@ public class WorkEffortContentWrapper im throw new IllegalArgumentException("Delegator missing"); } - List<GenericValue> workEffortContentList = null; + GenericValue workEffortContent = null; try { - workEffortContentList = delegator.findByAnd("WorkEffortContent", UtilMisc.toMap("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId), UtilMisc.toList("-fromDate"), true); + workEffortContent = EntityQuery.use(delegator).from("WorkEffortContent") + .where("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId) + .orderBy("-fromDate") + .filterByDate() + .cache(true) + .queryFirst(); } catch (GeneralException e) { Debug.logError(e, module); } - - if (workEffortContentList != null) { - workEffortContentList = EntityUtil.filterByDate(workEffortContentList); - return EntityUtil.getFirst(workEffortContentList); - } else { - return null; - } + return workEffortContent; } public static WorkEffortContentWrapper makeWorkEffortContentWrapper(GenericValue workEffort, HttpServletRequest request) { Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java?rev=1642400&r1=1642399&r2=1642400&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java Sat Nov 29 08:02:05 2014 @@ -88,10 +88,7 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.util.EntityQuery; -import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelParam; @@ -329,7 +326,7 @@ public class ICalConverter { Summary summary = new Summary(UtilProperties.getMessage("WorkEffortUiLabels", "WorkEffortEventReminder", Locale.getDefault())); Delegator delegator = workEffort.getDelegator(); String workEffortId = workEffort.getString("workEffortId"); - List<GenericValue> reminderList = delegator.findList("WorkEffortEventReminder", EntityCondition.makeCondition("workEffortId", EntityOperator.EQUALS, workEffort.get("workEffortId")), null, null, null, false); + List<GenericValue> reminderList = EntityQuery.use(delegator).from("WorkEffortEventReminder").where("workEffortId", workEffort.get("workEffortId")).queryList(); for (GenericValue reminder : reminderList) { String reminderId = workEffortId + "-" + reminder.getString("sequenceId"); VAlarm alarm = null; @@ -740,7 +737,7 @@ public class ICalConverter { if (workEffortId == null) { Property uid = component.getProperty(Uid.UID); if (uid != null) { - GenericValue workEffort = EntityUtil.getFirst(delegator.findByAnd("WorkEffort", UtilMisc.toMap("universalId", uid.getValue()), null, false)); + GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("universalId", uid.getValue()).queryFirst(); if (workEffort != null) { workEffortId = workEffort.getString("workEffortId"); } @@ -807,7 +804,7 @@ public class ICalConverter { Delegator delegator = (Delegator) context.get("delegator"); List<GenericValue> assignments = null; try { - assignments = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortPartyAssignment", serviceMap, null, false)); + assignments = EntityQuery.use(delegator).from("WorkEffortPartyAssignment").where(serviceMap).filterByDate().queryList(); if (assignments.size() == 0) { serviceMap.put("statusId", "PRTYASGN_OFFERED"); serviceMap.put("fromDate", new Timestamp(System.currentTimeMillis())); @@ -905,7 +902,7 @@ public class ICalConverter { if (workEffort.get("estimatedCompletionDate") == null) { replaceProperty(componentProps, toDuration(workEffort.getDouble("estimatedMilliSeconds"))); } - List<GenericValue> relatedParties = EntityUtil.filterByDate(delegator.findList("WorkEffortPartyAssignView", EntityCondition.makeCondition("workEffortId", EntityOperator.EQUALS, workEffortId), null, null, null, true)); + List<GenericValue> relatedParties = EntityQuery.use(delegator).from("WorkEffortPartyAssignView").where("workEffortId", workEffortId).cache(true).filterByDate().queryList(); if (relatedParties.size() > 0) { loadRelatedParties(relatedParties, componentProps, context); } Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java?rev=1642400&r1=1642399&r2=1642400&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java Sat Nov 29 08:02:05 2014 @@ -37,6 +37,7 @@ import org.ofbiz.content.data.DataResour import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; public class WorkEffortKeywordIndex { @@ -68,15 +69,15 @@ public class WorkEffortKeywordIndex { addWeightedKeywordSourceString(workEffort, "currentStatusId", strings); if (!"0".equals(UtilProperties.getPropertyValue("workeffortsearch", "index.weight.WorkEffortNoteAndData.noteInfo", "1"))) { - List<GenericValue> workEffortNotes = delegator.findByAnd("WorkEffortNoteAndData", UtilMisc.toMap("workEffortId", workEffortId), null, false); + List<GenericValue> workEffortNotes = EntityQuery.use(delegator).from("WorkEffortNoteAndData").where("workEffortId", workEffortId).queryList(); for (GenericValue workEffortNote : workEffortNotes) { addWeightedKeywordSourceString(workEffortNote, "noteInfo", strings); - } + } } //WorkEffortAttribute if (!"0".equals(UtilProperties.getPropertyValue("workeffortsearch", "index.weight.WorkEffortAttribute.attrName", "1")) || !"0".equals(UtilProperties.getPropertyValue("workeffortsearch", "index.weight.WorkEffortAttribute.attrValue", "1"))) { - List<GenericValue> workEffortAttributes = delegator.findByAnd("WorkEffortAttribute", UtilMisc.toMap("workEffortId", workEffortId), null, false); + List<GenericValue> workEffortAttributes = EntityQuery.use(delegator).from("WorkEffortAttribute").where("workEffortId", workEffortId).queryList(); for (GenericValue workEffortAttribute : workEffortAttributes) { addWeightedKeywordSourceString(workEffortAttribute, "attrName", strings); addWeightedKeywordSourceString(workEffortAttribute, "attrValue", strings); @@ -92,7 +93,7 @@ public class WorkEffortKeywordIndex { Debug.logWarning("Could not parse weight number: " + e.toString(), module); } - List<GenericValue> workEffortContentAndInfos = delegator.findByAnd("WorkEffortContentAndInfo", UtilMisc.toMap("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId), null, false); + List<GenericValue> workEffortContentAndInfos = EntityQuery.use(delegator).from("WorkEffortContentAndInfo").where("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId).queryList(); for (GenericValue workEffortContentAndInfo: workEffortContentAndInfos) { addWeightedDataResourceString(workEffortContentAndInfo, weight, strings, delegator, workEffort); List<GenericValue> alternateViews = workEffortContentAndInfo.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"), false); Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java?rev=1642400&r1=1642399&r2=1642400&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java Sat Nov 29 08:02:05 2014 @@ -40,7 +40,6 @@ import org.ofbiz.common.KeywordSearchUti import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.condition.EntityComparisonOperator; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; @@ -52,7 +51,6 @@ import org.ofbiz.entity.model.ModelViewE import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasField; import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; -import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; @@ -103,7 +101,7 @@ public class WorkEffortSearch { // now find all sub-categories, filtered by effective dates, and call this routine for them try { // Find WorkEffortAssoc, workEffortAssocTypeId=WORK_EFF_BREAKDOWN - List<GenericValue> workEffortAssocList = delegator.findByAnd("WorkEffortAssoc", UtilMisc.toMap("workEffortIdFrom", workEffortId, "workEffortAssocTypeId", "WORK_EFF_BREAKDOWN"), null, true); + List<GenericValue> workEffortAssocList = EntityQuery.use(delegator).from("WorkEffortAssoc").where("workEffortIdFrom", workEffortId, "workEffortAssocTypeId", "WORK_EFF_BREAKDOWN").cache(true).queryList(); for (GenericValue workEffortAssoc: workEffortAssocList) { String subWorkEffortId = workEffortAssoc.getString("workEffortIdTo"); if (workEffortIdSet.contains(subWorkEffortId)) { @@ -118,8 +116,7 @@ public class WorkEffortSearch { } // Find WorkEffort where current workEffortId = workEffortParentId; only select minimal fields to keep the size low - List<GenericValue> childWorkEffortList = delegator.findList("WorkEffort", EntityCondition.makeCondition("workEffortParentId", EntityComparisonOperator.EQUALS, workEffortId), - UtilMisc.toSet("workEffortId", "workEffortParentId"), null, null, true); + List<GenericValue> childWorkEffortList = EntityQuery.use(delegator).select("workEffortId", "workEffortParentId").from("WorkEffort").where("workEffortParentId", workEffortId).cache(true).queryList(); for (GenericValue childWorkEffort: childWorkEffortList) { String subWorkEffortId = childWorkEffort.getString("workEffortId"); if (workEffortIdSet.contains(subWorkEffortId)) { @@ -306,20 +303,23 @@ public class WorkEffortSearch { resultSortOrder.setSortOrder(this); } dynamicViewEntity.addAlias("WEFF", "workEffortId", null, null, null, Boolean.valueOf(workEffortIdGroupBy), null); - EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND); // Debug.logInfo("WorkEffortSearch, whereCondition = " + whereCondition.toString(), module); - EntityFindOptions efo = new EntityFindOptions(); - efo.setDistinct(true); - efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); - if (maxResults != null) { - efo.setMaxRows(maxResults); - } - EntityListIterator eli = null; try { - eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, orderByList, efo); + int maxRows = 0; + if (maxResults != null) { + maxRows = maxResults; + } + eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect)) + .from(dynamicViewEntity) + .where(entityConditionList) + .orderBy(orderByList) + .distinct() + .cursorScrollInsensitive() + .maxRows(maxRows) + .queryIterator(); } catch (GenericEntityException e) { Debug.logError(e, "Error in workEffort search", module); return null; Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java?rev=1642400&r1=1642399&r2=1642400&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java Sat Nov 29 08:02:05 2014 @@ -53,7 +53,6 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntityQuery; -import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.security.Security; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -92,9 +91,7 @@ public class WorkEffortServices { EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"), EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED") ); - validWorkEfforts = EntityUtil.filterByDate( - delegator.findList("WorkEffortAndPartyAssign", ecl, null, UtilMisc.toList("estimatedStartDate", "priority"), null, false) - ); + validWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(ecl).orderBy("estimatedStartDate", "priority").filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -127,9 +124,7 @@ public class WorkEffortServices { conditionList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED")); EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(conditionList, EntityOperator.AND); - validWorkEfforts = EntityUtil.filterByDate( - delegator.findList("WorkEffortAndPartyAssign", ecl, null, UtilMisc.toList("estimatedStartDate", "priority"), null, false) - ); + validWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(ecl).orderBy("estimatedStartDate", "priority").filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -162,7 +157,7 @@ public class WorkEffortServices { EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"), EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PRTYASGN_UNASSIGNED")); - validWorkEfforts = EntityUtil.filterByDate(delegator.findList("WorkEffortAndPartyAssign", ecl, null, UtilMisc.toList("priority"), null, false)); + validWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(ecl).orderBy("priority").filterByDate().queryList(); ecl = EntityCondition.makeCondition( EntityOperator.AND, EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.get("partyId")), @@ -170,7 +165,7 @@ public class WorkEffortServices { EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CANCELLED "), EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_COMPLETED"), EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CLOSED")); - validWorkEfforts.addAll(EntityUtil.filterByDate(delegator.findList("WorkEffortAndPartyAssign", ecl, null, UtilMisc.toList("createdDate DESC"), null, false))); + validWorkEfforts.addAll(EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(ecl).orderBy("createdDate DESC").filterByDate().queryList()); } catch (GenericEntityException e) { Debug.logWarning(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -207,8 +202,7 @@ public class WorkEffortServices { constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED")); constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED")); - EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(constraints, EntityOperator.AND); - validWorkEfforts = EntityUtil.filterByDate(delegator.findList("WorkEffortAndPartyAssign", ecl, null, UtilMisc.toList("priority"), null, false)); + validWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(constraints).orderBy("priority").filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -244,10 +238,7 @@ public class WorkEffortServices { constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED")); constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED")); - EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(constraints); - roleWorkEfforts = EntityUtil.filterByDate( - delegator.findList("WorkEffortPartyAssignByRole", ecl, null, UtilMisc.toList("priority"), null, false) - ); + 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, @@ -283,10 +274,7 @@ public class WorkEffortServices { constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED")); constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED")); - EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(constraints); - groupWorkEfforts = EntityUtil.filterByDate( - delegator.findList("WorkEffortPartyAssignByGroup", ecl, null, UtilMisc.toList("priority"), null, false) - ); + groupWorkEfforts = EntityQuery.use(delegator).from("WorkEffortPartyAssignByGroup").where(constraints).orderBy("priority").filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -337,7 +325,7 @@ public class WorkEffortServices { // get a list of workEffortPartyAssignments, if empty then this user CANNOT view the event, unless they have permission to view all if (userLogin != null && userLogin.get("partyId") != null && workEffortId != null) { try { - workEffortPartyAssignments = delegator.findByAnd("WorkEffortPartyAssignment", UtilMisc.toMap("workEffortId", workEffortId, "partyId", userLogin.get("partyId")), null, false); + workEffortPartyAssignments = EntityQuery.use(delegator).from("WorkEffortPartyAssignment").where("workEffortId", workEffortId, "partyId", userLogin.get("partyId")).queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -635,20 +623,17 @@ public class WorkEffortServices { } */ - EntityCondition eclTotal = EntityCondition.makeCondition(entityExprList, EntityJoinOperator.AND); - - List<String> orderByList = UtilMisc.toList("estimatedStartDate"); try { List<GenericValue> tempWorkEfforts = null; if (UtilValidate.isNotEmpty(partyIdsToUse)) { // Debug.logInfo("=====conditions for party: " + eclTotal); - tempWorkEfforts = EntityUtil.filterByDate(delegator.findList("WorkEffortAndPartyAssignAndType", eclTotal, null, orderByList, null, false)); + tempWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssignAndType").where(entityExprList).orderBy("estimatedStartDate").filterByDate().queryList(); } else { - tempWorkEfforts = delegator.findList("WorkEffort", eclTotal, null, orderByList, null, false); + tempWorkEfforts = EntityQuery.use(delegator).from("WorkEffort").where(entityExprList).orderBy("estimatedStartDate").queryList(); } if (!"CAL_PERSONAL".equals(calendarType) && UtilValidate.isNotEmpty(fixedAssetId)) { // Get "new style" work efforts - tempWorkEfforts.addAll(EntityUtil.filterByDate(delegator.findList("WorkEffortAndFixedAssetAssign", eclTotal, null, orderByList, null, false))); + tempWorkEfforts.addAll(EntityQuery.use(delegator).from("WorkEffortAndFixedAssetAssign").where(entityExprList).orderBy("estimatedStartDate").filterByDate().queryList()); } validWorkEfforts = WorkEffortWorker.removeDuplicateWorkEfforts(tempWorkEfforts); } catch (GenericEntityException e) { @@ -790,15 +775,13 @@ public class WorkEffortServices { findIncomingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_RUNNING")); findIncomingProductionRunsConds.add(EntityCondition.makeCondition(findIncomingProductionRunsStatusConds, EntityOperator.OR)); - EntityConditionList<EntityCondition> findIncomingProductionRunsCondition = EntityCondition.makeCondition(findIncomingProductionRunsConds, EntityOperator.AND); - - List<GenericValue> incomingProductionRuns = delegator.findList("WorkEffortAndGoods", findIncomingProductionRunsCondition, null, UtilMisc.toList("-estimatedCompletionDate"), null, false); + List<GenericValue> incomingProductionRuns = EntityQuery.use(delegator).from("WorkEffortAndGoods").where(findIncomingProductionRunsConds).orderBy("-estimatedCompletionDate").queryList(); for (GenericValue incomingProductionRun: incomingProductionRuns) { double producedQtyTot = 0.0; if (incomingProductionRun.getString("currentStatusId").equals("PRUN_COMPLETED")) { - List<GenericValue> inventoryItems = delegator.findByAnd("WorkEffortAndInventoryProduced", UtilMisc.toMap("productId", productId, "workEffortId", incomingProductionRun.getString("workEffortId")), null, false); + List<GenericValue> inventoryItems = EntityQuery.use(delegator).from("WorkEffortAndInventoryProduced").where("productId", productId, "workEffortId", incomingProductionRun.getString("workEffortId")).queryList(); for (GenericValue inventoryItem: inventoryItems) { - GenericValue inventoryItemDetail = EntityUtil.getFirst(delegator.findByAnd("InventoryItemDetail", UtilMisc.toMap("inventoryItemId", inventoryItem.getString("inventoryItemId")), UtilMisc.toList("inventoryItemDetailSeqId"), false)); + GenericValue inventoryItemDetail = EntityQuery.use(delegator).from("InventoryItemDetail").where("inventoryItemId", inventoryItem.getString("inventoryItemId")).orderBy("inventoryItemDetailSeqId").queryFirst(); if (inventoryItemDetail != null && inventoryItemDetail.get("quantityOnHandDiff") != null) { Double inventoryItemQty = inventoryItemDetail.getDouble("quantityOnHandDiff"); producedQtyTot = producedQtyTot + inventoryItemQty.doubleValue(); @@ -857,8 +840,7 @@ public class WorkEffortServices { findOutgoingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_RUNNING")); findOutgoingProductionRunsConds.add(EntityCondition.makeCondition(findOutgoingProductionRunsStatusConds, EntityOperator.OR)); - EntityConditionList<EntityCondition> findOutgoingProductionRunsCondition = EntityCondition.makeCondition(findOutgoingProductionRunsConds, EntityOperator.AND); - List<GenericValue> outgoingProductionRuns = delegator.findList("WorkEffortAndGoods", findOutgoingProductionRunsCondition, null, UtilMisc.toList("-estimatedStartDate"), null, false); + List<GenericValue> outgoingProductionRuns = EntityQuery.use(delegator).from("WorkEffortAndGoods").where(findOutgoingProductionRunsConds).orderBy("-estimatedStartDate").queryList(); for (GenericValue outgoingProductionRun: outgoingProductionRuns) { String weFacilityId = outgoingProductionRun.getString("facilityId"); Double neededQuantity = outgoingProductionRun.getDouble("estimatedQuantity"); @@ -909,7 +891,10 @@ public class WorkEffortServices { Timestamp now = new Timestamp(System.currentTimeMillis()); List<GenericValue> eventReminders = null; try { - eventReminders = delegator.findList("WorkEffortEventReminder", EntityCondition.makeCondition(UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("reminderDateTime", EntityOperator.EQUALS, null), EntityCondition.makeCondition("reminderDateTime", EntityOperator.LESS_THAN_EQUAL_TO, now)), EntityOperator.OR), null, null, null, false); + eventReminders = EntityQuery.use(delegator).from("WorkEffortEventReminder") + .where(EntityCondition.makeCondition(UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("reminderDateTime", EntityOperator.EQUALS, null), + EntityCondition.makeCondition("reminderDateTime", EntityOperator.LESS_THAN_EQUAL_TO, now)), EntityOperator.OR)) + .queryList(); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "WorkEffortEventRemindersRetrivingError", UtilMisc.toMap("errorString", e), localePar)); @@ -1114,7 +1099,7 @@ public class WorkEffortServices { if (modelEntity != null && modelEntity.getField("recurrenceOffset") != null) { List<GenericValue> eventReminders = null; try { - eventReminders = delegator.findList("WorkEffortEventReminder", null, null, null, null, false); + eventReminders = EntityQuery.use(delegator).from("WorkEffortEventReminder").queryList(); for (GenericValue reminder : eventReminders) { if (UtilValidate.isNotEmpty(reminder.get("recurrenceOffset"))) { reminder.set("reminderOffset", reminder.get("recurrenceOffset")); Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java?rev=1642400&r1=1642399&r2=1642400&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java Sat Nov 29 08:02:05 2014 @@ -26,15 +26,11 @@ import javolution.util.FastList; import javolution.util.FastSet; import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityConditionList; -import org.ofbiz.entity.condition.EntityExpr; -import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.util.EntityQuery; /** WorkEffortWorker - Work Effort worker class. */ @@ -56,22 +52,13 @@ public class WorkEffortWorker { List<GenericValue> workEfforts = FastList.newInstance(); try { - EntityConditionList<EntityExpr> exprsLevelFirst = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition(left, workEffortId), - EntityCondition.makeCondition("workEffortAssocTypeId", workEffortAssocTypeId)), EntityOperator.AND); - List<GenericValue> childWEAssocsLevelFirst = delegator.findList("WorkEffortAssoc", exprsLevelFirst, null, null, null, true); + List<GenericValue> childWEAssocsLevelFirst = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, workEffortId, "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); for (GenericValue childWEAssocLevelFirst : childWEAssocsLevelFirst) { - EntityConditionList<EntityExpr> exprsLevelNext = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition(left, childWEAssocLevelFirst.get(right)), - EntityCondition.makeCondition("workEffortAssocTypeId", workEffortAssocTypeId)), EntityOperator.AND); - List<GenericValue> childWEAssocsLevelNext = delegator.findList("WorkEffortAssoc", exprsLevelNext, null, null, null, true); + List<GenericValue> childWEAssocsLevelNext = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, childWEAssocLevelFirst.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); while (UtilValidate.isNotEmpty(childWEAssocsLevelNext)) { List<GenericValue> tempWorkEffortList = FastList.newInstance(); for (GenericValue childWEAssocLevelNext : childWEAssocsLevelNext) { - EntityConditionList<EntityExpr> exprsLevelNth = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition(left, childWEAssocLevelNext.get(right)), - EntityCondition.makeCondition("workEffortAssocTypeId", workEffortAssocTypeId)), EntityOperator.AND); - List<GenericValue> childWEAssocsLevelNth = delegator.findList("WorkEffortAssoc", exprsLevelNth, null, null, null, true); + List<GenericValue> childWEAssocsLevelNth = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, childWEAssocLevelNext.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); if (UtilValidate.isNotEmpty(childWEAssocsLevelNth)) { tempWorkEffortList.addAll(childWEAssocsLevelNth); } |
Free forum by Nabble | Edit this page |