From 733c45e3301eb31a214dd3984c90b88037e4be9c Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 8 May 2012 19:18:10 +0000 Subject: [PATCH] NIHVIVO-3665 - vitro components for new class hierarchy --- webapp/build.xml | 8 +- .../freemarker/ListClassGroupsController.java | 117 ++++++++ .../ListVClassWebappsController.java | 141 +++++++++ .../ShowClassHierarchyController.java | 247 ++++++++++++++++ webapp/web/css/classHierarchy.css | 85 ++++++ webapp/web/images/vitro_minus_sign.gif | Bin 0 -> 200 bytes webapp/web/images/vitro_plus_sign.gif | Bin 0 -> 324 bytes .../web/js/siteAdmin/classHierarchyUtils.js | 269 ++++++++++++++++++ .../siteAdmin/siteAdmin-classHierarchy.ftl | 43 +++ 9 files changed, 906 insertions(+), 4 deletions(-) create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java create mode 100644 webapp/web/css/classHierarchy.css create mode 100644 webapp/web/images/vitro_minus_sign.gif create mode 100644 webapp/web/images/vitro_plus_sign.gif create mode 100644 webapp/web/js/siteAdmin/classHierarchyUtils.js create mode 100644 webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl diff --git a/webapp/build.xml b/webapp/build.xml index e9109d57d..429c87998 100644 --- a/webapp/build.xml +++ b/webapp/build.xml @@ -3,7 +3,7 @@ @@ -12,7 +12,7 @@ + - - - - - - - - - - - - - - - - --> @@ -115,7 +115,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory. - + diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java new file mode 100644 index 000000000..73384ba8c --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java @@ -0,0 +1,117 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.freemarker; + +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; +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.VClassGroupDao; + + +public class ListClassGroupsController extends FreemarkerHttpServlet { + + private static final Log log = LogFactory.getLog(ListClassGroupsController.class.getName()); + + private static final String TEMPLATE_NAME = "siteAdmin-classHierarchy.ftl"; + + @Override + protected Actions requiredActions(VitroRequest vreq) { + return SimplePermission.EDIT_ONTOLOGY.ACTIONS; + } + + @Override + protected ResponseValues processRequest(VitroRequest vreq) { + + Map body = new HashMap(); + try { + + body.put("displayOption", "group"); + body.put("pageTitle", "Class Groups"); + + VClassGroupDao dao = vreq.getFullWebappDaoFactory().getVClassGroupDao(); + + List groups = dao.getPublicGroupsWithVClasses(); + + String json = new String(); + int counter = 0; + + if (groups != null) { + for(VClassGroup vcg: groups) { + if ( counter > 0 ) { + json += ", "; + } + String publicName = vcg.getPublicName(); + if ( StringUtils.isBlank(publicName) ) { + publicName = "(unnamed group)"; + } + try { + json += "{ \"name\": \""+publicName+"\", "; + } catch (Exception e) { + json += "{ \"name\": \"" + publicName + "\", "; + } + Integer t; + + json += "\"data\": { \"displayRank\": \"" + (((t = Integer.valueOf(vcg.getDisplayRank())) != -1) ? t.toString() : "") + "\"}, "; + + List classList = vcg.getVitroClassList(); + if (classList != null && classList.size()>0) { + json += "\"children\": ["; + Iterator classIt = classList.iterator(); + while (classIt.hasNext()) { + VClass vcw = classIt.next(); + if (vcw.getName() != null && vcw.getURI() != null) { + try { + json += "{ \"name\": \""+vcw.getName()+"\", "; + } catch (Exception e) { + json += "\"" + vcw.getName() + "\", "; + } + } else { + json += "\"\", "; + } + + String shortDefStr = (vcw.getShortDef() == null) ? "" : vcw.getShortDef(); + json += "\"data\": { \"shortDef\": \"" + shortDefStr + "\"}, \"children\": [] "; + if (classIt.hasNext()) + json += "} , "; + else + json += "}] "; + } + } + else { + json += "\"children\": [] "; + } + json += "} "; + counter += 1; + } + } + + body.put("jsonTree",json); + + } catch (Throwable t) { + t.printStackTrace(); + } + + return new TemplateResponseValues(TEMPLATE_NAME, body); + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java new file mode 100644 index 000000000..8c1f40e69 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java @@ -0,0 +1,141 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.freemarker; + +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.hp.hpl.jena.vocabulary.OWL; + +import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; +import edu.cornell.mannlib.vitro.webapp.beans.Ontology; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; +import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +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.OntologyDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; + + +public class ListVClassWebappsController extends FreemarkerHttpServlet { + + private static final Log log = LogFactory.getLog(ListVClassWebappsController.class.getName()); + + private static final String TEMPLATE_NAME = "siteAdmin-classHierarchy.ftl"; + + @Override + protected Actions requiredActions(VitroRequest vreq) { + return SimplePermission.EDIT_ONTOLOGY.ACTIONS; + } + + @Override + protected ResponseValues processRequest(VitroRequest vreq) { + + Map body = new HashMap(); + try { + + body.put("displayOption", "all"); + body.put("pageTitle", "All Classes"); + + List classes = null; + + if (vreq.getParameter("showPropertyRestrictions") != null) { + PropertyDao pdao = vreq.getFullWebappDaoFactory().getObjectPropertyDao(); + classes = pdao.getClassesWithRestrictionOnProperty(vreq.getParameter("propertyURI")); + } else { + VClassDao vcdao = vreq.getFullWebappDaoFactory().getVClassDao(); + + if (vreq.getParameter("iffRoot") != null) { + classes = vcdao.getRootClasses(); + } else { + classes = vcdao.getAllVclasses(); + } + + } + String json = new String(); + int counter = 0; + + String ontologyURI = vreq.getParameter("ontologyUri"); + + if (classes != null) { + Collections.sort(classes); + Iterator classesIt = classes.iterator(); + while (classesIt.hasNext()) { + if ( counter > 0 ) { + json += ", "; + } + VClass cls = (VClass) classesIt.next(); + if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) { + if (cls.getName() != null) + try { + json += "{ \"name\": \""+cls.getLocalNameWithPrefix()+"\", "; + } catch (Exception e) { + json += "{ \"name\": \"" + cls.getLocalNameWithPrefix() + "\", "; + } + else + json += "{ \"name\": \"\""; + String shortDef = (cls.getShortDef()==null) ? "" : cls.getShortDef(); + + json += "\"data\": { \"shortDef\": \"" + shortDef + "\", "; + + // get group name + WebappDaoFactory wadf = vreq.getFullWebappDaoFactory(); + VClassGroupDao groupDao= wadf.getVClassGroupDao(); + String groupURI = cls.getGroupURI(); + String groupName = ""; + VClassGroup classGroup = null; + if(groupURI != null) { + classGroup = groupDao.getGroupByURI(groupURI); + if (classGroup!=null) { + groupName = classGroup.getPublicName(); + } + } + + json += "\"classGroup\": \"" + groupName + "\", "; + + // get ontology name + OntologyDao ontDao = wadf.getOntologyDao(); + String ontName = null; + try { + Ontology ont = ontDao.getOntologyByURI(cls.getNamespace()); + ontName = ont.getName(); + } catch (Exception e) {} + ontName = (ontName == null) ? "" : ontName; + + json += "\"ontology\": \"" + ontName + "\"} }"; + + counter += 1; + + } + } + body.put("jsonTree",json); + } + + } catch (Throwable t) { + t.printStackTrace(); + } + + return new TemplateResponseValues(TEMPLATE_NAME, body); + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java new file mode 100644 index 000000000..f91adbb07 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java @@ -0,0 +1,247 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.freemarker; + +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.hp.hpl.jena.vocabulary.OWL; + +import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; +import edu.cornell.mannlib.vitro.webapp.beans.Ontology; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; +import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +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.email.FreemarkerEmailFactory; +import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; + + +public class ShowClassHierarchyController extends FreemarkerHttpServlet { + + private static final Log log = LogFactory.getLog(ShowClassHierarchyController.class.getName()); + + private static final String TEMPLATE_NAME = "siteAdmin-classHierarchy.ftl"; + private int MAXDEPTH = 7; + + private VClassDao vcDao = null; + + private int previous_posn = 0; + private int childCount = 0; + private int uriCounter = 0; + + @Override + protected Actions requiredActions(VitroRequest vreq) { + return SimplePermission.EDIT_ONTOLOGY.ACTIONS; + } + + @Override + protected ResponseValues processRequest(VitroRequest vreq) { + + Map body = new HashMap(); + try { + String displayOption = ""; + + if ( vreq.getParameter("displayOption") != null ) { + displayOption = vreq.getParameter("displayOption"); + } + else { + displayOption = "asserted"; + } + + body.put("displayOption", displayOption); + boolean inferred = ( displayOption.equals("inferred") ); + if ( inferred ) { + body.put("pageTitle", "Inferred Class Hierarchy"); + } + else { + body.put("pageTitle", "Asserted Class Hierarchy"); + } + + if (vreq.getAssertionsWebappDaoFactory() != null && !inferred) { + vcDao = vreq.getAssertionsWebappDaoFactory().getVClassDao(); + } else { + vcDao = vreq.getFullWebappDaoFactory().getVClassDao(); + } + String json = new String(); + + String ontologyUri = vreq.getParameter("ontologyUri"); + String startClassUri = vreq.getParameter("vclassUri"); + + List roots = null; + + if (ontologyUri != null) { + roots = vcDao.getOntologyRootClasses(ontologyUri); + } else if (startClassUri != null) { + roots = new LinkedList(); + roots.add(vcDao.getVClassByURI(startClassUri)); + } else { + roots = vcDao.getRootClasses(); + } + + if (roots.isEmpty()) { + roots = new LinkedList(); + roots.add(vreq.getFullWebappDaoFactory().getVClassDao() + .getTopConcept()); + } + Collections.sort(roots); + int counter = 0; + + Iterator rootIt = roots.iterator(); + if (!rootIt.hasNext()) { + VClass vcw = new VClass(); + vcw.setName("No classes found."); + json += addVClassDataToResultsList(vreq.getFullWebappDaoFactory(), vcw,0,ontologyUri,counter); + } else { + while (rootIt.hasNext()) { + VClass root = (VClass) rootIt.next(); + if (root != null) { + json += addChildren(vreq.getFullWebappDaoFactory(), root, 0, ontologyUri,counter,"parent"); + counter += 1; + } + } + int length = json.length(); + if ( length > 0 ) { + json += " }"; + } + } + body.put("jsonTree",json); + + } catch (Throwable t) { + t.printStackTrace(); + } + + return new TemplateResponseValues(TEMPLATE_NAME, body); + } + + private String addChildren(WebappDaoFactory wadf, VClass parent, int position, String ontologyUri, int counter, String status) { + String rowElts = addVClassDataToResultsList(wadf, parent, position, ontologyUri, counter); + int childShift = (rowElts.length() > 0) ? 1 : 0; // if addVClassDataToResultsList filtered out the result, don't shift the children over + int length = rowElts.length(); + String leaves = ""; + leaves += rowElts; + List childURIstrs = vcDao.getSubClassURIs(parent.getURI()); + if ((childURIstrs.size()>0) && position 0 ) { + // need this for when we show the classes associated with an ontology + String ending = leaves.substring(leaves.length() - 2, leaves.length()); + if ( ending.equals("] ") ) { + log.debug("[1] leaves += }]"); + leaves += "}]"; + } + else if ( ending.equals(" [") ){ + log.debug("[2] leaves += ]"); + leaves += "] "; + } + else { + log.debug("[3] leaves += }]"); + leaves += "}]"; + } + } + } + } + } + else { + if ( ontologyUri == null ) { + leaves += "] "; + } + else if ( ontologyUri != null && length > 0 ) { + leaves += "] "; + } + } + return leaves; + } + + private String addVClassDataToResultsList(WebappDaoFactory wadf, VClass vcw, int position, String ontologyUri, int counter) { + String tempString = ""; + if (ontologyUri == null || ( (vcw.getNamespace()!=null) && (vcw.getNamespace().equals(ontologyUri)) ) ) { + // first if statement ensures that the first class begins with correct format + if ( counter < 1 && position < 1 ) { + tempString += "{ \"name\": "; + } + else if ( position == previous_posn ) { + tempString += "}, { \"name\": "; + } + else if ( position > previous_posn ) { + tempString += " { \"name\": "; + } + else if ( position < previous_posn ) { + tempString += "}, { \"name\": "; + } + + try { + tempString += "\""+vcw.getLocalNameWithPrefix()+"\", "; + } catch (Exception e) { + tempString += "\" " + ((vcw.getLocalNameWithPrefix() == null) ? "" : vcw.getLocalNameWithPrefix()) + "\", "; + } + + tempString += "\"data\": { \"shortDef\": \"" + ((vcw.getShortDef() == null) ? "" : vcw.getShortDef()) + "\", "; + + // Get group name if it exists + VClassGroupDao groupDao= wadf.getVClassGroupDao(); + String groupURI = vcw.getGroupURI(); + String groupName = null; + VClassGroup classGroup = null; + if(groupURI != null) { + classGroup = groupDao.getGroupByURI(groupURI); + if (classGroup != null) { + groupName = classGroup.getPublicName(); + } + } + tempString += "\"classGroup\": \"" + ((groupName == null) ? "" : groupName) + "\", "; + // Get ontology name + String ontName = null; + try { + OntologyDao ontDao = wadf.getOntologyDao(); + Ontology ont = ontDao.getOntologyByURI(vcw.getNamespace()); + ontName = ont.getName(); + } catch (Exception e) {} + + tempString += "\"ontology\": \"" + ((ontName == null) ? "" : ontName) + "\"}, \"children\": ["; + + previous_posn = position; + } + return tempString; + } + +} diff --git a/webapp/web/css/classHierarchy.css b/webapp/web/css/classHierarchy.css new file mode 100644 index 000000000..f1f92b5bb --- /dev/null +++ b/webapp/web/css/classHierarchy.css @@ -0,0 +1,85 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +table.classHierarchy { + margin-left:25px; + margin-right:25px; + margin-bottom:22px; + font-size:.8em; + min-width:900px; + max-width:900px; + background-color:#f8f8f8; + border-style: solid; + border-width: 1px; + border-color: #f0f0f0; +} +table.classHierarchy td { + padding-left:6px; +} +table.classHierarchy .classDetail { + width:90px; + color:#064D68; + white-space: nowrap; +} +table.subclassTable { + margin-left:15px; + margin-bottom:4px; + margin-top:-4px; + display:none; +} +td.subclassCell { + font-size:1.2em; + padding-bottom:4px; +} +section#container div { + width:925px; + background-color:#f2f2f2; + vertical-align:middle; + height:26px; +} +section#container div a { + margin-left: 6px; + font-weight: bold; +} +section#container div span { + padding-right: 10px; + float: right; +} +span.headerSpanPlus { + width: 12px; + background: url(../images/vitro_plus_sign.gif) left center no-repeat; +} +span.headerSpanMinus { + width: 12px; + background: url(../images/vitro_minus_sign.gif) left center no-repeat; +} +span.subclassExpandPlus { + padding-right: 14px; + background: url(../images/vitro_plus_sign.gif) left center no-repeat; +} +span.subclassExpandMinus { + padding-right: 14px; + background: url(../images/vitro_minus_sign.gif) left center no-repeat; +} +span#expandAll { + margin-right: 10px; + float: right; + font-size: 0.85em; +} +div#expandLink { + margin-top:-10px; + width:100%; + margin-bottom:24px; +} +label#displayOptions { + display:inline-block; + padding-right:6px; + margin-top:20px; +} +table.innerDefinition { + margin-top:-5px; + margin-left:4px; + margin-right:4px; + margin-bottom:4px; + line-height:20px; +} + diff --git a/webapp/web/images/vitro_minus_sign.gif b/webapp/web/images/vitro_minus_sign.gif new file mode 100644 index 0000000000000000000000000000000000000000..d65d2246da2490da81d7b92b80d41e999052585f GIT binary patch literal 200 zcmZ?wbhEHbY8j*E?rjgL);i;Ihok57zGN=!^lPEJlqNl8sj&j5j} z%*@QJtgPJJ-2D8)qJrYW!orf0l8TCos;a8``uc{3hNh;b=H}*>mX?l=jwzF-{)Yj@ ze^Smxsfi`2DGKG8B^e6tp1uJJ`FRS73ciWS42nNl7`Yha8FUzc0OTSDR`mz!eJPpq oG`u*tRdYR(83H~>oNLJx7uRfeT|DW8h*Tq^^3fbCS49SE0A|Qaf&c&j literal 0 HcmV?d00001 diff --git a/webapp/web/images/vitro_plus_sign.gif b/webapp/web/images/vitro_plus_sign.gif new file mode 100644 index 0000000000000000000000000000000000000000..3692ef627a3ad707425afaab61bf6db674103c6a GIT binary patch literal 324 zcmZ?wbhEHbF8yg>+5EmC0A0M9>pOl!Gn4FxP zl9G}N0_hoPnHeCEm6eg5nVFfLnUj^3m6MZ`o12@TTaXU|g+&F$g@uJhMMWhgC8edM z6%`d#RaN!%^$iUTO-)VB&CM+>E$!{?9UUE=ot;xAO`S7m&VLGk;y)?pqSVBa)D(sC z%#sWRcTe8{h5S5)L", { + id: "classContainer" + classHierarchyUtils.classCounter + }); + var descendants = ""; + var headerSpan = ""; + + if ( this.children.length ) { + descendants = classHierarchyUtils.getTheChildren(this); + headerSpan = " "; + } + + classHierarchyUtils.classHtml += "
" + this.name + headerSpan + "
" + "" ; + + if ( this.data.shortDef.length > 0 ) { + classHierarchyUtils.classHtml += ""; + } + + if ( this.data.classGroup.length > 0 ) { + classHierarchyUtils.classHtml += ""; + } + + classHierarchyUtils.classHtml += ""; + + + classHierarchyUtils.classHtml += descendants; + + classHierarchyUtils.classHtml += "
" + this.data.shortDef + "
Class Group:" + this.data.classGroup + "
Ontology:" + this.data.ontology + "
"; + // alert(classHierarchyUtils.classHtml); + $newClassSection.html(classHierarchyUtils.classHtml); + $newClassSection.appendTo($('section#container')); + classHierarchyUtils.makeHeaderSpansClickable(classHierarchyUtils.classCounter); + classHierarchyUtils.makeSubclassSpansClickable(); + classHierarchyUtils.clickableSpans = [] ; + classHierarchyUtils.classHtml = ""; + classHierarchyUtils.classCounter += 1; + }); + }, + + getTheChildren: function(node) { + var childDetails = ""; + var ctr = 0 + $.each(node.children, function() { + if ( ctr == 0 ) { + childDetails += "Subclasses:"; + ctr = ctr + 1; + } + else { + childDetails += "" ; + } + + childDetails += " " + + this.name + ""; + + classHierarchyUtils.clickableSpans.push('subclassExpand' + classHierarchyUtils.expandCounter); + + classHierarchyUtils.expandCounter += 1; + + if ( this.data.shortDef.length > 0 ) { + childDetails += ""; + } + + if ( this.data.classGroup.length > 0 ) { + childDetails += ""; + } + + childDetails += ""; + + if ( this.children ) { + var grandChildren = classHierarchyUtils.getTheChildren(this); + childDetails += grandChildren; + } + }); + childDetails += "
" + this.data.shortDef + "
Class Group:" + this.data.classGroup + "
Ontology:" + this.data.ontology + "
"; + return childDetails; + }, + + makeHeaderSpansClickable: function(ctr) { + + var $clickableHeader = $('section#classContainer' + ctr).find('span.headerSpanPlus'); + + $clickableHeader.click(function() { + if ( $clickableHeader.attr('view') == "less" ) { + $clickableHeader.addClass("headerSpanMinus"); + $('table#classHierarchy' + ctr).find('span').addClass("subclassExpandMinus"); + $('table#classHierarchy' + ctr).find('table.subclassTable').show(); + $clickableHeader.attr('view', 'more' ); + } + else { + $clickableHeader.removeClass("headerSpanMinus"); + $('table#classHierarchy' + ctr).find('span').removeClass("subclassExpandMinus"); + $('table#classHierarchy' + ctr).find('table.subclassTable').hide(); + $clickableHeader.attr('view', 'less' ); + } + }); + },// $('myOjbect').css('background-image', 'url(' + imageUrl + ')'); + + makeSubclassSpansClickable: function() { + $.each(classHierarchyUtils.clickableSpans, function() { + var currentSpan = this; + var $clickableSpan = $('section#container').find('span#' + currentSpan); + var $subclassTable = $('section#container').find('table#subclassTable' + currentSpan.replace("subclassExpand","")); + + $clickableSpan.click(function() { + if ( $subclassTable.is(':visible') ) { + $subclassTable.hide(); + $subclassTable.find('table.subclassTable').hide(); + $subclassTable.find('span').removeClass("subclassExpandMinus"); + $clickableSpan.removeClass("subclassExpandMinus"); + } + else { + $subclassTable.show(); + $clickableSpan.addClass("subclassExpandMinus"); + } + }); + }); + }, + + wireExpandLink: function() { + this.expandAll.click(function() { + if ( classHierarchyUtils.expandAll.text() == "expand all" ) { + classHierarchyUtils.expandAll.text("collapse all"); + $('span.headerSpanPlus').addClass("headerSpanMinus"); + $('table.classHierarchy').find('span').addClass("subclassExpandMinus"); + $('table.classHierarchy').find('table.subclassTable').show(); + $('section#container').find('span.headerSpanPlus').attr('view','more'); + } + else { + classHierarchyUtils.expandAll.text("expand all"); + $('span.headerSpanPlus').removeClass("headerSpanMinus"); + $('table.classHierarchy').find('span').removeClass("subclassExpandMinus"); + $('table.classHierarchy').find('table.subclassTable').hide(); + $('section#container').find('span.headerSpanPlus').attr('view','less'); + } + }); + }, + + buildAllClassesHtml: function() { + + $.each(json, function() { + $newClassSection = jQuery("
", { + id: "classContainer" + classHierarchyUtils.classCounter + }); + + classHierarchyUtils.classHtml += "
" + this.name + "
" + "" ; + + if ( this.data.shortDef.length > 0 ) { + classHierarchyUtils.classHtml += ""; + } + + if ( this.data.classGroup.length > 0 ) { + classHierarchyUtils.classHtml += ""; + } + + classHierarchyUtils.classHtml += ""; + + classHierarchyUtils.classHtml += "
" + this.data.shortDef + "
Class Group:" + this.data.classGroup + "
Ontology:" + this.data.ontology + "
"; + + $newClassSection.html(classHierarchyUtils.classHtml); + $newClassSection.appendTo($('section#container')); + classHierarchyUtils.classHtml = ""; + classHierarchyUtils.classCounter += 1; + }); + }, + + buildClassGroupHtml: function() { + + $.each(json, function() { + $newClassSection = jQuery("
", { + id: "classContainer" + classHierarchyUtils.classCounter + }); + var descendants = ""; + + if ( this.children.length ) { + var ctr = 0; + $.each(this.children, function() { + if ( ctr == 0 ) { + descendants += "Classes:"; + ctr = ctr + 1; + } + else { + descendants += "" ; + } + + descendants += "" + this.name + ""; + descendants += "
" + this.data.shortDef + "
"; + + }); + descendants += ""; + } + + classHierarchyUtils.classHtml += "
" + this.name + "
" + "" ; + + if ( this.data.displayRank.length > 0 ) { + classHierarchyUtils.classHtml += "" + } + + classHierarchyUtils.classHtml += descendants; + + classHierarchyUtils.classHtml += "
Display Rank:" + this.data.displayRank + "
"; + // alert(classHierarchyUtils.classHtml); + $newClassSection.html(classHierarchyUtils.classHtml); + $newClassSection.appendTo($('section#container')); + classHierarchyUtils.classHtml = ""; + classHierarchyUtils.classCounter += 1; + }); + } +} diff --git a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl new file mode 100644 index 000000000..7f2d15e48 --- /dev/null +++ b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl @@ -0,0 +1,43 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +
+ +

${pageTitle!}

+ + <#if !displayOption?has_content> + <#assign displayOption = "asserted"> + +
+ + + +
+ + + + + +
+ +
+
+ + + + +${stylesheets.add('')} + +${scripts.add('', + '')} +