NIHVIVO-1704 Enable jump links after returning to individual profile after submitting an editing form. Pass property all the way down the property display macro chain, so any macro has access to property attributes like name, localname, and uri. Provide PropertyTemplateModel.getLocalName() and PropertyTemplateModel.getUri() for this purpose.

This commit is contained in:
rjy7 2011-01-18 21:21:14 +00:00
parent 346d7ba4ce
commit ce76206f7c
7 changed files with 49 additions and 46 deletions

View file

@ -46,7 +46,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
if (policyHelper != null) {
// If the display limit has already been reached, we can't add a new statement
int displayLimit = dp.getDisplayLimit();
// Display limit of -1 (default value for new property) doesn't count
// Display limit of -1 (default value for new property) means no display limit
if ( (displayLimit < 0) || (displayLimit > statements.size()) ) {
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
if (policyHelper.isAuthorizedAction(action)) {

View file

@ -140,7 +140,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
return propertyList;
}
public boolean getShowEditingLinks() {
public boolean isEditable() {
// RY This will be improved later. What is important is not whether the user is a self-editor,
// but whether he has editing privileges on this profile.
return VitroRequestPrep.isSelfEditing(vreq) ||

View file

@ -17,6 +17,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
private static final Log log = LogFactory.getLog(PropertyTemplateModel.class);
private String name;
private String localName;
protected String propertyUri;
// For editing
@ -24,10 +25,12 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
protected boolean addAccess = false;
PropertyTemplateModel(Property property, Individual subject, EditingPolicyHelper policyHelper) {
propertyUri = property.getURI();
localName = property.getLocalName();
// Do in subclass constructor. The label has not been set on the property, and the
// means of getting the label differs between object and data properties.
// this.name = property.getLabel();
propertyUri = property.getURI();
if (policyHelper != null) {
subjectUri = subject.getURI();
@ -38,10 +41,6 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
this.name = name;
}
protected String getUri() {
return propertyUri;
}
/* Access methods for templates */
@ -51,7 +50,14 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
return name;
}
public String getLocalName() {
return localName;
}
public String getUri() {
return propertyUri;
}
public abstract String getAddUrl();
}