NIHVIVO-2744 Display of mostSpecificType(s) on individual profile (in place of former moniker).

This commit is contained in:
ryounes 2011-06-23 15:00:23 +00:00
parent d74f5f3072
commit 5998f8b095
14 changed files with 95 additions and 34 deletions

View file

@ -34,4 +34,6 @@ public interface ObjectPropertyStatementDao {
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(String subjectUri, String propertyUri, String objectKey, String query);
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(String subjectUri, String propertyUri, String objectKey, String query, Set<String> constructQueries);
public List<String> getMostSpecificTypesForIndividual(String subjectUri);
}

View file

@ -57,6 +57,8 @@ public class VitroVocabulary {
public static final String PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromUpdateBelowRoleLevelAnnot";
//public static final String PROHIBITED_FROM_DELETE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromDeleteBelowRoleLevelAnnot";
public static final String MOST_SPECIFIC_TYPE = vitroURI + "mostSpecificType";
// roles
public static final String PUBLIC = "http://vitro.mannlib.cornell.edu/ns/vitro/role#public";
public static final String SELF = "http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor";

View file

@ -82,28 +82,22 @@ class ObjectPropertyStatementDaoFiltering extends BaseFiltering implements Objec
return innerObjectPropertyStatementDao.insertNewObjectPropertyStatement(objPropertyStmt);
}
@Override
// RY What about filtering?
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
String subjectUri, String propertyUri, String objectKey, String query) {
return innerObjectPropertyStatementDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, query);
}
@Override
// RY What about filtering?
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
String subjectUri, String propertyUri, String objectKey, String query, Set<String> queryStrings) {
return innerObjectPropertyStatementDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, query, queryStrings);
}
@Override
public List<String> getMostSpecificTypesForIndividual(String subjectUri) {
return innerObjectPropertyStatementDao.getMostSpecificTypesForIndividual(subjectUri);
}
// @Override
// // RY What about filtering?
// public Map<String, List<Map<String, Object>>> getCollatedObjectPropertyStatementsForIndividual(
// String subjectUri, String propertyUri, String query) {
// return innerObjectPropertyStatementDao.getCollatedObjectPropertyStatementsForIndividual(subjectUri, propertyUri, query);
// }
}

View file

@ -778,7 +778,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
}
log.debug("Data property query string:\n" + query);
Iterator<QuerySolution> results = getPropertyQueryResults(subjectUri, query);
Iterator<QuerySolution> results = getPropertyQueryResults(query);
List<DataProperty> properties = new ArrayList<DataProperty>();
while (results.hasNext()) {
QuerySolution sol = results.next();

View file

@ -871,7 +871,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
}
log.debug("Object property query:\n" + query);
Iterator<QuerySolution> results = getPropertyQueryResults(subjectUri, query);
Iterator<QuerySolution> results = getPropertyQueryResults(query);
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
while (results.hasNext()) {
QuerySolution soln = results.next();

View file

@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -38,6 +39,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent;
public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements ObjectPropertyStatementDao {
@ -359,7 +361,6 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
initialBindings.add(
"property", ResourceFactory.createResource(propertyUri));
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
@ -383,4 +384,58 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
}
protected static final String MOST_SPECIFIC_TYPE_QUERY =
"PREFIX rdfs: <" + VitroVocabulary.RDFS + "> \n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?label WHERE { \n" +
" ?subject vitro:mostSpecificType ?type . \n" +
" ?type rdfs:label ?label \n" +
"} ORDER BY ?label ";
@Override
/**
* Finds all mostSpecificTypes of an individual.
* Returns a list of type labels.
* **/
public List<String> getMostSpecificTypesForIndividual(String subjectUri) {
String queryString = subUriForQueryVar(MOST_SPECIFIC_TYPE_QUERY, "subject", subjectUri);
log.debug("Query string for vitro:mostSpecificType : " + queryString);
Query query = null;
try {
query = QueryFactory.create(queryString, Syntax.syntaxARQ);
} catch(Throwable th){
log.error("Could not create SPARQL query for query string. " + th.getMessage());
log.error(queryString);
return Collections.emptyList();
}
List<String> types = new ArrayList<String>();
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
try {
QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
ResultSet results = qexec.execSelect();
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
RDFNode node = soln.get("label");
if (node.isLiteral()) {
String label = node.asLiteral().getLexicalForm();
if (! StringUtils.isBlank(label)) {
types.add(label);
}
}
}
} finally {
dataset.getLock().leaveCriticalSection();
w.close();
}
return types;
}
}

