Author: jonesde
Date: Mon Jan 1 15:15:33 2007 New Revision: 491685 URL: http://svn.apache.org/viewvc?view=rev&rev=491685 Log: Applied patch with initial WorkEffort search UI and related events, etc; from Jira #OFBIZ-580; this is the WorkEffortAdvancedSearch.patch file there Added: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java (with props) ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java (with props) ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh (with props) ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh (with props) ofbiz/trunk/applications/workeffort/webapp/workeffort/find/ ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl (with props) ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl (with props) Modified: ofbiz/trunk/applications/workeffort/build.xml ofbiz/trunk/applications/workeffort/config/WorkEffortUiLabels.properties ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/controller.xml ofbiz/trunk/applications/workeffort/widget/WorkEffortScreens.xml Modified: ofbiz/trunk/applications/workeffort/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/build.xml?view=diff&rev=491685&r1=491684&r2=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/build.xml (original) +++ ofbiz/trunk/applications/workeffort/build.xml Mon Jan 1 15:15:33 2007 @@ -44,6 +44,8 @@ <fileset dir="../../framework/security/build/lib" includes="*.jar"/> <fileset dir="../../framework/service/lib" includes="*.jar"/> <fileset dir="../../framework/service/build/lib" includes="*.jar"/> + <fileset dir="../../framework/webapp/lib" includes="*.jar"/> + <fileset dir="../../framework/webapp/build/lib" includes="*.jar"/> <fileset dir="../../framework/common/build/lib" includes="*.jar"/> <fileset dir="../content/build/lib" includes="*.jar"/> <fileset dir="../party/build/lib" includes="*.jar"/> Modified: ofbiz/trunk/applications/workeffort/config/WorkEffortUiLabels.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/config/WorkEffortUiLabels.properties?view=diff&rev=491685&r1=491684&r2=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/config/WorkEffortUiLabels.properties (original) +++ ofbiz/trunk/applications/workeffort/config/WorkEffortUiLabels.properties Mon Jan 1 15:15:33 2007 @@ -220,7 +220,6 @@ WorkEffortKeywordAllWordsMatch=all words match WorkEffortKeywordAlreadyExist=WorkEffort - Keyword already exist WorkEffortKeywordAnyWordMatches=any word matches -WorkEffortKeywordRelevency=Keyword Relevency WorkEffortKeywords=Keywords WorkEffortKeywordWhere=where WorkEffortLastModified=Last Modified @@ -303,6 +302,7 @@ WorkEffortResultOfLookup=Result Of Lookup WorkEffortReviews=Reviews WorkEffortRevision=Revision +WorkEffortSearchWorkEfforts=Search WorkEfforts WorkEffortSelected=Selected WorkEffortSelectContactMechanism=Select an existing contact mechanism WorkEffortShopLists=Shopping Lists 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?view=diff&rev=491685&r1=491684&r2=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearch.java Mon Jan 1 15:15:33 2007 @@ -43,6 +43,8 @@ import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; +import org.ofbiz.entity.condition.EntityFieldValue; +import org.ofbiz.entity.condition.EntityFunction; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.DynamicViewEntity; import org.ofbiz.entity.model.ModelKeyMap; @@ -53,7 +55,7 @@ import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntityUtil; -import org.ofbiz.party.party.PartyHelper; + /** @@ -316,8 +318,7 @@ if (resultSortOrder != null) { resultSortOrder.setSortOrder(this); - } - + } dynamicViewEntity.addAlias("WEFF", "workEffortId", null, null, null, new Boolean(workEffortIdGroupBy), null); EntityCondition whereCondition = new EntityConditionList(entityConditionList, EntityOperator.AND); EntityFindOptions efo = new EntityFindOptions(); @@ -505,7 +506,7 @@ public abstract String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale); } - + public static class WorkEffortAssocConstraint extends WorkEffortSearchConstraint { public static final String constraintName = "WorkEffortAssoc"; protected String workEffortId; @@ -577,6 +578,7 @@ workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.workEffortId + "," + this.workEffortAssocTypeId, "includeSubWorkEfforts", this.includeSubWorkEfforts ? "Y" : "N"))); } + /** pretty print for log messages and even UI stuff */ public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { GenericValue workEffort = null; @@ -645,7 +647,56 @@ } } } + public static class WorkEffortReviewConstraint extends WorkEffortSearchConstraint { + public static final String constraintName = "WorkEffortReview"; + protected String reviewTextString; + + public WorkEffortReviewConstraint(String reviewTextString) { + this.reviewTextString = reviewTextString; + } + + public void addConstraint(WorkEffortSearchContext workEffortSearchContext) { + String entityAlias = "WFR" + workEffortSearchContext.index; + String prefix = "wfr" + workEffortSearchContext.index; + workEffortSearchContext.index++; + workEffortSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "WorkEffortReview"); + workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ReviewText", "reviewText", null, null, null, null); + workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId")); + workEffortSearchContext.entityConditionList.add( new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue(prefix + "ReviewText")), EntityOperator.LIKE ,new EntityFunction.UPPER(("%"+ reviewTextString) + "%"))); + Map 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(); + ppBuf.append(UtilProperties.getMessage(resource, "WorkEffortReviews", locale) + ": \""); + ppBuf.append(this.reviewTextString + "\", " + UtilProperties.getMessage(resource, "WorkEffortKeywordWhere", locale) + " "); + return ppBuf.toString(); + } + + public boolean equals(Object obj) { + WorkEffortSearchConstraint psc = (WorkEffortSearchConstraint) obj; + if (psc instanceof WorkEffortReviewConstraint) { + WorkEffortReviewConstraint that = (WorkEffortReviewConstraint) psc; + if (this.reviewTextString == null) { + if (that.reviewTextString != null) { + return false; + } + } else { + if (!this.reviewTextString.equals(that.reviewTextString)) { + return false; + } + } + return true; + } else { + return false; + } + } + } + public static class PartyAssignmentConstraint extends WorkEffortSearchConstraint { public static final String constraintName = "PartyAssignment"; protected String partyId; Added: 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?view=auto&rev=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java (added) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java Mon Jan 1 15:15:33 2007 @@ -0,0 +1,112 @@ +/* + * + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +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 org.ofbiz.entity.GenericDelegator; +import org.ofbiz.webapp.stats.VisitHandler; +import org.ofbiz.workeffort.workeffort.WorkEffortSearch.ResultSortOrder; +import org.ofbiz.workeffort.workeffort.WorkEffortSearch.WorkEffortSearchContext; +import org.ofbiz.workeffort.workeffort.WorkEffortSearchSession.WorkEffortSearchOptions; + + +public class WorkEffortSearchEvents { + + public static final String module = WorkEffortSearchEvents.class.getName(); + + public static Map getWorkEffortSearchResult(HttpServletRequest request, GenericDelegator delegator) { + + // ========== Create View Indexes + int viewIndex = 0; + int viewSize = 20; + int highIndex = 0; + int lowIndex = 0; + int listSize = 0; + + HttpSession session = request.getSession(); + WorkEffortSearchOptions workEffortSearchOptions = WorkEffortSearchSession.getWorkEffortSearchOptions(session); + + Integer viewIndexInteger = workEffortSearchOptions.getViewIndex(); + if (viewIndexInteger != null) viewIndex = viewIndexInteger.intValue(); + Integer viewSizeInteger = workEffortSearchOptions.getViewSize(); + if (viewSizeInteger != null) viewSize = viewSizeInteger.intValue(); + + lowIndex = viewIndex * viewSize; + 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); + + // ========== Do the actual search + ArrayList workEffortIds = null; + String visitId = VisitHandler.getVisitId(session); + List 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 + WorkEffortSearchSession.checkSaveSearchOptionsHistory(session); + + ResultSortOrder resultSortOrder = WorkEffortSearchOptions.getResultSortOrder(request); + + WorkEffortSearchContext workEffortSearchContext = new WorkEffortSearchContext(delegator, visitId); + workEffortSearchContext.addWorkEffortSearchConstraints(workEffortSearchConstraintList); + + workEffortSearchContext.setResultSortOrder(resultSortOrder); + workEffortSearchContext.setResultOffset(resultOffset); + workEffortSearchContext.setMaxResults(maxResults); + + workEffortIds = workEffortSearchContext.doSearch(); + + Integer totalResults = workEffortSearchContext.getTotalResults(); + if (totalResults != null) { + listSize = totalResults.intValue(); + } + } + + if (listSize < highIndex) { + highIndex = listSize; + } + + // ========== Setup other display info + List searchConstraintStrings = WorkEffortSearchSession.searchGetConstraintStrings(false, session, delegator); + String searchSortOrderString = WorkEffortSearchSession.searchGetSortOrderString(false, request); + + // ========== populate the result Map + Map result = new HashMap(); + + 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("searchConstraintStrings", searchConstraintStrings); + result.put("searchSortOrderString", searchSortOrderString); + + return result; + } + + +} Propchange: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: 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?view=auto&rev=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java (added) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java Mon Jan 1 15:15:33 2007 @@ -0,0 +1,288 @@ +/* + * + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.workeffort.workeffort; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilHttp; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.workeffort.workeffort.WorkEffortSearch.ResultSortOrder; +import org.ofbiz.workeffort.workeffort.WorkEffortSearch.WorkEffortSearchConstraint; +import org.ofbiz.workeffort.workeffort.WorkEffortSearch.SortKeywordRelevancy; + +public class WorkEffortSearchSession { + + public static final String module = WorkEffortSearchSession.class.getName(); + public static class WorkEffortSearchOptions implements java.io.Serializable { + protected List constraintList = null; + protected ResultSortOrder resultSortOrder = null; + protected Integer viewIndex = null; + protected Integer viewSize = null; + protected boolean changed = false; + public WorkEffortSearchOptions() { } + + /** Basic copy constructor */ + public WorkEffortSearchOptions(WorkEffortSearchOptions workEffortSearchOptions) { + this.constraintList = new LinkedList(workEffortSearchOptions.constraintList); + this.resultSortOrder = workEffortSearchOptions.resultSortOrder; + this.viewIndex = workEffortSearchOptions.viewIndex; + this.viewSize = workEffortSearchOptions.viewSize; + this.changed = workEffortSearchOptions.changed; + } + + public List getConstraintList() { + return this.constraintList; + } + public static List 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(); + } + if (!workEffortSearchOptions.constraintList.contains(workEffortSearchConstraint)) { + workEffortSearchOptions.constraintList.add(workEffortSearchConstraint); + workEffortSearchOptions.changed = true; + } + } + + public ResultSortOrder getResultSortOrder() { + if (this.resultSortOrder == null) { + this.resultSortOrder = new SortKeywordRelevancy(); + this.changed = true; + } + return this.resultSortOrder; + } + public static ResultSortOrder getResultSortOrder(HttpServletRequest request) { + WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(request.getSession()); + return workEffortSearchOptions.getResultSortOrder(); + } + public static void setResultSortOrder(ResultSortOrder resultSortOrder, HttpSession session) { + WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(session); + workEffortSearchOptions.resultSortOrder = resultSortOrder; + workEffortSearchOptions.changed = true; + } + + public static void clearSearchOptions(HttpSession session) { + WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(session); + workEffortSearchOptions.constraintList = null; + workEffortSearchOptions.resultSortOrder = null; + } + + public void clearViewInfo() { + this.viewIndex = null; + this.viewSize = null; + } + + /** + * @return Returns the viewIndex. + */ + public Integer getViewIndex() { + return viewIndex; + } + /** + * @param viewIndex The viewIndex to set. + */ + public void setViewIndex(Integer viewIndex) { + this.viewIndex = viewIndex; + } + /** + * @return Returns the viewSize. + */ + public Integer getViewSize() { + return viewSize; + } + /** + * @param viewSize The viewSize to set. + */ + public void setViewSize(Integer viewSize) { + this.viewSize = viewSize; + } + + public List searchGetConstraintStrings(boolean detailed, GenericDelegator delegator, Locale locale) { + List workEffortSearchConstraintList = this.getConstraintList(); + List constraintStrings = new ArrayList(); + if (workEffortSearchConstraintList == null) { + return constraintStrings; + } + Iterator workEffortSearchConstraintIter = workEffortSearchConstraintList.iterator(); + while (workEffortSearchConstraintIter.hasNext()) { + WorkEffortSearchConstraint workEffortSearchConstraint = (WorkEffortSearchConstraint) workEffortSearchConstraintIter.next(); + if (workEffortSearchConstraint == null) continue; + String constraintString = workEffortSearchConstraint.prettyPrintConstraint(delegator, detailed, locale); + if (UtilValidate.isNotEmpty(constraintString)) { + constraintStrings.add(constraintString); + } else { + constraintStrings.add("Description not available"); + } + } + return constraintStrings; + } + } + + public static WorkEffortSearchOptions getWorkEffortSearchOptions(HttpSession session) { + WorkEffortSearchOptions workEffortSearchOptions = (WorkEffortSearchOptions) session.getAttribute("_WORK_EFFORT_SEARCH_OPTIONS_CURRENT_"); + if (workEffortSearchOptions == null) { + workEffortSearchOptions = new WorkEffortSearchOptions(); + session.setAttribute("_WORK_EFFORT_SEARCH_OPTIONS_CURRENT_", workEffortSearchOptions); + } + return workEffortSearchOptions; + } + + public static void processSearchParameters(Map parameters, HttpServletRequest request) { + Boolean alreadyRun = (Boolean) request.getAttribute("processSearchParametersAlreadyRun"); + if (Boolean.TRUE.equals(alreadyRun)) { + return; + } else { + request.setAttribute("processSearchParametersAlreadyRun", Boolean.TRUE); + } + HttpSession session = request.getSession(); + boolean constraintsChanged = false; + + // clear search? by default yes, but if the clearSearch parameter is N then don't + String clearSearchString = (String) parameters.get("clearSearch"); + if (!"N".equals(clearSearchString)) { + searchClear(session); + constraintsChanged = true; + } else { + String removeConstraint = (String) parameters.get("removeConstraint"); + if (UtilValidate.isNotEmpty(removeConstraint)) { + try { + searchRemoveConstraint(Integer.parseInt(removeConstraint), session); + constraintsChanged = true; + } catch (Exception e) { + Debug.logError(e, "Error removing constraint [" + removeConstraint + "]", module); + } + } + } + +// add a Work Effort Review to the search + if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_STRING_REVIEW_TEXT"))) { + String reviewText = (String) parameters.get("SEARCH_STRING_REVIEW_TEXT"); + searchAddConstraint(new WorkEffortSearch.WorkEffortReviewConstraint(reviewText), session); + constraintsChanged = true; + } + // if keywords were specified, add a constraint for them + if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_STRING"))) { + String keywordString = (String) parameters.get("SEARCH_STRING"); + String searchOperator = (String) parameters.get("SEARCH_OPERATOR"); + // defaults to true/Y, ie anything but N is true/Y + boolean anyPrefixSuffix = !"N".equals((String) parameters.get("SEARCH_ANYPRESUF")); + searchAddConstraint(new WorkEffortSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session); + constraintsChanged = true; + } + // set the sort order + String sortOrder = (String) parameters.get("sortOrder"); + String sortAscending = (String) parameters.get("sortAscending"); + boolean ascending = !"N".equals(sortAscending); + if (sortOrder != null) { + if (sortOrder.equals("SortKeywordRelevancy")) { + searchSetSortOrder(new WorkEffortSearch.SortKeywordRelevancy(), session); + } else if (sortOrder.startsWith("SortWorkEffortField:")) { + String fieldName = sortOrder.substring("SortWorkEffortField:".length()); + searchSetSortOrder(new WorkEffortSearch.SortWorkEffortField(fieldName, ascending), session); + } + } + + WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(session); + if (constraintsChanged) { + // query changed, clear out the VIEW_INDEX & VIEW_SIZE + workEffortSearchOptions.clearViewInfo(); + } + + String viewIndexStr = (String) parameters.get("VIEW_INDEX"); + if (UtilValidate.isNotEmpty(viewIndexStr)) { + try { + workEffortSearchOptions.setViewIndex(Integer.valueOf(viewIndexStr)); + } 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)); + } + } + + String viewSizeStr = (String) parameters.get("VIEW_SIZE"); + if (UtilValidate.isNotEmpty(viewSizeStr)) { + try { + workEffortSearchOptions.setViewSize(Integer.valueOf(viewSizeStr)); + } catch (Exception e) { + Debug.logError(e, "Error formatting VIEW_SIZE, setting to 20", module); + workEffortSearchOptions.setViewSize(new Integer(20)); + } + } + } + + public static void searchAddConstraint(WorkEffortSearchConstraint workEffortSearchConstraint, HttpSession session) { + WorkEffortSearchOptions.addConstraint(workEffortSearchConstraint, session); + } + 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_"); + if (optionsHistoryList == null) { + optionsHistoryList = new LinkedList(); + session.setAttribute("_WORK_EFFORT_SEARCH_OPTIONS_HISTORY_", optionsHistoryList); + } + return optionsHistoryList; + } + + public static List searchGetConstraintStrings(boolean detailed, HttpSession session, GenericDelegator delegator) { + Locale locale = UtilHttp.getLocale(session); + WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(session); + return workEffortSearchOptions.searchGetConstraintStrings(detailed, delegator, locale); + } + public static String searchGetSortOrderString(boolean detailed, HttpServletRequest request) { + Locale locale = UtilHttp.getLocale(request); + ResultSortOrder resultSortOrder = WorkEffortSearchOptions.getResultSortOrder(request); + if (resultSortOrder == null) return ""; + return resultSortOrder.prettyPrintSortOrder(detailed, locale); + } + public static void checkSaveSearchOptionsHistory(HttpSession session) { + 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); + optionsHistoryList.add(0, new WorkEffortSearchOptions(workEffortSearchOptions)); + workEffortSearchOptions.changed = false; + } + } + public static void searchRemoveConstraint(int index, HttpSession session) { + List workEffortSearchConstraintList = WorkEffortSearchOptions.getConstraintList(session); + if (workEffortSearchConstraintList == null) { + return; + } else if (index >= workEffortSearchConstraintList.size()) { + return; + } else { + workEffortSearchConstraintList.remove(index); + } + } + public static void searchClear(HttpSession session) { + WorkEffortSearchOptions.clearSearchOptions(session); + } +} Propchange: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh?view=auto&rev=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh (added) +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh Mon Jan 1 15:15:33 2007 @@ -0,0 +1,31 @@ +/* + * + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.base.util.*; +import org.ofbiz.workeffort.workeffort.*; + +searchOperator = parameters.get("SEARCH_OPERATOR"); +if (!"AND".equals(searchOperator) && !"OR".equals(searchOperator)) { + searchOperator = "OR"; +} + +searchConstraintStrings = WorkEffortSearchSession.searchGetConstraintStrings(false, session, delegator); +searchSortOrderString = WorkEffortSearchSession.searchGetSortOrderString(false, request); + +context.put("searchOperator", searchOperator); +context.put("searchConstraintStrings", searchConstraintStrings); +context.put("searchSortOrderString", searchSortOrderString); Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh?view=auto&rev=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh (added) +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh Mon Jan 1 15:15:33 2007 @@ -0,0 +1,32 @@ +/* + * + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.base.util.*; +import org.ofbiz.workeffort.workeffort.*; + +// note: this can be run multiple times in the same request without causing problems, will check to see on its own if it has run again +WorkEffortSearchSession.processSearchParameters(parameters, request); +Map result = WorkEffortSearchEvents.getWorkEffortSearchResult(request, delegator); + +context.put("workEffortIds", result.get("workEffortIds")); +context.put("viewIndex", result.get("viewIndex")); +context.put("viewSize", result.get("viewSize")); +context.put("listSize", result.get("listSize")); +context.put("lowIndex", result.get("lowIndex")); +context.put("highIndex", result.get("highIndex")); +context.put("searchConstraintStrings", result.get("searchConstraintStrings")); +context.put("searchSortOrderString", result.get("searchSortOrderString")); Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/controller.xml?view=diff&rev=491685&r1=491684&r2=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/controller.xml Mon Jan 1 15:15:33 2007 @@ -552,7 +552,17 @@ <response name="success" type="view" value="EditWorkEffortKeywords"/> <response name="error" type="view" value="EditWorkEffortKeywords"/> </request-map> - + + <!-- Work Efort Advanced Search --> + <request-map uri="WorkEffortSearchOptions"> + <security https="true" auth="true"/> + <response name="success" type="view" value="WorkEffortSearchOptions"/> + </request-map> + <request-map uri="WorkEffortSearchResults"> + <security https="true" auth="true"/> + <response name="success" type="view" value="WorkEffortSearchResults"/> + </request-map> + <!-- Lookup request mappings --> <request-map uri="LookupWorkEffort"><security https="true" auth="true"/><response name="success" type="view" value="LookupWorkEffort"/></request-map> @@ -633,7 +643,10 @@ <view-map name="EditWorkEffortReviews" type="screen" page="component://workeffort/widget/WorkEffortScreens.xml#EditWorkEffortReviews"/> <view-map name="EditWorkEffortKeywords" type="screen" page="component://workeffort/widget/WorkEffortScreens.xml#EditWorkEffortKeywords"/> - + <view-map name="WorkEffortSearchOptions" type="screen" page="component://workeffort/widget/WorkEffortScreens.xml#WorkEffortSearchOptions"/> + <view-map name="WorkEffortSearchResults" type="screen" page="component://workeffort/widget/WorkEffortScreens.xml#WorkEffortSearchResults"/> + + <view-map name="LookupWorkEffort" type="screen" page="component://workeffort/widget/LookupScreens.xml#LookupWorkEffort"/> <view-map name="LookupTimesheet" type="screen" page="component://workeffort/widget/LookupScreens.xml#LookupTimesheet"/> Added: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl?view=auto&rev=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl (added) +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl Mon Jan 1 15:15:33 2007 @@ -0,0 +1,87 @@ +<#-- + +Copyright 2001-2006 The Apache Software Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +--> +<div class="head1">${uiLabelMap.ProductAdvancedSearch}</div> +<br/> +<form name="advToKeyWordSearchForm" method="post" action="<@ofbizUrl>WorkEffortSearchResults</@ofbizUrl>" style="margin: 0;"> + <input type="hidden" name="VIEW_SIZE" value="25"/> + <table border="0" wdith="100%"> + <tr> + <td align="right" valign="middle"> + <div class="tabletext">${uiLabelMap.WorkEffortKeywords}:</div> + </td> + <td valign="middle"> + <div class="tabletext"> + <input type="text" class="inputBox" name="SEARCH_STRING" size="40" value="${requestParameters.SEARCH_STRING?if_exists}"/> + ${uiLabelMap.CommonAny}<input type="radio" name="SEARCH_OPERATOR" value="OR" <#if searchOperator == "OR">checked</#if>/> + ${uiLabelMap.CommonAll}<input type="radio" name="SEARCH_OPERATOR" value="AND" <#if searchOperator == "AND">checked</#if>/> + </div> + </td> + </tr> + + <tr> + <td align="right" valign="middle"> + <div class="tabletext">${uiLabelMap.WorkEffortReviews}:</div> + </td> + <td valign="middle"> + <div class="tabletext"> + <input type="text" class="inputBox" name="SEARCH_STRING_REVIEW_TEXT" size="40" value="${requestParameters.SEARCH_STRING_REVIEW_TEXT?if_exists}"/> + </div> + </td> + </tr> + + <tr> + <td align="right" valign="middle"> + <div class="tabletext">${uiLabelMap.CommonSortedBy}:</div> + </td> + <td valign="middle"> + <div class="tabletext"> + <select name="sortOrder" class="selectBox"> + <option value="SortKeywordRelevancy">${uiLabelMap.ProductKeywordRelevency}</option> + <option value="SortWorkEffortField:workEffortName">${uiLabelMap.WorkEffortName}</option> + </select> + ${uiLabelMap.ProductLowToHigh}<input type="radio" name="sortAscending" value="Y" checked/> + ${uiLabelMap.ProductHighToLow}<input type="radio" name="sortAscending" value="N"/> + </div> + </td> + </tr> + <#if searchConstraintStrings?has_content> + <tr> + <td align="right" valign="top"> + <div class="tabletext">${uiLabelMap.ProductLastSearch}</div> + </td> + <td valign="top"> + <#list searchConstraintStrings as searchConstraintString> + <div class="tabletext"> - ${searchConstraintString}</div> + </#list> + <div class="tabletext">${uiLabelMap.CommonSortedBy}: ${searchSortOrderString}</div> + <div class="tabletext"> + ${uiLabelMap.ProductNewSearch}<input type="radio" name="clearSearch" value="Y" checked/> + ${uiLabelMap.ProductRefineSearch}<input type="radio" name="clearSearch" value="N"/> + </div> + </td> + </tr> + </#if> + <tr> + <td> + <div class="tabletext"> + <a href="javascript:document.advToKeyWordSearchForm.submit()" class="buttontext">${uiLabelMap.CommonFind}</a> + </div> + </td> + </tr> + <input type="image" src="<@ofbizContentUrl>/images/spacer.gif</@ofbizContentUrl>" onClick="javascript:document.advToKeyWordSearchForm.submit();"/> + </table> +</form> Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl?view=auto&rev=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl (added) +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl Mon Jan 1 15:15:33 2007 @@ -0,0 +1,86 @@ +<#-- + +Copyright 2001-2006 The Apache Software Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +--> + +<div class="head1">${uiLabelMap.WorkEffortSearchWorkEfforts}, <span class="head2">${uiLabelMap.ProductSearchFor}:</span></div> +<#list searchConstraintStrings as searchConstraintString> + <div class="tabletext"> <a href="<@ofbizUrl>WorkEffortSearchResults?removeConstraint=${searchConstraintString_index}&clearSearch=N</@ofbizUrl>" class="buttontext">[X]</a> ${searchConstraintString}</div> +</#list> +<div class="tabletext">${uiLabelMap.CommonSortedBy}: ${searchSortOrderString}</div> +<div class="tabletext"><a href="<@ofbizUrl>WorkEffortSearchOptions</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonRefine} ${uiLabelMap.CommonSearch}]</a></div> + +<#if !workEffortIds?has_content> + <br/><div class="head2"> ${uiLabelMap.ProductNoResultsFound}.</div> +</#if> + +<#if workEffortIds?has_content> +<table border="0" width="100%" cellpadding="2"> + <tr> + <td align="right"> + <b> + <#if 0 < viewIndex?int> + <a href="<@ofbizUrl>WorkEffortSearchResults/~VIEW_INDEX=${viewIndex-1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonPrevious}]</a> | + </#if> + <#if 0 < listSize?int> + <span class="tabletext">${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} ${listSize}</span> + </#if> + <#if highIndex?int < listSize?int> + | <a href="<@ofbizUrl>WorkEffortSearchResults/~VIEW_INDEX=${viewIndex+1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonNext}]</a> + </#if> + </b> + </td> + </tr> +</table> +</#if> + +<#if workEffortIds?has_content> + +<center> + <table width="100%" cellpadding="0" cellspacing="0"> + <#assign listIndex = lowIndex> + <#list workEffortIds as workEffortId><#-- note that there is no boundary range because that is being done before the list is put in the content --> + <#assign workEffort = delegator.findByPrimaryKey("WorkEffort", Static["org.ofbiz.base.util.UtilMisc"].toMap("workEffortId", workEffortId))> + <tr> + <td> + <a href="<@ofbizUrl>EditWorkEffort?workEffortId=${workEffortId}</@ofbizUrl>" class="buttontext">[${workEffortId}] ${(workEffort.workEffortName)?if_exists}</a> + </td> + </tr> + </#list> + </table> +</center> +</#if> + +<#if workEffortIds?has_content> +<table border="0" width="100%" cellpadding="2"> + <tr> + <td align="right"> + <b> + <#if 0 < viewIndex?int> + <a href="<@ofbizUrl>WorkEffortSearchResults/~VIEW_INDEX=${viewIndex-1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonPrevious}]</a> | + </#if> + <#if 0 < listSize?int> + <span class="tabletext">${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} ${listSize}</span> + </#if> + <#if highIndex?int < listSize?int> + | <a href="<@ofbizUrl>WorkEffortSearchResults/~VIEW_INDEX=${viewIndex+1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonNext}]</a> + </#if> + </b> + </td> + </tr> +</table> + +<hr class="sepbar"/> +</#if> Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/workeffort/widget/WorkEffortScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/widget/WorkEffortScreens.xml?view=diff&rev=491685&r1=491684&r2=491685 ============================================================================== --- ofbiz/trunk/applications/workeffort/widget/WorkEffortScreens.xml (original) +++ ofbiz/trunk/applications/workeffort/widget/WorkEffortScreens.xml Mon Jan 1 15:15:33 2007 @@ -97,6 +97,7 @@ <decorator-section name="body"> <container><label style="head1">${uiLabelMap.PageTitleFindWorkEffort}</label></container> <container><link text="${uiLabelMap.WorkEffortCreate}" target="EditWorkEffort?DONE_PAGE=${donePage}" style="linktext"/></container> + <container><link text="${uiLabelMap.ProductAdvancedSearch}" target="WorkEffortSearchOptions" style="linktext"/></container> <include-form name="FindWorkEffort" location="component://workeffort/widget/WorkEffortForms.xml"/> </decorator-section> </decorator-screen> @@ -580,6 +581,42 @@ <include-form name="AddWorkEffortKeyword" location="component://workeffort/widget/WorkEffortForms.xml"/> <container><label style="head1">${uiLabelMap.WorkEffortKeywords}</label></container> <include-form name="ListWorkEffortKeywords" location="component://workeffort/widget/WorkEffortForms.xml"/> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> + + <screen name="WorkEffortSearchResults"> + <section> + <actions> + <set field="titleProperty" value="PageTitleSearchResults"/> + <script location="component://workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchResults.bsh"/> + </actions> + <widgets> + <decorator-screen name="CommonWorkEffortDecorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <platform-specific> + <html><html-template location="component://workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl"/></html> + </platform-specific> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> + + <screen name="WorkEffortSearchOptions"> + <section> + <actions> + <set field="titleProperty" value="PageTitleSearchResults"/> + <script location="component://workeffort/webapp/workeffort/WEB-INF/actions/find/WorkEffortSearchOptions.bsh"/> + </actions> + <widgets> + <decorator-screen name="CommonWorkEffortDecorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <platform-specific> + <html><html-template location="component://workeffort/webapp/workeffort/find/WorkEffortSearchOptions.ftl"/></html> + </platform-specific> </decorator-section> </decorator-screen> </widgets> |
Free forum by Nabble | Edit this page |