updates for menu management and internal institutional class
This commit is contained in:
parent
d170336432
commit
21c8f4990d
8 changed files with 119 additions and 48 deletions
|
@ -149,5 +149,7 @@ xmlns:vitro="&vitro;"
|
|||
|
||||
<owl:AnnotationProperty rdf:about="&vitro;mostSpecificType"/>
|
||||
<owl:AnnotationProperty rdf:about="&vitro;extendedLinkedData"/>
|
||||
<!--Institutional Internal class -->
|
||||
<owl:AnnotationProperty rdf:about="&vitro;isMenuPageIntersectionClass"/>
|
||||
|
||||
</rdf:RDF>
|
||||
|
|
|
@ -322,6 +322,15 @@ public class MenuManagementEdit extends VitroHttpServlet {
|
|||
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
||||
ResourceFactory.createResource(classUri)));
|
||||
}
|
||||
//Also check if internal class checked
|
||||
String internalClass = vreq.getParameter("display-internalClass");
|
||||
if(internalClass != null && !internalClass.isEmpty()) {
|
||||
//The value should be the internal class uri
|
||||
dgModel.add(dgModel.createStatement(
|
||||
dataGetterResource,
|
||||
ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY),
|
||||
ResourceFactory.createResource(internalClass)));
|
||||
}
|
||||
return dgModel;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
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.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
@ -36,6 +37,7 @@ import com.hp.hpl.jena.vocabulary.RDF;
|
|||
public class MenuManagementController extends FreemarkerHttpServlet {
|
||||
private static final Log log = LogFactory.getLog(MenuManagementController.class);
|
||||
protected final static String SUBMIT_FORM = "/processEditDisplayModel";
|
||||
protected final static String CANCEL_FORM = "/individual?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fontologies%2Fdisplay%2F1.1%23DefaultMenu&switchToDisplayModel=true";
|
||||
|
||||
protected final static String EDIT_FORM = "testMenuManagement.ftl";
|
||||
protected final static String CMD_PARAM = "cmd";
|
||||
|
@ -76,6 +78,9 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
|||
}
|
||||
//Form url submission
|
||||
data.put("formUrls", vreq.getContextPath() + SUBMIT_FORM);
|
||||
data.put("cancelUrl", vreq.getContextPath() + CANCEL_FORM);
|
||||
//This will be reset if internal class exists
|
||||
data.put("internalClass", "");
|
||||
return new TemplateResponseValues(EDIT_FORM, data);
|
||||
|
||||
}
|
||||
|
@ -109,6 +114,7 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
|||
Map<String, Object> data = new HashMap<String,Object>();
|
||||
data.put("menuAction", "Add");
|
||||
//Generate empty values for fields
|
||||
data.put("menuItem", "");
|
||||
data.put("menuName", "");
|
||||
data.put("prettyUrl", "");
|
||||
data.put("associatedPage", "");
|
||||
|
@ -266,6 +272,21 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
|||
this.getClassesForDataGetter(writeModel, dataGetter, data);
|
||||
//Also save the class group for display
|
||||
this.getClassGroupForDataGetter(writeModel, dataGetter, data);
|
||||
//Check whether institutional internal class exists
|
||||
this.checkInstitutionalInternalClass(writeModel, data);
|
||||
this.checkIfPageInternal(writeModel, data);
|
||||
|
||||
}
|
||||
|
||||
private void checkIfPageInternal(OntModel writeModel,
|
||||
Map<String, Object> data) {
|
||||
if(data.containsKey("internalClass") && data.containsKey("restrictClasses")) {
|
||||
List<String> restrictClasses = (List<String>)data.get("restrictClasses");
|
||||
String internalClass = (String) data.get("internalClass");
|
||||
if(restrictClasses.contains(internalClass)) {
|
||||
data.put("pageInternalOnly", true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -279,41 +300,55 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
|||
|
||||
}
|
||||
|
||||
//Instead of returning vclasses, just returning class Uris as vclasses appear to need their own template
|
||||
//to show up correctly
|
||||
private void getClassesForDataGetter(OntModel writeModel, Resource dataGetter,
|
||||
Map<String, Object> data) {
|
||||
VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache(getServletContext());
|
||||
|
||||
|
||||
StmtIterator classesIt = writeModel.listStatements(dataGetter,
|
||||
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
||||
(RDFNode) null);
|
||||
//TODO: Copied from IndividualsForClassesDataGetter, perhaps could reuse in separate method
|
||||
VClassGroup classesGroup = new VClassGroup();
|
||||
classesGroup.setURI("displayClasses");
|
||||
List<VClass> vClasses = new ArrayList<VClass>();
|
||||
|
||||
//Just need the class uris
|
||||
List<String> classUris = new ArrayList<String>();
|
||||
|
||||
while(classesIt.hasNext()) {
|
||||
String classUri = classesIt.nextStatement().getResource().getURI();
|
||||
VClass vclass = vcgc.getCachedVClass(classUri);
|
||||
if(vclass != null) {
|
||||
|
||||
log.debug("VClass does exist for " + classUri + " and entity count is " + vclass.getEntityCount());
|
||||
vClasses.add(vclass);
|
||||
} else {
|
||||
log.debug("Vclass " + classUri + " does not exist in the cache");
|
||||
log.error("Error occurred, vclass does not exist for this uri " + classUri);
|
||||
//Throw exception here
|
||||
}
|
||||
classUris.add(classUri);
|
||||
}
|
||||
data.put("includeClasses", classesGroup);
|
||||
//TODO: Check if classes included are equivalent to classes in class group, and set "includeAllClasses" to true if so
|
||||
|
||||
data.put("includeClasses", classUris);
|
||||
|
||||
//This checks whether restrict classes returned and include institutional internal class
|
||||
//TODO: Create separate method to get restricted classes
|
||||
//Get restrict classes - specifically internal class
|
||||
List<String> restrictClassUris = new ArrayList<String>();
|
||||
StmtIterator restrictClassesIt = writeModel.listStatements(dataGetter,
|
||||
ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY),
|
||||
(RDFNode) null);
|
||||
while(restrictClassesIt.hasNext()) {
|
||||
String restrictClassUri = restrictClassesIt.nextStatement().getResource().getURI();
|
||||
restrictClassUris.add(restrictClassUri);
|
||||
}
|
||||
data.put("restrictClasses", restrictClassUris);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//TODO: Create method to get restricted classes
|
||||
//Get restrict classes - specifically internal class
|
||||
//VClassGroup restrictClassesGroup = new VClassGroup();
|
||||
//restrictClassesGroup.setURI("restrictClasses");
|
||||
//List<VClass> restrictVClasses = new ArrayList<VClass>();
|
||||
|
||||
//Check whether any classes exist with internal class restrictions
|
||||
private void checkInstitutionalInternalClass(OntModel writeModel,
|
||||
Map<String, Object> data) {
|
||||
OntModel mainModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null);
|
||||
//List<String> internalClasses = new ArrayList<String>();
|
||||
if(internalIt.hasNext()) {
|
||||
//internalClasses.add(internalIt.nextStatement().getResource().getURI());
|
||||
String internalClass = internalIt.nextStatement().getResource().getURI();
|
||||
data.put("internalClass", internalClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Get the class page
|
||||
private void getClassGroupForDataGetter(OntModel writeModel, Resource dataGetter,
|
||||
|
|
|
@ -62,6 +62,7 @@ public class DisplayVocabulary {
|
|||
public static final String HAS_TEXT_REPRESENTATION = NS + "hasMenuText";
|
||||
|
||||
|
||||
|
||||
/** <p>The namespace of the vocabulary as a string</p>
|
||||
* @see #NS */
|
||||
public static String getURI() {return NS;}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class VitroVocabulary {
|
|||
public static final String SKIP_EDIT_FORM = vitroURI + "skipEditForm";
|
||||
public static final String PROPERTY_STUBOBJECTPROPERTYANNOT = vitroURI + "stubObjectPropertyAnnot";
|
||||
public static final String PROPERTY_COLLATEBYSUBCLASSANNOT = vitroURI + "collateBySubclassAnnot";
|
||||
|
||||
public static final String IS_INTERNAL_CLASSANNOT = vitroURI + "isMenuPageIntersectionClass";
|
||||
// ================== link related =====================================
|
||||
|
||||
public static final String LINK = vitroURI+"Link";
|
||||
|
|
|
@ -26,22 +26,22 @@ var menuManagementEdit = {
|
|||
});
|
||||
},
|
||||
showClassGroups: function() {
|
||||
if(!this.existingContentType.hasClass("hide")) {
|
||||
this.existingContentType.addClass("hide");
|
||||
this.selectClassesMessage.addClass("hide");
|
||||
this.classesForClassGroup.addClass("hide");
|
||||
if(!this.existingContentType.hasClass("hidden")) {
|
||||
this.existingContentType.addClass("hidden");
|
||||
this.selectClassesMessage.addClass("hidden");
|
||||
this.classesForClassGroup.addClass("hidden");
|
||||
}
|
||||
this.selectContentType.removeClass("hide");
|
||||
this.selectContentType.removeClass("hidden");
|
||||
|
||||
},
|
||||
hideClassGroups: function() {
|
||||
if(!this.selectContentType.hasClass("hide")) {
|
||||
if(!this.selectContentType.hasClass("hidden")) {
|
||||
|
||||
this.selectContentType.addClass("hide");
|
||||
this.selectContentType.addClass("hidden");
|
||||
}
|
||||
this.existingContentType.removeClass("hide");
|
||||
this.selectClassesMessage.removeClass("hide");
|
||||
this.classesForClassGroup.removeClass("hide");
|
||||
this.existingContentType.removeClass("hidden");
|
||||
this.selectClassesMessage.removeClass("hidden");
|
||||
this.classesForClassGroup.removeClass("hidden");
|
||||
},
|
||||
chooseClassGroup: function() {
|
||||
|
||||
|
@ -56,13 +56,13 @@ var menuManagementEdit = {
|
|||
} else {
|
||||
//update existing content type with correct class group name and hide class group select again
|
||||
var _this = menuManagementEdit;
|
||||
_this.hideClassGroups();
|
||||
menuManagementEdit.hideClassGroups();
|
||||
|
||||
_this.selectedGroupForPage.html(results.classGroupName);
|
||||
menuManagementEdit.selectedGroupForPage.html(results.classGroupName);
|
||||
//retrieve classes for class group and display with all selected
|
||||
_this.classesForClassGroup.empty();
|
||||
_this.classesForClassGroup.append("<ul id='selectedClasses' name='selectedClasses'>");
|
||||
_this.classesForClassGroup.append('<li class="ui-state-default">' +
|
||||
menuManagementEdit.classesForClassGroup.empty();
|
||||
menuManagementEdit.classesForClassGroup.append('<ul id="selectedClasses" name="selectedClasses">');
|
||||
menuManagementEdit.classesForClassGroup.append('<li class="ui-state-default">' +
|
||||
'<input type="checkbox" name="allSelected" id="allSelected" value="all" checked/>' +
|
||||
'<label class="inline" for="All"> All</label>' +
|
||||
'</li>');
|
||||
|
@ -75,7 +75,7 @@ var menuManagementEdit = {
|
|||
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
||||
'</li>');
|
||||
});
|
||||
_this.classesForClassGroup.append("</ul>");
|
||||
menuManagementEdit.classesForClassGroup.append("</ul>");
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
<#--
|
||||
Institutional Internal Class Form
|
||||
Associated with generator:
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.InstitutionalInternalClassForm
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.InstitutionalInternalClassForm.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<h2>Lorem ipsum dolor sit amet</h2>
|
||||
<h2>Set up Institutional Internal Class</h2>
|
||||
|
||||
<form class="editForm" action = "${editConfiguration.submitToUrl}">
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
<#-- some additional processing here which shows or hides the class group selection and classes based on initial action-->
|
||||
<#assign existingClassGroupStyle = " " />
|
||||
<#assign selectClassGroupStyle = 'class="hide"' />
|
||||
<#assign selectClassGroupStyle = 'class="hidden"' />
|
||||
<#if menuAction = "Add">
|
||||
<#assign existingClassGroupStyle = 'class="hide"' />
|
||||
<#assign existingClassGroupStyle = 'class="hidden"' />
|
||||
<#assign selectClassGroupStyle = " " />
|
||||
</#if>
|
||||
|
||||
|
@ -65,8 +65,8 @@
|
|||
</section>
|
||||
|
||||
<#-- Select classes in a class group -->
|
||||
<p id="selectClassesMessage" name="selectClassesMessage">Select content to display</p>
|
||||
<section id="classesInSelectedGroup" name="classesInSelectedGroup">
|
||||
<p id="selectClassesMessage" name="selectClassesMessage" ${existingClassGroupStyle}>Select content to display</p>
|
||||
<section id="classesInSelectedGroup" name="classesInSelectedGroup" ${existingClassGroupStyle}>
|
||||
|
||||
<ul id="selectedClasses" name="selectedClasses">
|
||||
<#--Adding a default class for "ALL" in case all classes selected-->
|
||||
|
@ -76,7 +76,15 @@
|
|||
</li>
|
||||
<#list classGroup as classInClassGroup>
|
||||
<li class="ui-state-default">
|
||||
<input type="checkbox" id="classInClassGroup" name="classInClassGroup" value="${classInClassGroup.URI}" <#if includeAllClasses = true>checked</#if> />
|
||||
<input type="checkbox" id="classInClassGroup" name="classInClassGroup" value="${classInClassGroup.URI}"
|
||||
<#if includeAllClasses = true>checked</#if> />
|
||||
<#if isIndividualsForClassesPage?has_content>
|
||||
<#list includeClasses as includeClass>
|
||||
<#if includeClass = classInClassGroup.URI>
|
||||
checked
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
<label class="inline" for="${classInClassGroup.name}"> ${classInClassGroup.name}</label>
|
||||
<span class="ui-icon-sortable"></span> <#--sortable icon for dragging and dropping menu items-->
|
||||
</li>
|
||||
|
@ -84,6 +92,22 @@
|
|||
</ul>
|
||||
</section>
|
||||
|
||||
<#if internalClass?has_content>
|
||||
<#assign enableInternalClass = '<p>To enable this option, you must first select an institutional internal class for your instance</p>' />
|
||||
<#assign disableClass = 'class="disable"' />
|
||||
<#else>
|
||||
<#assign enableInternalClass = '' />
|
||||
<#assign disableClass = '' />
|
||||
</#if>
|
||||
<input type="checkbox" ${disableClass} name="display-internalClass" value="${internalClass}" id="display-internalClass"
|
||||
<#if pageInternalOnly?has_content>
|
||||
checked
|
||||
</#if>
|
||||
/>
|
||||
<label ${disableClass} for="display-internalClass}">Only display ${associatedPage} within my institution</label>
|
||||
${enableInternalClass}
|
||||
|
||||
|
||||
<input type="submit" name="submit-${menuAction}" value="Save changes" class="submit" /> or <a class="cancel" href="${formUrls}">Cancel</a>
|
||||
|
||||
<p class="requiredHint">* required fields</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue