diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java index 43be8519b..b232de485 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java @@ -41,7 +41,7 @@ public class DeletePageController extends VitroHttpServlet { removeStatements = ModelFactory.createDefaultModel(); VitroRequest vreq = new VitroRequest(rawRequest); String pageUri = vreq.getParameter("pageURI"); - if(pageUri != null) { + if(pageUri != null) { doDeletePage(pageUri, vreq, resp); } resp.sendRedirect(rawRequest.getContextPath() + REDIRECT_URL); @@ -130,7 +130,7 @@ public class DeletePageController extends VitroHttpServlet { (RDFNode) null); while(dataGetterIt.hasNext()) { Statement dataGetterStmt = dataGetterIt.nextStatement(); - Resource dataGetterResource = dataGetterStmt.getSubject(); + Resource dataGetterResource = dataGetterStmt.getResource(); dataGettersModel.add(displayModel.listStatements(dataGetterResource, null, (RDFNode) null)); } return dataGettersModel; @@ -160,11 +160,7 @@ public class DeletePageController extends VitroHttpServlet { //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"); - } + return vreq.getDisplayModel(); } Log log = LogFactory.getLog(MenuManagementEdit.class); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java index 1d205f9dc..84255162a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java @@ -366,9 +366,43 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec // } try { + //If RDFService is null, will do what code used to do before, otherwise employ rdfservice + if(rdfService == null) { + log.debug("RDF Service null, Using CONSTRUCT query string for object property " + + propertyUri + ": " + queryString); + Query query = null; + try { + query = QueryFactory.create(queryString, Syntax.syntaxARQ); + } catch(Throwable th){ + log.error("Could not create CONSTRUCT SPARQL query for query " + + "string. " + th.getMessage()); + log.error(queryString); + return constructedModel; + } + + DatasetWrapper w = dwf.getDatasetWrapper(); + Dataset dataset = w.getDataset(); + dataset.getLock().enterCriticalSection(Lock.READ); + QueryExecution qe = null; + try { + qe = QueryExecutionFactory.create( + query, dataset); + qe.execConstruct(constructedModel); + } catch (Exception e) { + log.error("Error getting constructed model for subject " + subjectUri + " and property " + propertyUri); + } finally { + if (qe != null) { + qe.close(); + } + dataset.getLock().leaveCriticalSection(); + w.close(); + } + } else { constructedModel.read( rdfService.sparqlConstructQuery( queryString, RDFService.ModelSerializationFormat.N3), null, "N3"); + + } } catch (Exception e) { log.error("Error getting constructed model for subject " + subjectUri + " and property " + propertyUri); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java index f0d4b2585..2b3dfad09 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java @@ -508,7 +508,12 @@ private String getExistingCustomTemplateQuery() { data.put("title", "Add Menu Item"); data.put("menuAction", "Add"); data.put("selectedTemplateType", "default"); - //defaults to regular class group page + //Check for parameter specifying that this is a new menu page, in which case + //menu item should be selected + String menuItemParam = vreq.getParameter("addMenuItem"); + if(menuItemParam != null) { + data.put("addMenuItem", menuItemParam); + } } //N3 strings diff --git a/webapp/web/js/menupage/pageManagementUtils.js b/webapp/web/js/menupage/pageManagementUtils.js index 394c1dd69..e8c987e3a 100644 --- a/webapp/web/js/menupage/pageManagementUtils.js +++ b/webapp/web/js/menupage/pageManagementUtils.js @@ -34,6 +34,12 @@ var pageManagementUtils = { } return false; }, + isAddMenuItem:function() { + if(pageManagementUtils.addMenuItem != null && pageManagementUtils.addMenuItem == "true") { + return true; + } + return false; + }, initExistingContent:function() { this.generateExistingContentSections(); //display more content button - will need to review how to hit save etc. @@ -135,7 +141,7 @@ var pageManagementUtils = { // tlw72 this.moreContentButton.hide(); //left side components //These depend on whether or not this is an existing item or not - if(this.isAdd()) { + if(this.isAdd() && !this.isAddMenuItem()) { this.defaultTemplateRadio.attr('checked',true); this.isMenuCheckbox.attr('checked',false); this.menuSection.hide(); @@ -345,6 +351,8 @@ var pageManagementUtils = { if($.isFunction(dataGetterProcessorObj.bindEventHandlers)) { dataGetterProcessorObj.bindEventHandlers($newContentObj); } + //Bind done event as the done button is within the cloned content + pageManagementUtils.bindClonedContentDoneEvent($newContentObj); }, createClonedContentContainer:function($newContentObj, counter, contentTypeLabel, varOrClass) { //Create the container for the new content @@ -367,6 +375,17 @@ var pageManagementUtils = { //place new content object $newContentObj.prependTo($innerDiv); }, + bindClonedContentDoneEvent:function($newContentObj) { + //Done button should just collapse the cloned content + $newContentObj.find("input[name='doneWithContent']").click(function() { + var thisInnerDiv = $(this).closest("div.pageContentWrapper"); + thisInnerDiv.slideUp(222); + var thisClickableSpan = $(this).closest("span.pageContentExpand"); + var thisArrowDiv = thisClickableSpan.find('div.arrow'); + thisArrowDiv.removeClass("collapseArrow"); + thisArrowDiv.addClass("expandArrow"); + }); + }, bindClonedContentContainerEvents:function($newDivContainer, counter) { var $clickableSpan = $newDivContainer.children('span#clickable' + counter); var $innerDiv = $newDivContainer.children('div#innerContainer' + counter); @@ -389,10 +408,11 @@ var pageManagementUtils = { } window.setTimeout('pageManagementUtils.adjustSaveButtonHeight()', 223); }); + //remove button $newRemoveLink = $innerDiv.find('a#remove' + counter); // tlw72 changed button to link //remove the content entirely - $newRemoveLink.click(function() { + $newRemoveLink.click(function(event) { //if content type of what is being deleted is browse class group, then //add browse classgroup back to set of options var contentType = $innerDiv.find("section.pageContent").attr("contentType"); @@ -402,6 +422,8 @@ var pageManagementUtils = { //remove the section $innerDiv.parent("div").remove(); pageManagementUtils.adjustSaveButtonHeight(); + //Because this is now a link, have to prevent default action of navigating to link + event.preventDefault(); }); }, resetClassGroupSection:function() { diff --git a/webapp/web/templates/freemarker/body/individual/individual-menu.ftl b/webapp/web/templates/freemarker/body/individual/individual-menu.ftl index 65ebad2b8..9819b280a 100644 --- a/webapp/web/templates/freemarker/body/individual/individual-menu.ftl +++ b/webapp/web/templates/freemarker/body/individual/individual-menu.ftl @@ -13,12 +13,12 @@ var menuItemData = []; -
checked="checked"#if> + <#if (menuAction="Edit" && menuItem?has_content) || (menuAction="Add" && addMenuItem = "true")>checked="checked"#if> > This is a menu page