*/\r
@Override\r
public List<TaxonNodeAgentRelation> listTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid,\r
- UUID agentUuid, UUID rankUuid, Integer start, Integer limit, List<String> propertyPaths) {\r
+ UUID agentUuid, UUID rankUuid, UUID relTypeUuid, Integer start, Integer limit, List<String> propertyPaths) {\r
\r
\r
- StringBuilder hql = prepareListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, false);\r
+ StringBuilder hql = prepareListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, relTypeUuid, false);\r
\r
Query query = getSession().createQuery(hql.toString());\r
\r
}\r
}\r
\r
- setParamsForListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, query);\r
+ setParamsForListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, relTypeUuid, query);\r
\r
List<TaxonNodeAgentRelation> records = query.list();\r
\r
* {@inheritDoc}\r
*/\r
@Override\r
- public long countTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid) {\r
+ public long countTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid, UUID relTypeUuid) {\r
\r
- StringBuilder hql = prepareListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, true);\r
+ StringBuilder hql = prepareListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, relTypeUuid, true);\r
Query query = getSession().createQuery(hql.toString());\r
\r
- setParamsForListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, query);\r
+ setParamsForListTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, relTypeUuid, query);\r
\r
Long count = Long.parseLong(query.uniqueResult().toString());\r
\r
* @param taxonUuid\r
* @param classificationUuid\r
* @param agentUuid\r
+ * @param relTypeUuid TODO\r
+ * @param doCount TODO\r
* @param rankId\r
* limit to taxa having this rank, only applies if <code>taxonUuid = null</code>\r
- * @param doCount TODO\r
* @return\r
*/\r
- private StringBuilder prepareListTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid, boolean doCount) {\r
+ private StringBuilder prepareListTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid, UUID relTypeUuid, boolean doCount) {\r
\r
StringBuilder hql = new StringBuilder();\r
\r
hql.append(" join tn.classification as c ");\r
if(agentUuid != null) {\r
// agentUuid is search filter, do not fetch it\r
- hql.append(" join tnar.agent as a ");\r
+// hql.append(" join tnar.agent as a ");\r
+ hql.append(join_fetch_mode).append(" tnar.agent as a ");\r
} else {\r
hql.append(join_fetch_mode).append(" tnar.agent as a ");\r
}\r
\r
hql.append(" where 1 = 1 ");\r
\r
+ if(relTypeUuid != null) {\r
+ hql.append(" and tnar.type.uuid = :relTypeUuid ");\r
+ }\r
+\r
if(taxonUuid != null) {\r
hql.append(" and t.uuid = :taxonUuid ");\r
} else {\r
* @param taxonUuid\r
* @param classificationUuid\r
* @param agentUuid\r
- * @param rankId TODO\r
+ * @param relTypeUuid TODO\r
* @param query\r
+ * @param rankId TODO\r
*/\r
private void setParamsForListTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid,\r
- UUID rankUuid, Query query) {\r
+ UUID rankUuid, UUID relTypeUuid, Query query) {\r
\r
if(taxonUuid != null) {\r
query.setParameter("taxonUuid", taxonUuid);\r
if(agentUuid != null) {\r
query.setParameter("agentUuid", agentUuid);\r
}\r
+ if(relTypeUuid != null) {\r
+ query.setParameter("relTypeUuid", relTypeUuid);\r
+ }\r
}\r
\r
}\r
*\r
* @param taxonUuid\r
* @param agentUuid TODO\r
- * @param rankId TODO\r
+ * @param relTypeUuid TODO\r
* @param start\r
* @param limit\r
* @param propertyPaths\r
+ * @param rankId TODO\r
* @param classification\r
* @return\r
*/\r
public List<TaxonNodeAgentRelation> listTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid,\r
- UUID agentUuid, UUID rankUuid, Integer start, Integer limit, List<String> propertyPaths);\r
+ UUID agentUuid, UUID rankUuid, UUID relTypeUuid, Integer start, Integer limit, List<String> propertyPaths);\r
\r
/**\r
* Returns the number of TaxonNodeAgentRelation entities which are associated with the TaxonNode for the\r
*\r
* @param taxonUuid\r
* @param agentUuid TODO\r
+ * @param relTypeUuid TODO\r
* @param rankId TODO\r
* @param classification\r
* @return\r
*/\r
- public long countTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid);\r
+ public long countTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid, UUID relTypeUuid);\r
\r
\r
}\r
private static final List<String> TAXONNODEAGENTRELATIONS_INIT_STRATEGY = Arrays.asList(new String[]{\r
// NOTE: all other cases are covered in the TaxonNodeDaoHibernateImpl method\r
// which is using join fetches\r
- "taxonNode.taxon.name.nomenclaturalReference"\r
+ "taxonNode.taxon.name.nomenclaturalReference",\r
});\r
\r
+ public List<String> getTaxonNodeAgentRelationsInitStrategy() {\r
+ return TAXONNODEAGENTRELATIONS_INIT_STRATEGY;\r
+ }\r
+\r
@Autowired\r
private ITaxonNodeService nodeService;\r
\r
public Pager<TaxonNodeAgentRelation> doGetTaxonNodeAgentRelations(\r
@PathVariable("uuid") UUID uuid,\r
@RequestParam(value = "classification_uuid" , required = false) UUID classificationUuid,\r
+ @RequestParam(value = "taxon_uuid" , required = false) UUID taxonUuid,\r
+ @RequestParam(value = "relType_uuid" , required = false) UUID relTypeUuid,\r
@RequestParam(value = "rank" , required = false) Rank rank,\r
@RequestParam(value = "pageNumber", required = false) Integer pageNumber,\r
@RequestParam(value = "pageSize", required = false) Integer pageSize,\r
if(rank != null) {\r
rankUuid = rank.getUuid();\r
}\r
- Pager<TaxonNodeAgentRelation> pager = nodeService.pageTaxonNodeAgentRelations(null, classificationUuid, uuid,\r
- rankUuid, pagerParams.getPageSize(), pagerParams.getPageIndex(), TAXONNODEAGENTRELATIONS_INIT_STRATEGY);\r
+ Pager<TaxonNodeAgentRelation> pager = nodeService.pageTaxonNodeAgentRelations(taxonUuid, classificationUuid, uuid,\r
+ rankUuid, relTypeUuid, pagerParams.getPageSize(), pagerParams.getPageIndex(), getTaxonNodeAgentRelationsInitStrategy());\r
return pager;\r
}\r
\r
public class AgentPortalController extends AgentController {
private static final List<String> TEAM_OR_PERSON_BASE_INIT_STRATEGY = Arrays.asList(new String[]{
+ // NOTE: all other cases are covered in the TaxonNodeDaoHibernateImpl method
+ // which is using join fetches
// AgentBase
-// "contact.urls",
-// "contact#phoneNumbers",
-// "contact#addresses",
-// "contact#faxNumbers",
-// "contact#emailAddresses",
+ "contact.*",
// Person
"institutionalMemberships.$",
+ "institutionalMemberships.institute.contact.*",
// Team
"teamMembers.$"
});
+ private static final List<String> TAXONNODEAGENTRELATIONS_INIT_STRATEGY = Arrays.asList(new String[]{
+ // NOTE: all other cases are covered in the TaxonNodeDaoHibernateImpl method
+ // which is using join fetches
+ "taxonNode.taxon.name.nomenclaturalReference",
+ // AgentBase
+ "agent.contact.*",
+ // Person
+ "agent.institutionalMemberships.$",
+ "agent.institutionalMemberships.institute.contact.*",
+ // Team
+ "agent.teamMembers.$"
+ });
+
+ @Override
+ public List<String> getTaxonNodeAgentRelationsInitStrategy() {
+ return TAXONNODEAGENTRELATIONS_INIT_STRATEGY;
+ }
+
/**
*
*/
public Pager<TaxonNodeAgentRelation> doGetTaxonNodeAgentRelations(\r
@PathVariable("uuid") UUID uuid,\r
@PathVariable("classification_uuid") UUID classificationUuid,\r
+ @RequestParam(value = "relType_uuid" , required = false) UUID relTypeUuid,\r
@RequestParam(value = "pageNumber", required = false) Integer pageNumber,\r
@RequestParam(value = "pageSize", required = false) Integer pageSize,\r
HttpServletRequest request,\r
pagerParams.normalizeAndValidate(response);\r
\r
Pager<TaxonNodeAgentRelation> pager = nodeService.pageTaxonNodeAgentRelations(uuid, classificationUuid,\r
- null, null, pagerParams.getPageSize(), pagerParams.getPageIndex(), null);\r
+ null, null, relTypeUuid, pagerParams.getPageSize(), pagerParams.getPageIndex(), null);\r
return pager;\r
}\r
\r
* @param taxonUuid
* @param agentUuid TODO
* @param rankUuid TODO
+ * @param relTypeUuid TODO
* @param classification
* @return
*/
public Pager<TaxonNodeAgentRelation> pageTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid,
- UUID agentUuid, UUID rankUuid, Integer pageSize, Integer pageIndex, List<String> propertyPaths);
+ UUID agentUuid, UUID rankUuid, UUID relTypeUuid, Integer pageSize, Integer pageIndex, List<String> propertyPaths);
}
@Override
public Pager<TaxonNodeAgentRelation> pageTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid,
- UUID agentUuid, UUID rankUuid, Integer pageSize, Integer pageIndex, List<String> propertyPaths) {
+ UUID agentUuid, UUID rankUuid, UUID relTypeUuid, Integer pageSize, Integer pageIndex, List<String> propertyPaths) {
List<TaxonNodeAgentRelation> records = null;
- long count = dao.countTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid);
+ long count = dao.countTaxonNodeAgentRelations(taxonUuid, classificationUuid, agentUuid, rankUuid, relTypeUuid);
if(PagerUtils.hasResultsInRange(count, pageIndex, pageSize)) {
records = dao.listTaxonNodeAgentRelations(taxonUuid, classificationUuid,
- agentUuid, rankUuid, PagerUtils.startFor(pageSize, pageIndex), PagerUtils.limitFor(pageSize), propertyPaths);
+ agentUuid, rankUuid, relTypeUuid, PagerUtils.startFor(pageSize, pageIndex), PagerUtils.limitFor(pageSize), propertyPaths);
}
Pager<TaxonNodeAgentRelation> pager = new DefaultPagerImpl<TaxonNodeAgentRelation>(pageIndex, count, pageSize, records);