NIHVIVO-1332 Editing link for rdfs:label

This commit is contained in:
rjy7 2011-01-13 00:38:26 +00:00
parent d99c66c746
commit 00691d1d40
3 changed files with 23 additions and 18 deletions

View file

@ -79,7 +79,8 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
}
// Determine whether the statement can be deleted
if ( ! propertyUri.equals(VitroVocabulary.LABEL)) {
// Hack for rdfs:label - the policy doesn't prevent deletion
if ( ! propertyUri.equals(VitroVocabulary.LABEL) ) {
action = new DropDataPropStmt(dps);
if (policyHelper.isAuthorizedAction(action)) {
markDeletable();
@ -105,10 +106,6 @@ 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;

View file

@ -175,6 +175,20 @@ public class IndividualTemplateModel extends BaseTemplateModel {
public boolean getShowAdminPanel() {
return loginStatusBean.isLoggedInAtLeast(LoginStatusBean.EDITOR);
}
public DataPropertyStatementTemplateModel getNameStatement() {
String propertyUri = VitroVocabulary.LABEL; // rdfs:label
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(getUri(), propertyUri, vreq, policyHelper);
// If the individual has no rdfs:label, return the local name. It will not be editable (this replicates previous behavior;
// perhaps we would want to allow a label to be added. But such individuals do not usually have their profiles viewed or
// edited directly.
if (dpstm.getValue() == null) {
dpstm.setValue(getLocalName());
}
return dpstm;
}
/* These methods simply forward to the methods of the wrapped individual. It would be desirable to
* implement a scheme for proxying or delegation so that the methods don't need to be simply listed here.
@ -186,17 +200,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
public String getName() {
return individual.getName();
}
public DataPropertyStatementTemplateModel getNameStatement() {
String propertyUri = VitroVocabulary.LABEL; // rdfs:label
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(getUri(), propertyUri, vreq, policyHelper);
// If the individual has no rdfs:label, return the local name. It will correctly not be editable.
if (dpstm.getValue() == null) {
dpstm.setValue(getLocalName());
}
return dpstm;
}
public String getMoniker() {
return individual.getMoniker();
}

View file

@ -12,6 +12,7 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
@ -58,7 +59,11 @@
String command = vreq.getParameter("cmd");
String vitroNsProp = (String) vreq.getParameter("vitroNsProp");
boolean isVitroNsProp = "true".equals(vitroNsProp) ? true : false;
boolean isVitroNsProp = false;
if ( "true".equals(vitroNsProp) || predicateUri.equals(VitroVocabulary.LABEL) ) {
isVitroNsProp = true;
}
if( subjectUri == null || subjectUri.trim().length() == 0 ) {
log.error("required subjectUri parameter missing");
@ -87,7 +92,6 @@
DataProperty dataproperty = wdf.getDataPropertyDao().getDataPropertyByURI( predicateUri );
if( dataproperty == null) {
// No dataproperty will be returned for a vitro ns prop, but we shouldn't throw an error.
// RY This is not necessarily true...
if (!isVitroNsProp) {
log.error("Could not find data property '"+predicateUri+"' in model");
throw new Error("editDatapropStmtRequest.jsp: Could not find DataProperty in model: " + predicateUri);