Updating to allow for deletion to use object property statement template model for all the list-view inclusions, and to wrap the edit configuration template model in a read only bean wrapper which allows accessing methods that require parameters. Also updating to allow menu management switching to use DirectResponseValues instead of regular Redirect, which will not do additional processing for the context path, etc.
This commit is contained in:
parent
de14c86bed
commit
fa92f36b52
5 changed files with 56 additions and 27 deletions
|
@ -32,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditSubmissionUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.EditConfigurationGenerator;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.EditConfigurationGenerator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.EditConfigurationTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.EditConfigurationTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.MultiValueEditSubmissionTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.MultiValueEditSubmissionTemplateModel;
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +106,9 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
//what goes in the map for templates?
|
//what goes in the map for templates?
|
||||||
Map<String,Object> templateData = new HashMap<String,Object>();
|
Map<String,Object> templateData = new HashMap<String,Object>();
|
||||||
EditConfigurationTemplateModel etm = new EditConfigurationTemplateModel( editConfig, vreq);
|
EditConfigurationTemplateModel etm = new EditConfigurationTemplateModel( editConfig, vreq);
|
||||||
templateData.put("editConfiguration", etm);
|
//Similar to individual controller, we're exposing getters that require paramters as well here -
|
||||||
|
//Used specifically since we are including object property statement template model
|
||||||
|
templateData.put("editConfiguration", wrap(etm, new ReadOnlyBeansWrapper()));
|
||||||
templateData.put("editSubmission", submissionTemplateModel);
|
templateData.put("editSubmission", submissionTemplateModel);
|
||||||
//Corresponding to original note for consistency with selenium tests and 1.1.1
|
//Corresponding to original note for consistency with selenium tests and 1.1.1
|
||||||
templateData.put("title", "Edit");
|
templateData.put("title", "Edit");
|
||||||
|
@ -135,7 +138,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
private ResponseValues redirectToMenuEdit(VitroRequest vreq) {
|
private ResponseValues redirectToMenuEdit(VitroRequest vreq) {
|
||||||
String queryString = vreq.getQueryString();
|
String queryString = vreq.getQueryString();
|
||||||
String redirectPage = vreq.getContextPath() + "/editDisplayModel?" + queryString;
|
String redirectPage = vreq.getContextPath() + "/editDisplayModel?" + queryString;
|
||||||
return new RedirectResponseValues(redirectPage, HttpServletResponse.SC_SEE_OTHER);
|
return new DirectRedirectResponseValues(redirectPage, HttpServletResponse.SC_SEE_OTHER);
|
||||||
|
|
||||||
}
|
}
|
||||||
private MultiValueEditSubmission getMultiValueSubmission(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
private MultiValueEditSubmission getMultiValueSubmission(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
||||||
|
|
|
@ -36,6 +36,10 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditElementVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataPropertyStatementTemplateModel;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.EditingPolicyHelper;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ObjectPropertyStatementTemplateModel;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.PropertyStatementTemplateModel;
|
||||||
|
|
||||||
public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
||||||
EditConfigurationVTwo editConfig;
|
EditConfigurationVTwo editConfig;
|
||||||
|
@ -420,24 +424,38 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Implement statement display
|
//TODO: Implement statement display
|
||||||
public Map<String, String> getStatementDisplay() {
|
public ObjectPropertyStatementTemplateModel getObjectStatementDisplay() {
|
||||||
Map<String, String> statementDisplay = new HashMap<String, String>();
|
Map<String, String> statementDisplay = new HashMap<String, String>();
|
||||||
if(isDataProperty()) {
|
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
statementDisplay.put("dataValue", getDataLiteralValuesFromParameter());
|
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
} else {
|
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||||
//Expecting statement parameters to be passed in
|
//ObjectPropertyStatementTemplate Model should pass the object key as part of the delete url
|
||||||
Map params = vreq.getParameterMap();
|
String objectKey = vreq.getParameter("objectKey");
|
||||||
for (Object key : params.keySet()) {
|
statementDisplay.put(objectKey, objectUri);
|
||||||
String keyString = (String) key; //key.toString()
|
//Set data map
|
||||||
if (keyString.startsWith("statement_")) {
|
Map params = vreq.getParameterMap();
|
||||||
keyString = keyString.replaceFirst("statement_", "");
|
for (Object key : params.keySet()) {
|
||||||
String value = ( (String[]) params.get(key))[0];
|
String keyString = (String) key; //key.toString()
|
||||||
statementDisplay.put(keyString, value);
|
if (keyString.startsWith("statement_")) {
|
||||||
}
|
keyString = keyString.replaceFirst("statement_", "");
|
||||||
}
|
String value = ( (String[]) params.get(key))[0];
|
||||||
|
statementDisplay.put(keyString, value);
|
||||||
}
|
}
|
||||||
return statementDisplay;
|
}
|
||||||
|
|
||||||
|
//Using object property statement template model here
|
||||||
|
ObjectPropertyStatementTemplateModel osm = new ObjectPropertyStatementTemplateModel(
|
||||||
|
subjectUri,
|
||||||
|
predicateUri,
|
||||||
|
objectKey,
|
||||||
|
statementDisplay,
|
||||||
|
null, null, vreq);
|
||||||
|
return osm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDataStatementDisplay() {
|
||||||
|
//Just return the value of the data property
|
||||||
|
return getDataLiteralValuesFromParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used for deletion in case there's a specific template to be employed
|
//Used for deletion in case there's a specific template to be employed
|
||||||
|
@ -464,6 +482,8 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
||||||
return dataValue;
|
return dataValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO:Check where this logic should actually go, copied from input element formatting tag
|
//TODO:Check where this logic should actually go, copied from input element formatting tag
|
||||||
public Map<String, String> getOfferTypesCreateNew() {
|
public Map<String, String> getOfferTypesCreateNew() {
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
||||||
protected String value;
|
protected String value;
|
||||||
|
|
||||||
//Extended to include vitro request to check for special parameters
|
//Extended to include vitro request to check for special parameters
|
||||||
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri,
|
public DataPropertyStatementTemplateModel(String subjectUri, String propertyUri,
|
||||||
Literal literal, EditingPolicyHelper policyHelper, VitroRequest vreq) {
|
Literal literal, EditingPolicyHelper policyHelper, VitroRequest vreq) {
|
||||||
super(subjectUri, propertyUri, policyHelper, vreq);
|
super(subjectUri, propertyUri, policyHelper, vreq);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
||||||
super(subjectUri, propertyUri, policyHelper, vreq);
|
super(subjectUri, propertyUri, policyHelper, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setValue(String value) {
|
public void setValue(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,16 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
// Used for editing
|
// Used for editing
|
||||||
private final String objectUri;
|
private final String objectUri;
|
||||||
private final String templateName;
|
private final String templateName;
|
||||||
|
private final String objectKey;
|
||||||
ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey,
|
public ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey,
|
||||||
Map<String, String> data, EditingPolicyHelper policyHelper, String templateName, VitroRequest vreq) {
|
Map<String, String> data, EditingPolicyHelper policyHelper, String templateName, VitroRequest vreq) {
|
||||||
super(subjectUri, propertyUri, policyHelper, vreq);
|
super(subjectUri, propertyUri, policyHelper, vreq);
|
||||||
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.objectUri = data.get(objectKey);
|
this.objectUri = data.get(objectKey);
|
||||||
this.templateName = templateName;
|
this.templateName = templateName;
|
||||||
|
//to keep track of later
|
||||||
|
this.objectKey = objectKey;
|
||||||
setEditUrls(policyHelper);
|
setEditUrls(policyHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +69,8 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
"subjectUri", subjectUri,
|
"subjectUri", subjectUri,
|
||||||
"predicateUri", propertyUri,
|
"predicateUri", propertyUri,
|
||||||
"objectUri", objectUri,
|
"objectUri", objectUri,
|
||||||
"cmd", "delete");
|
"cmd", "delete",
|
||||||
|
"objectKey", objectKey);
|
||||||
|
|
||||||
for ( String key : data.keySet() ) {
|
for ( String key : data.keySet() ) {
|
||||||
String value = data.get(key);
|
String value = data.get(key);
|
||||||
|
|
|
@ -4,20 +4,23 @@
|
||||||
|
|
||||||
<#if editConfiguration.objectProperty = true>
|
<#if editConfiguration.objectProperty = true>
|
||||||
<#assign toBeDeletedClass = "objProp" />
|
<#assign toBeDeletedClass = "objProp" />
|
||||||
|
<#assign statement = editConfiguration.objectStatementDisplay />
|
||||||
|
<#else>
|
||||||
|
<#assign statement = editConfiguration.dataStatementDisplay />
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#assign deletionTemplateName = editConfiguration.deleteTemplate/>
|
<#assign deletionTemplateName = editConfiguration.deleteTemplate/>
|
||||||
<#assign statement = editConfiguration.statementDisplay />
|
|
||||||
<form action="${editConfiguration.deleteProcessingUrl}" method="get">
|
<form action="${editConfiguration.deleteProcessingUrl}" method="get">
|
||||||
<h2>Are you sure you want to delete the following entry from <em>${editConfiguration.propertyName}</em>?</h2>
|
<h2>Are you sure you want to delete the following entry from <em>${editConfiguration.propertyName}</em>?</h2>
|
||||||
|
|
||||||
<p class="toBeDeleted ${toBeDeletedClass}">
|
<p class="toBeDeleted ${toBeDeletedClass}">
|
||||||
<#if editConfiguration.objectProperty = true>
|
<#if editConfiguration.objectProperty = true>
|
||||||
<#if statement?has_content && (statement?keys?size > 0)>
|
<#if statement?has_content>
|
||||||
<#include deletionTemplateName />
|
<#include deletionTemplateName />
|
||||||
</#if>
|
</#if>
|
||||||
<#else>
|
<#else>
|
||||||
${statement.dataValue}
|
${statement}
|
||||||
</#if>
|
</#if>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue