NIHVIVO-3665 - vitro components for new class hierarchy

This commit is contained in:
tworrall 2012-05-08 19:18:10 +00:00
parent 79cd09e2fa
commit 733c45e330
9 changed files with 906 additions and 4 deletions

View file

@ -12,7 +12,7 @@
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
properties properties
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - -->
<dirname property="corebase.dir" file="${ant.file.vitroCore}" /> <dirname property="corebase.dir" file="${ant.file.vitroCore}" />
<!-- A product script will override appbase.dir, but not corebase.dir --> <!-- A product script will override appbase.dir, but not corebase.dir -->
@ -115,7 +115,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
</not> </not>
</condition> </condition>
</fail> </fail>
<!--
<fail message="The vitro.home.directory &quot;${vitro.home.directory}&quot; is not writable."> <fail message="The vitro.home.directory &quot;${vitro.home.directory}&quot; is not writable.">
<condition> <condition>
<not> <not>
@ -125,7 +125,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
</not> </not>
</condition> </condition>
</fail> </fail>
-->
<property name="solr.home.dir" location="${vitro.home.directory}/solr" /> <property name="solr.home.dir" location="${vitro.home.directory}/solr" />
</target> </target>

View file

@ -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<String, Object> body = new HashMap<String, Object>();
try {
body.put("displayOption", "group");
body.put("pageTitle", "Class Groups");
VClassGroupDao dao = vreq.getFullWebappDaoFactory().getVClassGroupDao();
List<VClassGroup> 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\": \"<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI(),"UTF-8")+"&amp;controller=Classgroup'>"+publicName+"</a>\", ";
} catch (Exception e) {
json += "{ \"name\": \"" + publicName + "\", ";
}
Integer t;
json += "\"data\": { \"displayRank\": \"" + (((t = Integer.valueOf(vcg.getDisplayRank())) != -1) ? t.toString() : "") + "\"}, ";
List<VClass> classList = vcg.getVitroClassList();
if (classList != null && classList.size()>0) {
json += "\"children\": [";
Iterator<VClass> classIt = classList.iterator();
while (classIt.hasNext()) {
VClass vcw = classIt.next();
if (vcw.getName() != null && vcw.getURI() != null) {
try {
json += "{ \"name\": \"<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"'>"+vcw.getName()+"</a>\", ";
} 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);
}
}

View file

@ -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<String, Object> body = new HashMap<String, Object>();
try {
body.put("displayOption", "all");
body.put("pageTitle", "All Classes");
List<VClass> 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<VClass> 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\": \"<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getLocalNameWithPrefix()+"</a>\", ";
} 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);
}
}

View file

@ -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<String, Object> body = new HashMap<String, Object>();
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<VClass> roots = null;
if (ontologyUri != null) {
roots = vcDao.getOntologyRootClasses(ontologyUri);
} else if (startClassUri != null) {
roots = new LinkedList<VClass>();
roots.add(vcDao.getVClassByURI(startClassUri));
} else {
roots = vcDao.getRootClasses();
}
if (roots.isEmpty()) {
roots = new LinkedList<VClass>();
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("<strong>No classes found.</strong>");
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<MAXDEPTH) {
List childClasses = new ArrayList();
Iterator childURIstrIt = childURIstrs.iterator();
while (childURIstrIt.hasNext()) {
String URIstr = (String) childURIstrIt.next();
try {
VClass child = (VClass) vcDao.getVClassByURI(URIstr);
if (!child.getURI().equals(OWL.Nothing.getURI())) {
childClasses.add(child);
}
} catch (Exception e) {}
}
Collections.sort(childClasses);
Iterator childClassIt = childClasses.iterator();
while (childClassIt.hasNext()) {
VClass child = (VClass) childClassIt.next();
leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter, "child");
if (!childClassIt.hasNext()) {
if ( ontologyUri == null ) {
leaves += " }] ";
}
else if ( ontologyUri != null && length > 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 += "\"<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"'>"+vcw.getLocalNameWithPrefix()+"</a>\", ";
} 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;
}
}

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

View file

@ -0,0 +1,269 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var classHierarchyUtils = {
onLoad: function(urlBase,displayOption) {
this.imagePath = urlBase + "/images/";
this.initObjects();
this.expandAll.hide();
if ( displayOption == "all" ) {
this.buildAllClassesHtml();
}
else if ( displayOption == "group" ) {
this.buildClassGroupHtml();
}
else {
this.buildClassHierarchyHtml();
this.wireExpandLink();
}
if ( displayOption == "asserted" || displayOption == "inferred" ) {
this.expandAll.show();
}
this.bindEventListeners();
},
initObjects: function() {
this.expandAll = $('span#expandAll').find('a');
this.classCounter = 1;
this.expandCounter = 1;
this.classHtml = "";
this.clickableSpans = [] ;
this.form = $('form#classHierarchyForm');
this.select = $('select#displayOption');
this.addClass = $('input#addClass');
},
bindEventListeners: function() {
this.select.change(function() {
if ( classHierarchyUtils.select.val() == "all") {
classHierarchyUtils.form.attr("action", "listVClassWebapps");
}
else if ( classHierarchyUtils.select.val() == "group") {
classHierarchyUtils.form.attr("action", "listGroups");
}
classHierarchyUtils.form.submit();
});
this.addClass.click(function() {
classHierarchyUtils.form.attr("action", "vclass_retry");
classHierarchyUtils.form.submit();
});
},
buildClassHierarchyHtml: function() {
$.each(json, function() {
$newClassSection = jQuery("<section></section>", {
id: "classContainer" + classHierarchyUtils.classCounter
});
var descendants = "";
var headerSpan = "";
if ( this.children.length ) {
descendants = classHierarchyUtils.getTheChildren(this);
headerSpan = "<span class='headerSpanPlus' id='headerSpan" + classHierarchyUtils.classCounter
+ "' view='less'>&nbsp;</span>";
}
classHierarchyUtils.classHtml += "<div>" + this.name + headerSpan + "</div>" + "<table class='classHierarchy' id='classHierarchy"
+ classHierarchyUtils.classCounter + "'>" ;
if ( this.data.shortDef.length > 0 ) {
classHierarchyUtils.classHtml += "<tr><td colspan='2'>" + this.data.shortDef + "</td></tr>";
}
if ( this.data.classGroup.length > 0 ) {
classHierarchyUtils.classHtml += "<tr><td class='classDetail'>Class Group:</td><td>" + this.data.classGroup + "</td></tr>";
}
classHierarchyUtils.classHtml += "<tr><td class='classDetail'>Ontology:</td><td>" + this.data.ontology + "</td></tr>";
classHierarchyUtils.classHtml += descendants;
classHierarchyUtils.classHtml += "</table>";
// 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 += "<tr><td class='classDetail'>Subclasses:</td>";
ctr = ctr + 1;
}
else {
childDetails += "<tr><td></td>" ;
}
childDetails += "<td class='subclassCell'><span class='subclassExpandPlus' id='subclassExpand"
+ classHierarchyUtils.expandCounter + "'>&nbsp;</span>"
+ this.name + "</td></tr><tr><td></td><td><table id='subclassTable"
+ classHierarchyUtils.expandCounter + "' class='subclassTable'>";
classHierarchyUtils.clickableSpans.push('subclassExpand' + classHierarchyUtils.expandCounter);
classHierarchyUtils.expandCounter += 1;
if ( this.data.shortDef.length > 0 ) {
childDetails += "<tr><td colspan='2'>" + this.data.shortDef + "</td></tr>";
}
if ( this.data.classGroup.length > 0 ) {
childDetails += "<tr><td class='classDetail'>Class Group:</td><td>" + this.data.classGroup + "</td></tr>";
}
childDetails += "<tr><td class='classDetail'>Ontology:</td><td>" + this.data.ontology + "</td></tr>";
if ( this.children ) {
var grandChildren = classHierarchyUtils.getTheChildren(this);
childDetails += grandChildren;
}
});
childDetails += "</table></td></tr>";
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("<section></section>", {
id: "classContainer" + classHierarchyUtils.classCounter
});
classHierarchyUtils.classHtml += "<div>" + this.name + "</div>" + "<table class='classHierarchy' id='classHierarchy"
+ classHierarchyUtils.classCounter + "'>" ;
if ( this.data.shortDef.length > 0 ) {
classHierarchyUtils.classHtml += "<tr><td colspan='2'>" + this.data.shortDef + "</td></tr>";
}
if ( this.data.classGroup.length > 0 ) {
classHierarchyUtils.classHtml += "<tr><td class='classDetail'>Class Group:</td><td>" + this.data.classGroup + "</td></tr>";
}
classHierarchyUtils.classHtml += "<tr><td class='classDetail'>Ontology:</td><td>" + this.data.ontology + "</td></tr>";
classHierarchyUtils.classHtml += "</table>";
$newClassSection.html(classHierarchyUtils.classHtml);
$newClassSection.appendTo($('section#container'));
classHierarchyUtils.classHtml = "";
classHierarchyUtils.classCounter += 1;
});
},
buildClassGroupHtml: function() {
$.each(json, function() {
$newClassSection = jQuery("<section></section>", {
id: "classContainer" + classHierarchyUtils.classCounter
});
var descendants = "";
if ( this.children.length ) {
var ctr = 0;
$.each(this.children, function() {
if ( ctr == 0 ) {
descendants += "<tr><td class='classDetail'>Classes:</td>";
ctr = ctr + 1;
}
else {
descendants += "<tr><td></td>" ;
}
descendants += "<td class='subclassCell'>" + this.name + "</td></tr>";
descendants += "<tr><td></td><td><table class='innerDefinition'><tr><td>" + this.data.shortDef + "</td></tr></table></td></tr>";
});
descendants += "</table></td></tr>";
}
classHierarchyUtils.classHtml += "<div>" + this.name + "</div>" + "<table class='classHierarchy' id='classHierarchy"
+ classHierarchyUtils.classCounter + "'>" ;
if ( this.data.displayRank.length > 0 ) {
classHierarchyUtils.classHtml += "<tr><td class='classDetail'>Display Rank:</td><td>" + this.data.displayRank + "</td></tr>"
}
classHierarchyUtils.classHtml += descendants;
classHierarchyUtils.classHtml += "</table>";
// alert(classHierarchyUtils.classHtml);
$newClassSection.html(classHierarchyUtils.classHtml);
$newClassSection.appendTo($('section#container'));
classHierarchyUtils.classHtml = "";
classHierarchyUtils.classCounter += 1;
});
}
}

View file

@ -0,0 +1,43 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<section role="region">
<h2>${pageTitle!}</h2>
<#if !displayOption?has_content>
<#assign displayOption = "asserted">
</#if>
<form name="classHierarchyForm" id="classHierarchyForm" action="showClassHierarchy" method="post" role="classHierarchy">
<label id="displayOptionLabel" class="inline">Display Options</label>
<select id="displayOption" name="displayOption">
<option value="asserted" <#if displayOption == "asserted">selected</#if> >Asserted Class Hierarchy</option>
<option value="inferred" <#if displayOption == "inferred">selected</#if> >Inferred Class Hierarchy</option>
<option value="all" <#if displayOption == "all">selected</#if> >All Classes</option>
<option value="group" <#if displayOption == "group">selected</#if> >Classes by Class Group</option>
</select>
<input id="addClass" value="Add New Class" class="form-button" type="submit" />
</form>
<div id="expandLink"><span id="expandAll" ><a href="#" title="expand all">expand all</a></span></div>
<section id="container">
</section>
</section>
<script language="javascript" type="text/javascript" >
var json = [${jsonTree!}];
</script>
<script language="javascript" type="text/javascript" >
$(document).ready(function() {
classHierarchyUtils.onLoad("${urls.base!}","${displayOption!}");
});
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/classHierarchy.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/siteAdmin/classHierarchyUtils.js"></script>')}