Committing the following changes
1) Handling Null pointer Exceptions for EntityPubCount, EntityGrantCount and EntitySubOrganizationTypes 2) Removing the dependency on vis_mode parameter in the server side code. The class the individual belongs to is retrieved using vitroRequest.getWebappDaoFactory().getIndividualDao().getIndividualByURI(IndividualURI).isVClass(ClassURI) 3) On the client side, the vis_mode parameter is set(from the value passed on by the requesthandler) to differentiate between personURL and SubOrganizationTemporalGraphURL on drill down. 4) Added entityComparisonErrorActivator.ftl to handle edge cases (if the resultset of the queries is NULL)
This commit is contained in:
parent
2152bb6008
commit
9971e5fa2b
9 changed files with 121 additions and 113 deletions
|
@ -105,7 +105,7 @@
|
|||
<listener>
|
||||
<listener-class>edu.cornell.mannlib.vitro.webapp.servlet.setup.PelletReasonerSetup</listener-class>
|
||||
</listener>
|
||||
<!-- -->
|
||||
|
||||
|
||||
<!-- The followng listener records all edit changes, in reified form, to another database model -->
|
||||
<!-- still at an experimental stage -->
|
||||
|
|
|
@ -464,7 +464,7 @@ function getTemporalVisURL(entity) {
|
|||
|
||||
} else{
|
||||
|
||||
result = subOrganizationTemporalGraphURL+ "&vis_mode=" + entity.visMode + "&" +
|
||||
result = subOrganizationTemporalGraphURL + "&" +
|
||||
"uri=" + entity.entityURI ;
|
||||
}
|
||||
|
||||
|
@ -857,16 +857,16 @@ function setEntityLevel(){
|
|||
function getEntityVisMode(jsonData){
|
||||
|
||||
$.each(jsonData, function(index, val) {
|
||||
if (val.visMode == "SCHOOL" || val.visMode == "UNIVERSITY" || val.visMode == "DEPARTMENT"){
|
||||
entityLevel = "Organizations";
|
||||
} else {
|
||||
if (val.visMode == "PERSON"){
|
||||
entityLevel = "People";
|
||||
} else {
|
||||
entityLevel = "Organizations";
|
||||
}
|
||||
return;
|
||||
});
|
||||
|
||||
/* To provide graceful degradation set entity level to a default error message.*/
|
||||
entityElevel = "ENTITY LEVEL UNDEFINED ERROR";
|
||||
entitylevel = "ENTITY LEVEL UNDEFINED ERROR";
|
||||
}
|
||||
|
||||
function toCamelCase(string){
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#assign organizationURI ="${organizationURI?url}">
|
||||
<#assign organizationVivoProfileURL = "${urls.base}/individual?uri=${organizationURI}">
|
||||
|
||||
<#-- variables passed from server-side code -->
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
|
||||
var contextPath = "${urls.base}";
|
||||
|
||||
</script>
|
||||
|
||||
<div id="body">
|
||||
<p>This Organization has neither Sub-Organizations nor People. Please visit this Organization's <a href="${organizationVivoProfileURL}">profile page.</a></p>
|
||||
</div>
|
|
@ -16,7 +16,7 @@
|
|||
<#assign temporalGraphSmallIcon = '${urls.images}/visualization/temporal_vis_small_icon.jpg'>
|
||||
|
||||
|
||||
<#assign TemporalGraphDownloadFile = '${urls.base}${dataVisualizationURLRoot}?vis=entity_comparison&uri=${organizationURI}&labelField=label&vis_mode=UNIVERSITY'>
|
||||
<#assign TemporalGraphDownloadFile = '${urls.base}${dataVisualizationURLRoot}?vis=entity_comparison&uri=${organizationURI}&labelField=label'>
|
||||
|
||||
|
||||
<#-- Javascript files -->
|
||||
|
|
|
@ -183,11 +183,14 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
|
|||
entity.addPublications(biboDocument);
|
||||
}
|
||||
|
||||
if(subentityURLToVO.size() == 0){
|
||||
if(subentityURLToVO.size() == 0 && personURLToVO.size() != 0){
|
||||
for(SubEntity person : personURLToVO.values()){
|
||||
entity.addSubEntity(person);
|
||||
}
|
||||
} else if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0){
|
||||
entity = new Entity(this.entityURI, "no-label");
|
||||
}
|
||||
|
||||
//TODO: return non-null value
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -34,10 +34,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Visual
|
|||
public class EntityPublicationCountRequestHandler implements
|
||||
VisualizationRequestHandler {
|
||||
|
||||
public static String ENTITY_VIS_MODE;
|
||||
public static String SUB_ENTITY_VIS_MODE;
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseValues generateStandardVisualization(
|
||||
VitroRequest vitroRequest, Log log, DataSource dataSource)
|
||||
|
@ -46,23 +42,26 @@ public class EntityPublicationCountRequestHandler implements
|
|||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
ENTITY_VIS_MODE = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
||||
|
||||
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
|
||||
Entity entity = queryManager.getQueryResult();
|
||||
|
||||
setVisModes();
|
||||
if(entity.getEntityLabel().equals("no-label")){
|
||||
|
||||
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
return prepareStandaloneErrorResponse(vitroRequest,entityURI);
|
||||
|
||||
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
|
||||
.getQueryResult();
|
||||
} else{
|
||||
|
||||
return prepareStandaloneResponse(vitroRequest, entity, entityURI,
|
||||
subOrganizationTypesResult);
|
||||
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
|
||||
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
|
||||
.getQueryResult();
|
||||
|
||||
return prepareStandaloneResponse(vitroRequest, entity, entityURI,
|
||||
subOrganizationTypesResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -75,14 +74,11 @@ public class EntityPublicationCountRequestHandler implements
|
|||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
ENTITY_VIS_MODE = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
||||
|
||||
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
|
||||
Entity entity = queryManager.getQueryResult();
|
||||
setVisModes();
|
||||
|
||||
|
||||
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
|
@ -148,7 +144,7 @@ public class EntityPublicationCountRequestHandler implements
|
|||
String standaloneTemplate = "entityComparisonStandaloneActivator.ftl";
|
||||
|
||||
String jsonContent = "";
|
||||
jsonContent = writePublicationsOverTimeJSON(entity.getSubEntities(), subOrganizationTypesResult);
|
||||
jsonContent = writePublicationsOverTimeJSON(vreq, entity.getSubEntities(), subOrganizationTypesResult);
|
||||
|
||||
|
||||
|
||||
|
@ -164,34 +160,29 @@ public class EntityPublicationCountRequestHandler implements
|
|||
}
|
||||
|
||||
|
||||
private void setVisModes() {
|
||||
private ResponseValues prepareStandaloneErrorResponse(
|
||||
VitroRequest vitroRequest, String entityURI) {
|
||||
|
||||
if (ENTITY_VIS_MODE.equalsIgnoreCase("DEPARTMENT")) {
|
||||
SUB_ENTITY_VIS_MODE = "PERSON";
|
||||
}else if (ENTITY_VIS_MODE.equalsIgnoreCase("SCHOOL")) {
|
||||
SUB_ENTITY_VIS_MODE = "DEPARTMENT";
|
||||
}else {
|
||||
SUB_ENTITY_VIS_MODE = "SCHOOL";
|
||||
}
|
||||
}
|
||||
Portal portal = vitroRequest.getPortal();
|
||||
String standaloneTemplate = "entityComparisonErrorActivator.ftl";
|
||||
|
||||
private void setEntityVisMode(JsonObject entityJson) {
|
||||
if(entityJson.getOrganizationType().contains("Department")){
|
||||
entityJson.setVisMode("DEPARTMENT");
|
||||
}else if(entityJson.getOrganizationType().contains("School")){
|
||||
entityJson.setVisMode("SCHOOL");
|
||||
}else{
|
||||
entityJson.setVisMode(SUB_ENTITY_VIS_MODE);
|
||||
}
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
body.put("portalBean", portal);
|
||||
body.put("title", "Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function to generate a json file for year <-> publication count mapping
|
||||
* @param vreq
|
||||
* @param subentities
|
||||
* @param subOrganizationTypesResult
|
||||
*/
|
||||
private String writePublicationsOverTimeJSON(Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
private String writePublicationsOverTimeJSON(VitroRequest vreq, Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
|
||||
Gson json = new Gson();
|
||||
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
|
||||
|
@ -220,7 +211,15 @@ public class EntityPublicationCountRequestHandler implements
|
|||
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel()));
|
||||
|
||||
entityJson.setEntityURI(subentity.getIndividualURI());
|
||||
setEntityVisMode(entityJson);
|
||||
|
||||
boolean isPerson = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
|
||||
|
||||
if(isPerson){
|
||||
entityJson.setVisMode("PERSON");
|
||||
} else{
|
||||
entityJson.setVisMode("ORGANIZATION");
|
||||
}
|
||||
// setEntityVisMode(entityJson);
|
||||
subEntitiesJson.add(entityJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
|
|||
+ "}";
|
||||
|
||||
|
||||
//System.out.println("\n\nEntity SubOrganizationTypes query is: "+ sparqlQuery);
|
||||
// System.out.println("\n\nEntity SubOrganizationTypes query is: "+ sparqlQuery);
|
||||
log.debug("\nThe sparql query is :\n" + sparqlQuery);
|
||||
|
||||
return sparqlQuery;
|
||||
|
@ -146,8 +146,8 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
|
|||
}
|
||||
}
|
||||
|
||||
//System.out.println("\n\nSub Organization Label Types Size --> " + subOrganizationLabelToTypes.size());
|
||||
//System.out.println("\n\nPeople Label Types Size --> " + personLabelToTypes.size());
|
||||
// System.out.println("\n\nSub Organization Label Types Size --> " + subOrganizationLabelToTypes.size());
|
||||
// System.out.println("\n\nPeople Label Types Size --> " + personLabelToTypes.size());
|
||||
|
||||
return (subOrganizationLabelToTypes.size() != 0 )? subOrganizationLabelToTypes : personLabelToTypes ;
|
||||
}
|
||||
|
|
|
@ -173,10 +173,12 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
|
|||
entity.addGrants(grant);
|
||||
}
|
||||
|
||||
if(subentityURLToVO.size() == 0){
|
||||
if(subentityURLToVO.size() == 0 && personURLToVO.size() != 0){
|
||||
for(SubEntity person : personURLToVO.values()){
|
||||
entity.addSubEntity(person);
|
||||
}
|
||||
} else if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0){
|
||||
entity = new Entity(this.entityURI, "no-label");
|
||||
}
|
||||
|
||||
return entity;
|
||||
|
|
|
@ -36,10 +36,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Visual
|
|||
public class EntityGrantCountRequestHandler implements
|
||||
VisualizationRequestHandler {
|
||||
|
||||
public static String ENTITY_VIS_MODE;
|
||||
public static String SUB_ENTITY_VIS_MODE;
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseValues generateStandardVisualization(
|
||||
VitroRequest vitroRequest, Log log, DataSource dataSource)
|
||||
|
@ -48,32 +44,26 @@ public class EntityGrantCountRequestHandler implements
|
|||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
|
||||
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
|
||||
Entity entity = queryManager.getQueryResult();
|
||||
|
||||
ENTITY_VIS_MODE = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
||||
setVisModes();
|
||||
if(entity.getEntityLabel().equals("no-label")){
|
||||
|
||||
// for(SubEntity se : entity.getSubEntities()){
|
||||
// System.out.println("se key -->" + se.getIndividualLabel());
|
||||
// }
|
||||
return prepareStandaloneErrorResponse(vitroRequest,entityURI);
|
||||
|
||||
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
} else{
|
||||
|
||||
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult();
|
||||
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
|
||||
// for(Map.Entry soTR : subOrganizationTypesResult.entrySet()){
|
||||
// System.out.println("soTR key -->" + soTR.getKey());
|
||||
// }
|
||||
//
|
||||
// System.out.println();
|
||||
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
|
||||
.getQueryResult();
|
||||
|
||||
return prepareStandaloneResponse(vitroRequest,
|
||||
entity,entityURI, subOrganizationTypesResult);
|
||||
return prepareStandaloneResponse(vitroRequest, entity, entityURI,
|
||||
subOrganizationTypesResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,10 +75,6 @@ public class EntityGrantCountRequestHandler implements
|
|||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
ENTITY_VIS_MODE = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
||||
setVisModes();
|
||||
|
||||
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
|
||||
entityURI, dataSource, log);
|
||||
|
||||
|
@ -158,7 +144,7 @@ public class EntityGrantCountRequestHandler implements
|
|||
String standaloneTemplate = "entityComparisonStandaloneActivator.ftl";
|
||||
|
||||
String jsonContent = "";
|
||||
jsonContent = writeGrantsOverTimeJSON(entity.getSubEntities(), subOrganizationTypesResult);
|
||||
jsonContent = writeGrantsOverTimeJSON(vreq, entity.getSubEntities(), subOrganizationTypesResult);
|
||||
|
||||
|
||||
|
||||
|
@ -173,24 +159,29 @@ public class EntityGrantCountRequestHandler implements
|
|||
|
||||
}
|
||||
|
||||
private void setVisModes() {
|
||||
private ResponseValues prepareStandaloneErrorResponse(
|
||||
VitroRequest vitroRequest, String entityURI) {
|
||||
|
||||
Portal portal = vitroRequest.getPortal();
|
||||
String standaloneTemplate = "entityComparisonErrorActivator.ftl";
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
body.put("portalBean", portal);
|
||||
body.put("title", "Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
||||
if (ENTITY_VIS_MODE.equalsIgnoreCase("DEPARTMENT")) {
|
||||
SUB_ENTITY_VIS_MODE = "PERSON";
|
||||
}else if (ENTITY_VIS_MODE.equalsIgnoreCase("SCHOOL")) {
|
||||
SUB_ENTITY_VIS_MODE = "DEPARTMENT";
|
||||
}else {
|
||||
SUB_ENTITY_VIS_MODE = "SCHOOL";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function to generate a json file for year <-> grant count mapping
|
||||
* @param vreq
|
||||
* @param subentities
|
||||
* @param subOrganizationTypesResult
|
||||
*/
|
||||
private String writeGrantsOverTimeJSON(Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
private String writeGrantsOverTimeJSON(VitroRequest vreq, Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
|
||||
Gson json = new Gson();
|
||||
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
|
||||
|
@ -219,7 +210,16 @@ public class EntityGrantCountRequestHandler implements
|
|||
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel()));
|
||||
|
||||
entityJson.setEntityURI(subentity.getIndividualURI());
|
||||
setEntityVisMode(entityJson);
|
||||
|
||||
boolean isPerson = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
|
||||
|
||||
if(isPerson){
|
||||
entityJson.setVisMode("PERSON");
|
||||
} else{
|
||||
entityJson.setVisMode("ORGANIZATION");
|
||||
}
|
||||
|
||||
// setEntityVisMode(entityJson);
|
||||
subEntitiesJson.add(entityJson);
|
||||
}
|
||||
|
||||
|
@ -228,17 +228,6 @@ public class EntityGrantCountRequestHandler implements
|
|||
|
||||
}
|
||||
|
||||
private void setEntityVisMode(JsonObject entityJson) {
|
||||
|
||||
if(entityJson.getOrganizationType().contains("Department")){
|
||||
entityJson.setVisMode("DEPARTMENT");
|
||||
}else if(entityJson.getOrganizationType().contains("School")){
|
||||
entityJson.setVisMode("SCHOOL");
|
||||
}else{
|
||||
entityJson.setVisMode(SUB_ENTITY_VIS_MODE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getEntityGrantsPerYearCSVContent(Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue