List<EntityExpr> exprListOr = FastList.newInstance();
for(String assocType : assocTypes) {
expr = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, assocType);
exprListOr.add(expr);
}
EntityConditionList assocExprList = EntityCondition.makeCondition(exprListOr, EntityOperator.OR);
exprList.add(assocExprList);
}
if (fromDate != null) {
EntityExpr fromExpr = EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate);
exprList.add(fromExpr);
}
if (thruDate != null) {
List<EntityExpr> thruList = FastList.newInstance();
//thruDate = UtilDateTime.getDayStart(thruDate, daysLater);
EntityExpr thruExpr = EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN, thruDate);
thruList.add(thruExpr);
EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null);
thruList.add(thruExpr2);
EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
exprList.add(thruExprList);
} else if (fromDate != null) {
List<EntityExpr> thruList = FastList.newInstance();
EntityExpr thruExpr = EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, fromDate);
thruList.add(thruExpr);
EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null);
thruList.add(thruExpr2);
EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
exprList.add(thruExprList);
} else {
EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null);
exprList.add(thruExpr2);
}
EntityConditionList assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND);
//if (Debug.infoOn()) Debug.logInfo(" assocExprList:" + assocExprList , "");
List<GenericValue> relatedAssocs = delegator.findList("ContentAssoc", assocExprList, null, UtilMisc.toList("-fromDate"), null, false);
//if (Debug.infoOn()) Debug.logInfo(" relatedAssoc:" + relatedAssocs.size() , "");
//for (int i = 0; i < relatedAssocs.size(); i++) {
//GenericValue a = (GenericValue) relatedAssocs.get(i);