From 0abd2aa86baa8e07b0b0fd7a52d72b064bdf9d10 Mon Sep 17 00:00:00 2001 From: cdtank Date: Tue, 8 Feb 2011 00:06:02 +0000 Subject: [PATCH] 1. Refactored common code for getting sub-organization types. --- .../EntityComparisonUtilityFunctions.java | 12 ++++++++++++ .../EntityPublicationCountRequestHandler.java | 14 ++++---------- .../EntityGrantCountRequestHandler.java | 16 +++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java index e2cde700..b91b2861 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java @@ -2,6 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparis import java.util.HashMap; import java.util.Map; +import java.util.Set; import org.apache.commons.logging.Log; @@ -87,5 +88,16 @@ public class EntityComparisonUtilityFunctions { fieldLabelToOutputFieldLabel); return highestLevelOrgURI; } + + public static Map> getSubEntityTypes(Log log, + DataSource dataSource, String subjectOrganization) + throws MalformedQueryParametersException { + QueryRunner>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( + subjectOrganization, dataSource, log); + + Map> subOrganizationTypesResult = queryManagerForsubOrganisationTypes + .getQueryResult(); + return subOrganizationTypesResult; + } } diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java index 8cacdb65..9cf5e9a9 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java @@ -120,11 +120,8 @@ public class EntityPublicationCountRequestHandler implements String subjectEntityURI, Entity entity) throws MalformedQueryParametersException { - QueryRunner>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( - subjectEntityURI, dataSource, log); - - Map> subOrganizationTypesResult = queryManagerForsubOrganisationTypes - .getQueryResult(); + Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( + log, dataSource, subjectEntityURI); return prepareStandaloneResponse(vitroRequest, entity, subjectEntityURI, subOrganizationTypesResult); @@ -144,11 +141,8 @@ public class EntityPublicationCountRequestHandler implements Entity entity = queryManager.getQueryResult(); - - QueryRunner>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( - entityURI, dataSource, log); - - Map> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult(); + Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( + log, dataSource, entityURI); return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult); diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java index 00b416eb..37d68651 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java @@ -107,10 +107,8 @@ public class EntityGrantCountRequestHandler implements Entity entity = queryManager.getQueryResult(); - QueryRunner>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( - entityURI, dataSource, log); - - Map> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult(); + Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( + log, dataSource, entityURI); return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult); @@ -149,17 +147,13 @@ public class EntityGrantCountRequestHandler implements String subjectOrganization, Entity entity) throws MalformedQueryParametersException { - QueryRunner>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( - subjectOrganization, dataSource, log); - - Map> subOrganizationTypesResult = queryManagerForsubOrganisationTypes - .getQueryResult(); + Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( + log, dataSource, subjectOrganization); return prepareStandaloneResponse(vitroRequest, entity, subjectOrganization, subOrganizationTypesResult); } - - + /** * Provides response when json file containing the grant count over the * years is requested.