dynamicViewEntity.addAlias(entityAlias, prefix + "Keyword", "keyword", null, null, null, null);
dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId"));
entityConditionList.add(EntityCondition.makeCondition(prefix + "Keyword", EntityOperator.LIKE, keyword));
//don't add an alias for this, will be part of a complex alias: dynamicViewEntity.addAlias(entityAlias, prefix + "RelevancyWeight", "relevancyWeight", null, null, null, null);
relevancyComplexAlias.addComplexAliasMember(new ComplexAliasField(entityAlias, "relevancyWeight", null, null));
}
//TODO: find out why Oracle and other dbs don't like the query resulting from this and fix: workEffortIdGroupBy = true;
if (!doingBothAndOr) {
dynamicViewEntity.addAlias(null, "totalRelevancy", null, null, null, null, null, relevancyComplexAlias);
}
}
if (keywordFixedOrSetAndList.size() > 0) {
for (Set<String> keywordFixedOrSet: keywordFixedOrSetAndList) {
// make index based values and increment
String entityAlias = "PK" + index;
String prefix = "pk" + index;
index++;
dynamicViewEntity.addMemberEntity(entityAlias, "WorkEffortKeyword");
dynamicViewEntity.addAlias(entityAlias, prefix + "Keyword", "keyword", null, null, null, null);
dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId"));
List<EntityExpr> keywordOrList = FastList.newInstance();
for (String keyword: keywordFixedOrSet) {
keywordOrList.add(EntityCondition.makeCondition(prefix + "Keyword", EntityOperator.LIKE, keyword));
}
entityConditionList.add(EntityCondition.makeCondition(keywordOrList, EntityOperator.OR));
workEffortIdGroupBy = true;
if (doingBothAndOr) {
relevancyComplexAlias.addComplexAliasMember(new ComplexAliasField(entityAlias, "relevancyWeight", null, "sum"));
} else {
dynamicViewEntity.addAlias(entityAlias, "totalRelevancy", "relevancyWeight", null, null, null, "sum");
}
}
}