From e2c48e65f966b182a3ce2ede783b06dda0593317 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Tue, 8 Oct 2013 14:33:38 -0400 Subject: [PATCH] VIVO-303 picklist sorting --- .../cornell/mannlib/vedit/util/FormUtils.java | 22 +------------- .../edit/Classes2ClassesRetryController.java | 4 +-- .../edit/DatapropEditController.java | 5 +++- .../Properties2PropertiesRetryController.java | 2 +- .../edit/PropertyEditController.java | 30 +++++-------------- .../edit/RefactorRetryController.java | 4 +-- .../ClassHierarchyListingController.java | 4 +-- ...ataPropertyHierarchyListingController.java | 6 ++-- .../DatatypePropertiesListingController.java | 4 +-- ...ectPropertyHierarchyListingController.java | 6 ++-- ...ectPropertyStatementListingController.java | 2 +- .../PropertyWebappsListingController.java | 6 ++-- .../VClassWebappsListingController.java | 4 +-- .../jena/RestrictionsListingController.java | 2 +- .../ListDatatypePropertiesController.java | 8 ++--- .../ListPropertyWebappsController.java | 4 +-- .../ListVClassWebappsController.java | 6 ++-- .../ShowClassHierarchyController.java | 18 ++++++----- .../ShowDataPropertyHierarchyController.java | 19 ++++++------ ...ShowObjectPropertyHierarchyController.java | 18 +++++------ .../webapp/dao/jena/DataPropertyDaoJena.java | 2 +- .../dao/jena/ObjectPropertyDaoJena.java | 3 +- .../webapp/dao/jena/WebappDaoFactoryJena.java | 8 +++-- .../templates/edit/specific/classes_edit.jsp | 18 +++++------ .../edit/specific/dataprops_edit.jsp | 6 ++-- .../templates/edit/specific/props_edit.jsp | 6 ++-- 26 files changed, 94 insertions(+), 123 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java b/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java index 5c65da7c0..c28ebf2a6 100644 --- a/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java +++ b/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java @@ -239,27 +239,7 @@ public class FormUtils { for (VClass vclass : wadf.getVClassDao().getAllVclasses()) { Option option = new Option(); option.setValue(vclass.getURI()); - if ( (selectedVClassURI != null) - && (vclass.getURI() != null) - && (selectedVClassURI.equals(vclass.getURI())) ) { - option.setSelected(true); - } - String ontologyPrefix = null; - if (vclass.getNamespace() != null) { - Ontology ont = wadf.getOntologyDao().getOntologyByURI( - vclass.getNamespace()); - if ( (ont != null) && (ont.getPrefix() != null) ) { - ontologyPrefix = ont.getPrefix(); - } - } - StringBuffer classNameBuffer = new StringBuffer(); - if (ontologyPrefix != null) { - classNameBuffer.append(ontologyPrefix).append(":"); - } - if (vclass.getName() != null) { - classNameBuffer.append(vclass.getName()); - } - option.setBody(classNameBuffer.toString()); + option.setBody(vclass.getPickListName()); vclassOptionList.add(option); } return vclassOptionList; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesRetryController.java index f724e82b1..94318919a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesRetryController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesRetryController.java @@ -60,8 +60,8 @@ public class Classes2ClassesRetryController extends BaseEditController { populateBeanFromParams(objectForEditing, request); HashMap hash = new HashMap(); - hash.put("SuperclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","LocalNameWithPrefix",objectForEditing.getSuperclassURI(),null)); - hash.put("SubclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","LocalNameWithPrefix",objectForEditing.getSubclassURI(),null)); + hash.put("SuperclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","PickListName",objectForEditing.getSuperclassURI(),null)); + hash.put("SubclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","PickListName",objectForEditing.getSubclassURI(),null)); FormObject foo = new FormObject(); foo.setOptionLists(hash); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java index 301611599..732b62be8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java @@ -24,6 +24,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.Ontology; 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.dao.DataPropertyDao; @@ -101,7 +102,9 @@ public class DatapropEditController extends BaseEditController { // TODO - need unionOf/intersectionOf-style domains for domain class String domainStr=""; try { - domainStr = (dp.getDomainClassURI() == null) ? "" : ""+dp.getDomainClassURI()+""; + VClass domainClass = getWebappDaoFactory().getVClassDao().getVClassByURI(dp.getDomainClassURI()); + String domainLinkAnchor = (domainClass != null) ? domainClass.getPickListName() : dp.getDomainClassURI(); + domainStr = (dp.getDomainClassURI() == null) ? "" : ""+domainLinkAnchor+""; } catch (UnsupportedEncodingException e) { log.error(e, e); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesRetryController.java index 1700983ae..6d1633ad8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesRetryController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesRetryController.java @@ -59,7 +59,7 @@ public class Properties2PropertiesRetryController extends BaseEditController { ? dpDao.getAllDataProperties() : opDao.getAllObjectProperties(); - Collections.sort(propList); + sortForPickList(propList, request); String superpropertyURIstr = request.getParameter("SuperpropertyURI"); String subpropertyURIstr = request.getParameter("SubpropertyURI"); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java index 106564297..accb66cb7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java @@ -86,7 +86,7 @@ public class PropertyEditController extends BaseEditController { ObjectProperty parent = propDao.getObjectPropertyByURI(p.getParentURI()); if (parent != null && parent.getURI() != null) { try { - parentPropertyStr = ""+parent.getLocalNameWithPrefix()+""; + parentPropertyStr = ""+parent.getPickListName()+""; } catch (UnsupportedEncodingException e) { log.error(e, e); } @@ -121,12 +121,12 @@ public class PropertyEditController extends BaseEditController { String domainStr = ""; if (p.getDomainVClassURI() != null) { VClass domainClass = vcDao.getVClassByURI(p.getDomainVClassURI()); - if (domainClass != null && domainClass.getURI() != null && domainClass.getLocalNameWithPrefix() != null) { + if (domainClass != null && domainClass.getURI() != null && domainClass.getPickListName() != null) { try { if (domainClass.isAnonymous()) { - domainStr = domainClass.getLocalNameWithPrefix(); + domainStr = domainClass.getPickListName(); } else { - domainStr = ""+domainClass.getLocalNameWithPrefix()+""; + domainStr = ""+domainClass.getPickListName()+""; } } catch (UnsupportedEncodingException e) { log.error(e, e); @@ -138,12 +138,12 @@ public class PropertyEditController extends BaseEditController { String rangeStr = ""; if (p.getRangeVClassURI() != null) { VClass rangeClass = vcDao.getVClassByURI(p.getRangeVClassURI()); - if (rangeClass != null && rangeClass.getURI() != null && rangeClass.getLocalNameWithPrefix() != null) { + if (rangeClass != null && rangeClass.getURI() != null && rangeClass.getPickListName() != null) { try { if (rangeClass.isAnonymous()) { - rangeStr = rangeClass.getLocalNameWithPrefix(); + rangeStr = rangeClass.getPickListName(); } else { - rangeStr = ""+rangeClass.getLocalNameWithPrefix()+""; + rangeStr = ""+rangeClass.getPickListName()+""; } } catch (UnsupportedEncodingException e) { log.error(e, e); @@ -175,22 +175,6 @@ public class PropertyEditController extends BaseEditController { results.add(p.getSelectFromExisting() ? "true" : "false"); // column 21 results.add(p.getOfferCreateNewOption() ? "true" : "false"); // column 22 - /* - String datapropStr = ""; - if (p.getObjectIndividualSortPropertyURI() != null) { - DataProperty dProp = dpDao.getDataPropertyByURI(p.getObjectIndividualSortPropertyURI()); - if (dProp != null && dProp.getURI() != null && dProp.getLocalNameWithPrefix() != null) { - try { - datapropStr = ""+dProp.getLocalNameWithPrefix()+""; - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - results.add(datapropStr); // column 16 - } else { - results.add("name (rdfs:label)"); // column 16 - } - */ results.add(p.getDomainEntitySortDirection() == null ? "ascending" : p.getDomainEntitySortDirection()); // column 23 results.add(p.getURI()); // column 24 diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java index e4859f349..7aaefe2b7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java @@ -54,7 +54,7 @@ public class RefactorRetryController extends BaseEditController { epo.setFormObject(foo); HashMap> optMap = new HashMap>(); foo.setOptionLists(optMap); - List