NIHVIVO-2449 Remove moniker from menupage display

This commit is contained in:
ryounes 2011-07-06 21:56:02 +00:00
parent 5f043d02ea
commit 7f24663115
4 changed files with 68 additions and 45 deletions

View file

@ -7,6 +7,7 @@ import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
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.controller.freemarker.SolrIndividualListController;
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.jena.VClassGroupCache;
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 ");
throw new Exception("parameter vclassId URI parameter expected ");
}
vreq.setAttribute("displayType", vitroClassIdStr);
rObj = getSolrIndividualsByVClass(vclass.getURI(),req, getServletContext());
}catch(Exception ex){
errorMessage = ex.toString();
@ -268,6 +271,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
return map;
}
//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
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;
}
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()
.getDataPropertyValuesForIndividualByProperty(ind, dp);
if( values == null || values.isEmpty() )

View file

@ -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.VClassGroup;
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.freemarker.IndividualListController;
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");
DataProperty lNameDp = (new DataProperty());
lNameDp.setURI("http://xmlns.com/foaf/0.1/lastName");
DataProperty monikerDp = (new DataProperty());
monikerDp.setURI( VitroVocabulary.MONIKER);
//this property is vivo specific
DataProperty preferredTitleDp = (new DataProperty());
preferredTitleDp.setURI("http://vivoweb.org/ontology/core#preferredTitle");
@ -241,13 +240,11 @@ public class DataGetterUtils {
jo.put("imageUrl", ind.getImageUrl());
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
String moniker = JSONServlet.getDataPropertyValue(ind, monikerDp, fullWdf);
jo.put("moniker", moniker);
jo.put("vclassName", JSONServlet.getVClassName(ind,moniker,fullWdf));
jo.put("vclassName", SolrJsonServlet.getMostSpecificTypeName(ind,fullWdf));
jo.put("preferredTitle", JSONServlet.getDataPropertyValue(ind, preferredTitleDp, fullWdf));
jo.put("firstName", JSONServlet.getDataPropertyValue(ind, fNameDp, fullWdf));
jo.put("lastName", JSONServlet.getDataPropertyValue(ind, lNameDp, fullWdf));
jo.put("preferredTitle", SolrJsonServlet.getDataPropertyValue(ind, preferredTitleDp, fullWdf));
jo.put("firstName", SolrJsonServlet.getDataPropertyValue(ind, fNameDp, fullWdf));
jo.put("lastName", SolrJsonServlet.getDataPropertyValue(ind, lNameDp, fullWdf));
jInds.put(jo);
}

View file

@ -95,7 +95,7 @@ var browseByVClass = {
}
$.getJSON(url, function(results) {
individualList = "";
var individualList = "";
// 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
@ -103,26 +103,30 @@ var browseByVClass = {
browseByVClass.emptyResultSet(results.vclass, alpha)
} else {
$.each(results.individuals, function(i, item) {
label = results.individuals[i].label;
moniker = results.individuals[i].moniker;
vclassName = results.individuals[i].vclassName;
uri = results.individuals[i].URI;
profileUrl = results.individuals[i].profileUrl;
if ( results.individuals[i].thumbUrl ) {
image = browseByVClass.baseUrl + results.individuals[i].thumbUrl;
var individual,
label,
vclassName,
uri,
profileUrl,
image,
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
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">';
} else {
listItem += '<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>';
// browseByVClass.individualsInVClass.append(listItem);
individualList += listItem;

View file

@ -45,7 +45,7 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
}
$.getJSON(url, function(results) {
individualList = "";
var individualList = "";
// 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
@ -53,39 +53,44 @@ browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
browseByVClass.emptyResultSet(results.vclass, alpha)
} else {
$.each(results.individuals, function(i, item) {
label = results.individuals[i].label;
firstName = results.individuals[i].firstName;
lastName = results.individuals[i].lastName;
var individual,
label,
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 ) {
fullName = firstName + ' ' + lastName;
} else {
fullName = label;
}
moniker = results.individuals[i].moniker;
vclassName = results.individuals[i].vclassName;
if ( results.individuals[i].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 = "";
var vclassName = individual.vclassName;
if ( individual.preferredTitle ) {
preferredTitle = individual.preferredTitle;
}
} else {
preferredTitle = results.individuals[i].preferredTitle;
}
uri = results.individuals[i].URI;
profileUrl = results.individuals[i].profileUrl;
if ( !results.individuals[i].thumbUrl ) {
uri = individual.URI;
profileUrl = individual.profileUrl;
if ( !individual.thumbUrl ) {
image = browseByVClass.baseUrl + '/images/placeholders/person.thumbnail.jpg';
} else {
image = browseByVClass.baseUrl + results.individuals[i].thumbUrl;
image = browseByVClass.baseUrl + individual.thumbUrl;
}
// Build the content of each list item, piecing together each component
listItem = '<li class="vcard individual foaf-person" role="listitem" role="navigation">';
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>';
// Include the calculated preferred title (see above) only if it's not empty
if ( preferredTitle != "" ) {
if ( preferredTitle ) {
listItem += '<span class="title">'+ preferredTitle +'</span>';
}
listItem += '</li>';