diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java new file mode 100644 index 000000000..6e7bb1dc2 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java @@ -0,0 +1,160 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.freemarker; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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.DataProperty; +import edu.cornell.mannlib.vitro.webapp.beans.Datatype; +import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.Controllers; +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.DataPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; + +public class ListDatatypePropertiesController extends FreemarkerHttpServlet { + + private static Log log = LogFactory.getLog( ListDatatypePropertiesController.class ); + + private static final String TEMPLATE_NAME = "siteAdmin-objectPropHierarchy.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 Data Properties"); + body.put("propertyType", "data"); + + String noResultsMsgStr = "No data properties found"; + + String ontologyUri = vreq.getParameter("ontologyUri"); + + DataPropertyDao dao = vreq.getFullWebappDaoFactory().getDataPropertyDao(); + VClassDao vcDao = vreq.getFullWebappDaoFactory().getVClassDao(); + DatatypeDao dDao = vreq.getFullWebappDaoFactory().getDatatypeDao(); + PropertyGroupDao pgDao = vreq.getFullWebappDaoFactory().getPropertyGroupDao(); + + List props = new ArrayList(); + if (vreq.getParameter("propsForClass") != null) { + noResultsMsgStr = "There are no data properties that apply to this class."; + Collection dataProps = dao.getDataPropertiesForVClass(vreq.getParameter("vclassUri")); + Iterator dataPropIt = dataProps.iterator(); + HashSet propURIs = new HashSet(); + while (dataPropIt.hasNext()) { + DataProperty dp = dataPropIt.next(); + if (!(propURIs.contains(dp.getURI()))) { + propURIs.add(dp.getURI()); + DataProperty prop = dao.getDataPropertyByURI(dp.getURI()); + if (prop != null) { + props.add(prop); + } + } + } + } else { + props = dao.getAllDataProperties(); + } + + if (ontologyUri != null) { + List scratch = new ArrayList(); + for (DataProperty p: props) { + if (p.getNamespace().equals(ontologyUri)) { + scratch.add(p); + } + } + props = scratch; + } + + if (props != null) { + Collections.sort(props); + } + + String json = new String(); + int counter = 0; + + if (props != null) { + if (props.size()==0) { + json = "{ \"name\": \"" + noResultsMsgStr + "\" }"; + } else { + for (DataProperty prop: props) { + if ( counter > 0 ) { + json += ", "; + } + + String nameStr = prop.getPublicName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName(); + try { + json += "{ \"name\": \"" + nameStr + "\", "; + } catch (Exception e) { + json += "{ \"name\": \"" + nameStr + "\", "; + } + + json += "\"data\": { \"internalName\": \"" + prop.getLocalNameWithPrefix() + "\", "; + +/* VClass vc = null; + String domainStr=""; + if (prop.getDomainClassURI() != null) { + vc = vcDao.getVClassByURI(prop.getDomainClassURI()); + if (vc != null) { + try { + domainStr=""+vc.getName()+""; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + } +*/ + VClass vc = (prop.getDomainClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainClassURI()) : null; + String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; + json += "\"domainVClass\": \"" + domainStr + "\", " ; + + Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI()); + String rangeDatatypeStr = (rangeDatatype==null)?prop.getRangeDatatypeURI():rangeDatatype.getName(); + json += "\"rangeVClass\": \"" + rangeDatatypeStr + "\", " ; + + if (prop.getGroupURI() != null) { + PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI()); + json += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" } } " ; + } else { + json += "\"group\": \"unspecified\" } }" ; + } + 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/ListPropertyWebappsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java new file mode 100644 index 000000000..4e13eb87d --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java @@ -0,0 +1,190 @@ +/* $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.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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.ObjectProperty; +import edu.cornell.mannlib.vitro.webapp.beans.Ontology; +import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; +import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.Controllers; +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.ObjectPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; + +public class ListPropertyWebappsController extends FreemarkerHttpServlet { + private static Log log = LogFactory.getLog( ListPropertyWebappsController.class ); + + private static final String TEMPLATE_NAME = "siteAdmin-objectPropHierarchy.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 Object Properties"); + body.put("propertyType", "object"); + + String noResultsMsgStr = "No object properties found"; + + String ontologyUri = vreq.getParameter("ontologyUri"); + + ObjectPropertyDao dao = vreq.getFullWebappDaoFactory().getObjectPropertyDao(); + PropertyInstanceDao piDao = vreq.getFullWebappDaoFactory().getPropertyInstanceDao(); + VClassDao vcDao = vreq.getFullWebappDaoFactory().getVClassDao(); + PropertyGroupDao pgDao = vreq.getFullWebappDaoFactory().getPropertyGroupDao(); + + String vclassURI = vreq.getParameter("vclassUri"); + + List props = new ArrayList(); + if (vreq.getParameter("propsForClass") != null) { + noResultsMsgStr = "There are no object properties that apply to this class."; + + // incomplete list of classes to check, but better than before + List superclassURIs = vcDao.getAllSuperClassURIs(vclassURI); + superclassURIs.add(vclassURI); + superclassURIs.addAll(vcDao.getEquivalentClassURIs(vclassURI)); + + Map propInstMap = new HashMap(); + for (String classURI : superclassURIs) { + Collection propInsts = piDao.getAllPropInstByVClass(classURI); + for (PropertyInstance propInst : propInsts) { + propInstMap.put(propInst.getPropertyURI(), propInst); + } + } + List propInsts = new ArrayList(); + propInsts.addAll(propInstMap.values()); + Collections.sort(propInsts); + + Iterator propInstIt = propInsts.iterator(); + HashSet propURIs = new HashSet(); + while (propInstIt.hasNext()) { + PropertyInstance pi = (PropertyInstance) propInstIt.next(); + if (!(propURIs.contains(pi.getPropertyURI()))) { + propURIs.add(pi.getPropertyURI()); + ObjectProperty prop = (ObjectProperty) dao.getObjectPropertyByURI(pi.getPropertyURI()); + if (prop != null) { + props.add(prop); + } + } + } + } else { + props = (vreq.getParameter("iffRoot")!=null) + ? dao.getRootObjectProperties() + : dao.getAllObjectProperties(); + } + + OntologyDao oDao = vreq.getFullWebappDaoFactory().getOntologyDao(); + HashMap ontologyHash = new HashMap(); + + Iterator propIt = props.iterator(); + List scratch = new ArrayList(); + while (propIt.hasNext()) { + ObjectProperty p = (ObjectProperty) propIt.next(); + if (p.getNamespace()!=null) { + if( !ontologyHash.containsKey( p.getNamespace() )){ + Ontology o = (Ontology)oDao.getOntologyByURI(p.getNamespace()); + if (o==null) { + if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) { + log.debug("doGet(): no ontology object found for the namespace "+p.getNamespace()); + } + } else { + ontologyHash.put(p.getNamespace(), o.getName() == null ? p.getNamespace() : o.getName()); + } + } + if (ontologyUri != null && p.getNamespace().equals(ontologyUri)) { + scratch.add(p); + } + } + } + + if (ontologyUri != null) { + props = scratch; + } + + if (props != null) { + Collections.sort(props, new ShowObjectPropertyHierarchyController.ObjectPropertyAlphaComparator()); + } + + String json = new String(); + int counter = 0; + + if (props != null) { + if (props.size()==0) { + json = "{ \"name\": \"" + noResultsMsgStr + "\" }"; + } else { + Iterator propsIt = props.iterator(); + while (propsIt.hasNext()) { + if ( counter > 0 ) { + json += ", "; + } + ObjectProperty prop = (ObjectProperty) propsIt.next(); + + String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop); + try { + json += "{ \"name\": \"" + + propNameStr + "\", "; + } catch (Exception e) { + json += "{ \"name\": \"" + propNameStr + "\", "; + } + + json += "\"data\": { \"internalName\": \"" + prop.getLocalNameWithPrefix() + "\", "; + + VClass vc = (prop.getDomainVClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainVClassURI()) : null; + String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; + json += "\"domainVClass\": \"" + domainStr + "\", " ; + + vc = (prop.getRangeVClassURI() != null) ? vcDao.getVClassByURI(prop.getRangeVClassURI()) : null; + String rangeStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; + json += "\"rangeVClass\": \"" + rangeStr + "\", " ; + + if (prop.getGroupURI() != null) { + PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI()); + json += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" } } " ; + } else { + json += "\"group\": \"unspecified\" } }" ; + } + 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 index f91adbb07..40cac772c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java @@ -11,7 +11,6 @@ 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; @@ -30,7 +29,6 @@ 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; @@ -47,8 +45,6 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet { private VClassDao vcDao = null; private int previous_posn = 0; - private int childCount = 0; - private int uriCounter = 0; @Override protected Actions requiredActions(VitroRequest vreq) { @@ -116,7 +112,7 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet { while (rootIt.hasNext()) { VClass root = (VClass) rootIt.next(); if (root != null) { - json += addChildren(vreq.getFullWebappDaoFactory(), root, 0, ontologyUri,counter,"parent"); + json += addChildren(vreq.getFullWebappDaoFactory(), root, 0, ontologyUri,counter); counter += 1; } } @@ -134,7 +130,7 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet { return new TemplateResponseValues(TEMPLATE_NAME, body); } - private String addChildren(WebappDaoFactory wadf, VClass parent, int position, String ontologyUri, int counter, String status) { + private String addChildren(WebappDaoFactory wadf, VClass parent, int position, String ontologyUri, int counter) { 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(); @@ -157,7 +153,7 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet { Iterator childClassIt = childClasses.iterator(); while (childClassIt.hasNext()) { VClass child = (VClass) childClassIt.next(); - leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter, "child"); + leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter); if (!childClassIt.hasNext()) { if ( ontologyUri == null ) { leaves += " }] "; @@ -166,15 +162,12 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet { // 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 += "}]"; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java new file mode 100644 index 000000000..6cb6b42e6 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java @@ -0,0 +1,251 @@ +/* $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.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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.DataProperty; +import edu.cornell.mannlib.vitro.webapp.beans.Datatype; +import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.Controllers; +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.DataPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; + +public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet { + + private static final Log log = LogFactory.getLog(ShowDataPropertyHierarchyController.class.getName()); + + private static final String TEMPLATE_NAME = "siteAdmin-objectPropHierarchy.ftl"; + private int MAXDEPTH = 5; + + private DataPropertyDao dpDao = null; + private VClassDao vcDao = null; + private PropertyGroupDao pgDao = null; + private DatatypeDao dDao = null; + + private int previous_posn = 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 = "hierarchy"; + } + body.put("displayOption", displayOption); + + if ( displayOption.equals("all") ) { + body.put("pageTitle", "All Data Properties"); + } + else { + body.put("pageTitle", "Data Property Hierarchy"); + } + + body.put("propertyType", "data"); + + dpDao = vreq.getAssertionsWebappDaoFactory().getDataPropertyDao(); + vcDao = vreq.getAssertionsWebappDaoFactory().getVClassDao(); + pgDao = vreq.getAssertionsWebappDaoFactory().getPropertyGroupDao(); + dDao = vreq.getAssertionsWebappDaoFactory().getDatatypeDao(); + + String json = new String(); + + String ontologyUri = vreq.getParameter("ontologyUri"); + String startPropertyUri = vreq.getParameter("propertyUri"); + + List roots = null; + + if (startPropertyUri != null) { + roots = new LinkedList(); + roots.add(dpDao.getDataPropertyByURI(startPropertyUri)); + } else { + roots = dpDao.getRootDataProperties(); + if (roots!=null){ + Collections.sort(roots); + } + } + + int counter = 0; + + if (roots!=null) { + Iterator rootIt = roots.iterator(); + if (!rootIt.hasNext()) { + DataProperty dp = new DataProperty(); + dp.setURI(ontologyUri+"fake"); + String notFoundMessage = "No data properties found."; + dp.setName(notFoundMessage); + dp.setName(notFoundMessage); + json += addDataPropertyDataToResultsList(dp, 0, ontologyUri, counter); + } else { + while (rootIt.hasNext()) { + DataProperty root = rootIt.next(); + if ( (ontologyUri==null) || ( (ontologyUri!=null) && (root.getNamespace()!=null) && (ontologyUri.equals(root.getNamespace())) ) ) { + json += addChildren(root, 0, ontologyUri, counter); + 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(DataProperty parent, int position, String ontologyUri, int counter) { + if (parent == null) { + return ""; + } + String details = addDataPropertyDataToResultsList(parent, position, ontologyUri, counter); + int length = details.length(); + String leaves = ""; + leaves += details; + List childURIstrs = dpDao.getSubPropertyURIs(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("] ") ) { + leaves += "}]"; + } + else if ( ending.equals(" [") ){ + leaves += "] "; + } + else { + leaves += "}]"; + } + } + } + } + } + else { + if ( ontologyUri == null ) { + leaves += "] "; + } + else if ( ontologyUri != null && length > 0 ) { + leaves += "] "; + } + } + return leaves; + } + + private String addDataPropertyDataToResultsList(DataProperty dp, int position, String ontologyUri, int counter) { + String tempString = ""; + if (dp == null) { + return tempString; + } + if (ontologyUri == null || ( (dp.getNamespace()!=null) && (dp.getNamespace().equals(ontologyUri)) ) ) { + 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\": "; + } + + String nameStr = dp.getPublicName()==null ? dp.getName()==null ? dp.getURI()==null ? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName(); + try { + tempString += "\"" + nameStr + "\", "; + } catch (Exception e) { + tempString += "\"" + nameStr + "\", "; + log.error("Unsupported: URLEncoder.encode() with UTF-8"); + } + + tempString += "\"data\": { \"internalName\": \"" + dp.getLocalNameWithPrefix() + "\", "; + + VClass tmp = null; + try { + tempString += "\"domainVClass\": \"" + (((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(dp.getDomainClassURI()).getLocalNameWithPrefix()) + "\", " ; + } catch (NullPointerException e) { + tempString += "\"domainVClass\": \"\","; + } + try { + Datatype rangeDatatype = dDao.getDatatypeByURI(dp.getRangeDatatypeURI()); + String rangeDatatypeStr = (rangeDatatype==null)?dp.getRangeDatatypeURI():rangeDatatype.getName(); + tempString += "\"rangeVClass\": \"" + ((rangeDatatypeStr != null) ? rangeDatatypeStr : "") + "\", " ; + } catch (NullPointerException e) { + tempString += "\"rangeVClass\": \"\","; + } + if (dp.getGroupURI() != null) { + PropertyGroup pGroup = pgDao.getGroupByURI(dp.getGroupURI()); + tempString += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" " ; + } else { + tempString += "\"group\": \"unspecified\""; + } + tempString += "}, \"children\": ["; + + previous_posn = position; + } + return tempString; + } + + private class DataPropertyAlphaComparator implements Comparator { + public int compare(Object o1, Object o2) { + return Collator.getInstance().compare( ((DataProperty)o1).getName(), ((DataProperty)o2).getName()); + } + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java new file mode 100644 index 000000000..659ddb97c --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java @@ -0,0 +1,275 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.freemarker; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +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.ObjectProperty; +import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.Controllers; +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.ObjectPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; + +public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet { + + private static final Log log = LogFactory.getLog(ShowObjectPropertyHierarchyController.class.getName()); + + private static final String TEMPLATE_NAME = "siteAdmin-objectPropHierarchy.ftl"; + + private int MAXDEPTH = 5; + + private ObjectPropertyDao opDao = null; + private VClassDao vcDao = null; + private PropertyGroupDao pgDao = null; + + private int previous_posn = 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 = "hierarchy"; + } + body.put("displayOption", displayOption); + + if ( displayOption.equals("all") ) { + body.put("pageTitle", "All Object Properties"); + } + else { + body.put("pageTitle", "Object Property Hierarchy"); + } + + body.put("propertyType", "object"); + + opDao = vreq.getAssertionsWebappDaoFactory().getObjectPropertyDao(); + vcDao = vreq.getAssertionsWebappDaoFactory().getVClassDao(); + pgDao = vreq.getAssertionsWebappDaoFactory().getPropertyGroupDao(); + + String json = new String(); + + String ontologyUri = vreq.getParameter("ontologyUri"); + String startPropertyUri = vreq.getParameter("propertyUri"); + + List roots = null; + + if (startPropertyUri != null) { + roots = new LinkedList(); + ObjectProperty op = opDao.getObjectPropertyByURI(startPropertyUri); + if (op == null) { + op = new ObjectProperty(); + op.setURI(startPropertyUri); + } + roots.add(op); + } else { + roots = opDao.getRootObjectProperties(); + if (roots!=null){ + Collections.sort(roots, new ObjectPropertyAlphaComparator()); // sorts by domain public + } + } + + int counter = 0; + + if (roots != null) { + Iterator rootIt = roots.iterator(); + if (!rootIt.hasNext()) { + ObjectProperty op = new ObjectProperty(); + op.setURI(ontologyUri+"fake"); + String notFoundMessage = "No object properties found."; + op.setDomainPublic(notFoundMessage); + json += addObjectPropertyDataToResultsList(op, 0, ontologyUri, counter); + } else { + while (rootIt.hasNext()) { + ObjectProperty root = rootIt.next(); + if ( (ontologyUri==null) || + ( (ontologyUri != null) + && (root.getNamespace() != null) + && (ontologyUri.equals(root.getNamespace())) ) ) { + json += addChildren(root, 0, ontologyUri, counter); + 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(ObjectProperty parent, int position, String ontologyUri, int counter) { + String details = addObjectPropertyDataToResultsList(parent, position, ontologyUri, counter); + int length = details.length(); + String leaves = ""; + leaves += details; + List childURIstrs = opDao.getSubPropertyURIs(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("] ") ) { + leaves += "}]"; + } + else if ( ending.equals(" [") ){ + leaves += "] "; + } + else { + leaves += "}]"; + } + } + } + } + } + else { + if ( ontologyUri == null ) { + leaves += "] "; + } + else if ( ontologyUri != null && length > 0 ) { + leaves += "] "; + } + } + return leaves; + } + + private String addObjectPropertyDataToResultsList(ObjectProperty op, int position, String ontologyUri, int counter) { + String tempString = ""; + if (ontologyUri == null || ( (op.getNamespace()!=null) && (op.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 += "\"" + getDisplayLabel(op)+"\", "; + } catch (UnsupportedEncodingException uee) { + tempString += "\"" + getDisplayLabel(op) + "\""; + log.error("Unsupported: URLEncoder.encode() with UTF-8"); + } + + tempString += "\"data\": { \"internalName\": \"" + op.getLocalNameWithPrefix() + "\", "; + + VClass tmp = null; + + try { + tempString += "\"domainVClass\": \"" + (((tmp = vcDao.getVClassByURI(op.getDomainVClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(op.getDomainVClassURI()).getLocalNameWithPrefix()) + "\", " ; + } catch (NullPointerException e) { + tempString += "\"domainVClass\": \"\","; + } + try { + tempString += "\"rangeVClass\": \"" + (((tmp = vcDao.getVClassByURI(op.getRangeVClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(op.getRangeVClassURI()).getLocalNameWithPrefix()) + "\", " ; + } catch (NullPointerException e) { + tempString += "\"rangeVClass\": \"\","; + } + if (op.getGroupURI() != null) { + PropertyGroup pGroup = pgDao.getGroupByURI(op.getGroupURI()); + tempString += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" " ; + } else { + tempString += "\"group\": \"unspecified\""; + } + tempString += "}, \"children\": ["; + + previous_posn = position; + } + return tempString; + } + + public static class ObjectPropertyAlphaComparator implements Comparator { + public int compare(ObjectProperty op1, ObjectProperty op2) { + if (op1 == null) { + return 1; + } else if (op2 == null) { + return -1; + } + String propLabel1 = getDisplayLabel(op1); + String propLabel2 = getDisplayLabel(op2); + if (propLabel1 == null) { + return 1; + } else if (propLabel2 == null) { + return -1; + } else { + return Collator.getInstance().compare( propLabel1, propLabel2 ); + } + } + } + + /* + * should never be null + */ + public static String getDisplayLabel(ObjectProperty op) { + String domainPublic = op.getDomainPublic(); + String displayLabel = (domainPublic != null && domainPublic.length() > 0) + ? domainPublic + : op.getLocalName(); + return (displayLabel != null) ? displayLabel : "[object property]" ; + } + +} \ No newline at end of file diff --git a/webapp/web/WEB-INF/web.xml b/webapp/web/WEB-INF/web.xml index 0287959bd..ec690c2ab 100644 --- a/webapp/web/WEB-INF/web.xml +++ b/webapp/web/WEB-INF/web.xml @@ -786,38 +786,38 @@ - ObjectPropertyHierarchyListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.ObjectPropertyHierarchyListingController + ShowObjectPropertyHierarchyController + edu.cornell.mannlib.vitro.webapp.controller.freemarker.ShowObjectPropertyHierarchyController - ObjectPropertyHierarchyListingController + ShowObjectPropertyHierarchyController /showObjectPropertyHierarchy - DataPropertyHierarchyListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.DataPropertyHierarchyListingController + ShowDataPropertyHierarchyController + edu.cornell.mannlib.vitro.webapp.controller.freemarker.ShowDataPropertyHierarchyController - DataPropertyHierarchyListingController + ShowDataPropertyHierarchyController /showDataPropertyHierarchy - PropertyWebappsListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.PropertyWebappsListingController + ListPropertyWebappsController + edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListPropertyWebappsController - PropertyWebappsListingController + ListPropertyWebappsController /listPropertyWebapps - DatatypePropertiesListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.DatatypePropertiesListingController + ListDatatypePropertiesController + edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListDatatypePropertiesController - DatatypePropertiesListingController + ListDatatypePropertiesController /listDatatypeProperties diff --git a/webapp/web/css/classHierarchy.css b/webapp/web/css/classHierarchy.css index f1f92b5bb..618c4d28d 100644 --- a/webapp/web/css/classHierarchy.css +++ b/webapp/web/css/classHierarchy.css @@ -65,6 +65,11 @@ span#expandAll { float: right; font-size: 0.85em; } +span.rangeClass { + color:#064D68; + padding-left:22px; + padding-right:8px; +} div#expandLink { margin-top:-10px; width:100%; diff --git a/webapp/web/js/siteAdmin/classHierarchyUtils.js b/webapp/web/js/siteAdmin/classHierarchyUtils.js index 1243db477..55d8ca7fc 100644 --- a/webapp/web/js/siteAdmin/classHierarchyUtils.js +++ b/webapp/web/js/siteAdmin/classHierarchyUtils.js @@ -32,6 +32,7 @@ this.form = $('form#classHierarchyForm'); this.select = $('select#displayOption'); this.addClass = $('input#addClass'); + this.addGroup = $('input#addGroup'); }, bindEventListeners: function() { @@ -49,6 +50,10 @@ classHierarchyUtils.form.attr("action", "vclass_retry"); classHierarchyUtils.form.submit(); }); + this.addGroup.click(function() { + classHierarchyUtils.form.attr("action", "editForm?controller=Classgroup"); + classHierarchyUtils.form.submit(); + }); }, buildClassHierarchyHtml: function() { @@ -148,13 +153,13 @@ $clickableHeader.click(function() { if ( $clickableHeader.attr('view') == "less" ) { $clickableHeader.addClass("headerSpanMinus"); - $('table#classHierarchy' + ctr).find('span').addClass("subclassExpandMinus"); + $('table#classHierarchy' + ctr).find('span.subclassExpandPlus').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('span.subclassExpandPlus').removeClass("subclassExpandMinus"); $('table#classHierarchy' + ctr).find('table.subclassTable').hide(); $clickableHeader.attr('view', 'less' ); } @@ -187,14 +192,14 @@ if ( classHierarchyUtils.expandAll.text() == "expand all" ) { classHierarchyUtils.expandAll.text("collapse all"); $('span.headerSpanPlus').addClass("headerSpanMinus"); - $('table.classHierarchy').find('span').addClass("subclassExpandMinus"); + $('table.classHierarchy').find('span.subclassExpandPlus').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('span.subclassExpandPlus').removeClass("subclassExpandMinus"); $('table.classHierarchy').find('table.subclassTable').hide(); $('section#container').find('span.headerSpanPlus').attr('view','less'); } diff --git a/webapp/web/js/siteAdmin/objectPropertyHierarchyUtils.js b/webapp/web/js/siteAdmin/objectPropertyHierarchyUtils.js new file mode 100644 index 000000000..de0b96db8 --- /dev/null +++ b/webapp/web/js/siteAdmin/objectPropertyHierarchyUtils.js @@ -0,0 +1,293 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + + var objectPropHierarchyUtils = { + onLoad: function(urlBase,displayOption,type) { + this.imagePath = urlBase + "/images/"; + this.propType = type; + this.initObjects(); + this.expandAll.hide(); + this.checkJsonTree(); + + if ( noProps ) { + this.buildNoPropsHtml(); + } + else if ( displayOption == "all" ) { + this.buildAllPropsHtml(); + } + else { + this.buildPropertyHierarchyHtml(); + this.wireExpandLink(); + } + + if ( displayOption == "hierarchy" ) { + 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.addProperty = $('input#addProperty'); + noProps = new Boolean; + }, + + bindEventListeners: function() { + if ( this.propType == "object" ) { + this.select.change(function() { + if ( objectPropHierarchyUtils.select.val() == "all") { + objectPropHierarchyUtils.form.attr("action", "listPropertyWebapps"); + } + else { + objectPropHierarchyUtils.form.attr("action", "showObjectPropertyHierarchy"); + } + objectPropHierarchyUtils.form.submit(); + }); + + this.addProperty.click(function() { + objectPropHierarchyUtils.form.attr("action", "editForm?controller=Property"); + objectPropHierarchyUtils.form.submit(); + }); + } + else { + this.select.change(function() { + if ( objectPropHierarchyUtils.select.val() == "all") { + objectPropHierarchyUtils.form.attr("action", "listDatatypeProperties"); + } + else { + objectPropHierarchyUtils.form.attr("action", "showDataPropertyHierarchy"); + } + objectPropHierarchyUtils.form.submit(); + }); + + this.addProperty.click(function() { + objectPropHierarchyUtils.form.attr("action", "editForm?controller=Dataprop"); + objectPropHierarchyUtils.form.submit(); + }); + } + }, + + checkJsonTree: function() { + if ( json.length == 1 ) { + $.each(json, function() { + // check to see whether we have a 'no properties' message or an actual json tree + if ( this.name.indexOf("properties") != -1 && this.data == undefined ) { + noProps = true; + } + else { + noProps = false; + } + }); + } + else { + noProps = false; + } + }, + + buildPropertyHierarchyHtml: function() { + + $.each(json, function() { + $newClassSection = jQuery("
", { + id: "classContainer" + objectPropHierarchyUtils.classCounter + }); + var descendants = ""; + var headerSpan = ""; + + if ( this.children.length ) { + descendants = objectPropHierarchyUtils.getTheChildren(this); + headerSpan = " "; + } + + objectPropHierarchyUtils.classHtml += "
" + this.name + headerSpan + "
" + "" ; + + objectPropHierarchyUtils.classHtml += ""; + + objectPropHierarchyUtils.classHtml += ""; + + objectPropHierarchyUtils.classHtml += ""; + + + objectPropHierarchyUtils.classHtml += descendants; + + objectPropHierarchyUtils.classHtml += "
Local Name:" + + (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "
Group:" + + (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "
Domain Class:" + + (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " "; + + objectPropHierarchyUtils.classHtml += "Range Class:" + + (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "
"; + // alert(objectPropHierarchyUtils.classHtml); + $newClassSection.html(objectPropHierarchyUtils.classHtml); + $newClassSection.appendTo($('section#container')); + objectPropHierarchyUtils.makeHeaderSpansClickable(objectPropHierarchyUtils.classCounter); + objectPropHierarchyUtils.makeSubpropertySpansClickable(); + objectPropHierarchyUtils.clickableSpans = [] ; + objectPropHierarchyUtils.classHtml = ""; + objectPropHierarchyUtils.classCounter += 1; + }); + }, + + getTheChildren: function(node) { + var childDetails = ""; + var subclassString = " "; + var ctr = 0 + $.each(node.children, function() { + if ( ctr == 0 ) { + childDetails += "Subproperties:"; + ctr = ctr + 1; + } + else { + childDetails += "" ; + } + + if ( this.children.length == 1 ) { + subclassString += " (1 subclass)"; + } + else if ( this.children.length > 1 ) { + subclassString += " (" + this.children.length + " subclasses)"; + } + + childDetails += " " + + this.name + subclassString + ""; + + subclassString = " "; + + objectPropHierarchyUtils.clickableSpans.push('subclassExpand' + objectPropHierarchyUtils.expandCounter); + + objectPropHierarchyUtils.expandCounter += 1; + + childDetails += ""; + + childDetails += ""; + + childDetails += ""; + + if ( this.children ) { + var grandChildren = objectPropHierarchyUtils.getTheChildren(this); + childDetails += grandChildren; + } + }); + childDetails += "
Local Name:" + + (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "
Group:" + + (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "
Domain Class:" + + (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " "; + + childDetails += "Range Class:" + + (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "
"; + 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.subclassExpandPlus').addClass("subclassExpandMinus"); + $('table#classHierarchy' + ctr).find('table.subclassTable').show(); + $clickableHeader.attr('view', 'more' ); + } + else { + $clickableHeader.removeClass("headerSpanMinus"); + $('table#classHierarchy' + ctr).find('span.subclassExpandPlus').removeClass("subclassExpandMinus"); + $('table#classHierarchy' + ctr).find('table.subclassTable').hide(); + $clickableHeader.attr('view', 'less' ); + } + }); + },// $('myOjbect').css('background-image', 'url(' + imageUrl + ')'); + + makeSubpropertySpansClickable: function() { + $.each(objectPropHierarchyUtils.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 ( objectPropHierarchyUtils.expandAll.text() == "expand all" ) { + objectPropHierarchyUtils.expandAll.text("collapse all"); + $('span.headerSpanPlus').addClass("headerSpanMinus"); + $('table.classHierarchy').find('span.subclassExpandPlus').addClass("subclassExpandMinus"); + $('table.classHierarchy').find('table.subclassTable').show(); + $('section#container').find('span.headerSpanPlus').attr('view','more'); + } + else { + objectPropHierarchyUtils.expandAll.text("expand all"); + $('span.headerSpanPlus').removeClass("headerSpanMinus"); + $('table.classHierarchy').find('span.subclassExpandPlus').removeClass("subclassExpandMinus"); + $('table.classHierarchy').find('table.subclassTable').hide(); + $('section#container').find('span.headerSpanPlus').attr('view','less'); + } + }); + }, + + buildAllPropsHtml: function() { + + $.each(json, function() { + $newClassSection = jQuery("
", { + id: "classContainer" + objectPropHierarchyUtils.classCounter + }); + + objectPropHierarchyUtils.classHtml += "
" + this.name + "
" + "" ; + + objectPropHierarchyUtils.classHtml += ""; + + objectPropHierarchyUtils.classHtml += ""; + + objectPropHierarchyUtils.classHtml += ""; + + objectPropHierarchyUtils.classHtml += "
Local Name:" + + (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "
Group:" + + (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "
Domain Class:" + + (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " "; + + objectPropHierarchyUtils.classHtml += "Range Class:" + + (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "
"; + + $newClassSection.html(objectPropHierarchyUtils.classHtml); + $newClassSection.appendTo($('section#container')); + objectPropHierarchyUtils.classHtml = ""; + objectPropHierarchyUtils.classCounter += 1; + }); + }, + + buildNoPropsHtml: function() { + + $.each(json, function() { + $newClassSection = jQuery("
", { + id: "classContainer" + objectPropHierarchyUtils.classCounter + }); + + objectPropHierarchyUtils.classHtml = "

" + this.name + "

"; + $newClassSection.html(objectPropHierarchyUtils.classHtml); + $newClassSection.appendTo($('section#container')); + objectPropHierarchyUtils.classHtml = ""; + }); + } +} diff --git a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl index b26e373cc..1c0af45a3 100644 --- a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl +++ b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-classHierarchy.ftl @@ -16,14 +16,10 @@ + <#if displayOption == "group"> + + - <#if displayOption == "group">
-
- - -
-
-
diff --git a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-objectPropHierarchy.ftl b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-objectPropHierarchy.ftl new file mode 100644 index 000000000..6b838a5dc --- /dev/null +++ b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-objectPropHierarchy.ftl @@ -0,0 +1,49 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- + Used to display both the object and data property hierarchies, though there are + separate controllers for those. Also used to display lists of "all" object and + data properties, though there are separate controllers for those, too. + --> + + +
+ +

${pageTitle!}

+ + <#if !displayOption?has_content> + <#assign displayOption = "hierarchy"> + + +
Object<#else>DataPropertyHierarchy" method="post" role="classHierarchy"> + + + object<#else>data property"/> +
+ + + +
+
+ +
+ + + + + + +${stylesheets.add('')} + +${scripts.add('', + '')} +