1. Refactored common code for getting sub-organization types.

This commit is contained in:
cdtank 2011-02-08 00:06:02 +00:00
parent 35487d0f30
commit 0abd2aa86b
3 changed files with 21 additions and 21 deletions

View file

@ -2,6 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparis
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -87,5 +88,16 @@ public class EntityComparisonUtilityFunctions {
fieldLabelToOutputFieldLabel); fieldLabelToOutputFieldLabel);
return highestLevelOrgURI; return highestLevelOrgURI;
} }
public static Map<String, Set<String>> getSubEntityTypes(Log log,
DataSource dataSource, String subjectOrganization)
throws MalformedQueryParametersException {
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
subjectOrganization, dataSource, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
.getQueryResult();
return subOrganizationTypesResult;
}
} }

View file

@ -120,11 +120,8 @@ public class EntityPublicationCountRequestHandler implements
String subjectEntityURI, Entity entity) String subjectEntityURI, Entity entity)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
subjectEntityURI, dataSource, log); log, dataSource, subjectEntityURI);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
.getQueryResult();
return prepareStandaloneResponse(vitroRequest, entity, subjectEntityURI, return prepareStandaloneResponse(vitroRequest, entity, subjectEntityURI,
subOrganizationTypesResult); subOrganizationTypesResult);
@ -144,11 +141,8 @@ public class EntityPublicationCountRequestHandler implements
Entity entity = queryManager.getQueryResult(); Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( log, dataSource, entityURI);
entityURI, dataSource, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult();
return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult); return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);

View file

@ -107,10 +107,8 @@ public class EntityGrantCountRequestHandler implements
Entity entity = queryManager.getQueryResult(); Entity entity = queryManager.getQueryResult();
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
entityURI, dataSource, log); log, dataSource, entityURI);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult();
return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult); return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);
@ -149,17 +147,13 @@ public class EntityGrantCountRequestHandler implements
String subjectOrganization, Entity entity) String subjectOrganization, Entity entity)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
subjectOrganization, dataSource, log); log, dataSource, subjectOrganization);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
.getQueryResult();
return prepareStandaloneResponse(vitroRequest, entity, subjectOrganization, return prepareStandaloneResponse(vitroRequest, entity, subjectOrganization,
subOrganizationTypesResult); subOrganizationTypesResult);
} }
/** /**
* Provides response when json file containing the grant count over the * Provides response when json file containing the grant count over the
* years is requested. * years is requested.