1. Changed icon for map of science.

2. Bug fixes for map of science edge cases.
3. Included a default error message when there are no publications to be found.
4. Improved text for map of sience info.
This commit is contained in:
tankchintan 2011-07-13 22:39:28 +00:00
parent 431036c1b0
commit 6f213a61fa
14 changed files with 614 additions and 532 deletions

View file

@ -211,3 +211,25 @@ a.map-of-science-links {
.paginatedtabs {
font-size: 0.81em;
}
/* --------------------------------------------------------------> */
/* SPECIAL STYLES FOR THE error */
/* --------------------------------------------------------------> */
#error-container {
display: none;
}
#noPublications-header {
font-size: 1.375em;
color: #2485ae;
line-height: 1.3em;
padding-top:15px;
padding-bottom:10px;
}
#noPublications-span {
font-size:22px;
}
#noPublications-span a {
color: #84a655;
font-size:16px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -237,7 +237,7 @@ var DataTableWidget = Class.extend({
}
me.currentSelectedFilter = SCIMAP_TYPE.SUBDISCIPLINE;
$("a#csv").attr("href", entityMapOfScienceSubDisciplineCSVURL);
$("a#csv").html("Export All Sub-Displines");
$("a#csv").html("Export All Sub-Disciplines");
} else {
@ -247,7 +247,7 @@ var DataTableWidget = Class.extend({
me.widget.fnSettings()._iDisplayLength = 13;
}
$("a#csv").attr("href", entityMapOfScienceDisciplineCSVURL);
$("a#csv").html("Export All Displines");
$("a#csv").html("Export All Disciplines");
}

View file

@ -177,8 +177,8 @@ var DisciplineMarkerManager = ScimapMarkerManager.extend({
marker.setContent(
'<div style="font-size: 80%; padding: 5px; text-align: left;"><b>'
+ poly.label +'</b><br />'
+ addCommasToNumber(poly.value.toFixed(2)) + ' of publications (pubs.)<br />'
+ (poly.value * 100 / this.maxValue).toFixed(2) + '% of activity</div>'
+ addCommasToNumber(poly.value.toFixed(2)) + ' publications (pubs.)<br />'
+ (poly.value * 100 / this.maxValue).toFixed(2) + '% activity</div>'
);
return marker;
}
@ -198,8 +198,8 @@ var SubdisciplineMarkerManager = ScimapMarkerManager.extend({
marker.setContent(
'<div style="font-size: 80%; padding: 5px; text-align: left;"><b>'
+ poly.label + '</b> in ' + disciplineLabel +'<br />'
+ addCommasToNumber(poly.value.toFixed(2)) + ' of publications (pubs.)<br />'
+ (poly.value * 100 / this.maxValue).toFixed(2) + '% of activity</div>'
+ addCommasToNumber(poly.value.toFixed(2)) + ' publications (pubs.)<br />'
+ (poly.value * 100 / this.maxValue).toFixed(2) + '% activity</div>'
);
return marker;

View file

@ -61,11 +61,11 @@ var EntityVisModeController = Class.extend({
if (me.isUnloaded) {
if (sync) {
downloader.downloadAndWait(url, function(data) {
me.loadJsonData(me, data[0]);
me.loadJsonData(me, data);
});
} else {
downloader.download(url, function(data) {
me.loadJsonData(me, data[0]);
me.loadJsonData(me, data);
});
}
} // end if
@ -74,12 +74,20 @@ var EntityVisModeController = Class.extend({
$("#" + responseContainerID).unblock();
if (data.error) {
$("#map-of-science-response").hide();
$("#error-container").show();
return;
}
data = data[0];
$.each(me.widgets, function(i, widget) {
widget.loadJsonData(data);
});
me.isUnloaded = false;
me.initToolTipInfo();
},
initToolTipInfo: function() {

View file

@ -18,7 +18,7 @@
<section id="visualization" role="region">
<#if isAuthor>
<#assign coAuthorIcon = "${urls.images}/visualization/co_author_icon.png">
<#assign mapOfScienceIcon = "${urls.images}/visualization/mapofscience/vivo_scimap_icon_v001.png">
<#assign mapOfScienceIcon = "${urls.images}/visualization/mapofscience/vivo_scimap.jpg">
<#assign coAuthorVisUrl = individual.coAuthorVisUrl>
<#assign mapOfScienceVisUrl = individual.mapOfScienceUrl>

View file

@ -3,5 +3,5 @@
<#-- Map Of Science visualization -->
<div id="map-of-science">
<h3><img src="${urls.images}/visualization/mapofscience/vivo_scimap_icon_v001.png" width="25px" height="25px" /><a href="${individual.mapOfScienceUrl}">Map of Science</a></h3>
<h3><img src="${urls.images}/visualization/mapofscience/vivo_scimap.jpg" width="25px" height="25px" /><a href="${individual.mapOfScienceUrl}">Map of Science</a></h3>
</div>

View file

@ -25,7 +25,7 @@
</#if>
<#assign mapOfScienceIcon = '${urls.images}/visualization/mapofscience/vivo_scimap_icon_v001.png'>
<#assign mapOfScienceIcon = '${urls.images}/visualization/mapofscience/vivo_scimap.jpg'>
<#assign entityMapOfScienceDataURL = "${urls.base}${dataVisualizationURLRoot}?vis=${mapOfScienceVisParam}&uri=${entityURI}&output=json">
<#assign entityMapOfScienceDisciplineCSVURL = "${urls.base}${dataVisualizationURLRoot}?vis=${mapOfScienceVisParam}&uri=${entityURI}&output=csv&vis_mode=discipline">

View file

@ -102,12 +102,25 @@ You can hover over a sub-discipline in the table below to show which overlaid ci
<br /><br />
<#--
In the table below, <b># of pubs.</b> column indicates number of publications that fall under a particular field (sub-discipline or
discipline). Sometimes this number will be fractional. This happens when a journal in which the publication was published happens
to impact more than one field and hence the publication score is distributed into number of fractions based on the weight scores
of the journal in the different fields.<br /><br />
discipline). Sometimes this number will be fractional. This happens when a journal in which the publication was published is associated
with more than one (sub)discipline. In these cases, the publication score is fractionally mapped based on the weight scores
of the journal.<br /><br />
<b>% activity</b> column indicates the percentage of publications that fall under a particular field.
-->
The table below summarizes this institution's body of publications as plotted on the map of science.
Each row corresponds to a field (discipline or sub-discipline) on the map.
<br /><br />
The <b># of pubs.</b> column shows how many of the publications were mapped to each field.
This count can be fractional because some publication venues are associated with more than one field.
Each publication in such a venue contributes fractionally to all associated fields according to a weighting scheme.
<br /><br />
The <b>% activity</b> column shows what proportion of the publications were mapped to each field.
</div>
@ -122,7 +135,20 @@ may need to be cleaned up before they are recognized. You may contact a VIVO sys
concern.</div>
<div id="searchInfoTooltipText" style="display:none;">
This search box is used to filter the table rows based on the sub-discipline (or discipline) label found in the first column.
<!-- Search for specific sub-discipline (or discipline) label in the first column of the table. -->
List only map of science areas whose names contain this text.
</div>
<div id="error-container">
<h1 id="noPublications-header">${entityLabel}</h1>
<h3 id="alternative-vis-info">Map of Science Visualization</h3>
<div id="error-body">
<p>This organization has neither sub-organizations nor people with publications in the system.
Please visit the full ${entityLabel} <a href="${entityVivoProfileURL}">profile page</a> for a more complete overview.</p>
</div>
</div>
${headScripts.add('<script type="text/javascript" src="${urls.base}/js/jquery_plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>')}

View file

@ -55,10 +55,8 @@ public class EntityPublicationCountRequestHandler implements
if (StringUtils.isBlank(entityURI)) {
entityURI = OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest);
.getStaffProvidedOrComputedHighestLevelOrganization(log,
dataset, vitroRequest);
}
@ -72,17 +70,20 @@ public class EntityPublicationCountRequestHandler implements
Dataset dataSource) throws MalformedQueryParametersException {
return generateStandardVisualizationForPublicationTemporalVis(
vitroRequest, log, dataSource, parameters.get(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY));
vitroRequest,
log,
dataSource,
parameters
.get(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY));
}
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI)
throws MalformedQueryParametersException {
String subjectEntityURI) throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner =
new EntityPublicationCountConstructQueryRunner(subjectEntityURI, dataset, log);
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(
subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
@ -93,13 +94,13 @@ public class EntityPublicationCountRequestHandler implements
if (entity.getEntityLabel().equals("no-label")) {
return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
return prepareStandaloneDataErrorResponse(vitroRequest,
subjectEntityURI);
} else {
return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, dataset,
subjectEntityURI, entity);
return getSubEntityTypesAndComputeDataResponse(vitroRequest, log,
dataset, subjectEntityURI, entity);
}
}
@ -110,7 +111,8 @@ public class EntityPublicationCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
fileData
.put(DataVisualizationController.FILE_CONTENT_KEY,
"{\"error\" : \"No Publications for this Organization found in VIVO.\"}");
return fileData;
}
@ -120,12 +122,11 @@ public class EntityPublicationCountRequestHandler implements
String subjectEntityURI, Entity entity)
throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult =
OrganizationUtilityFunctions.getSubEntityTypes(
log, dataset, subjectEntityURI);
Map<String, Set<String>> subOrganizationTypesResult = OrganizationUtilityFunctions
.getSubEntityTypes(log, dataset, subjectEntityURI);
return prepareStandaloneDataResponse(vitroRequest, entity, entity.getSubEntities(),
subOrganizationTypesResult);
return prepareStandaloneDataResponse(vitroRequest, entity, entity
.getSubEntities(), subOrganizationTypesResult);
}
@Override
@ -137,19 +138,17 @@ public class EntityPublicationCountRequestHandler implements
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
/*
* This will provide the data in json format mainly used for standalone tmeporal vis.
* */
* This will provide the data in json format mainly used for standalone
* tmeporal vis.
*/
if (VisualizationFrameworkConstants.JSON_OUTPUT_FORMAT
.equalsIgnoreCase(vitroRequest.getParameter(
VisualizationFrameworkConstants.VIS_MODE_KEY))) {
.equalsIgnoreCase(vitroRequest
.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
if (StringUtils.isNotBlank(entityURI)) {
return getSubjectEntityAndGenerateDataResponse(
vitroRequest,
log,
dataset,
entityURI);
return getSubjectEntityAndGenerateDataResponse(vitroRequest,
log, dataset, entityURI);
} else {
return getSubjectEntityAndGenerateDataResponse(
@ -158,18 +157,16 @@ public class EntityPublicationCountRequestHandler implements
dataset,
OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest));
log, dataset, vitroRequest));
}
} else {
/*
* This provides csv download files for the content in the tables.
* */
*/
ModelConstructor constructQueryRunner =
new EntityPublicationCountConstructQueryRunner(entityURI, dataset, log);
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(
entityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
@ -178,39 +175,41 @@ public class EntityPublicationCountRequestHandler implements
Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult =
OrganizationUtilityFunctions.getSubEntityTypes(
log, dataset, entityURI);
Map<String, Set<String>> subOrganizationTypesResult = OrganizationUtilityFunctions
.getSubEntityTypes(log, dataset, entityURI);
return prepareDataResponse(entity, entity.getSubEntities(), subOrganizationTypesResult);
return prepareDataResponse(entity, entity.getSubEntities(),
subOrganizationTypesResult);
}
}
@Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Entity Pub Count does not provide Ajax Response.");
throw new UnsupportedOperationException(
"Entity Pub Count does not provide Ajax Response.");
}
/**
* Provides response when json file containing the publication count over the
* years is requested.
* Provides response when json file containing the publication count over
* the years is requested.
*
* @param entity
* @param subentities
* @param subOrganizationTypesResult
*/
private Map<String, String> prepareDataResponse(Entity entity, Set<SubEntity> subentities,
private Map<String, String> prepareDataResponse(Entity entity,
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
String entityLabel = entity.getEntityLabel();
/*
* To make sure that null/empty records for entity names do not cause any mischief.
* */
* To make sure that null/empty records for entity names do not cause
* any mischief.
*/
if (StringUtils.isBlank(entityLabel)) {
entityLabel = "no-organization";
}
@ -218,49 +217,50 @@ public class EntityPublicationCountRequestHandler implements
String outputFileName = UtilityFunctions.slugify(entityLabel)
+ "_publications-per-year" + ".csv";
Map<String, String> fileData = new HashMap<String, String>();
fileData.put(DataVisualizationController.FILE_NAME_KEY,
outputFileName);
fileData.put(DataVisualizationController.FILE_NAME_KEY, outputFileName);
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
getEntityPublicationsPerYearCSVContent(subentities, subOrganizationTypesResult));
return fileData;
}
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(),
getEntityPublicationsPerYearCSVContent(subentities,
subOrganizationTypesResult));
return fileData;
}
private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
String entityURI) {
private Map<String, String> prepareStandaloneDataResponse(
VitroRequest vitroRequest, Entity entity,
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult)
throws MalformedQueryParametersException {
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) {
String standaloneTemplate = "entityComparisonOnPublicationsStandalone.ftl";
String organizationLabel = OrganizationUtilityFunctions
.getEntityLabelFromDAO(vreq,
entityURI);
.getEntityLabelFromDAO(vreq, entityURI);
Map<String, Object> body = new HashMap<String, Object>();
body.put("title", organizationLabel + " - Temporal Graph Visualization");
body
.put("title", organizationLabel
+ " - Temporal Graph Visualization");
body.put("organizationURI", entityURI);
body.put("organizationLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
body.put("vivoDefaultNamespace", vreq.getWebappDaoFactory().getDefaultNamespace());
body.put("organizationLocalName", UtilityFunctions
.getIndividualLocalName(entityURI, vreq));
body.put("vivoDefaultNamespace", vreq.getWebappDaoFactory()
.getDefaultNamespace());
body.put("organizationLabel", organizationLabel);
return new TemplateResponseValues(standaloneTemplate, body);
@ -268,21 +268,23 @@ public class EntityPublicationCountRequestHandler implements
/**
* Function to generate a json file for year <-> publication count mapping.
*
* @param vreq
* @param subentities
* @param subOrganizationTypesResult
* @throws MalformedQueryParametersException
*/
private String writePublicationsOverTimeJSON(VitroRequest vreq,
Set<SubEntity> subentities,
Map<String, Set<String>>
subOrganizationTypesResult) {
Map<String, Set<String>> subOrganizationTypesResult)
throws MalformedQueryParametersException {
Gson json = new Gson();
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
for (SubEntity subentity : subentities) {
JsonObject entityJson = new JsonObject(
subentity.getIndividualLabel());
JsonObject entityJson = new JsonObject(subentity
.getIndividualLabel());
List<List<Integer>> yearPubCount = new ArrayList<List<Integer>>();
@ -291,7 +293,8 @@ public class EntityPublicationCountRequestHandler implements
.entrySet()) {
List<Integer> currentPubYear = new ArrayList<Integer>();
if (pubEntry.getKey().equals(VOConstants.DEFAULT_PUBLICATION_YEAR)) {
if (pubEntry.getKey().equals(
VOConstants.DEFAULT_PUBLICATION_YEAR)) {
currentPubYear.add(-1);
} else {
currentPubYear.add(Integer.parseInt(pubEntry.getKey()));
@ -307,7 +310,8 @@ public class EntityPublicationCountRequestHandler implements
entityJson.setEntityURI(subentity.getIndividualURI());
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity.getIndividualURI());
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity
.getIndividualURI());
if (isPerson) {
entityJson.setVisMode("PERSON");
@ -329,7 +333,8 @@ public class EntityPublicationCountRequestHandler implements
for (SubEntity subEntity : subentities) {
csvFileContent.append(StringEscapeUtils.escapeCsv(subEntity.getIndividualLabel()));
csvFileContent.append(StringEscapeUtils.escapeCsv(subEntity
.getIndividualLabel()));
csvFileContent.append(", ");
csvFileContent.append(subEntity.getActivities().size());
csvFileContent.append(", ");
@ -341,7 +346,8 @@ public class EntityPublicationCountRequestHandler implements
joinedTypes.append(subOrganizationType + "; ");
}
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes.toString()));
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes
.toString()));
csvFileContent.append("\n");
}
return csvFileContent.toString();

View file

@ -34,7 +34,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
public class EntityGrantCountRequestHandler implements
VisualizationRequestHandler {
@ -56,10 +55,8 @@ public class EntityGrantCountRequestHandler implements
if (StringUtils.isBlank(entityURI)) {
entityURI = OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest);
.getStaffProvidedOrComputedHighestLevelOrganization(log,
dataset, vitroRequest);
}
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
@ -71,7 +68,11 @@ public class EntityGrantCountRequestHandler implements
Dataset dataSource) throws MalformedQueryParametersException {
return generateStandardVisualizationForGrantTemporalVis(
vitroRequest, log, dataSource, parameters.get(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY));
vitroRequest,
log,
dataSource,
parameters
.get(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY));
}
@ -84,19 +85,17 @@ public class EntityGrantCountRequestHandler implements
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
/*
* This will provide the data in json format mainly used for standalone temporal vis.
* */
* This will provide the data in json format mainly used for standalone
* temporal vis.
*/
if (VisualizationFrameworkConstants.JSON_OUTPUT_FORMAT
.equalsIgnoreCase(vitroRequest
.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
if (StringUtils.isNotBlank(entityURI)) {
return getSubjectEntityAndGenerateDataResponse(
vitroRequest,
log,
dataset,
entityURI);
return getSubjectEntityAndGenerateDataResponse(vitroRequest,
log, dataset, entityURI);
} else {
return getSubjectEntityAndGenerateDataResponse(
@ -105,17 +104,15 @@ public class EntityGrantCountRequestHandler implements
dataset,
OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest));
log, dataset, vitroRequest));
}
} else {
/*
* This provides csv download files for the content in the tables.
* */
ModelConstructor constructQueryRunner =
new EntityGrantCountConstructQueryRunner(entityURI, dataset, log);
*/
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(
entityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
@ -124,12 +121,11 @@ public class EntityGrantCountRequestHandler implements
Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult = OrganizationUtilityFunctions
.getSubEntityTypes(log, dataset, entityURI);
Map<String, Set<String>> subOrganizationTypesResult =
OrganizationUtilityFunctions.getSubEntityTypes(
log, dataset, entityURI);
return prepareDataResponse(entity, entity.getSubEntities(), subOrganizationTypesResult);
return prepareDataResponse(entity, entity.getSubEntities(),
subOrganizationTypesResult);
}
@ -145,11 +141,10 @@ public class EntityGrantCountRequestHandler implements
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI)
throws MalformedQueryParametersException {
String subjectEntityURI) throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner =
new EntityGrantCountConstructQueryRunner(subjectEntityURI, dataset, log);
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(
subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
@ -159,12 +154,12 @@ public class EntityGrantCountRequestHandler implements
Entity entity = queryManager.getQueryResult();
if (entity.getEntityLabel().equals("no-label")) {
return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
return prepareStandaloneDataErrorResponse(vitroRequest,
subjectEntityURI);
} else {
return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, dataset,
subjectEntityURI, entity);
return getSubEntityTypesAndComputeDataResponse(vitroRequest, log,
dataset, subjectEntityURI, entity);
}
}
@ -173,14 +168,13 @@ public class EntityGrantCountRequestHandler implements
String subjectOrganization, Entity entity)
throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult =
OrganizationUtilityFunctions.getSubEntityTypes(
log, dataset, subjectOrganization);
Map<String, Set<String>> subOrganizationTypesResult = OrganizationUtilityFunctions
.getSubEntityTypes(log, dataset, subjectOrganization);
return prepareStandaloneDataResponse(vitroRequest, entity, subOrganizationTypesResult);
return prepareStandaloneDataResponse(vitroRequest, entity,
subOrganizationTypesResult);
}
private Map<String, String> prepareStandaloneDataErrorResponse(
VitroRequest vitroRequest, String subjectEntityURI) {
@ -188,24 +182,23 @@ public class EntityGrantCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
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) {
VitroRequest vitroRequest, Entity entity,
Map<String, Set<String>> subOrganizationTypesResult)
throws MalformedQueryParametersException {
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(),
writeGrantsOverTimeJSON(vitroRequest, entity.getSubEntities(),
subOrganizationTypesResult));
return fileData;
}
@ -218,14 +211,16 @@ public class EntityGrantCountRequestHandler implements
* @param subentities
* @param subOrganizationTypesResult
*/
private Map<String, String> prepareDataResponse(Entity entity, Set<SubEntity> subentities,
private Map<String, String> prepareDataResponse(Entity entity,
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
String entityLabel = entity.getEntityLabel();
/*
* To make sure that null/empty records for entity names do not cause any mischief.
* */
* To make sure that null/empty records for entity names do not cause
* any mischief.
*/
if (StringUtils.isBlank(entityLabel)) {
entityLabel = "no-organization";
}
@ -233,32 +228,34 @@ public class EntityGrantCountRequestHandler implements
String outputFileName = UtilityFunctions.slugify(entityLabel)
+ "_grants-per-year" + ".csv";
Map<String, String> fileData = new HashMap<String, String>();
fileData.put(DataVisualizationController.FILE_NAME_KEY,
outputFileName);
fileData.put(DataVisualizationController.FILE_NAME_KEY, outputFileName);
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
getEntityGrantsPerYearCSVContent(subentities, subOrganizationTypesResult));
getEntityGrantsPerYearCSVContent(subentities,
subOrganizationTypesResult));
return fileData;
}
private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
String entityURI) {
private TemplateResponseValues prepareStandaloneMarkupResponse(
VitroRequest vreq, String entityURI) {
String standaloneTemplate = "entityComparisonOnGrantsStandalone.ftl";
String organizationLabel = OrganizationUtilityFunctions.getEntityLabelFromDAO(vreq,
entityURI);
String organizationLabel = OrganizationUtilityFunctions
.getEntityLabelFromDAO(vreq, entityURI);
Map<String, Object> body = new HashMap<String, Object>();
body.put("title", organizationLabel + " - Temporal Graph Visualization");
body
.put("title", organizationLabel
+ " - Temporal Graph Visualization");
body.put("organizationURI", entityURI);
body.put("organizationLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
body.put("vivoDefaultNamespace", vreq.getWebappDaoFactory().getDefaultNamespace());
body.put("organizationLocalName", UtilityFunctions
.getIndividualLocalName(entityURI, vreq));
body.put("vivoDefaultNamespace", vreq.getWebappDaoFactory()
.getDefaultNamespace());
body.put("organizationLabel", organizationLabel);
return new TemplateResponseValues(standaloneTemplate, body);
@ -266,20 +263,23 @@ public class EntityGrantCountRequestHandler implements
/**
* Function to generate a json file for year <-> grant count mapping.
*
* @param vreq
* @param subentities
* @param subOrganizationTypesResult
* @throws MalformedQueryParametersException
*/
private String writeGrantsOverTimeJSON(VitroRequest vreq,
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
Map<String, Set<String>> subOrganizationTypesResult)
throws MalformedQueryParametersException {
Gson json = new Gson();
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
for (SubEntity subentity : subentities) {
JsonObject entityJson = new JsonObject(
subentity.getIndividualLabel());
JsonObject entityJson = new JsonObject(subentity
.getIndividualLabel());
List<List<Integer>> yearGrantCount = new ArrayList<List<Integer>>();
@ -288,8 +288,7 @@ public class EntityGrantCountRequestHandler implements
.entrySet()) {
List<Integer> currentGrantYear = new ArrayList<Integer>();
if (grantEntry.getKey().equals(
VOConstants.DEFAULT_GRANT_YEAR)) {
if (grantEntry.getKey().equals(VOConstants.DEFAULT_GRANT_YEAR)) {
currentGrantYear.add(-1);
} else {
currentGrantYear.add(Integer.parseInt(grantEntry.getKey()));
@ -305,7 +304,8 @@ public class EntityGrantCountRequestHandler implements
entityJson.setEntityURI(subentity.getIndividualURI());
if (UtilityFunctions.isEntityAPerson(vreq, subentity.getIndividualURI())) {
if (UtilityFunctions.isEntityAPerson(vreq, subentity
.getIndividualURI())) {
entityJson.setVisMode("PERSON");
} else {
entityJson.setVisMode("ORGANIZATION");
@ -318,8 +318,7 @@ public class EntityGrantCountRequestHandler implements
}
private String getEntityGrantsPerYearCSVContent(
Set<SubEntity> subentities,
private String getEntityGrantsPerYearCSVContent(Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
StringBuilder csvFileContent = new StringBuilder();
@ -328,7 +327,8 @@ public class EntityGrantCountRequestHandler implements
for (SubEntity subEntity : subentities) {
csvFileContent.append(StringEscapeUtils.escapeCsv(subEntity.getIndividualLabel()));
csvFileContent.append(StringEscapeUtils.escapeCsv(subEntity
.getIndividualLabel()));
csvFileContent.append(", ");
csvFileContent.append(subEntity.getActivities().size());
csvFileContent.append(", ");
@ -340,7 +340,8 @@ public class EntityGrantCountRequestHandler implements
joinedTypes.append(subOrganizationType + "; ");
}
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes.toString()));
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes
.toString()));
csvFileContent.append("\n");
}

View file

@ -32,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.entitycomparison.Organizat
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Entity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.MapOfScienceActivity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.json.MapOfScience;
@ -262,12 +263,18 @@ public class MapOfScienceVisualizationRequestHandler implements
private Map<String, String> prepareStandaloneDataErrorResponse() {
GenericQueryMap errorDataResponse = new GenericQueryMap();
errorDataResponse.addEntry("error", "No Publications for this Entity found in VIVO.");
Gson jsonErrorResponse = new Gson();
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 Entity found in VIVO.\"}");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, jsonErrorResponse.toJson(errorDataResponse));
return fileData;
}
@ -326,7 +333,8 @@ public class MapOfScienceVisualizationRequestHandler implements
private Map<String, String> prepareStandaloneDataResponse(
VitroRequest vitroRequest,
Entity entity) {
Entity entity)
throws MalformedQueryParametersException {
Map<String, String> fileData = new HashMap<String, String>();
@ -362,9 +370,10 @@ public class MapOfScienceVisualizationRequestHandler implements
* @param vreq
* @param subentities
* @param subOrganizationTypesResult
* @throws MalformedQueryParametersException
*/
private String writeMapOfScienceDataJSON(VitroRequest vreq,
Entity subjectEntity) {
Entity subjectEntity) throws MalformedQueryParametersException {
Gson json = new Gson();
Set jsonContent = new HashSet();

View file

@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
@ -251,11 +252,20 @@ public class UtilityFunctions {
return collaboratorshipNetworkURL != null ? collaboratorshipNetworkURL : "" ;
}
public static boolean isEntityAPerson(VitroRequest vreq, String individualURI) {
return vreq.getWebappDaoFactory()
public static boolean isEntityAPerson(VitroRequest vreq, String individualURI)
throws MalformedQueryParametersException {
Individual individualByURI = vreq.getWebappDaoFactory()
.getIndividualDao()
.getIndividualByURI(individualURI)
.getIndividualByURI(individualURI);
if (individualByURI != null) {
return individualByURI
.isVClass("http://xmlns.com/foaf/0.1/Person");
} else {
throw new MalformedQueryParametersException("Individual with " + individualURI + " not found in the system.");
}
}