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

📄 contentworker.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * $Id: ContentWorker.java 5462 2005-08-05 18:35:48Z jonesde $ * *  Copyright (c) 2001-2005 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.content.content;import java.io.IOException;import java.io.StringReader;import java.io.StringWriter;import java.io.Writer;import java.sql.Timestamp;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Locale;import java.util.Map;import java.util.Set;import javax.xml.parsers.ParserConfigurationException;import org.ofbiz.base.util.BshUtil;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.GeneralException;import org.ofbiz.base.util.StringUtil;import org.ofbiz.base.util.UtilDateTime;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.base.util.string.FlexibleStringExpander;import org.ofbiz.content.ContentManagementWorker;import org.ofbiz.content.data.DataResourceWorker;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericPK;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.condition.EntityConditionList;import org.ofbiz.entity.condition.EntityExpr;import org.ofbiz.entity.condition.EntityOperator;import org.ofbiz.entity.util.EntityUtil;import org.ofbiz.minilang.MiniLangException;import org.ofbiz.minilang.SimpleMapProcessor;import org.ofbiz.service.GenericServiceException;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.service.ServiceUtil;import org.xml.sax.InputSource;import org.xml.sax.SAXException;import bsh.EvalError;import freemarker.ext.dom.NodeModel;//import com.clarkware.profiler.Profiler;/** * ContentWorker Class *  * @author <a href="mailto:byersa@automationgroups.com">Al Byers</a> * @version $Rev: 5462 $ * @since 2.2 *  *   */public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface {    public static final String module = ContentWorker.class.getName();    public ContentWorker() { }        public GenericValue getCurrentContentExt(GenericDelegator delegator, List trail, GenericValue userLogin, Map ctx, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GeneralException {        return getCurrentContent(delegator, trail, userLogin, ctx, nullThruDatesOnly, contentAssocPredicateId);    }    public Map renderSubContentAsTextExt(GenericDelegator delegator, String contentId, Writer out, String mapKey, String subContentId, GenericValue subContentDataResourceView,             Map templateContext, Locale locale, String mimeTypeId, GenericValue userLogin, Timestamp fromDate) throws GeneralException, IOException {        return renderSubContentAsText(delegator, contentId, out, mapKey, subContentId, subContentDataResourceView,                 templateContext, locale, mimeTypeId, userLogin, fromDate);    }    public String renderSubContentAsTextCacheExt(GenericDelegator delegator, String contentId,  String mapKey, GenericValue subContentDataResourceView,             Map templateRoot, Locale locale, String mimeTypeId, GenericValue userLogin, Timestamp fromDate) throws GeneralException, IOException {        return renderSubContentAsTextCache(delegator, contentId, mapKey, subContentDataResourceView,                 templateRoot, locale, mimeTypeId, userLogin, fromDate);    }    public Map renderSubContentAsTextCacheExt(GenericDelegator delegator, String contentId, Writer out, String mapKey,  GenericValue subContentDataResourceView,             Map templateRoot, Locale locale, String mimeTypeId, GenericValue userLogin, Timestamp fromDate) throws GeneralException, IOException {        return renderSubContentAsTextCache(delegator, contentId, out, mapKey, subContentDataResourceView,                 templateRoot, locale, mimeTypeId, userLogin, fromDate);    }    public Map renderSubContentAsTextCacheExt(GenericDelegator delegator, String contentId, Writer out, String mapKey,  GenericValue subContentDataResourceView,             Map templateRoot, Locale locale, String mimeTypeId, GenericValue userLogin, Timestamp fromDate, Boolean nullThruDatesOnly) throws GeneralException, IOException {        return renderSubContentAsTextCache(delegator, contentId, out, mapKey, subContentDataResourceView,                 templateRoot, locale, mimeTypeId, userLogin, fromDate, nullThruDatesOnly);    }    public Map renderContentAsTextExt(GenericDelegator delegator, String contentId, Writer out, Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException {        return renderContentAsText(delegator, contentId, out, templateContext, view, locale, mimeTypeId);    }    public String renderContentAsTextCacheExt(GenericDelegator delegator, String contentId,  Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException {        return renderContentAsTextCache(delegator, contentId,  templateContext, view, locale, mimeTypeId);    }    public Map renderContentAsTextCacheExt(GenericDelegator delegator, String contentId, Writer out, Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException {        return renderContentAsTextCache(delegator, contentId, out, templateContext, view, locale, mimeTypeId);    }    public String getMimeTypeIdExt(GenericDelegator delegator, GenericValue view, Map ctx) {        return getMimeTypeId(delegator, view, ctx);    }    public GenericValue getWebSitePublishPointExt(GenericDelegator delegator, String contentId, boolean ignoreCache) throws GenericEntityException {        return ContentManagementWorker.getWebSitePublishPoint(delegator, contentId, ignoreCache);    }        public static GenericValue findAlternateLocaleContent(GenericDelegator delegator, GenericValue view, Locale locale) {        GenericValue contentAssocDataResourceViewFrom = view;        if (locale == null) {            return contentAssocDataResourceViewFrom;        }                String localeStr = locale.toString();        boolean isTwoLetterLocale = localeStr.length() == 2;        List alternateViews = null;        try {            alternateViews = view.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"));        } catch (GenericEntityException e) {            Debug.logError(e, "Error finding alternate locale content: " + e.toString(), module);            return contentAssocDataResourceViewFrom;        }                alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true);        Iterator alternateViewIter = alternateViews.iterator();        while (alternateViewIter.hasNext()) {            GenericValue thisView = (GenericValue) alternateViewIter.next();            String currentLocaleString = thisView.getString("localeString");            if (UtilValidate.isEmpty(currentLocaleString)) {                continue;            }                        int currentLocaleLength = currentLocaleString.length();                        // could be a 2 letter or 5 letter code            if (isTwoLetterLocale) {                if (currentLocaleLength == 2) {                    // if the currentLocaleString is only a two letter code and the current one is a two and it matches, we are done                    if (localeStr.equals(currentLocaleString)) {                        contentAssocDataResourceViewFrom = thisView;                        break;                    }                } else if (currentLocaleLength == 5) {                    // if the currentLocaleString is only a two letter code and the current one is a five, match up but keep going                    if (localeStr.equals(currentLocaleString.substring(0, 2))) {                        contentAssocDataResourceViewFrom = thisView;                    }                }            } else {                if (currentLocaleLength == 2) {                    // if the currentLocaleString is a five letter code and the current one is a two and it matches, keep going                    if (localeStr.substring(0, 2).equals(currentLocaleString)) {                        contentAssocDataResourceViewFrom = thisView;                    }                } else if (currentLocaleLength == 5) {                    // if the currentLocaleString is a five letter code and the current one is a five, if it matches we are done                    if (localeStr.equals(currentLocaleString)) {                        contentAssocDataResourceViewFrom = thisView;                        break;                    }                }            }        }                return contentAssocDataResourceViewFrom;    }    public static void traverse(GenericDelegator delegator, GenericValue content, Timestamp fromDate, Timestamp thruDate, Map whenMap, int depthIdx, Map masterNode, String contentAssocTypeId, List pickList, String direction) {                //String startContentAssocTypeId = null;        String contentTypeId = null;        String contentId = null;        try {            if (contentAssocTypeId == null) {                contentAssocTypeId = "";            }            contentId = (String) content.get("contentId");            contentTypeId = (String) content.get("contentTypeId");            List topicList = content.getRelatedByAnd("ToContentAssoc", UtilMisc.toMap("contentAssocTypeId", "TOPIC"));            List topics = new ArrayList();            for (int i = 0; i < topicList.size(); i++) {                GenericValue assoc = (GenericValue) topicList.get(i);                topics.add(assoc.get("contentId"));            }            List keywordList = content.getRelatedByAnd("ToContentAssoc", UtilMisc.toMap("contentAssocTypeId", "KEYWORD"));            List keywords = new ArrayList();            for (int i = 0; i < keywordList.size(); i++) {                GenericValue assoc = (GenericValue) keywordList.get(i);                keywords.add(assoc.get("contentId"));            }            List purposeValueList = content.getRelatedCache("ContentPurpose");            List purposes = new ArrayList();            for (int i = 0; i < purposeValueList.size(); i++) {                GenericValue purposeValue = (GenericValue) purposeValueList.get(i);                purposes.add(purposeValue.get("contentPurposeTypeId"));            }            List contentTypeAncestry = new ArrayList();            getContentTypeAncestry(delegator, contentTypeId, contentTypeAncestry);            Map context = new HashMap();            context.put("content", content);            context.put("contentAssocTypeId", contentAssocTypeId);            //context.put("related", related);            context.put("purposes", purposes);            context.put("topics", topics);            context.put("keywords", keywords);            context.put("typeAncestry", contentTypeAncestry);            boolean isPick = checkWhen(context, (String) whenMap.get("pickWhen"));            boolean isReturnBefore = checkReturnWhen(context, (String) whenMap.get("returnBeforePickWhen"));            Map thisNode = null;            if (isPick || !isReturnBefore) {                thisNode = new HashMap();                thisNode.put("contentId", contentId);                thisNode.put("contentTypeId", contentTypeId);                thisNode.put("contentAssocTypeId", contentAssocTypeId);                List kids = (List) masterNode.get("kids");                if (kids == null) {                    kids = new ArrayList();                    masterNode.put("kids", kids);                }                kids.add(thisNode);            }            if (isPick) {                pickList.add(content);                thisNode.put("value", content);            }            boolean isReturnAfter = checkReturnWhen(context, (String) whenMap.get("returnAfterPickWhen"));            if (!isReturnAfter) {                List relatedAssocs = getContentAssocsWithId(delegator, contentId, fromDate, thruDate, direction, new ArrayList());                Iterator it = relatedAssocs.iterator();                Map assocContext = new HashMap();                assocContext.put("related", relatedAssocs);                while (it.hasNext()) {

⌨️ 快捷键说明

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