View file

@ -404,7 +404,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
return classSet;
}
protected Iterator<QuerySolution> getPropertyQueryResults(String subjectUri, Query query) {
protected Iterator<QuerySolution> getPropertyQueryResults(Query query) {
log.debug("SPARQL query:\n" + query.toString());
// RY Removing prebinding due to Jena bug: when isLiteral(?object) or

View file

@ -116,9 +116,6 @@ public class SolrAutocompleteController extends VitroAjaxController {
Collections.sort(results);
// map.put("results", results);
// writeTemplate(TEMPLATE_DEFAULT, map, config, vreq, response);
JSONArray jsonArray = new JSONArray();
for (SearchResult result : results) {
jsonArray.put(result.toMap());
@ -157,7 +154,7 @@ public class SolrAutocompleteController extends VitroAjaxController {
query.setFields(VitroLuceneTermNames.NAME_RAW, VitroLuceneTermNames.URI); // fields to retrieve
// Can't sort on multivalued field, so sort results in Java when we get them
// Can't sort on multivalued field, so we sort the results in Java when we get them.
// query.setSortField(VitroLuceneTermNames.NAME_LOWERCASE, SolrQuery.ORDER.asc);
return query;

View file

@ -168,7 +168,7 @@ public class SolrPagedSearchController extends FreemarkerHttpServlet {
if( startIndex >= DEFAULT_MAX_HIT_COUNT - hitsPerPage )
maxHitCount = startIndex + DEFAULT_MAX_HIT_COUNT ;
log.debug("maxHitSize is " + maxHitCount);
log.debug("maxHitCount is " + maxHitCount);
String qtxt = vreq.getParameter(VitroQuery.QUERY_PARAMETER_NAME);

View file

@ -2,8 +2,11 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -20,8 +23,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
@ -146,10 +149,12 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
return individual.getName();
}
public String getMoniker() {
return individual.getMoniker();
public List<String> getMostSpecificTypes() {
ObjectPropertyStatementDao opsDao = vreq.getWebappDaoFactory().getObjectPropertyStatementDao();
return opsDao.getMostSpecificTypesForIndividual(getUri());
}
public String getUri() {
return individual.getURI();
}

View file

@ -39,7 +39,7 @@
#individual-intro h1 {
padding-bottom: 8px;
}
#individual-intro span.preferred-title {
#individual-intro span.most-specific-type {
padding-left: 10px;
margin-left: 10px;
}
@ -188,7 +188,7 @@ ul#additional-emails li {
#individual-info.withThumb {
width: 78%;
}
h1.fn .preferred-title {
h1.fn .most-specific-type {
padding-left: 10px;
margin-left: 10px;
}

View file

@ -31,10 +31,8 @@
<#-- Label -->
<@p.label individual editable />
<#-- Moniker -->
<#if individual.moniker?has_content>
<span class="preferred-title">${individual.moniker}</span>
</#if>
<#-- Most-specific types -->
<@p.mostSpecificTypes individual />
</h1>
</#if>
</header>

View file

@ -240,3 +240,11 @@ name will be used as the label. -->
<@editingLinks "label" label editable />
</#macro>
<#-- Most specific types -->
<#macro mostSpecificTypes individual>
<#local types = individual.mostSpecificTypes />
<#list types as type>
<span class="most-specific-type">${type}</span>
</#list>
</#macro>

View file

@ -1151,7 +1151,7 @@ ul#alpha-browse-individuals .count-classes {
font-size: 1.375em;
color: #47B6D0;
}
#individual-intro span.preferred-title {
#individual-intro span.most-specific-type {
font-size: .825em;
color: #5e6363;
border-left: 1px solid #A6B1B0;
@ -1224,7 +1224,7 @@ ul.individual-urls-people li a {
color: #006279;
line-height: 1.3em;
}
h1.fn .preferred-title {
h1.fn .most-specific-type {
font-size: .825em;
color: #5e6363;
border-left: 1px solid #a6b1b0;