NIHVIVO-1332 Editing link for rdfs:label
This commit is contained in:
parent
cbda8cb95f
commit
50edcb5bbf
9 changed files with 95 additions and 60 deletions
|
@ -41,6 +41,8 @@ public interface DataPropertyStatementDao {
|
|||
int insertNewDataPropertyStatement(DataPropertyStatement dataPropertyStatement );
|
||||
|
||||
List<Literal> getDataPropertyValuesForIndividualByProperty(Individual subject, DataProperty property);
|
||||
|
||||
List<Literal> getDataPropertyValuesForIndividualByProperty(String subjectUri, String propertyUri);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -99,4 +99,10 @@ class DataPropertyStatementDaoFiltering extends BaseFiltering implements DataPro
|
|||
return innerDataPropertyStatementDao.getDataPropertyValuesForIndividualByProperty(subject, property);
|
||||
}
|
||||
|
||||
@Override
|
||||
// RY What about filtering?
|
||||
public List<Literal> getDataPropertyValuesForIndividualByProperty(String subjectUri, String propertyUri) {
|
||||
return innerDataPropertyStatementDao.getDataPropertyValuesForIndividualByProperty(subjectUri, propertyUri);
|
||||
}
|
||||
|
||||
}
|
|
@ -285,17 +285,20 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
|||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*
|
||||
* SPARQL-based method for getting the individual's values for a single data property.
|
||||
* SPARQL-based methods for getting the individual's values for a single data property.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<Literal> getDataPropertyValuesForIndividualByProperty(Individual subject, DataProperty property) {
|
||||
return getDataPropertyValuesForIndividualByProperty(subject.getURI(), property.getURI());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Literal> getDataPropertyValuesForIndividualByProperty(String subjectUri, String propertyUri) {
|
||||
log.debug("dataPropertyValueQueryString:\n" + dataPropertyValueQueryString);
|
||||
log.debug("dataPropertyValueQuery:\n" + dataPropertyValueQuery);
|
||||
log.debug("dataPropertyValueQuery:\n" + dataPropertyValueQuery);
|
||||
|
||||
String subjectUri = subject.getURI();
|
||||
String propertyUri = property.getURI();
|
||||
|
||||
QuerySolutionMap bindings = new QuerySolutionMap();
|
||||
bindings.add("subject", ResourceFactory.createResource(subjectUri));
|
||||
bindings.add("property", ResourceFactory.createResource(propertyUri));
|
||||
|
@ -319,6 +322,6 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
|||
dataset.getLock().leaveCriticalSection();
|
||||
w.close();
|
||||
}
|
||||
return values;
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -15,10 +14,12 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropDataPr
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropStmt;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||
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.ParamMap;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||
|
||||
public class DataPropertyStatementTemplateModel extends PropertyStatementTemplateModel {
|
||||
|
||||
|
@ -35,6 +36,22 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
|||
super(subjectUri, propertyUri, policyHelper);
|
||||
|
||||
this.value = value;
|
||||
setEditAccess(value, policyHelper);
|
||||
|
||||
}
|
||||
|
||||
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq, EditingPolicyHelper policyHelper) {
|
||||
super(subjectUri, propertyUri, policyHelper);
|
||||
|
||||
DataPropertyStatementDao dpsDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
|
||||
List<Literal> values = dpsDao.getDataPropertyValuesForIndividualByProperty(subjectUri, propertyUri);
|
||||
|
||||
value = values.get(0);
|
||||
setEditAccess(value, policyHelper);
|
||||
|
||||
}
|
||||
|
||||
private void setEditAccess(Literal value, EditingPolicyHelper policyHelper) {
|
||||
|
||||
if (policyHelper != null) { // we're editing
|
||||
DataPropertyStatement dps = new DataPropertyStatementImpl(subjectUri, propertyUri, value.getLexicalForm());
|
||||
|
@ -50,13 +67,16 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
|||
}
|
||||
|
||||
// Determine whether the statement can be deleted
|
||||
action = new DropDataPropStmt(dps);
|
||||
if (policyHelper.isAuthorizedAction(action)) {
|
||||
markDeletable();
|
||||
}
|
||||
}
|
||||
if ( ! propertyUri.equals(VitroVocabulary.LABEL)) {
|
||||
action = new DropDataPropStmt(dps);
|
||||
if (policyHelper.isAuthorizedAction(action)) {
|
||||
markDeletable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Access methods for templates */
|
||||
|
||||
public String getValue() {
|
||||
|
@ -73,6 +93,10 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
|||
if (! isDeletable()) {
|
||||
params.put("deleteProhibited", "prohibited");
|
||||
}
|
||||
//
|
||||
if (propertyUri.equals(VitroVocabulary.LABEL)) {
|
||||
params.put("vitroNsProp", "true");
|
||||
}
|
||||
editUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||
}
|
||||
return editUrl;
|
||||
|
|
|
@ -45,22 +45,13 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
private Individual subject;
|
||||
private VitroRequest vreq;
|
||||
private WebappDaoFactory wdf;
|
||||
private LoginStatusBean loginStatusBean;
|
||||
|
||||
private List<PropertyGroupTemplateModel> groups;
|
||||
|
||||
GroupedPropertyList(Individual subject, VitroRequest vreq, LoginStatusBean loginStatusBean) {
|
||||
GroupedPropertyList(Individual subject, VitroRequest vreq, EditingPolicyHelper policyHelper) {
|
||||
this.subject = subject;
|
||||
this.vreq = vreq;
|
||||
this.wdf = vreq.getWebappDaoFactory();
|
||||
this.loginStatusBean = loginStatusBean;
|
||||
|
||||
// Determine whether we're editing or not.
|
||||
boolean userCanEditThisProfile = getEditingStatus();
|
||||
|
||||
EditingPolicyHelper policyHelper = null;
|
||||
if (userCanEditThisProfile) {
|
||||
policyHelper = new EditingPolicyHelper(vreq, getServletContext());
|
||||
}
|
||||
|
||||
// Create the property list for the subject. The properties will be put into groups later.
|
||||
List<Property> propertyList = new ArrayList<Property>();
|
||||
|
@ -80,7 +71,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
// If editing this page, merge in object properties applicable to the individual that are currently
|
||||
// unpopulated, so the properties are displayed to allow statements to be added to these properties.
|
||||
// RY In future, we should limit this to properties that the user CAN add properties to.
|
||||
if (userCanEditThisProfile) {
|
||||
if (policyHelper != null) {
|
||||
mergeAllPossibleObjectProperties(objectPropertyList, propertyList);
|
||||
}
|
||||
|
||||
|
@ -96,7 +87,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
propertyList.add(dp);
|
||||
}
|
||||
|
||||
if (userCanEditThisProfile) {
|
||||
if (policyHelper != null) {
|
||||
mergeAllPossibleDataProperties(propertyList);
|
||||
}
|
||||
|
||||
|
@ -113,17 +104,6 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true iff the user is editing.
|
||||
* These tests may change once self-editing issues are straightened out. What we really need to know
|
||||
* is whether the user can edit this profile, not whether in general he/she is an editor.
|
||||
*/
|
||||
private boolean getEditingStatus() {
|
||||
boolean isSelfEditing = VitroRequestPrep.isSelfEditing(vreq);
|
||||
boolean isCurator = loginStatusBean.isLoggedInAtLeast(LoginStatusBean.CURATOR);
|
||||
return isSelfEditing || isCurator;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void sort(List<Property> propertyList) {
|
||||
try {
|
||||
|
@ -160,7 +140,6 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
|
||||
private void mergeAllPossibleObjectProperties(List<ObjectProperty> objectPropertyList, List<Property> propertyList) {
|
||||
PropertyInstanceDao piDao = wdf.getPropertyInstanceDao();
|
||||
// RY *** Does this exclude properties in the excluded namespaces already? If not, need same test as above
|
||||
Collection<PropertyInstance> allPropInstColl = piDao.getAllPossiblePropInstForIndividual(subject.getURI());
|
||||
if (allPropInstColl != null) {
|
||||
for (PropertyInstance pi : allPropInstColl) {
|
||||
|
@ -189,7 +168,6 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
|
||||
protected void mergeAllPossibleDataProperties(List<Property> propertyList) {
|
||||
DataPropertyDao dpDao = wdf.getDataPropertyDao();
|
||||
// RY *** Does this exclude properties in the excluded namespaces already? If not, need same test as above
|
||||
Collection <DataProperty> allDatapropColl = dpDao.getAllPossibleDatapropsForIndividual(subject.getURI());
|
||||
if (allDatapropColl != null) {
|
||||
for (DataProperty dp : allDatapropColl ) {
|
||||
|
|
|
@ -7,18 +7,14 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.openrdf.model.URI;
|
||||
import org.openrdf.model.impl.URIImpl;
|
||||
|
||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Link;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
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.ParamMap;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder.ClassView;
|
||||
|
@ -35,6 +31,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
protected UrlBuilder urlBuilder;
|
||||
protected GroupedPropertyList propertyList = null;
|
||||
protected LoginStatusBean loginStatusBean = null;
|
||||
private EditingPolicyHelper policyHelper = null;
|
||||
|
||||
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
||||
this.individual = individual;
|
||||
|
@ -49,7 +46,24 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
this.loginStatusBean = loginStatusBean;
|
||||
// Needed for getting portal-sensitive urls. Remove if multi-portal support is removed.
|
||||
this.urlBuilder = new UrlBuilder(vreq.getPortal());
|
||||
|
||||
// If editing, create a helper object to check requested actions against policies
|
||||
if (isEditable(loginStatusBean)) {
|
||||
policyHelper = new EditingPolicyHelper(vreq, getServletContext());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true iff the user is editing.
|
||||
* These tests may change once self-editing issues are straightened out. What we really need to know
|
||||
* is whether the user can edit this profile, not whether in general he/she is an editor.
|
||||
*/
|
||||
private boolean isEditable(LoginStatusBean loginStatusBean) {
|
||||
boolean isSelfEditing = VitroRequestPrep.isSelfEditing(vreq);
|
||||
boolean isCurator = loginStatusBean.isLoggedInAtLeast(LoginStatusBean.CURATOR);
|
||||
return isSelfEditing || isCurator;
|
||||
}
|
||||
|
||||
|
||||
/* These methods perform some manipulation of the data returned by the Individual methods */
|
||||
|
||||
|
@ -146,7 +160,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
|
||||
public GroupedPropertyList getPropertyList() {
|
||||
if (propertyList == null) {
|
||||
propertyList = new GroupedPropertyList(individual, vreq, loginStatusBean);
|
||||
propertyList = new GroupedPropertyList(individual, vreq, policyHelper);
|
||||
}
|
||||
return propertyList;
|
||||
}
|
||||
|
@ -169,10 +183,15 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
* declare new methods here that are not declared in the Individual interface.
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
public String getName() {
|
||||
return individual.getName();
|
||||
}
|
||||
|
||||
public DataPropertyStatementTemplateModel getNameStatement() {
|
||||
String propertyUri = VitroVocabulary.LABEL;
|
||||
return new DataPropertyStatementTemplateModel(getUri(), propertyUri, vreq, policyHelper);
|
||||
}
|
||||
|
||||
public String getMoniker() {
|
||||
return individual.getMoniker();
|
||||
}
|
||||
|
@ -181,14 +200,6 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
return individual.getURI();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return individual.getDescription();
|
||||
}
|
||||
|
||||
public String getBlurb() {
|
||||
return individual.getBlurb();
|
||||
}
|
||||
|
||||
public List<String> getKeywords() {
|
||||
return individual.getKeywords();
|
||||
}
|
||||
|
@ -202,6 +213,14 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
return individual.getLocalName();
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public String getDescription() {
|
||||
return individual.getDescription();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getBlurb() {
|
||||
return individual.getBlurb();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
String command = vreq.getParameter("cmd");
|
||||
|
||||
String vitroNsProp = (String) vreq.getParameter("vitroNsProp");
|
||||
boolean isVitroNsProp = (vitroNsProp != null && vitroNsProp.equals("true")) ? true : false;
|
||||
boolean isVitroNsProp = "true".equals(vitroNsProp) ? true : false;
|
||||
|
||||
if( subjectUri == null || subjectUri.trim().length() == 0 ) {
|
||||
log.error("required subjectUri parameter missing");
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
<#else>
|
||||
<h1 class="fn">
|
||||
<#-- Label -->
|
||||
${individual.name}
|
||||
<#assign label = individual.nameStatement>
|
||||
${label.value}
|
||||
<@p.editingLinks label editing />
|
||||
|
||||
<#-- Moniker -->
|
||||
<#if individual.moniker?has_content>
|
||||
|
|
|
@ -101,8 +101,9 @@
|
|||
<#-- Convert the string dateTimeString to a datetime object -->
|
||||
<#function toDateTime dateTimeString>
|
||||
<#-- First convert the datetime string to a string format that Freemarker
|
||||
understands, then to a datetime object -->
|
||||
<#return dateTimeString?replace("T", " ")?replace("Z", "")?datetime("yyyy-MM-dd HH:mm:ss")>
|
||||
understands, then to a datetime object. For now, strip away a time zone rather
|
||||
than displaying it. -->
|
||||
<#return dateTimeString?replace("T", " ")?replace("Z.*$", "", "r")?datetime("yyyy-MM-dd HH:mm:ss")>
|
||||
</#function>
|
||||
|
||||
<#-- Apply a precision and format type to format a datetime -->
|
||||
|
|
Loading…
Add table
Reference in a new issue