📄 contentservicescomplex.java
字号:
if (assocTypes == null) { assocTypes = new ArrayList(); } assocTypes.addAll(lst); } List contentTypes = (List)context.get("contentTypes"); String contentTypesString = (String)context.get("contentTypesString"); if (UtilValidate.isNotEmpty(contentTypesString)) { List lst = StringUtil.split(contentTypesString, "|"); if (contentTypes == null) { contentTypes = new ArrayList(); } contentTypes.addAll(lst); } Timestamp fromDate = (Timestamp)context.get("fromDate"); String fromDateStr = (String)context.get("fromDateStr"); String contentId = (String)context.get("contentId"); String direction = (String)context.get("direction"); String mapKey = (String)context.get("mapKey"); String contentAssocPredicateId = (String)context.get("contentAssocPredicateId"); Boolean nullThruDatesOnly = (Boolean)context.get("nullThruDatesOnly"); Map results = null; try { results = getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId); } catch(GenericEntityException e) { return ServiceUtil.returnError(e.getMessage()); } catch(MiniLangException e2) { return ServiceUtil.returnError(e2.getMessage()); } return results; } public static Map getAssocAndContentAndDataResourceCacheMethod(GenericDelegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, String fromDateStr, List assocTypes, List contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException, MiniLangException { Map results = getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId, null); return results; } public static Map getAssocAndContentAndDataResourceCacheMethod(GenericDelegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, String fromDateStr, List assocTypes, List contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId, String orderBy) throws GenericEntityException, MiniLangException { List exprList = new ArrayList(); EntityExpr joinExpr = null; EntityExpr expr = null; String viewName = null; GenericValue contentAssoc = null; String contentFieldName = null; if (direction != null && direction.equalsIgnoreCase("From") ) { contentFieldName = "contentIdTo"; } else { contentFieldName = "contentId"; } if (direction != null && direction.equalsIgnoreCase("From") ) { viewName = "ContentAssocDataResourceViewFrom"; } else { viewName = "ContentAssocDataResourceViewTo"; } //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, assocTypes:" + assocTypes, module); Map fieldMap = UtilMisc.toMap(contentFieldName, contentId); if (assocTypes != null && assocTypes.size() == 1) { fieldMap.putAll(UtilMisc.toMap("contentAssocTypeId", assocTypes.get(0))); } if (UtilValidate.isNotEmpty(mapKey)) { if (mapKey.equalsIgnoreCase("is null")) fieldMap.putAll(UtilMisc.toMap("mapKey", null)); else fieldMap.putAll(UtilMisc.toMap("mapKey", mapKey)); } if (UtilValidate.isNotEmpty(contentAssocPredicateId)) { if (contentAssocPredicateId.equalsIgnoreCase("is null")) fieldMap.putAll(UtilMisc.toMap("contentAssocPredicateId", null)); else fieldMap.putAll(UtilMisc.toMap("contentAssocPredicateId", contentAssocPredicateId)); } if (nullThruDatesOnly != null && nullThruDatesOnly.booleanValue()) { fieldMap.putAll(UtilMisc.toMap("thruDate", null)); } List contentAssocsUnfiltered = null; //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, fieldMap:" + fieldMap, module); contentAssocsUnfiltered = delegator.findByAndCache("ContentAssoc", fieldMap, UtilMisc.toList("-fromDate")); //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, contentAssocsUnfiltered:" + contentAssocsUnfiltered, module); if (fromDate == null && fromDateStr != null ) { fromDate = UtilDateTime.toTimestamp( fromDateStr ); } List contentAssocsDateFiltered2 = EntityUtil.filterByDate(contentAssocsUnfiltered, fromDate); List contentAssocsDateFiltered = EntityUtil.orderBy(contentAssocsDateFiltered2, UtilMisc.toList("sequenceNum", "fromDate DESC")); String contentAssocTypeId = null; List contentAssocsTypeFiltered = new ArrayList(); if (assocTypes != null && assocTypes.size() > 1) { Iterator it = contentAssocsDateFiltered.iterator(); while (it.hasNext()) { contentAssoc = (GenericValue)it.next(); contentAssocTypeId = (String)contentAssoc.get("contentAssocTypeId"); if (assocTypes.contains(contentAssocTypeId)) { contentAssocsTypeFiltered.add(contentAssoc); } } } else { contentAssocsTypeFiltered = contentAssocsDateFiltered; } String assocRelationName = null; if (direction != null && direction.equalsIgnoreCase("To") ) { assocRelationName = "ToContent"; } else { assocRelationName = "FromContent"; } GenericValue contentAssocDataResourceView = null; GenericValue content = null; GenericValue dataResource = null; List contentAssocDataResourceList = new ArrayList(); Locale locale = Locale.getDefault(); // TODO: this needs to be passed in Iterator it = contentAssocsTypeFiltered.iterator(); while (it.hasNext()) { contentAssoc = (GenericValue)it.next(); content = contentAssoc.getRelatedOneCache(assocRelationName); if (contentTypes != null && contentTypes.size() > 0) { String contentTypeId = (String)content.get("contentTypeId"); if (contentTypes.contains(contentTypeId)) { contentAssocDataResourceView = delegator.makeValue(viewName, null); contentAssocDataResourceView.setAllFields(content, true, null, null); } } else { contentAssocDataResourceView = delegator.makeValue(viewName, null); contentAssocDataResourceView.setAllFields(content, true, null, null); } SimpleMapProcessor.runSimpleMapProcessor("org/ofbiz/content/ContentManagementMapProcessors.xml", "contentAssocOut", contentAssoc, contentAssocDataResourceView, new ArrayList(), locale); //if (Debug.infoOn()) Debug.logInfo("contentAssoc:" + contentAssoc, module); //contentAssocDataResourceView.setAllFields(contentAssoc, false, null, null); String dataResourceId = content.getString("dataResourceId"); if (UtilValidate.isNotEmpty(dataResourceId)) dataResource = content.getRelatedOneCache("DataResource"); //if (Debug.infoOn()) Debug.logInfo("dataResource:" + dataResource, module); //if (Debug.infoOn()) Debug.logInfo("contentAssocDataResourceView:" + contentAssocDataResourceView, module); if (dataResource != null) { //contentAssocDataResourceView.setAllFields(dataResource, false, null, null); SimpleMapProcessor.runSimpleMapProcessor("org/ofbiz/content/ContentManagementMapProcessors.xml", "dataResourceOut", dataResource, contentAssocDataResourceView, new ArrayList(), locale); } //if (Debug.infoOn()) Debug.logInfo("contentAssocDataResourceView:" + contentAssocDataResourceView, module); contentAssocDataResourceList.add(contentAssocDataResourceView ); } List orderByList = null; if (UtilValidate.isNotEmpty(orderBy)) { orderByList = StringUtil.split(orderBy, "|"); contentAssocDataResourceList = EntityUtil.orderBy(contentAssocDataResourceList, orderByList); } HashMap results = new HashMap(); results.put("entityList", contentAssocDataResourceList); if (contentAssocDataResourceList != null && contentAssocDataResourceList.size() > 0 ) { results.put("view", contentAssocDataResourceList.get(0)); } return results; }/* public static Map getSubContentAndDataResource(GenericDelegator delegator, String contentId, String direction, Timestamp fromDate, String assocType, String contentType, String orderBy) throws GenericEntityException { List exprList = new ArrayList(); EntityExpr joinExpr = null; EntityExpr expr = null; String viewName = null; GenericValue contentAssoc = null; String contentFieldName = null; if (direction != null && direction.equalsIgnoreCase("From") ) { viewName = "ContentAssocDataResourceViewFrom"; contentFieldName = "contentIdTo"; joinExpr = new EntityExpr("caContentIdTo", EntityOperator.EQUALS, contentId); } else { viewName = "ContentAssocDataResourceViewTo"; contentFieldName = "contentId"; joinExpr = new EntityExpr("caContentId", EntityOperator.EQUALS, contentId); } exprList.add(joinExpr); if (UtilValidate.isNotEmpty(assocType)) { expr = new EntityExpr("caContentAssocTypeId", EntityOperator.EQUALS, assocType); exprList.add(expr); } if (UtilValidate.isNotEmpty(contentType)) { expr = new EntityExpr("caContentTypeId", EntityOperator.EQUALS, contentType); exprList.add(expr); } List orderByList = null; if (UtilValidate.isNotEmpty(orderBy)) { orderByList = StringUtil.split(orderBy, "|"); contentAssocDataResourceList = EntityUtil.orderBy(contentAssocDataResourceList, orderByList); } HashMap results = new HashMap(); results.put("entityList", contentAssocDataResourceList); return results; }*/}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -