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.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
@ -87,5 +88,16 @@ public class EntityComparisonUtilityFunctions {
fieldLabelToOutputFieldLabel);
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)
throws MalformedQueryParametersException {
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
subjectEntityURI, dataSource, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
.getQueryResult();
Map<String, Set<String>> 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<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
entityURI, dataSource, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
log, dataSource, entityURI);
return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);

View file

@ -107,10 +107,8 @@ public class EntityGrantCountRequestHandler implements
Entity entity = queryManager.getQueryResult();
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
entityURI, dataSource, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult();
Map<String, Set<String>> 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<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
subjectOrganization, dataSource, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
.getQueryResult();
Map<String, Set<String>> 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.