This commit is contained in:
James Agnew 2016-05-03 10:12:03 -04:00
parent cce0ce6b8e
commit 7429a382dd
1 changed files with 5 additions and 12 deletions

View File

@ -2071,8 +2071,11 @@ public class SearchBuilder {
String targetResourceType = defaultString(nextInclude.getParamTargetType(), null); String targetResourceType = defaultString(nextInclude.getParamTargetType(), null);
for (String nextPath : paths) { for (String nextPath : paths) {
String sql; String sql;
boolean haveTargetTypesDefinedByParam = param != null && param.getTargets() != null && param.getTargets().isEmpty() == false;
if (targetResourceType != null) { if (targetResourceType != null) {
sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids) AND r.myTargetResourceType = :target_resource_type"; sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids) AND r.myTargetResourceType = :target_resource_type";
} else if (haveTargetTypesDefinedByParam) {
sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids) AND r.myTargetResourceType in (:target_resource_types)";
} else { } else {
sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids)"; sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids)";
} }
@ -2081,21 +2084,11 @@ public class SearchBuilder {
q.setParameter("target_pids", nextRoundMatches); q.setParameter("target_pids", nextRoundMatches);
if (targetResourceType != null) { if (targetResourceType != null) {
q.setParameter("target_resource_type", targetResourceType); q.setParameter("target_resource_type", targetResourceType);
} else if (haveTargetTypesDefinedByParam) {
q.setParameter("target_resource_types", param.getTargets());
} }
List<ResourceLink> results = q.getResultList(); List<ResourceLink> results = q.getResultList();
for (ResourceLink resourceLink : results) { for (ResourceLink resourceLink : results) {
if (param != null && param.getTargets() != null && param.getTargets().isEmpty() == false) {
String type;
if (theReverseMode) {
type = resourceLink.getSourceResource().getResourceType();
} else {
type = resourceLink.getTargetResource().getResourceType();
}
if (!param.getTargets().contains(type)) {
continue;
}
}
if (theReverseMode) { if (theReverseMode) {
Long pid = resourceLink.getSourceResourcePid(); Long pid = resourceLink.getSourceResourcePid();
pidsToInclude.add(pid); pidsToInclude.add(pid);