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.configuration.generators.EditConfigurationGenerator;
|
||||
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.MultiValueEditSubmissionTemplateModel;
|
||||
/**
|
||||
|
@ -105,7 +106,9 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
//what goes in the map for templates?
|
||||
Map<String,Object> templateData = new HashMap<String,Object>();
|
||||
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);
|
||||
//Corresponding to original note for consistency with selenium tests and 1.1.1
|
||||
templateData.put("title", "Edit");
|
||||
|
@ -135,7 +138,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
private ResponseValues redirectToMenuEdit(VitroRequest vreq) {
|
||||
String queryString = vreq.getQueryString();
|
||||
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) {
|
||||
|
|
|
@ -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.SelectListGeneratorVTwo;
|
||||
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 {
|
||||
EditConfigurationVTwo editConfig;
|
||||
|
@ -420,24 +424,38 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
}
|
||||
|
||||
//TODO: Implement statement display
|
||||
public Map<String, String> getStatementDisplay() {
|
||||
public ObjectPropertyStatementTemplateModel getObjectStatementDisplay() {
|
||||
Map<String, String> statementDisplay = new HashMap<String, String>();
|
||||
if(isDataProperty()) {
|
||||
statementDisplay.put("dataValue", getDataLiteralValuesFromParameter());
|
||||
} else {
|
||||
//Expecting statement parameters to be passed in
|
||||
Map params = vreq.getParameterMap();
|
||||
for (Object key : params.keySet()) {
|
||||
String keyString = (String) key; //key.toString()
|
||||
if (keyString.startsWith("statement_")) {
|
||||
keyString = keyString.replaceFirst("statement_", "");
|
||||
String value = ( (String[]) params.get(key))[0];
|
||||
statementDisplay.put(keyString, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return statementDisplay;
|
||||
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||
//ObjectPropertyStatementTemplate Model should pass the object key as part of the delete url
|
||||
String objectKey = vreq.getParameter("objectKey");
|
||||
statementDisplay.put(objectKey, objectUri);
|
||||
//Set data map
|
||||
Map params = vreq.getParameterMap();
|
||||
for (Object key : params.keySet()) {
|
||||
String keyString = (String) key; //key.toString()
|
||||
if (keyString.startsWith("statement_")) {
|
||||
keyString = keyString.replaceFirst("statement_", "");
|
||||
String value = ( (String[]) params.get(key))[0];
|
||||
statementDisplay.put(keyString, value);
|
||||
}
|
||||
}
|
||||
|
||||
//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
|
||||
|
@ -464,6 +482,8 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
return dataValue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO:Check where this logic should actually go, copied from input element formatting tag
|
||||
public Map<String, String> getOfferTypesCreateNew() {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
|||
protected String value;
|
||||
|
||||
//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) {
|
||||
super(subjectUri, propertyUri, policyHelper, vreq);
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
|||
super(subjectUri, propertyUri, policyHelper, vreq);
|
||||
}
|
||||
|
||||
protected void setValue(String value) {
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,16 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
|||
// Used for editing
|
||||
private final String objectUri;
|
||||
private final String templateName;
|
||||
|
||||
ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey,
|
||||
private final String objectKey;
|
||||
public ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey,
|
||||
Map<String, String> data, EditingPolicyHelper policyHelper, String templateName, VitroRequest vreq) {
|
||||
super(subjectUri, propertyUri, policyHelper, vreq);
|
||||
|
||||
this.data = data;
|
||||
this.objectUri = data.get(objectKey);
|
||||
this.templateName = templateName;
|
||||
//to keep track of later
|
||||
this.objectKey = objectKey;
|
||||
setEditUrls(policyHelper);
|
||||
}
|
||||
|
||||
|
@ -67,7 +69,8 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
|||
"subjectUri", subjectUri,
|
||||
"predicateUri", propertyUri,
|
||||
"objectUri", objectUri,
|
||||
"cmd", "delete");
|
||||
"cmd", "delete",
|
||||
"objectKey", objectKey);
|
||||
|
||||
for ( String key : data.keySet() ) {
|
||||
String value = data.get(key);
|
||||
|
|
|
@ -4,20 +4,23 @@
|
|||
|
||||
<#if editConfiguration.objectProperty = true>
|
||||
<#assign toBeDeletedClass = "objProp" />
|
||||
<#assign statement = editConfiguration.objectStatementDisplay />
|
||||
<#else>
|
||||
<#assign statement = editConfiguration.dataStatementDisplay />
|
||||
</#if>
|
||||
|
||||
<#assign deletionTemplateName = editConfiguration.deleteTemplate/>
|
||||
<#assign statement = editConfiguration.statementDisplay />
|
||||
|
||||
<form action="${editConfiguration.deleteProcessingUrl}" method="get">
|
||||
<h2>Are you sure you want to delete the following entry from <em>${editConfiguration.propertyName}</em>?</h2>
|
||||
|
||||
<p class="toBeDeleted ${toBeDeletedClass}">
|
||||
<#if editConfiguration.objectProperty = true>
|
||||
<#if statement?has_content && (statement?keys?size > 0)>
|
||||
<#if statement?has_content>
|
||||
<#include deletionTemplateName />
|
||||
</#if>
|
||||
<#else>
|
||||
${statement.dataValue}
|
||||
${statement}
|
||||
</#if>
|
||||
</p>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue