⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productsearchsession.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * $Id: ProductSearchSession.java 5462 2005-08-05 18:35:48Z jonesde $ * *  Copyright (c) 2002-2004 The Open For Business Project (www.ofbiz.org) *  *  Permission is hereby granted, free of charge, to any person obtaining a *  copy of this software and associated documentation files (the "Software"), *  to deal in the Software without restriction, including without limitation *  the rights to use, copy, modify, merge, publish, distribute, sublicense, *  and/or sell copies of the Software, and to permit persons to whom the *  Software is furnished to do so, subject to the following conditions: * *  The above copyright notice and this permission notice shall be included *  in all copies or substantial portions of the Software. * *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *  THE USE OR OTHER DEALINGS IN THE SOFTWARE. */package org.ofbiz.product.product;import java.io.IOException;import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Map;import java.util.Set;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilHttp;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.webapp.stats.VisitHandler;import org.ofbiz.webapp.control.RequestHandler;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.util.EntityUtil;import org.ofbiz.product.catalog.CatalogWorker;import org.ofbiz.product.feature.ParametricSearch;import org.ofbiz.product.product.ProductSearch.CategoryConstraint;import org.ofbiz.product.product.ProductSearch.FeatureConstraint;import org.ofbiz.product.product.ProductSearch.KeywordConstraint;import org.ofbiz.product.product.ProductSearch.ProductSearchConstraint;import org.ofbiz.product.product.ProductSearch.ProductSearchContext;import org.ofbiz.product.product.ProductSearch.ResultSortOrder;import org.ofbiz.product.product.ProductSearch.SortKeywordRelevancy;import org.ofbiz.product.store.ProductStoreWorker;/** *  Utility class with methods to prepare and perform ProductSearch operations in the content of an HttpSession * * @author <a href="mailto:jonesde@ofbiz.org">David E. Jones</a> * @version    $Rev: 5462 $ * @since      3.0 */public class ProductSearchSession {    public static final String module = ProductSearchSession.class.getName();    public static class ProductSearchOptions 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 ProductSearchOptions() { }        /** Basic copy constructor */        public ProductSearchOptions(ProductSearchOptions productSearchOptions) {            this.constraintList = new LinkedList(productSearchOptions.constraintList);            this.resultSortOrder = productSearchOptions.resultSortOrder;            this.viewIndex = productSearchOptions.viewIndex;            this.viewSize = productSearchOptions.viewSize;            this.changed = productSearchOptions.changed;        }        public List getConstraintList() {            return this.constraintList;        }        public static List getConstraintList(HttpSession session) {            return getProductSearchOptions(session).constraintList;        }        public static void addConstraint(ProductSearchConstraint productSearchConstraint, HttpSession session) {            ProductSearchOptions productSearchOptions = getProductSearchOptions(session);            if (productSearchOptions.constraintList == null) {                productSearchOptions.constraintList = new LinkedList();            }            if (!productSearchOptions.constraintList.contains(productSearchConstraint)) {                productSearchOptions.constraintList.add(productSearchConstraint);                productSearchOptions.changed = true;            }        }        public ResultSortOrder getResultSortOrder() {            if (this.resultSortOrder == null) {                this.resultSortOrder = new SortKeywordRelevancy();                this.changed = true;            }            return this.resultSortOrder;        }        public static ResultSortOrder getResultSortOrder(HttpSession session) {            ProductSearchOptions productSearchOptions = getProductSearchOptions(session);            return productSearchOptions.getResultSortOrder();        }        public static void setResultSortOrder(ResultSortOrder resultSortOrder, HttpSession session) {            ProductSearchOptions productSearchOptions = getProductSearchOptions(session);             productSearchOptions.resultSortOrder = resultSortOrder;            productSearchOptions.changed = true;        }                public static void clearSearchOptions(HttpSession session) {            ProductSearchOptions productSearchOptions = getProductSearchOptions(session);             productSearchOptions.constraintList = null;            productSearchOptions.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) {            List productSearchConstraintList = this.getConstraintList();            List constraintStrings = new ArrayList();            if (productSearchConstraintList == null) {                return constraintStrings;            }            Iterator productSearchConstraintIter = productSearchConstraintList.iterator();            while (productSearchConstraintIter.hasNext()) {                ProductSearchConstraint productSearchConstraint = (ProductSearchConstraint) productSearchConstraintIter.next();                if (productSearchConstraint == null) continue;                String constraintString = productSearchConstraint.prettyPrintConstraint(delegator, detailed);                if (UtilValidate.isNotEmpty(constraintString)) {                    constraintStrings.add(constraintString);                } else {                    constraintStrings.add("Description not available");                }            }            return constraintStrings;        }    }    public static ProductSearchOptions getProductSearchOptions(HttpSession session) {        ProductSearchOptions productSearchOptions = (ProductSearchOptions) session.getAttribute("_PRODUCT_SEARCH_OPTIONS_CURRENT_");         if (productSearchOptions == null) {            productSearchOptions = new ProductSearchOptions();            session.setAttribute("_PRODUCT_SEARCH_OPTIONS_CURRENT_", productSearchOptions);        }        return productSearchOptions;    }    public static void checkSaveSearchOptionsHistory(HttpSession session) {        ProductSearchOptions productSearchOptions = getProductSearchOptions(session);         // if the options have changed since the last search, add it to the beginning of the search options history        if (productSearchOptions.changed) {            List optionsHistoryList = getSearchOptionsHistoryList(session);             optionsHistoryList.add(0, new ProductSearchOptions(productSearchOptions));            productSearchOptions.changed = false;        }    }    public static List getSearchOptionsHistoryList(HttpSession session) {        List optionsHistoryList = (List) session.getAttribute("_PRODUCT_SEARCH_OPTIONS_HISTORY_");         if (optionsHistoryList == null) {            optionsHistoryList = new LinkedList();            session.setAttribute("_PRODUCT_SEARCH_OPTIONS_HISTORY_", optionsHistoryList);        }        return optionsHistoryList;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -