}
public static Map getAssocAndContentAndDataResourceMethod(GenericDelegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, Timestamp thruDate, String fromDateStr, String thruDateStr, List assocTypes, List contentTypes) {
List exprList = FastList.newInstance();
EntityExpr joinExpr = null;
EntityExpr expr = null;
String viewName = null;
if (mapKey != null) {
EntityExpr mapKeyExpr = EntityCondition.makeCondition("caMapKey", EntityOperator.EQUALS, mapKey);
exprList.add(mapKeyExpr);
}
if (direction != null && direction.equalsIgnoreCase("From")) {
joinExpr = EntityCondition.makeCondition("caContentIdTo", EntityOperator.EQUALS, contentId);
viewName = "ContentAssocDataResourceViewFrom";
} else {
joinExpr = EntityCondition.makeCondition("caContentId", EntityOperator.EQUALS, contentId);
viewName = "ContentAssocDataResourceViewTo";
}
exprList.add(joinExpr);
if (UtilValidate.isNotEmpty(assocTypes)) {
exprList.add(EntityCondition.makeCondition("caContentAssocTypeId", EntityOperator.IN, assocTypes));
}
if (UtilValidate.isNotEmpty(contentTypes)) {
exprList.add(EntityCondition.makeCondition("contentTypeId", EntityOperator.IN, contentTypes));
}
if (fromDate == null && fromDateStr != null) {
fromDate = UtilDateTime.toTimestamp(fromDateStr);
}
if (thruDate == null && thruDateStr != null) {
thruDate = UtilDateTime.toTimestamp(thruDateStr);
}
if (fromDate != null) {
EntityExpr fromExpr = EntityCondition.makeCondition("caFromDate", EntityOperator.LESS_THAN, fromDate);
exprList.add(fromExpr);
}
if (thruDate != null) {
List thruList = FastList.newInstance();
//thruDate = UtilDateTime.getDayStart(thruDate, daysLater);
EntityExpr thruExpr = EntityCondition.makeCondition("caThruDate", EntityOperator.LESS_THAN, thruDate);
thruList.add(thruExpr);
EntityExpr thruExpr2 = EntityCondition.makeCondition("caThruDate", EntityOperator.EQUALS, null);
thruList.add(thruExpr2);
EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
exprList.add(thruExprList);
} else if (fromDate != null) {
List thruList = FastList.newInstance();
EntityExpr thruExpr = EntityCondition.makeCondition("caThruDate", EntityOperator.GREATER_THAN, fromDate);
thruList.add(thruExpr);
EntityExpr thruExpr2 = EntityCondition.makeCondition("caThruDate", EntityOperator.EQUALS, null);
thruList.add(thruExpr2);
EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
exprList.add(thruExprList);
}
EntityConditionList assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND);