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

📄 productsearch.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            Set fullKeywordSet = new TreeSet();            // 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();                boolean replaceEntered = KeywordSearch.expandKeywordForSearch(keyword, expandedSet, delegator);                fullKeywordSet.addAll(expandedSet);                if (!replaceEntered) {                    fullKeywordSet.add(keyword);                }            }            return fullKeywordSet;        }        public void addConstraint(ProductSearchContext productSearchContext) {            // just make the fixed keyword lists and put them in the context            if (isAnd) {                // when isAnd is true we need to make a list of keyword sets where each set corresponds to one                //incoming/entered keyword and contains all of the expanded keywords plus the entered keyword if none of                //the expanded keywords are flagged as replacements; now the tricky part: each set should be or'ed together,                //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 = KeywordSearch.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();                    boolean replaceEntered = KeywordSearch.expandKeywordForSearch(keyword, expandedSet, productSearchContext.getDelegator());                    if (!replaceEntered) {                        expandedSet.add(keyword);                    }                    Set fixedSet = KeywordSearch.fixKeywordsForSearch(expandedSet, anyPrefix, anySuffix, removeStems, isAnd);                    Set fixedKeywordSet = new HashSet();                    fixedKeywordSet.addAll(fixedSet);                    productSearchContext.keywordFixedOrSetAndList.add(fixedKeywordSet);                }            } else {                // when isAnd is false, just add all of the new entries to the big list                Set keywordFirstPass = makeFullKeywordSet(productSearchContext.getDelegator()); // includes keyword expansion, etc                Set keywordSet = KeywordSearch.fixKeywordsForSearch(keywordFirstPass, anyPrefix, anySuffix, removeStems, isAnd);                productSearchContext.orKeywordFixedSet.addAll(keywordSet);            }            // add in productSearchConstraint, don't worry about the productSearchResultId or constraintSeqId, those will be fill in later            Map 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");            valueMap.put("removeStems", this.removeStems ? "Y" : "N");            productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", valueMap));        }        /** pretty print for log messages and even UI stuff */        public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) {            return "Keyword(s): \"" + this.keywordsString + "\", where " + (isAnd ? "all words match" : "any word matches");        }        public boolean equals(Object obj) {            ProductSearchConstraint psc = (ProductSearchConstraint) obj;            if (psc instanceof KeywordConstraint) {                KeywordConstraint that = (KeywordConstraint) psc;                if (this.anyPrefix != that.anyPrefix) {                    return false;                }                if (this.anySuffix != that.anySuffix) {                    return false;                }                if (this.isAnd != that.isAnd) {                    return false;                }                if (this.removeStems != that.removeStems) {                    return false;                }                if (this.keywordsString == null) {                    if (that.keywordsString != null) {                        return false;                    }                } else {                    if (!this.keywordsString.equals(that.keywordsString)) {                        return false;                    }                }                return true;            } else {                return false;            }        }    }    public static class LastUpdatedRangeConstraint extends ProductSearchConstraint {        public static final String constraintName = "LastUpdatedRange";        protected Timestamp fromDate;        protected Timestamp thruDate;        public LastUpdatedRangeConstraint(Timestamp fromDate, Timestamp thruDate) {            this.fromDate = fromDate;            this.thruDate = thruDate;        }        public void addConstraint(ProductSearchContext productSearchContext) {            // TODO: implement LastUpdatedRangeConstraint makeEntityCondition        }        /** pretty print for log messages and even UI stuff */        public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) {            // TODO: implement the pretty print for log messages and even UI stuff            return null;        }        public boolean equals(Object obj) {            ProductSearchConstraint psc = (ProductSearchConstraint) obj;            if (psc instanceof LastUpdatedRangeConstraint) {                LastUpdatedRangeConstraint that = (LastUpdatedRangeConstraint) psc;                if (this.fromDate == null) {                    if (that.fromDate != null) {                        return false;                    }                } else {                    if (!this.fromDate.equals(that.fromDate)) {                        return false;                    }                }                if (this.thruDate == null) {                    if (that.thruDate != null) {                        return false;                    }                } else {                    if (!this.thruDate.equals(that.thruDate)) {                        return false;                    }                }                return true;            } else {                return false;            }        }    }    public static class ListPriceRangeConstraint extends ProductSearchConstraint {        public static final String constraintName = "ListPriceRange";        protected Double lowPrice;        protected Double highPrice;        public ListPriceRangeConstraint(Double lowPrice, Double highPrice) {            this.lowPrice = lowPrice;            this.highPrice = highPrice;        }        public void addConstraint(ProductSearchContext productSearchContext) {            // TODO: implement ListPriceRangeConstraint makeEntityCondition        }        /** pretty print for log messages and even UI stuff */        public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) {            // TODO: implement the pretty print for log messages and even UI stuff            return null;        }        public boolean equals(Object obj) {            ProductSearchConstraint psc = (ProductSearchConstraint) obj;            if (psc instanceof ListPriceRangeConstraint) {                ListPriceRangeConstraint that = (ListPriceRangeConstraint) psc;                if (this.lowPrice == null) {                    if (that.lowPrice != null) {                        return false;                    }                } else {                    if (!this.lowPrice.equals(that.lowPrice)) {                        return false;                    }                }                if (this.highPrice == null) {                    if (that.highPrice != null) {                        return false;                    }                } else {                    if (!this.highPrice.equals(that.highPrice)) {                        return false;                    }                }                return true;            } else {                return false;            }        }    }    public static class SupplierConstraint extends ProductSearchConstraint {        public static final String constraintName = "Supplier";        protected String supplierPartyId;        public SupplierConstraint(String supplierPartyId) {            this.supplierPartyId = supplierPartyId;        }        public void addConstraint(ProductSearchContext productSearchContext) {            // make index based values and increment            String entityAlias = "SP" + productSearchContext.index;            String prefix = "sp" + productSearchContext.index;            productSearchContext.index++;            productSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "SupplierProduct");            productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "SupplierPartyId", "partyId", null, null, null, null);            productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));            productSearchContext.entityConditionList.add(new EntityExpr(prefix + "SupplierPartyId", EntityOperator.EQUALS, supplierPartyId));            // add in productSearchConstraint, don't worry about the productSearchResultId or constraintSeqId, those will be fill in later            productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.supplierPartyId)));        }        public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) {            return "Supplier: " + PartyHelper.getPartyName(delegator, supplierPartyId, false);        }        public boolean equals(Object obj) {            ProductSearchConstraint psc = (ProductSearchConstraint) obj;            if (psc instanceof SupplierConstraint) {                SupplierConstraint that = (SupplierConstraint) psc;                if (this.supplierPartyId == null) {                    if (that.supplierPartyId != null) {                        return false;                    }                } else {                    if (!this.supplierPartyId.equals(that.supplierPartyId)) {                        return false;                    }                }                return true;            } else {                return false;            }        }    }    // ======================================================================    // Result Sort Classes    // ======================================================================    public static abstract class ResultSortOrder implements java.io.Serializable {        public ResultSortOrder() {        }        public abstract void setSortOrder(ProductSearchContext productSearchContext);        public abstract String getOrderName();        public abstract String prettyPrintSortOrder(boolean detailed);        public abstract boolean isAscending();    }    public static class SortKeywordRelevancy extends ResultSortOrder {        public SortKeywordRelevancy() {        }

⌨️ 快捷键说明

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