}
@SuppressWarnings("unchecked")
public static Map<String, Object> getAssocAndContentAndDataResourceMethod(Delegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, Timestamp thruDate, String fromDateStr, String thruDateStr, List<String> assocTypes, List<String> contentTypes) {
List exprList = FastList.newInstance();
EntityExpr joinExpr = 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<EntityExpr> 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<EntityExpr> thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
exprList.add(thruExprList);
} else if (fromDate != null) {
List<EntityExpr> 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<EntityExpr> thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
exprList.add(thruExprList);
}
EntityConditionList<EntityExpr> assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND);