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

@ -210,4 +210,26 @@ 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

@ -1,207 +1,207 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
/**
* The MarkerManager is more like a composite class of Marker. It manages
* markers by grouping the markers by keys.
*/
var MarkerManager = Class.extend({
init: function() {
this.keyToMarker = {};
},
addMarker: function(key, marker) {
this.keyToMarker[key] = marker;
},
length: function() {
var size = 0;
for (var key in this.keyToMarker) {
if (this.keyToMarker.hasOwnProperty(key)) size++;
}
return size;
},
getMarker: function(key) {
return this.keyToMarker[key];
},
getMarkerArray: function() {
var array = [];
$.each(this.keyToMarker, function(i, e){ array.push(e); });
return array;
},
hasKey: function(key) {
return (this.keyToMarker.hasOwnProperty(key));
},
showMarkers: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.show();
});
},
hideMarkers: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.hide();
});
},
addMarkersToMap: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.addToMap();
});
},
removeMarkersFromMap: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.removeFromMap();
});
}
});
/**
* Customized Discipline labels MarkerManager for Science map purpose. It is an abstract class
*/
var DisciplineLabelsMarkerManager = MarkerManager.extend({
init: function(map) {
this._super();
this.map = map;
this.initMarkers(map);
},
initMarkers: function(map) {
me = this;
$.each(DISCIPLINES, function(id, discipline) {
var opts = {
map: map,
position: createNoWrapLatLng(discipline.labelLatitude, discipline.labelLongitude),
icon: getDisciplineLabelImageURL(id),
clickable: false
};
me.addMarker(id, new Marker(opts));
});
},
showMarkers: function() {
this._super();
}
});
/**
* Customized MarkerManager for Science map purpose. It is an abstract class
*/
var ScimapMarkerManager = MarkerManager.extend({
init: function(map, colorStrategy, sizeCoder) {
this._super();
this.colorStrategy = colorStrategy;
this.sizeCoder = sizeCoder;
this.map = map;
this.maxValue = 1;
this.layer = {};
},
setSizeCoder: function(sizeCoder) {
this.sizeCoder = sizeCoder;
this.maxValue = sizeCoder.getMaxValue();
},
createMarker: function(key, density) {
var me = this;
var marker;
if (!me.hasKey(key)) {
var size = me.sizeCoder.getSize(density);
var color = me.colorStrategy.getColor(key);
var layer = me.layer;
var label = layer[key].label;
var latlng = createNoWrapLatLng(layer[key].latitude, layer[key].longitude);
marker = createScinodeMarker(me.map, label, density, size, color, latlng);
me.addMarker(key, marker);
} else {
marker = me.keyToMarker[key];
marker.setValue(marker.getValue() + density);
marker.setSize(me.sizeCoder.getSize(marker.getValue()));
}
return marker;
},
updateMarkerViews: function() {
var me = this;
for (var key in me.keyToMarker) {
var marker = me.keyToMarker[key];
marker.setSize(me.sizeCodingFunc(marker.getValue()));
marker.setColor(me.colorStrategy.getColor(key));
}
},
display: function(numberOfMarkers) {
var markerArray = this.sortedMarkers;
if (!markerArray || !markerArray.length) {
markerArray = this.getMarkerArray();
}
$.each(markerArray, function() {
if (numberOfMarkers > 0) {
this.show();
numberOfMarkers--;
} else {
this.hide();
}
});
},
mouseIn: function(key) {
var marker = this.getMarker(key);
if (marker) {
marker.focus();
}
},
mouseInAll: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.focus();
});
},
mouseOut: function(key) {
var marker = this.getMarker(key);
if (marker) {
marker.unfocus();
}
},
mouseOutAll: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.unfocus();
});
},
sort: function() {
this.sortedMarkers = this.getMarkerArray();
this.sortedMarkers.sort(function(a, b) {
return b.getValue() -a.getValue();
});
}
});
var DisciplineMarkerManager = ScimapMarkerManager.extend({
init: function(map, colorStrategy, sizeCoder) {
this._super(map, colorStrategy, sizeCoder);
this.layer = DISCIPLINES;
},
createMarker: function(subdisciplineKey, density) {
var me = this;
var key = SUBDISCIPLINES[subdisciplineKey].discipline;
var marker = this._super(key, density);
var poly = marker.polygon;
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>'
);
return marker;
}
});
var SubdisciplineMarkerManager = ScimapMarkerManager.extend({
init: function(map, colorStrategy, sizeCoder) {
this._super(map, colorStrategy, sizeCoder);
this.layer = SUBDISCIPLINES;
},
createMarker: function(subdisciplineKey, density) {
var marker = this._super(subdisciplineKey, density);
var disciplineId = SUBDISCIPLINES[subdisciplineKey].discipline;
var disciplineLabel = DISCIPLINES[disciplineId].label;
var poly = marker.polygon;
/* Override the getContent for Subdiscipline */
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>'
);
return marker;
}
});
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
/**
* The MarkerManager is more like a composite class of Marker. It manages
* markers by grouping the markers by keys.
*/
var MarkerManager = Class.extend({
init: function() {
this.keyToMarker = {};
},
addMarker: function(key, marker) {
this.keyToMarker[key] = marker;
},
length: function() {
var size = 0;
for (var key in this.keyToMarker) {
if (this.keyToMarker.hasOwnProperty(key)) size++;
}
return size;
},
getMarker: function(key) {
return this.keyToMarker[key];
},
getMarkerArray: function() {
var array = [];
$.each(this.keyToMarker, function(i, e){ array.push(e); });
return array;
},
hasKey: function(key) {
return (this.keyToMarker.hasOwnProperty(key));
},
showMarkers: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.show();
});
},
hideMarkers: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.hide();
});
},
addMarkersToMap: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.addToMap();
});
},
removeMarkersFromMap: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.removeFromMap();
});
}
});
/**
* Customized Discipline labels MarkerManager for Science map purpose. It is an abstract class
*/
var DisciplineLabelsMarkerManager = MarkerManager.extend({
init: function(map) {
this._super();
this.map = map;
this.initMarkers(map);
},
initMarkers: function(map) {
me = this;
$.each(DISCIPLINES, function(id, discipline) {
var opts = {
map: map,
position: createNoWrapLatLng(discipline.labelLatitude, discipline.labelLongitude),
icon: getDisciplineLabelImageURL(id),
clickable: false
};
me.addMarker(id, new Marker(opts));
});
},
showMarkers: function() {
this._super();
}
});
/**
* Customized MarkerManager for Science map purpose. It is an abstract class
*/
var ScimapMarkerManager = MarkerManager.extend({
init: function(map, colorStrategy, sizeCoder) {
this._super();
this.colorStrategy = colorStrategy;
this.sizeCoder = sizeCoder;
this.map = map;
this.maxValue = 1;
this.layer = {};
},
setSizeCoder: function(sizeCoder) {
this.sizeCoder = sizeCoder;
this.maxValue = sizeCoder.getMaxValue();
},
createMarker: function(key, density) {
var me = this;
var marker;
if (!me.hasKey(key)) {
var size = me.sizeCoder.getSize(density);
var color = me.colorStrategy.getColor(key);
var layer = me.layer;
var label = layer[key].label;
var latlng = createNoWrapLatLng(layer[key].latitude, layer[key].longitude);
marker = createScinodeMarker(me.map, label, density, size, color, latlng);
me.addMarker(key, marker);
} else {
marker = me.keyToMarker[key];
marker.setValue(marker.getValue() + density);
marker.setSize(me.sizeCoder.getSize(marker.getValue()));
}
return marker;
},
updateMarkerViews: function() {
var me = this;
for (var key in me.keyToMarker) {
var marker = me.keyToMarker[key];
marker.setSize(me.sizeCodingFunc(marker.getValue()));
marker.setColor(me.colorStrategy.getColor(key));
}
},
display: function(numberOfMarkers) {
var markerArray = this.sortedMarkers;
if (!markerArray || !markerArray.length) {
markerArray = this.getMarkerArray();
}
$.each(markerArray, function() {
if (numberOfMarkers > 0) {
this.show();
numberOfMarkers--;
} else {
this.hide();
}
});
},
mouseIn: function(key) {
var marker = this.getMarker(key);
if (marker) {
marker.focus();
}
},
mouseInAll: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.focus();
});
},
mouseOut: function(key) {
var marker = this.getMarker(key);
if (marker) {
marker.unfocus();
}
},
mouseOutAll: function() {
$.each(this.keyToMarker, function(i, marker) {
marker.unfocus();
});
},
sort: function() {
this.sortedMarkers = this.getMarkerArray();
this.sortedMarkers.sort(function(a, b) {
return b.getValue() -a.getValue();
});
}
});
var DisciplineMarkerManager = ScimapMarkerManager.extend({
init: function(map, colorStrategy, sizeCoder) {
this._super(map, colorStrategy, sizeCoder);
this.layer = DISCIPLINES;
},
createMarker: function(subdisciplineKey, density) {
var me = this;
var key = SUBDISCIPLINES[subdisciplineKey].discipline;
var marker = this._super(key, density);
var poly = marker.polygon;
marker.setContent(
'<div style="font-size: 80%; padding: 5px; text-align: left;"><b>'
+ poly.label +'</b><br />'
+ addCommasToNumber(poly.value.toFixed(2)) + ' publications (pubs.)<br />'
+ (poly.value * 100 / this.maxValue).toFixed(2) + '% activity</div>'
);
return marker;
}
});
var SubdisciplineMarkerManager = ScimapMarkerManager.extend({
init: function(map, colorStrategy, sizeCoder) {
this._super(map, colorStrategy, sizeCoder);
this.layer = SUBDISCIPLINES;
},
createMarker: function(subdisciplineKey, density) {
var marker = this._super(subdisciplineKey, density);
var disciplineId = SUBDISCIPLINES[subdisciplineKey].discipline;
var disciplineLabel = DISCIPLINES[disciplineId].label;
var poly = marker.polygon;
/* Override the getContent for Subdiscipline */
marker.setContent(
'<div style="font-size: 80%; padding: 5px; text-align: left;"><b>'
+ poly.label + '</b> in ' + disciplineLabel +'<br />'
+ 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

@ -35,7 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
public class EntityPublicationCountRequestHandler implements
VisualizationRequestHandler {
@Override
public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset dataset)
@ -43,7 +43,7 @@ public class EntityPublicationCountRequestHandler implements
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
return generateStandardVisualizationForPublicationTemporalVis(
vitroRequest, log, dataset, entityURI);
}
@ -51,19 +51,17 @@ public class EntityPublicationCountRequestHandler implements
private ResponseValues generateStandardVisualizationForPublicationTemporalVis(
VitroRequest vitroRequest, Log log, Dataset dataset,
String entityURI) throws MalformedQueryParametersException {
if (StringUtils.isBlank(entityURI)) {
entityURI = OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest);
.getStaffProvidedOrComputedHighestLevelOrganization(log,
dataset, vitroRequest);
}
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
}
@Override
@ -72,46 +70,50 @@ 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 {
ModelConstructor constructQueryRunner =
new EntityPublicationCountConstructQueryRunner(subjectEntityURI, dataset, log);
String subjectEntityURI) throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(
subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
subjectEntityURI, constructedModel, log);
Entity entity = queryManager.getQueryResult();
if (entity.getEntityLabel().equals("no-label")) {
return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
} else {
return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, dataset,
subjectEntityURI, entity);
return prepareStandaloneDataErrorResponse(vitroRequest,
subjectEntityURI);
} else {
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.\"}");
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;
}
@ -119,13 +121,12 @@ public class EntityPublicationCountRequestHandler implements
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI, Entity entity)
throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult =
OrganizationUtilityFunctions.getSubEntityTypes(
log, dataset, subjectEntityURI);
return prepareStandaloneDataResponse(vitroRequest, entity, entity.getSubEntities(),
subOrganizationTypesResult);
Map<String, Set<String>> subOrganizationTypesResult = OrganizationUtilityFunctions
.getSubEntityTypes(log, dataset, subjectEntityURI);
return prepareStandaloneDataResponse(vitroRequest, entity, entity
.getSubEntities(), subOrganizationTypesResult);
}
@Override
@ -135,154 +136,155 @@ 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.
* */
* 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(
vitroRequest,
log,
dataset,
OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest));
vitroRequest,
log,
dataset,
OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
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();
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
entityURI, constructedModel, log);
entityURI, constructedModel, log);
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";
}
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_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_NAME_KEY, outputFileName);
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
writePublicationsOverTimeJSON(vitroRequest,
entity.getSubEntities(),
subOrganizationTypesResult));
getEntityPublicationsPerYearCSVContent(subentities,
subOrganizationTypesResult));
return fileData;
}
private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
String entityURI) {
String standaloneTemplate = "entityComparisonOnPublicationsStandalone.ftl";
String organizationLabel = OrganizationUtilityFunctions
.getEntityLabelFromDAO(vreq,
entityURI);
Map<String, Object> body = new HashMap<String, Object>();
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("organizationLabel", organizationLabel);
return new TemplateResponseValues(standaloneTemplate, body);
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);
Map<String, Object> body = new HashMap<String, Object>();
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("organizationLabel", organizationLabel);
return new TemplateResponseValues(standaloneTemplate, body);
}
/**
* Function to generate a json file for year <-> publication count mapping.
* @param vreq
*
* @param vreq
* @param subentities
* @param subOrganizationTypesResult
* @param subOrganizationTypesResult
* @throws MalformedQueryParametersException
*/
private String writePublicationsOverTimeJSON(VitroRequest vreq,
Set<SubEntity> subentities,
Map<String, Set<String>>
subOrganizationTypesResult) {
private String writePublicationsOverTimeJSON(VitroRequest vreq,
Set<SubEntity> subentities,
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,24 +293,26 @@ 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()));
}
currentPubYear.add(pubEntry.getValue());
yearPubCount.add(currentPubYear);
}
entityJson.setYearToActivityCount(yearPubCount);
entityJson.getOrganizationTypes().addAll(
subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.setEntityURI(subentity.getIndividualURI());
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity.getIndividualURI());
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity
.getIndividualURI());
if (isPerson) {
entityJson.setVisMode("PERSON");
} else {
@ -320,28 +324,30 @@ public class EntityPublicationCountRequestHandler implements
}
private String getEntityPublicationsPerYearCSVContent(
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
StringBuilder csvFileContent = new StringBuilder();
csvFileContent.append("Entity Name, Publication Count, Entity Type\n");
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(", ");
StringBuilder joinedTypes = new StringBuilder();
for (String subOrganizationType : subOrganizationTypesResult
.get(subEntity.getIndividualLabel())) {
.get(subEntity.getIndividualLabel())) {
joinedTypes.append(subOrganizationType + "; ");
}
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes.toString()));
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes
.toString()));
csvFileContent.append("\n");
}
return csvFileContent.toString();
@ -353,4 +359,4 @@ public class EntityPublicationCountRequestHandler implements
return null;
}
}
}

View file

@ -34,18 +34,17 @@ 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 {
@Override
public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
return generateStandardVisualizationForGrantTemporalVis(vitroRequest,
log, dataset, entityURI);
}
@ -54,13 +53,11 @@ public class EntityGrantCountRequestHandler implements
VitroRequest vitroRequest, Log log, Dataset dataset,
String entityURI) throws MalformedQueryParametersException {
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));
}
@ -82,89 +83,83 @@ public class EntityGrantCountRequestHandler implements
String entityURI = vitroRequest
.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))) {
.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(
vitroRequest,
log,
dataset,
OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest));
vitroRequest,
log,
dataset,
OrganizationUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
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();
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
entityURI, constructedModel, log);
Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult =
OrganizationUtilityFunctions.getSubEntityTypes(
log, dataset, entityURI);
Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
entityURI, constructedModel, log);
Entity entity = queryManager.getQueryResult();
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 Grant Count "
throw new UnsupportedOperationException("Entity Grant Count "
+ "does not provide Ajax response.");
}
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI)
throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner =
new EntityGrantCountConstructQueryRunner(subjectEntityURI, dataset, log);
String subjectEntityURI) throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(
subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
subjectEntityURI, constructedModel, log);
subjectEntityURI, constructedModel, log);
Entity entity = queryManager.getQueryResult();
if (entity.getEntityLabel().equals("no-label")) {
return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
} else {
return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, dataset,
subjectEntityURI, entity);
return prepareStandaloneDataErrorResponse(vitroRequest,
subjectEntityURI);
} else {
return getSubEntityTypesAndComputeDataResponse(vitroRequest, log,
dataset, subjectEntityURI, entity);
}
}
@ -172,41 +167,39 @@ public class EntityGrantCountRequestHandler implements
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectOrganization, Entity entity)
throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult =
OrganizationUtilityFunctions.getSubEntityTypes(
log, dataset, subjectOrganization);
return prepareStandaloneDataResponse(vitroRequest, entity, subOrganizationTypesResult);
Map<String, Set<String>> subOrganizationTypesResult = OrganizationUtilityFunctions
.getSubEntityTypes(log, dataset, subjectOrganization);
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.\"}");
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) {
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(),
subOrganizationTypesResult));
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
writeGrantsOverTimeJSON(vitroRequest, entity.getSubEntities(),
subOrganizationTypesResult));
return fileData;
}
@ -218,68 +211,75 @@ 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";
}
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_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
getEntityGrantsPerYearCSVContent(subentities, subOrganizationTypesResult));
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));
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);
}
/**
* Function to generate a json file for year <-> grant count mapping.
* @param vreq
*
* @param vreq
* @param subentities
* @param subOrganizationTypesResult
* @param subOrganizationTypesResult
* @throws MalformedQueryParametersException
*/
private String writeGrantsOverTimeJSON(VitroRequest vreq,
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
private String writeGrantsOverTimeJSON(VitroRequest vreq,
Set<SubEntity> subentities,
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,13 +288,12 @@ 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()));
}
currentGrantYear.add(grantEntry.getValue());
yearGrantCount.add(currentGrantYear);
}
@ -304,45 +303,47 @@ public class EntityGrantCountRequestHandler implements
subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.setEntityURI(subentity.getIndividualURI());
if (UtilityFunctions.isEntityAPerson(vreq, subentity.getIndividualURI())) {
if (UtilityFunctions.isEntityAPerson(vreq, subentity
.getIndividualURI())) {
entityJson.setVisMode("PERSON");
} else {
entityJson.setVisMode("ORGANIZATION");
}
}
subEntitiesJson.add(entityJson);
}
return json.toJson(subEntitiesJson);
}
private String getEntityGrantsPerYearCSVContent(
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
private String getEntityGrantsPerYearCSVContent(Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
StringBuilder csvFileContent = new StringBuilder();
csvFileContent.append("Entity Name, Grant Count, Entity Type\n");
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(", ");
StringBuilder joinedTypes = new StringBuilder();
for (String subOrganizationType : subOrganizationTypesResult
.get(subEntity.getIndividualLabel())) {
.get(subEntity.getIndividualLabel())) {
joinedTypes.append(subOrganizationType + "; ");
}
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes.toString()));
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes
.toString()));
csvFileContent.append("\n");
}
}
return csvFileContent.toString();
}
@ -352,5 +353,5 @@ public class EntityGrantCountRequestHandler implements
// TODO Auto-generated method stub
return null;
}
}

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;
@ -261,13 +262,19 @@ 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()
.getIndividualDao()
.getIndividualByURI(individualURI)
.isVClass("http://xmlns.com/foaf/0.1/Person");
public static boolean isEntityAPerson(VitroRequest vreq, String individualURI)
throws MalformedQueryParametersException {
Individual individualByURI = vreq.getWebappDaoFactory()
.getIndividualDao()
.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.");
}
}