NIHVIVO-1332 Editing link for rdfs🏷️ fix error when the individual has only a local name but no label
This commit is contained in:
parent
50edcb5bbf
commit
78f9a3f116
2 changed files with 28 additions and 11 deletions
|
@ -26,29 +26,41 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
||||||
private static final Log log = LogFactory.getLog(DataPropertyStatementTemplateModel.class);
|
private static final Log log = LogFactory.getLog(DataPropertyStatementTemplateModel.class);
|
||||||
private static final String EDIT_PATH = "edit/editDatapropStmtRequestDispatch.jsp";
|
private static final String EDIT_PATH = "edit/editDatapropStmtRequestDispatch.jsp";
|
||||||
|
|
||||||
private Literal value;
|
private String value = null;
|
||||||
|
|
||||||
// Used for editing
|
// Used for editing
|
||||||
private String dataPropHash = null;
|
private String dataPropHash = null;
|
||||||
|
|
||||||
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri,
|
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri,
|
||||||
Literal value, EditingPolicyHelper policyHelper) {
|
Literal literal, EditingPolicyHelper policyHelper) {
|
||||||
super(subjectUri, propertyUri, policyHelper);
|
super(subjectUri, propertyUri, policyHelper);
|
||||||
|
|
||||||
this.value = value;
|
this.value = literal.getLexicalForm();
|
||||||
setEditAccess(value, policyHelper);
|
setEditAccess(literal, policyHelper);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method handles the special case where we are creating a DataPropertyStatementTemplateModel outside the GroupedPropertyList.
|
||||||
|
* Specifically, it allows rdfs:label to be treated like a data property statement and thus have editing links. It could potentially
|
||||||
|
* be used for other properties outside the property list as well.
|
||||||
|
*/
|
||||||
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq, EditingPolicyHelper policyHelper) {
|
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq, EditingPolicyHelper policyHelper) {
|
||||||
super(subjectUri, propertyUri, policyHelper);
|
super(subjectUri, propertyUri, policyHelper);
|
||||||
|
|
||||||
DataPropertyStatementDao dpsDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
|
DataPropertyStatementDao dpsDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
|
||||||
List<Literal> values = dpsDao.getDataPropertyValuesForIndividualByProperty(subjectUri, propertyUri);
|
List<Literal> literals = dpsDao.getDataPropertyValuesForIndividualByProperty(subjectUri, propertyUri);
|
||||||
|
|
||||||
value = values.get(0);
|
// Make sure the subject has a value for this property
|
||||||
setEditAccess(value, policyHelper);
|
if (literals.size() > 0) {
|
||||||
|
Literal literal = literals.get(0);
|
||||||
|
value = literal.getLexicalForm();
|
||||||
|
setEditAccess(literal, policyHelper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditAccess(Literal value, EditingPolicyHelper policyHelper) {
|
private void setEditAccess(Literal value, EditingPolicyHelper policyHelper) {
|
||||||
|
@ -80,7 +92,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
||||||
/* Access methods for templates */
|
/* Access methods for templates */
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value.getLexicalForm();
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditUrl() {
|
public String getEditUrl() {
|
||||||
|
|
|
@ -188,8 +188,13 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataPropertyStatementTemplateModel getNameStatement() {
|
public DataPropertyStatementTemplateModel getNameStatement() {
|
||||||
String propertyUri = VitroVocabulary.LABEL;
|
String propertyUri = VitroVocabulary.LABEL; // rdfs:label
|
||||||
return new DataPropertyStatementTemplateModel(getUri(), propertyUri, vreq, policyHelper);
|
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() {
|
public String getMoniker() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue