updates for page management, and replacing empty options with Constant empty options for pageData in EditConfigurationTemplateModel in populateDropdowns and also logging error if name in pageData already in use for that field name
This commit is contained in:
parent
a3fec6ed18
commit
7e2a5d22d4
14 changed files with 403 additions and 50 deletions
|
@ -0,0 +1,171 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
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.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
|
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||||
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Process deletions for page, deleting page, data getters and any associated menu items.
|
||||||
|
*/
|
||||||
|
public class DeletePageController extends VitroHttpServlet {
|
||||||
|
|
||||||
|
private final static String REDIRECT_URL = "/pageList";
|
||||||
|
private static Model removeStatements = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest rawRequest, HttpServletResponse resp)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
removeStatements = ModelFactory.createDefaultModel();
|
||||||
|
VitroRequest vreq = new VitroRequest(rawRequest);
|
||||||
|
String pageUri = vreq.getParameter("pageURI");
|
||||||
|
if(pageUri != null) {
|
||||||
|
doDeletePage(pageUri, vreq, resp);
|
||||||
|
}
|
||||||
|
resp.sendRedirect(rawRequest.getContextPath() + REDIRECT_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doGet(HttpServletRequest rawRequest, HttpServletResponse resp) {
|
||||||
|
doPost(rawRequest, resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Parameter retrieval is identical, but in one case an entirey new menu item needs to be created
|
||||||
|
//along with a new page
|
||||||
|
public void doDeletePage(String pageUri, VitroRequest vreq, HttpServletResponse resp) {
|
||||||
|
|
||||||
|
OntModel displayModel = getDisplayModel(vreq);
|
||||||
|
if(displayModel == null) {
|
||||||
|
//Throw some kind of exception
|
||||||
|
log.error("Display model not being retrieved correctly");
|
||||||
|
}
|
||||||
|
|
||||||
|
String errorMessage = "";
|
||||||
|
processDelete(pageUri, displayModel, vreq);
|
||||||
|
|
||||||
|
//Edits to model occur here
|
||||||
|
displayModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
try {
|
||||||
|
log.debug("Statement to be removed are ");
|
||||||
|
StringWriter r = new StringWriter();
|
||||||
|
removeStatements.write(r, "N3");
|
||||||
|
log.debug(r.toString());
|
||||||
|
r.close();
|
||||||
|
displayModel.remove(removeStatements);
|
||||||
|
|
||||||
|
} catch(Exception ex) {
|
||||||
|
log.error("An error occurred in processing command", ex);
|
||||||
|
errorMessage += "An error occurred and the operation could not be completed successfully.";
|
||||||
|
}finally {
|
||||||
|
displayModel.leaveCriticalSection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void processDelete(String pageUri, OntModel displayModel, VitroRequest vreq) {
|
||||||
|
//get the page resource
|
||||||
|
Resource pageResource = getExistingPage(pageUri, displayModel);
|
||||||
|
//if the page is related to a menu item, get the menu item information
|
||||||
|
Resource menuItemResource = getExistingMenuItem(pageResource, displayModel);
|
||||||
|
|
||||||
|
//What statements should be added and removed
|
||||||
|
removeStatements.add(getStatementsToRemove(displayModel, menuItemResource, pageResource));
|
||||||
|
//No statements to add
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//What statements need to be removed
|
||||||
|
private Model getStatementsToRemove(OntModel displayModel,
|
||||||
|
Resource menuItemResource, Resource pageResource) {
|
||||||
|
Model removeModel = ModelFactory.createDefaultModel();
|
||||||
|
removeModel.add(displayModel.listStatements(pageResource, null, (RDFNode) null));
|
||||||
|
//if menu item exists for this page, get all statements related to menu item and page
|
||||||
|
if(menuItemResource != null) {
|
||||||
|
removeModel.add(displayModel.listStatements(menuItemResource, null, (RDFNode) null));
|
||||||
|
//Also remove any statements where menu item resource is an object
|
||||||
|
removeModel.add(displayModel.listStatements(null, null, menuItemResource));
|
||||||
|
}
|
||||||
|
//Get all data getter statements
|
||||||
|
Model associatedDataGettersModel = getDataGettersStatements(pageResource, displayModel);
|
||||||
|
removeModel.add(associatedDataGettersModel);
|
||||||
|
return removeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get all data getters associated with page
|
||||||
|
private Model getDataGettersStatements(Resource pageResource, OntModel displayModel) {
|
||||||
|
Model dataGettersModel = ModelFactory.createDefaultModel();
|
||||||
|
//To iterate through to get all data getters and then all their statements
|
||||||
|
//PAge to data getter statements have already been added when all page statements were added
|
||||||
|
StmtIterator dataGetterIt = displayModel.listStatements(
|
||||||
|
pageResource,
|
||||||
|
ResourceFactory.createProperty(DisplayVocabulary.HAS_DATA_GETTER),
|
||||||
|
(RDFNode) null);
|
||||||
|
while(dataGetterIt.hasNext()) {
|
||||||
|
Statement dataGetterStmt = dataGetterIt.nextStatement();
|
||||||
|
Resource dataGetterResource = dataGetterStmt.getSubject();
|
||||||
|
dataGettersModel.add(displayModel.listStatements(dataGetterResource, null, (RDFNode) null));
|
||||||
|
}
|
||||||
|
return dataGettersModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Resource getExistingPage(String pageUri, OntModel displayModel) {
|
||||||
|
return ResourceFactory.createResource(pageUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Resource getExistingMenuItem(Resource pageResource, OntModel displayModel) {
|
||||||
|
Resource menuItemResource = null;
|
||||||
|
StmtIterator menuItemIt = displayModel.listStatements(null,
|
||||||
|
DisplayVocabulary.TO_PAGE,
|
||||||
|
pageResource);
|
||||||
|
while(menuItemIt.hasNext()) {
|
||||||
|
Statement menuStmt = menuItemIt.nextStatement();
|
||||||
|
menuItemResource = menuStmt.getSubject();
|
||||||
|
}
|
||||||
|
return menuItemResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//This should be in write mode
|
||||||
|
//TODO: find better way of doing this
|
||||||
|
private OntModel getDisplayModel(VitroRequest vreq) {
|
||||||
|
if(vreq.getAttribute(vreq.SPECIAL_WRITE_MODEL) != null) {
|
||||||
|
return vreq.getWriteModel();
|
||||||
|
} else {
|
||||||
|
return (OntModel) getServletContext().getAttribute("http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadata");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log log = LogFactory.getLog(MenuManagementEdit.class);
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.QuerySolutionMap;
|
import com.hp.hpl.jena.query.QuerySolutionMap;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
|
import com.hp.hpl.jena.vocabulary.XSD;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
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;
|
||||||
|
@ -145,7 +146,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
FieldVTwo menuItemLinkTextField = new FieldVTwo().setName("menuLinkText");
|
FieldVTwo menuItemLinkTextField = new FieldVTwo().setName("menuLinkText");
|
||||||
conf.addField(menuItemLinkTextField);
|
conf.addField(menuItemLinkTextField);
|
||||||
|
|
||||||
FieldVTwo menuItemPositionField = new FieldVTwo().setName("menuPosition");
|
FieldVTwo menuItemPositionField = new FieldVTwo().setName("menuPosition").setRangeDatatypeUri(XSD.integer.getURI());
|
||||||
conf.addField(menuItemPositionField);
|
conf.addField(menuItemPositionField);
|
||||||
|
|
||||||
//The actual page content information is stored in this field, and then
|
//The actual page content information is stored in this field, and then
|
||||||
|
@ -175,18 +176,16 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
|
|
||||||
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
|
editConfiguration.setUrlToReturnTo(UrlBuilder.getUrl("/pageList"));
|
||||||
//For the case of a new page
|
//For the case of a new page
|
||||||
if(subjectUri == null) {
|
if(subjectUri == null) {
|
||||||
//Once added, return to pageList
|
//Once added, return to pageList
|
||||||
editConfiguration.setUrlToReturnTo(UrlBuilder.getUrl("/pageList"));
|
|
||||||
editConfiguration.setEntityToReturnTo("?page");
|
editConfiguration.setEntityToReturnTo("?page");
|
||||||
editConfiguration.setPredicateUri(predicateUri);
|
editConfiguration.setPredicateUri(predicateUri);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//For the case of an existing page
|
//For the case of an existing page
|
||||||
//Page title pageName or page hasDataGetter dataGetter
|
//Page title pageName or page hasDataGetter dataGetter
|
||||||
editConfiguration.setUrlPatternToReturnTo("/individual");
|
|
||||||
editConfiguration.setEntityToReturnTo(subjectUri);
|
editConfiguration.setEntityToReturnTo(subjectUri);
|
||||||
//Set update version here
|
//Set update version here
|
||||||
//if subject uri = page uri != null or empty, editing existing page
|
//if subject uri = page uri != null or empty, editing existing page
|
||||||
|
@ -486,22 +485,15 @@ private String getExistingCustomTemplateQuery() {
|
||||||
addNewPageData(vreq, formSpecificData);
|
addNewPageData(vreq, formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for menu position, return either existing menu position or get the highest available menu position
|
||||||
|
retrieveMenuPosition(editConfiguration, vreq, formSpecificData);
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTemplate(EditConfigurationVTwo editConfiguration) {
|
|
||||||
String returnTemplate = "default";
|
|
||||||
if(editConfiguration.getSubjectUri() != null) {
|
|
||||||
//Then template is EXISTING template
|
|
||||||
//TODO: Get existing template value for page
|
|
||||||
}
|
|
||||||
return returnTemplate;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRequiredPageData(VitroRequest vreq, Map<String, Object> data) {
|
private void addRequiredPageData(VitroRequest vreq, Map<String, Object> data) {
|
||||||
MenuManagementDataUtils.includeRequiredSystemData(vreq.getSession().getServletContext(), data);
|
MenuManagementDataUtils.includeRequiredSystemData(vreq.getSession().getServletContext(), data);
|
||||||
|
data.put("classGroup", new ArrayList<String>());
|
||||||
|
data.put("classGroups", DataGetterUtils.getClassGroups(vreq.getSession().getServletContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addExistingPageData(VitroRequest vreq, Map<String, Object> data) {
|
private void addExistingPageData(VitroRequest vreq, Map<String, Object> data) {
|
||||||
|
@ -515,17 +507,6 @@ private String getExistingCustomTemplateQuery() {
|
||||||
private void addNewPageData(VitroRequest vreq, Map<String, Object> data) {
|
private void addNewPageData(VitroRequest vreq, Map<String, Object> data) {
|
||||||
data.put("title", "Add Menu Item");
|
data.put("title", "Add Menu Item");
|
||||||
data.put("menuAction", "Add");
|
data.put("menuAction", "Add");
|
||||||
//Generate empty values for fields
|
|
||||||
data.put("menuItem", "");
|
|
||||||
data.put("pageName", "");
|
|
||||||
data.put("prettyUrl", "");
|
|
||||||
data.put("associatedPage", "");
|
|
||||||
data.put("associatedPageURI", "");
|
|
||||||
data.put("classGroup", new ArrayList<String>());
|
|
||||||
//not a page already assigned a class group
|
|
||||||
data.put("isClassGroupPage", false);
|
|
||||||
data.put("includeAllClasses", false);
|
|
||||||
data.put("classGroups", DataGetterUtils.getClassGroups(vreq.getSession().getServletContext()));
|
|
||||||
data.put("selectedTemplateType", "default");
|
data.put("selectedTemplateType", "default");
|
||||||
//defaults to regular class group page
|
//defaults to regular class group page
|
||||||
}
|
}
|
||||||
|
@ -563,5 +544,57 @@ private String getExistingCustomTemplateQuery() {
|
||||||
return prefixes + "?page display:hasDataGetter " + dataGetterVar + ".";
|
return prefixes + "?page display:hasDataGetter " + dataGetterVar + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void retrieveMenuPosition(EditConfigurationVTwo editConfig, VitroRequest vreq, Map<String, Object> formSpecificData) {
|
||||||
|
boolean returnHighestMenuPosition = false;
|
||||||
|
//if adding a new page or if editing an existing page which does not have an associated
|
||||||
|
//menu position
|
||||||
|
int availableMenuPosition = this.getAvailableMenuPosition(editConfig, vreq);
|
||||||
|
formSpecificData.put("highestMenuPosition", "" + availableMenuPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the highest menu position and return that + 1 for the menu position that can be associated
|
||||||
|
//for a new menu item
|
||||||
|
public int getAvailableMenuPosition(EditConfigurationVTwo editConfig, VitroRequest vreq) {
|
||||||
|
//Execute sparql query to get highest menu position
|
||||||
|
int maxMenuPosition = getMaxMenuPosition(editConfig, vreq);
|
||||||
|
return maxMenuPosition + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private int getMaxMenuPosition(EditConfigurationVTwo editConfig, VitroRequest vreq) {
|
||||||
|
int maxMenuPosition = 0;
|
||||||
|
Literal menuPosition = null;
|
||||||
|
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||||
|
OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel");
|
||||||
|
String maxMenuPositionQuery = getMaxMenuPositionQueryString();
|
||||||
|
QueryExecution qe = null;
|
||||||
|
try{
|
||||||
|
Query query = QueryFactory.create(maxMenuPositionQuery);
|
||||||
|
qe = QueryExecutionFactory.create(query, queryModel);
|
||||||
|
ResultSet results = qe.execSelect();
|
||||||
|
while( results.hasNext()){
|
||||||
|
QuerySolution qs = results.nextSolution();
|
||||||
|
menuPosition = qs.getLiteral("menuPosition");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception ex) {
|
||||||
|
log.error("Error occurred in executing query " + maxMenuPositionQuery, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(menuPosition != null) {
|
||||||
|
maxMenuPosition = menuPosition.getInt();
|
||||||
|
}
|
||||||
|
return maxMenuPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String getMaxMenuPositionQueryString() {
|
||||||
|
String query = getSparqlPrefix() +
|
||||||
|
"SELECT ?menuPosition WHERE {?pageUri display:menuPosition ?menuPosition . } " +
|
||||||
|
"ORDER BY DESC(?menuPosition) LIMIT 1";
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditElementVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditElementVTwo;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.SelectListGeneratorVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.SelectListGeneratorVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper;
|
import edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper;
|
||||||
|
@ -95,12 +96,16 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
for(String fieldName: editConfig.getFields().keySet()){
|
for(String fieldName: editConfig.getFields().keySet()){
|
||||||
FieldVTwo field = editConfig.getField(fieldName);
|
FieldVTwo field = editConfig.getField(fieldName);
|
||||||
|
//TODO: Check if we even need empty options if field options do not exist
|
||||||
if( field.getFieldOptions() == null ){
|
if( field.getFieldOptions() == null ){
|
||||||
//putting empty map in here because FM can't deal
|
//empty options
|
||||||
pageData.put(fieldName, Collections.EMPTY_MAP);
|
field.setOptions(new ConstantFieldOptions());
|
||||||
}
|
}
|
||||||
Map<String, String> optionsMap = SelectListGeneratorVTwo.getOptions(editConfig, fieldName, wdf);
|
Map<String, String> optionsMap = SelectListGeneratorVTwo.getOptions(editConfig, fieldName, wdf);
|
||||||
optionsMap = SelectListGeneratorVTwo.getSortedMap(optionsMap);
|
optionsMap = SelectListGeneratorVTwo.getSortedMap(optionsMap);
|
||||||
|
if(pageData.containsKey(fieldName)) {
|
||||||
|
log.error("Check the edit configuration setup as pageData already contains " + fieldName + " and this will be overwritten now with empty collection");
|
||||||
|
}
|
||||||
pageData.put(fieldName, optionsMap);
|
pageData.put(fieldName, optionsMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ display:pageListData
|
||||||
OPTIONAL {?listedPageUri display:requiresBodyTemplate ?listedPageTemplate .}
|
OPTIONAL {?listedPageUri display:requiresBodyTemplate ?listedPageTemplate .}
|
||||||
OPTIONAL {?listedPageMenuItem display:toPage ?listedPageUri .}
|
OPTIONAL {?listedPageMenuItem display:toPage ?listedPageUri .}
|
||||||
OPTIONAL {?listedPageUri display:cannotDeletePage ?listedPageCannotDeletePage .}
|
OPTIONAL {?listedPageUri display:cannotDeletePage ?listedPageCannotDeletePage .}
|
||||||
} """ .
|
} ORDER BY ?listedPageTitle """ .
|
||||||
###Page Management and Data Getters
|
###Page Management and Data Getters
|
||||||
#Data getter type labels
|
#Data getter type labels
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData> rdfs:label "Class Group Page" .
|
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData> rdfs:label "Class Group Page" .
|
||||||
|
|
|
@ -359,6 +359,8 @@
|
||||||
<url-pattern>/deletePropertyController</url-pattern>
|
<url-pattern>/deletePropertyController</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>PostEditCleanupController</servlet-name>
|
<servlet-name>PostEditCleanupController</servlet-name>
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.PostEditCleanupController</servlet-class>
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.PostEditCleanupController</servlet-class>
|
||||||
|
@ -368,6 +370,15 @@
|
||||||
<url-pattern>/postEditCleanupController</url-pattern>
|
<url-pattern>/postEditCleanupController</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>DeletePageController</servlet-name>
|
||||||
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.edit.DeletePageController</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>DeletePageController</servlet-name>
|
||||||
|
<url-pattern>/deletePageController</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>EditRequestDispatch</servlet-name>
|
<servlet-name>EditRequestDispatch</servlet-name>
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.EditRequestDispatchController</servlet-class>
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.EditRequestDispatchController</servlet-class>
|
||||||
|
|
|
@ -214,6 +214,8 @@ var pageManagementUtils = {
|
||||||
//Submission: validate as well as create appropriate hidden json inputs
|
//Submission: validate as well as create appropriate hidden json inputs
|
||||||
$("form").submit(function (event) {
|
$("form").submit(function (event) {
|
||||||
var validationError = pageManagementUtils.validateMenuItemForm();
|
var validationError = pageManagementUtils.validateMenuItemForm();
|
||||||
|
//Add any errors from page content sections
|
||||||
|
validationError += pageManagementUtils.validatePageContentSections();
|
||||||
if (validationError == "") {
|
if (validationError == "") {
|
||||||
//Create the appropriate json objects
|
//Create the appropriate json objects
|
||||||
pageManagementUtils.createPageContentForSubmission();
|
pageManagementUtils.createPageContentForSubmission();
|
||||||
|
@ -273,8 +275,6 @@ var pageManagementUtils = {
|
||||||
pageManagementUtils.adjustSaveButtonHeight();
|
pageManagementUtils.adjustSaveButtonHeight();
|
||||||
},
|
},
|
||||||
collapseAllExistingContent:function() {
|
collapseAllExistingContent:function() {
|
||||||
var $clickableSpan = $newDivContainer.children('span#clickable' + counter);
|
|
||||||
var $innerDiv = $newDivContainer.children('div#innerContainer' + counter);
|
|
||||||
var spanArrows = pageManagementUtils.savedContentDivs.find("span.pageContentExpand div.arrow");
|
var spanArrows = pageManagementUtils.savedContentDivs.find("span.pageContentExpand div.arrow");
|
||||||
spanArrows.removeClass("collapseArrow");
|
spanArrows.removeClass("collapseArrow");
|
||||||
spanArrows.addClass("expandArrow");
|
spanArrows.addClass("expandArrow");
|
||||||
|
@ -682,8 +682,38 @@ var pageManagementUtils = {
|
||||||
if(pageManagementUtils.contentTypeSelect.find("option[value='browseClassGroup']").length == 0) {
|
if(pageManagementUtils.contentTypeSelect.find("option[value='browseClassGroup']").length == 0) {
|
||||||
//if removed, add browse class group back
|
//if removed, add browse class group back
|
||||||
var classGroupOption = '<option value="browseClassGroup">Browse Class Group</option>';
|
var classGroupOption = '<option value="browseClassGroup">Browse Class Group</option>';
|
||||||
pageManagementUtils.contentTypeSelect.find('option:eq(0)').after(classGroupGroupOption);
|
pageManagementUtils.contentTypeSelect.find('option:eq(0)').after(classGroupOption);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
//get label of page content section
|
||||||
|
getPageContentSectionLabel:function(pageContentSection) {
|
||||||
|
var label = pageContentSection.closest("div.pageContentContainer").find("span.pageContentTypeLabel").html();
|
||||||
|
if(label == null) {
|
||||||
|
label = "";
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
},
|
||||||
|
//Validation across different content types
|
||||||
|
validatePageContentSections:function() {
|
||||||
|
//Get all page content sections
|
||||||
|
var pageContentSections = $("section[class='pageContent']");
|
||||||
|
var validationErrorMsg = "";
|
||||||
|
//For each, based on type, validate if a validation function exists
|
||||||
|
$.each(pageContentSections, function(i) {
|
||||||
|
if(pageManagementUtils.processDataGetterUtils != null) {
|
||||||
|
var dataGetterType = pageManagementUtils.processDataGetterUtils.selectDataGetterType($(this));
|
||||||
|
if(pageManagementUtils.dataGetterProcessorMap != null) {
|
||||||
|
var dataGetterProcessor = pageManagementUtils.dataGetterProcessorMap[dataGetterType];
|
||||||
|
//the content type specific processor will create the json object to be returned
|
||||||
|
if($.isFunction(dataGetterProcessor.validateFormSubmission)) {
|
||||||
|
//Get label of page content section
|
||||||
|
var label = pageManagementUtils.getPageContentSectionLabel($(this));
|
||||||
|
validationErrorMsg += dataGetterProcessor.validateFormSubmission($(this), label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return validationErrorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -126,6 +126,22 @@ var processClassGroupDataGetterContent = {
|
||||||
//Should probably remove this entire method and copy there
|
//Should probably remove this entire method and copy there
|
||||||
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
|
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
//Validation on form submit: Check to see that class group has been selected
|
||||||
|
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
|
||||||
|
var validationError = "";
|
||||||
|
if (pageContentSection.find('select[name="selectClassGroup"]').val() =='-1') {
|
||||||
|
validationError += pageContentSectionLabel + ": You must supply a class group <br />";
|
||||||
|
} else {
|
||||||
|
//class group has been selected, make sure there is at least one class selected
|
||||||
|
var allSelected = pageContentSection.find('input[name="allSelected"]:checked').length;
|
||||||
|
var noClassesSelected = pageContentSection.find('input[name="classInClassGroup"]:checked').length;
|
||||||
|
if (allSelected == 0 && noClassesSelected == 0) {
|
||||||
|
//at least one class should be selected
|
||||||
|
validationError += pageContentSectionLabel + ":You must select the classes to display<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,20 @@ var processFixedHTMLDataGetterContent = {
|
||||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||||
var saveToVarValue = existingContentObject["saveToVar"];
|
var saveToVarValue = existingContentObject["saveToVar"];
|
||||||
return saveToVarValue;
|
return saveToVarValue;
|
||||||
|
},
|
||||||
|
//Validation on form submit: Check to see that class group has been selected
|
||||||
|
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
|
||||||
|
var validationError = "";
|
||||||
|
//Check that query and saveToVar have been input
|
||||||
|
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
|
||||||
|
if(variableValue == "") {
|
||||||
|
validationError += pageContentSectionLabel + ": You must supply a variable to save HTML content. <br />"
|
||||||
|
}
|
||||||
|
var htmlValue = pageContentSection.find("textarea[name='htmlValue']").val();
|
||||||
|
if(htmlValue == "") {
|
||||||
|
validationError += pageContentSectionLabel + ": You must supply some HTML or text. <br />";
|
||||||
|
}
|
||||||
|
return validationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ var processIndividualsForClassesDataGetterContent = {
|
||||||
//For the label of the content section for editing, need to add additional value
|
//For the label of the content section for editing, need to add additional value
|
||||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||||
return processClassGroupDataGetterContent.retrieveAdditionalLabelText(existingContentObject);
|
return processClassGroupDataGetterContent.retrieveAdditionalLabelText(existingContentObject);
|
||||||
|
},
|
||||||
|
//Validation on form submit: Check to see that class group has been selected
|
||||||
|
validateFormSubmission: function(pageContentSection) {
|
||||||
|
return processClassGroupDataGetterContent.validateFormSubmission(pageContentSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -32,6 +32,20 @@ var processSparqlDataGetterContent = {
|
||||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||||
var saveToVarValue = existingContentObject["saveToVar"];
|
var saveToVarValue = existingContentObject["saveToVar"];
|
||||||
return saveToVarValue;
|
return saveToVarValue;
|
||||||
|
},
|
||||||
|
//Validation on form submit: Check to see that class group has been selected
|
||||||
|
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
|
||||||
|
var validationError = "";
|
||||||
|
//Check that query and saveToVar have been input
|
||||||
|
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
|
||||||
|
if(variableValue == "") {
|
||||||
|
validationError += pageContentSectionLabel + ": You must supply a variable to save query results. <br />"
|
||||||
|
}
|
||||||
|
var queryValue = pageContentSection.find("textarea[name='query']").val();
|
||||||
|
if(queryValue == "") {
|
||||||
|
validationError += pageContentSectionLabel + ": You must supply a Sparql query. <br />";
|
||||||
|
}
|
||||||
|
return validationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
49
webapp/web/js/pageDeletion.js
Normal file
49
webapp/web/js/pageDeletion.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
var pageDeletion = {
|
||||||
|
// on initial page setup
|
||||||
|
onLoad:function(){
|
||||||
|
if (this.disableFormInUnsupportedBrowsers()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initObjects();
|
||||||
|
this.bindEventListeners();
|
||||||
|
},
|
||||||
|
initObjects:function() {
|
||||||
|
this.deleteLinks = $("a[cmd='deletePage']");
|
||||||
|
},
|
||||||
|
bindEventListeners:function() {
|
||||||
|
this.deleteLinks.click(function(event) {
|
||||||
|
var href=$(this).attr("href");
|
||||||
|
var pageTitle = $(this).attr("pageTitle");
|
||||||
|
var confirmResult = confirm("Are you sure you wish to delete this page: " + pageTitle + "?");
|
||||||
|
if(confirmResult) {
|
||||||
|
//Continue with the link
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
event.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
disableFormInUnsupportedBrowsers: function() {
|
||||||
|
var disableWrapper = $('#ie67DisableWrapper');
|
||||||
|
|
||||||
|
// Check for unsupported browsers only if the element exists on the page
|
||||||
|
if (disableWrapper.length) {
|
||||||
|
if (vitro.browserUtils.isIELessThan8()) {
|
||||||
|
disableWrapper.show();
|
||||||
|
$('.noIE67').hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
pageDeletion.onLoad();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -46,11 +46,10 @@
|
||||||
<td>
|
<td>
|
||||||
<a href="${urls.base}/individual?uri=${pagex.listedPageUri?url}&switchToDisplayModel=1"><img src="${urls.images!}/profile-page-icon.png" title="view the profile properties for this page" alt="profile page"></a>
|
<a href="${urls.base}/individual?uri=${pagex.listedPageUri?url}&switchToDisplayModel=1"><img src="${urls.images!}/profile-page-icon.png" title="view the profile properties for this page" alt="profile page"></a>
|
||||||
|
|
||||||
<#-- <#if pagex.listedPageCannotDeletePage?? >
|
<#if !pagex.listedPageCannotDeletePage?has_content >
|
||||||
<#else>
|
<a cmd="deletePage" pageTitle=" ${pagex.listedPageTitle!}" href="${urls.base}/deletePageController?pageURI=${pagex.listedPageUri?url}"><img src="${urls.images!}/individual/deleteIcon.gif" title="delete this page" alt="delete"></a>
|
||||||
<a href="#"><img src="${urls.images!}/individual/deleteIcon.gif" title="delete this page" alt="delete"></a>
|
|
||||||
</#if>
|
</#if>
|
||||||
--> </td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +72,13 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/menupage/pageList.css" />',
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />',
|
||||||
|
'<link rel="stylesheet" href="${urls.base}/css/menupage/pageList.css" />',
|
||||||
'<link rel="stylesheet" href="${urls.base}/css/menumanagement/menuManagement.css" />')}
|
'<link rel="stylesheet" href="${urls.base}/css/menumanagement/menuManagement.css" />')}
|
||||||
|
|
||||||
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')}
|
||||||
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}
|
||||||
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')}
|
||||||
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/pageDeletion.js"></script>')}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
<#--Browse Class Groups Section-->
|
<#--Browse Class Groups Section-->
|
||||||
<#-----------Variable assignment-------------->
|
<#-----------Variable assignment-------------->
|
||||||
<#--Requires Menu action be defined in parent template-->
|
<#--Requires Menu action be defined in parent template-->
|
||||||
|
|
||||||
<#assign classGroup = pageData.classGroup />
|
<#assign classGroup = pageData.classGroup />
|
||||||
<#assign classGroups = pageData.classGroups />
|
<#assign classGroups = pageData.classGroups />
|
||||||
<#assign includeAllClasses = false/>
|
|
||||||
<#-- some additional processing here which shows or hides the class group selection and classes based on initial action-->
|
<#-- some additional processing here which shows or hides the class group selection and classes based on initial action-->
|
||||||
<#assign existingClassGroupStyle = " " />
|
<#assign existingClassGroupStyle = " " />
|
||||||
<#assign selectClassGroupStyle = 'class="hidden"' />
|
<#assign selectClassGroupStyle = 'class="hidden"' />
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
<select name="selectClassGroup" id="selectClassGroup" role="combobox">
|
<select name="selectClassGroup" id="selectClassGroup" role="combobox">
|
||||||
<option value="-1" role="option">Select one</option>
|
<option value="-1" role="option">Select one</option>
|
||||||
<#list classGroups as aClassGroup>
|
<#list classGroups as aClassGroup>
|
||||||
<option value="${aClassGroup.URI}" <#if aClassGroup.URI = associatedPageURI>selected</#if> role="option">${aClassGroup.publicName}</option>
|
<option value="${aClassGroup.URI}" role="option">${aClassGroup.publicName}</option>
|
||||||
</#list>
|
</#list>
|
||||||
</select>
|
</select>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -8,11 +8,9 @@
|
||||||
<#assign pageName = "" />
|
<#assign pageName = "" />
|
||||||
<#assign selectedTemplateType = "default" />
|
<#assign selectedTemplateType = "default" />
|
||||||
<#assign prettyUrl = ""/>
|
<#assign prettyUrl = ""/>
|
||||||
<#assign associatedPage = ""/>
|
|
||||||
<#assign associatedPageURI = ""/>
|
|
||||||
<#assign menuItem = ""/>
|
<#assign menuItem = ""/>
|
||||||
<#assign menuLinkText = "" />
|
<#assign menuLinkText = "" />
|
||||||
<#assign menuPosition = "" />
|
<#assign menuPosition = pageData.highestMenuPosition />
|
||||||
<#--Existing Values For Editing condition-->
|
<#--Existing Values For Editing condition-->
|
||||||
<#assign literalValues = editConfiguration.existingLiteralValues />
|
<#assign literalValues = editConfiguration.existingLiteralValues />
|
||||||
<#assign uriValues = editConfiguration.existingUriValues />
|
<#assign uriValues = editConfiguration.existingUriValues />
|
||||||
|
@ -21,12 +19,15 @@
|
||||||
<#assign prettyUrl = lvf.getFormFieldValue(editSubmission, editConfiguration, "prettyUrl")/>
|
<#assign prettyUrl = lvf.getFormFieldValue(editSubmission, editConfiguration, "prettyUrl")/>
|
||||||
<#assign menuItem = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuItem")/>
|
<#assign menuItem = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuItem")/>
|
||||||
<#assign menuLinkText = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuLinkText")/>
|
<#assign menuLinkText = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuLinkText")/>
|
||||||
<#assign menuPosition = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuPosition")/>
|
|
||||||
<#assign customTemplate = lvf.getFormFieldValue(editSubmission, editConfiguration, "customTemplate")/>
|
<#assign customTemplate = lvf.getFormFieldValue(editSubmission, editConfiguration, "customTemplate")/>
|
||||||
<#if customTemplate?has_content>
|
<#if customTemplate?has_content>
|
||||||
<#assign selectedTemplateType = "custom" />
|
<#assign selectedTemplateType = "custom" />
|
||||||
</#if>
|
</#if>
|
||||||
|
<#assign editMenuPosition = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuPosition")/>
|
||||||
|
<#--if menu position exists for a menu item, then use that, otherwise use the highest available menu position number from page data-->
|
||||||
|
<#if editMenuPosition?has_content && editMenuPosition != "">
|
||||||
|
<#assign menuPosition = editMenuPosition/>
|
||||||
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#------------HTML Portion------------->
|
<#------------HTML Portion------------->
|
||||||
|
@ -97,7 +98,7 @@
|
||||||
<label for="default">Menu Item Name</label>
|
<label for="default">Menu Item Name</label>
|
||||||
<input type="hidden" id="menuItem" name="menuItem" value="${menuItem!''}" />
|
<input type="hidden" id="menuItem" name="menuItem" value="${menuItem!''}" />
|
||||||
<input type="text" id="menuLinkText" name="menuLinkText" value="${menuLinkText!''}" size="28" role="input" />
|
<input type="text" id="menuLinkText" name="menuLinkText" value="${menuLinkText!''}" size="28" role="input" />
|
||||||
<input type="text" id="menuPosition" name="menuPosition" value="${menuPosition!''}" />
|
<input type="hidden" id="menuPosition" name="menuPosition" value="${menuPosition!''}" />
|
||||||
<p class="note">If left blank, the page title will be used.</p>
|
<p class="note">If left blank, the page title will be used.</p>
|
||||||
</section>
|
</section>
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue