NIHVIVO-2449 Remove moniker from menupage display
This commit is contained in:
parent
5f043d02ea
commit
7f24663115
4 changed files with 68 additions and 45 deletions
|
@ -7,6 +7,7 @@ import java.io.PrintWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
@ -34,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.SolrIndividualListController;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.SolrIndividualListController;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
||||||
|
@ -148,6 +150,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
||||||
log.debug("parameter vclassId URI parameter expected ");
|
log.debug("parameter vclassId URI parameter expected ");
|
||||||
throw new Exception("parameter vclassId URI parameter expected ");
|
throw new Exception("parameter vclassId URI parameter expected ");
|
||||||
}
|
}
|
||||||
|
vreq.setAttribute("displayType", vitroClassIdStr);
|
||||||
rObj = getSolrIndividualsByVClass(vclass.getURI(),req, getServletContext());
|
rObj = getSolrIndividualsByVClass(vclass.getURI(),req, getServletContext());
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
errorMessage = ex.toString();
|
errorMessage = ex.toString();
|
||||||
|
@ -268,6 +271,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Factoring out to allow for results to be processed from query for both lucene and solr
|
//Factoring out to allow for results to be processed from query for both lucene and solr
|
||||||
//Map given to process method includes the actual individuals returned from the search
|
//Map given to process method includes the actual individuals returned from the search
|
||||||
public static JSONObject processVClassResults(Map<String, Object> map, VitroRequest vreq, ServletContext context, boolean multipleVclasses) throws Exception{
|
public static JSONObject processVClassResults(Map<String, Object> map, VitroRequest vreq, ServletContext context, boolean multipleVclasses) throws Exception{
|
||||||
|
@ -275,7 +279,20 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
||||||
return rObj;
|
return rObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getDataPropertyValue(Individual ind, DataProperty dp, WebappDaoFactory wdf){
|
|
||||||
|
public static String getMostSpecificTypeName(Individual individual, WebappDaoFactory wdf) {
|
||||||
|
ObjectPropertyStatementDao opsDao = wdf.getObjectPropertyStatementDao();
|
||||||
|
Map<String, String> types = opsDao.getMostSpecificTypesForIndividual(individual.getURI());
|
||||||
|
Collection<String> typeLabels = types.values();
|
||||||
|
Iterator<String> i = typeLabels.iterator();
|
||||||
|
// Temporarily just returning one vaue since that's what the js expects. Fix later.
|
||||||
|
if (i.hasNext()) {
|
||||||
|
return i.next();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDataPropertyValue(Individual ind, DataProperty dp, WebappDaoFactory wdf){
|
||||||
List<Literal> values = wdf.getDataPropertyStatementDao()
|
List<Literal> values = wdf.getDataPropertyStatementDao()
|
||||||
.getDataPropertyValuesForIndividualByProperty(ind, dp);
|
.getDataPropertyValuesForIndividualByProperty(ind, dp);
|
||||||
if( values == null || values.isEmpty() )
|
if( values == null || values.isEmpty() )
|
||||||
|
|
|
@ -24,7 +24,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.JSONServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.SolrJsonServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.PageController;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.PageController;
|
||||||
|
@ -170,8 +170,7 @@ public class DataGetterUtils {
|
||||||
fNameDp.setURI("http://xmlns.com/foaf/0.1/firstName");
|
fNameDp.setURI("http://xmlns.com/foaf/0.1/firstName");
|
||||||
DataProperty lNameDp = (new DataProperty());
|
DataProperty lNameDp = (new DataProperty());
|
||||||
lNameDp.setURI("http://xmlns.com/foaf/0.1/lastName");
|
lNameDp.setURI("http://xmlns.com/foaf/0.1/lastName");
|
||||||
DataProperty monikerDp = (new DataProperty());
|
|
||||||
monikerDp.setURI( VitroVocabulary.MONIKER);
|
|
||||||
//this property is vivo specific
|
//this property is vivo specific
|
||||||
DataProperty preferredTitleDp = (new DataProperty());
|
DataProperty preferredTitleDp = (new DataProperty());
|
||||||
preferredTitleDp.setURI("http://vivoweb.org/ontology/core#preferredTitle");
|
preferredTitleDp.setURI("http://vivoweb.org/ontology/core#preferredTitle");
|
||||||
|
@ -241,13 +240,11 @@ public class DataGetterUtils {
|
||||||
jo.put("imageUrl", ind.getImageUrl());
|
jo.put("imageUrl", ind.getImageUrl());
|
||||||
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
|
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
|
||||||
|
|
||||||
String moniker = JSONServlet.getDataPropertyValue(ind, monikerDp, fullWdf);
|
jo.put("vclassName", SolrJsonServlet.getMostSpecificTypeName(ind,fullWdf));
|
||||||
jo.put("moniker", moniker);
|
|
||||||
jo.put("vclassName", JSONServlet.getVClassName(ind,moniker,fullWdf));
|
|
||||||
|
|
||||||
jo.put("preferredTitle", JSONServlet.getDataPropertyValue(ind, preferredTitleDp, fullWdf));
|
jo.put("preferredTitle", SolrJsonServlet.getDataPropertyValue(ind, preferredTitleDp, fullWdf));
|
||||||
jo.put("firstName", JSONServlet.getDataPropertyValue(ind, fNameDp, fullWdf));
|
jo.put("firstName", SolrJsonServlet.getDataPropertyValue(ind, fNameDp, fullWdf));
|
||||||
jo.put("lastName", JSONServlet.getDataPropertyValue(ind, lNameDp, fullWdf));
|
jo.put("lastName", SolrJsonServlet.getDataPropertyValue(ind, lNameDp, fullWdf));
|
||||||
|
|
||||||
jInds.put(jo);
|
jInds.put(jo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ var browseByVClass = {
|
||||||
}
|
}
|
||||||
|
|
||||||
$.getJSON(url, function(results) {
|
$.getJSON(url, function(results) {
|
||||||
individualList = "";
|
var individualList = "";
|
||||||
|
|
||||||
// Catch exceptions when empty individuals result set is returned
|
// Catch exceptions when empty individuals result set is returned
|
||||||
// This is very likely to happen now since we don't have individual counts for each letter and always allow the result set to be filtered by any letter
|
// This is very likely to happen now since we don't have individual counts for each letter and always allow the result set to be filtered by any letter
|
||||||
|
@ -103,26 +103,30 @@ var browseByVClass = {
|
||||||
browseByVClass.emptyResultSet(results.vclass, alpha)
|
browseByVClass.emptyResultSet(results.vclass, alpha)
|
||||||
} else {
|
} else {
|
||||||
$.each(results.individuals, function(i, item) {
|
$.each(results.individuals, function(i, item) {
|
||||||
label = results.individuals[i].label;
|
var individual,
|
||||||
moniker = results.individuals[i].moniker;
|
label,
|
||||||
vclassName = results.individuals[i].vclassName;
|
vclassName,
|
||||||
uri = results.individuals[i].URI;
|
uri,
|
||||||
profileUrl = results.individuals[i].profileUrl;
|
profileUrl,
|
||||||
if ( results.individuals[i].thumbUrl ) {
|
image,
|
||||||
image = browseByVClass.baseUrl + results.individuals[i].thumbUrl;
|
listItem;
|
||||||
|
|
||||||
|
individual = results.individuals[i];
|
||||||
|
label = individual.label;
|
||||||
|
vclassName = individual.vclassName;
|
||||||
|
uri = individual.URI;
|
||||||
|
profileUrl = individual.profileUrl;
|
||||||
|
if ( individual.thumbUrl ) {
|
||||||
|
image = browseByVClass.baseUrl + individual.thumbUrl;
|
||||||
}
|
}
|
||||||
// Build the content of each list item, piecing together each component
|
// Build the content of each list item, piecing together each component
|
||||||
listItem = '<li class="individual" role="listitem" role="navigation">';
|
listItem = '<li class="individual" role="listitem" role="navigation">';
|
||||||
if ( typeof results.individuals[i].thumbUrl !== "undefined" ) {
|
if ( typeof individual.thumbUrl !== "undefined" ) {
|
||||||
listItem += '<img src="'+ image +'" width="90" alt="'+ label +'" /><h1 class="thumb">';
|
listItem += '<img src="'+ image +'" width="90" alt="'+ label +'" /><h1 class="thumb">';
|
||||||
} else {
|
} else {
|
||||||
listItem += '<h1>';
|
listItem += '<h1>';
|
||||||
}
|
}
|
||||||
listItem += '<a href="'+ profileUrl +'" title="View the profile page for '+ label +'">'+ label +'</a></h1>';
|
listItem += '<a href="'+ profileUrl +'" title="View the profile page for '+ label +'">'+ label +'</a></h1>';
|
||||||
// Include the moniker only if it's not empty and not equal to the VClass name
|
|
||||||
if ( moniker != vclassName && moniker != "" ) {
|
|
||||||
listItem += '<span class="title">'+ moniker +'</span>';
|
|
||||||
}
|
|
||||||
listItem += '</li>';
|
listItem += '</li>';
|
||||||
// browseByVClass.individualsInVClass.append(listItem);
|
// browseByVClass.individualsInVClass.append(listItem);
|
||||||
individualList += listItem;
|
individualList += listItem;
|
||||||
|
|
|
@ -45,7 +45,7 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$.getJSON(url, function(results) {
|
$.getJSON(url, function(results) {
|
||||||
individualList = "";
|
var individualList = "";
|
||||||
|
|
||||||
// Catch exceptions when empty individuals result set is returned
|
// Catch exceptions when empty individuals result set is returned
|
||||||
// This is very likely to happen now since we don't have individual counts for each letter and always allow the result set to be filtered by any letter
|
// This is very likely to happen now since we don't have individual counts for each letter and always allow the result set to be filtered by any letter
|
||||||
|
@ -53,39 +53,44 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
|
||||||
browseByVClass.emptyResultSet(results.vclass, alpha)
|
browseByVClass.emptyResultSet(results.vclass, alpha)
|
||||||
} else {
|
} else {
|
||||||
$.each(results.individuals, function(i, item) {
|
$.each(results.individuals, function(i, item) {
|
||||||
label = results.individuals[i].label;
|
var individual,
|
||||||
firstName = results.individuals[i].firstName;
|
label,
|
||||||
lastName = results.individuals[i].lastName;
|
firstName,
|
||||||
|
lastName,
|
||||||
|
fullName,
|
||||||
|
vclassName,
|
||||||
|
preferredTitle,
|
||||||
|
uri,
|
||||||
|
profileUrl,
|
||||||
|
image,
|
||||||
|
listItem;
|
||||||
|
|
||||||
|
individual = results.individuals[i];
|
||||||
|
label = individual.label;
|
||||||
|
firstName = individual.firstName;
|
||||||
|
lastName = individual.lastName;
|
||||||
if ( firstName && lastName ) {
|
if ( firstName && lastName ) {
|
||||||
fullName = firstName + ' ' + lastName;
|
fullName = firstName + ' ' + lastName;
|
||||||
} else {
|
} else {
|
||||||
fullName = label;
|
fullName = label;
|
||||||
}
|
}
|
||||||
moniker = results.individuals[i].moniker;
|
var vclassName = individual.vclassName;
|
||||||
vclassName = results.individuals[i].vclassName;
|
if ( individual.preferredTitle ) {
|
||||||
if ( results.individuals[i].preferredTitle == "") {
|
preferredTitle = individual.preferredTitle;
|
||||||
// Use the moniker only if it's not empty and not equal to the VClass name
|
|
||||||
if ( moniker != vclassName && moniker != "" ) {
|
|
||||||
preferredTitle = moniker;
|
|
||||||
} else {
|
|
||||||
preferredTitle = "";
|
|
||||||
}
|
}
|
||||||
} else {
|
uri = individual.URI;
|
||||||
preferredTitle = results.individuals[i].preferredTitle;
|
profileUrl = individual.profileUrl;
|
||||||
}
|
if ( !individual.thumbUrl ) {
|
||||||
uri = results.individuals[i].URI;
|
|
||||||
profileUrl = results.individuals[i].profileUrl;
|
|
||||||
if ( !results.individuals[i].thumbUrl ) {
|
|
||||||
image = browseByVClass.baseUrl + '/images/placeholders/person.thumbnail.jpg';
|
image = browseByVClass.baseUrl + '/images/placeholders/person.thumbnail.jpg';
|
||||||
} else {
|
} else {
|
||||||
image = browseByVClass.baseUrl + results.individuals[i].thumbUrl;
|
image = browseByVClass.baseUrl + individual.thumbUrl;
|
||||||
}
|
}
|
||||||
// Build the content of each list item, piecing together each component
|
// Build the content of each list item, piecing together each component
|
||||||
listItem = '<li class="vcard individual foaf-person" role="listitem" role="navigation">';
|
listItem = '<li class="vcard individual foaf-person" role="listitem" role="navigation">';
|
||||||
listItem += '<img src="'+ image +'" width="90" alt="'+ fullName +'" />';
|
listItem += '<img src="'+ image +'" width="90" alt="'+ fullName +'" />';
|
||||||
listItem += '<h1 class="fn thumb"><a href="'+ profileUrl +'" title="View the profile page for '+ fullName +'">'+ fullName +'</a></h1>';
|
listItem += '<h1 class="fn thumb"><a href="'+ profileUrl +'" title="View the profile page for '+ fullName +'">'+ fullName +'</a></h1>';
|
||||||
// Include the calculated preferred title (see above) only if it's not empty
|
// Include the calculated preferred title (see above) only if it's not empty
|
||||||
if ( preferredTitle != "" ) {
|
if ( preferredTitle ) {
|
||||||
listItem += '<span class="title">'+ preferredTitle +'</span>';
|
listItem += '<span class="title">'+ preferredTitle +'</span>';
|
||||||
}
|
}
|
||||||
listItem += '</li>';
|
listItem += '</li>';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue