Updates for n3 editing and freemarker conversion. Also fixing propDelete.jsp's reference to freemarker configuration loading to include correct method call.
This commit is contained in:
parent
23b55d2ae6
commit
591af24749
15 changed files with 356 additions and 112 deletions
|
@ -6,7 +6,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -37,6 +37,7 @@ import com.hp.hpl.jena.rdf.model.StmtIterator;
|
|||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
|
@ -75,9 +76,7 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
} else {
|
||||
processDataProperty(vreq);
|
||||
}
|
||||
//Get subject, predicate uri ,
|
||||
//Redirect
|
||||
//return new TemplateResponseValues(editConfig.getTemplate(), map);
|
||||
|
||||
String redirectUrl = getRedirectUrl(vreq);
|
||||
return new RedirectResponseValues(redirectUrl, HttpServletResponse.SC_SEE_OTHER);
|
||||
}
|
||||
|
@ -89,8 +88,8 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
int hashIndex = predicateUri.lastIndexOf("#");
|
||||
String localName = predicateUri.substring(hashIndex + 1);
|
||||
String redirectUrl = "/entity?uri=" + subjectUri;
|
||||
return null;
|
||||
String redirectUrl = "/entity?uri=" + URLEncoder.encode(subjectUri);
|
||||
return redirectUrl + "#" + URLEncoder.encode(localName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,7 +112,8 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
return "In delete property controller, could not find object property " + predicateUri;
|
||||
}
|
||||
} else {
|
||||
DataProperty prop = EditConfigurationUtils.getDataProperty(vreq);
|
||||
DataProperty prop = getDataProperty(vreq);
|
||||
|
||||
if(prop == null) {
|
||||
return "In delete property controller, could not find data property " + predicateUri;
|
||||
}
|
||||
|
@ -123,6 +123,18 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
|
||||
}
|
||||
|
||||
private DataProperty getDataProperty(VitroRequest vreq) {
|
||||
//This is the standard mechanism but note that datapropStmtDelete uses wdf with user aware
|
||||
|
||||
//DataProperty prop = EditConfigurationUtils.getDataProperty(vreq);
|
||||
String editorUri = EditN3Utils.getEditorUri(vreq);
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory().getUserAwareDaoFactory(editorUri);
|
||||
DataProperty prop = wdf.getDataPropertyDao().getDataPropertyByURI(
|
||||
EditConfigurationUtils.getPredicateUri(vreq));
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
private TemplateResponseValues doErrorMessage(String errorMessage) {
|
||||
HashMap<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("errorMessage", errorMessage);
|
||||
|
@ -137,33 +149,51 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
private void deleteDataPropertyStatement(VitroRequest vreq) {
|
||||
Individual subject = EditConfigurationUtils.getSubjectIndividual(vreq);
|
||||
//TODO: if null, need to throw or show error
|
||||
int dataHash = getDataHash(vreq);
|
||||
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
|
||||
int dataHash = EditConfigurationUtils.getDataHash(vreq);
|
||||
DataPropertyStatement dps = EditConfigurationUtils.getDataPropertyStatement(vreq, vreq.getSession(), dataHash, predicateUri);
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
|
||||
|
||||
|
||||
if(dps != null) {
|
||||
logDataPropertyDeletionMessages(dps);
|
||||
processDataPropertyStatement(dps, subjectUri, predicateUri);
|
||||
wdf.getDataPropertyStatementDao().deleteDataPropertyStatement(dps);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int getDataHash(VitroRequest vreq) {
|
||||
int dataHash = 0;
|
||||
String datapropKey = EditConfigurationUtils.getDataPropKey(vreq);
|
||||
if (datapropKey!=null && datapropKey.trim().length()>0) {
|
||||
try {
|
||||
dataHash = Integer.parseInt(datapropKey);
|
||||
} catch (NumberFormatException ex) {
|
||||
log.error("Cannot decode incoming dataprop key str " + datapropKey + "as integer hash");
|
||||
//throw new JspException("Cannot decode incoming datapropKey String value "+datapropKeyStr+" as an integer hash in datapropStmtDelete.jsp");
|
||||
}
|
||||
private void processDataPropertyStatement(
|
||||
DataPropertyStatement dps, String subjectUri, String predicateUri) {
|
||||
//if no individual Uri set to subject uri
|
||||
if( dps.getIndividualURI() == null || dps.getIndividualURI().trim().length() == 0){
|
||||
log.debug("adding missing subjectURI to DataPropertyStatement" );
|
||||
dps.setIndividualURI( subjectUri );
|
||||
}
|
||||
//if no predicate, set predicate uri
|
||||
if( dps.getDatapropURI() == null || dps.getDatapropURI().trim().length() == 0){
|
||||
log.debug("adding missing datapropUri to DataPropertyStatement");
|
||||
dps.setDatapropURI( predicateUri );
|
||||
}
|
||||
return dataHash;
|
||||
}
|
||||
|
||||
|
||||
private void logDataPropertyDeletionMessages(DataPropertyStatement dps) {
|
||||
log.debug("attempting to delete dataPropertyStatement: subjectURI <" + dps.getIndividualURI() +">");
|
||||
log.debug( "predicateURI <" + dps.getDatapropURI() + ">");
|
||||
log.debug( "literal \"" + dps.getData() + "\"" );
|
||||
log.debug( "lang @" + (dps.getLanguage() == null ? "null" : dps.getLanguage()));
|
||||
log.debug( "datatype ^^" + (dps.getDatatypeURI() == null ? "null" : dps.getDatatypeURI() ));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//process object property
|
||||
private void processObjectProperty(VitroRequest vreq) {
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
|
|
|
@ -8,12 +8,16 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.EditConfigurationTemplateModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
|
@ -21,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
|
||||
public class EditConfigurationUtils {
|
||||
private static Log log = LogFactory.getLog(EditConfigurationUtils.class);
|
||||
|
||||
protected static final String MULTI_VALUED_EDIT_SUBMISSION = "MultiValueEditSubmission";
|
||||
|
||||
|
@ -158,5 +163,20 @@ public class EditConfigurationUtils {
|
|||
}
|
||||
return dps;
|
||||
}
|
||||
|
||||
//TODO: Include get object property statement
|
||||
public static int getDataHash(VitroRequest vreq) {
|
||||
int dataHash = 0;
|
||||
String datapropKey = EditConfigurationUtils.getDataPropKey(vreq);
|
||||
if (datapropKey!=null && datapropKey.trim().length()>0) {
|
||||
try {
|
||||
dataHash = Integer.parseInt(datapropKey);
|
||||
} catch (NumberFormatException ex) {
|
||||
log.error("Cannot decode incoming dataprop key str " + datapropKey + "as integer hash");
|
||||
//throw new JspException("Cannot decode incoming datapropKey String value "+datapropKeyStr+" as an integer hash in datapropStmtDelete.jsp");
|
||||
}
|
||||
}
|
||||
return dataHash;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public class EditConfigurationVTwo {
|
|||
|
||||
EditN3GeneratorVTwo n3generator;
|
||||
|
||||
private List<ModelChangePreprocessor> modelChangePreprocessors = Collections.emptyList();
|
||||
private List<ModelChangePreprocessor> modelChangePreprocessors;
|
||||
|
||||
private List<EditSubmissionVTwoPreprocessor> editSubmissionPreprocessors = Collections.emptyList();
|
||||
|
||||
|
@ -157,6 +157,7 @@ public class EditConfigurationVTwo {
|
|||
queryModelSelector = StandardModelSelector.selector;
|
||||
resourceModelSelector = StandardModelSelector.selector;
|
||||
wdfSelectorForOptons = StandardWDFSelector.selector;
|
||||
modelChangePreprocessors = new LinkedList<ModelChangePreprocessor>();
|
||||
}
|
||||
|
||||
//Make copy of edit configuration object
|
||||
|
|
|
@ -237,7 +237,7 @@ public class DefaultAddMissingIndividualFormGenerator implements EditConfigurati
|
|||
//asserted types string buffer is empty in the original jsp
|
||||
//TODO: Review original comments in jsp to see what could go here
|
||||
//n3Optional.add(getN3AssertedTypes(vreq));
|
||||
n3Optional.add(getFlagURI(vreq));
|
||||
n3Optional.add("?" + objectVarName + " rdf:type " + getFlagURI(vreq));
|
||||
return n3Optional;
|
||||
|
||||
}
|
||||
|
@ -386,8 +386,10 @@ public class DefaultAddMissingIndividualFormGenerator implements EditConfigurati
|
|||
//if object property
|
||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
if(isForwardToCreateButEdit(vreq) ||
|
||||
objectIndividual != null) {
|
||||
if(!isReplaceWithNew(vreq) &&
|
||||
(isForwardToCreateButEdit(vreq) ||
|
||||
objectIndividual != null)
|
||||
) {
|
||||
editConfiguration.prepareForObjPropUpdate(model);
|
||||
} else {
|
||||
//new object to be created
|
||||
|
|
|
@ -49,8 +49,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
final String DEFAULT_DATA_FORM = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.DefaultDataPropertyFormGenerator";
|
||||
//TODO: Create this generator
|
||||
final String RDFS_LABEL_FORM = "";
|
||||
final String DEFAULT_ERROR_FORM = "error.jsp";
|
||||
final String DEFAULT_ADD_INDIVIDUAL = "defaultAddMissingIndividualForm.jsp";
|
||||
final String DEFAULT_DELETE_FORM = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.DefaultDeleteGenerator";
|
||||
@Override
|
||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
|
||||
|
@ -61,9 +60,11 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
if(isErrorCondition(vreq)){
|
||||
return doHelp(vreq, getErrorMessage(vreq));
|
||||
}
|
||||
//TODO: Check if skip edit form needs to go here or elsewhere
|
||||
//in case form needs to be redirected b/c of special individuals
|
||||
// processSkipEditForm(vreq);
|
||||
|
||||
//if edit form needs to be skipped to object instead
|
||||
if(isSkipEditForm(vreq)) {
|
||||
return processSkipEditForm(vreq);
|
||||
}
|
||||
|
||||
//Get the edit generator name
|
||||
String editConfGeneratorName = processEditConfGeneratorName(vreq);
|
||||
|
@ -132,8 +133,12 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
String editConfGeneratorName = DEFAULT_OBJ_FORM;
|
||||
String predicateUri = getPredicateUri(vreq);
|
||||
String formParam = getFormParam(vreq);
|
||||
//Handle deletion before any of the other cases
|
||||
if(isDeleteForm(vreq)) {
|
||||
editConfGeneratorName = DEFAULT_DELETE_FORM;
|
||||
}
|
||||
// *** handle the case where the form is specified as a request parameter ***
|
||||
if( predicateUri == null && ( formParam != null && !formParam.isEmpty()) ){
|
||||
else if( predicateUri == null && ( formParam != null && !formParam.isEmpty()) ){
|
||||
//form parameter must be a fully qualified java class name of a EditConfigurationVTwoGenerator implementation.
|
||||
editConfGeneratorName = formParam;
|
||||
} else if(isVitroLabel(predicateUri)) { //in case of data property
|
||||
|
@ -170,10 +175,9 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
|
||||
|
||||
//TODO: Implement below correctly or integrate
|
||||
private ResponseValues processSkipEditForm(VitroRequest vreq) {
|
||||
//Certain predicates may be annotated to change the behavior of the edit
|
||||
//if skip edit form
|
||||
private boolean isSkipEditForm(VitroRequest vreq) {
|
||||
//Certain predicates may be annotated to change the behavior of the edit
|
||||
//link. Check for this annotation and, if present, simply redirect
|
||||
//to the normal individual display for the object URI instead of bringing
|
||||
//up an editing form.
|
||||
|
@ -183,16 +187,19 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
String predicateUri = vreq.getParameter("predicateUri");
|
||||
boolean isEditOfExistingStmt = isEditOfExistingStmt(vreq);
|
||||
|
||||
if ( isEditOfExistingStmt && (wdf.getObjectPropertyDao().skipEditForm(predicateUri)) ) {
|
||||
log.debug("redirecting to object for predicate " + predicateUri);
|
||||
String redirectPage = vreq.getContextPath() + "/individual";
|
||||
redirectPage += "uri=" + URLEncoder.encode(vreq.getParameter("objectUri")) +
|
||||
"&relatedSubjectUri=" + URLEncoder.encode(vreq.getParameter("subjectUri")) +
|
||||
"&relatingPredicateUri=" + URLEncoder.encode(vreq.getParameter("predicateUri"));
|
||||
return new RedirectResponseValues(redirectPage, HttpServletResponse.SC_SEE_OTHER);
|
||||
}
|
||||
return null;
|
||||
return (isEditOfExistingStmt && (wdf.getObjectPropertyDao().skipEditForm(predicateUri)));
|
||||
}
|
||||
|
||||
//TODO: Implement below correctly or integrate
|
||||
private ResponseValues processSkipEditForm(VitroRequest vreq) {
|
||||
String redirectPage = vreq.getContextPath() + "/individual";
|
||||
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
redirectPage += "uri=" + URLEncoder.encode(objectUri) +
|
||||
"&relatedSubjectUri=" + URLEncoder.encode(subjectUri) +
|
||||
"&relatingPredicateUri=" + URLEncoder.encode(predicateUri);
|
||||
return new RedirectResponseValues(redirectPage, HttpServletResponse.SC_SEE_OTHER);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
|
||||
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.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||
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.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.controller.ProcessRdfFormController.Utilities;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
||||
/**
|
||||
* This servlet will process EditConfigurations with query parameters
|
||||
* to perform an edit.
|
||||
*
|
||||
* TODO: rename this class ProcessN3Edit
|
||||
*/
|
||||
public class PostEditCleanupController extends FreemarkerHttpServlet{
|
||||
|
||||
private Log log = LogFactory.getLog(PostEditCleanupController.class);
|
||||
|
||||
|
||||
//bdc34: this is likely to become a servlet instead of a jsp.
|
||||
// You can get a reference to the servlet from the context.
|
||||
// this will need to be converted from a jsp to something else
|
||||
|
||||
@Override
|
||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
EditConfigurationVTwo configuration = EditConfigurationVTwo.getConfigFromSession(vreq.getSession(), vreq);
|
||||
if(configuration == null)
|
||||
throw new Error("No edit configuration found.");
|
||||
|
||||
//get the EditSubmission
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(vreq.getParameterMap(), configuration);
|
||||
String entityToReturnTo = ProcessRdfForm.processEntityToReturnTo(configuration, submission, vreq);
|
||||
return doPostEdit(vreq, entityToReturnTo);
|
||||
}
|
||||
|
||||
|
||||
public static RedirectResponseValues doPostEdit(VitroRequest vreq, String resourceToRedirectTo ) {
|
||||
String urlPattern = 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);
|
||||
|
||||
//Get prop local name if it exists
|
||||
String predicateLocalName = Utilities.getPredicateLocalName(editConfig);
|
||||
|
||||
//Get url pattern
|
||||
urlPattern = Utilities.getPostEditUrlPattern(vreq, editConfig);
|
||||
predicateAnchor = Utilities.getPredicateAnchorPostEdit(urlPattern, predicateLocalName);
|
||||
if(predicateAnchor != null && !predicateAnchor.isEmpty()) {
|
||||
vreq.setAttribute("predicateAnchor", predicateAnchor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Redirect appropriately
|
||||
if( resourceToRedirectTo != null ){
|
||||
ParamMap paramMap = new ParamMap();
|
||||
paramMap.put("uri", resourceToRedirectTo);
|
||||
paramMap.put("extra","true"); //for ie6
|
||||
return new RedirectResponseValues( UrlBuilder.getPath(urlPattern,paramMap) + predicateAnchor );
|
||||
} else if ( !urlPattern.endsWith("individual") && !urlPattern.endsWith("entity") ){
|
||||
return new RedirectResponseValues( urlPattern );
|
||||
}
|
||||
return new RedirectResponseValues( UrlBuilder.getUrl(Route.LOGIN) );
|
||||
}
|
||||
|
||||
}
|
|
@ -65,7 +65,6 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
|||
//bdc34: this is likely to become a servlet instead of a jsp.
|
||||
// You can get a reference to the servlet from the context.
|
||||
// this will need to be converted from a jsp to something else
|
||||
public static final String POST_EDIT_CLEANUP_JSP = "postEditCleanUp.jsp";
|
||||
|
||||
@Override
|
||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
|
@ -111,7 +110,7 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
|||
String entityToReturnTo = ProcessRdfForm.processEntityToReturnTo(configuration, submission, vreq);
|
||||
//For data property processing, need to update edit configuration for back button
|
||||
ProcessRdfForm.updateEditConfigurationForBackButton(configuration, submission, vreq, writeModel);
|
||||
return doPostEdit(vreq, entityToReturnTo);
|
||||
return PostEditCleanupController.doPostEdit(vreq, entityToReturnTo);
|
||||
}
|
||||
|
||||
//In case of back button confusion
|
||||
|
@ -208,49 +207,7 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
|||
}
|
||||
return null; //no errors
|
||||
}
|
||||
|
||||
//TODO: Is this the equivalent of post Edit Cleanup
|
||||
//Also do we wish to continue setting attributes on the request?
|
||||
|
||||
private RedirectResponseValues doPostEdit(VitroRequest vreq, String resourceToRedirectTo ) {
|
||||
String urlPattern = 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);
|
||||
|
||||
//Get prop local name if it exists
|
||||
String predicateLocalName = Utilities.getPredicateLocalName(editConfig);
|
||||
|
||||
//Get url pattern
|
||||
urlPattern = Utilities.getPostEditUrlPattern(vreq, editConfig);
|
||||
predicateAnchor = Utilities.getPredicateAnchorPostEdit(urlPattern, predicateLocalName);
|
||||
if(predicateAnchor != null && !predicateAnchor.isEmpty()) {
|
||||
vreq.setAttribute("predicateAnchor", predicateAnchor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Redirect appropriately
|
||||
if( resourceToRedirectTo != null ){
|
||||
ParamMap paramMap = new ParamMap();
|
||||
paramMap.put("uri", resourceToRedirectTo);
|
||||
paramMap.put("extra","true"); //for ie6
|
||||
return new RedirectResponseValues( UrlBuilder.getPath(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
|
||||
public static class Utilities {
|
||||
|
|
|
@ -346,6 +346,37 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
return getObjectPredicateProperty().getOfferCreateNewOption();
|
||||
}
|
||||
|
||||
public String getPropertyName() {
|
||||
if(isObjectProperty()) {
|
||||
return getPropertyPublicDomainTitle().toLowerCase();
|
||||
}
|
||||
if(isDataProperty()) {
|
||||
return getPropertyPublicName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: Implement statement display
|
||||
public Map<String, String> getStatementDisplay() {
|
||||
Map<String, String> statementDisplay = new HashMap<String, String>();
|
||||
if(isDataProperty()) {
|
||||
statementDisplay.put("dataValue", getDataLiteralValuesAsString());
|
||||
} 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;
|
||||
}
|
||||
|
||||
//TODO:Check where this logic should actually go, copied from input element formatting tag
|
||||
public Map<String, String> getOfferTypesCreateNew() {
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
|
@ -444,8 +475,19 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
return getMainEditUrl() + "?" + vreq.getQueryString();
|
||||
}
|
||||
|
||||
//this url is for canceling
|
||||
public String getCancelUrl() {
|
||||
String editKey = editConfig.getEditKey();
|
||||
return vreq.getContextPath() + "/postEditCleanupController?editKey=" + editKey + "&cancel=true";
|
||||
}
|
||||
|
||||
public String getMainEditUrl() {
|
||||
return "/edit/editRequestDispatch";
|
||||
return vreq.getContextPath() + "/editRequestDispatch";
|
||||
}
|
||||
|
||||
//Get confirm deletion url
|
||||
public String getDeleteProcessingUrl() {
|
||||
return vreq.getContextPath() + "/deletePropertyController";
|
||||
}
|
||||
|
||||
//TODO: Check if this logic is correct and delete prohibited does not expect a specific value
|
||||
|
@ -471,4 +513,12 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
}
|
||||
}
|
||||
|
||||
public String getVitroNsProperty() {
|
||||
String vitroNsProp = vreq.getParameter("vitroNsProp");
|
||||
if(vitroNsProp == null) {
|
||||
vitroNsProp = "";
|
||||
}
|
||||
return vitroNsProp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue