1. In Temporal vis developed vis drilling up from lower level. (see http://issues.library.cornell.edu/browse/NIHVIVO-1800)
2. Refactored client-side code for temporal vis.
This commit is contained in:
parent
82c4d1faa7
commit
ae43216396
19 changed files with 449 additions and 78 deletions
|
@ -13,6 +13,10 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#subject-parent-entity {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#error-container {
|
#error-container {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +53,7 @@ img.bar-count-icon {
|
||||||
|
|
||||||
.legend-bar {
|
.legend-bar {
|
||||||
margin-bottom: 3px;
|
margin-bottom: 3px;
|
||||||
|
cursor:default;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unknown-legend-bar {
|
.unknown-legend-bar {
|
||||||
|
|
|
@ -36,6 +36,8 @@ $(document).ready(function() {
|
||||||
|
|
||||||
currentParameter = parameter.name;
|
currentParameter = parameter.name;
|
||||||
selectedDataURL = parameter.dataLink;
|
selectedDataURL = parameter.dataLink;
|
||||||
|
temporalGraphCommonURL = parameter.viewBaseLink;
|
||||||
|
csvDownloadURL = parameter.csvLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -175,47 +177,79 @@ function performEntityCheckboxClickedRedrawActions() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
var processJSONData = {
|
||||||
* function to populate the labelToEntityRecord object with the
|
|
||||||
* values from the json file and
|
isParentEntityAvailable: false,
|
||||||
* dynamically generate checkboxes
|
|
||||||
*/
|
setupGlobals: function(jsonContent) {
|
||||||
function loadData(jsonData, dataTableParams) {
|
$.each(jsonContent, function (index, val) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We are checking if the "label" attribute is present, because that pertains to
|
||||||
|
* data used for linegraph visualization.
|
||||||
|
* */
|
||||||
|
if (val.label) {
|
||||||
|
|
||||||
$.each(jsonData, function (index, val) {
|
|
||||||
setOfLabels.push(val.label);
|
setOfLabels.push(val.label);
|
||||||
URIToEntityRecord[val.entityURI] = val;
|
URIToEntityRecord[val.entityURI] = val;
|
||||||
if (val.lastCachedAtDateTime) {
|
if (val.lastCachedAtDateTime) {
|
||||||
lastCachedAtDateTimes[lastCachedAtDateTimes.length] = val.lastCachedAtDateTime;
|
lastCachedAtDateTimes[lastCachedAtDateTimes.length] = val.lastCachedAtDateTime;
|
||||||
}
|
}
|
||||||
|
} else if (val.subjectEntityLabel) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is to set the drill-up visualization URLs.
|
||||||
|
* */
|
||||||
|
$.each(val.parentURIToLabel, function(index, value) {
|
||||||
|
|
||||||
|
$("a#subject-parent-entity-temporal-url").attr("href", getTemporalVisURL(index));
|
||||||
|
|
||||||
|
$("a#subject-parent-entity-profile-url").attr("href", getVIVOURL(index));
|
||||||
|
$("a#subject-parent-entity-profile-url").text(value);
|
||||||
|
|
||||||
|
processJSONData.isParentEntityAvailable = true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (processJSONData.isParentEntityAvailable) {
|
||||||
|
$("#subject-parent-entity").show();
|
||||||
|
} else {
|
||||||
|
$("#subject-parent-entity").hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* function to populate the labelToEntityRecord object with the
|
||||||
|
* values from the json file and
|
||||||
|
* dynamically generate checkboxes
|
||||||
|
*/
|
||||||
|
loadData: function(jsonData, dataTableParams) {
|
||||||
|
|
||||||
|
processJSONData.setupGlobals(jsonData);
|
||||||
|
|
||||||
prepareTableForDataTablePagination(jsonData, dataTableParams);
|
prepareTableForDataTablePagination(jsonData, dataTableParams);
|
||||||
setEntityLevel(getEntityVisMode(jsonData));
|
setEntityLevel(getEntityVisMode(jsonData));
|
||||||
|
|
||||||
entityCheckboxOperatedOnEventListener();
|
entityCheckboxOperatedOnEventListener();
|
||||||
|
},
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function to populate the labelToEntityRecord object with the
|
* function to populate the labelToEntityRecord object with the
|
||||||
* values from the json file and
|
* values from the json file and
|
||||||
* dynamically generate checkboxes
|
* dynamically generate checkboxes
|
||||||
*/
|
*/
|
||||||
function reloadData(preselectedEntityURIs, jsonData) {
|
reloadData: function(preselectedEntityURIs, jsonData) {
|
||||||
|
|
||||||
$.each(jsonData, function (index, val) {
|
processJSONData.setupGlobals(jsonData);
|
||||||
setOfLabels.push(val.label);
|
|
||||||
URIToEntityRecord[val.entityURI] = val;
|
|
||||||
if (val.lastCachedAtDateTime) {
|
|
||||||
lastCachedAtDateTimes[lastCachedAtDateTimes.length] = val.lastCachedAtDateTime;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
reloadDataTablePagination(preselectedEntityURIs, jsonData);
|
reloadDataTablePagination(preselectedEntityURIs, jsonData);
|
||||||
setEntityLevel(getEntityVisMode(jsonData));
|
setEntityLevel(getEntityVisMode(jsonData));
|
||||||
|
|
||||||
|
$("a#csv").attr("href", csvDownloadURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
function entityCheckboxOperatedOnEventListener() {
|
function entityCheckboxOperatedOnEventListener() {
|
||||||
|
|
||||||
|
@ -394,7 +428,7 @@ temporalGraphProcessor = {
|
||||||
/*
|
/*
|
||||||
* render the temporal graph per the sent content.
|
* render the temporal graph per the sent content.
|
||||||
* */
|
* */
|
||||||
loadData(jsonData, this.dataTableParams);
|
processJSONData.loadData(jsonData, this.dataTableParams);
|
||||||
|
|
||||||
lastCachedAtDateTimes.sort(lastCachedAtDateTimeParser.ascendingDateSorter);
|
lastCachedAtDateTimes.sort(lastCachedAtDateTimeParser.ascendingDateSorter);
|
||||||
|
|
||||||
|
@ -438,7 +472,7 @@ temporalGraphProcessor = {
|
||||||
/*
|
/*
|
||||||
* render the temporal graph per the sent content.
|
* render the temporal graph per the sent content.
|
||||||
* */
|
* */
|
||||||
reloadData(currentSelectedEntityURIs, jsonData);
|
processJSONData.reloadData(currentSelectedEntityURIs, jsonData);
|
||||||
|
|
||||||
lastCachedAtDateTimes.sort(lastCachedAtDateTimeParser.ascendingDateSorter);
|
lastCachedAtDateTimes.sort(lastCachedAtDateTimeParser.ascendingDateSorter);
|
||||||
|
|
||||||
|
|
|
@ -640,7 +640,7 @@ function createLegendRow(entity, bottomDiv) {
|
||||||
* there is no drill-down possible, so don't diaply the temporal graph icon.
|
* there is no drill-down possible, so don't diaply the temporal graph icon.
|
||||||
* */
|
* */
|
||||||
if (entity.visMode !== "PERSON") {
|
if (entity.visMode !== "PERSON") {
|
||||||
labelDiv.append('<a class="temporal-vis-url" href="' + getTemporalVisURL(entity) + '"><img src = "' + temporalGraphSmallIcon + '"/></a>');
|
labelDiv.append('<a class="temporal-vis-url" href="' + getTemporalVisURL(entity.entityURI) + '"><img src = "' + temporalGraphSmallIcon + '"/></a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ function createLegendRow(entity, bottomDiv) {
|
||||||
checkbox.attr('checked', true);
|
checkbox.attr('checked', true);
|
||||||
checkbox.attr('id', 'checkbox');
|
checkbox.attr('id', 'checkbox');
|
||||||
checkbox.attr('class', 'easyDeselectCheckbox');
|
checkbox.attr('class', 'easyDeselectCheckbox');
|
||||||
checkbox.attr('value', entity.label);
|
checkbox.attr('value', entity.entityURI);
|
||||||
|
|
||||||
var hiddenLabel = $('<label>');
|
var hiddenLabel = $('<label>');
|
||||||
hiddenLabel.attr('type', 'hidden');
|
hiddenLabel.attr('type', 'hidden');
|
||||||
|
@ -720,7 +720,7 @@ function renderBarAndLabel(entity, divBar, divLabel, spanElement) {
|
||||||
var entityLabelForLegend = divLabel.find(".entity-label-url");
|
var entityLabelForLegend = divLabel.find(".entity-label-url");
|
||||||
entityLabelForLegend.html(entity.label);
|
entityLabelForLegend.html(entity.label);
|
||||||
entityLabelForLegend.ellipsis();
|
entityLabelForLegend.ellipsis();
|
||||||
entityLabelForLegend.wrap("<a class='entity-url' title='" + entity.label + "' href='" + getVIVOURL(entity) + "'></a>");
|
entityLabelForLegend.wrap("<a class='entity-url' title='" + entity.label + "' href='" + getVIVOURL(entity.entityURI) + "'></a>");
|
||||||
|
|
||||||
var countExplanation = 'VIVO knows the ' + COMPARISON_PARAMETERS_INFO[currentParameter].name + ' year for '
|
var countExplanation = 'VIVO knows the ' + COMPARISON_PARAMETERS_INFO[currentParameter].name + ' year for '
|
||||||
+ combinedCount.knownYearCount + ' out of '
|
+ combinedCount.knownYearCount + ' out of '
|
||||||
|
@ -731,16 +731,15 @@ function renderBarAndLabel(entity, divBar, divLabel, spanElement) {
|
||||||
spanElement.text(sum).css("font-size", "0.8em").css("color", "#595B5B");
|
spanElement.text(sum).css("font-size", "0.8em").css("color", "#595B5B");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVIVOURL(entity){
|
function getVIVOURL(entityURI){
|
||||||
|
|
||||||
var result = subOrganizationVivoProfileURL + "uri="+entity.entityURI;
|
return subOrganizationVivoProfileURL + "uri=" + entityURI;
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTemporalVisURL(entity) {
|
function getTemporalVisURL(entityURI) {
|
||||||
|
|
||||||
return subOrganizationTemporalGraphURL + "&uri=" + entity.entityURI ;
|
return temporalGraphCommonURL + "&uri=" + entityURI ;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVIVOProfileURL(given_uri) {
|
function getVIVOProfileURL(given_uri) {
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
<div id="body">
|
<div id="body">
|
||||||
|
|
||||||
|
<div id="subject-parent-entity">
|
||||||
|
<a id="subject-parent-entity-profile-url" href="#"></a>
|
||||||
|
<a id="subject-parent-entity-temporal-url" href="#"><img src="${temporalGraphSmallIcon}" width="15px" height="15px"/></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h2 id="header-entity-label"><span><a id="organizationMoniker" href="${organizationVivoProfileURL}">${organizationLabel}</a>
|
<h2 id="header-entity-label"><span><a id="organizationMoniker" href="${organizationVivoProfileURL}">${organizationLabel}</a>
|
||||||
<img id="incomplete-data-disclaimer" class="infoIcon" src="${urls.images}/iconInfo.png" alt="information icon" title="This information is based solely on ${currentParameterObject.value} which have been loaded into the VIVO system" /></span></h2>
|
<img id="incomplete-data-disclaimer" class="infoIcon" src="${urls.images}/iconInfo.png" alt="information icon" title="This information is based solely on ${currentParameterObject.value} which have been loaded into the VIVO system" /></span></h2>
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ var currentParameter = "${currentParameter}";
|
||||||
/*
|
/*
|
||||||
This is used in util.js to print grant temporal graph links for all sub-organizations.
|
This is used in util.js to print grant temporal graph links for all sub-organizations.
|
||||||
*/
|
*/
|
||||||
var subOrganizationTemporalGraphURL = "${subOrganizationGrantTemporalGraphCommonURL}";
|
var temporalGraphCommonURL = subOrganizationGrantTemporalGraphCommonURL;
|
||||||
|
|
||||||
var temporalGraphDataURL = '${temporalGraphDataURL}';
|
var temporalGraphDataURL = '${temporalGraphDataURL}';
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ $(document).ready(function () {
|
||||||
<#include "entityComparisonBody.ftl">
|
<#include "entityComparisonBody.ftl">
|
||||||
|
|
||||||
<#--
|
<#--
|
||||||
Right now we include the error message by default becuae currently I could not devise any more smarted solution. By default
|
Right now we include the error message by default because currently I could not devise any more smarted solution. By default
|
||||||
the CSS of the #error-container is display:none; so it will be hidden unless explicitly commanded to be shown which we do in
|
the CSS of the #error-container is display:none; so it will be hidden unless explicitly commanded to be shown which we do in
|
||||||
via JavaScript.
|
via JavaScript.
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -23,7 +23,7 @@ var currentParameter = "${currentParameter}";
|
||||||
/*
|
/*
|
||||||
This is used in util.js to print grant temporal graph links for all sub-organizations.
|
This is used in util.js to print grant temporal graph links for all sub-organizations.
|
||||||
*/
|
*/
|
||||||
var subOrganizationTemporalGraphURL = "${subOrganizationPublicationTemporalGraphCommonURL}";
|
var temporalGraphCommonURL = subOrganizationPublicationTemporalGraphCommonURL;
|
||||||
|
|
||||||
var temporalGraphDataURL = '${temporalGraphDataURL}';
|
var temporalGraphDataURL = '${temporalGraphDataURL}';
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ $(document).ready(function () {
|
||||||
<#include "entityComparisonBody.ftl">
|
<#include "entityComparisonBody.ftl">
|
||||||
|
|
||||||
<#--
|
<#--
|
||||||
Right now we include the error message by default becuae currently I could not devise any more smarted solution. By default
|
Right now we include the error message by default because currently I could not devise any more smarted solution. By default
|
||||||
the CSS of the #error-container is display:none; so it will be hidden unless explicitly commanded to be shown which we do in
|
the CSS of the #error-container is display:none; so it will be hidden unless explicitly commanded to be shown which we do in
|
||||||
via JavaScript.
|
via JavaScript.
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -26,14 +26,18 @@
|
||||||
"pluralName": "publications",
|
"pluralName": "publications",
|
||||||
"dropDownText": "by Publications",
|
"dropDownText": "by Publications",
|
||||||
"viewLink": "${organizationPublicationTemporalGraphURL}",
|
"viewLink": "${organizationPublicationTemporalGraphURL}",
|
||||||
|
"viewBaseLink": "${subOrganizationPublicationTemporalGraphCommonURL}",
|
||||||
"dataLink": "${organizationPublicationTemporalGraphDataURL}",
|
"dataLink": "${organizationPublicationTemporalGraphDataURL}",
|
||||||
|
"csvLink": "${temporalGraphDownloadCSVCommonURL}&vis=entity_comparison",
|
||||||
"value": "Publications" }>
|
"value": "Publications" }>
|
||||||
|
|
||||||
<#assign grantParameter = { "name": "grant",
|
<#assign grantParameter = { "name": "grant",
|
||||||
"pluralName": "grants",
|
"pluralName": "grants",
|
||||||
"dropDownText": "by Grants",
|
"dropDownText": "by Grants",
|
||||||
"viewLink": "${organizationGrantTemporalGraphURL}",
|
"viewLink": "${organizationGrantTemporalGraphURL}",
|
||||||
|
"viewBaseLink": "${subOrganizationGrantTemporalGraphCommonURL}",
|
||||||
"dataLink": "${organizationGrantTemporalGraphDataURL}",
|
"dataLink": "${organizationGrantTemporalGraphDataURL}",
|
||||||
|
"csvLink": "${temporalGraphDownloadCSVCommonURL}&vis=entity_grant_count",
|
||||||
"value": "Grants" }>
|
"value": "Grants" }>
|
||||||
|
|
||||||
<#assign parameterOptions = [publicationParameter, grantParameter]>
|
<#assign parameterOptions = [publicationParameter, grantParameter]>
|
||||||
|
@ -86,6 +90,9 @@ var contextPath = "${urls.base}";
|
||||||
var temporalGraphSmallIcon = "${temporalGraphSmallIcon}";
|
var temporalGraphSmallIcon = "${temporalGraphSmallIcon}";
|
||||||
var subOrganizationVivoProfileURL = "${subOrganizationVivoProfileURL}";
|
var subOrganizationVivoProfileURL = "${subOrganizationVivoProfileURL}";
|
||||||
|
|
||||||
|
var subOrganizationGrantTemporalGraphCommonURL = "${subOrganizationGrantTemporalGraphCommonURL}";
|
||||||
|
var subOrganizationPublicationTemporalGraphCommonURL = "${subOrganizationPublicationTemporalGraphCommonURL}";
|
||||||
|
|
||||||
var jsonString = '${jsonContent!}';
|
var jsonString = '${jsonContent!}';
|
||||||
var organizationLabel = '${organizationLabel}';
|
var organizationLabel = '${organizationLabel}';
|
||||||
var organizationVIVOProfileURL = "${organizationVivoProfileURL}";
|
var organizationVIVOProfileURL = "${organizationVivoProfileURL}";
|
||||||
|
@ -97,7 +104,7 @@ var entityCheckboxSelectorDOMClass = "${entityCheckboxSelectorDOMClass}";
|
||||||
|
|
||||||
var isDataRequestSentViaAJAX = false;
|
var isDataRequestSentViaAJAX = false;
|
||||||
|
|
||||||
var temporalGraphProcessor;
|
var csvDownloadURL, temporalGraphProcessor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This has to be declared before making a call to GUI event manager JS.
|
This has to be declared before making a call to GUI event manager JS.
|
||||||
|
|
|
@ -93,6 +93,12 @@ public class QueryFieldLabels {
|
||||||
public static final String SUBORGANIZATION_URL = "subOrganizationLit";
|
public static final String SUBORGANIZATION_URL = "subOrganizationLit";
|
||||||
public static final String SUBORGANIZATION_LABEL = "subOrganizationLabelLit";
|
public static final String SUBORGANIZATION_LABEL = "subOrganizationLabelLit";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parent Organization related field labels
|
||||||
|
*/
|
||||||
|
public static final String PARENT_ORGANIZATION_URL = "parentOrganizationLit";
|
||||||
|
public static final String PARENT_ORGANIZATION_LABEL = "parentOrganizationLabelLit";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sub Organization related field labels
|
* Sub Organization related field labels
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -172,11 +172,23 @@ public class EntityComparisonUtilityFunctions {
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(entityA.getEntityURI(), entityB.getEntityURI())) {
|
if (StringUtils.equalsIgnoreCase(entityA.getEntityURI(), entityB.getEntityURI())) {
|
||||||
|
|
||||||
Entity mergedEntity = new Entity(entityA.getEntityURI(), entityA.getEntityLabel());
|
Entity mergedEntity = new Entity(entityA.getEntityURI());
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(entityA.getEntityLabel())) {
|
||||||
|
|
||||||
|
mergedEntity.setEntityLabel(entityA.getEntityLabel());
|
||||||
|
|
||||||
|
} else if (StringUtils.isNotBlank(entityB.getEntityLabel())) {
|
||||||
|
|
||||||
|
mergedEntity.setEntityLabel(entityB.getEntityLabel());
|
||||||
|
}
|
||||||
|
|
||||||
mergedEntity.addSubEntitities(entityA.getSubEntities());
|
mergedEntity.addSubEntitities(entityA.getSubEntities());
|
||||||
mergedEntity.addSubEntitities(entityB.getSubEntities());
|
mergedEntity.addSubEntitities(entityB.getSubEntities());
|
||||||
|
|
||||||
|
mergedEntity.addParents(entityA.getParents());
|
||||||
|
mergedEntity.addParents(entityB.getParents());
|
||||||
|
|
||||||
return mergedEntity;
|
return mergedEntity;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Co
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubjectEntityJSON;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.SelectOnModelUtilities;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.SelectOnModelUtilities;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||||
|
@ -221,7 +222,7 @@ public class TemporalGrantVisualizationRequestHandler implements
|
||||||
"application/octet-stream");
|
"application/octet-stream");
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||||
writeGrantsOverTimeJSON(vitroRequest,
|
writeGrantsOverTimeJSON(vitroRequest,
|
||||||
entity.getSubEntities()));
|
entity));
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,12 +286,12 @@ public class TemporalGrantVisualizationRequestHandler implements
|
||||||
* @param subOrganizationTypesResult
|
* @param subOrganizationTypesResult
|
||||||
*/
|
*/
|
||||||
private String writeGrantsOverTimeJSON(VitroRequest vreq,
|
private String writeGrantsOverTimeJSON(VitroRequest vreq,
|
||||||
Set<SubEntity> subentities) {
|
Entity subjectEntity) {
|
||||||
|
|
||||||
Gson json = new Gson();
|
Gson json = new Gson();
|
||||||
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
|
Set jsonifiedResponse = new HashSet();
|
||||||
|
|
||||||
for (SubEntity subentity : subentities) {
|
for (SubEntity subentity : subjectEntity.getSubEntities()) {
|
||||||
JsonObject entityJson = new JsonObject(
|
JsonObject entityJson = new JsonObject(
|
||||||
subentity.getIndividualLabel());
|
subentity.getIndividualLabel());
|
||||||
|
|
||||||
|
@ -326,10 +327,17 @@ public class TemporalGrantVisualizationRequestHandler implements
|
||||||
entityJson.setVisMode("ORGANIZATION");
|
entityJson.setVisMode("ORGANIZATION");
|
||||||
}
|
}
|
||||||
|
|
||||||
subEntitiesJson.add(entityJson);
|
jsonifiedResponse.add(entityJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.toJson(subEntitiesJson);
|
|
||||||
|
SubjectEntityJSON subjectEntityJSON = new SubjectEntityJSON(subjectEntity.getEntityLabel(),
|
||||||
|
subjectEntity.getEntityURI(),
|
||||||
|
subjectEntity.getParents());
|
||||||
|
|
||||||
|
jsonifiedResponse.add(subjectEntityJSON);
|
||||||
|
|
||||||
|
return json.toJson(jsonifiedResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEntityGrantsPerYearCSVContent(Entity entity) {
|
private String getEntityGrantsPerYearCSVContent(Entity entity) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Ac
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubjectEntityJSON;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.SelectOnModelUtilities;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.SelectOnModelUtilities;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||||
|
@ -89,7 +90,6 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
||||||
Entity organizationWithAssociatedPeople = SelectOnModelUtilities
|
Entity organizationWithAssociatedPeople = SelectOnModelUtilities
|
||||||
.getSubjectOrganizationAssociatedPeople(dataset, subjectEntityURI);
|
.getSubjectOrganizationAssociatedPeople(dataset, subjectEntityURI);
|
||||||
|
|
||||||
|
|
||||||
if (organizationWithAssociatedPeople.getSubEntities() != null) {
|
if (organizationWithAssociatedPeople.getSubEntities() != null) {
|
||||||
|
|
||||||
documentURIForAssociatedPeopleTOVO = SelectOnModelUtilities
|
documentURIForAssociatedPeopleTOVO = SelectOnModelUtilities
|
||||||
|
@ -247,7 +247,7 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
||||||
"application/octet-stream");
|
"application/octet-stream");
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||||
writePublicationsOverTimeJSON(vitroRequest,
|
writePublicationsOverTimeJSON(vitroRequest,
|
||||||
entity.getSubEntities()));
|
entity));
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,12 +277,12 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
||||||
* @param subOrganizationTypesResult
|
* @param subOrganizationTypesResult
|
||||||
*/
|
*/
|
||||||
private String writePublicationsOverTimeJSON(VitroRequest vreq,
|
private String writePublicationsOverTimeJSON(VitroRequest vreq,
|
||||||
Set<SubEntity> subentities) {
|
Entity subjectEntity) {
|
||||||
|
|
||||||
Gson json = new Gson();
|
Gson json = new Gson();
|
||||||
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
|
Set subEntitiesJson = new HashSet();
|
||||||
|
|
||||||
for (SubEntity subentity : subentities) {
|
for (SubEntity subentity : subjectEntity.getSubEntities()) {
|
||||||
|
|
||||||
JsonObject entityJson = new JsonObject(
|
JsonObject entityJson = new JsonObject(
|
||||||
subentity.getIndividualLabel());
|
subentity.getIndividualLabel());
|
||||||
|
@ -320,6 +320,13 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
||||||
|
|
||||||
subEntitiesJson.add(entityJson);
|
subEntitiesJson.add(entityJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SubjectEntityJSON subjectEntityJSON = new SubjectEntityJSON(subjectEntity.getEntityLabel(),
|
||||||
|
subjectEntity.getEntityURI(),
|
||||||
|
subjectEntity.getParents());
|
||||||
|
|
||||||
|
subEntitiesJson.add(subjectEntityJSON);
|
||||||
|
|
||||||
return json.toJson(subEntitiesJson);
|
return json.toJson(subEntitiesJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructo
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PeopleToPublicationsFactory;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PeopleToPublicationsFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PersonToGrantsFactory;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PersonToGrantsFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PersonToPublicationsFactory;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PersonToPublicationsFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.SubOrganizationWithinModelFactory;
|
||||||
|
|
||||||
public class ModelConstructorUtilities {
|
public class ModelConstructorUtilities {
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ public class ModelConstructorUtilities {
|
||||||
put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToGrantsForSubOrganizationsFactory());
|
put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToGrantsForSubOrganizationsFactory());
|
||||||
put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new OrganizationAssociatedPeopleModelWithTypesFactory());
|
put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new OrganizationAssociatedPeopleModelWithTypesFactory());
|
||||||
put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new OrganizationModelWithTypesFactory());
|
put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new OrganizationModelWithTypesFactory());
|
||||||
|
put(SubOrganizationWithinModelConstructor.MODEL_TYPE, new SubOrganizationWithinModelFactory());
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public static Model getOrConstructModel(String uri, String modelType, Dataset dataset)
|
public static Model getOrConstructModel(String uri, String modelType, Dataset dataset)
|
||||||
|
|
|
@ -70,8 +70,6 @@ public class OrganizationModelWithTypesConstructor implements ModelConstructor {
|
||||||
|
|
||||||
private Model executeQuery(String constructQuery) {
|
private Model executeQuery(String constructQuery) {
|
||||||
|
|
||||||
System.out.println("in constructed model fior organization");
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
before = System.currentTimeMillis();
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
import com.hp.hpl.jena.query.Query;
|
||||||
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
|
|
||||||
|
public class SubOrganizationWithinModelConstructor implements ModelConstructor {
|
||||||
|
|
||||||
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
|
public static final String MODEL_TYPE = "SUBORGANIZATION_WITHIN_HIERARCHY_MODEL";
|
||||||
|
|
||||||
|
private Dataset dataset;
|
||||||
|
|
||||||
|
private Model constructedModel;
|
||||||
|
|
||||||
|
private Log log = LogFactory.getLog(SubOrganizationWithinModelConstructor.class.getName());
|
||||||
|
|
||||||
|
private long before, after;
|
||||||
|
|
||||||
|
public SubOrganizationWithinModelConstructor(Dataset dataset) {
|
||||||
|
this.dataset = dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor is present so that we can abstract out the model construction process.
|
||||||
|
* @param uri
|
||||||
|
* @param dataset
|
||||||
|
*/
|
||||||
|
public SubOrganizationWithinModelConstructor(String uri, Dataset dataset) {
|
||||||
|
this.dataset = dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String constructAllSubOrganizationsWithinQuery() {
|
||||||
|
return ""
|
||||||
|
+ " CONSTRUCT { "
|
||||||
|
+ " ?organization rdf:type foaf:Organization . "
|
||||||
|
+ " ?organization rdfs:label ?organizationLabel . "
|
||||||
|
+ " ?organization core:subOrganizationWithin ?parentOrganization . "
|
||||||
|
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
||||||
|
+ " } "
|
||||||
|
+ " WHERE { "
|
||||||
|
+ " ?organization rdf:type foaf:Organization . "
|
||||||
|
+ " ?organization rdfs:label ?organizationLabel . "
|
||||||
|
+ " "
|
||||||
|
+ " OPTIONAL { "
|
||||||
|
+ " ?organization core:subOrganizationWithin ?parentOrganization . "
|
||||||
|
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
||||||
|
+ " } "
|
||||||
|
+ " } ";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Model executeQuery(String constructQuery) {
|
||||||
|
|
||||||
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
before = System.currentTimeMillis();
|
||||||
|
log.debug("CONSTRUCT query string : " + constructQuery);
|
||||||
|
|
||||||
|
Query query = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery()
|
||||||
|
+ constructQuery, SYNTAX);
|
||||||
|
} catch (Throwable th) {
|
||||||
|
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||||
|
+ "string. " + th.getMessage());
|
||||||
|
log.error(constructQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
return constructedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getConstructedModel() throws MalformedQueryParametersException {
|
||||||
|
|
||||||
|
if (constructedModel != null && !constructedModel.isEmpty()) {
|
||||||
|
return constructedModel;
|
||||||
|
} else {
|
||||||
|
constructedModel = executeQuery(constructAllSubOrganizationsWithinQuery());
|
||||||
|
return constructedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.SubOrganizationWithinModelConstructor;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.ConstructedModelTracker;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
|
|
||||||
|
public class SubOrganizationWithinModelFactory implements ModelFactoryInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException {
|
||||||
|
|
||||||
|
Model candidateModel = ConstructedModelTracker.getModel(
|
||||||
|
ConstructedModelTracker
|
||||||
|
.generateModelIdentifier(
|
||||||
|
null,
|
||||||
|
SubOrganizationWithinModelConstructor.MODEL_TYPE));
|
||||||
|
|
||||||
|
if (candidateModel != null) {
|
||||||
|
|
||||||
|
return candidateModel;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
ModelConstructor model = new SubOrganizationWithinModelConstructor(dataset);
|
||||||
|
Model constructedModel = model.getConstructedModel();
|
||||||
|
|
||||||
|
ConstructedModelTracker.trackModel(
|
||||||
|
ConstructedModelTracker
|
||||||
|
.generateModelIdentifier(
|
||||||
|
null,
|
||||||
|
SubOrganizationWithinModelConstructor.MODEL_TYPE),
|
||||||
|
constructedModel);
|
||||||
|
|
||||||
|
return constructedModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class Entity extends Individual {
|
public class Entity extends Individual {
|
||||||
|
|
||||||
|
private Set<Individual> parents = new LinkedHashSet<Individual>();
|
||||||
private Set<SubEntity> children = new LinkedHashSet<SubEntity>();
|
private Set<SubEntity> children = new LinkedHashSet<SubEntity>();
|
||||||
|
|
||||||
public Entity(String entityURI, String entityLabel) {
|
public Entity(String entityURI, String entityLabel) {
|
||||||
|
@ -29,10 +30,18 @@ public class Entity extends Individual {
|
||||||
return this.getIndividualLabel();
|
return this.getIndividualLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEntityLabel(String label) {
|
||||||
|
this.setIndividualLabel(label);
|
||||||
|
}
|
||||||
|
|
||||||
public Set<SubEntity> getSubEntities() {
|
public Set<SubEntity> getSubEntities() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Individual> getParents() {
|
||||||
|
return parents;
|
||||||
|
}
|
||||||
|
|
||||||
public void addSubEntity(SubEntity subEntity) {
|
public void addSubEntity(SubEntity subEntity) {
|
||||||
this.children.add(subEntity);
|
this.children.add(subEntity);
|
||||||
}
|
}
|
||||||
|
@ -41,4 +50,8 @@ public class Entity extends Individual {
|
||||||
this.children.addAll(subEntities);
|
this.children.addAll(subEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addParents(Collection<Individual> parents) {
|
||||||
|
this.parents.addAll(parents);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects;
|
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class SubjectEntityJSON {
|
||||||
|
|
||||||
|
private String subjectEntityLabel;
|
||||||
|
private String subjectEntityURI;
|
||||||
|
private Map<String, String> parentURIToLabel = new HashMap<String, String>();
|
||||||
|
|
||||||
|
public SubjectEntityJSON(String subjectEntityURI, String label,
|
||||||
|
Set<Individual> parentOrganizations) {
|
||||||
|
this.subjectEntityURI = subjectEntityURI;
|
||||||
|
this.subjectEntityLabel = label;
|
||||||
|
|
||||||
|
this.setParentURIToLabel(parentOrganizations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubjectEntityURI() {
|
||||||
|
return subjectEntityURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubjectEntityURI(String subjectEntityURI) {
|
||||||
|
this.subjectEntityURI = subjectEntityURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubjectEntityLabel() {
|
||||||
|
return subjectEntityLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubjectEntityLabel(String label) {
|
||||||
|
this.subjectEntityLabel = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getParentURIToLabel() {
|
||||||
|
return parentURIToLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentURIToLabel(Set<Individual> parentOrganizations) {
|
||||||
|
for (Individual parentOrganization : parentOrganizations) {
|
||||||
|
this.parentURIToLabel.put(parentOrganization.getIndividualURI(), parentOrganization.getIndividualLabel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,8 +25,10 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructo
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PeopleToGrantsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PeopleToGrantsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PeopleToPublicationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PeopleToPublicationsModelConstructor;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.SubOrganizationWithinModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||||
|
|
||||||
public class SelectOnModelUtilities {
|
public class SelectOnModelUtilities {
|
||||||
|
@ -59,8 +61,82 @@ public class SelectOnModelUtilities {
|
||||||
"",
|
"",
|
||||||
organizationModel);
|
organizationModel);
|
||||||
|
|
||||||
return getEntityWithSubOrganizations(subjectEntityURI,
|
Entity entityWithSubOrganizations = getEntityWithSubOrganizations(subjectEntityURI,
|
||||||
subOrganizationsWithTypesQuery.getQueryResult());
|
subOrganizationsWithTypesQuery.getQueryResult());
|
||||||
|
|
||||||
|
Entity entityWithParentOrganizations = getAllParentOrganizations(dataset, subjectEntityURI);
|
||||||
|
|
||||||
|
entityWithSubOrganizations.addParents(entityWithParentOrganizations.getParents());
|
||||||
|
|
||||||
|
return entityWithSubOrganizations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Entity getAllParentOrganizations(Dataset dataset,
|
||||||
|
String subjectEntityURI) throws MalformedQueryParametersException {
|
||||||
|
Model organizationModel = ModelConstructorUtilities
|
||||||
|
.getOrConstructModel(
|
||||||
|
null,
|
||||||
|
SubOrganizationWithinModelConstructor.MODEL_TYPE,
|
||||||
|
dataset);
|
||||||
|
|
||||||
|
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||||
|
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
||||||
|
fieldLabelToOutputFieldLabel.put("parentOrganization", QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
||||||
|
fieldLabelToOutputFieldLabel.put("parentOrganizationLabel", QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
||||||
|
|
||||||
|
String whereClause = ""
|
||||||
|
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
||||||
|
+ " <" + subjectEntityURI + "> core:subOrganizationWithin ?parentOrganization . "
|
||||||
|
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . ";
|
||||||
|
|
||||||
|
QueryRunner<ResultSet> parentOrganizationsQuery =
|
||||||
|
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||||
|
"",
|
||||||
|
whereClause,
|
||||||
|
"",
|
||||||
|
organizationModel);
|
||||||
|
|
||||||
|
return getEntityWithParentOrganizations(subjectEntityURI,
|
||||||
|
parentOrganizationsQuery.getQueryResult());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Entity getEntityWithParentOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
||||||
|
|
||||||
|
Entity entity = new Entity(subjectEntityURI);
|
||||||
|
Map<String, Individual> parentOrganizationURIToVO = new HashMap<String, Individual>();
|
||||||
|
|
||||||
|
while (queryResult.hasNext()) {
|
||||||
|
|
||||||
|
QuerySolution solution = queryResult.nextSolution();
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
||||||
|
|
||||||
|
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
||||||
|
if (organizationLabelNode != null) {
|
||||||
|
entity.setIndividualLabel(organizationLabelNode.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RDFNode parentOrganizationNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
||||||
|
|
||||||
|
Individual parent;
|
||||||
|
|
||||||
|
if (!parentOrganizationURIToVO.containsKey(parentOrganizationNode.toString())) {
|
||||||
|
|
||||||
|
parent = new Individual(parentOrganizationNode.toString());
|
||||||
|
|
||||||
|
parentOrganizationURIToVO.put(parentOrganizationNode.toString(), parent);
|
||||||
|
|
||||||
|
RDFNode parentOrganizationLabelNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
||||||
|
if (parentOrganizationLabelNode != null) {
|
||||||
|
parent.setIndividualLabel(parentOrganizationLabelNode.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.addParents(parentOrganizationURIToVO.values());
|
||||||
|
|
||||||
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Entity getEntityWithSubOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
private static Entity getEntityWithSubOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
||||||
|
@ -76,7 +152,8 @@ public class SelectOnModelUtilities {
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
||||||
if (organizationLabelNode != null) {
|
if (organizationLabelNode != null) {
|
||||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
|
||||||
|
entity.setEntityLabel(organizationLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue