1. Partial fix for NIHVIVO-2130. Now the downloadable csv file properly prints out all the authors, with same name. The right hand side bar still prints wrong values in case of authors with duplicate names.
2. Solution for 2 stage loading for temporal graph where now when the intial call is made to it, it returns with the markup & js lib includes & then makes an ajax call to get the data file in json format which is the used to render the linegraph & the table.
This commit is contained in:
parent
f1bcbd69ca
commit
ad3497d0bc
17 changed files with 1277 additions and 562 deletions
|
@ -90,7 +90,6 @@ public class VisualizationFrameworkConstants {
|
|||
public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL";
|
||||
public static final String DEPARTMENT_COMPARISON_VIS_MODE = "DEPARTMENT";
|
||||
public static final String HIGHEST_LEVEL_ORGANIZATION_VIS_MODE = "HIGHEST_LEVEL_ORGANIZATION";
|
||||
|
||||
|
||||
/*
|
||||
* These values represent possible visualizations provided as values to the "vis" url key.
|
||||
|
@ -105,5 +104,9 @@ public class VisualizationFrameworkConstants {
|
|||
public static final String ENTITY_COMPARISON_VIS = "entity_comparison";
|
||||
public static final String CO_PI_VIS = "coprincipalinvestigator";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* These values represent possible vis-modes for temporal graph vis
|
||||
* */
|
||||
public static final String TEMPORAL_GRAPH_JSON_DATA_VIS_MODE = "json";
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.DataVisualizationController;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.CoAuthorshipData;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Node;
|
||||
|
@ -133,28 +133,40 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
|
||||
|
||||
private String getCoauthorsListCSVContent(Map<String, Integer> coAuthorsToCount) {
|
||||
private String getCoauthorsListCSVContent(CoAuthorshipData coAuthorshipData) {
|
||||
|
||||
StringBuilder csvFileContent = new StringBuilder();
|
||||
|
||||
csvFileContent.append("Year, Count\n");
|
||||
csvFileContent.append("Co-author, Count\n");
|
||||
|
||||
for (Entry<String, Integer> currentEntry : coAuthorsToCount.entrySet()) {
|
||||
csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
|
||||
//for (Entry<String, Integer> currentEntry : coAuthorsToCount.entrySet()) {
|
||||
for (Node currNode : coAuthorshipData.getNodes()) {
|
||||
|
||||
/*
|
||||
* We have already printed the Ego Node info.
|
||||
* */
|
||||
if (currNode != coAuthorshipData.getEgoNode()) {
|
||||
|
||||
|
||||
csvFileContent.append(StringEscapeUtils.escapeCsv(currNode.getNodeName()));
|
||||
csvFileContent.append(",");
|
||||
csvFileContent.append(currentEntry.getValue());
|
||||
csvFileContent.append(currNode.getNumOfAuthoredWorks());
|
||||
csvFileContent.append("\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return csvFileContent.toString();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String getCoauthorsPerYearCSVContent(Map<String, Set<Node>> yearToCoauthors) {
|
||||
|
||||
StringBuilder csvFileContent = new StringBuilder();
|
||||
|
||||
csvFileContent.append("Year, Count, Co-Author(s)\n");
|
||||
csvFileContent.append("Year, Count, Co-author(s)\n");
|
||||
|
||||
for (Entry<String, Set<Node>> currentEntry : yearToCoauthors.entrySet()) {
|
||||
csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
|
||||
|
@ -225,15 +237,11 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
|||
private Map<String, String> prepareCoauthorsListDataResponse(CoAuthorshipData coAuthorshipData) {
|
||||
|
||||
String outputFileName = "";
|
||||
Map<String, Integer> coAuthorsToCount = new TreeMap<String, Integer>();
|
||||
|
||||
|
||||
if (coAuthorshipData.getNodes() != null && coAuthorshipData.getNodes().size() > 0) {
|
||||
|
||||
outputFileName = UtilityFunctions.slugify(coAuthorshipData.getEgoNode().getNodeName())
|
||||
+ "_co-authors" + ".csv";
|
||||
|
||||
coAuthorsToCount = getCoAuthorsList(coAuthorshipData);
|
||||
|
||||
} else {
|
||||
outputFileName = "no_co-authors" + ".csv";
|
||||
}
|
||||
|
@ -244,29 +252,11 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
|||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||
getCoauthorsListCSVContent(coAuthorsToCount));
|
||||
getCoauthorsListCSVContent(coAuthorshipData));
|
||||
|
||||
return fileData;
|
||||
}
|
||||
|
||||
private Map<String, Integer> getCoAuthorsList(CoAuthorshipData coAuthorsipVO) {
|
||||
|
||||
Map<String, Integer> coAuthorsToCount = new TreeMap<String, Integer>();
|
||||
|
||||
for (Node currNode : coAuthorsipVO.getNodes()) {
|
||||
|
||||
/*
|
||||
* We have already printed the Ego Node info.
|
||||
* */
|
||||
if (currNode != coAuthorsipVO.getEgoNode()) {
|
||||
|
||||
coAuthorsToCount.put(currNode.getNodeName(), currNode.getNumOfAuthoredWorks());
|
||||
|
||||
}
|
||||
}
|
||||
return coAuthorsToCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a response when graphml formatted co-authorship network is requested, typically by
|
||||
* the flash vis.
|
||||
|
|
|
@ -153,21 +153,30 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
|
|||
}
|
||||
|
||||
|
||||
private String getCoPIsListCSVContent(Map<String, Integer> coPIsToCount) {
|
||||
private String getCoPIsListCSVContent(CoPIData coPIData) {
|
||||
|
||||
StringBuilder csvFileContent = new StringBuilder();
|
||||
|
||||
csvFileContent.append("Year, Count\n");
|
||||
csvFileContent.append("Co-investigator, Count\n");
|
||||
|
||||
for (Entry<String, Integer> currentEntry : coPIsToCount.entrySet()) {
|
||||
csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
|
||||
// for (Entry<String, Integer> currentEntry : coPIData.entrySet()) {
|
||||
for (CoPINode currNode : coPIData.getNodes()) {
|
||||
|
||||
/*
|
||||
* We have already printed the Ego Node info.
|
||||
* */
|
||||
if (currNode != coPIData.getEgoNode()) {
|
||||
|
||||
csvFileContent.append(StringEscapeUtils.escapeCsv(currNode.getNodeName()));
|
||||
csvFileContent.append(",");
|
||||
csvFileContent.append(currentEntry.getValue());
|
||||
csvFileContent.append(currNode.getNumberOfInvestigatedGrants());
|
||||
csvFileContent.append("\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return csvFileContent.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -175,7 +184,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
|
|||
|
||||
StringBuilder csvFileContent = new StringBuilder();
|
||||
|
||||
csvFileContent.append("Year, Count, Co-PI(s)\n");
|
||||
csvFileContent.append("Year, Count, Co-investigator(s)\n");
|
||||
|
||||
for (Map.Entry<String, Set<CoPINode>> currentEntry : yearToCoPI.entrySet()) {
|
||||
|
||||
|
@ -247,15 +256,12 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
|
|||
private Map<String, String> prepareCoPIsListDataResponse(CoPIData coPIData) {
|
||||
|
||||
String outputFileName = "";
|
||||
Map<String, Integer> coPIsToCount = new TreeMap<String, Integer>();
|
||||
|
||||
if (coPIData.getNodes() != null && coPIData.getNodes().size() > 0) {
|
||||
|
||||
outputFileName = UtilityFunctions.slugify(coPIData.getEgoNode().getNodeName())
|
||||
+ "_co-investigators" + ".csv";
|
||||
|
||||
coPIsToCount = getCoPIsList(coPIData);
|
||||
|
||||
} else {
|
||||
outputFileName = "no_co-investigators" + ".csv";
|
||||
}
|
||||
|
@ -266,7 +272,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
|
|||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||
getCoPIsListCSVContent(coPIsToCount));
|
||||
getCoPIsListCSVContent(coPIData));
|
||||
|
||||
return fileData;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,21 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import com.hp.hpl.jena.iri.IRI;
|
||||
import com.hp.hpl.jena.iri.IRIFactory;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.GenericQueryMap;
|
||||
|
@ -107,4 +114,47 @@ public class EntityComparisonUtilityFunctions {
|
|||
return subOrganizationTypesResult;
|
||||
}
|
||||
|
||||
public static String getEntityLabelFromDAO(VitroRequest vitroRequest,
|
||||
String entityURI) {
|
||||
|
||||
IndividualDao iDao = vitroRequest.getWebappDaoFactory().getIndividualDao();
|
||||
Individual ind = iDao.getIndividualByURI(entityURI);
|
||||
|
||||
String organizationLabel = "Unknown Organization";
|
||||
|
||||
if (ind != null) {
|
||||
organizationLabel = ind.getName();
|
||||
}
|
||||
return organizationLabel;
|
||||
}
|
||||
|
||||
public static String getStaffProvidedOrComputedHighestLevelOrganization(Log log,
|
||||
Dataset Dataset)
|
||||
throws MalformedQueryParametersException {
|
||||
|
||||
String finalHighestLevelOrganizationURI = "";
|
||||
|
||||
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getProperty("visualization.topLevelOrg");
|
||||
|
||||
/*
|
||||
* First checking if the staff has provided highest level organization in deploy.properties
|
||||
* if so use to temporal graph vis.
|
||||
*/
|
||||
if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) {
|
||||
|
||||
/*
|
||||
* To test for the validity of the URI submitted.
|
||||
*/
|
||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
|
||||
|
||||
if (iri.hasViolation(false)) {
|
||||
finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log, Dataset);
|
||||
} else {
|
||||
finalHighestLevelOrganizationURI = staffProvidedHighestLevelOrganization;
|
||||
}
|
||||
}
|
||||
return finalHighestLevelOrganizationURI;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,10 +67,7 @@ public class EntityPublicationCountConstructQueryRunner {
|
|||
+ "?Person rdfs:label ?PersonLabel . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "?Document rdfs:label ?DocumentLabel . "
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate . "
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
+ "?Document rdfs:label ?DocumentLabel "
|
||||
+"}"
|
||||
+ "WHERE { "
|
||||
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
|
||||
|
@ -80,18 +77,8 @@ public class EntityPublicationCountConstructQueryRunner {
|
|||
+ "?Person core:authorInAuthorship ?Resource . "
|
||||
+ "?Person rdfs:label ?PersonLabel . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
// + "?Document rdf:type bibo:Document . "
|
||||
+ "?Document rdfs:label ?DocumentLabel "
|
||||
|
||||
+ "{"
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate "
|
||||
+ "}"
|
||||
+ "UNION "
|
||||
+ "{"
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
+ "}"
|
||||
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "?Document rdfs:label ?DocumentLabel "
|
||||
+ "}" ;
|
||||
|
||||
|
||||
|
@ -110,10 +97,7 @@ public class EntityPublicationCountConstructQueryRunner {
|
|||
+ "?Person rdfs:label ?PersonLabel . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "?Document rdfs:label ?DocumentLabel . "
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate . "
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property ."
|
||||
+ "?Document rdfs:label ?DocumentLabel "
|
||||
+"}"
|
||||
+ "WHERE { "
|
||||
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
|
||||
|
@ -121,18 +105,8 @@ public class EntityPublicationCountConstructQueryRunner {
|
|||
+ "?Person core:authorInAuthorship ?Resource . "
|
||||
+ "?Person rdfs:label ?PersonLabel . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
// + "?Document rdf:type bibo:Document . "
|
||||
+ "?Document rdfs:label ?DocumentLabel "
|
||||
|
||||
+ "{"
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate "
|
||||
+ "}"
|
||||
+ "UNION "
|
||||
+ "{"
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
+ "}"
|
||||
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "?Document rdfs:label ?DocumentLabel "
|
||||
+ "}" ;
|
||||
|
||||
|
||||
|
@ -140,90 +114,93 @@ public class EntityPublicationCountConstructQueryRunner {
|
|||
|
||||
}
|
||||
|
||||
// private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
|
||||
//
|
||||
// String sparqlQuery =
|
||||
//
|
||||
// "CONSTRUCT { "
|
||||
// + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
|
||||
// + "?subOrganization core:organizationForPosition ?Position . "
|
||||
// + "?Position core:positionForPerson ?Person . "
|
||||
// + "?Person core:authorInAuthorship ?Resource . "
|
||||
// + "?Resource core:linkedInformationResource ?Document . "
|
||||
// + "?Document rdf:type bibo:Document . "
|
||||
// + "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
// + "?dateTimeValue core:dateTime ?publicationDate . "
|
||||
// + "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
// +"}"
|
||||
// + "WHERE { "
|
||||
// + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
|
||||
// + "?subOrganization core:organizationForPosition ?Position . "
|
||||
// + "?Position core:positionForPerson ?Person . "
|
||||
// + "?Person core:authorInAuthorship ?Resource . "
|
||||
// + "?Resource core:linkedInformationResource ?Document . "
|
||||
// + "?Document rdf:type bibo:Document . "
|
||||
// + "{"
|
||||
// + "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
// + "?dateTimeValue core:dateTime ?publicationDate "
|
||||
// + "}"
|
||||
// + "UNION "
|
||||
// + "{"
|
||||
// + "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
// + "}"
|
||||
// + "}" ;
|
||||
//
|
||||
//
|
||||
// return sparqlQuery;
|
||||
//
|
||||
// }
|
||||
private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
|
||||
|
||||
String sparqlQuery =
|
||||
|
||||
"CONSTRUCT { "
|
||||
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
|
||||
+ "?subOrganization core:organizationForPosition ?Position . "
|
||||
+ "?Position core:positionForPerson ?Person . "
|
||||
+ "?Person core:authorInAuthorship ?Resource . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate . "
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
+"}"
|
||||
+ "WHERE { "
|
||||
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
|
||||
+ "?subOrganization core:organizationForPosition ?Position . "
|
||||
+ "?Position core:positionForPerson ?Person . "
|
||||
+ "?Person core:authorInAuthorship ?Resource . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "{"
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate "
|
||||
+ "}"
|
||||
+ "UNION "
|
||||
+ "{"
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
+ "}"
|
||||
+ "}" ;
|
||||
|
||||
|
||||
return sparqlQuery;
|
||||
|
||||
// private String generateConstructQueryForDocumentDateTimeValue(String queryURI){
|
||||
//
|
||||
// String sparqlQuery =
|
||||
//
|
||||
// "CONSTRUCT { "
|
||||
// + "<"+queryURI+ "> core:organizationForPosition ?Position . "
|
||||
// + "?Position core:positionForPerson ?Person . "
|
||||
// + "?Person core:authorInAuthorship ?Resource . "
|
||||
// + "?Resource core:linkedInformationResource ?Document . "
|
||||
// + "?Document rdf:type bibo:Document . "
|
||||
// + "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
// + "?dateTimeValue core:dateTime ?publicationDate . "
|
||||
// + "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
// +"}"
|
||||
// + "WHERE { "
|
||||
// + "<"+queryURI+ "> core:organizationForPosition ?Position . "
|
||||
// + "?Position core:positionForPerson ?Person . "
|
||||
// + "?Person core:authorInAuthorship ?Resource . "
|
||||
// + "?Resource core:linkedInformationResource ?Document . "
|
||||
// + "?Document rdf:type bibo:Document . "
|
||||
// + "{"
|
||||
// + "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
// + "?dateTimeValue core:dateTime ?publicationDate "
|
||||
// + "}"
|
||||
// + "UNION "
|
||||
// + "{"
|
||||
// + "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
// + "}"
|
||||
// + "}" ;
|
||||
//
|
||||
//
|
||||
// return sparqlQuery;
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
private String generateConstructQueryForDocumentDateTimeValue(String queryURI){
|
||||
|
||||
String sparqlQuery =
|
||||
|
||||
"CONSTRUCT { "
|
||||
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
|
||||
+ "?Position core:positionForPerson ?Person . "
|
||||
+ "?Person core:authorInAuthorship ?Resource . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate . "
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
+"}"
|
||||
+ "WHERE { "
|
||||
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
|
||||
+ "?Position core:positionForPerson ?Person . "
|
||||
+ "?Person core:authorInAuthorship ?Resource . "
|
||||
+ "?Resource core:linkedInformationResource ?Document . "
|
||||
+ "?Document rdf:type bibo:Document . "
|
||||
+ "{"
|
||||
+ "?Document core:dateTimeValue ?dateTimeValue . "
|
||||
+ "?dateTimeValue core:dateTime ?publicationDate "
|
||||
+ "}"
|
||||
+ "UNION "
|
||||
+ "{"
|
||||
+ "?Document core:year ?publicationYearUsing_1_1_property "
|
||||
+ "}"
|
||||
+ "}" ;
|
||||
|
||||
|
||||
return sparqlQuery;
|
||||
|
||||
}
|
||||
|
||||
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
|
||||
|
||||
Model constructedModel = ModelFactory.createDefaultModel();
|
||||
|
||||
before = System.currentTimeMillis();
|
||||
|
||||
for (String queryString : constructQueries) {
|
||||
before = System.currentTimeMillis();
|
||||
|
||||
log.debug("CONSTRUCT query string : " + queryString);
|
||||
|
||||
Query query = null;
|
||||
|
||||
try{
|
||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
|
||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
|
||||
//log.info("query: "+ queryString);
|
||||
}catch(Throwable th){
|
||||
log.error("Could not create CONSTRUCT SPARQL query for query " +
|
||||
"string. " + th.getMessage());
|
||||
|
@ -232,16 +209,16 @@ public class EntityPublicationCountConstructQueryRunner {
|
|||
|
||||
QueryExecution qe = QueryExecutionFactory.create(
|
||||
query, Dataset);
|
||||
|
||||
try {
|
||||
qe.execConstruct(constructedModel);
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
|
||||
after = System.currentTimeMillis();
|
||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) );
|
||||
|
||||
}
|
||||
|
||||
after = System.currentTimeMillis();
|
||||
log.info("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) );
|
||||
// constructedModel.write(System.out);
|
||||
return constructedModel;
|
||||
}
|
||||
|
@ -281,8 +258,8 @@ public class EntityPublicationCountConstructQueryRunner {
|
|||
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI));
|
||||
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI));
|
||||
constructQueries.add(generateConstructQueryForPersons(this.egoURI));
|
||||
// constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
|
||||
// constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
|
||||
constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
|
||||
constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,20 +17,16 @@ import org.apache.commons.logging.LogFactory;
|
|||
import com.google.gson.Gson;
|
||||
import com.hp.hpl.jena.iri.IRI;
|
||||
import com.hp.hpl.jena.iri.IRIFactory;
|
||||
import com.hp.hpl.jena.iri.Violation;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.DataVisualizationController;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||
|
@ -40,6 +36,10 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryR
|
|||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||
|
||||
/**
|
||||
* @author cdtank
|
||||
*
|
||||
*/
|
||||
public class EntityPublicationCountRequestHandler implements
|
||||
VisualizationRequestHandler {
|
||||
|
||||
|
@ -53,49 +53,15 @@ public class EntityPublicationCountRequestHandler implements
|
|||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
if (StringUtils.isNotBlank(entityURI)){
|
||||
|
||||
return getSubjectEntityAndGenerateResponse(vitroRequest, log,
|
||||
Dataset, entityURI);
|
||||
} else {
|
||||
if (StringUtils.isBlank(entityURI)){
|
||||
|
||||
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getProperty("visualization.topLevelOrg");
|
||||
|
||||
/*
|
||||
* First checking if the staff has provided highest level organization in deploy.properties
|
||||
* if so use to temporal graph vis.
|
||||
*/
|
||||
if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) {
|
||||
|
||||
/*
|
||||
* To test for the validity of the URI submitted.
|
||||
*/
|
||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
|
||||
|
||||
if (iri.hasViolation(false)) {
|
||||
|
||||
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
||||
log.error("Highest Level Organization URI provided is invalid " + errorMsg);
|
||||
|
||||
} else {
|
||||
|
||||
return getSubjectEntityAndGenerateResponse(vitroRequest,
|
||||
log, Dataset,
|
||||
staffProvidedHighestLevelOrganization);
|
||||
}
|
||||
}
|
||||
|
||||
String highestLevelOrgURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log,
|
||||
Dataset);
|
||||
|
||||
return getSubjectEntityAndGenerateResponse(vitroRequest, log,
|
||||
Dataset, highestLevelOrgURI);
|
||||
entityURI = EntityComparisonUtilityFunctions
|
||||
.getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset);
|
||||
}
|
||||
|
||||
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
||||
}
|
||||
|
||||
private ResponseValues getSubjectEntityAndGenerateResponse(
|
||||
|
||||
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
|
||||
VitroRequest vitroRequest, Log log, Dataset Dataset,
|
||||
String subjectEntityURI)
|
||||
throws MalformedQueryParametersException {
|
||||
|
@ -105,25 +71,33 @@ public class EntityPublicationCountRequestHandler implements
|
|||
|
||||
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
||||
subjectEntityURI, constructedModel, log);
|
||||
|
||||
|
||||
Entity entity = queryManager.getQueryResult();
|
||||
|
||||
|
||||
if (entity.getEntityLabel().equals("no-label")) {
|
||||
|
||||
return prepareStandaloneErrorResponse(vitroRequest, subjectEntityURI);
|
||||
return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
|
||||
|
||||
} else {
|
||||
|
||||
return getSubEntityTypesAndRenderStandaloneResponse(
|
||||
return getSubEntityTypesAndComputeDataResponse(
|
||||
vitroRequest, log, Dataset,
|
||||
subjectEntityURI, entity);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> prepareStandaloneDataErrorResponse(
|
||||
VitroRequest vitroRequest, String subjectEntityURI) {
|
||||
|
||||
Map<String, String> fileData = new HashMap<String, String>();
|
||||
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Publications for this Organization found in VIVO.\"}");
|
||||
return fileData;
|
||||
}
|
||||
|
||||
private ResponseValues getSubEntityTypesAndRenderStandaloneResponse(
|
||||
private Map<String, String> getSubEntityTypesAndComputeDataResponse(
|
||||
VitroRequest vitroRequest, Log log, Dataset Dataset,
|
||||
String subjectEntityURI, Entity entity)
|
||||
throws MalformedQueryParametersException {
|
||||
|
@ -131,10 +105,9 @@ public class EntityPublicationCountRequestHandler implements
|
|||
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
|
||||
log, Dataset, subjectEntityURI);
|
||||
|
||||
return prepareStandaloneResponse(vitroRequest, entity, subjectEntityURI,
|
||||
return prepareStandaloneDataResponse(vitroRequest, entity, entity.getSubEntities(),
|
||||
subOrganizationTypesResult);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> generateDataVisualization(
|
||||
|
@ -143,20 +116,52 @@ public class EntityPublicationCountRequestHandler implements
|
|||
|
||||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
/*
|
||||
* This will provide the data in json format mainly used for standalone tmeporal vis.
|
||||
* */
|
||||
if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
|
||||
.equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
|
||||
|
||||
if (StringUtils.isNotBlank(entityURI)){
|
||||
|
||||
EntityPublicationCountConstructQueryRunner constructQueryRunner = new EntityPublicationCountConstructQueryRunner(entityURI, Dataset, log);
|
||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||
return getSubjectEntityAndGenerateDataResponse(
|
||||
vitroRequest,
|
||||
log,
|
||||
Dataset,
|
||||
entityURI);
|
||||
} else {
|
||||
|
||||
return getSubjectEntityAndGenerateDataResponse(
|
||||
vitroRequest,
|
||||
log,
|
||||
Dataset,
|
||||
EntityComparisonUtilityFunctions
|
||||
.getStaffProvidedOrComputedHighestLevelOrganization(
|
||||
log,
|
||||
Dataset));
|
||||
}
|
||||
|
||||
} else {
|
||||
/*
|
||||
* This provides csv download files for the content in the tables.
|
||||
* */
|
||||
|
||||
EntityPublicationCountConstructQueryRunner constructQueryRunner = new EntityPublicationCountConstructQueryRunner(entityURI, Dataset, log);
|
||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||
|
||||
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
||||
entityURI, constructedModel, log);
|
||||
|
||||
Entity entity = queryManager.getQueryResult();
|
||||
|
||||
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
|
||||
log, Dataset, entityURI);
|
||||
|
||||
return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);
|
||||
|
||||
}
|
||||
|
||||
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
||||
entityURI, constructedModel, log);
|
||||
|
||||
Entity entity = queryManager.getQueryResult();
|
||||
|
||||
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
|
||||
log, Dataset, entityURI);
|
||||
|
||||
return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,41 +204,49 @@ public class EntityPublicationCountRequestHandler implements
|
|||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||
getEntityPublicationsPerYearCSVContent(subentities, subOrganizationTypesResult));
|
||||
return fileData;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vreq
|
||||
* @param valueObjectContainer
|
||||
* @return
|
||||
*/
|
||||
private TemplateResponseValues prepareStandaloneResponse(VitroRequest vreq,
|
||||
Entity entity, String entityURI, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
private Map<String, String> prepareStandaloneDataResponse(
|
||||
VitroRequest vitroRequest,
|
||||
Entity entity,
|
||||
Set<SubEntity> subentities,
|
||||
Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
|
||||
Map<String, String> fileData = new HashMap<String, String>();
|
||||
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||
writePublicationsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult));
|
||||
return fileData;
|
||||
}
|
||||
|
||||
private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
|
||||
String entityURI) {
|
||||
|
||||
Portal portal = vreq.getPortal();
|
||||
String standaloneTemplate = "entityComparisonOnPublicationsStandalone.ftl";
|
||||
|
||||
String jsonContent = "";
|
||||
jsonContent = writePublicationsOverTimeJSON(vreq, entity.getSubEntities(), subOrganizationTypesResult);
|
||||
|
||||
String title = "";
|
||||
|
||||
if (StringUtils.isNotBlank(entity.getEntityLabel())) {
|
||||
title = entity.getEntityLabel() + " - ";
|
||||
}
|
||||
|
||||
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vreq,
|
||||
entityURI);
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
body.put("portalBean", portal);
|
||||
body.put("title", title + "Temporal Graph Visualization");
|
||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
body.put("organizationLabel", entity.getEntityLabel());
|
||||
body.put("jsonContent", jsonContent);
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This method should not be called anymore although the templates being
|
||||
* called by this method are still in use, so we should not get rid of it.
|
||||
* @param vitroRequest
|
||||
* @param entityURI
|
||||
* @return
|
||||
*/
|
||||
private ResponseValues prepareStandaloneErrorResponse(
|
||||
VitroRequest vitroRequest, String entityURI) {
|
||||
|
||||
|
@ -241,14 +254,8 @@ public class EntityPublicationCountRequestHandler implements
|
|||
String standaloneTemplate = "entityPublicationComparisonError.ftl";
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
|
||||
IndividualDao iDao = vitroRequest.getWebappDaoFactory().getIndividualDao();
|
||||
Individual ind = iDao.getIndividualByURI(entityURI);
|
||||
|
||||
String organizationLabel = "Unknown Organization";
|
||||
|
||||
if (ind != null) {
|
||||
organizationLabel = ind.getName();
|
||||
}
|
||||
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vitroRequest,
|
||||
entityURI);
|
||||
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
body.put("portalBean", portal);
|
||||
|
@ -258,8 +265,7 @@ public class EntityPublicationCountRequestHandler implements
|
|||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* function to generate a json file for year <-> publication count mapping
|
||||
* @param vreq
|
||||
|
@ -302,7 +308,7 @@ public class EntityPublicationCountRequestHandler implements
|
|||
|
||||
entityJson.setEntityURI(subentity.getIndividualURI());
|
||||
|
||||
boolean isPerson = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
|
||||
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity);
|
||||
|
||||
if(isPerson){
|
||||
entityJson.setVisMode("PERSON");
|
||||
|
@ -316,7 +322,7 @@ public class EntityPublicationCountRequestHandler implements
|
|||
return json.toJson(subEntitiesJson);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String getEntityPublicationsPerYearCSVContent(Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
|
||||
StringBuilder csvFileContent = new StringBuilder();
|
||||
|
|
|
@ -15,21 +15,15 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.hp.hpl.jena.iri.IRI;
|
||||
import com.hp.hpl.jena.iri.IRIFactory;
|
||||
import com.hp.hpl.jena.iri.Violation;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.DataVisualizationController;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparison.EntityComparisonUtilityFunctions;
|
||||
|
@ -54,48 +48,13 @@ public class EntityGrantCountRequestHandler implements
|
|||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
if (StringUtils.isNotBlank(entityURI)){
|
||||
if (StringUtils.isBlank(entityURI)){
|
||||
|
||||
return getSubjectEntityAndGenerateResponse(vitroRequest, log,
|
||||
Dataset, entityURI);
|
||||
entityURI = EntityComparisonUtilityFunctions
|
||||
.getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset);
|
||||
|
||||
} else {
|
||||
|
||||
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getProperty("visualization.topLevelOrg");
|
||||
|
||||
/*
|
||||
* First checking if the staff has provided highest level organization in deploy.properties
|
||||
* if so use to temporal graph vis.
|
||||
*/
|
||||
if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) {
|
||||
|
||||
/*
|
||||
* To test for the validity of the URI submitted.
|
||||
*/
|
||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
|
||||
|
||||
if (iri.hasViolation(false)) {
|
||||
|
||||
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
||||
log.error("Highest Level Organization URI provided is invalid " + errorMsg);
|
||||
|
||||
} else {
|
||||
|
||||
return getSubjectEntityAndGenerateResponse(vitroRequest,
|
||||
log, Dataset,
|
||||
staffProvidedHighestLevelOrganization);
|
||||
}
|
||||
}
|
||||
|
||||
String highestLevelOrgURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log,
|
||||
Dataset);
|
||||
|
||||
return getSubjectEntityAndGenerateResponse(vitroRequest, log,
|
||||
Dataset, highestLevelOrgURI);
|
||||
}
|
||||
|
||||
|
||||
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,6 +64,36 @@ public class EntityGrantCountRequestHandler implements
|
|||
|
||||
String entityURI = vitroRequest
|
||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||
|
||||
/*
|
||||
* This will provide the data in json format mainly used for standalone tmeporal vis.
|
||||
* */
|
||||
if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
|
||||
.equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
|
||||
|
||||
if (StringUtils.isNotBlank(entityURI)){
|
||||
|
||||
return getSubjectEntityAndGenerateDataResponse(
|
||||
vitroRequest,
|
||||
log,
|
||||
Dataset,
|
||||
entityURI);
|
||||
} else {
|
||||
|
||||
return getSubjectEntityAndGenerateDataResponse(
|
||||
vitroRequest,
|
||||
log,
|
||||
Dataset,
|
||||
EntityComparisonUtilityFunctions
|
||||
.getStaffProvidedOrComputedHighestLevelOrganization(
|
||||
log,
|
||||
Dataset));
|
||||
}
|
||||
|
||||
} else {
|
||||
/*
|
||||
* This provides csv download files for the content in the tables.
|
||||
* */
|
||||
|
||||
EntityGrantCountConstructQueryRunner constructQueryRunner = new EntityGrantCountConstructQueryRunner(entityURI, Dataset, log);
|
||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||
|
@ -119,6 +108,8 @@ public class EntityGrantCountRequestHandler implements
|
|||
log, Dataset, entityURI);
|
||||
|
||||
return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -128,7 +119,7 @@ public class EntityGrantCountRequestHandler implements
|
|||
throw new UnsupportedOperationException("Entity Grant Count does not provide Ajax Response.");
|
||||
}
|
||||
|
||||
private ResponseValues getSubjectEntityAndGenerateResponse(
|
||||
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
|
||||
VitroRequest vitroRequest, Log log, Dataset Dataset,
|
||||
String subjectEntityURI)
|
||||
throws MalformedQueryParametersException {
|
||||
|
@ -142,18 +133,16 @@ public class EntityGrantCountRequestHandler implements
|
|||
Entity entity = queryManager.getQueryResult();
|
||||
|
||||
if (entity.getEntityLabel().equals("no-label")) {
|
||||
|
||||
return prepareStandaloneErrorResponse(vitroRequest, subjectEntityURI);
|
||||
|
||||
return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
|
||||
} else {
|
||||
|
||||
return getSubEntityTypesAndRenderStandaloneResponse(
|
||||
return getSubEntityTypesAndComputeDataResponse(
|
||||
vitroRequest, log, Dataset,
|
||||
subjectEntityURI, entity);
|
||||
}
|
||||
}
|
||||
|
||||
private ResponseValues getSubEntityTypesAndRenderStandaloneResponse(
|
||||
private Map<String, String> getSubEntityTypesAndComputeDataResponse(
|
||||
VitroRequest vitroRequest, Log log, Dataset Dataset,
|
||||
String subjectOrganization, Entity entity)
|
||||
throws MalformedQueryParametersException {
|
||||
|
@ -161,8 +150,34 @@ public class EntityGrantCountRequestHandler implements
|
|||
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
|
||||
log, Dataset, subjectOrganization);
|
||||
|
||||
return prepareStandaloneResponse(vitroRequest, entity, subjectOrganization,
|
||||
subOrganizationTypesResult);
|
||||
return prepareStandaloneDataResponse(vitroRequest, entity, subOrganizationTypesResult);
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> prepareStandaloneDataErrorResponse(
|
||||
VitroRequest vitroRequest, String subjectEntityURI) {
|
||||
|
||||
Map<String, String> fileData = new HashMap<String, String>();
|
||||
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Grants for this Organization found in VIVO.\"}");
|
||||
return fileData;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> prepareStandaloneDataResponse(
|
||||
VitroRequest vitroRequest,
|
||||
Entity entity,
|
||||
Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
|
||||
Map<String, String> fileData = new HashMap<String, String>();
|
||||
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||
writeGrantsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult));
|
||||
return fileData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,39 +215,30 @@ public class EntityGrantCountRequestHandler implements
|
|||
return fileData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vreq
|
||||
* @param valueObjectContainer
|
||||
* @return
|
||||
*/
|
||||
private TemplateResponseValues prepareStandaloneResponse(VitroRequest vreq,
|
||||
Entity entity, String entityURI, Map<String, Set<String>> subOrganizationTypesResult) {
|
||||
|
||||
Portal portal = vreq.getPortal();
|
||||
String standaloneTemplate = "entityComparisonOnGrantsStandalone.ftl";
|
||||
private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
|
||||
String entityURI) {
|
||||
|
||||
Portal portal = vreq.getPortal();
|
||||
String standaloneTemplate = "entityComparisonOnGrantsStandalone.ftl";
|
||||
|
||||
String jsonContent = "";
|
||||
jsonContent = writeGrantsOverTimeJSON(vreq, entity.getSubEntities(), subOrganizationTypesResult);
|
||||
|
||||
String title = "";
|
||||
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vreq,
|
||||
entityURI);
|
||||
|
||||
if (StringUtils.isNotBlank(entity.getEntityLabel())) {
|
||||
title = entity.getEntityLabel() + " - ";
|
||||
}
|
||||
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
body.put("portalBean", portal);
|
||||
body.put("title", title + "Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
body.put("organizationLabel", entity.getEntityLabel());
|
||||
body.put("jsonContent", jsonContent);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
body.put("portalBean", portal);
|
||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method should not be called anymore although the templates being
|
||||
* called by this method are still in use, so we should not get rid of it.
|
||||
* @return
|
||||
*/
|
||||
private ResponseValues prepareStandaloneErrorResponse(
|
||||
VitroRequest vitroRequest, String entityURI) {
|
||||
|
||||
|
@ -240,14 +246,8 @@ public class EntityGrantCountRequestHandler implements
|
|||
String standaloneTemplate = "entityGrantComparisonError.ftl";
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
|
||||
IndividualDao iDao = vitroRequest.getWebappDaoFactory().getIndividualDao();
|
||||
Individual ind = iDao.getIndividualByURI(entityURI);
|
||||
|
||||
String organizationLabel = "Unknown Organization";
|
||||
|
||||
if (ind != null) {
|
||||
organizationLabel = ind.getName();
|
||||
}
|
||||
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vitroRequest,
|
||||
entityURI);
|
||||
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
|
||||
|
@ -300,7 +300,7 @@ public class EntityGrantCountRequestHandler implements
|
|||
|
||||
entityJson.setEntityURI(subentity.getIndividualURI());
|
||||
|
||||
boolean isPerson = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
|
||||
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity);
|
||||
|
||||
if(isPerson){
|
||||
entityJson.setVisMode("PERSON");
|
||||
|
|
|
@ -35,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Co
|
|||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.CoPINode;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Grant;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Node;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||
|
||||
public class UtilityFunctions {
|
||||
|
||||
|
@ -320,5 +321,9 @@ public class UtilityFunctions {
|
|||
|
||||
return collaboratorshipNetworkURL != null ? collaboratorshipNetworkURL : "" ;
|
||||
}
|
||||
|
||||
public static boolean isEntityAPerson(VitroRequest vreq, SubEntity subentity) {
|
||||
return vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue