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

📄 contentworker.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
         return nodeTrail;    }    public static String getContentAncestryNodeTrailCsv(GenericDelegator delegator, String contentId, String contentAssocTypeId, String direction) throws GenericEntityException {         List contentAncestorList = new ArrayList();         getContentAncestry(delegator, contentId, contentAssocTypeId, direction, contentAncestorList);         String csv = StringUtil.join(contentAncestorList, ",");         return csv;    }    public static void getContentAncestryValues(GenericDelegator delegator, String contentId, String contentAssocTypeId, String direction, List contentAncestorList) throws GenericEntityException {        String contentIdField = null;        String contentIdOtherField = null;        if (direction != null && direction.equalsIgnoreCase("to")) {            contentIdField = "contentId";            contentIdOtherField = "contentIdTo";        } else {            contentIdField = "contentIdTo";            contentIdOtherField = "contentId";        }                    //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentId:" + contentId, "");        try {            List lst = delegator.findByAndCache("ContentAssoc", UtilMisc.toMap(contentIdField, contentId, "contentAssocTypeId", contentAssocTypeId));            //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst:" + lst, "");            List lst2 = EntityUtil.filterByDate(lst);            //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst2:" + lst2, "");            if (lst2.size() > 0) {                GenericValue contentAssoc = (GenericValue)lst2.get(0);                getContentAncestryValues(delegator, contentAssoc.getString(contentIdOtherField), contentAssocTypeId, direction, contentAncestorList);                GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentAssoc.getString(contentIdOtherField)));                                contentAncestorList.add(content);            }        } catch(GenericEntityException e) {            Debug.logError(e,module);             return;        }        return;    }    public static Map pullEntityValues(GenericDelegator delegator, String entityName, Map context) {        GenericValue entOut = delegator.makeValue(entityName, null);        entOut.setPKFields(context);        entOut.setNonPKFields(context);        return (Map) entOut;    }    /**     * callContentPermissionCheck Formats data for a call to the checkContentPermission service.     */    public static String callContentPermissionCheck(GenericDelegator delegator, LocalDispatcher dispatcher, Map context) {        Map permResults = callContentPermissionCheckResult(delegator, dispatcher, context);        String permissionStatus = (String) permResults.get("permissionStatus");        return permissionStatus;    }    public static Map callContentPermissionCheckResult(GenericDelegator delegator, LocalDispatcher dispatcher, Map context) {                Map permResults = new HashMap();        String skipPermissionCheck = (String) context.get("skipPermissionCheck");        if (skipPermissionCheck == null            || skipPermissionCheck.length() == 0            || (!skipPermissionCheck.equalsIgnoreCase("true") && !skipPermissionCheck.equalsIgnoreCase("granted"))) {            GenericValue userLogin = (GenericValue) context.get("userLogin");            Map serviceInMap = new HashMap();            serviceInMap.put("userLogin", userLogin);            serviceInMap.put("targetOperationList", context.get("targetOperationList"));            serviceInMap.put("contentPurposeList", context.get("contentPurposeList"));            serviceInMap.put("targetOperationString", context.get("targetOperationString"));            serviceInMap.put("contentPurposeString", context.get("contentPurposeString"));            serviceInMap.put("entityOperation", context.get("entityOperation"));            serviceInMap.put("currentContent", context.get("currentContent"));            serviceInMap.put("displayFailCond", context.get("displayFailCond"));            try {                permResults = dispatcher.runSync("checkContentPermission", serviceInMap);            } catch (GenericServiceException e) {                Debug.logError(e, "Problem checking permissions", "ContentServices");            }        } else {            permResults.put("permissionStatus", "granted");           }        return permResults;    }    public static GenericValue getSubContent(GenericDelegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, List assocTypes, Timestamp fromDate) throws IOException {        //GenericValue content = null;        GenericValue view = null;        try {            if (subContentId == null) {                if (contentId == null) {                    throw new GenericEntityException("contentId and subContentId are null.");                }                Map results = null;                results = ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, "From", fromDate, null, null, null, assocTypes, null);                List entityList = (List) results.get("entityList");                if (entityList == null || entityList.size() == 0) {                    //throw new IOException("No subcontent found.");                } else {                    view = (GenericValue) entityList.get(0);                }            } else {                List lst = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", subContentId));                if (lst == null || lst.size() == 0) {                    throw new IOException("No subContent found for subContentId=." + subContentId);                }                view = (GenericValue) lst.get(0);            }        } catch (GenericEntityException e) {            throw new IOException(e.getMessage());        }        return view;    }    public static GenericValue getSubContentCache(GenericDelegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, List assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException {        //GenericValue content = null;        GenericValue view = null;        if (UtilValidate.isEmpty(subContentId)) {            view = getSubContentCache(delegator, contentId, mapKey, userLogin, assocTypes, fromDate, nullThruDatesOnly, contentAssocPredicateId);        } else {            view = getContentCache(delegator, subContentId);        }        return view;    }    public static GenericValue getSubContentCache(GenericDelegator delegator, String contentId, String mapKey,  GenericValue userLogin, List assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException {        //GenericValue content = null;        GenericValue view = null;        if (contentId == null) {            Debug.logError("ContentId is null", module);        	return view;        }        Map results = null;        List contentTypes = null;        try {            results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, "From", fromDate, null, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId);        } catch(MiniLangException e) {            throw new RuntimeException(e.getMessage());        }        List entityList = (List) results.get("entityList");        if (entityList == null || entityList.size() == 0) {            //throw new IOException("No subcontent found.");        } else {            view = (GenericValue) entityList.get(0);        }        return view;    }    public static GenericValue getContentCache(GenericDelegator delegator, String contentId) throws GenericEntityException {        GenericValue view = null;        List lst = delegator.findByAndCache("ContentDataResourceView", UtilMisc.toMap("contentId", contentId));            //if (Debug.infoOn()) Debug.logInfo("getContentCache, lst(2):" + lst, "");        if (lst != null && lst.size() > 0) {            view = (GenericValue) lst.get(0);        }        return view;    }    public static GenericValue getCurrentContent(GenericDelegator delegator, List trail, GenericValue userLogin, Map ctx, Boolean nullThruDatesOnly, String contentAssocPredicateId)  throws GeneralException {        String contentId = (String)ctx.get("contentId");        String subContentId = (String)ctx.get("subContentId");        String mapKey = (String)ctx.get("mapKey");        Timestamp fromDate = UtilDateTime.nowTimestamp();        List assocTypes = null;        List passedGlobalNodeTrail = null;        GenericValue currentContent = null;        String viewContentId = null;        if (trail != null && trail.size() > 0) {             passedGlobalNodeTrail = new ArrayList(trail);        } else {            passedGlobalNodeTrail = new ArrayList();        }        //if (Debug.infoOn()) Debug.logInfo("in getCurrentContent, passedGlobalNodeTrail(3):" + passedGlobalNodeTrail , module);        int sz = passedGlobalNodeTrail.size();        if (sz > 0) {            Map nd = (Map)passedGlobalNodeTrail.get(sz - 1);            if (nd != null)                currentContent = (GenericValue)nd.get("value");            if (currentContent != null)                 viewContentId = (String)currentContent.get("contentId");        }        //if (Debug.infoOn()) Debug.logInfo("in getCurrentContent, currentContent(3):" + currentContent , module);        //if (Debug.infoOn()) Debug.logInfo("getCurrentContent, contentId:" + contentId, "");        //if (Debug.infoOn()) Debug.logInfo("getCurrentContent, subContentId:" + subContentId, "");        //if (Debug.infoOn()) Debug.logInfo("getCurrentContent, viewContentId:" + viewContentId, "");        if (UtilValidate.isNotEmpty(subContentId)) {            ctx.put("subContentId", subContentId);            ctx.put("contentId", null);            if (viewContentId != null && viewContentId.equals(subContentId) ) {                return currentContent;            }        } else {            ctx.put("contentId", contentId);            ctx.put("subContentId", null);            if (viewContentId != null && viewContentId.equals(contentId) ) {                return currentContent;            }        }        //if (Debug.infoOn()) Debug.logInfo("getCurrentContent(2), contentId:" + contentId + " viewContentId:" + viewContentId + " subContentId:" + subContentId, "");        if (UtilValidate.isNotEmpty(contentId) || UtilValidate.isNotEmpty(subContentId)) {            try {                currentContent = ContentWorker.getSubContentCache(delegator, contentId, mapKey, subContentId, userLogin, assocTypes, fromDate, nullThruDatesOnly, contentAssocPredicateId);                Map node = ContentWorker.makeNode(currentContent);                passedGlobalNodeTrail.add(node);            } catch (GenericEntityException e) {                throw new GeneralException(e.getMessage());            }        }        ctx.put("globalNodeTrail", passedGlobalNodeTrail);        ctx.put("indent", new Integer(sz));        //if (Debug.infoOn()) Debug.logInfo("getCurrentContent, currentContent:" + currentContent, "");        return currentContent;    }    public static GenericValue getContentFromView(GenericValue view) {        GenericValue content = null;        if (view == null) {            return content;        }        GenericDelegator delegator = view.getDelegator();        content = delegator.makeValue("Content", null);        content.setPKFields(view);        content.setNonPKFields(view);        String dataResourceId = null;        try {            dataResourceId = (String) view.get("drDataResourceId");        } catch (Exception e) {            dataResourceId = (String) view.get("dataResourceId");        }        content.set("dataResourceId", dataResourceId);        return content;    }    public static Map renderSubContentAsText(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 {        Map results = new HashMap();        //GenericValue content = null;        if (subContentDataResourceView == null) {            subContentDataResourceView = getSubContentCache(delegator, contentId, mapKey, subContentId, userLogin, null, fromDate, new Boolean(false), null);        }        results.put("view", subContentDataResourceView);        if (subContentDataResourceView == null) {            //throw new IOException("SubContentDataResourceView is null.");            return results;        }        //String dataResourceId = (String) subContentDataResourceView.get("drDataResourceId");        contentId = (String) subContentDataResourceView.get("contentId");        //GenericValue dataResourceContentView = null;        if (templateContext == null) {            templateContext = new HashMap();        }

⌨️ 快捷键说明

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