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;mostSpecificType"/>
|
||||||
<owl:AnnotationProperty rdf:about="&vitro;extendedLinkedData"/>
|
<owl:AnnotationProperty rdf:about="&vitro;extendedLinkedData"/>
|
||||||
|
<!--Institutional Internal class -->
|
||||||
|
<owl:AnnotationProperty rdf:about="&vitro;isMenuPageIntersectionClass"/>
|
||||||
|
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
|
|
|
@ -322,6 +322,15 @@ public class MenuManagementEdit extends VitroHttpServlet {
|
||||||
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
||||||
ResourceFactory.createResource(classUri)));
|
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;
|
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.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
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.DisplayVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
@ -36,6 +37,7 @@ import com.hp.hpl.jena.vocabulary.RDF;
|
||||||
public class MenuManagementController extends FreemarkerHttpServlet {
|
public class MenuManagementController extends FreemarkerHttpServlet {
|
||||||
private static final Log log = LogFactory.getLog(MenuManagementController.class);
|
private static final Log log = LogFactory.getLog(MenuManagementController.class);
|
||||||
protected final static String SUBMIT_FORM = "/processEditDisplayModel";
|
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 EDIT_FORM = "testMenuManagement.ftl";
|
||||||
protected final static String CMD_PARAM = "cmd";
|
protected final static String CMD_PARAM = "cmd";
|
||||||
|
@ -76,6 +78,9 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
//Form url submission
|
//Form url submission
|
||||||
data.put("formUrls", vreq.getContextPath() + SUBMIT_FORM);
|
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);
|
return new TemplateResponseValues(EDIT_FORM, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,6 +114,7 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
||||||
Map<String, Object> data = new HashMap<String,Object>();
|
Map<String, Object> data = new HashMap<String,Object>();
|
||||||
data.put("menuAction", "Add");
|
data.put("menuAction", "Add");
|
||||||
//Generate empty values for fields
|
//Generate empty values for fields
|
||||||
|
data.put("menuItem", "");
|
||||||
data.put("menuName", "");
|
data.put("menuName", "");
|
||||||
data.put("prettyUrl", "");
|
data.put("prettyUrl", "");
|
||||||
data.put("associatedPage", "");
|
data.put("associatedPage", "");
|
||||||
|
@ -266,6 +272,21 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
||||||
this.getClassesForDataGetter(writeModel, dataGetter, data);
|
this.getClassesForDataGetter(writeModel, dataGetter, data);
|
||||||
//Also save the class group for display
|
//Also save the class group for display
|
||||||
this.getClassGroupForDataGetter(writeModel, dataGetter, data);
|
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,
|
private void getClassesForDataGetter(OntModel writeModel, Resource dataGetter,
|
||||||
Map<String, Object> data) {
|
Map<String, Object> data) {
|
||||||
VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache(getServletContext());
|
|
||||||
|
|
||||||
StmtIterator classesIt = writeModel.listStatements(dataGetter,
|
StmtIterator classesIt = writeModel.listStatements(dataGetter,
|
||||||
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
||||||
(RDFNode) null);
|
(RDFNode) null);
|
||||||
//TODO: Copied from IndividualsForClassesDataGetter, perhaps could reuse in separate method
|
|
||||||
VClassGroup classesGroup = new VClassGroup();
|
//Just need the class uris
|
||||||
classesGroup.setURI("displayClasses");
|
List<String> classUris = new ArrayList<String>();
|
||||||
List<VClass> vClasses = new ArrayList<VClass>();
|
|
||||||
|
|
||||||
while(classesIt.hasNext()) {
|
while(classesIt.hasNext()) {
|
||||||
String classUri = classesIt.nextStatement().getResource().getURI();
|
String classUri = classesIt.nextStatement().getResource().getURI();
|
||||||
VClass vclass = vcgc.getCachedVClass(classUri);
|
classUris.add(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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
data.put("includeClasses", classesGroup);
|
data.put("includeClasses", classUris);
|
||||||
//TODO: Check if classes included are equivalent to classes in class group, and set "includeAllClasses" to true if so
|
|
||||||
|
//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
|
//Check whether any classes exist with internal class restrictions
|
||||||
//VClassGroup restrictClassesGroup = new VClassGroup();
|
private void checkInstitutionalInternalClass(OntModel writeModel,
|
||||||
//restrictClassesGroup.setURI("restrictClasses");
|
Map<String, Object> data) {
|
||||||
//List<VClass> restrictVClasses = new ArrayList<VClass>();
|
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
|
//Get the class page
|
||||||
private void getClassGroupForDataGetter(OntModel writeModel, Resource dataGetter,
|
private void getClassGroupForDataGetter(OntModel writeModel, Resource dataGetter,
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class DisplayVocabulary {
|
||||||
public static final String HAS_TEXT_REPRESENTATION = NS + "hasMenuText";
|
public static final String HAS_TEXT_REPRESENTATION = NS + "hasMenuText";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** <p>The namespace of the vocabulary as a string</p>
|
/** <p>The namespace of the vocabulary as a string</p>
|
||||||
* @see #NS */
|
* @see #NS */
|
||||||
public static String getURI() {return 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 SKIP_EDIT_FORM = vitroURI + "skipEditForm";
|
||||||
public static final String PROPERTY_STUBOBJECTPROPERTYANNOT = vitroURI + "stubObjectPropertyAnnot";
|
public static final String PROPERTY_STUBOBJECTPROPERTYANNOT = vitroURI + "stubObjectPropertyAnnot";
|
||||||
public static final String PROPERTY_COLLATEBYSUBCLASSANNOT = vitroURI + "collateBySubclassAnnot";
|
public static final String PROPERTY_COLLATEBYSUBCLASSANNOT = vitroURI + "collateBySubclassAnnot";
|
||||||
|
public static final String IS_INTERNAL_CLASSANNOT = vitroURI + "isMenuPageIntersectionClass";
|
||||||
// ================== link related =====================================
|
// ================== link related =====================================
|
||||||
|
|
||||||
public static final String LINK = vitroURI+"Link";
|
public static final String LINK = vitroURI+"Link";
|
||||||
|
|
|
@ -26,22 +26,22 @@ var menuManagementEdit = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showClassGroups: function() {
|
showClassGroups: function() {
|
||||||
if(!this.existingContentType.hasClass("hide")) {
|
if(!this.existingContentType.hasClass("hidden")) {
|
||||||
this.existingContentType.addClass("hide");
|
this.existingContentType.addClass("hidden");
|
||||||
this.selectClassesMessage.addClass("hide");
|
this.selectClassesMessage.addClass("hidden");
|
||||||
this.classesForClassGroup.addClass("hide");
|
this.classesForClassGroup.addClass("hidden");
|
||||||
}
|
}
|
||||||
this.selectContentType.removeClass("hide");
|
this.selectContentType.removeClass("hidden");
|
||||||
|
|
||||||
},
|
},
|
||||||
hideClassGroups: function() {
|
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.existingContentType.removeClass("hidden");
|
||||||
this.selectClassesMessage.removeClass("hide");
|
this.selectClassesMessage.removeClass("hidden");
|
||||||
this.classesForClassGroup.removeClass("hide");
|
this.classesForClassGroup.removeClass("hidden");
|
||||||
},
|
},
|
||||||
chooseClassGroup: function() {
|
chooseClassGroup: function() {
|
||||||
|
|
||||||
|
@ -56,13 +56,13 @@ var menuManagementEdit = {
|
||||||
} else {
|
} else {
|
||||||
//update existing content type with correct class group name and hide class group select again
|
//update existing content type with correct class group name and hide class group select again
|
||||||
var _this = menuManagementEdit;
|
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
|
//retrieve classes for class group and display with all selected
|
||||||
_this.classesForClassGroup.empty();
|
menuManagementEdit.classesForClassGroup.empty();
|
||||||
_this.classesForClassGroup.append("<ul id='selectedClasses' name='selectedClasses'>");
|
menuManagementEdit.classesForClassGroup.append('<ul id="selectedClasses" name="selectedClasses">');
|
||||||
_this.classesForClassGroup.append('<li class="ui-state-default">' +
|
menuManagementEdit.classesForClassGroup.append('<li class="ui-state-default">' +
|
||||||
'<input type="checkbox" name="allSelected" id="allSelected" value="all" checked/>' +
|
'<input type="checkbox" name="allSelected" id="allSelected" value="all" checked/>' +
|
||||||
'<label class="inline" for="All"> All</label>' +
|
'<label class="inline" for="All"> All</label>' +
|
||||||
'</li>');
|
'</li>');
|
||||||
|
@ -75,7 +75,7 @@ var menuManagementEdit = {
|
||||||
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
||||||
'</li>');
|
'</li>');
|
||||||
});
|
});
|
||||||
_this.classesForClassGroup.append("</ul>");
|
menuManagementEdit.classesForClassGroup.append("</ul>");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
<#--
|
<#--
|
||||||
Institutional Internal Class Form
|
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}">
|
<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-->
|
<#-- 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="hide"' />
|
<#assign selectClassGroupStyle = 'class="hidden"' />
|
||||||
<#if menuAction = "Add">
|
<#if menuAction = "Add">
|
||||||
<#assign existingClassGroupStyle = 'class="hide"' />
|
<#assign existingClassGroupStyle = 'class="hidden"' />
|
||||||
<#assign selectClassGroupStyle = " " />
|
<#assign selectClassGroupStyle = " " />
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<#-- Select classes in a class group -->
|
<#-- Select classes in a class group -->
|
||||||
<p id="selectClassesMessage" name="selectClassesMessage">Select content to display</p>
|
<p id="selectClassesMessage" name="selectClassesMessage" ${existingClassGroupStyle}>Select content to display</p>
|
||||||
<section id="classesInSelectedGroup" name="classesInSelectedGroup">
|
<section id="classesInSelectedGroup" name="classesInSelectedGroup" ${existingClassGroupStyle}>
|
||||||
|
|
||||||
<ul id="selectedClasses" name="selectedClasses">
|
<ul id="selectedClasses" name="selectedClasses">
|
||||||
<#--Adding a default class for "ALL" in case all classes selected-->
|
<#--Adding a default class for "ALL" in case all classes selected-->
|
||||||
|
@ -76,7 +76,15 @@
|
||||||
</li>
|
</li>
|
||||||
<#list classGroup as classInClassGroup>
|
<#list classGroup as classInClassGroup>
|
||||||
<li class="ui-state-default">
|
<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>
|
<label class="inline" for="${classInClassGroup.name}"> ${classInClassGroup.name}</label>
|
||||||
<span class="ui-icon-sortable"></span> <#--sortable icon for dragging and dropping menu items-->
|
<span class="ui-icon-sortable"></span> <#--sortable icon for dragging and dropping menu items-->
|
||||||
</li>
|
</li>
|
||||||
|
@ -84,6 +92,22 @@
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</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>
|
<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>
|
<p class="requiredHint">* required fields</p>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue