NIHVIVO-1332 Links to add new data property statement.
This commit is contained in:
parent
86b6d57fcf
commit
9a344cfc89
1 changed files with 23 additions and 0 deletions
|
@ -8,10 +8,17 @@ import java.util.List;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropStmt;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
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;
|
||||
|
||||
public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||
|
@ -19,6 +26,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
|||
private static final Log log = LogFactory.getLog(DataPropertyTemplateModel.class);
|
||||
|
||||
private static final String TYPE = "data";
|
||||
private static final String EDIT_PATH = "edit/editDatapropStmtRequestDispatch.jsp";
|
||||
|
||||
private List<DataPropertyStatementTemplateModel> statements;
|
||||
|
||||
|
@ -27,6 +35,15 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
|||
|
||||
setName(dp.getPublicName());
|
||||
|
||||
// Determine whether a new statement can be added
|
||||
if (policyHelper != null) {
|
||||
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
|
||||
PolicyDecision decision = policyHelper.getPolicyDecision(action);
|
||||
if( decision != null && decision.getAuthorized() == Authorization.AUTHORIZED ) {
|
||||
addAccess = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the data property statements via a sparql query
|
||||
DataPropertyStatementDao dpDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
|
||||
List<DataPropertyStatement> dpStatements = dpDao.getDataPropertyStatementsForIndividualByProperty(subject, dp);
|
||||
|
@ -45,6 +62,12 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
|||
@Override
|
||||
public String getAddUrl() {
|
||||
String addUrl = "";
|
||||
if (addAccess) {
|
||||
ParamMap params = new ParamMap(
|
||||
"subjectUri", subjectUri,
|
||||
"predicateUri", propertyUri);
|
||||
addUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||
}
|
||||
return addUrl;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue