📄 contentservicescomplex.java
字号:
thruList.add(thruExpr);
EntityExpr thruExpr2 = new EntityExpr("caThruDate", EntityOperator.EQUALS, null);
thruList.add(thruExpr2);
EntityConditionList thruExprList = new EntityConditionList(thruList, EntityOperator.OR);
exprList.add(thruExprList);
} else if (fromDate != null) {
List thruList = new ArrayList();
EntityExpr thruExpr = new EntityExpr("caThruDate", EntityOperator.GREATER_THAN, fromDate);
//Debug.logVerbose("in getAACADR, thruExpr:" + thruExpr, null);
thruList.add(thruExpr);
EntityExpr thruExpr2 = new EntityExpr("caThruDate", EntityOperator.EQUALS, null);
//Debug.logVerbose("in getAACADR, thruExpr2:" + thruExpr2, null);
thruList.add(thruExpr2);
EntityConditionList thruExprList = new EntityConditionList(thruList, EntityOperator.OR);
exprList.add(thruExprList);
}
EntityConditionList assocExprList = new EntityConditionList(exprList, EntityOperator.AND);
List relatedAssocs = null;
//Debug.logVerbose("in getAACADR, viewName:" + viewName, null);
try {
//relatedAssocs = delegator.findByCondition(viewName, joinExpr,
relatedAssocs = delegator.findByCondition(viewName, assocExprList,
new ArrayList(),UtilMisc.toList("caFromDate"));
} catch(GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
}
//Debug.logVerbose("relatedAssocs size:" + relatedAssocs.size(), null);
for (int i=0; i < relatedAssocs.size(); i++) {
GenericValue a = (GenericValue)relatedAssocs.get(i);
Debug.logVerbose(" contentId:" + a.get("contentId")
+ " To:" + a.get("caContentIdTo")
+ " fromDate:" + a.get("caFromDate")
+ " thruDate:" + a.get("caThruDate")
+ " AssocTypeId:" + a.get("caContentAssocTypeId")
,null);
}
HashMap results = new HashMap();
results.put("entityList", relatedAssocs);
return results;
}
/*
* A service that returns a list of ContentAssocDataResourceViewFrom/To views that are
* associated with the passed in contentId. Other conditions are also applied, including:
* a list of contentAssocTypeIds or contentTypeIds that the result set views must match.
* A direction (From or To - case insensitive).
* From and thru dates or date strings.
* A mapKey value.
*/
public static Map getAssocAndContentAndDataResourceCache(DispatchContext dctx, Map context) {
GenericDelegator delegator = dctx.getDelegator();
List assocTypes = (List)context.get("assocTypes");
List contentTypes = (List)context.get("contentTypes");
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");
Boolean nullThruDatesOnly = (Boolean)context.get("nullThruDatesOnly");
//Debug.logVerbose("in getAACADR, contentId:" + contentId, null);
//Debug.logVerbose("in getAACADR, mapKey:" + mapKey, null);
//Debug.logVerbose("in getAACADR, direction:" + direction, null);
//Debug.logVerbose("in getAACADR, fromDateStr:" + fromDateStr, null);
Map results = null;
try {
results = getAssocAndContentAndDataResourceCacheMethod(delegator,
contentId, mapKey, direction, fromDate,
fromDateStr, assocTypes, contentTypes, nullThruDatesOnly);
} 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) throws GenericEntityException, MiniLangException{
return getAssocAndContentAndDataResourceCacheMethod(delegator,
contentId, mapKey, direction, fromDate,
fromDateStr, assocTypes, contentTypes, null);
}
public static Map getAssocAndContentAndDataResourceCacheMethod(GenericDelegator delegator, String contentId, String mapKey, String direction,
Timestamp fromDate, String fromDateStr, List assocTypes, List contentTypes, Boolean nullThruDatesOnly) 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";
}
List contentAssocsUnfiltered = null;
if (nullThruDatesOnly != null && nullThruDatesOnly.booleanValue()) {
contentAssocsUnfiltered = delegator.findByAndCache("ContentAssoc", UtilMisc.toMap(contentFieldName, contentId, "mapKey", mapKey, "thruDate", null), UtilMisc.toList("-fromDate"));
} else {
contentAssocsUnfiltered = delegator.findByAndCache("ContentAssoc", UtilMisc.toMap(contentFieldName, contentId, "mapKey", mapKey), UtilMisc.toList("-fromDate"));
}
if (fromDate == null && fromDateStr != null ) {
fromDate = UtilDateTime.toTimestamp( fromDateStr );
}
List contentAssocsDateFiltered = EntityUtil.filterByDate(contentAssocsUnfiltered, fromDate);
String contentAssocTypeId = null;
List contentAssocsTypeFiltered = new ArrayList();
if (assocTypes != null && assocTypes.size() > 0) {
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 subContentDataResourceView = null;
GenericValue content = null;
GenericValue dataResource = null;
List subContentDataResourceList = new ArrayList();
Locale locale = Locale.getDefault();
Iterator it = contentAssocsTypeFiltered.iterator();
while (it.hasNext()) {
contentAssoc = (GenericValue)it.next();
content = contentAssoc.getRelatedOneCache(assocRelationName);
if (Debug.verboseOn()) Debug.logVerbose("content:" + content, module);
if (contentTypes != null && contentTypes.size() > 0) {
String contentTypeId = (String)content.get("contentTypeId");
if (contentTypes.contains(contentTypeId)) {
subContentDataResourceView = delegator.makeValue("SubContentDataResourceView", null);
subContentDataResourceView.setAllFields(content, true, null, null);
}
} else {
subContentDataResourceView = delegator.makeValue("SubContentDataResourceView", null);
subContentDataResourceView.setAllFields(content, true, null, null);
}
if (Debug.verboseOn()) Debug.logVerbose("subContentDataResourceView:" + subContentDataResourceView, module);
dataResource = content.getRelatedOneCache("DataResource");
if (dataResource != null) {
if (Debug.verboseOn()) Debug.logVerbose("dataResource:" + dataResource, module);
SimpleMapProcessor.runSimpleMapProcessor("org/ofbiz/content/ContentManagementMapProcessors.xml", "dataResourceOut", dataResource, subContentDataResourceView, new ArrayList(), locale);
}
subContentDataResourceList.add(subContentDataResourceView );
}
HashMap results = new HashMap();
results.put("entityList", subContentDataResourceList);
return results;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -