Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop

This commit is contained in:
hudajkhan 2013-10-09 12:52:26 -04:00
commit 781c5105f1
56 changed files with 388 additions and 504 deletions

View file

@ -2,13 +2,19 @@
package edu.cornell.mannlib.vedit.controller; package edu.cornell.mannlib.vedit.controller;
import java.text.Collator;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
@ -21,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vedit.beans.EditProcessObject; import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vedit.util.FormUtils; import edu.cornell.mannlib.vedit.util.FormUtils;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
@ -155,6 +162,41 @@ public class BaseEditController extends VitroHttpServlet {
} }
} }
public List<Option> getSortedList(HashMap<String,Option> hashMap, List<Option> optionList, VitroRequest vreq){
class ListComparator implements Comparator<String>{
Collator collator;
public ListComparator(Collator collator) {
this.collator = collator;
}
@Override
public int compare(String str1, String str2) {
return collator.compare(str1, str2);
}
}
List<String> bodyVal = new ArrayList<String>();
List<Option> options = new ArrayList<Option>();
Iterator<Option> itr = optionList.iterator();
while(itr.hasNext()){
Option option = itr.next();
hashMap.put(option.getBody(),option);
bodyVal.add(option.getBody());
}
Collections.sort(bodyVal, new ListComparator(vreq.getCollator()));
ListIterator<String> itrStr = bodyVal.listIterator();
while(itrStr.hasNext()){
options.add(hashMap.get(itrStr.next()));
}
return options;
}
protected WebappDaoFactory getWebappDaoFactory() { protected WebappDaoFactory getWebappDaoFactory() {
return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory(); return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory();
} }

View file

@ -239,27 +239,7 @@ public class FormUtils {
for (VClass vclass : wadf.getVClassDao().getAllVclasses()) { for (VClass vclass : wadf.getVClassDao().getAllVclasses()) {
Option option = new Option(); Option option = new Option();
option.setValue(vclass.getURI()); option.setValue(vclass.getURI());
if ( (selectedVClassURI != null) option.setBody(vclass.getPickListName());
&& (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());
vclassOptionList.add(option); vclassOptionList.add(option);
} }
return vclassOptionList; return vclassOptionList;

View file

@ -134,6 +134,10 @@ public class BaseResourceBean implements ResourceBean {
} }
} }
public String getLabel() {
return getLocalName();
}
public String getLocalName() { public String getLocalName() {
if( localName == null && this.URI != null) if( localName == null && this.URI != null)
buildLocalAndNS(this.URI); buildLocalAndNS(this.URI);

View file

@ -12,7 +12,7 @@ import java.util.LinkedList;
* @author bjl23 * @author bjl23
* *
*/ */
public class DataProperty extends Property implements Comparable<DataProperty> { public class DataProperty extends Property implements Comparable<DataProperty>, ResourceBean {
private String name = null; private String name = null;
private String publicName = null; private String publicName = null;
@ -63,6 +63,10 @@ public class DataProperty extends Property implements Comparable<DataProperty> {
this.publicName = publicName; this.publicName = publicName;
} }
public String getLabel() {
return getPublicName();
}
public String getDomainClassURI() { public String getDomainClassURI() {
return domainClassURI; return domainClassURI;
} }

View file

@ -22,7 +22,7 @@ import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
* a class representing an object property * a class representing an object property
* *
*/ */
public class ObjectProperty extends Property implements Comparable<ObjectProperty> public class ObjectProperty extends Property implements Comparable<ObjectProperty>, ResourceBean
{ {
private static final Log log = LogFactory.getLog(ObjectProperty.class.getName()); private static final Log log = LogFactory.getLog(ObjectProperty.class.getName());
@ -95,6 +95,10 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
this.domainEntityURI = domainEntityURI; this.domainEntityURI = domainEntityURI;
} }
public String getLabel() {
return getDomainPublic();
}
public String getDomainPublic() { public String getDomainPublic() {
return domainPublic; return domainPublic;
} }

View file

@ -7,7 +7,7 @@ import java.util.Comparator;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
public class Property extends BaseResourceBean { public class Property extends BaseResourceBean implements ResourceBean {
private static Log log = LogFactory.getLog( Property.class ); private static Log log = LogFactory.getLog( Property.class );

View file

@ -10,6 +10,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
* Time: 3:41:23 PM * Time: 3:41:23 PM
*/ */
public interface ResourceBean { public interface ResourceBean {
String getURI(); String getURI();
boolean isAnonymous(); boolean isAnonymous();
@ -24,28 +25,20 @@ public interface ResourceBean {
void setLocalName(String localName); void setLocalName(String localName);
String getLabel();
public RoleLevel getHiddenFromDisplayBelowRoleLevel() ; public RoleLevel getHiddenFromDisplayBelowRoleLevel() ;
public void setHiddenFromDisplayBelowRoleLevel(RoleLevel eR) ; public void setHiddenFromDisplayBelowRoleLevel(RoleLevel eR) ;
public void setHiddenFromDisplayBelowRoleLevelUsingRoleUri(String roleUri) ; public void setHiddenFromDisplayBelowRoleLevelUsingRoleUri(String roleUri) ;
/*
public RoleLevel getProhibitedFromCreateBelowRoleLevel() ;
public void setProhibitedFromCreateBelowRoleLevel(RoleLevel eR) ;
public void setProhibitedFromCreateBelowRoleLevelUsingRoleUri(String roleUri) ;
*/
public RoleLevel getProhibitedFromUpdateBelowRoleLevel() ; public RoleLevel getProhibitedFromUpdateBelowRoleLevel() ;
public void setProhibitedFromUpdateBelowRoleLevel(RoleLevel eR) ; public void setProhibitedFromUpdateBelowRoleLevel(RoleLevel eR) ;
public void setProhibitedFromUpdateBelowRoleLevelUsingRoleUri(String roleUri) ; public void setProhibitedFromUpdateBelowRoleLevelUsingRoleUri(String roleUri) ;
/*
public RoleLevel getProhibitedFromDeleteBelowRoleLevel() ;
public void setProhibitedFromDeleteBelowRoleLevel(RoleLevel eR) ; public String getPickListName();
public void setProhibitedFromDeleteBelowRoleLevelUsingRoleUri(String roleUri) ;
*/
} }

View file

@ -5,10 +5,13 @@ package edu.cornell.mannlib.vitro.webapp.controller;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.Collator;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -27,7 +30,9 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper; import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage; import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage;
import edu.cornell.mannlib.vitro.webapp.beans.ResourceBean;
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LogoutRedirector; import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LogoutRedirector;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.i18n.I18n; import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
@ -187,6 +192,25 @@ public class VitroHttpServlet extends HttpServlet {
+ "?afterLogin=" + encodedAfterLoginUrl; + "?afterLogin=" + encodedAfterLoginUrl;
} }
protected void sortForPickList(List<? extends ResourceBean> beans,
VitroRequest vreq) {
Collections.sort(beans, new PickListSorter(vreq));
}
protected class PickListSorter implements Comparator<ResourceBean> {
Collator collator;
public PickListSorter(VitroRequest vreq) {
this.collator = vreq.getCollator();
}
public int compare(ResourceBean b1, ResourceBean b2) {
return collator.compare(b1.getPickListName(), b2.getPickListName());
}
}
/** /**
* If logging on the subclass is set to the TRACE level, dump the HTTP * If logging on the subclass is set to the TRACE level, dump the HTTP
* headers on the request. * headers on the request.

View file

@ -3,6 +3,7 @@
package edu.cornell.mannlib.vitro.webapp.controller; package edu.cornell.mannlib.vitro.webapp.controller;
import java.text.Collator;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -215,6 +216,14 @@ public class VitroRequest extends HttpServletRequestWrapper {
return (OntModel) getAttribute("languageNeutralUnionFullModel"); return (OntModel) getAttribute("languageNeutralUnionFullModel");
} }
public void setCollator(Collator collator) {
setAttribute("collator", collator);
}
public Collator getCollator() {
return (Collator) getAttribute("collator");
}
public void setLanguageNeutralWebappDaoFactory(WebappDaoFactory wadf) { public void setLanguageNeutralWebappDaoFactory(WebappDaoFactory wadf) {
setAttribute("languageNeutralWebappDaoFactory", wadf); setAttribute("languageNeutralWebappDaoFactory", wadf);
} }

View file

@ -60,8 +60,8 @@ public class Classes2ClassesRetryController extends BaseEditController {
populateBeanFromParams(objectForEditing, request); populateBeanFromParams(objectForEditing, request);
HashMap hash = new HashMap(); HashMap hash = new HashMap();
hash.put("SuperclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","LocalNameWithPrefix",objectForEditing.getSuperclassURI(),null)); hash.put("SuperclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","PickListName",objectForEditing.getSuperclassURI(),null));
hash.put("SubclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","LocalNameWithPrefix",objectForEditing.getSubclassURI(),null)); hash.put("SubclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(),"URI","PickListName",objectForEditing.getSubclassURI(),null));
FormObject foo = new FormObject(); FormObject foo = new FormObject();
foo.setOptionLists(hash); foo.setOptionLists(hash);

View file

@ -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.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology; import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; 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.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; 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 // TODO - need unionOf/intersectionOf-style domains for domain class
String domainStr=""; String domainStr="";
try { try {
domainStr = (dp.getDomainClassURI() == null) ? "" : "<a href=\"vclassEdit?uri="+URLEncoder.encode(dp.getDomainClassURI(),"UTF-8")+"\">"+dp.getDomainClassURI()+"</a>"; VClass domainClass = getWebappDaoFactory().getVClassDao().getVClassByURI(dp.getDomainClassURI());
String domainLinkAnchor = (domainClass != null) ? domainClass.getPickListName() : dp.getDomainClassURI();
domainStr = (dp.getDomainClassURI() == null) ? "" : "<a href=\"vclassEdit?uri="+URLEncoder.encode(dp.getDomainClassURI(),"UTF-8")+"\">"+domainLinkAnchor+"</a>";
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
log.error(e, e); log.error(e, e);
} }

View file

@ -64,11 +64,12 @@ public class IndividualTypeRetryController extends BaseEditController {
request.setAttribute("individual", ind); request.setAttribute("individual", ind);
List<VClass> allVClasses = vcDao.getAllVclasses(); List<VClass> allVClasses = vcDao.getAllVclasses();
sortForPickList(allVClasses, vreq);
Set<String> allClassURISet = new HashSet<String>(); Set<String> allClassURISet = new HashSet<String>();
Map<String,String> classNameMap = new HashMap<String,String>(); Map<String,String> classNameMap = new HashMap<String,String>();
for (Iterator allClassIt = allVClasses.iterator(); allClassIt.hasNext(); ) { for (Iterator allClassIt = allVClasses.iterator(); allClassIt.hasNext(); ) {
VClass vc = (VClass) allClassIt.next(); VClass vc = (VClass) allClassIt.next();
classNameMap.put(vc.getURI(),vc.getLocalNameWithPrefix()); classNameMap.put(vc.getURI(),vc.getPickListName());
allClassURISet.add(vc.getURI()); allClassURISet.add(vc.getURI());
} }
@ -98,7 +99,6 @@ public class IndividualTypeRetryController extends BaseEditController {
typeOptionList.add(opt); typeOptionList.add(opt);
} }
Collections.sort(typeOptionList,new OptionCollator());
optionMap.put("types",typeOptionList); optionMap.put("types",typeOptionList);
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
@ -124,23 +124,4 @@ public class IndividualTypeRetryController extends BaseEditController {
// shouldn't be posting to this controller // shouldn't be posting to this controller
} }
static class OptionCollator implements Comparator<Option> {
public int compare (Option o1, Option o2) {
// Collator collator = Collator.getInstance();
return getLocalName ( o1.getBody().toString() )
.compareTo(
getLocalName ( o2.getBody().toString() ) );
}
private String getLocalName( String in ){
if( in == null )
return "";
int i = in.indexOf(':');
if( i >= 0 )
return in.substring( i );
else
return in;
}
}
} }

View file

@ -124,7 +124,7 @@ public class ObjectPropertyStatementRetryController extends BaseEditController {
} }
List<Individual> indList = new LinkedList(); List<Individual> indList = new LinkedList();
indList.addAll(possIndSet); indList.addAll(possIndSet);
Collections.sort(indList, new IndComparator()); sortForPickList(indList, vreq);
List objectEntOptionList = new LinkedList(); List objectEntOptionList = new LinkedList();
Iterator<Individual> indIt = indList.iterator(); Iterator<Individual> indIt = indList.iterator();
while (indIt.hasNext()) { while (indIt.hasNext()) {
@ -168,12 +168,4 @@ public class ObjectPropertyStatementRetryController extends BaseEditController {
doPost(request, response); doPost(request, response);
} }
private class IndComparator implements Comparator {
public int compare(Object o1, Object o2) {
Collator collator = Collator.getInstance();
return collator.compare(((Individual)o1).getName() , ((Individual)o2).getName());
}
}
} }

View file

@ -59,16 +59,16 @@ public class Properties2PropertiesRetryController extends BaseEditController {
? dpDao.getAllDataProperties() ? dpDao.getAllDataProperties()
: opDao.getAllObjectProperties(); : opDao.getAllObjectProperties();
Collections.sort(propList); sortForPickList(propList, request);
String superpropertyURIstr = request.getParameter("SuperpropertyURI"); String superpropertyURIstr = request.getParameter("SuperpropertyURI");
String subpropertyURIstr = request.getParameter("SubpropertyURI"); String subpropertyURIstr = request.getParameter("SubpropertyURI");
HashMap<String,Option> hashMap = new HashMap<String,Option>(); HashMap<String,Option> hashMap = new HashMap<String,Option>();
List<Option> optionList = FormUtils.makeOptionListFromBeans(propList,"URI","LocalNameWithPrefix",superpropertyURIstr,null); List<Option> optionList = FormUtils.makeOptionListFromBeans(propList,"URI","PickListName",superpropertyURIstr,null);
List<Option> superPropertyOptions = getSortedList(hashMap,optionList); List<Option> superPropertyOptions = getSortedList(hashMap, optionList, request);
optionList = FormUtils.makeOptionListFromBeans(propList,"URI","LocalNameWithPrefix",subpropertyURIstr,null); optionList = FormUtils.makeOptionListFromBeans(propList,"URI","PickListName",subpropertyURIstr,null);
List<Option> subPropertyOptions = getSortedList(hashMap, optionList); List<Option> subPropertyOptions = getSortedList(hashMap, optionList, request);
HashMap hash = new HashMap(); HashMap hash = new HashMap();
hash.put("SuperpropertyURI", superPropertyOptions); hash.put("SuperpropertyURI", superPropertyOptions);
@ -105,34 +105,4 @@ public class Properties2PropertiesRetryController extends BaseEditController {
} }
public List<Option> getSortedList(HashMap<String,Option> hashMap, List<Option> optionList){
class ListComparator implements Comparator<String>{
@Override
public int compare(String str1, String str2) {
// TODO Auto-generated method stub
Collator collator = Collator.getInstance();
return collator.compare(str1, str2);
}
}
List<String> bodyVal = new ArrayList<String>();
List<Option> options = new ArrayList<Option>();
Iterator<Option> itr = optionList.iterator();
while(itr.hasNext()){
Option option = itr.next();
hashMap.put(option.getBody(),option);
bodyVal.add(option.getBody());
}
Collections.sort(bodyVal, new ListComparator());
ListIterator<String> itrStr = bodyVal.listIterator();
while(itrStr.hasNext()){
options.add(hashMap.get(itrStr.next()));
}
return options;
}
} }

View file

@ -86,7 +86,7 @@ public class PropertyEditController extends BaseEditController {
ObjectProperty parent = propDao.getObjectPropertyByURI(p.getParentURI()); ObjectProperty parent = propDao.getObjectPropertyByURI(p.getParentURI());
if (parent != null && parent.getURI() != null) { if (parent != null && parent.getURI() != null) {
try { try {
parentPropertyStr = "<a href=\"propertyEdit?uri="+URLEncoder.encode(parent.getURI(),"UTF-8")+"\">"+parent.getLocalNameWithPrefix()+"</a>"; parentPropertyStr = "<a href=\"propertyEdit?uri="+URLEncoder.encode(parent.getURI(),"UTF-8")+"\">"+parent.getPickListName()+"</a>";
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
log.error(e, e); log.error(e, e);
} }
@ -121,12 +121,12 @@ public class PropertyEditController extends BaseEditController {
String domainStr = ""; String domainStr = "";
if (p.getDomainVClassURI() != null) { if (p.getDomainVClassURI() != null) {
VClass domainClass = vcDao.getVClassByURI(p.getDomainVClassURI()); 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 { try {
if (domainClass.isAnonymous()) { if (domainClass.isAnonymous()) {
domainStr = domainClass.getLocalNameWithPrefix(); domainStr = domainClass.getPickListName();
} else { } else {
domainStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(domainClass.getURI(),"UTF-8")+"\">"+domainClass.getLocalNameWithPrefix()+"</a>"; domainStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(domainClass.getURI(),"UTF-8")+"\">"+domainClass.getPickListName()+"</a>";
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
log.error(e, e); log.error(e, e);
@ -138,12 +138,12 @@ public class PropertyEditController extends BaseEditController {
String rangeStr = ""; String rangeStr = "";
if (p.getRangeVClassURI() != null) { if (p.getRangeVClassURI() != null) {
VClass rangeClass = vcDao.getVClassByURI(p.getRangeVClassURI()); 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 { try {
if (rangeClass.isAnonymous()) { if (rangeClass.isAnonymous()) {
rangeStr = rangeClass.getLocalNameWithPrefix(); rangeStr = rangeClass.getPickListName();
} else { } else {
rangeStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(rangeClass.getURI(),"UTF-8")+"\">"+rangeClass.getLocalNameWithPrefix()+"</a>"; rangeStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(rangeClass.getURI(),"UTF-8")+"\">"+rangeClass.getPickListName()+"</a>";
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
log.error(e, 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.getSelectFromExisting() ? "true" : "false"); // column 21
results.add(p.getOfferCreateNewOption() ? "true" : "false"); // column 22 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 = "<a href=\"datapropEdit?uri="+URLEncoder.encode(dProp.getURI(),"UTF-8")+"\">"+dProp.getLocalNameWithPrefix()+"</a>";
} 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.getDomainEntitySortDirection() == null ? "ascending" : p.getDomainEntitySortDirection()); // column 23
results.add(p.getURI()); // column 24 results.add(p.getURI()); // column 24

View file

@ -154,7 +154,7 @@ public class PropertyRetryController extends BaseEditController {
List groupOptList = FormUtils.makeOptionListFromBeans(request.getUnfilteredWebappDaoFactory().getPropertyGroupDao().getPublicGroups(true),"URI","Name", ((propertyForEditing.getGroupURI()==null) ? "" : propertyForEditing.getGroupURI()), null, (propertyForEditing.getGroupURI()!=null)); List groupOptList = FormUtils.makeOptionListFromBeans(request.getUnfilteredWebappDaoFactory().getPropertyGroupDao().getPublicGroups(true),"URI","Name", ((propertyForEditing.getGroupURI()==null) ? "" : propertyForEditing.getGroupURI()), null, (propertyForEditing.getGroupURI()!=null));
HashMap<String,Option> hashMap = new HashMap<String,Option>(); HashMap<String,Option> hashMap = new HashMap<String,Option>();
groupOptList = getSortedList(hashMap,groupOptList); groupOptList = getSortedList(hashMap,groupOptList,request);
groupOptList.add(0,new Option("","none")); groupOptList.add(0,new Option("","none"));
optionMap.put("GroupURI", groupOptList); optionMap.put("GroupURI", groupOptList);
@ -241,24 +241,10 @@ public class PropertyRetryController extends BaseEditController {
List<Option> parentIdList = FormUtils.makeOptionListFromBeans( List<Option> parentIdList = FormUtils.makeOptionListFromBeans(
objPropList,"URI","PickListName",propertyForEditing.getParentURI(),null); objPropList,"URI","PickListName",propertyForEditing.getParentURI(),null);
HashMap<String,Option> hashMap = new HashMap<String,Option>(); HashMap<String,Option> hashMap = new HashMap<String,Option>();
parentIdList = getSortedList(hashMap,parentIdList); parentIdList = getSortedList(hashMap,parentIdList,request);
parentIdList.add(0,new Option("-1","none (root property)", false)); parentIdList.add(0,new Option("-1","none (root property)", false));
optionMap.put("ParentURI", parentIdList); optionMap.put("ParentURI", parentIdList);
/*
List<DataProperty> dpList = dpDao.getAllDataProperties();
Collections.sort(dpList);
List<Option> objectIndividualSortPropertyList =
FormUtils.makeOptionListFromBeans(
dpList, "URI", "Name",
propertyForEditing.getObjectIndividualSortPropertyURI(),
null);
objectIndividualSortPropertyList.add(0, new Option(
"","- name (rdfs:label) -"));
optionMap.put("ObjectIndividualSortPropertyURI",
objectIndividualSortPropertyList);
*/
List<Option> domainOptionList = FormUtils.makeVClassOptionList( List<Option> domainOptionList = FormUtils.makeVClassOptionList(
request.getUnfilteredWebappDaoFactory(), request.getUnfilteredWebappDaoFactory(),
propertyForEditing.getDomainVClassURI()); propertyForEditing.getDomainVClassURI());
@ -266,7 +252,7 @@ public class PropertyRetryController extends BaseEditController {
&& propertyForEditing.getDomainVClass().isAnonymous()) { && propertyForEditing.getDomainVClass().isAnonymous()) {
domainOptionList.add(0, new Option( domainOptionList.add(0, new Option(
propertyForEditing.getDomainVClass().getURI(), propertyForEditing.getDomainVClass().getURI(),
propertyForEditing.getDomainVClass().getName(), propertyForEditing.getDomainVClass().getPickListName(),
true)); true));
} }
domainOptionList.add(0, new Option("","(none specified)")); domainOptionList.add(0, new Option("","(none specified)"));
@ -279,7 +265,7 @@ public class PropertyRetryController extends BaseEditController {
&& propertyForEditing.getRangeVClass().isAnonymous()) { && propertyForEditing.getRangeVClass().isAnonymous()) {
rangeOptionList.add(0, new Option( rangeOptionList.add(0, new Option(
propertyForEditing.getRangeVClass().getURI(), propertyForEditing.getRangeVClass().getURI(),
propertyForEditing.getRangeVClass().getName(), propertyForEditing.getRangeVClass().getPickListName(),
true)); true));
} }
rangeOptionList.add(0, new Option("","(none specified)")); rangeOptionList.add(0, new Option("","(none specified)"));
@ -316,33 +302,5 @@ public class PropertyRetryController extends BaseEditController {
} }
} }
public List<Option> getSortedList(HashMap<String,Option> hashMap, List<Option> optionList){
class ListComparator implements Comparator<String>{
@Override
public int compare(String str1, String str2) {
// TODO Auto-generated method stub
Collator collator = Collator.getInstance();
return collator.compare(str1, str2);
}
}
List<String> bodyVal = new ArrayList<String>();
List<Option> options = new ArrayList<Option>();
Iterator<Option> itr = optionList.iterator();
while(itr.hasNext()){
Option option = itr.next();
hashMap.put(option.getBody(),option);
bodyVal.add(option.getBody());
}
Collections.sort(bodyVal, new ListComparator());
ListIterator<String> itrStr = bodyVal.listIterator();
while(itrStr.hasNext()){
options.add(hashMap.get(itrStr.next()));
}
return options;
}
} }

View file

@ -54,7 +54,7 @@ public class RefactorRetryController extends BaseEditController {
epo.setFormObject(foo); epo.setFormObject(foo);
HashMap<String,List<Option>> optMap = new HashMap<String,List<Option>>(); HashMap<String,List<Option>> optMap = new HashMap<String,List<Option>>();
foo.setOptionLists(optMap); foo.setOptionLists(optMap);
List<Option> subjectClassOpts = FormUtils.makeOptionListFromBeans(request.getUnfilteredWebappDaoFactory().getVClassDao().getAllVclasses(),"URI","Name", null, null); List<Option> subjectClassOpts = FormUtils.makeOptionListFromBeans(request.getUnfilteredWebappDaoFactory().getVClassDao().getAllVclasses(),"URI","PickListName", null, null);
subjectClassOpts.add(0,new Option("","? wildcard",true)); subjectClassOpts.add(0,new Option("","? wildcard",true));
optMap.put("SubjectClassURI", subjectClassOpts); optMap.put("SubjectClassURI", subjectClassOpts);
optMap.put("ObjectClassURI", subjectClassOpts); optMap.put("ObjectClassURI", subjectClassOpts);
@ -63,14 +63,14 @@ public class RefactorRetryController extends BaseEditController {
if (epo.getAttribute("propertyType").equals("ObjectProperty")) { if (epo.getAttribute("propertyType").equals("ObjectProperty")) {
List<ObjectProperty> opList = request.getUnfilteredWebappDaoFactory().getObjectPropertyDao().getAllObjectProperties(); List<ObjectProperty> opList = request.getUnfilteredWebappDaoFactory().getObjectPropertyDao().getAllObjectProperties();
Collections.sort(opList); Collections.sort(opList);
newPropertyOpts = FormUtils.makeOptionListFromBeans(opList,"URI","LocalNameWithPrefix", null, null); newPropertyOpts = FormUtils.makeOptionListFromBeans(opList,"URI","PickListName", null, null);
} else { } else {
List<DataProperty> dpList = request.getUnfilteredWebappDaoFactory().getDataPropertyDao().getAllDataProperties(); List<DataProperty> dpList = request.getUnfilteredWebappDaoFactory().getDataPropertyDao().getAllDataProperties();
Collections.sort(dpList); Collections.sort(dpList);
newPropertyOpts = FormUtils.makeOptionListFromBeans(dpList,"URI","Name", null, null); newPropertyOpts = FormUtils.makeOptionListFromBeans(dpList,"URI","PickListName", null, null);
} }
HashMap<String,Option> hashMap = new HashMap<String,Option>(); HashMap<String,Option> hashMap = new HashMap<String,Option>();
newPropertyOpts = getSortedList(hashMap,newPropertyOpts); newPropertyOpts = getSortedList(hashMap,newPropertyOpts,request);
newPropertyOpts.add(new Option("","(move to trash)")); newPropertyOpts.add(new Option("","(move to trash)"));
optMap.put("NewPropertyURI", newPropertyOpts); optMap.put("NewPropertyURI", newPropertyOpts);
@ -90,7 +90,7 @@ public class RefactorRetryController extends BaseEditController {
epo.setFormObject(foo); epo.setFormObject(foo);
HashMap<String,List<Option>> optMap = new HashMap<String,List<Option>>(); HashMap<String,List<Option>> optMap = new HashMap<String,List<Option>>();
foo.setOptionLists(optMap); foo.setOptionLists(optMap);
List<Option> newClassURIopts = FormUtils.makeOptionListFromBeans(request.getUnfilteredWebappDaoFactory().getVClassDao().getAllVclasses(),"URI","LocalNameWithPrefix", null, null); List<Option> newClassURIopts = FormUtils.makeOptionListFromBeans(request.getUnfilteredWebappDaoFactory().getVClassDao().getAllVclasses(),"URI","PickListName", null, null);
newClassURIopts.add(new Option ("","move to trash")); newClassURIopts.add(new Option ("","move to trash"));
optMap.put("NewVClassURI", newClassURIopts); optMap.put("NewVClassURI", newClassURIopts);
request.setAttribute("editAction","refactorOp"); request.setAttribute("editAction","refactorOp");
@ -137,34 +137,6 @@ public class RefactorRetryController extends BaseEditController {
} }
public List<Option> getSortedList(HashMap<String,Option> hashMap, List<Option> optionList){
class ListComparator implements Comparator<String>{
@Override
public int compare(String str1, String str2) {
// TODO Auto-generated method stub
Collator collator = Collator.getInstance();
return collator.compare(str1, str2);
}
}
List<String> bodyVal = new ArrayList<String>();
List<Option> options = new ArrayList<Option>();
Iterator<Option> itr = optionList.iterator();
while(itr.hasNext()){
Option option = itr.next();
hashMap.put(option.getBody(),option);
bodyVal.add(option.getBody());
}
Collections.sort(bodyVal, new ListComparator());
ListIterator<String> itrStr = bodyVal.listIterator();
while(itrStr.hasNext()){
options.add(hashMap.get(itrStr.next()));
}
return options;
}
} }

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.edit; package edu.cornell.mannlib.vitro.webapp.controller.edit;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -16,7 +15,6 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDFS; import com.hp.hpl.jena.vocabulary.RDFS;
import com.ibm.icu.text.Collator;
import edu.cornell.mannlib.vedit.beans.EditProcessObject; import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject; import edu.cornell.mannlib.vedit.beans.FormObject;
@ -25,6 +23,7 @@ import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.beans.Datatype; import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
import edu.cornell.mannlib.vitro.webapp.beans.Property; import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.ResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
@ -58,12 +57,12 @@ public class RestrictionRetryController extends BaseEditController {
// default to object property restriction // default to object property restriction
boolean propertyType = ("data".equals(request.getParameter("propertyType"))) ? DATA : OBJECT ; boolean propertyType = ("data".equals(request.getParameter("propertyType"))) ? DATA : OBJECT ;
List<? extends Property> pList = (propertyType == OBJECT) List<? extends ResourceBean> pList = (propertyType == OBJECT)
? request.getUnfilteredWebappDaoFactory().getObjectPropertyDao().getAllObjectProperties() ? request.getUnfilteredWebappDaoFactory().getObjectPropertyDao().getAllObjectProperties()
: request.getUnfilteredWebappDaoFactory().getDataPropertyDao().getAllDataProperties(); : request.getUnfilteredWebappDaoFactory().getDataPropertyDao().getAllDataProperties();
List<Option> onPropertyList = new LinkedList<Option>(); List<Option> onPropertyList = new LinkedList<Option>();
Collections.sort(pList, new PropSorter()); sortForPickList(pList, request);
for (Property p: pList) { for (ResourceBean p: pList) {
onPropertyList.add( new Option(p.getURI(),p.getPickListName())); onPropertyList.add( new Option(p.getURI(),p.getPickListName()));
} }
@ -146,14 +145,5 @@ public class RestrictionRetryController extends BaseEditController {
return valueDatatypeOptionList; return valueDatatypeOptionList;
} }
private class PropSorter implements Comparator<Property> {
public int compare(Property p1, Property p2) {
if (p1.getLocalNameWithPrefix() == null) return 1;
if (p2.getLocalNameWithPrefix() == null) return -1;
return Collator.getInstance().compare(p1.getLocalNameWithPrefix(), p2.getLocalNameWithPrefix());
}
}
} }

View file

@ -201,9 +201,9 @@ public class ClassHierarchyListingController extends BaseEditController {
Integer numCols = (NUM_COLS-1)-position; Integer numCols = (NUM_COLS-1)-position;
try { try {
numCols = addColToResults(((vcw.getLocalNameWithPrefix() == null) ? "" : "<a href=\"vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"\">"+vcw.getLocalNameWithPrefix()+"</a>"), results, numCols); numCols = addColToResults(((vcw.getPickListName() == null) ? "" : "<a href=\"vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"\">"+vcw.getPickListName()+"</a>"), results, numCols);
} catch (Exception e) { } catch (Exception e) {
numCols = addColToResults(((vcw.getLocalNameWithPrefix() == null) ? "" : vcw.getLocalNameWithPrefix()), results, numCols); // column 2 numCols = addColToResults(((vcw.getPickListName() == null) ? "" : vcw.getPickListName()), results, numCols); // column 2
} }
numCols = addColToResults(((vcw.getShortDef() == null) ? "" : vcw.getShortDef()), results, numCols); // column 3 numCols = addColToResults(((vcw.getShortDef() == null) ? "" : vcw.getShortDef()), results, numCols); // column 3
numCols = addColToResults(((vcw.getExample() == null) ? "" : vcw.getExample()), results, numCols); // column 4 numCols = addColToResults(((vcw.getExample() == null) ? "" : vcw.getExample()), results, numCols); // column 4

View file

@ -187,13 +187,13 @@ public class DataPropertyHierarchyListingController extends BaseEditController {
String nameStr = dp.getPublicName()==null ? dp.getName()==null ? dp.getURI()==null ? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName(); String nameStr = dp.getPublicName()==null ? dp.getName()==null ? dp.getURI()==null ? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName();
try { try {
numCols=addColToResults("<a href=\"datapropEdit?uri="+URLEncoder.encode(dp.getURI(),"UTF-8")+"\">"+nameStr+"</a> <span style='font-style:italic; color:\"grey\";'>"+dp.getLocalNameWithPrefix()+"</span>",results,numCols); // column 2 numCols=addColToResults("<a href=\"datapropEdit?uri="+URLEncoder.encode(dp.getURI(),"UTF-8")+"\">"+nameStr+"</a> <span style='font-style:italic; color:\"grey\";'>"+dp.getPickListName()+"</span>",results,numCols); // column 2
} catch (Exception e) { } catch (Exception e) {
numCols=addColToResults(nameStr + " <i>" + dp.getLocalNameWithPrefix() + "</i>",results,numCols); // column 2 numCols=addColToResults(nameStr + " <i>" + dp.getPickListName() + "</i>",results,numCols); // column 2
} }
VClass tmp = null; VClass tmp = null;
try { try {
numCols = addColToResults((((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(dp.getDomainClassURI()).getLocalNameWithPrefix()), results, numCols); // column 3 numCols = addColToResults((((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null && (tmp.getPickListName() == null)) ? "" : vcDao.getVClassByURI(dp.getDomainClassURI()).getPickListName()), results, numCols); // column 3
} catch (NullPointerException e) { } catch (NullPointerException e) {
numCols = addColToResults("-",results,numCols); numCols = addColToResults("-",results,numCols);
} }
@ -237,10 +237,4 @@ public class DataPropertyHierarchyListingController extends BaseEditController {
return colIndex-1; return colIndex-1;
} }
private class DataPropertyAlphaComparator implements Comparator {
public int compare(Object o1, Object o2) {
return Collator.getInstance().compare( ((DataProperty)o1).getName(), ((DataProperty)o2).getName());
}
}
} }

View file

@ -111,9 +111,9 @@ public class DatatypePropertiesListingController extends BaseEditController {
results.add("XX"); // column 1 results.add("XX"); // column 1
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName(); String nameStr = prop.getPublicName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName();
try { try {
results.add("<a href=\"datapropEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"\">"+nameStr+"</a> <span style='font-style:italic; color:\"grey\";'>"+prop.getLocalNameWithPrefix()+"</span>"); // column 2 results.add("<a href=\"datapropEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"\">"+nameStr+"</a> <span style='font-style:italic; color:\"grey\";'>"+prop.getPickListName()+"</span>"); // column 2
} catch (Exception e) { } catch (Exception e) {
results.add(nameStr + " <span style='font-style:italic; color:\"grey\";'>" + prop.getLocalNameWithPrefix() + "</span>"); // column 2 results.add(nameStr + " <span style='font-style:italic; color:\"grey\";'>" + prop.getPickListName() + "</span>"); // column 2
} }
VClass vc = null; VClass vc = null;
String domainStr=""; String domainStr="";
@ -170,19 +170,4 @@ public class DatatypePropertiesListingController extends BaseEditController {
} }
} }
/*
private class DatatypePropertyAlphaComparator implements Comparator {
public int compare (Object o1, Object o2) {
Collator collator = Collator.getInstance();
DataProperty dp1 = (DataProperty) o1;
DataProperty dp2 = (DataProperty) o2;
String dp1Str = (dp1.getPublicName()==null) ? dp1.getName() : dp1.getPublicName();
dp1Str = (dp1Str == null) ? "" : dp1Str;
String dp2Str = (dp2.getPublicName()==null) ? dp2.getName() : dp2.getPublicName();
dp2Str = (dp2Str == null) ? "" : dp2Str;
return collator.compare(dp1Str,dp2Str);
}
}
*/
} }

View file

@ -83,7 +83,7 @@ public class ObjectPropertyHierarchyListingController extends BaseEditController
} else { } else {
roots = opDao.getRootObjectProperties(); roots = opDao.getRootObjectProperties();
if (roots!=null){ if (roots!=null){
Collections.sort(roots, new ObjectPropertyAlphaComparator()); // sorts by domain public Collections.sort(roots, new ObjectPropertyAlphaComparator(vrequest.getCollator())); // sorts by domain public
} }
} }
@ -187,16 +187,16 @@ public class ObjectPropertyHierarchyListingController extends BaseEditController
} }
numCols = addColToResults( ((hyperlink != null) ? hyperlink : getDisplayLabel(op)) numCols = addColToResults( ((hyperlink != null) ? hyperlink : getDisplayLabel(op))
+ "<br/><span style='font-style:italic; color:\"grey\";'>"+op.getLocalNameWithPrefix()+"</span>", results, numCols); // column 2 + "<br/><span style='font-style:italic; color:\"grey\";'>"+op.getPickListName()+"</span>", results, numCols); // column 2
VClass tmp = null; VClass tmp = null;
try { try {
numCols = addColToResults((((tmp = vcDao.getVClassByURI(op.getDomainVClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(op.getDomainVClassURI()).getLocalNameWithPrefix()), results, numCols); // column 3 numCols = addColToResults((((tmp = vcDao.getVClassByURI(op.getDomainVClassURI())) != null && (tmp.getPickListName() == null)) ? "" : vcDao.getVClassByURI(op.getDomainVClassURI()).getPickListName()), results, numCols); // column 3
} catch (NullPointerException e) { } catch (NullPointerException e) {
numCols = addColToResults("",results,numCols); numCols = addColToResults("",results,numCols);
} }
try { try {
numCols = addColToResults((((tmp = vcDao.getVClassByURI(op.getRangeVClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(op.getRangeVClassURI()).getLocalNameWithPrefix()), results, numCols); // column 4 numCols = addColToResults((((tmp = vcDao.getVClassByURI(op.getRangeVClassURI())) != null && (tmp.getPickListName() == null)) ? "" : vcDao.getVClassByURI(op.getRangeVClassURI()).getPickListName()), results, numCols); // column 4
} catch (NullPointerException e) { } catch (NullPointerException e) {
numCols = addColToResults("",results,numCols); numCols = addColToResults("",results,numCols);
} }
@ -237,6 +237,13 @@ public class ObjectPropertyHierarchyListingController extends BaseEditController
} }
public static class ObjectPropertyAlphaComparator implements Comparator<ObjectProperty> { public static class ObjectPropertyAlphaComparator implements Comparator<ObjectProperty> {
Collator collator;
public ObjectPropertyAlphaComparator(Collator collator) {
this.collator = collator;
}
public int compare(ObjectProperty op1, ObjectProperty op2) { public int compare(ObjectProperty op1, ObjectProperty op2) {
if (op1 == null) { if (op1 == null) {
return 1; return 1;
@ -250,7 +257,7 @@ public class ObjectPropertyHierarchyListingController extends BaseEditController
} else if (propLabel2 == null) { } else if (propLabel2 == null) {
return -1; return -1;
} else { } else {
return Collator.getInstance().compare( propLabel1, propLabel2 ); return collator.compare( propLabel1, propLabel2 );
} }
} }
} }

View file

@ -140,7 +140,7 @@ public class ObjectPropertyStatementListingController extends
if (count == 0) { if (count == 0) {
results.add("XX"); results.add("XX");
results.add("No statements found for property \""+op.getLocalNameWithPrefix()+"\""); results.add("No statements found for property \""+op.getPickListName()+"\"");
results.add(""); results.add("");
results.add(""); results.add("");
if (showVClasses) { if (showVClasses) {

View file

@ -47,7 +47,7 @@ public class PropertyGroupsListingController extends BaseEditController {
List<PropertyGroup> groups = dao.getPublicGroups(WITH_PROPERTIES); List<PropertyGroup> groups = dao.getPublicGroups(WITH_PROPERTIES);
Comparator<Property> comparator = new PropertySorter(); Comparator<Property> comparator = new PropertySorter(vreq.getCollator());
List<String> results = new ArrayList<String>(); List<String> results = new ArrayList<String>();
results.add("XX"); results.add("XX");
@ -138,7 +138,11 @@ public class PropertyGroupsListingController extends BaseEditController {
private class PropertySorter implements Comparator<Property> { private class PropertySorter implements Comparator<Property> {
private Collator coll = Collator.getInstance(); Collator collator;
public PropertySorter(Collator collator) {
this.collator = collator;
}
public int compare(Property p1, Property p2) { public int compare(Property p1, Property p2) {
String name1 = getName(p1); String name1 = getName(p1);
@ -150,7 +154,7 @@ public class PropertyGroupsListingController extends BaseEditController {
} else if (name1 == null && name2 == null) { } else if (name1 == null && name2 == null) {
return 0; return 0;
} }
return coll.compare(name1, name2); return collator.compare(name1, name2);
} }
private String getName(Property prop) { private String getName(Property prop) {

View file

@ -125,7 +125,9 @@ public class PropertyWebappsListingController extends BaseEditController {
} }
if (props != null) { if (props != null) {
Collections.sort(props, new ObjectPropertyHierarchyListingController.ObjectPropertyAlphaComparator()); Collections.sort(
props, new ObjectPropertyHierarchyListingController
.ObjectPropertyAlphaComparator(vrequest.getCollator()));
} }
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
@ -163,16 +165,16 @@ public class PropertyWebappsListingController extends BaseEditController {
results.add(propNameStr); // column 2 results.add(propNameStr); // column 2
} }
results.add(prop.getLocalNameWithPrefix()); // column 3 results.add(prop.getPickListName()); // column 3
VClass vc = (prop.getDomainVClassURI() != null) ? VClass vc = (prop.getDomainVClassURI() != null) ?
vcDao.getVClassByURI(prop.getDomainVClassURI()) : null; vcDao.getVClassByURI(prop.getDomainVClassURI()) : null;
String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; String domainStr = (vc != null) ? vc.getPickListName() : "";
results.add(domainStr); // column 4 results.add(domainStr); // column 4
vc = (prop.getRangeVClassURI() != null) ? vc = (prop.getRangeVClassURI() != null) ?
vcDao.getVClassByURI(prop.getRangeVClassURI()) : null; vcDao.getVClassByURI(prop.getRangeVClassURI()) : null;
String rangeStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; String rangeStr = (vc != null) ? vc.getPickListName() : "";
results.add(rangeStr); // column 5 results.add(rangeStr); // column 5
if (prop.getGroupURI() != null) { if (prop.getGroupURI() != null) {

View file

@ -115,11 +115,4 @@ public class VClassWebappWithInstancesListingController extends BaseEditControll
} }
private class EntityWebappAlphaComparator implements Comparator {
public int compare (Object o1, Object o2) {
Collator collator = Collator.getInstance();
return collator.compare(((ObjectProperty)o1).getLocalName(),((ObjectProperty)o2).getLocalName());
}
}
} }

View file

@ -79,9 +79,9 @@ public class VClassWebappsListingController extends BaseEditController {
if (cls.getName() != null) if (cls.getName() != null)
try { try {
//String className = (cls.getName()==null || cls.getName().length()==0) ? cls.getURI() : cls.getName(); //String className = (cls.getName()==null || cls.getName().length()==0) ? cls.getURI() : cls.getName();
results.add("<a href=\"./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"\">"+cls.getLocalNameWithPrefix()+"</a>"); results.add("<a href=\"./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"\">"+cls.getPickListName()+"</a>");
} catch (Exception e) { } catch (Exception e) {
results.add(cls.getLocalNameWithPrefix()); results.add(cls.getPickListName());
} }
else else
results.add(""); results.add("");

View file

@ -124,7 +124,7 @@ public class RestrictionsListingController extends BaseEditController {
results.add("XX"); results.add("XX");
Property onProperty = rest.getOnProperty(); Property onProperty = rest.getOnProperty();
ObjectProperty op = opDao.getObjectPropertyByURI(onProperty.getURI()); ObjectProperty op = opDao.getObjectPropertyByURI(onProperty.getURI());
results.add(op.getLocalNameWithPrefix()); results.add(op.getPickListName());
if (rest.isAllValuesFromRestriction()) { if (rest.isAllValuesFromRestriction()) {
results.add("all values from"); results.add("all values from");
AllValuesFromRestriction avfrest = (AllValuesFromRestriction) rest.as(AllValuesFromRestriction.class); AllValuesFromRestriction avfrest = (AllValuesFromRestriction) rest.as(AllValuesFromRestriction.class);

View file

@ -92,7 +92,7 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
} }
if (props != null) { if (props != null) {
Collections.sort(props); sortForPickList(props, vreq);
} }
String json = new String(); String json = new String();
@ -107,7 +107,7 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
json += ", "; json += ", ";
} }
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName(); String nameStr = prop.getPickListName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName();
try { try {
json += "{ \"name\": " + JSONUtils.quote("<a href='datapropEdit?uri="+ URLEncoder.encode(prop.getURI())+"'>" + nameStr + "</a>") + ", "; json += "{ \"name\": " + JSONUtils.quote("<a href='datapropEdit?uri="+ URLEncoder.encode(prop.getURI())+"'>" + nameStr + "</a>") + ", ";
@ -115,7 +115,7 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
json += "{ \"name\": " + JSONUtils.quote(nameStr) + ", "; json += "{ \"name\": " + JSONUtils.quote(nameStr) + ", ";
} }
json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", "; json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getPickListName()) + ", ";
/* VClass vc = null; /* VClass vc = null;
String domainStr=""; String domainStr="";
@ -131,7 +131,7 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
} }
*/ */
VClass vc = (prop.getDomainClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainClassURI()) : null; VClass vc = (prop.getDomainClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainClassURI()) : null;
String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; String domainStr = (vc != null) ? vc.getPickListName() : "";
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ; json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI()); Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI());

View file

@ -49,8 +49,7 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
PropertyGroupDao dao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); PropertyGroupDao dao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
List<PropertyGroup> groups = dao.getPublicGroups(WITH_PROPERTIES); List<PropertyGroup> groups = dao.getPublicGroups(WITH_PROPERTIES);
sortForPickList(groups, vreq);
// Comparator<Property> comparator = new PropertySorter();
String json = new String(); String json = new String();
int counter = 0; int counter = 0;
@ -125,33 +124,4 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
return new TemplateResponseValues(TEMPLATE_NAME, body); return new TemplateResponseValues(TEMPLATE_NAME, body);
} }
/*
private class PropertySorter implements Comparator<Property> {
private Collator coll = Collator.getInstance();
public int compare(Property p1, Property p2) {
String name1 = getName(p1);
String name2 = getName(p2);
if (name1 == null && name2 != null) {
return 1;
} else if (name2 == null && name1 != null) {
return -1;
} else if (name1 == null && name2 == null) {
return 0;
}
return coll.compare(name1, name2);
}
private String getName(Property prop) {
if (prop instanceof ObjectProperty) {
return ((ObjectProperty) prop).getDomainPublic();
} else if (prop instanceof DataProperty) {
return ((DataProperty) prop).getName();
} else {
return prop.getLabel();
}
}
}
*/
} }

View file

@ -132,7 +132,7 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
} }
if (props != null) { if (props != null) {
Collections.sort(props, new ShowObjectPropertyHierarchyController.ObjectPropertyAlphaComparator()); sortForPickList(props, vreq);
} }
String json = new String(); String json = new String();
@ -161,11 +161,11 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", "; json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", ";
VClass vc = (prop.getDomainVClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainVClassURI()) : null; VClass vc = (prop.getDomainVClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainVClassURI()) : null;
String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; String domainStr = (vc != null) ? vc.getPickListName() : "";
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ; json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
vc = (prop.getRangeVClassURI() != null) ? vcDao.getVClassByURI(prop.getRangeVClassURI()) : null; vc = (prop.getRangeVClassURI() != null) ? vcDao.getVClassByURI(prop.getRangeVClassURI()) : null;
String rangeStr = (vc != null) ? vc.getLocalNameWithPrefix() : ""; String rangeStr = (vc != null) ? vc.getPickListName() : "";
json += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", " ; json += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", " ;
if (prop.getGroupURI() != null) { if (prop.getGroupURI() != null) {

View file

@ -69,7 +69,7 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
String ontologyURI = vreq.getParameter("ontologyUri"); String ontologyURI = vreq.getParameter("ontologyUri");
if (classes != null) { if (classes != null) {
Collections.sort(classes); sortForPickList(classes, vreq);
Iterator<VClass> classesIt = classes.iterator(); Iterator<VClass> classesIt = classes.iterator();
while (classesIt.hasNext()) { while (classesIt.hasNext()) {
if ( counter > 0 ) { if ( counter > 0 ) {
@ -79,9 +79,9 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) { if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
if (cls.getName() != null) if (cls.getName() != null)
try { try {
json += "{ \"name\": " + JSONUtils.quote("<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getLocalNameWithPrefix()+"</a>") + ", "; json += "{ \"name\": " + JSONUtils.quote("<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getPickListName()+"</a>") + ", ";
} catch (Exception e) { } catch (Exception e) {
json += "{ \"name\": " + JSONUtils.quote(cls.getLocalNameWithPrefix()) + ", "; json += "{ \"name\": " + JSONUtils.quote(cls.getPickListName()) + ", ";
} }
else else
json += "{ \"name\": \"\""; json += "{ \"name\": \"\"";

View file

@ -97,7 +97,7 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
roots.add(vreq.getUnfilteredWebappDaoFactory().getVClassDao() roots.add(vreq.getUnfilteredWebappDaoFactory().getVClassDao()
.getTopConcept()); .getTopConcept());
} }
Collections.sort(roots); sortForPickList(roots, vreq);
int counter = 0; int counter = 0;
Iterator<VClass> rootIt = roots.iterator(); Iterator<VClass> rootIt = roots.iterator();
@ -109,7 +109,8 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
while (rootIt.hasNext()) { while (rootIt.hasNext()) {
VClass root = (VClass) rootIt.next(); VClass root = (VClass) rootIt.next();
if (root != null) { if (root != null) {
json += addChildren(vreq.getUnfilteredWebappDaoFactory(), root, 0, ontologyUri,counter); json += addChildren(vreq.getUnfilteredWebappDaoFactory(),
root, 0, ontologyUri, counter, vreq);
counter += 1; counter += 1;
} }
} }
@ -123,7 +124,8 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
return new TemplateResponseValues(TEMPLATE_NAME, body); return new TemplateResponseValues(TEMPLATE_NAME, body);
} }
private String addChildren(WebappDaoFactory wadf, VClass parent, int position, String ontologyUri, int counter) { private String addChildren(WebappDaoFactory wadf, VClass parent, int position,
String ontologyUri, int counter, VitroRequest vreq) {
String rowElts = addVClassDataToResultsList(wadf, parent, position, ontologyUri, 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 childShift = (rowElts.length() > 0) ? 1 : 0; // if addVClassDataToResultsList filtered out the result, don't shift the children over
int length = rowElts.length(); int length = rowElts.length();
@ -142,11 +144,11 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
} }
} catch (Exception e) {} } catch (Exception e) {}
} }
Collections.sort(childClasses); sortForPickList(childClasses, vreq);
Iterator<VClass> childClassIt = childClasses.iterator(); Iterator<VClass> childClassIt = childClasses.iterator();
while (childClassIt.hasNext()) { while (childClassIt.hasNext()) {
VClass child = (VClass) childClassIt.next(); VClass child = (VClass) childClassIt.next();
leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter); leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter, vreq);
if (!childClassIt.hasNext()) { if (!childClassIt.hasNext()) {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += " }] "; leaves += " }] ";
@ -197,10 +199,10 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
try { try {
tempString += JSONUtils.quote("<a href='vclassEdit?uri=" + tempString += JSONUtils.quote("<a href='vclassEdit?uri=" +
URLEncoder.encode(vcw.getURI(),"UTF-8") + "'>" + URLEncoder.encode(vcw.getURI(),"UTF-8") + "'>" +
vcw.getLocalNameWithPrefix() + "</a>") +", "; vcw.getPickListName() + "</a>") +", ";
} catch (Exception e) { } catch (Exception e) {
tempString += JSONUtils.quote(((vcw.getLocalNameWithPrefix() == null) tempString += JSONUtils.quote(((vcw.getPickListName() == null)
? "" : vcw.getLocalNameWithPrefix())) + ", "; ? "" : vcw.getPickListName())) + ", ";
} }
String shortDef = ((vcw.getShortDef() == null) ? "" : vcw.getShortDef()) ; String shortDef = ((vcw.getShortDef() == null) ? "" : vcw.getShortDef()) ;

View file

@ -94,7 +94,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
} else { } else {
roots = dpDao.getRootDataProperties(); roots = dpDao.getRootDataProperties();
if (roots!=null){ if (roots!=null){
Collections.sort(roots); sortForPickList(roots, vreq);
} }
} }
@ -113,7 +113,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
while (rootIt.hasNext()) { while (rootIt.hasNext()) {
DataProperty root = rootIt.next(); DataProperty root = rootIt.next();
if ( (ontologyUri==null) || ( (ontologyUri!=null) && (root.getNamespace()!=null) && (ontologyUri.equals(root.getNamespace())) ) ) { if ( (ontologyUri==null) || ( (ontologyUri!=null) && (root.getNamespace()!=null) && (ontologyUri.equals(root.getNamespace())) ) ) {
json += addChildren(root, 0, ontologyUri, counter); json += addChildren(root, 0, ontologyUri, counter, vreq);
counter += 1; counter += 1;
} }
} }
@ -132,7 +132,8 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
return new TemplateResponseValues(TEMPLATE_NAME, body); return new TemplateResponseValues(TEMPLATE_NAME, body);
} }
private String addChildren(DataProperty parent, int position, String ontologyUri, int counter) { private String addChildren(DataProperty parent, int position, String ontologyUri,
int counter, VitroRequest vreq) {
if (parent == null) { if (parent == null) {
return ""; return "";
} }
@ -149,11 +150,11 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
DataProperty child = dpDao.getDataPropertyByURI(URIstr); DataProperty child = dpDao.getDataPropertyByURI(URIstr);
childProps.add(child); childProps.add(child);
} }
Collections.sort(childProps); sortForPickList(childProps, vreq);
Iterator<DataProperty> childPropIt = childProps.iterator(); Iterator<DataProperty> childPropIt = childProps.iterator();
while (childPropIt.hasNext()) { while (childPropIt.hasNext()) {
DataProperty child = childPropIt.next(); DataProperty child = childPropIt.next();
leaves += addChildren(child, position+1, ontologyUri, counter); leaves += addChildren(child, position+1, ontologyUri, counter, vreq);
if (!childPropIt.hasNext()) { if (!childPropIt.hasNext()) {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += " }] "; leaves += " }] ";
@ -204,7 +205,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
tempString += "}, { \"name\": "; tempString += "}, { \"name\": ";
} }
String nameStr = dp.getPublicName() == null String nameStr = dp.getPickListName() == null
? dp.getName() == null ? dp.getName() == null
? dp.getURI() == null ? dp.getURI() == null
? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName(); ? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName();
@ -214,17 +215,17 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
dp.getURI()) + "'>" + nameStr + "</a>") + ", "; dp.getURI()) + "'>" + nameStr + "</a>") + ", ";
tempString += "\"data\": { \"internalName\": " + JSONUtils.quote( tempString += "\"data\": { \"internalName\": " + JSONUtils.quote(
dp.getLocalNameWithPrefix()) + ", "; dp.getPickListName()) + ", ";
VClass tmp = null; VClass tmp = null;
try { try {
tempString += "\"domainVClass\": " + JSONUtils.quote( tempString += "\"domainVClass\": " + JSONUtils.quote(
((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null ((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null
&& (tmp.getLocalNameWithPrefix() == null)) && (tmp.getPickListName() == null))
? "" ? ""
: vcDao.getVClassByURI( : vcDao.getVClassByURI(
dp.getDomainClassURI()) dp.getDomainClassURI())
.getLocalNameWithPrefix()) + ", " ; .getPickListName()) + ", " ;
} catch (NullPointerException e) { } catch (NullPointerException e) {
tempString += "\"domainVClass\": \"\","; tempString += "\"domainVClass\": \"\",";
} }

View file

@ -96,7 +96,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
} else { } else {
roots = opDao.getRootObjectProperties(); roots = opDao.getRootObjectProperties();
if (roots!=null){ if (roots!=null){
Collections.sort(roots, new ObjectPropertyAlphaComparator()); // sorts by domain public Collections.sort(roots, new ObjectPropertyAlphaComparator(vreq)); // sorts by domain public
} }
} }
@ -219,11 +219,11 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
tempString += "\"domainVClass\": " + JSONUtils.quote( tempString += "\"domainVClass\": " + JSONUtils.quote(
((tmp = vcDao.getVClassByURI( ((tmp = vcDao.getVClassByURI(
op.getDomainVClassURI())) != null op.getDomainVClassURI())) != null
&& (tmp.getLocalNameWithPrefix() == null)) && (tmp.getPickListName() == null))
? "" ? ""
: vcDao.getVClassByURI( : vcDao.getVClassByURI(
op.getDomainVClassURI()) op.getDomainVClassURI())
.getLocalNameWithPrefix()) + ", " ; .getPickListName()) + ", " ;
} catch (NullPointerException e) { } catch (NullPointerException e) {
tempString += "\"domainVClass\": \"\","; tempString += "\"domainVClass\": \"\",";
} }
@ -231,11 +231,11 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
tempString += "\"rangeVClass\": " + JSONUtils.quote( tempString += "\"rangeVClass\": " + JSONUtils.quote(
((tmp = vcDao.getVClassByURI( ((tmp = vcDao.getVClassByURI(
op.getRangeVClassURI())) != null op.getRangeVClassURI())) != null
&& (tmp.getLocalNameWithPrefix() == null)) && (tmp.getPickListName() == null))
? "" ? ""
: vcDao.getVClassByURI( : vcDao.getVClassByURI(
op.getRangeVClassURI()) op.getRangeVClassURI())
.getLocalNameWithPrefix()) + ", " ; .getPickListName()) + ", " ;
} catch (NullPointerException e) { } catch (NullPointerException e) {
tempString += "\"rangeVClass\": \"\","; tempString += "\"rangeVClass\": \"\",";
} }
@ -254,20 +254,27 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
} }
public static class ObjectPropertyAlphaComparator implements Comparator<ObjectProperty> { public static class ObjectPropertyAlphaComparator implements Comparator<ObjectProperty> {
Collator collator;
public ObjectPropertyAlphaComparator(VitroRequest vreq) {
this.collator = vreq.getCollator();
}
public int compare(ObjectProperty op1, ObjectProperty op2) { public int compare(ObjectProperty op1, ObjectProperty op2) {
if (op1 == null) { if (op1 == null) {
return 1; return 1;
} else if (op2 == null) { } else if (op2 == null) {
return -1; return -1;
} }
String propLabel1 = getDisplayLabel(op1); String propLabel1 = op1.getPickListName();
String propLabel2 = getDisplayLabel(op2); String propLabel2 = op2.getPickListName();
if (propLabel1 == null) { if (propLabel1 == null) {
return 1; return 1;
} else if (propLabel2 == null) { } else if (propLabel2 == null) {
return -1; return -1;
} else { } else {
return Collator.getInstance().compare( propLabel1, propLabel2 ); return collator.compare( propLabel1, propLabel2 );
} }
} }
} }
@ -276,9 +283,9 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
* should never be null * should never be null
*/ */
public static String getDisplayLabel(ObjectProperty op) { public static String getDisplayLabel(ObjectProperty op) {
String domainPublic = op.getDomainPublic(); String displayLabel = op.getPickListName();
String displayLabel = (domainPublic != null && domainPublic.length() > 0) displayLabel = (displayLabel != null && displayLabel.length() > 0)
? domainPublic ? displayLabel
: op.getLocalName(); : op.getLocalName();
return (displayLabel != null) ? displayLabel : "[object property]" ; return (displayLabel != null) ? displayLabel : "[object property]" ;
} }

View file

@ -5,15 +5,12 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
//import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.openrdf.model.URI;
import org.openrdf.model.impl.URIImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
@ -33,6 +30,7 @@ public class UrlBuilder {
BROWSE("/browse"), BROWSE("/browse"),
CONTACT("/contact"), CONTACT("/contact"),
DATA_PROPERTY_EDIT("/datapropEdit"), DATA_PROPERTY_EDIT("/datapropEdit"),
DISPLAY("/display"),
INDIVIDUAL("/individual"), INDIVIDUAL("/individual"),
INDIVIDUAL_EDIT("/entityEdit"), INDIVIDUAL_EDIT("/entityEdit"),
INDIVIDUAL_LIST("/individuallist"), INDIVIDUAL_LIST("/individuallist"),
@ -250,14 +248,14 @@ public class UrlBuilder {
String defaultNamespace = wadf.getDefaultNamespace(); String defaultNamespace = wadf.getDefaultNamespace();
if (defaultNamespace.equals(namespace)) { if (defaultNamespace.equals(namespace)) {
profileUrl = getUrl(Route.INDIVIDUAL.path() + "/" + localName); profileUrl = getUrl(Route.DISPLAY.path() + "/" + localName);
} else { } else {
if (wadf.getApplicationDao().isExternallyLinkedNamespace(namespace)) { if (wadf.getApplicationDao().isExternallyLinkedNamespace(namespace)) {
log.debug("Found externally linked namespace " + namespace); log.debug("Found externally linked namespace " + namespace);
profileUrl = namespace + localName; profileUrl = namespace + localName;
} else { } else {
ParamMap params = new ParamMap("uri", individual.getURI()); ParamMap params = new ParamMap("uri", individual.getURI());
profileUrl = getUrl("/individual", params); profileUrl = getUrl(Route.INDIVIDUAL.path(), params);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -284,25 +282,6 @@ public class UrlBuilder {
return getIndividualProfileUrl(new IndividualImpl(individualUri), vreq); return getIndividualProfileUrl(new IndividualImpl(individualUri), vreq);
} }
protected static String getIndividualProfileUrl(
String individualUri,
String namespace, String localName,
String defaultNamespace){
String profileUrl = "";
try{
if ( isUriInDefaultNamespace( individualUri, defaultNamespace) ) {
profileUrl = getUrl(Route.INDIVIDUAL.path() + "/" + localName);
} else {
ParamMap params = new ParamMap("uri", individualUri);
profileUrl = getUrl("/individual", params);
}
} catch (Exception e) {
log.warn(e);
return null;
}
return profileUrl;
}
public static boolean isUriInDefaultNamespace(String individualUri, VitroRequest vreq) { public static boolean isUriInDefaultNamespace(String individualUri, VitroRequest vreq) {
return isUriInDefaultNamespace(individualUri, vreq.getWebappDaoFactory()); return isUriInDefaultNamespace(individualUri, vreq.getWebappDaoFactory());
} }

View file

@ -162,9 +162,7 @@ class IndividualResponseBuilder {
map = new HashMap<String, Object>(); map = new HashMap<String, Object>();
map.put("name", relatedSubjectInd.getName()); map.put("name", relatedSubjectInd.getName());
// TODO find out which of these values is the correct one
map.put("url", UrlBuilder.getIndividualProfileUrl(relatedSubjectInd, vreq)); map.put("url", UrlBuilder.getIndividualProfileUrl(relatedSubjectInd, vreq));
map.put("url", (new ListedIndividual(relatedSubjectInd, vreq)).getProfileUrl());
String relatingPredicateUri = vreq.getParameter("relatingPredicateUri"); String relatingPredicateUri = vreq.getParameter("relatingPredicateUri");
if (relatingPredicateUri != null) { if (relatingPredicateUri != null) {

View file

@ -450,7 +450,7 @@ public class JenaIngestController extends BaseEditController {
vreq.setAttribute("bodyJsp",INGEST_MENU_JSP); vreq.setAttribute("bodyJsp",INGEST_MENU_JSP);
} else { } else {
List<String> dbTypes = DatabaseType.allNames(); List<String> dbTypes = DatabaseType.allNames();
Collections.sort(dbTypes, new CollationSort()); Collections.sort(dbTypes, new CollationSort(vreq));
vreq.setAttribute("dbTypes", dbTypes); vreq.setAttribute("dbTypes", dbTypes);
vreq.setAttribute("title", "Connect Jena Database"); vreq.setAttribute("title", "Connect Jena Database");
vreq.setAttribute("bodyJsp",CONNECT_DB_JSP); vreq.setAttribute("bodyJsp",CONNECT_DB_JSP);
@ -1295,7 +1295,11 @@ public class JenaIngestController extends BaseEditController {
private class CollationSort implements Comparator<String> { private class CollationSort implements Comparator<String> {
Collator collator = Collator.getInstance(); Collator collator;
public CollationSort(VitroRequest vreq) {
this.collator = vreq.getCollator();
}
public int compare(String s1, String s2) { public int compare(String s1, String s2) {
return collator.compare(s1, s2); return collator.compare(s1, s2);

View file

@ -259,6 +259,16 @@ public class IndividualFiltering implements Individual {
return _innerIndividual.getName(); return _innerIndividual.getName();
} }
@Override
public String getLabel() {
return _innerIndividual.getLabel();
}
@Override
public String getPickListName() {
return getName();
}
@Override @Override
public String getRdfsLabel(){ public String getRdfsLabel(){
return _innerIndividual.getRdfsLabel(); return _innerIndividual.getRdfsLabel();

View file

@ -177,20 +177,10 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
dp.setURI(op.getURI()); dp.setURI(op.getURI());
dp.setNamespace(op.getNameSpace()); dp.setNamespace(op.getNameSpace());
dp.setLocalName(op.getLocalName()); dp.setLocalName(op.getLocalName());
OntologyDao oDao=getWebappDaoFactory().getOntologyDao(); dp.setLocalNameWithPrefix(getWebappDaoFactory().makeLocalNameWithPrefix(dp));
Ontology o = oDao.getOntologyByURI(dp.getNamespace());
if (o==null) {
if (!VitroVocabulary.vitroURI.equals(dp.getNamespace())) {
log.debug("datapropFromOntProperty(): no ontology object found for the namespace "+dp.getNamespace());
}
dp.setLocalNameWithPrefix(dp.getLocalName());
dp.setPickListName(getLabelOrId(op));
} else {
dp.setLocalNameWithPrefix(o.getPrefix()==null?(o.getName()==null?"unspec:"+dp.getLocalName():o.getName()+":"+dp.getLocalName()):o.getPrefix()+":"+dp.getLocalName());
dp.setPickListName(getLabelOrId(op)+o.getPrefix()==null?(o.getName()==null?" (unspec:)":" ("+o.getName()+")"):" ("+o.getPrefix()+")");
}
dp.setName(op.getLocalName()); dp.setName(op.getLocalName());
dp.setPublicName(getLabelOrId(op)); dp.setPublicName(getLabelOrId(op));
dp.setPickListName(getWebappDaoFactory().makePickListName(dp));
Resource dRes = op.getDomain(); Resource dRes = op.getDomain();
if (dRes != null) { if (dRes != null) {
dp.setDomainClassURI(dRes.getURI()); dp.setDomainClassURI(dRes.getURI());

View file

@ -79,6 +79,10 @@ public class IndividualJena extends IndividualImpl implements Individual {
} }
} }
public String getLabel() {
return getRdfsLabel();
}
public String getRdfsLabel() { public String getRdfsLabel() {
if (this.rdfsLabel != null) { if (this.rdfsLabel != null) {
return rdfsLabel; return rdfsLabel;

View file

@ -94,27 +94,14 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
p.setURI(op.getURI()); p.setURI(op.getURI());
p.setNamespace(op.getNameSpace()); p.setNamespace(op.getNameSpace());
p.setLocalName(op.getLocalName()); p.setLocalName(op.getLocalName());
OntologyDao oDao=getWebappDaoFactory().getOntologyDao(); p.setLocalNameWithPrefix(getWebappDaoFactory().makeLocalNameWithPrefix(p));
Ontology o = oDao.getOntologyByURI(p.getNamespace());
if (o == null) {
if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) {
log.debug("propertyFromOntProperty(): no ontology object found for the namespace "+p.getNamespace());
}
p.setLocalNameWithPrefix(p.getLocalName());
p.setPickListName(getLabelOrId(op));
} else {
String prefix = o.getPrefix()==null?(o.getName()==null?"unspec":o.getName()):o.getPrefix();
p.setLocalNameWithPrefix(prefix+":"+p.getLocalName());
//log.warn("setting pickListName to: "+p.getLocalName()+" ("+prefix+")");
p.setPickListName(getLabelOrId(op) + " ("+prefix+")");
}
String propertyName = getPropertyStringValue(op,PROPERTY_FULLPROPERTYNAMEANNOT);
if (op.getLabel(null) != null) if (op.getLabel(null) != null)
p.setDomainPublic(getLabelOrId(op)); p.setDomainPublic(getLabelOrId(op));
else else
p.setDomainPublic(op.getLocalName()); p.setDomainPublic(op.getLocalName());
if (p.getDomainPublic() == null) if (p.getDomainPublic() == null)
p.setDomainPublic("[related to]"); p.setDomainPublic("[related to]");
p.setPickListName(getWebappDaoFactory().makePickListName(p));
if (op.getDomain() != null) if (op.getDomain() != null)
p.setDomainVClassURI( (op.getDomain().isAnon()) ? PSEUDO_BNODE_NS+op.getDomain().getId().toString() : op.getDomain().getURI()); p.setDomainVClassURI( (op.getDomain().isAnon()) ? PSEUDO_BNODE_NS+op.getDomain().getId().toString() : op.getDomain().getURI());
if (op.getRange() != null) if (op.getRange() != null)

View file

@ -75,50 +75,27 @@ public class VClassJena extends VClass {
} }
@Override @Override
public String getLocalNameWithPrefix() { public String getLabel() {
return getName();
}
@Override
public String getLocalNameWithPrefix() {
if (this.localNameWithPrefix != null) { if (this.localNameWithPrefix != null) {
return localNameWithPrefix; return localNameWithPrefix;
} else { } else {
cls.getOntModel().enterCriticalSection(Lock.READ); this.localNameWithPrefix = webappDaoFactory.makeLocalNameWithPrefix(this);
try {
VClassDao vClassDao = webappDaoFactory.getVClassDao();
if (vClassDao instanceof VClassDaoJena) {
this.localNameWithPrefix = ((VClassDaoJena) vClassDao).getLabelForClass(cls,true,false);
} else {
log.error("WebappDaoFactory returned a type of " + vClassDao.getClass().getName() + ". Expected VClassDaoJena");
this.localNameWithPrefix = webappDaoFactory.getJenaBaseDao().getLabelOrId(cls);
}
return this.localNameWithPrefix; return this.localNameWithPrefix;
} finally {
cls.getOntModel().leaveCriticalSection();
}
} }
} }
@Override @Override
public String getPickListName() { public String getPickListName() {
if (this.pickListName != null) { if (this.pickListName != null) {
return pickListName; return pickListName;
} else { } else {
cls.getOntModel().enterCriticalSection(Lock.READ); this.pickListName = webappDaoFactory.makePickListName(this);
try {
VClassDao vClassDao = webappDaoFactory.getVClassDao();
if (vClassDao instanceof VClassDaoJena) {
this.pickListName = ((VClassDaoJena) vClassDao).getLabelForClass(cls,false,true);
} else {
log.error("WebappDaoFactory returned a type of " + vClassDao.getClass().getName() + ". Expected VClassDaoJena");
this.pickListName = webappDaoFactory.getJenaBaseDao().getLabelOrId(cls);
}
return this.pickListName; return this.pickListName;
} finally {
cls.getOntModel().leaveCriticalSection();
}
} }
} }

View file

@ -9,6 +9,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.iri.IRI; import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory; import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
@ -20,14 +23,12 @@ import com.hp.hpl.jena.query.DatasetFactory;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator; import com.hp.hpl.jena.util.iterator.ClosableIterator;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.beans.ResourceBean;
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao; import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
@ -44,6 +45,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao; import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener; import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
@ -53,6 +55,8 @@ import edu.cornell.mannlib.vitro.webapp.utils.jena.URIUtils;
public class WebappDaoFactoryJena implements WebappDaoFactory { public class WebappDaoFactoryJena implements WebappDaoFactory {
private static final Log log = LogFactory.getLog(WebappDaoFactoryJena.class);
protected IndividualDao entityWebappDao; protected IndividualDao entityWebappDao;
protected ApplicationDaoJena applicationDao; protected ApplicationDaoJena applicationDao;
protected UserAccountsDao userAccountsDao; protected UserAccountsDao userAccountsDao;
@ -533,4 +537,43 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
} }
public String makeLocalNameWithPrefix(ResourceBean bean) {
OntologyDao oDao = this.getOntologyDao();
Ontology o = oDao.getOntologyByURI(bean.getNamespace());
if (o == null) {
if (VitroVocabulary.vitroURI.equals(bean.getNamespace())) {
return "vitro:" + bean.getLocalName();
} else {
log.debug("no ontology object found for namespace " + bean.getNamespace());
return bean.getLocalName();
}
} else {
String prefix = o.getPrefix() == null ? (
o.getName() == null ?
"unspec" : o.getName()) : o.getPrefix();
return prefix + ":" + bean.getLocalName();
}
}
public String makePickListName(ResourceBean bean) {
OntologyDao oDao = this.getOntologyDao();
Ontology o = oDao.getOntologyByURI(bean.getNamespace());
String label = (bean.getLabel() != null) ? bean.getLabel () : bean.getLocalName();
label = (label != null) ? label : bean.getURI();
if (o == null) {
if (VitroVocabulary.vitroURI.equals(bean.getNamespace())) {
return label + " (vitro)";
} else {
log.debug("no ontology object found for namespace " + bean.getNamespace());
return label;
}
} else {
String prefix = o.getPrefix() == null ? (
o.getName() == null ?
"unspec" : o.getName()) : o.getPrefix();
return label + " (" + prefix + ")";
}
}
} }

View file

@ -14,6 +14,8 @@ import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
@ -58,7 +60,8 @@ public class SelectListGeneratorVTwo {
//Methods to sort the options map //Methods to sort the options map
// from http://forum.java.sun.com/thread.jspa?threadID=639077&messageID=4250708 // from http://forum.java.sun.com/thread.jspa?threadID=639077&messageID=4250708
//Modified to allow for a custom comparator to be sent in, defaults to mapPairsComparator //Modified to allow for a custom comparator to be sent in, defaults to mapPairsComparator
public static Map<String,String> getSortedMap(Map<String,String> hmap, Comparator<String[]> comparator){ public static Map<String,String> getSortedMap(Map<String,String> hmap,
Comparator<String[]> comparator, VitroRequest vreq){
// first make temporary list of String arrays holding both the key and its corresponding value, so that the list can be sorted with a decent comparator // first make temporary list of String arrays holding both the key and its corresponding value, so that the list can be sorted with a decent comparator
List<String[]> objectsToSort = new ArrayList<String[]>(hmap.size()); List<String[]> objectsToSort = new ArrayList<String[]>(hmap.size());
for (String key:hmap.keySet()) { for (String key:hmap.keySet()) {
@ -70,7 +73,7 @@ public class SelectListGeneratorVTwo {
//if no comparator is passed in, utilize MapPairsComparator //if no comparator is passed in, utilize MapPairsComparator
if(comparator == null) { if(comparator == null) {
comparator = new MapPairsComparator(); comparator = new MapPairsComparator(vreq);
} }
Collections.sort(objectsToSort, comparator); Collections.sort(objectsToSort, comparator);
@ -84,8 +87,13 @@ public class SelectListGeneratorVTwo {
//Sorts by the value of the 2nd element in each of the arrays //Sorts by the value of the 2nd element in each of the arrays
private static class MapPairsComparator implements Comparator<String[]> { private static class MapPairsComparator implements Comparator<String[]> {
private Collator collator;
public MapPairsComparator(VitroRequest vreq) {
this.collator = vreq.getCollator();
}
public int compare (String[] s1, String[] s2) { public int compare (String[] s1, String[] s2) {
Collator collator = Collator.getInstance();
if (s2 == null) { if (s2 == null) {
return 1; return 1;
} else if (s1 == null) { } else if (s1 == null) {

View file

@ -6,7 +6,10 @@ import static edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetup
import static edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase.JENA_INF_MODEL; import static edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase.JENA_INF_MODEL;
import java.io.IOException; import java.io.IOException;
import java.text.Collator;
import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.servlet.Filter; import javax.servlet.Filter;
@ -154,6 +157,8 @@ public class RequestModelsPrep implements Filter {
wrapModelsWithLanguageAwareness(vreq); wrapModelsWithLanguageAwareness(vreq);
setCollator(vreq);
setWebappDaoFactories(vreq, rdfService); setWebappDaoFactories(vreq, rdfService);
} }
@ -309,9 +314,19 @@ public class RequestModelsPrep implements Filter {
return config; return config;
} }
/**
* This method is also used by VitroHttpServlet to retrieve the right Collator
* instance for picklist sorting
* @param req
* @return
*/
public static Enumeration<Locale> getPreferredLocales(HttpServletRequest req) {
return req.getLocales();
}
private List<String> getPreferredLanguages(HttpServletRequest req) { private List<String> getPreferredLanguages(HttpServletRequest req) {
log.debug("Accept-Language: " + req.getHeader("Accept-Language")); log.debug("Accept-Language: " + req.getHeader("Accept-Language"));
return LanguageFilteringUtils.localesToLanguages(req.getLocales()); return LanguageFilteringUtils.localesToLanguages(getPreferredLocales(req));
} }
/** /**
@ -332,6 +347,19 @@ public class RequestModelsPrep implements Filter {
} }
} }
private void setCollator(VitroRequest vreq) {
Enumeration<Locale> locales = getPreferredLocales(vreq);
while(locales.hasMoreElements()) {
Locale locale = locales.nextElement();
Collator collator = Collator.getInstance(locale);
if(collator != null) {
vreq.setCollator(collator);
return;
}
}
vreq.setCollator(Collator.getInstance());
}
private boolean isStoreReasoned(ServletRequest req) { private boolean isStoreReasoned(ServletRequest req) {
String isStoreReasoned = ConfigurationProperties.getBean(req).getProperty( String isStoreReasoned = ConfigurationProperties.getBean(req).getProperty(
"VitroConnection.DataSource.isStoreReasoned", "true"); "VitroConnection.DataSource.isStoreReasoned", "true");

View file

@ -43,7 +43,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
import edu.cornell.mannlib.vitro.webapp.i18n.I18n; import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
import edu.cornell.mannlib.vitro.webapp.search.IndexConstants; import edu.cornell.mannlib.vitro.webapp.search.IndexConstants;
import edu.cornell.mannlib.vitro.webapp.search.SearchException; import edu.cornell.mannlib.vitro.webapp.search.SearchException;
@ -250,7 +252,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
if( wasHtmlRequested ){ if( wasHtmlRequested ){
if ( !classGroupFilterRequested && !typeFilterRequested ) { if ( !classGroupFilterRequested && !typeFilterRequested ) {
// Search request includes no ClassGroup and no type, so add ClassGroup search refinement links. // Search request includes no ClassGroup and no type, so add ClassGroup search refinement links.
body.put("classGroupLinks", getClassGroupsLinks(grpDao, docs, response, queryText)); body.put("classGroupLinks", getClassGroupsLinks(vreq, grpDao, docs, response, queryText));
} else if ( classGroupFilterRequested && !typeFilterRequested ) { } else if ( classGroupFilterRequested && !typeFilterRequested ) {
// Search request is for a ClassGroup, so add rdf:type search refinement links // Search request is for a ClassGroup, so add rdf:type search refinement links
// but try to filter out classes that are subclasses // but try to filter out classes that are subclasses
@ -354,7 +356,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
* Get the class groups represented for the individuals in the documents. * Get the class groups represented for the individuals in the documents.
* @param qtxt * @param qtxt
*/ */
private List<VClassGroupSearchLink> getClassGroupsLinks(VClassGroupDao grpDao, SolrDocumentList docs, QueryResponse rsp, String qtxt) { private List<VClassGroupSearchLink> getClassGroupsLinks(VitroRequest vreq, VClassGroupDao grpDao, SolrDocumentList docs, QueryResponse rsp, String qtxt) {
Map<String,Long> cgURItoCount = new HashMap<String,Long>(); Map<String,Long> cgURItoCount = new HashMap<String,Long>();
List<VClassGroup> classgroups = new ArrayList<VClassGroup>( ); List<VClassGroup> classgroups = new ArrayList<VClassGroup>( );
@ -376,11 +378,14 @@ public class PagedSearchController extends FreemarkerHttpServlet {
grpDao.sortGroupList(classgroups); grpDao.sortGroupList(classgroups);
VClassGroupsForRequest vcgfr = VClassGroupCache.getVClassGroups(vreq);
List<VClassGroupSearchLink> classGroupLinks = new ArrayList<VClassGroupSearchLink>(classgroups.size()); List<VClassGroupSearchLink> classGroupLinks = new ArrayList<VClassGroupSearchLink>(classgroups.size());
for (VClassGroup vcg : classgroups) { for (VClassGroup vcg : classgroups) {
long count = cgURItoCount.get( vcg.getURI() ); String groupURI = vcg.getURI();
if (vcg.getPublicName() != null && count > 0 ) { VClassGroup localizedVcg = vcgfr.getGroup(groupURI);
classGroupLinks.add(new VClassGroupSearchLink(qtxt, vcg, count)); long count = cgURItoCount.get( groupURI );
if (localizedVcg.getPublicName() != null && count > 0 ) {
classGroupLinks.add(new VClassGroupSearchLink(qtxt, localizedVcg, count));
} }
} }
return classGroupLinks; return classGroupLinks;
@ -507,7 +512,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
return query; return query;
} }
public class VClassGroupSearchLink extends LinkTemplateModel { public static class VClassGroupSearchLink extends LinkTemplateModel {
long count = 0; long count = 0;
VClassGroupSearchLink(String querytext, VClassGroup classgroup, long count) { VClassGroupSearchLink(String querytext, VClassGroup classgroup, long count) {
super(classgroup.getPublicName(), "/search", PARAM_QUERY_TEXT, querytext, PARAM_CLASSGROUP, classgroup.getURI()); super(classgroup.getPublicName(), "/search", PARAM_QUERY_TEXT, querytext, PARAM_CLASSGROUP, classgroup.getURI());
@ -517,7 +522,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
public String getCount() { return Long.toString(count); } public String getCount() { return Long.toString(count); }
} }
public class VClassSearchLink extends LinkTemplateModel { public static class VClassSearchLink extends LinkTemplateModel {
long count = 0; long count = 0;
VClassSearchLink(String querytext, VClass type, long count) { VClassSearchLink(String querytext, VClass type, long count) {
super(type.getName(), "/search", PARAM_QUERY_TEXT, querytext, PARAM_RDFTYPE, type.getURI()); super(type.getName(), "/search", PARAM_QUERY_TEXT, querytext, PARAM_RDFTYPE, type.getURI());

View file

@ -72,7 +72,7 @@ public class GetAllPrefix extends BaseEditController {
respo += "<options>"; respo += "<options>";
List<String> prefixList = new ArrayList<String>(); List<String> prefixList = new ArrayList<String>();
prefixList.addAll(prefixMap.keySet()); prefixList.addAll(prefixMap.keySet());
Collections.sort(prefixList, Collator.getInstance()); Collections.sort(prefixList, vreq.getCollator());
for (String prefix : prefixList) { for (String prefix : prefixList) {
respo += makeOption(prefix, prefixMap.get(prefix)); respo += makeOption(prefix, prefixMap.get(prefix));
} }

View file

@ -103,7 +103,7 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
field.setOptions(new ConstantFieldOptions()); field.setOptions(new ConstantFieldOptions());
} }
Map<String, String> optionsMap = SelectListGeneratorVTwo.getOptions(editConfig, fieldName, wdf); Map<String, String> optionsMap = SelectListGeneratorVTwo.getOptions(editConfig, fieldName, wdf);
optionsMap = SelectListGeneratorVTwo.getSortedMap(optionsMap, field.getFieldOptions().getCustomComparator()); optionsMap = SelectListGeneratorVTwo.getSortedMap(optionsMap, field.getFieldOptions().getCustomComparator(), vreq);
if(pageData.containsKey(fieldName)) { if(pageData.containsKey(fieldName)) {
log.error("Check the edit configuration setup as pageData already contains " + fieldName + " and this will be overwritten now with empty collection"); log.error("Check the edit configuration setup as pageData already contains " + fieldName + " and this will be overwritten now with empty collection");
} }

View file

@ -1,23 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.edit;
import junit.framework.Assert;
import org.junit.Test;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
public class IndividualTypeRetryControllerTest extends AbstractTestClass {
@Test
public void optionCollator(){
IndividualTypeRetryController.OptionCollator oc = new IndividualTypeRetryController.OptionCollator();
int comp = oc.compare(
new Option("foo", "foo"),
new Option("Person", "foaf:Person") );
//we just want compare() to not throw an exception
}
}

View file

@ -74,14 +74,14 @@ public class UrlBuilderTest extends AbstractTestClass {
UrlBuilder.contextPath = "/vivo"; UrlBuilder.contextPath = "/vivo";
String path = "/individual"; String path = "/individual";
ParamMap params = new ParamMap(); ParamMap params = new ParamMap();
params.put("name", "★Tom★"); params.put("name", "\u2605Tom\u2605"); // \u2605 is Unicode for a five-pointed star.
Assert.assertEquals("/vivo/individual?name=%E2%98%85Tom%E2%98%85", UrlBuilder.getUrl(path, params)); Assert.assertEquals("/vivo/individual?name=%E2%98%85Tom%E2%98%85", UrlBuilder.getUrl(path, params));
} }
@Test @Test
public void testDecodeUtf8Url() { public void testDecodeUtf8Url() {
String vClassUri = "http://vivoweb.org/ontology/core#FacultyMember"; String vClassUri = "http://vivoweb.org/ontology/core#FacultyMember\u2605"; // \u2605 is Unicode for a five-pointed star.
String vClassUriEncoded = "http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23FacultyMember%E2%98%85"; String vClassUriEncoded = "http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23FacultyMember%E2%98%85";
Assert.assertEquals(vClassUri, UrlBuilder.urlDecode(vClassUriEncoded)); Assert.assertEquals(vClassUri, UrlBuilder.urlDecode(vClassUriEncoded));
} }
@ -94,11 +94,11 @@ public class UrlBuilderTest extends AbstractTestClass {
String uri = "http://example.com/individual/n2343"; String uri = "http://example.com/individual/n2343";
String url = UrlBuilder.getIndividualProfileUrl(uri, vreq); String url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
Assert.assertEquals("http://example.com/individual/n2343", url); Assert.assertEquals("http://example.com/display/n2343", url);
uri = "http://example.com/individual/bob"; uri = "http://example.com/individual/bob";
url = UrlBuilder.getIndividualProfileUrl(uri, vreq); url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
Assert.assertEquals("http://example.com/individual/bob",url); Assert.assertEquals("http://example.com/display/bob",url);
uri = "http://nondefaultNS.com/individual/n2343"; uri = "http://nondefaultNS.com/individual/n2343";
url = UrlBuilder.getIndividualProfileUrl(uri, vreq); url = UrlBuilder.getIndividualProfileUrl(uri, vreq);

View file

@ -113,6 +113,7 @@ public class VClassJenaTest {
Assert.assertEquals(vClassJena.getName(), vClass.getName()); Assert.assertEquals(vClassJena.getName(), vClass.getName());
Assert.assertEquals(vClassJena.getLocalNameWithPrefix(), vClass.getLocalNameWithPrefix()); Assert.assertEquals(vClassJena.getLocalNameWithPrefix(), vClass.getLocalNameWithPrefix());
Assert.assertEquals(vClassJena.getPickListName(), vClass.getPickListName()); Assert.assertEquals(vClassJena.getPickListName(), vClass.getPickListName());
Assert.assertEquals(vClassJena.getExample(), vClass.getExample()); Assert.assertEquals(vClassJena.getExample(), vClass.getExample());
Assert.assertEquals(vClassJena.getDescription(), vClass.getDescription()); Assert.assertEquals(vClassJena.getDescription(), vClass.getDescription());
@ -162,7 +163,7 @@ public class VClassJenaTest {
VClass vcw = new VClass(); VClass vcw = new VClass();
cls.getModel().enterCriticalSection(Lock.READ); cls.getModel().enterCriticalSection(Lock.READ);
vcw.setName(getLabelForClass(cls,false,false,wadf)); vcw.setName(getLabelForClass(cls,false,false,wadf));
vcw.setLocalNameWithPrefix(getLabelForClass(cls,true,false,wadf)); vcw.setLocalNameWithPrefix(wadf.makeLocalNameWithPrefix(vcw));
vcw.setPickListName(getLabelForClass(cls,false,true,wadf)); vcw.setPickListName(getLabelForClass(cls,false,true,wadf));
try { try {
if (cls.isAnon()) { if (cls.isAnon()) {
@ -233,18 +234,6 @@ public class VClassJenaTest {
} }
vcw.setProhibitedFromUpdateBelowRoleLevel(prohibitedRoleLevel);//this might get set to null vcw.setProhibitedFromUpdateBelowRoleLevel(prohibitedRoleLevel);//this might get set to null
// We need a better way of caching the counts. For now I'm only setting 0 for the empty classes, to hide them from the DWR editing
//ClosableIterator typeIt = getOntModel().listStatements(null,RDF.type,cls);
//try {
// if (!typeIt.hasNext()) {
// vcw.setEntityCount(0);
// }
//} finally {
// typeIt.close();
//}
} finally { } finally {
cls.getModel().leaveCriticalSection(); cls.getModel().leaveCriticalSection();
} }

View file

@ -82,6 +82,16 @@ public class IndividualStub implements Individual {
return name; return name;
} }
@Override
public String getLabel() {
return getName();
}
@Override
public String getPickListName() {
return getName();
}
@Override @Override
public List<DataPropertyStatement> getDataPropertyStatements() { public List<DataPropertyStatement> getDataPropertyStatements() {
return new ArrayList<DataPropertyStatement>(dpsSet); return new ArrayList<DataPropertyStatement>(dpsSet);

View file

@ -77,7 +77,7 @@
<input type="hidden" name="VClassName" value="this anonymous class"/> <input type="hidden" name="VClassName" value="this anonymous class"/>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<input type="hidden" name="VClassName" value="${VClass.localNameWithPrefix}"/> <input type="hidden" name="VClassName" value="${VClass.pickListName}"/>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<input type="hidden" name="mode" value="moveInstances"/> <input type="hidden" name="mode" value="moveInstances"/>
@ -99,10 +99,10 @@
<li><input type="checkbox" name="SuperclassURI" value="${superclass.URI}" class="form-item"/> <li><input type="checkbox" name="SuperclassURI" value="${superclass.URI}" class="form-item"/>
<c:choose> <c:choose>
<c:when test="${!superclass.anonymous}"> <c:when test="${!superclass.anonymous}">
<a href="${superclassURL}">${superclass.localNameWithPrefix}</a> <a href="${superclassURL}">${superclass.pickListName}</a>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
${superclass.localNameWithPrefix} ${superclass.pickListName}
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</li> </li>
@ -137,10 +137,10 @@
<li><input type="checkbox" name="SubclassURI" value="${subclass.URI}" class="form-item"/> <li><input type="checkbox" name="SubclassURI" value="${subclass.URI}" class="form-item"/>
<c:choose> <c:choose>
<c:when test="${!subclass.anonymous}"> <c:when test="${!subclass.anonymous}">
<a href="${subclassURL}"> ${subclass.localNameWithPrefix} </a> <a href="${subclassURL}"> ${subclass.pickListName} </a>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
${subclass.localNameWithPrefix} ${subclass.pickListName}
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</li> </li>
@ -181,10 +181,10 @@
<li><input type="checkbox" name="SubclassURI" value="${subclass.URI}" class="form-item"/> <li><input type="checkbox" name="SubclassURI" value="${subclass.URI}" class="form-item"/>
<c:choose> <c:choose>
<c:when test="${!subclass.anonymous}"> <c:when test="${!subclass.anonymous}">
<a href="${subclassURL}"> ${subclass.localNameWithPrefix} </a> <a href="${subclassURL}"> ${subclass.pickListName} </a>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
${subclass.localNameWithPrefix} ${subclass.pickListName}
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</li> </li>
@ -223,10 +223,10 @@
<li><input type="checkbox" name="SubclassURI" value="${subclass.URI}" class="form-item"/> <li><input type="checkbox" name="SubclassURI" value="${subclass.URI}" class="form-item"/>
<c:choose> <c:choose>
<c:when test="${!subclass.anonymous}"> <c:when test="${!subclass.anonymous}">
<a href="${subclassURL}"> ${subclass.localNameWithPrefix} </a> <a href="${subclassURL}"> ${subclass.pickListName} </a>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
${subclass.localNameWithPrefix} ${subclass.pickListName}
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</li> </li>

View file

@ -81,7 +81,7 @@
<c:param name="uri" value="${superproperty.URI}"/> <c:param name="uri" value="${superproperty.URI}"/>
</c:url> </c:url>
<li><input type="checkbox" name="SuperpropertyURI" value="${superproperty.URI}" class="form-item"/> <li><input type="checkbox" name="SuperpropertyURI" value="${superproperty.URI}" class="form-item"/>
<a href="${superpropertyURL}">${superproperty.localNameWithPrefix}</a> <a href="${superpropertyURL}">${superproperty.pickListName}</a>
</li> </li>
</c:forEach> </c:forEach>
</ul> </ul>
@ -114,7 +114,7 @@
<c:param name="uri" value="${subproperty.URI}"/> <c:param name="uri" value="${subproperty.URI}"/>
</c:url> </c:url>
<li><input type="checkbox" name="SubpropertyURI" value="${subproperty.URI}" class="form-item"/> <li><input type="checkbox" name="SubpropertyURI" value="${subproperty.URI}" class="form-item"/>
<a href="${subpropertyURL}"> ${subproperty.localNameWithPrefix} </a> <a href="${subpropertyURL}"> ${subproperty.pickListName} </a>
</li> </li>
</c:forEach> </c:forEach>
</ul> </ul>
@ -147,7 +147,7 @@
<c:param name="uri" value="${eqproperty.URI}"/> <c:param name="uri" value="${eqproperty.URI}"/>
</c:url> </c:url>
<li><input type="checkbox" name="SubpropertyURI" value="${eqproperty.URI}" class="form-item"/> <li><input type="checkbox" name="SubpropertyURI" value="${eqproperty.URI}" class="form-item"/>
<a href="${eqpropertyURL}"> ${eqproperty.localNameWithPrefix} </a> <a href="${eqpropertyURL}"> ${eqproperty.pickListName} </a>
</li> </li>
</c:forEach> </c:forEach>
</ul> </ul>

View file

@ -103,7 +103,7 @@
<c:param name="uri" value="${superproperty.URI}"/> <c:param name="uri" value="${superproperty.URI}"/>
</c:url> </c:url>
<li><input type="checkbox" name="SuperpropertyURI" value="${superproperty.URI}" class="form-item"/> <li><input type="checkbox" name="SuperpropertyURI" value="${superproperty.URI}" class="form-item"/>
<a href="${superpropertyURL}">${superproperty.localNameWithPrefix}</a> <a href="${superpropertyURL}">${superproperty.pickListName}</a>
</li> </li>
</c:forEach> </c:forEach>
</ul> </ul>
@ -135,7 +135,7 @@
<c:param name="uri" value="${subproperty.URI}"/> <c:param name="uri" value="${subproperty.URI}"/>
</c:url> </c:url>
<li><input type="checkbox" name="SubpropertyURI" value="${subproperty.URI}" class="form-item"/> <li><input type="checkbox" name="SubpropertyURI" value="${subproperty.URI}" class="form-item"/>
<a href="${subpropertyURL}"> ${subproperty.localNameWithPrefix} </a> <a href="${subpropertyURL}"> ${subproperty.pickListName} </a>
</li> </li>
</c:forEach> </c:forEach>
</ul> </ul>
@ -172,7 +172,7 @@
<c:param name="uri" value="${eqproperty.URI}"/> <c:param name="uri" value="${eqproperty.URI}"/>
</c:url> </c:url>
<li><input type="checkbox" name="SubpropertyURI" value="${eqproperty.URI}" class="form-item"/> <li><input type="checkbox" name="SubpropertyURI" value="${eqproperty.URI}" class="form-item"/>
<a href="${eqpropertyURL}"> ${eqproperty.localNameWithPrefix} </a> <a href="${eqpropertyURL}"> ${eqproperty.pickListName} </a>
</li> </li>
</c:forEach> </c:forEach>
</ul> </ul>