Worked on java based N3 editing. NIHVIVO-2236
This commit is contained in:
parent
7f07155cf8
commit
def98f96de
9 changed files with 229 additions and 85 deletions
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
@ -57,38 +58,38 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
|||
public class EditConfigurationVTwo {
|
||||
|
||||
//Strings representing required n3 for RDF
|
||||
List<String> n3Required;
|
||||
List<String> n3Required = Collections.emptyList();
|
||||
//String representing optional N3 for RDF
|
||||
List<String> n3Optional;
|
||||
List<String> n3Optional = Collections.emptyList();
|
||||
//Names of variables of 'objects' i.e. URIs on form
|
||||
List<String> urisOnform;
|
||||
List<String> urisOnform = Collections.emptyList();
|
||||
//Names of variables corresponding to data values i.e. literals on form
|
||||
List<String> literalsOnForm;
|
||||
List<String> literalsOnForm = Collections.emptyList();
|
||||
//Names of variables corresponding to Files on form
|
||||
List<String> filesOnForm;
|
||||
List<String> filesOnForm = Collections.emptyList();
|
||||
|
||||
//Multi values now supported for uris and literals, so second parameter needs to be List<String>
|
||||
//Mapping of variable name for object to values for object, i.e. URIs, e.g. "hasElement" = "<a.com>, <b.com>"
|
||||
Map<String,List<String>> urisInScope;
|
||||
Map<String,List<String>> urisInScope = Collections.emptyMap();
|
||||
//Mapping from variable name to values for literals
|
||||
Map<String, List<Literal>> literalsInScope;
|
||||
Map<String, List<Literal>> literalsInScope = Collections.emptyMap();
|
||||
|
||||
//Map name of variable to sparql query which should return a one-column result set of URIs corresponding to variable
|
||||
//E.g. sparql for inverse of object property
|
||||
Map<String,String> sparqlForAdditionalUrisInScope;
|
||||
Map<String,String> sparqlForAdditionalUrisInScope = Collections.emptyMap();
|
||||
//Mapping variable to sparql query returning literals
|
||||
Map<String,String> sparqlForAdditionalLiteralsInScope;
|
||||
Map<String,String> sparqlForAdditionalLiteralsInScope = Collections.emptyMap();
|
||||
|
||||
//Variable names to URI prefixes for variables that are allowed to have new instances created
|
||||
Map<String,String> newResources;
|
||||
Map<String,String> newResources = Collections.emptyMap();
|
||||
|
||||
//Variable names to fields, Field = additional configuration for variable
|
||||
Map<String,FieldVTwo> fields;
|
||||
Map<String,FieldVTwo> fields = Collections.emptyMap();
|
||||
|
||||
//Mapping variable name to Sparql query to find existing literals corresponding to variable, result set should be one-column multi-row of literals
|
||||
Map<String,String>sparqlForExistingLiterals;
|
||||
Map<String,String>sparqlForExistingLiterals = Collections.emptyMap();
|
||||
//Mapping variable name to Sparql query to find existing URIs corresponding to variable, result set should be one-column multi-row of URIs/URI resources
|
||||
Map<String,String>sparqlForExistingUris;
|
||||
Map<String,String>sparqlForExistingUris = Collections.emptyMap();
|
||||
|
||||
String subjectUri;
|
||||
String varNameForSubject;
|
||||
|
@ -113,13 +114,13 @@ public class EditConfigurationVTwo {
|
|||
String formUrl;
|
||||
String editKey;
|
||||
|
||||
List<N3Validator> validators;
|
||||
List<N3Validator> validators = Collections.emptyList();
|
||||
|
||||
EditN3GeneratorVTwo n3generator;
|
||||
|
||||
private List<ModelChangePreprocessor> modelChangePreprocessors;
|
||||
private List<ModelChangePreprocessor> modelChangePreprocessors = Collections.emptyList();
|
||||
|
||||
private List<EditSubmissionVTwoPreprocessor> editSubmissionPreprocessors = null;
|
||||
private List<EditSubmissionVTwoPreprocessor> editSubmissionPreprocessors = Collections.emptyList();
|
||||
|
||||
private ProhibitedFromSearch prohibitedFromSearch;
|
||||
|
||||
|
|
|
@ -144,8 +144,40 @@ public class EditN3GeneratorVTwo {
|
|||
* subInUris should no longer be used.
|
||||
*/
|
||||
public static List<String> subInMultiLiterals(Map<String,List<Literal>> varsToVals, List<String> n3targets){
|
||||
return null;
|
||||
if( varsToVals == null || varsToVals.isEmpty()) return n3targets;
|
||||
|
||||
ArrayList<String>outv=new ArrayList<String>();
|
||||
for( String n3 : n3targets ){
|
||||
String tmp = n3;
|
||||
for( String key : varsToVals.keySet()){
|
||||
tmp = subInMultiLiterals( key, varsToVals.get(key),tmp);
|
||||
}
|
||||
}
|
||||
return n3targets;
|
||||
}
|
||||
|
||||
protected static String subInMultiLiterals(String var, List<Literal>values, String n3){
|
||||
String tmp = n3;
|
||||
|
||||
//make the multivalue literal string
|
||||
List<String> n3Values = new ArrayList<String>(values.size());
|
||||
for( Literal value : values){
|
||||
n3Values.add( formatLiteral(value) );
|
||||
}
|
||||
String valueString = org.apache.commons.lang.StringUtils.join(n3Values, ",");
|
||||
|
||||
//Substitute it in to n3
|
||||
String varRegex = "\\?" + var + "(?=\\.\\p{Space}|\\p{Space})";
|
||||
|
||||
String out = null;
|
||||
if( valueString != null )
|
||||
out = tmp.replaceAll(varRegex, Matcher.quoteReplacement( valueString ));
|
||||
else
|
||||
out = n3;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public List<String> subInLiterals(Map<String, Literal> varsToVals, List<String> targets){
|
||||
if( varsToVals == null || varsToVals.isEmpty()) return targets;
|
||||
|
@ -224,6 +256,7 @@ public class EditN3GeneratorVTwo {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public Map<String,List<String>> substituteIntoValues
|
||||
(Map<String,List<String>> varsToUris,
|
||||
Map<String,List<Literal>> varsToLiterals,
|
||||
|
@ -292,7 +325,7 @@ public class EditN3GeneratorVTwo {
|
|||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
protected String formatLiteral(Literal literal)
|
||||
protected static String formatLiteral(Literal literal)
|
||||
{
|
||||
String datatype = literal.getDatatypeURI() ;
|
||||
String lang = literal.getLanguage() ;
|
||||
|
@ -407,7 +440,7 @@ public class EditN3GeneratorVTwo {
|
|||
}
|
||||
}
|
||||
|
||||
protected String formatURI(String uriStr)
|
||||
protected static String formatURI(String uriStr)
|
||||
{
|
||||
// Not as a qname - write as a quoted URIref
|
||||
// Should we unicode escape here?
|
||||
|
|
|
@ -16,7 +16,7 @@ public class EditSubmissionUtils {
|
|||
|
||||
/* *************** Static utility methods to get EditSub from Session *********** */
|
||||
|
||||
public static MultiValueEditSubmission getEditSubmissionFromSession(HttpSession sess, EditConfiguration editConfig){
|
||||
public static MultiValueEditSubmission getEditSubmissionFromSession(HttpSession sess, EditConfigurationVTwo editConfig){
|
||||
Map<String,MultiValueEditSubmission> submissions =
|
||||
(Map<String,MultiValueEditSubmission>)sess.getAttribute(MULTI_VALUED_EDIT_SUBMISSION);
|
||||
if( submissions == null )
|
||||
|
@ -40,7 +40,7 @@ public class EditSubmissionUtils {
|
|||
public static void clearEditSubmissionInSession(HttpSession sess, MultiValueEditSubmission editSub){
|
||||
if( sess == null) return;
|
||||
if( editSub == null ) return;
|
||||
Map<String,MultiValueEditSubmission> submissions = (Map<String,MultiValueEditSubmission>)sess.getAttribute("MULTI_VALUED_EDIT_SUBMISSION");
|
||||
Map<String,MultiValueEditSubmission> submissions = (Map<String,MultiValueEditSubmission>)sess.getAttribute(MULTI_VALUED_EDIT_SUBMISSION);
|
||||
if( submissions == null ){
|
||||
throw new Error("MultiValueEditSubmission: could not get a Map of MultiValueEditSubmission from the session.");
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class EditSubmissionUtils {
|
|||
|
||||
public static void clearAllEditSubmissionsInSession(HttpSession sess ){
|
||||
if( sess == null) return;
|
||||
sess.removeAttribute("MULTI_VALUED_EDIT_SUBMISSION");
|
||||
sess.removeAttribute(MULTI_VALUED_EDIT_SUBMISSION);
|
||||
}
|
||||
|
||||
public static Map<String, String[]> convertParams(
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
|
||||
|
||||
/**
|
||||
* Generate the EditConfiguration for the Institutional Internal Class Form.
|
||||
|
@ -15,12 +18,45 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
|
|||
*/
|
||||
public class InstitutionalInternalClassForm implements EditConfigurationGenerator {
|
||||
|
||||
String INTERNAL_CLASS_ANNOTATION_URI= "<http://example.com/vivo#ChangeMeUniveristy>";
|
||||
|
||||
@Override
|
||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||
EditConfigurationVTwo editConfig = new EditConfigurationVTwo();
|
||||
|
||||
//set up the template for the form
|
||||
editConfig.setTemplate("institutionalInternalClassForm.ftl");
|
||||
|
||||
//Set the n3 that is required for the edit
|
||||
//bdc34: don't know how the annotation will be structured
|
||||
StringList n3ForInternalClass =new StringList( " ?internalClassUri "+INTERNAL_CLASS_ANNOTATION_URI+" \"true\" . " );
|
||||
editConfig.setN3Required( n3ForInternalClass );
|
||||
|
||||
//bdc34: maybe this is redundent with the keys of the fields Map?
|
||||
editConfig.setUrisOnform( new StringList( "internalClassUri" ));
|
||||
|
||||
Field field = new Field();
|
||||
field.setAssertions( n3ForInternalClass );
|
||||
|
||||
//maybe field should have a way to get an option list?
|
||||
//field.setOptionGenerator( new InternalClassOptionGenerator() );
|
||||
|
||||
//edit config should have URL to submit the form to
|
||||
//editConfig.setUrl
|
||||
//set the url pattern that the client will return to after a successful edit
|
||||
editConfig.setUrlPatternToReturnTo("/siteAdmin");
|
||||
|
||||
editConfig.setSubmitToUrl("/edit/process");
|
||||
return editConfig;
|
||||
}
|
||||
|
||||
|
||||
public class StringList extends ArrayList<String>{
|
||||
public StringList( String ... strings){
|
||||
super();
|
||||
for( String str: strings){
|
||||
this.add(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
|
||||
//what goes in the map for templates?
|
||||
Map<String,Object> templateData = new HashMap<String,Object>();
|
||||
templateData.put("EditConfiguration", new EditConfigurationTemplateModel( editConfig, vreq));
|
||||
templateData.put("editConfiguration", new EditConfigurationTemplateModel( editConfig, vreq));
|
||||
templateData.put("formTitle", formTitle);
|
||||
|
||||
return new TemplateResponseValues(template, templateData);
|
||||
|
|
|
@ -16,27 +16,33 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper.TemplateProcessingException;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditSubmissionUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.AdditionsAndRetractions;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditSubmissionUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.ProcessRdfForm;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils;
|
||||
|
||||
/**
|
||||
* This servlet will process EditConfigurations with query parameters
|
||||
|
@ -54,33 +60,25 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
|||
// this will need to be converted from a jsp to something else
|
||||
public static final String POST_EDIT_CLEANUP_JSP = "postEditCleanUp.jsp";
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
|
||||
ServletException, IOException{
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
|
||||
ServletException, IOException{
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
|
||||
@Override
|
||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
//get the EditConfiguration
|
||||
EditConfigurationVTwo configuration = getEditConfiguration(request);
|
||||
if(configuration == null){
|
||||
doEditConfigNotFound( vreq, response);
|
||||
return;
|
||||
}
|
||||
EditConfigurationVTwo configuration = getEditConfiguration(vreq);
|
||||
if(configuration == null)
|
||||
throw new Error("No edit configuration found.");
|
||||
|
||||
//get the EditSubmission
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(vreq.getParameterMap(), configuration);
|
||||
EditSubmissionUtils.putEditSubmissionInSession(request.getSession(), submission);
|
||||
EditSubmissionUtils.putEditSubmissionInSession(vreq.getSession(), submission);
|
||||
|
||||
boolean hasErrors = doValidationErrors(vreq, configuration, submission, response);
|
||||
if( hasErrors)
|
||||
return; //processValidationErrors() already forwarded to redisplay the form with validation messages
|
||||
ResponseValues errorResponse = doValidationErrors(vreq, configuration, submission);
|
||||
if( errorResponse != null )
|
||||
return errorResponse;
|
||||
|
||||
// get the models to work with in case the write model and query model are not the defaults
|
||||
OntModel queryModel = configuration.getQueryModelSelector().getModel(request, getServletContext());
|
||||
OntModel writeModel = configuration.getWriteModelSelector().getModel(request,getServletContext());
|
||||
OntModel queryModel = configuration.getQueryModelSelector().getModel(vreq, getServletContext());
|
||||
OntModel writeModel = configuration.getWriteModelSelector().getModel(vreq,getServletContext());
|
||||
|
||||
AdditionsAndRetractions changes;
|
||||
if(configuration.isUpdate()){
|
||||
|
@ -97,32 +95,32 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
|||
ProcessRdfForm.applyChangesToWriteModel(changes, queryModel, writeModel, EditN3Utils.getEditorUri(vreq) );
|
||||
|
||||
//Here we are trying to get the entity to return to URL,
|
||||
//Maybe this should be in POST_EDIT_CLEANUP?
|
||||
if( configuration.getEntityToReturnTo() != null ){
|
||||
request.setAttribute("entityToReturnTo", ProcessRdfForm.substitueForURL( configuration, submission));
|
||||
vreq.setAttribute("entityToReturnTo", ProcessRdfForm.substitueForURL( configuration, submission));
|
||||
}
|
||||
|
||||
doPostEdit(vreq,response);
|
||||
return doPostEdit(vreq);
|
||||
}
|
||||
|
||||
private EditConfigurationVTwo getEditConfiguration(HttpServletRequest request) {
|
||||
HttpSession session = request.getSession();
|
||||
EditConfigurationVTwo editConfiguration = EditConfigurationVTwo.getConfigFromSession(session, request);
|
||||
return editConfiguration;
|
||||
}
|
||||
private void doEditConfigNotFound(VitroRequest request, HttpServletResponse response) {
|
||||
HashMap<String,Object>map = new HashMap<String,Object>();
|
||||
map.put("message", "No editing configuration found, cannot process edit.");
|
||||
ResponseValues values = new TemplateResponseValues("message.ftl", map);
|
||||
try {
|
||||
doResponse(request,response,values);
|
||||
} catch (TemplateProcessingException e) {
|
||||
log.error("Could not process template for doEditConfigNotFound()",e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doValidationErrors(VitroRequest vreq,
|
||||
EditConfigurationVTwo editConfiguration, MultiValueEditSubmission submission,
|
||||
HttpServletResponse response) throws ServletException, IOException {
|
||||
// private ResponseValues doEditConfigNotFound(VitroRequest request) {
|
||||
// HashMap<String,Object>map = new HashMap<String,Object>();
|
||||
// map.put("message", "No editing configuration found, cannot process edit.");
|
||||
// ResponseValues values = new TemplateResponseValues("message.ftl", map);
|
||||
// try {
|
||||
// doResponse(request,values);
|
||||
// } catch (TemplateProcessingException e) {
|
||||
// log.error("Could not process template for doEditConfigNotFound()",e);
|
||||
// }
|
||||
// }
|
||||
|
||||
private ResponseValues doValidationErrors(VitroRequest vreq,
|
||||
EditConfigurationVTwo editConfiguration, MultiValueEditSubmission submission) {
|
||||
|
||||
Map<String, String> errors = submission.getValidationErrors();
|
||||
|
||||
|
@ -131,16 +129,85 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
|||
vreq.setAttribute("formUrl", form);
|
||||
vreq.setAttribute("view", vreq.getParameter("view"));
|
||||
|
||||
RequestDispatcher requestDispatcher = vreq.getRequestDispatcher(editConfiguration.getFormUrl());
|
||||
requestDispatcher.forward(vreq, response);
|
||||
return true;
|
||||
return new RedirectResponseValues(editConfiguration.getFormUrl());
|
||||
}
|
||||
return false;
|
||||
return null; //no errors
|
||||
}
|
||||
|
||||
private void doPostEdit(VitroRequest vreq, HttpServletResponse response) throws ServletException, IOException {
|
||||
RequestDispatcher requestDispatcher = vreq.getRequestDispatcher(POST_EDIT_CLEANUP_JSP);
|
||||
requestDispatcher.forward(vreq, response);
|
||||
private RedirectResponseValues doPostEdit(VitroRequest vreq ) {
|
||||
String resourceToRedirectTo = null;
|
||||
String urlPattern = null;
|
||||
String predicateLocalName = null;
|
||||
String predicateAnchor = "";
|
||||
HttpSession session = vreq.getSession(false);
|
||||
if( session != null ) {
|
||||
EditConfigurationVTwo editConfig = EditConfigurationVTwo.getConfigFromSession(session,vreq);
|
||||
//In order to support back button resubmissions, don't remove the editConfig from session.
|
||||
//EditConfiguration.clearEditConfigurationInSession(session, editConfig);
|
||||
|
||||
MultiValueEditSubmission editSub = EditSubmissionUtils.getEditSubmissionFromSession(session,editConfig);
|
||||
EditSubmissionUtils.clearEditSubmissionInSession(session, editSub);
|
||||
|
||||
if( editConfig != null ){
|
||||
String predicateUri = editConfig.getPredicateUri();
|
||||
if( predicateUri != null ){
|
||||
try{
|
||||
Property prop = ResourceFactory.createProperty(predicateUri);
|
||||
predicateLocalName = prop.getLocalName();
|
||||
}catch (com.hp.hpl.jena.shared.InvalidPropertyURIException e){
|
||||
log.debug("could not convert predicateUri into a valid URI",e);
|
||||
}
|
||||
}
|
||||
|
||||
if( editConfig.getEntityToReturnTo() != null && editConfig.getEntityToReturnTo().startsWith("?") ){
|
||||
resourceToRedirectTo = (String)vreq.getAttribute("entityToReturnTo");
|
||||
}else{
|
||||
resourceToRedirectTo = editConfig.getEntityToReturnTo();
|
||||
}
|
||||
|
||||
//if there is no entity to return to it is likely a cancel
|
||||
if( resourceToRedirectTo == null || resourceToRedirectTo.length() == 0 )
|
||||
resourceToRedirectTo = editConfig.getSubjectUri();
|
||||
}
|
||||
|
||||
//set up base URL
|
||||
String cancel = vreq.getParameter("cancel");
|
||||
String urlPatternToReturnTo = null;
|
||||
String urlPatternToCancelTo = null;
|
||||
if (editConfig != null) {
|
||||
urlPatternToReturnTo = editConfig.getUrlPatternToReturnTo();
|
||||
urlPatternToCancelTo = vreq.getParameter("url");
|
||||
}
|
||||
// If a different cancel return path has been designated, use it. Otherwise, use the regular return path.
|
||||
if (cancel != null && cancel.equals("true") && !StringUtils.isEmpty(urlPatternToCancelTo)) {
|
||||
urlPattern = urlPatternToCancelTo;
|
||||
} else if (!StringUtils.isEmpty(urlPatternToReturnTo)) {
|
||||
urlPattern = urlPatternToReturnTo;
|
||||
} else {
|
||||
urlPattern = "/individual";
|
||||
}
|
||||
|
||||
//looks like a redirect to a profile page, try to add anchor for property that was just edited.
|
||||
if( urlPattern.endsWith("individual") || urlPattern.endsWith("entity") ){
|
||||
if( predicateLocalName != null && predicateLocalName.length() > 0){
|
||||
predicateAnchor = "#" + predicateLocalName;
|
||||
vreq.setAttribute("predicateAnchor", predicateAnchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( resourceToRedirectTo != null ){
|
||||
UrlBuilder.ParamMap paramMap= new UrlBuilder.ParamMap();
|
||||
paramMap.put("uri", resourceToRedirectTo);
|
||||
paramMap.put("extra","true"); //for ie6
|
||||
return new RedirectResponseValues( UrlBuilder.getUrl(urlPattern,paramMap) + predicateAnchor );
|
||||
} else if ( !urlPattern.endsWith("individual") && !urlPattern.endsWith("entity") ){
|
||||
return new RedirectResponseValues( urlPattern );
|
||||
}
|
||||
|
||||
|
||||
return new RedirectResponseValues( UrlBuilder.getUrl(Route.LOGIN) );
|
||||
|
||||
}
|
||||
|
||||
//Move to EditN3Utils but keep make new uris here
|
||||
|
|
|
@ -24,6 +24,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
}
|
||||
|
||||
public String getSubmitToUrl(){
|
||||
return editConfig.getSubmitToUrl();
|
||||
return getUrl( editConfig.getSubmitToUrl() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,21 @@ Associated with generator:
|
|||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.InstitutionalInternalClassForm
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<h2>Lorem ipsum dolor sit amet</h2>
|
||||
|
||||
<form class="editForm" action = "xyz">
|
||||
<p>consectetur adipisicing elit</p>
|
||||
<input type="text" id="objectVar" size="80" />
|
||||
<div style="margin-top: 0.2em">
|
||||
<input type="submit" id="submit" value="submit" cancel="true"/>
|
||||
</div>
|
||||
</form>
|
||||
<form class="editForm" action = "${editConfiguration.submitToUrl}">
|
||||
|
||||
<p>consectetur adipisicing elit</p>
|
||||
|
||||
<input type="text" name="internalClassUri" size="80" />
|
||||
|
||||
<input type="hidden" name="editKey" value="${editConfiguration.editKey}" />
|
||||
|
||||
<div style="margin-top: 0.2em">
|
||||
<input type="submit" value="submit" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<@dumpAll/>
|
Loading…
Add table
Reference in a new issue