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

📄 traversesubcontenttransform.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    try {                        content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId));                    } catch(GenericEntityException e){                        // TODO: Not sure what to put here.                        throw new RuntimeException(e.getMessage());                    }                }*/                Map rootNode = ContentWorker.makeNode(subContentDataResourceView);                ContentWorker.traceNodeTrail("1",nodeTrail);                ContentWorker.selectKids(rootNode, traverseContext);                ContentWorker.traceNodeTrail("2",nodeTrail);                nodeTrail.add(rootNode);                boolean isPick = checkWhen(subContentDataResourceView, (String)traverseContext.get("contentAssocTypeId"));                rootNode.put("isPick", new Boolean(isPick));                if (!isPick) {                    ContentWorker.traceNodeTrail("3",nodeTrail);                    isPick = ContentWorker.traverseSubContent(traverseContext);                    ContentWorker.traceNodeTrail("4",nodeTrail);                }                if (isPick) {                    populateContext(traverseContext, templateCtx);                    ContentWorker.traceNodeTrail("5",nodeTrail);                    return TransformControl.EVALUATE_BODY;                } else {                    return TransformControl.SKIP_BODY;                }            }            public int afterBody() throws TemplateModelException, IOException {                //out.write(buf.toString());                //buf.setLength(0);                //templateContext.put("buf", new StringBuffer());                List nodeTrail = (List)traverseContext.get("nodeTrail");                ContentWorker.traceNodeTrail("6",nodeTrail);                boolean inProgress = ContentWorker.traverseSubContent(traverseContext);                ContentWorker.traceNodeTrail("7",nodeTrail);                if (inProgress) {                    populateContext(traverseContext, templateCtx);                    ContentWorker.traceNodeTrail("8",nodeTrail);                    return TransformControl.REPEAT_EVALUATION;                } else                    return TransformControl.END_EVALUATION;            }            public void close() throws IOException {                String wrappedFTL = buf.toString();                String encloseWrappedText = (String)templateCtx.get("encloseWrappedText");                if (UtilValidate.isEmpty(encloseWrappedText) || encloseWrappedText.equalsIgnoreCase("false")) {                    out.write(wrappedFTL);                    wrappedFTL = null; // So it won't get written again below.                }                String wrapTemplateId = (String)templateCtx.get("wrapTemplateId");                if (UtilValidate.isNotEmpty(wrapTemplateId)) {                    templateCtx.put("wrappedFTL", wrappedFTL);                                        Map templateRoot = FreeMarkerWorker.createEnvironmentMap(env);                    /*                    templateRoot.put("viewSize", viewSize);                    templateRoot.put("viewIndex", viewIndex);                    templateRoot.put("listSize", listSize);                    templateRoot.put("highIndex", highIndex);                    templateRoot.put("lowIndex", lowIndex);                    templateRoot.put("queryString", queryString);                    templateRoot.put("wrapDataResourceTypeId", subDataResourceTypeId);                    templateRoot.put("wrapContentIdTo", contentId);                    templateRoot.put("wrapMimeTypeId", mimeTypeId);                    //templateRoot.put("wrapMapKey", mapKey);                    */                    templateRoot.put("context", templateCtx);                    String mimeTypeId = (String) templateCtx.get("mimeTypeId");                    Locale locale = (Locale) templateCtx.get("locale");                    if (locale == null)                        locale = Locale.getDefault();                    try {                        ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, null, locale, mimeTypeId);                    } catch (GeneralException e) {                        Debug.logError(e, "Error rendering content", module);                        throw new IOException("Error rendering content" + e.toString());                    }/*                    Map resultsCtx = (Map) FreeMarkerWorker.getWrappedObject("context", env);                    templateContext.put("contentId", contentId);                    templateContext.put("locale", locale);                    templateContext.put("mapKey", null);                    templateContext.put("subContentId", null);                    templateContext.put("templateContentId", null);                    templateContext.put("subDataResourceTypeId", null);                    templateContext.put("mimeTypeId", null);*/                } else {                    if (UtilValidate.isNotEmpty(wrappedFTL))                        out.write(wrappedFTL);                }                    FreeMarkerWorker.removeValues(templateCtx, removeKeyNames);                    FreeMarkerWorker.reloadValues(templateCtx, savedValues, env);            }            private boolean checkWhen (GenericValue thisContent, String contentAssocTypeId) {                        boolean isPick = false;                Map assocContext = new HashMap();                if (UtilValidate.isEmpty(contentAssocTypeId))                    contentAssocTypeId = "";                assocContext.put("contentAssocTypeId", contentAssocTypeId);                //assocContext.put("contentTypeId", assocValue.get("contentTypeId") );                String assocRelation = null;                String thisDirection = (String)templateCtx.get("direction");                String thisContentId = (String)templateCtx.get("thisContentId");                String relatedDirection = null;                if (thisDirection != null && thisDirection.equalsIgnoreCase("From")) {                    assocContext.put("contentIdFrom", thisContentId);                    assocRelation = "FromContent";                    relatedDirection = "From";                } else {                    assocContext.put("contentIdTo", thisContentId);                    assocRelation = "ToContent";                    relatedDirection = "To";                }                assocContext.put("content", thisContent);                List purposes = ContentWorker.getPurposes(thisContent);                assocContext.put("purposes", purposes);                List contentTypeAncestry = new ArrayList();                String contentTypeId = (String)thisContent.get("contentTypeId");                try {                    ContentWorker.getContentTypeAncestry(delegator, contentTypeId, contentTypeAncestry);                } catch(GenericEntityException e) {                    return false;                }                assocContext.put("typeAncestry", contentTypeAncestry);                Map whenMap = (Map)traverseContext.get("whenMap");                String pickWhen = (String)whenMap.get("pickWhen");                List nodeTrail = (List)traverseContext.get("nodeTrail");                int indentSz = indent.intValue() + nodeTrail.size();                assocContext.put("indentObj", new Integer(indentSz));                isPick = ContentWorker.checkWhen(assocContext, (String)whenMap.get("pickWhen"));                return isPick;           }            public void populateContext(Map traverseContext, Map templateContext) {                List nodeTrail = (List)traverseContext.get("nodeTrail");                int sz = nodeTrail.size();                Map node = (Map)nodeTrail.get(sz - 1);                GenericValue content = (GenericValue)node.get("value");                String contentId = (String)node.get("contentId");                String subContentId = (String)node.get("subContentId");                templateContext.put("subContentId", contentId);                templateContext.put("subContentDataResourceView", null);                int indentSz = indent.intValue() + nodeTrail.size();                templateContext.put("indent", new Integer(indentSz));                if (sz >= 2) {                    Map parentNode = (Map)nodeTrail.get(sz - 2);                    GenericValue parentContent = (GenericValue)parentNode.get("value");                    String parentContentId = (String)parentNode.get("contentId");                    templateContext.put("parentContentId", parentContentId);                    templateContext.put("parentContent", parentContent);                    templateContext.put("nodeTrail", nodeTrail);                }                return;            }        };    }}

⌨️ 快捷键说明

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