}
@SuppressWarnings("unchecked")
public static List<GenericValue> getContentAssocsWithId(Delegator delegator, String contentId, Timestamp fromDate, Timestamp thruDate, String direction, List<String> assocTypes) throws GenericEntityException {
List exprList = FastList.newInstance();
EntityExpr joinExpr = null;
EntityExpr expr = null;
if (direction != null && direction.equalsIgnoreCase("From")) {
joinExpr = EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId);
} else {
joinExpr = EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId);
}
exprList.add(joinExpr);
if (UtilValidate.isNotEmpty(assocTypes)) {
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);