NIHVIVO-2744 Display of mostSpecificType(s) on individual profile (in place of former moniker).
This commit is contained in:
parent
d74f5f3072
commit
5998f8b095
14 changed files with 95 additions and 34 deletions
|
@ -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);
|
||||||
|
|
||||||
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(String subjectUri, String propertyUri, String objectKey, String query, Set<String> constructQueries);
|
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(String subjectUri, String propertyUri, String objectKey, String query, Set<String> constructQueries);
|
||||||
|
|
||||||
|
public List<String> getMostSpecificTypesForIndividual(String subjectUri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class VitroVocabulary {
|
||||||
public static final String DISPLAY = DisplayVocabulary.DISPLAY_NS;
|
public static final String DISPLAY = DisplayVocabulary.DISPLAY_NS;
|
||||||
|
|
||||||
// properties found on the beans
|
// properties found on the beans
|
||||||
|
|
||||||
public static final String DESCRIPTION = vitroURI+"description";
|
public static final String DESCRIPTION = vitroURI+"description";
|
||||||
public static final String DESCRIPTION_ANNOT = vitroURI + "descriptionAnnot";
|
public static final String DESCRIPTION_ANNOT = vitroURI + "descriptionAnnot";
|
||||||
public static final String PUBLIC_DESCRIPTION_ANNOT = vitroURI + "publicDescriptionAnnot";
|
public static final String PUBLIC_DESCRIPTION_ANNOT = vitroURI + "publicDescriptionAnnot";
|
||||||
|
@ -56,6 +56,8 @@ public class VitroVocabulary {
|
||||||
//public static final String PROHIBITED_FROM_CREATE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromCreateBelowRoleLevelAnnot";
|
//public static final String PROHIBITED_FROM_CREATE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromCreateBelowRoleLevelAnnot";
|
||||||
public static final String PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromUpdateBelowRoleLevelAnnot";
|
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 PROHIBITED_FROM_DELETE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromDeleteBelowRoleLevelAnnot";
|
||||||
|
|
||||||
|
public static final String MOST_SPECIFIC_TYPE = vitroURI + "mostSpecificType";
|
||||||
|
|
||||||
// roles
|
// roles
|
||||||
public static final String PUBLIC = "http://vitro.mannlib.cornell.edu/ns/vitro/role#public";
|
public static final String PUBLIC = "http://vitro.mannlib.cornell.edu/ns/vitro/role#public";
|
||||||
|
|
|
@ -82,28 +82,22 @@ class ObjectPropertyStatementDaoFiltering extends BaseFiltering implements Objec
|
||||||
return innerObjectPropertyStatementDao.insertNewObjectPropertyStatement(objPropertyStmt);
|
return innerObjectPropertyStatementDao.insertNewObjectPropertyStatement(objPropertyStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// RY What about filtering?
|
|
||||||
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
|
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
|
||||||
String subjectUri, String propertyUri, String objectKey, String query) {
|
String subjectUri, String propertyUri, String objectKey, String query) {
|
||||||
return innerObjectPropertyStatementDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, query);
|
return innerObjectPropertyStatementDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// RY What about filtering?
|
|
||||||
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
|
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
|
||||||
String subjectUri, String propertyUri, String objectKey, String query, Set<String> queryStrings) {
|
String subjectUri, String propertyUri, String objectKey, String query, Set<String> queryStrings) {
|
||||||
return innerObjectPropertyStatementDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, query, queryStrings);
|
return innerObjectPropertyStatementDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, query, queryStrings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getMostSpecificTypesForIndividual(String subjectUri) {
|
||||||
// @Override
|
return innerObjectPropertyStatementDao.getMostSpecificTypesForIndividual(subjectUri);
|
||||||
// // RY What about filtering?
|
}
|
||||||
// public Map<String, List<Map<String, Object>>> getCollatedObjectPropertyStatementsForIndividual(
|
|
||||||
// String subjectUri, String propertyUri, String query) {
|
|
||||||
// return innerObjectPropertyStatementDao.getCollatedObjectPropertyStatementsForIndividual(subjectUri, propertyUri, query);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -778,7 +778,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
}
|
}
|
||||||
log.debug("Data property query string:\n" + query);
|
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>();
|
List<DataProperty> properties = new ArrayList<DataProperty>();
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
QuerySolution sol = results.next();
|
QuerySolution sol = results.next();
|
||||||
|
|
|
@ -871,7 +871,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
}
|
}
|
||||||
log.debug("Object property query:\n" + query);
|
log.debug("Object property query:\n" + query);
|
||||||
|
|
||||||
Iterator<QuerySolution> results = getPropertyQueryResults(subjectUri, query);
|
Iterator<QuerySolution> results = getPropertyQueryResults(query);
|
||||||
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
|
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
QuerySolution soln = results.next();
|
QuerySolution soln = results.next();
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.ObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
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;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent;
|
||||||
|
|
||||||
public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements ObjectPropertyStatementDao {
|
public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements ObjectPropertyStatementDao {
|
||||||
|
@ -359,7 +361,6 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
||||||
initialBindings.add(
|
initialBindings.add(
|
||||||
"property", ResourceFactory.createResource(propertyUri));
|
"property", ResourceFactory.createResource(propertyUri));
|
||||||
|
|
||||||
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
|
||||||
DatasetWrapper w = dwf.getDatasetWrapper();
|
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,7 +404,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
return classSet;
|
return classSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Iterator<QuerySolution> getPropertyQueryResults(String subjectUri, Query query) {
|
protected Iterator<QuerySolution> getPropertyQueryResults(Query query) {
|
||||||
log.debug("SPARQL query:\n" + query.toString());
|
log.debug("SPARQL query:\n" + query.toString());
|
||||||
|
|
||||||
// RY Removing prebinding due to Jena bug: when isLiteral(?object) or
|
// RY Removing prebinding due to Jena bug: when isLiteral(?object) or
|
||||||
|
|
|
@ -116,9 +116,6 @@ public class SolrAutocompleteController extends VitroAjaxController {
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
// map.put("results", results);
|
|
||||||
// writeTemplate(TEMPLATE_DEFAULT, map, config, vreq, response);
|
|
||||||
|
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
for (SearchResult result : results) {
|
for (SearchResult result : results) {
|
||||||
jsonArray.put(result.toMap());
|
jsonArray.put(result.toMap());
|
||||||
|
@ -157,7 +154,7 @@ public class SolrAutocompleteController extends VitroAjaxController {
|
||||||
|
|
||||||
query.setFields(VitroLuceneTermNames.NAME_RAW, VitroLuceneTermNames.URI); // fields to retrieve
|
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);
|
// query.setSortField(VitroLuceneTermNames.NAME_LOWERCASE, SolrQuery.ORDER.asc);
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class SolrPagedSearchController extends FreemarkerHttpServlet {
|
||||||
if( startIndex >= DEFAULT_MAX_HIT_COUNT - hitsPerPage )
|
if( startIndex >= DEFAULT_MAX_HIT_COUNT - hitsPerPage )
|
||||||
maxHitCount = startIndex + DEFAULT_MAX_HIT_COUNT ;
|
maxHitCount = startIndex + DEFAULT_MAX_HIT_COUNT ;
|
||||||
|
|
||||||
log.debug("maxHitSize is " + maxHitCount);
|
log.debug("maxHitCount is " + maxHitCount);
|
||||||
|
|
||||||
String qtxt = vreq.getParameter(VitroQuery.QUERY_PARAMETER_NAME);
|
String qtxt = vreq.getParameter(VitroQuery.QUERY_PARAMETER_NAME);
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ public class SolrPagedSearchController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
log.error("problem getting VClassGroups from search hits "
|
log.error("problem getting VClassGroups from search hits "
|
||||||
+ e.getMessage());
|
+ e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
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.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
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.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.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
|
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
|
||||||
|
@ -146,10 +149,12 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
||||||
return individual.getName();
|
return individual.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMoniker() {
|
public List<String> getMostSpecificTypes() {
|
||||||
return individual.getMoniker();
|
ObjectPropertyStatementDao opsDao = vreq.getWebappDaoFactory().getObjectPropertyStatementDao();
|
||||||
|
return opsDao.getMostSpecificTypesForIndividual(getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
return individual.getURI();
|
return individual.getURI();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#individual-intro h1 {
|
#individual-intro h1 {
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
}
|
}
|
||||||
#individual-intro span.preferred-title {
|
#individual-intro span.most-specific-type {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ ul#additional-emails li {
|
||||||
#individual-info.withThumb {
|
#individual-info.withThumb {
|
||||||
width: 78%;
|
width: 78%;
|
||||||
}
|
}
|
||||||
h1.fn .preferred-title {
|
h1.fn .most-specific-type {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,8 @@
|
||||||
<#-- Label -->
|
<#-- Label -->
|
||||||
<@p.label individual editable />
|
<@p.label individual editable />
|
||||||
|
|
||||||
<#-- Moniker -->
|
<#-- Most-specific types -->
|
||||||
<#if individual.moniker?has_content>
|
<@p.mostSpecificTypes individual />
|
||||||
<span class="preferred-title">${individual.moniker}</span>
|
|
||||||
</#if>
|
|
||||||
</h1>
|
</h1>
|
||||||
</#if>
|
</#if>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -240,3 +240,11 @@ name will be used as the label. -->
|
||||||
<@editingLinks "label" label editable />
|
<@editingLinks "label" label editable />
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
|
<#-- Most specific types -->
|
||||||
|
<#macro mostSpecificTypes individual>
|
||||||
|
<#local types = individual.mostSpecificTypes />
|
||||||
|
<#list types as type>
|
||||||
|
<span class="most-specific-type">${type}</span>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
|
|
@ -1151,7 +1151,7 @@ ul#alpha-browse-individuals .count-classes {
|
||||||
font-size: 1.375em;
|
font-size: 1.375em;
|
||||||
color: #47B6D0;
|
color: #47B6D0;
|
||||||
}
|
}
|
||||||
#individual-intro span.preferred-title {
|
#individual-intro span.most-specific-type {
|
||||||
font-size: .825em;
|
font-size: .825em;
|
||||||
color: #5e6363;
|
color: #5e6363;
|
||||||
border-left: 1px solid #A6B1B0;
|
border-left: 1px solid #A6B1B0;
|
||||||
|
@ -1224,7 +1224,7 @@ ul.individual-urls-people li a {
|
||||||
color: #006279;
|
color: #006279;
|
||||||
line-height: 1.3em;
|
line-height: 1.3em;
|
||||||
}
|
}
|
||||||
h1.fn .preferred-title {
|
h1.fn .most-specific-type {
|
||||||
font-size: .825em;
|
font-size: .825em;
|
||||||
color: #5e6363;
|
color: #5e6363;
|
||||||
border-left: 1px solid #a6b1b0;
|
border-left: 1px solid #a6b1b0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue