You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2008/08/14 17:13:18 UTC
svn commit: r685937 [1/2] - in
/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort: content/
project/ workeffort/
Author: doogie
Date: Thu Aug 14 08:13:17 2008
New Revision: 685937
URL: http://svn.apache.org/viewvc?rev=685937&view=rev
Log:
Generics, StringBuilder, for-loop, Number.valueOf.
Modified:
ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java
ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/project/ProjectWorker.java
ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java
ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java
ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java
ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java
ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.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=685937&r1=685936&r2=685937&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 Thu Aug 14 08:13:17 2008
@@ -51,7 +51,7 @@
public static final String module = WorkEffortContentWrapper.class.getName();
public static final String CACHE_KEY_SEPARATOR = "::";
- public static UtilCache workEffortContentCache = new UtilCache("workeffort.content.rendered", true);
+ public static UtilCache<String, String> workEffortContentCache = new UtilCache<String, String>("workeffort.content.rendered", true);
protected LocalDispatcher dispatcher;
protected GenericValue workEffort;
@@ -164,7 +164,7 @@
return null;
}
- public List getList(String contentTypeId) {
+ public List<String> getList(String contentTypeId) {
try {
return getWorkEffortContentTextList(workEffort, contentTypeId, locale, mimeTypeId, workEffort.getDelegator(), dispatcher);
} catch (Exception e) {
@@ -236,7 +236,7 @@
try {
if (useCache && workEffortContentCache.get(cacheKey) != null) {
- return (String) workEffortContentCache.get(cacheKey);
+ return workEffortContentCache.get(cacheKey);
}
Writer outWriter = new StringWriter();
@@ -304,24 +304,22 @@
}
if (workEffortContent != null) {
// when rendering the product content, always include the Product and ProductContent records that this comes from
- Map inContext = FastMap.newInstance();
+ Map<String, Object> inContext = FastMap.newInstance();
inContext.put("workEffort", workEffort);
inContext.put("workEffortContent", workEffortContent);
ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false);
}
}
- public static List getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException {
- List partyContentList = delegator.findByAndCache("WorkEffortContent", UtilMisc.toMap("workEffortId", workEffort.getString("partyId"), "workEffortContentTypeId", workEffortContentTypeId), UtilMisc.toList("-fromDate"));
+ public static List<String> getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException {
+ List<GenericValue> partyContentList = delegator.findByAndCache("WorkEffortContent", UtilMisc.toMap("workEffortId", workEffort.getString("partyId"), "workEffortContentTypeId", workEffortContentTypeId), UtilMisc.toList("-fromDate"));
partyContentList = EntityUtil.filterByDate(partyContentList);
- List contentList = FastList.newInstance();
+ List<String> contentList = FastList.newInstance();
if (partyContentList != null) {
- Iterator i = partyContentList.iterator();
- while (i.hasNext()) {
- GenericValue workEffortContent = (GenericValue) i.next();
+ for (GenericValue workEffortContent: partyContentList) {
StringWriter outWriter = new StringWriter();
- Map inContext = FastMap.newInstance();
+ Map<String, Object> inContext = FastMap.newInstance();
inContext.put("workEffort", workEffort);
inContext.put("workEffortContent", workEffortContent);
ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false);
@@ -345,7 +343,7 @@
throw new IllegalArgumentException("GenericDelegator missing");
}
- List workEffortContentList = null;
+ List<GenericValue> workEffortContentList = null;
try {
workEffortContentList = delegator.findByAndCache("WorkEffortContent", UtilMisc.toMap("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId), UtilMisc.toList("-fromDate"));
} catch (GeneralException e) {
Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/project/ProjectWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/project/ProjectWorker.java?rev=685937&r1=685936&r2=685937&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/project/ProjectWorker.java (original)
+++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/project/ProjectWorker.java Thu Aug 14 08:13:17 2008
@@ -19,12 +19,13 @@
package org.ofbiz.workeffort.project;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javax.servlet.jsp.PageContext;
+import javolution.util.FastList;
+
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericDelegator;
@@ -46,7 +47,7 @@
GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
GenericValue userLogin = (GenericValue) pageContext.getSession().getAttribute("userLogin");
- Collection validWorkEfforts = null;
+ Collection<GenericValue> validWorkEfforts = null;
if (userLogin != null && userLogin.get("partyId") != null) {
try {
@@ -103,7 +104,7 @@
if (projectWorkEffortId == null)
projectWorkEffortId = (String) pageContext.getRequest().getAttribute("projectWorkEffortId");
- Collection relatedWorkEfforts = null;
+ Collection<GenericValue> relatedWorkEfforts = null;
if (userLogin != null && userLogin.get("partyId") != null) {
try {
@@ -117,14 +118,11 @@
}
}
- Collection validWorkEfforts = new ArrayList();
+ Collection<GenericValue> validWorkEfforts = FastList.newInstance();
if (relatedWorkEfforts != null) {
- Iterator relatedWorkEffortsIter = relatedWorkEfforts.iterator();
-
try {
- while (relatedWorkEffortsIter.hasNext()) {
- GenericValue workEffortAssoc = (GenericValue) relatedWorkEffortsIter.next();
+ for (GenericValue workEffortAssoc: relatedWorkEfforts) {
GenericValue workEffort = workEffortAssoc.getRelatedOne("ToWorkEffort");
// only get phases
@@ -153,7 +151,7 @@
if (phaseWorkEffortId == null)
phaseWorkEffortId = (String) pageContext.getRequest().getAttribute("phaseWorkEffortId");
- Collection relatedWorkEfforts = null;
+ Collection<GenericValue> relatedWorkEfforts = null;
if (userLogin != null && userLogin.get("partyId") != null) {
try {
@@ -167,14 +165,11 @@
}
}
- Collection validWorkEfforts = new ArrayList();
+ Collection<GenericValue> validWorkEfforts = FastList.newInstance();
if (relatedWorkEfforts != null) {
- Iterator relatedWorkEffortsIter = relatedWorkEfforts.iterator();
-
try {
- while (relatedWorkEffortsIter.hasNext()) {
- GenericValue workEffortAssoc = (GenericValue) relatedWorkEffortsIter.next();
+ for (GenericValue workEffortAssoc: relatedWorkEfforts) {
GenericValue workEffort = workEffortAssoc.getRelatedOne("ToWorkEffort");
// only get phases
@@ -202,7 +197,7 @@
if (workEffortId == null)
workEffortId = (String) pageContext.getRequest().getAttribute("workEffortId");
- Collection notes = null;
+ Collection<GenericValue> notes = null;
if (userLogin != null && userLogin.get("partyId") != null) {
try {
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=685937&r1=685936&r2=685937&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 Thu Aug 14 08:13:17 2008
@@ -20,15 +20,15 @@
package org.ofbiz.workeffort.workeffort;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import javolution.util.FastList;
+
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilDateTime;
@@ -53,17 +53,17 @@
String stopWordBagOr = KeywordSearchUtil.getStopWordBagOr();
String stopWordBagAnd = KeywordSearchUtil.getStopWordBagAnd();
boolean removeStems = KeywordSearchUtil.getRemoveStems();
- Set stemSet = KeywordSearchUtil.getStemSet();
+ Set<String> stemSet = KeywordSearchUtil.getStemSet();
- Map keywords = new TreeMap();
- List strings = new ArrayList(50);
+ Map<String, Long> keywords = new TreeMap<String, Long>();
+ List<String> strings = FastList.newInstance();
int widWeight = 1;
try {
widWeight = Integer.parseInt(UtilProperties.getPropertyValue("workeffortsearch", "index.weight.WorkEffort.workEffortId", "1"));
} catch (Exception e) {
Debug.logWarning("Could not parse weight number: " + e.toString(), module);
}
- keywords.put(workEffort.getString("workEffortId").toLowerCase(), new Long(widWeight));
+ keywords.put(workEffort.getString("workEffortId").toLowerCase(), Long.valueOf(widWeight));
addWeightedKeywordSourceString(workEffort, "workEffortName", strings);
addWeightedKeywordSourceString(workEffort, "workEffortTypeId", strings);
@@ -88,10 +88,7 @@
}
String workEffortContentTypes = UtilProperties.getPropertyValue("workeffortsearch", "index.include.WorkEffortContentTypes");
- List workEffortContentTypeList = Arrays.asList(workEffortContentTypes.split(","));
- Iterator workEffortContentTypeIter = workEffortContentTypeList.iterator();
- while (workEffortContentTypeIter.hasNext()) {
- String workEffortContentTypeId = (String) workEffortContentTypeIter.next();
+ for (String workEffortContentTypeId: workEffortContentTypes.split(",")) {
int weight = 1;
try {
weight = Integer.parseInt(UtilProperties.getPropertyValue("workeffortsearch", "index.weight.WorkEffortContent." + workEffortContentTypeId, "1"));
@@ -99,31 +96,23 @@
Debug.logWarning("Could not parse weight number: " + e.toString(), module);
}
- List workEffortContentAndInfos = delegator.findByAnd("WorkEffortContentAndInfo", UtilMisc.toMap("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId), null);
- Iterator workEffortContentAndInfoIter = workEffortContentAndInfos.iterator();
- while (workEffortContentAndInfoIter.hasNext()) {
- GenericValue workEffortContentAndInfo = (GenericValue) workEffortContentAndInfoIter.next();
+ List<GenericValue> workEffortContentAndInfos = delegator.findByAnd("WorkEffortContentAndInfo", UtilMisc.toMap("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId), null);
+ for (GenericValue workEffortContentAndInfo: workEffortContentAndInfos) {
addWeightedDataResourceString(workEffortContentAndInfo, weight, strings, delegator, workEffort);
- List alternateViews = workEffortContentAndInfo.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"));
+ List<GenericValue> alternateViews = workEffortContentAndInfo.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"));
alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true);
- Iterator alternateViewIter = alternateViews.iterator();
- while (alternateViewIter.hasNext()) {
- GenericValue thisView = (GenericValue) alternateViewIter.next();
+ for (GenericValue thisView: alternateViews) {
addWeightedDataResourceString(thisView, weight, strings, delegator, workEffort);
}
}
}
- Iterator strIter = strings.iterator();
- while (strIter.hasNext()) {
- String str = (String) strIter.next();
+ for (String str: strings) {
// call process keywords method here
KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
}
- List toBeStored = new LinkedList();
- Iterator kiter = keywords.entrySet().iterator();
- while (kiter.hasNext()) {
- Map.Entry entry = (Map.Entry) kiter.next();
+ List<GenericValue> toBeStored = FastList.newInstance();
+ for (Map.Entry<String, Long> entry: keywords.entrySet()) {
GenericValue workEffortKeyword = delegator.makeValue("WorkEffortKeyword", UtilMisc.toMap("workEffortId", workEffort.getString("workEffortId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue()));
toBeStored.add(workEffortKeyword);
}
@@ -134,8 +123,8 @@
}
- public static void addWeightedDataResourceString(GenericValue dataResource, int weight, List strings, GenericDelegator delegator, GenericValue workEffort) {
- Map workEffortCtx = UtilMisc.toMap("workEffort", workEffort);
+ public static void addWeightedDataResourceString(GenericValue dataResource, int weight, List<String> strings, GenericDelegator delegator, GenericValue workEffort) {
+ Map<String, Object> workEffortCtx = UtilMisc.<String, Object>toMap("workEffort", workEffort);
try {
String contentText = DataResourceWorker.renderDataResourceAsText(delegator, dataResource.getString("dataResourceId"), workEffortCtx, null, null, false);
for (int i = 0; i < weight; i++) {
@@ -147,7 +136,7 @@
Debug.logError(e1, "Error getting content text to index", module);
}
}
- public static void addWeightedKeywordSourceString(GenericValue value, String fieldName, List strings) {
+ public static void addWeightedKeywordSourceString(GenericValue value, String fieldName, List<String> strings) {
if (value.getString(fieldName) != null) {
int weight = 1;
Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java?rev=685937&r1=685936&r2=685937&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java (original)
+++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java Thu Aug 14 08:13:17 2008
@@ -51,14 +51,14 @@
// TODO: restrict status transitions
String statusId = (String) wepa.get("statusId");
- Map context = UtilMisc.toMap("workEffortId", wepa.get("workEffortId"), "partyId", wepa.get("partyId"),
+ Map<String, Object> context = UtilMisc.toMap("workEffortId", wepa.get("workEffortId"), "partyId", wepa.get("partyId"),
"roleTypeId", wepa.get("roleTypeId"), "fromDate", wepa.get("fromDate"),
"userLogin", userLogin);
if ("CAL_ACCEPTED".equals(statusId)) {
// accept the activity assignment
try {
- Map results = dispatcher.runSync("wfAcceptAssignment", context);
+ Map<String, Object> results = dispatcher.runSync("wfAcceptAssignment", context);
if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
Debug.logWarning((String) results.get(ModelService.ERROR_MESSAGE), module);
@@ -68,7 +68,7 @@
} else if ("CAL_COMPLETED".equals(statusId)) {
// complete the activity assignment
try {
- Map results = dispatcher.runSync("wfCompleteAssignment", context);
+ Map<String, Object> results = dispatcher.runSync("wfCompleteAssignment", context);
if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
Debug.logWarning((String) results.get(ModelService.ERROR_MESSAGE), module);
@@ -78,7 +78,7 @@
} else if ("CAL_DECLINED".equals(statusId)) {
// decline the activity assignment
try {
- Map results = dispatcher.runSync("wfDeclineAssignment", context);
+ Map<String, Object> results = dispatcher.runSync("wfDeclineAssignment", context);
if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
Debug.logWarning((String) results.get(ModelService.ERROR_MESSAGE), module);
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=685937&r1=685936&r2=685937&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 Thu Aug 14 08:13:17 2008
@@ -21,9 +21,7 @@
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -84,17 +82,17 @@
public static final String module = WorkEffortSearch.class.getName();
public static final String resource = "WorkEffortUiLabels";
- public static ArrayList searchWorkEfforts(List workEffortSearchConstraintList, ResultSortOrder resultSortOrder, GenericDelegator delegator, String visitId) {
+ public static ArrayList<String> searchWorkEfforts(List<? extends WorkEffortSearchConstraint> workEffortSearchConstraintList, ResultSortOrder resultSortOrder, GenericDelegator delegator, String visitId) {
WorkEffortSearchContext workEffortSearchContext = new WorkEffortSearchContext(delegator, visitId);
workEffortSearchContext.addWorkEffortSearchConstraints(workEffortSearchConstraintList);
workEffortSearchContext.setResultSortOrder(resultSortOrder);
- ArrayList workEffortIds = workEffortSearchContext.doSearch();
+ ArrayList<String> workEffortIds = workEffortSearchContext.doSearch();
return workEffortIds;
}
- public static void getAllSubWorkEffortIds(String workEffortId, Set workEffortIdSet, GenericDelegator delegator, Timestamp nowTimestamp) {
+ public static void getAllSubWorkEffortIds(String workEffortId, Set<String> workEffortIdSet, GenericDelegator delegator, Timestamp nowTimestamp) {
if (nowTimestamp == null) {
nowTimestamp = UtilDateTime.nowTimestamp();
}
@@ -105,11 +103,8 @@
// now find all sub-categories, filtered by effective dates, and call this routine for them
try {
// Find WorkEffortAssoc, workEffortAssocTypeId=WORK_EFF_BREAKDOWN
- List workEffortAssocList = delegator.findByAndCache("WorkEffortAssoc", UtilMisc.toMap("workEffortIdFrom", workEffortId, "workEffortAssocTypeId", "WORK_EFF_BREAKDOWN"));
- Iterator workEffortAssocIter = workEffortAssocList.iterator();
- while (workEffortAssocIter.hasNext()) {
- GenericValue workEffortAssoc = (GenericValue) workEffortAssocIter.next();
-
+ List<GenericValue> workEffortAssocList = delegator.findByAndCache("WorkEffortAssoc", UtilMisc.toMap("workEffortIdFrom", workEffortId, "workEffortAssocTypeId", "WORK_EFF_BREAKDOWN"));
+ for (GenericValue workEffortAssoc: workEffortAssocList) {
String subWorkEffortId = workEffortAssoc.getString("workEffortIdTo");
if (workEffortIdSet.contains(subWorkEffortId)) {
// if this category has already been traversed, no use doing it again; this will also avoid infinite loops
@@ -123,12 +118,9 @@
}
// Find WorkEffort where current workEffortId = workEffortParentId; only select minimal fields to keep the size low
- List childWorkEffortList = delegator.findList("WorkEffort", EntityCondition.makeCondition("workEffortParentId", EntityComparisonOperator.EQUALS, workEffortId),
+ List<GenericValue> childWorkEffortList = delegator.findList("WorkEffort", EntityCondition.makeCondition("workEffortParentId", EntityComparisonOperator.EQUALS, workEffortId),
UtilMisc.toSet("workEffortId", "workEffortParentId"), null, null, true);
- Iterator childWorkEffortIter = childWorkEffortList.iterator();
- while (childWorkEffortIter.hasNext()) {
- GenericValue childWorkEffort = (GenericValue) childWorkEffortIter.next();
-
+ for (GenericValue childWorkEffort: childWorkEffortList) {
String subWorkEffortId = childWorkEffort.getString("workEffortId");
if (workEffortIdSet.contains(subWorkEffortId)) {
// if this category has already been traversed, no use doing it again; this will also avoid infinite loops
@@ -145,17 +137,17 @@
public static class WorkEffortSearchContext {
public int index = 1;
- public List entityConditionList = new LinkedList();
- public List orderByList = new LinkedList();
- public List fieldsToSelect = UtilMisc.toList("workEffortId");
+ public List<EntityCondition> entityConditionList = FastList.newInstance();
+ public List<String> orderByList = FastList.newInstance();
+ public List<String> fieldsToSelect = UtilMisc.toList("workEffortId");
public DynamicViewEntity dynamicViewEntity = new DynamicViewEntity();
public boolean workEffortIdGroupBy = false;
public boolean includedKeywordSearch = false;
public Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
- public List keywordFixedOrSetAndList = new LinkedList();
- public Set orKeywordFixedSet = new HashSet();
- public Set andKeywordFixedSet = new HashSet();
- public List workEffortSearchConstraintList = new LinkedList();
+ public List<Set<String>> keywordFixedOrSetAndList = FastList.newInstance();
+ public Set<String> orKeywordFixedSet = FastSet.newInstance();
+ public Set<String> andKeywordFixedSet = FastSet.newInstance();
+ public List<GenericValue> workEffortSearchConstraintList = FastList.newInstance();
public ResultSortOrder resultSortOrder = null;
public Integer resultOffset = null;
public Integer maxResults = null;
@@ -173,11 +165,9 @@
return this.delegator;
}
- public void addWorkEffortSearchConstraints(List workEffortSearchConstraintList) {
+ public void addWorkEffortSearchConstraints(List<? extends WorkEffortSearchConstraint> workEffortSearchConstraintList) {
// Go through the constraints and add them in
- Iterator workEffortSearchConstraintIter = workEffortSearchConstraintList.iterator();
- while (workEffortSearchConstraintIter.hasNext()) {
- WorkEffortSearchConstraint constraint = (WorkEffortSearchConstraint) workEffortSearchConstraintIter.next();
+ for (WorkEffortSearchConstraint constraint: workEffortSearchConstraintList) {
constraint.addConstraint(this);
}
}
@@ -198,12 +188,12 @@
return this.totalResults;
}
- public ArrayList doSearch() {
+ public ArrayList<String> doSearch() {
long startMillis = System.currentTimeMillis();
// do the query
EntityListIterator eli = this.doQuery(delegator);
- ArrayList workEffortIds = this.makeWorkEffortIdList(eli);
+ ArrayList<String> workEffortIds = this.makeWorkEffortIdList(eli);
if (eli != null) {
try {
eli.close();
@@ -216,7 +206,7 @@
double totalSeconds = ((double)endMillis - (double)startMillis)/1000.0;
// store info about results in the database, attached to the user's visitId, if specified
- this.saveSearchResultInfo(new Long(workEffortIds.size()), new Double(totalSeconds));
+ this.saveSearchResultInfo(Long.valueOf(workEffortIds.size()), Double.valueOf(totalSeconds));
return workEffortIds;
}
@@ -236,9 +226,9 @@
}
// remove all or sets from the or set and list where the or set is size 1 and put them in the and list
- Iterator keywordFixedOrSetAndTestIter = keywordFixedOrSetAndList.iterator();
+ Iterator<Set<String>> keywordFixedOrSetAndTestIter = keywordFixedOrSetAndList.iterator();
while (keywordFixedOrSetAndTestIter.hasNext()) {
- Set keywordFixedOrSet = (Set) keywordFixedOrSetAndTestIter.next();
+ Set<String> keywordFixedOrSet = keywordFixedOrSetAndTestIter.next();
if (keywordFixedOrSet.size() == 0) {
keywordFixedOrSetAndTestIter.remove();
} else if (keywordFixedOrSet.size() == 1) {
@@ -256,10 +246,7 @@
if (andKeywordFixedSet.size() > 0) {
// add up the relevancyWeight fields from all keyword member entities for a total to sort by
- Iterator keywordIter = andKeywordFixedSet.iterator();
- while (keywordIter.hasNext()) {
- String keyword = (String) keywordIter.next();
-
+ for (String keyword: andKeywordFixedSet) {
// make index based values and increment
String entityAlias = "PK" + index;
String prefix = "pk" + index;
@@ -281,9 +268,7 @@
}
}
if (keywordFixedOrSetAndList.size() > 0) {
- Iterator keywordFixedOrSetAndIter = keywordFixedOrSetAndList.iterator();
- while (keywordFixedOrSetAndIter.hasNext()) {
- Set keywordFixedOrSet = (Set) keywordFixedOrSetAndIter.next();
+ for (Set<String> keywordFixedOrSet: keywordFixedOrSetAndList) {
// make index based values and increment
String entityAlias = "PK" + index;
String prefix = "pk" + index;
@@ -292,10 +277,8 @@
dynamicViewEntity.addMemberEntity(entityAlias, "WorkEffortKeyword");
dynamicViewEntity.addAlias(entityAlias, prefix + "Keyword", "keyword", null, null, null, null);
dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId"));
- List keywordOrList = new LinkedList();
- Iterator keywordIter = keywordFixedOrSet.iterator();
- while (keywordIter.hasNext()) {
- String keyword = (String) keywordIter.next();
+ List<EntityExpr> keywordOrList = FastList.newInstance();
+ for (String keyword: keywordFixedOrSet) {
keywordOrList.add(EntityCondition.makeCondition(prefix + "Keyword", EntityOperator.LIKE, keyword));
}
entityConditionList.add(EntityCondition.makeCondition(keywordOrList, EntityOperator.OR));
@@ -322,7 +305,7 @@
if (resultSortOrder != null) {
resultSortOrder.setSortOrder(this);
}
- dynamicViewEntity.addAlias("WEFF", "workEffortId", null, null, null, new Boolean(workEffortIdGroupBy), null);
+ 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);
@@ -342,8 +325,8 @@
return eli;
}
- public ArrayList makeWorkEffortIdList(EntityListIterator eli) {
- ArrayList workEffortIds = new ArrayList(maxResults == null ? 100 : maxResults.intValue());
+ public ArrayList<String> makeWorkEffortIdList(EntityListIterator eli) {
+ ArrayList<String> workEffortIds = new ArrayList<String>(maxResults == null ? 100 : maxResults.intValue());
if (eli == null) {
Debug.logWarning("The eli is null, returning zero results", module);
return workEffortIds;
@@ -391,7 +374,7 @@
if (this.resultOffset != null) {
failTotal = this.resultOffset.intValue() - 1;
}
- this.totalResults = new Integer(failTotal);
+ this.totalResults = Integer.valueOf(failTotal);
return workEffortIds;
}
@@ -400,7 +383,7 @@
int numRetreived = 1;
int duplicatesFound = 0;
- Set workEffortIdSet = new HashSet();
+ Set<String> workEffortIdSet = FastSet.newInstance();
workEffortIds.add(searchResult.getString("workEffortId"));
workEffortIdSet.add(searchResult.getString("workEffortId"));
@@ -416,10 +399,10 @@
}
/*
- StringBuffer lineMsg = new StringBuffer("Got search result line: ");
- Iterator fieldsToSelectIter = fieldsToSelect.iterator();
+ StringBuilder lineMsg = new StringBuilder("Got search result line: ");
+ Iterator<String> fieldsToSelectIter = fieldsToSelect.iterator();
while (fieldsToSelectIter.hasNext()) {
- String fieldName = (String) fieldsToSelectIter.next();
+ String fieldName = fieldsToSelectIter.next();
lineMsg.append(fieldName);
lineMsg.append("=");
lineMsg.append(searchResult.get(fieldName));
@@ -435,7 +418,7 @@
// we weren't at the end, so go to the end and get the index
//Debug.logInfo("Getting totalResults from ending index - before last() currentIndex=" + eli.currentIndex(), module);
if (eli.last()) {
- this.totalResults = new Integer(eli.currentIndex());
+ this.totalResults = Integer.valueOf(eli.currentIndex());
//Debug.logInfo("Getting totalResults from ending index - after last() currentIndex=" + eli.currentIndex(), module);
}
}
@@ -444,7 +427,7 @@
if (this.resultOffset != null) {
total += (this.resultOffset.intValue() - 1);
}
- this.totalResults = new Integer(total);
+ this.totalResults = Integer.valueOf(total);
}
Debug.logInfo("Got search values, numRetreived=" + numRetreived + ", totalResults=" + totalResults + ", maxResults=" + maxResults + ", resultOffset=" + resultOffset + ", duplicatesFound(in the current results)=" + duplicatesFound, module);
@@ -478,10 +461,8 @@
workEffortSearchResult.set("searchDate", nowTimestamp);
workEffortSearchResult.create();
- Iterator workEffortSearchConstraintIter = workEffortSearchConstraintList.iterator();
int seqId = 1;
- while (workEffortSearchConstraintIter.hasNext()) {
- GenericValue workEffortSearchConstraint = (GenericValue) workEffortSearchConstraintIter.next();
+ for (GenericValue workEffortSearchConstraint: workEffortSearchConstraintList) {
workEffortSearchConstraint.set("workEffortSearchResultId", workEffortSearchResultId);
workEffortSearchConstraint.set("constraintSeqId", Integer.toString(seqId));
workEffortSearchConstraint.create();
@@ -526,7 +507,7 @@
}
public void addConstraint(WorkEffortSearchContext workEffortSearchContext) {
- Set workEffortIdSet = FastSet.newInstance();
+ Set<String> workEffortIdSet = FastSet.newInstance();
if (includeSubWorkEfforts) {
// find all sub-categories recursively, make a Set of workEffortId
WorkEffortSearch.getAllSubWorkEffortIds(workEffortId, workEffortIdSet, workEffortSearchContext.getDelegator(), workEffortSearchContext.nowTimestamp);
@@ -553,7 +534,7 @@
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId","workEffortIdFrom"));
- List assocConditionFromTo = FastList.newInstance();
+ List<EntityExpr> assocConditionFromTo = FastList.newInstance();
assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "WorkEffortIdTo", EntityOperator.IN, workEffortIdSet));
if (UtilValidate.isNotEmpty(workEffortAssocTypeId)) {
assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", EntityOperator.EQUALS, workEffortAssocTypeId));
@@ -574,7 +555,7 @@
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId","workEffortIdTo"));
- List assocConditionToFrom = FastList.newInstance();
+ List<EntityExpr> assocConditionToFrom = FastList.newInstance();
assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "WorkEffortIdFrom", EntityOperator.IN, workEffortIdSet));
if (UtilValidate.isNotEmpty(workEffortAssocTypeId)) {
assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", EntityOperator.EQUALS, workEffortAssocTypeId));
@@ -602,7 +583,7 @@
Debug.logError(e, "Error looking up WorkEffortAssocConstraint pretty print info: " + e.toString(), module);
}
- StringBuffer ppBuf = new StringBuffer();
+ StringBuilder ppBuf = new StringBuilder();
ppBuf.append(UtilProperties.getMessage(resource, "WorkEffortAssoc", locale) + ": ");
if (workEffort != null) {
ppBuf.append(workEffort.getString("workEffortName"));
@@ -623,7 +604,7 @@
}
}
if (this.includeSubWorkEfforts) {
- ppBuf.append(" (" + UtilProperties.getMessage(resource, "WorkEffortIncludeAllSubWorkEfforts", locale) + ")");
+ ppBuf.append(" (").append(UtilProperties.getMessage(resource, "WorkEffortIncludeAllSubWorkEfforts", locale)).append(")");
}
return ppBuf.toString();
}
@@ -676,16 +657,16 @@
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ReviewText", "reviewText", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId"));
workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(prefix + "ReviewText"), EntityOperator.LIKE, EntityFunction.UPPER("%" + reviewTextString + "%")));
- Map valueMap = UtilMisc.toMap("constraintName", constraintName, "infoString", this.reviewTextString);
+ Map<String, String> valueMap = UtilMisc.toMap("constraintName", constraintName, "infoString", this.reviewTextString);
workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", valueMap));
}
/** pretty print for log messages and even UI stuff */
public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) {
- StringBuffer ppBuf = new StringBuffer();
+ StringBuilder ppBuf = new StringBuilder();
ppBuf.append(UtilProperties.getMessage(resource, "WorkEffortReviews", locale) + ": \"");
- ppBuf.append(this.reviewTextString + "\", " + UtilProperties.getMessage(resource, "WorkEffortKeywordWhere", locale) + " ");
+ ppBuf.append(this.reviewTextString).append("\", ").append(UtilProperties.getMessage(resource, "WorkEffortKeywordWhere", locale)).append(" ");
return ppBuf.toString();
}
@@ -752,7 +733,7 @@
} catch (GenericEntityException e) {
Debug.logError(e, "Error finding PartyAssignmentConstraint information for constraint pretty print", module);
}
- StringBuffer ppBuf = new StringBuffer();
+ StringBuilder ppBuf = new StringBuilder();
ppBuf.append("WorkEffort Assignment: ");
if (partyNameView != null) {
if (UtilValidate.isNotEmpty(partyNameView.getString("firstName"))) {
@@ -818,10 +799,10 @@
public static class ProductSetConstraint extends WorkEffortSearchConstraint {
public static final String constraintName = "ProductSet";
- protected Set productIdSet;
+ protected Set<String> productIdSet;
- public ProductSetConstraint(Collection productIdSet) {
- this.productIdSet = new HashSet(productIdSet);
+ public ProductSetConstraint(Collection<String> productIdSet) {
+ this.productIdSet = UtilMisc.makeSetWritable(productIdSet);
}
public void addConstraint(WorkEffortSearchContext workEffortSearchContext) {
@@ -841,10 +822,10 @@
workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, workEffortSearchContext.nowTimestamp));
// add in workEffortSearchConstraint, don't worry about the workEffortSearchResultId or constraintSeqId, those will be fill in later
- StringBuffer productIdInfo = new StringBuffer();
- Iterator productIdIter = this.productIdSet.iterator();
+ StringBuilder productIdInfo = new StringBuilder();
+ Iterator<String> productIdIter = this.productIdSet.iterator();
while (productIdIter.hasNext()) {
- String productId = (String) productIdIter.next();
+ String productId = productIdIter.next();
productIdInfo.append(productId);
if (productIdIter.hasNext()) {
productIdInfo.append(",");
@@ -855,11 +836,11 @@
}
public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) {
- StringBuffer infoOut = new StringBuffer();
+ StringBuilder infoOut = new StringBuilder();
try {
- Iterator productIdIter = this.productIdSet.iterator();
+ Iterator<String> productIdIter = this.productIdSet.iterator();
while (productIdIter.hasNext()) {
- String productId = (String) productIdIter.next();
+ String productId = productIdIter.next();
GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
if (product == null) {
infoOut.append("[");
@@ -920,15 +901,13 @@
}
}
- public Set makeFullKeywordSet(GenericDelegator delegator) {
- Set keywordSet = KeywordSearchUtil.makeKeywordSet(this.keywordsString, null, true);
- Set fullKeywordSet = new TreeSet();
+ public Set<String> makeFullKeywordSet(GenericDelegator delegator) {
+ Set<String> keywordSet = KeywordSearchUtil.makeKeywordSet(this.keywordsString, null, true);
+ Set<String> fullKeywordSet = new TreeSet<String>();
// expand the keyword list according to the thesaurus and create a new set of keywords
- Iterator keywordIter = keywordSet.iterator();
- while (keywordIter.hasNext()) {
- String keyword = (String) keywordIter.next();
- Set expandedSet = new TreeSet();
+ for (String keyword: keywordSet) {
+ Set<String> expandedSet = new TreeSet<String>();
boolean replaceEntered = KeywordSearchUtil.expandKeywordForSearch(keyword, expandedSet, delegator);
fullKeywordSet.addAll(expandedSet);
if (!replaceEntered) {
@@ -948,31 +927,29 @@
//but then the sets should be and'ed to produce the overall expression; create the SQL for this
//needs some work as the current method only support a list of and'ed words and a list of or'ed words, not
//a list of or'ed sets to be and'ed together
- Set keywordSet = KeywordSearchUtil.makeKeywordSet(this.keywordsString, null, true);
+ Set<String> keywordSet = KeywordSearchUtil.makeKeywordSet(this.keywordsString, null, true);
// expand the keyword list according to the thesaurus and create a new set of keywords
- Iterator keywordIter = keywordSet.iterator();
- while (keywordIter.hasNext()) {
- String keyword = (String) keywordIter.next();
- Set expandedSet = new TreeSet();
+ for (String keyword: keywordSet) {
+ Set<String> expandedSet = new TreeSet<String>();
boolean replaceEntered = KeywordSearchUtil.expandKeywordForSearch(keyword, expandedSet, workEffortSearchContext.getDelegator());
if (!replaceEntered) {
expandedSet.add(keyword);
}
- Set fixedSet = KeywordSearchUtil.fixKeywordsForSearch(expandedSet, anyPrefix, anySuffix, removeStems, isAnd);
- Set fixedKeywordSet = new HashSet();
+ Set<String> fixedSet = KeywordSearchUtil.fixKeywordsForSearch(expandedSet, anyPrefix, anySuffix, removeStems, isAnd);
+ Set<String> fixedKeywordSet = FastSet.newInstance();
fixedKeywordSet.addAll(fixedSet);
workEffortSearchContext.keywordFixedOrSetAndList.add(fixedKeywordSet);
}
} else {
// when isAnd is false, just add all of the new entries to the big list
- Set keywordFirstPass = makeFullKeywordSet(workEffortSearchContext.getDelegator()); // includes keyword expansion, etc
- Set keywordSet = KeywordSearchUtil.fixKeywordsForSearch(keywordFirstPass, anyPrefix, anySuffix, removeStems, isAnd);
+ Set<String> keywordFirstPass = makeFullKeywordSet(workEffortSearchContext.getDelegator()); // includes keyword expansion, etc
+ Set<String> keywordSet = KeywordSearchUtil.fixKeywordsForSearch(keywordFirstPass, anyPrefix, anySuffix, removeStems, isAnd);
workEffortSearchContext.orKeywordFixedSet.addAll(keywordSet);
}
// add in workEffortSearchConstraint, don't worry about the workEffortSearchResultId or constraintSeqId, those will be fill in later
- Map valueMap = UtilMisc.toMap("constraintName", constraintName, "infoString", this.keywordsString);
+ Map<String, String> valueMap = UtilMisc.toMap("constraintName", constraintName, "infoString", this.keywordsString);
valueMap.put("anyPrefix", this.anyPrefix ? "Y" : "N");
valueMap.put("anySuffix", this.anySuffix ? "Y" : "N");
valueMap.put("isAnd", this.isAnd ? "Y" : "N");
@@ -982,9 +959,9 @@
/** pretty print for log messages and even UI stuff */
public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) {
- StringBuffer ppBuf = new StringBuffer();
- ppBuf.append(UtilProperties.getMessage(resource, "WorkEffortKeywords", locale) + ": \"");
- ppBuf.append(this.keywordsString + "\", " + UtilProperties.getMessage(resource, "WorkEffortKeywordWhere", locale) + " ");
+ StringBuilder ppBuf = new StringBuilder();
+ ppBuf.append(UtilProperties.getMessage(resource, "WorkEffortKeywords", locale)).append(": \"");
+ ppBuf.append(this.keywordsString).append("\", ").append(UtilProperties.getMessage(resource, "WorkEffortKeywordWhere", locale)).append(" ");
ppBuf.append(isAnd ? UtilProperties.getMessage(resource, "WorkEffortKeywordAllWordsMatch", locale) : UtilProperties.getMessage(resource, "WorkEffortKeywordAnyWordMatches", locale));
return ppBuf.toString();
}
@@ -1034,7 +1011,7 @@
public void addConstraint(WorkEffortSearchContext workEffortSearchContext) {
workEffortSearchContext.dynamicViewEntity.addAlias("WEFF", "lastModifiedDate", "lastModifiedDate", null, null, null, null);
- EntityConditionList dateConditions = null;
+ EntityConditionList<EntityExpr> dateConditions = null;
EntityExpr dateCondition=null;
if(fromDate !=null && thruDate!=null) {
dateConditions= EntityCondition.makeCondition(UtilMisc.toList(
@@ -1045,7 +1022,7 @@
} else if (thruDate != null) {
dateCondition = EntityCondition.makeCondition("lastModifiedDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate);
}
- EntityConditionList conditions = null;
+ EntityConditionList<? extends EntityCondition> conditions = null;
if(fromDate !=null && thruDate!=null) {
conditions=EntityCondition.makeCondition(UtilMisc.toList(
dateConditions,
@@ -1066,9 +1043,9 @@
/** pretty print for log messages and even UI stuff */
public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) {
- StringBuffer ppBuf = new StringBuffer();
- ppBuf.append(UtilProperties.getMessage(resource, "WorkEffortLastModified", locale) + ": \"");
- ppBuf.append(fromDate +"-" +thruDate + "\", " + UtilProperties.getMessage(resource, "WorkEffortLastModified", locale) + " ");
+ StringBuilder ppBuf = new StringBuilder();
+ ppBuf.append(UtilProperties.getMessage(resource, "WorkEffortLastModified", locale)).append(": \"");
+ ppBuf.append(fromDate).append("-").append(thruDate).append("\", ").append(UtilProperties.getMessage(resource, "WorkEffortLastModified", locale)).append(" ");
return ppBuf.toString();
}
Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java?rev=685937&r1=685936&r2=685937&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java (original)
+++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java Thu Aug 14 08:13:17 2008
@@ -19,16 +19,18 @@
package org.ofbiz.workeffort.workeffort;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import javolution.util.FastMap;
+
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.webapp.stats.VisitHandler;
import org.ofbiz.workeffort.workeffort.WorkEffortSearch.ResultSortOrder;
+import org.ofbiz.workeffort.workeffort.WorkEffortSearch.WorkEffortSearchConstraint;
import org.ofbiz.workeffort.workeffort.WorkEffortSearch.WorkEffortSearchContext;
import org.ofbiz.workeffort.workeffort.WorkEffortSearchSession.WorkEffortSearchOptions;
@@ -58,13 +60,13 @@
highIndex = (viewIndex + 1) * viewSize;
// setup resultOffset and maxResults, noting that resultOffset is 1 based, not zero based as these numbers
- Integer resultOffset = new Integer(lowIndex + 1);
- Integer maxResults = new Integer(viewSize);
+ Integer resultOffset = Integer.valueOf(lowIndex + 1);
+ Integer maxResults = Integer.valueOf(viewSize);
// ========== Do the actual search
ArrayList workEffortIds = null;
String visitId = VisitHandler.getVisitId(session);
- List workEffortSearchConstraintList = WorkEffortSearchOptions.getConstraintList(session);
+ List<WorkEffortSearchConstraint> workEffortSearchConstraintList = WorkEffortSearchOptions.getConstraintList(session);
// if no constraints, don't do a search...
if (workEffortSearchConstraintList != null && workEffortSearchConstraintList.size() > 0) {
// if the search options have changed since the last search, put at the beginning of the options history list
@@ -92,18 +94,18 @@
}
// ========== Setup other display info
- List searchConstraintStrings = WorkEffortSearchSession.searchGetConstraintStrings(false, session, delegator);
+ List<String> searchConstraintStrings = WorkEffortSearchSession.searchGetConstraintStrings(false, session, delegator);
String searchSortOrderString = WorkEffortSearchSession.searchGetSortOrderString(false, request);
// ========== populate the result Map
- Map result = new HashMap();
+ Map<String, Object> result = FastMap.newInstance();
result.put("workEffortIds", workEffortIds);
- result.put("viewIndex", new Integer(viewIndex));
- result.put("viewSize", new Integer(viewSize));
- result.put("listSize", new Integer(listSize));
- result.put("lowIndex", new Integer(lowIndex));
- result.put("highIndex", new Integer(highIndex));
+ result.put("viewIndex", Integer.valueOf(viewIndex));
+ result.put("viewSize", Integer.valueOf(viewSize));
+ result.put("listSize", Integer.valueOf(listSize));
+ result.put("lowIndex", Integer.valueOf(lowIndex));
+ result.put("highIndex", Integer.valueOf(highIndex));
result.put("searchConstraintStrings", searchConstraintStrings);
result.put("searchSortOrderString", searchSortOrderString);
Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java?rev=685937&r1=685936&r2=685937&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java (original)
+++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java Thu Aug 14 08:13:17 2008
@@ -19,9 +19,7 @@
package org.ofbiz.workeffort.workeffort;
import java.sql.Timestamp;
-import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -29,8 +27,12 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import javolution.util.FastList;
+
import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.workeffort.workeffort.WorkEffortSearch.ResultSortOrder;
@@ -41,7 +43,7 @@
public static final String module = WorkEffortSearchSession.class.getName();
public static class WorkEffortSearchOptions implements java.io.Serializable {
- protected List constraintList = null;
+ protected List<WorkEffortSearchConstraint> constraintList = null;
protected ResultSortOrder resultSortOrder = null;
protected Integer viewIndex = null;
protected Integer viewSize = null;
@@ -50,23 +52,23 @@
/** Basic copy constructor */
public WorkEffortSearchOptions(WorkEffortSearchOptions workEffortSearchOptions) {
- this.constraintList = new LinkedList(workEffortSearchOptions.constraintList);
+ this.constraintList = UtilMisc.makeListWritable(workEffortSearchOptions.constraintList);
this.resultSortOrder = workEffortSearchOptions.resultSortOrder;
this.viewIndex = workEffortSearchOptions.viewIndex;
this.viewSize = workEffortSearchOptions.viewSize;
this.changed = workEffortSearchOptions.changed;
}
- public List getConstraintList() {
+ public List<WorkEffortSearchConstraint> getConstraintList() {
return this.constraintList;
}
- public static List getConstraintList(HttpSession session) {
+ public static List<WorkEffortSearchConstraint> getConstraintList(HttpSession session) {
return getWorkEffortSearchOptions(session).constraintList;
}
public static void addConstraint(WorkEffortSearchConstraint workEffortSearchConstraint, HttpSession session) {
WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(session);
if (workEffortSearchOptions.constraintList == null) {
- workEffortSearchOptions.constraintList = new LinkedList();
+ workEffortSearchOptions.constraintList = FastList.newInstance();
}
if (!workEffortSearchOptions.constraintList.contains(workEffortSearchConstraint)) {
workEffortSearchOptions.constraintList.add(workEffortSearchConstraint);
@@ -127,15 +129,13 @@
this.viewSize = viewSize;
}
- public List searchGetConstraintStrings(boolean detailed, GenericDelegator delegator, Locale locale) {
- List workEffortSearchConstraintList = this.getConstraintList();
- List constraintStrings = new ArrayList();
+ public List<String> searchGetConstraintStrings(boolean detailed, GenericDelegator delegator, Locale locale) {
+ List<WorkEffortSearchConstraint> workEffortSearchConstraintList = this.getConstraintList();
+ List<String> constraintStrings = FastList.newInstance();
if (workEffortSearchConstraintList == null) {
return constraintStrings;
}
- Iterator workEffortSearchConstraintIter = workEffortSearchConstraintList.iterator();
- while (workEffortSearchConstraintIter.hasNext()) {
- WorkEffortSearchConstraint workEffortSearchConstraint = (WorkEffortSearchConstraint) workEffortSearchConstraintIter.next();
+ for (WorkEffortSearchConstraint workEffortSearchConstraint: workEffortSearchConstraintList) {
if (workEffortSearchConstraint == null) continue;
String constraintString = workEffortSearchConstraint.prettyPrintConstraint(delegator, detailed, locale);
if (UtilValidate.isNotEmpty(constraintString)) {
@@ -157,7 +157,7 @@
return workEffortSearchOptions;
}
- public static void processSearchParameters(Map parameters, HttpServletRequest request) {
+ public static void processSearchParameters(Map<String, Object> parameters, HttpServletRequest request) {
Boolean alreadyRun = (Boolean) request.getAttribute("processSearchParametersAlreadyRun");
if (Boolean.TRUE.equals(alreadyRun)) {
return;
@@ -208,10 +208,10 @@
// add a Product Set to the search
if (UtilValidate.isNotEmpty((String) parameters.get("productId_1"))) {
- List productSet = new ArrayList();
- productSet.add(parameters.get("productId_1"));
+ List<String> productSet = FastList.newInstance();
+ productSet.add((String) parameters.get("productId_1"));
if (UtilValidate.isNotEmpty((String) parameters.get("productId_2"))) {
- productSet.add(parameters.get("productId_2"));
+ productSet.add((String) parameters.get("productId_2"));
}
searchAddConstraint(new WorkEffortSearch.ProductSetConstraint(productSet), session);
constraintsChanged = true;
@@ -267,7 +267,7 @@
} catch (Exception e) {
Debug.logError(e, "Error formatting VIEW_INDEX, setting to 0", module);
// we could just do nothing here, but we know something was specified so we don't want to use the previous value from the session
- workEffortSearchOptions.setViewIndex(new Integer(0));
+ workEffortSearchOptions.setViewIndex(Integer.valueOf(0));
}
}
@@ -277,7 +277,7 @@
workEffortSearchOptions.setViewSize(Integer.valueOf(viewSizeStr));
} catch (Exception e) {
Debug.logError(e, "Error formatting VIEW_SIZE, setting to 20", module);
- workEffortSearchOptions.setViewSize(new Integer(20));
+ workEffortSearchOptions.setViewSize(Integer.valueOf(20));
}
}
}
@@ -288,16 +288,16 @@
public static void searchSetSortOrder(ResultSortOrder resultSortOrder, HttpSession session) {
WorkEffortSearchOptions.setResultSortOrder(resultSortOrder, session);
}
- public static List getSearchOptionsHistoryList(HttpSession session) {
- List optionsHistoryList = (List) session.getAttribute("_WORK_EFFORT_SEARCH_OPTIONS_HISTORY_");
+ public static List<WorkEffortSearchOptions> getSearchOptionsHistoryList(HttpSession session) {
+ List<WorkEffortSearchOptions> optionsHistoryList = UtilGenerics.checkList(session.getAttribute("_WORK_EFFORT_SEARCH_OPTIONS_HISTORY_"));
if (optionsHistoryList == null) {
- optionsHistoryList = new LinkedList();
+ optionsHistoryList = FastList.newInstance();
session.setAttribute("_WORK_EFFORT_SEARCH_OPTIONS_HISTORY_", optionsHistoryList);
}
return optionsHistoryList;
}
- public static List searchGetConstraintStrings(boolean detailed, HttpSession session, GenericDelegator delegator) {
+ public static List<String> searchGetConstraintStrings(boolean detailed, HttpSession session, GenericDelegator delegator) {
Locale locale = UtilHttp.getLocale(session);
WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(session);
return workEffortSearchOptions.searchGetConstraintStrings(detailed, delegator, locale);
@@ -312,13 +312,13 @@
WorkEffortSearchOptions workEffortSearchOptions = WorkEffortSearchSession.getWorkEffortSearchOptions(session);
// if the options have changed since the last search, add it to the beginning of the search options history
if (workEffortSearchOptions.changed) {
- List optionsHistoryList = WorkEffortSearchSession.getSearchOptionsHistoryList(session);
+ List<WorkEffortSearchOptions> optionsHistoryList = WorkEffortSearchSession.getSearchOptionsHistoryList(session);
optionsHistoryList.add(0, new WorkEffortSearchOptions(workEffortSearchOptions));
workEffortSearchOptions.changed = false;
}
}
public static void searchRemoveConstraint(int index, HttpSession session) {
- List workEffortSearchConstraintList = WorkEffortSearchOptions.getConstraintList(session);
+ List<WorkEffortSearchConstraint> workEffortSearchConstraintList = WorkEffortSearchOptions.getConstraintList(session);
if (workEffortSearchConstraintList == null) {
return;
} else if (index >= workEffortSearchConstraintList.size()) {