1. Fix for issue http://issues.library.cornell.edu/browse/NIHVIVO-3019
2. Also changed the text in different cases for the error. Code reviewed by Chin Hua.
This commit is contained in:
parent
7a3f04be63
commit
54b390b851
7 changed files with 137 additions and 36 deletions
|
@ -233,3 +233,8 @@ a.map-of-science-links {
|
||||||
color: #84a655;
|
color: #84a655;
|
||||||
font-size:16px;
|
font-size:16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.error-list li {
|
||||||
|
font-size: 0.81em;
|
||||||
|
list-style: disc inside none;
|
||||||
|
}
|
100
productMods/js/visualization/mapofscience/ErrorDisplayWidget.js
Normal file
100
productMods/js/visualization/mapofscience/ErrorDisplayWidget.js
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
var ErrorDisplayWidget = Class.extend({
|
||||||
|
|
||||||
|
container: '',
|
||||||
|
body: '',
|
||||||
|
bodyID: 'error-body',
|
||||||
|
messagePlaceholderID: 'variable-error-text',
|
||||||
|
|
||||||
|
init: function(opts) {
|
||||||
|
|
||||||
|
this.container = $("#" + opts.containerID);
|
||||||
|
this.body = this.container.find("#" + this.bodyID);
|
||||||
|
},
|
||||||
|
|
||||||
|
isErrorConditionTriggered: function(responseData) {
|
||||||
|
|
||||||
|
if (responseData.error) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseData[0].pubsMapped === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
show: function(errorForType, responseData) {
|
||||||
|
|
||||||
|
var isZeroPublicationsCase = responseData.error ? true : false;
|
||||||
|
var newErrorMessage = "";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This means that the organization or person has zero publications.
|
||||||
|
* */
|
||||||
|
if (isZeroPublicationsCase) {
|
||||||
|
|
||||||
|
newErrorMessage += "No publications in the system have been attributed to this " + errorForType.toLowerCase() + ".";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* This means that the organization or person has publications but none of them are mapped.
|
||||||
|
* Change the default text.
|
||||||
|
* */
|
||||||
|
newErrorMessage += this._getUnScienceLocatedErrorMessage(errorForType, responseData[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now replace the error message with the newly created one.
|
||||||
|
* */
|
||||||
|
this.body.find("#" + this.messagePlaceholderID).html(newErrorMessage);
|
||||||
|
|
||||||
|
this.container.show();
|
||||||
|
},
|
||||||
|
|
||||||
|
_getUnScienceLocatedErrorMessage: function(errorForType, responseData) {
|
||||||
|
|
||||||
|
var totalPublications = responseData.pubsWithNoJournals + responseData.pubsWithInvalidJournals;
|
||||||
|
var newErrorMessage = "";
|
||||||
|
|
||||||
|
if (totalPublications > 1) {
|
||||||
|
newErrorMessage = "None of the " + totalPublications + " publications attributed to this "
|
||||||
|
+ errorForType.toLowerCase() + " have been 'science-located'.";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
newErrorMessage = "The publication attributed to this "
|
||||||
|
+ errorForType.toLowerCase() + " has not been 'science-located'.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
newErrorMessage += "<ul class='error-list'>";
|
||||||
|
|
||||||
|
if (responseData.pubsWithNoJournals && responseData.pubsWithNoJournals > 0) {
|
||||||
|
|
||||||
|
var publicationsText = (responseData.pubsWithNoJournals > 1) ? "publications" : "publication";
|
||||||
|
|
||||||
|
newErrorMessage += "<li>" + responseData.pubsWithNoJournals + " " + publicationsText + " have no journal"
|
||||||
|
+ " information.</li>"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseData.pubsWithInvalidJournals && responseData.pubsWithInvalidJournals > 0) {
|
||||||
|
|
||||||
|
var publicationsText = (responseData.pubsWithInvalidJournals > 1) ? "publications" : "publication";
|
||||||
|
|
||||||
|
newErrorMessage += "<li>" + responseData.pubsWithInvalidJournals + " " + publicationsText + " "
|
||||||
|
+ " could not be matched with a map location using their journal information.</li>"
|
||||||
|
}
|
||||||
|
|
||||||
|
newErrorMessage += "</ul>";
|
||||||
|
|
||||||
|
return newErrorMessage;
|
||||||
|
},
|
||||||
|
|
||||||
|
hide: function() {
|
||||||
|
this.container.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -6,6 +6,8 @@ var currentVisMode;
|
||||||
var currentController;
|
var currentController;
|
||||||
var visModeControllers = {};
|
var visModeControllers = {};
|
||||||
var responseContainerID = "map-of-science-response";
|
var responseContainerID = "map-of-science-response";
|
||||||
|
var ERROR_DISPLAY_WIDGET = '';
|
||||||
|
|
||||||
var loadingScreenTimeout;
|
var loadingScreenTimeout;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -84,6 +86,11 @@ function helper() {
|
||||||
|
|
||||||
/* Using .load instead of .ready due to issue with IE and Google Maps API */
|
/* Using .load instead of .ready due to issue with IE and Google Maps API */
|
||||||
$(window).load(function() {
|
$(window).load(function() {
|
||||||
|
|
||||||
|
ERROR_DISPLAY_WIDGET = new ErrorDisplayWidget({
|
||||||
|
containerID: 'error-container'
|
||||||
|
});
|
||||||
|
|
||||||
setupLoadingScreen();
|
setupLoadingScreen();
|
||||||
initMap();
|
initMap();
|
||||||
initVisModeController();
|
initVisModeController();
|
||||||
|
|
|
@ -74,9 +74,9 @@ var EntityVisModeController = Class.extend({
|
||||||
|
|
||||||
$("#" + responseContainerID).unblock();
|
$("#" + responseContainerID).unblock();
|
||||||
|
|
||||||
if (data.error) {
|
if (ERROR_DISPLAY_WIDGET.isErrorConditionTriggered(data)) {
|
||||||
$("#map-of-science-response").hide();
|
$("#map-of-science-response").hide();
|
||||||
$("#error-container").show();
|
ERROR_DISPLAY_WIDGET.show(ENTITY_TYPE, data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ var disciplineLabelImageUrlPrefix = mapOfScienceImageFolderPrefix + "labels/";
|
||||||
|
|
||||||
var entityLabel = '${entityLabel}';
|
var entityLabel = '${entityLabel}';
|
||||||
|
|
||||||
|
var ENTITY_TYPE = '${entityType}';
|
||||||
|
|
||||||
var loadingImageLink = contextPath + "/images/visualization/ajax-loader-indicator.gif";
|
var loadingImageLink = contextPath + "/images/visualization/ajax-loader-indicator.gif";
|
||||||
var refreshPageImageLink = contextPath + "/images/visualization/refresh-green.png";
|
var refreshPageImageLink = contextPath + "/images/visualization/refresh-green.png";
|
||||||
|
|
||||||
|
@ -62,6 +64,7 @@ ${scripts.add('<script type="text/javascript" src="http://maps.google.com/maps/a
|
||||||
'<script type="text/javascript" src="${urls.base}/js/visualization/visualization-helper-functions.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/visualization/visualization-helper-functions.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.notify.min.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.notify.min.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/ClassExtendUtils.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/ClassExtendUtils.js"></script>',
|
||||||
|
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/ErrorDisplayWidget.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/DownloadManager.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/DownloadManager.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/NumberUtils.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/NumberUtils.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/Tooltip.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/visualization/mapofscience/Tooltip.js"></script>',
|
||||||
|
|
|
@ -142,13 +142,11 @@ concern.</div>
|
||||||
<div id="error-container">
|
<div id="error-container">
|
||||||
|
|
||||||
<h1 id="noPublications-header">${entityLabel}</h1>
|
<h1 id="noPublications-header">${entityLabel}</h1>
|
||||||
|
<h3 id="vis-title">Map of Science Visualization</h3>
|
||||||
<h3 id="alternative-vis-info">Map of Science Visualization</h3>
|
|
||||||
<div id="error-body">
|
<div id="error-body">
|
||||||
<p>This organization has neither sub-organizations nor people with publications in the system.
|
<p><span id="variable-error-text">No publications in the system have been attributed to this organization.</span><hr />
|
||||||
Please visit the full ${entityLabel} <a href="${entityVivoProfileURL}">profile page</a> for a more complete overview.</p>
|
Please visit the ${entityLabel} <a href="${entityVivoProfileURL}">profile page</a> for a complete overview.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${headScripts.add('<script type="text/javascript" src="${urls.base}/js/jquery_plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>')}
|
${headScripts.add('<script type="text/javascript" src="${urls.base}/js/jquery_plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>')}
|
|
@ -82,11 +82,6 @@ public class MapOfScienceVisualizationRequestHandler implements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("current models in the system are");
|
|
||||||
// for (Map.Entry<String, Model> entry : ConstructedModelTracker.getAllModels().entrySet()) {
|
|
||||||
// System.out.println(entry.getKey() + " -> " + entry.getValue().size());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,23 +155,7 @@ public class MapOfScienceVisualizationRequestHandler implements
|
||||||
organizationEntity = OrganizationUtilityFunctions.mergeEntityIfShareSameURI(
|
organizationEntity = OrganizationUtilityFunctions.mergeEntityIfShareSameURI(
|
||||||
organizationEntity,
|
organizationEntity,
|
||||||
organizationWithAssociatedPeople);
|
organizationWithAssociatedPeople);
|
||||||
} /*else {
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is for just people.
|
|
||||||
Set<SubEntity> test = new HashSet<SubEntity>();
|
|
||||||
|
|
||||||
test.add(new SubEntity(subjectEntityURI));
|
|
||||||
|
|
||||||
documentURIForAssociatedPeopleTOVO = SelectOnModelUtilities
|
|
||||||
.getPublicationsWithJournalForAssociatedPeople(dataset, test);
|
|
||||||
|
|
||||||
organizationEntity = OrganizationUtilityFunctions.mergeEntityIfShareSameURI(
|
|
||||||
organizationEntity,
|
|
||||||
organizationWithAssociatedPeople);
|
|
||||||
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (allDocumentURIToVOs.isEmpty() && documentURIForAssociatedPeopleTOVO.isEmpty()) {
|
if (allDocumentURIToVOs.isEmpty() && documentURIForAssociatedPeopleTOVO.isEmpty()) {
|
||||||
|
|
||||||
|
@ -347,19 +326,28 @@ public class MapOfScienceVisualizationRequestHandler implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
|
private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
|
||||||
String entityURI) {
|
String entityURI)
|
||||||
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
String standaloneTemplate = "mapOfScienceStandalone.ftl";
|
String standaloneTemplate = "mapOfScienceStandalone.ftl";
|
||||||
|
|
||||||
String organizationLabel = OrganizationUtilityFunctions
|
String entityLabel = UtilityFunctions.getIndividualLabelFromDAO(
|
||||||
.getEntityLabelFromDAO(vreq,
|
vreq,
|
||||||
entityURI);
|
entityURI);
|
||||||
|
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
body.put("title", organizationLabel + " - Map of Science Visualization");
|
body.put("title", entityLabel + " - Map of Science Visualization");
|
||||||
body.put("entityURI", entityURI);
|
body.put("entityURI", entityURI);
|
||||||
body.put("entityLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
|
body.put("entityLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
|
||||||
body.put("entityLabel", organizationLabel);
|
body.put("entityLabel", entityLabel);
|
||||||
|
|
||||||
|
if (UtilityFunctions.isEntityAPerson(vreq, entityURI)) {
|
||||||
|
body.put("entityType", "PERSON");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
body.put("entityType", "ORGANIZATION");
|
||||||
|
}
|
||||||
|
|
||||||
body.put("vivoDefaultNamespace", vreq.getWebappDaoFactory().getDefaultNamespace());
|
body.put("vivoDefaultNamespace", vreq.getWebappDaoFactory().getDefaultNamespace());
|
||||||
|
|
||||||
return new TemplateResponseValues(standaloneTemplate, body);
|
return new TemplateResponseValues(standaloneTemplate, body);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue