Merge branch 'develop' of github.com:vivo-project/Vitro into develop
This commit is contained in:
commit
6604b58f7c
10 changed files with 283 additions and 313 deletions
|
@ -34,8 +34,10 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.edit.utils.RoleLevelOptionsSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
|
||||
public class DatapropRetryController extends BaseEditController {
|
||||
|
@ -54,11 +56,12 @@ public class DatapropRetryController extends BaseEditController {
|
|||
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
|
||||
DatatypeDao dDao = vreq.getUnfilteredWebappDaoFactory().getDatatypeDao();
|
||||
DataPropertyDao dpDao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao();
|
||||
WebappDaoFactory wadf = ModelAccess.on(getServletContext()).getWebappDaoFactory();
|
||||
|
||||
DatatypeDao dDao = wadf.getDatatypeDao();
|
||||
DataPropertyDao dpDao = wadf.getDataPropertyDao();
|
||||
epo.setDataAccessObject(dpDao);
|
||||
OntologyDao ontDao = vreq.getUnfilteredWebappDaoFactory().getOntologyDao();
|
||||
VClassDao vclassDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
|
||||
DataProperty objectForEditing = null;
|
||||
String action = null;
|
||||
|
|
|
@ -2,17 +2,12 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -26,6 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
|
||||
public class ListClassGroupsController extends FreemarkerHttpServlet {
|
||||
|
@ -64,12 +60,10 @@ public class ListClassGroupsController extends FreemarkerHttpServlet {
|
|||
if ( StringUtils.isBlank(publicName) ) {
|
||||
publicName = "(unnamed group)";
|
||||
}
|
||||
publicName = publicName.replace("\"","\\\"");
|
||||
publicName = publicName.replace("\'","\\\'");
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI(),"UTF-8")+"&controller=Classgroup'>"+publicName+"</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI())+"&controller=Classgroup'>"+publicName+"</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + publicName + "\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote(publicName) + ", ";
|
||||
}
|
||||
Integer t;
|
||||
|
||||
|
@ -83,18 +77,16 @@ public class ListClassGroupsController extends FreemarkerHttpServlet {
|
|||
VClass vcw = classIt.next();
|
||||
if (vcw.getName() != null && vcw.getURI() != null) {
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"'>"+vcw.getName()+"</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI())+"'>"+vcw.getName()+"</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "\"" + vcw.getName() + "\", ";
|
||||
json += "" + JSONUtils.quote(vcw.getName()) + ", ";
|
||||
}
|
||||
} else {
|
||||
json += "\"\", ";
|
||||
}
|
||||
|
||||
String shortDefStr = (vcw.getShortDef() == null) ? "" : vcw.getShortDef();
|
||||
shortDefStr = shortDefStr.replace("\"","\\\"");
|
||||
shortDefStr = shortDefStr.replace("\'","\\\'");
|
||||
json += "\"data\": { \"shortDef\": \"" + shortDefStr + "\"}, \"children\": [] ";
|
||||
json += "\"data\": { \"shortDef\": " + JSONUtils.quote(shortDefStr) + "}, \"children\": [] ";
|
||||
if (classIt.hasNext())
|
||||
json += "} , ";
|
||||
else
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -13,8 +11,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -25,7 +22,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -33,7 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
|
||||
|
||||
|
@ -112,15 +108,14 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName();
|
||||
nameStr = nameStr.replace("\"","\\\"");
|
||||
nameStr = nameStr.replace("\'","\\\'");
|
||||
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='datapropEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>" + nameStr + "</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='datapropEdit?uri="+ URLEncoder.encode(prop.getURI())+"'>" + nameStr + "</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + nameStr + "\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote(nameStr) + ", ";
|
||||
}
|
||||
|
||||
json += "\"data\": { \"internalName\": \"" + prop.getLocalNameWithPrefix() + "\", ";
|
||||
json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", ";
|
||||
|
||||
/* VClass vc = null;
|
||||
String domainStr="";
|
||||
|
@ -137,15 +132,15 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
|
|||
*/
|
||||
VClass vc = (prop.getDomainClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainClassURI()) : null;
|
||||
String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : "";
|
||||
json += "\"domainVClass\": \"" + domainStr + "\", " ;
|
||||
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
|
||||
|
||||
Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI());
|
||||
String rangeDatatypeStr = (rangeDatatype==null)?prop.getRangeDatatypeURI():rangeDatatype.getName();
|
||||
json += "\"rangeVClass\": \"" + rangeDatatypeStr + "\", " ;
|
||||
json += "\"rangeVClass\": " + JSONUtils.quote(rangeDatatypeStr) + ", " ;
|
||||
|
||||
if (prop.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
||||
json += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" } } " ;
|
||||
json += "\"group\": " + JSONUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ;
|
||||
} else {
|
||||
json += "\"group\": \"unspecified\" } }" ;
|
||||
}
|
||||
|
|
|
@ -3,29 +3,23 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -70,12 +64,10 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
|
|||
if ( StringUtils.isBlank(publicName) ) {
|
||||
publicName = "(unnamed group)";
|
||||
}
|
||||
publicName = publicName.replace("\"","\\\"");
|
||||
publicName = publicName.replace("\'","\\\'");
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./editForm?uri="+URLEncoder.encode(pg.getURI(),"UTF-8")+"&controller=PropertyGroup'>" + publicName + "</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(pg.getURI(),"UTF-8")+"&controller=PropertyGroup'>" + publicName + "</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + publicName + "\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote(publicName) + ", ";
|
||||
}
|
||||
Integer t;
|
||||
|
||||
|
@ -100,10 +92,10 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
|
|||
}
|
||||
if (prop.getURI() != null) {
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='" + controllerStr
|
||||
+ "?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"+ nameStr +"</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='" + controllerStr
|
||||
+ "?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"+ nameStr +"</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "\"" + nameStr + "\", ";
|
||||
json += JSONUtils.quote(nameStr) + ", ";
|
||||
}
|
||||
} else {
|
||||
json += "\"\", ";
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -12,8 +11,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -25,7 +23,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -35,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
||||
private static Log log = LogFactory.getLog( ListPropertyWebappsController.class );
|
||||
|
@ -67,7 +65,7 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
|
||||
String vclassURI = vreq.getParameter("vclassUri");
|
||||
|
||||
List props = new ArrayList();
|
||||
List<ObjectProperty> props = new ArrayList<ObjectProperty>();
|
||||
if (vreq.getParameter("propsForClass") != null) {
|
||||
noResultsMsgStr = "There are no object properties that apply to this class.";
|
||||
|
||||
|
@ -87,8 +85,8 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
propInsts.addAll(propInstMap.values());
|
||||
Collections.sort(propInsts);
|
||||
|
||||
Iterator propInstIt = propInsts.iterator();
|
||||
HashSet propURIs = new HashSet();
|
||||
Iterator<PropertyInstance> propInstIt = propInsts.iterator();
|
||||
HashSet<String> propURIs = new HashSet<String>();
|
||||
while (propInstIt.hasNext()) {
|
||||
PropertyInstance pi = (PropertyInstance) propInstIt.next();
|
||||
if (!(propURIs.contains(pi.getPropertyURI()))) {
|
||||
|
@ -108,13 +106,13 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
OntologyDao oDao = vreq.getUnfilteredWebappDaoFactory().getOntologyDao();
|
||||
HashMap<String,String> ontologyHash = new HashMap<String,String>();
|
||||
|
||||
Iterator propIt = props.iterator();
|
||||
List<ObjectProperty> scratch = new ArrayList();
|
||||
Iterator<ObjectProperty> propIt = props.iterator();
|
||||
List<ObjectProperty> scratch = new ArrayList<ObjectProperty>();
|
||||
while (propIt.hasNext()) {
|
||||
ObjectProperty p = (ObjectProperty) propIt.next();
|
||||
if (p.getNamespace()!=null) {
|
||||
ObjectProperty p = propIt.next();
|
||||
if (p.getNamespace() != null) {
|
||||
if( !ontologyHash.containsKey( p.getNamespace() )){
|
||||
Ontology o = (Ontology)oDao.getOntologyByURI(p.getNamespace());
|
||||
Ontology o = oDao.getOntologyByURI(p.getNamespace());
|
||||
if (o==null) {
|
||||
if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) {
|
||||
log.debug("doGet(): no ontology object found for the namespace "+p.getNamespace());
|
||||
|
@ -144,36 +142,35 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
if (props.size()==0) {
|
||||
json = "{ \"name\": \"" + noResultsMsgStr + "\" }";
|
||||
} else {
|
||||
Iterator propsIt = props.iterator();
|
||||
Iterator<ObjectProperty> propsIt = props.iterator();
|
||||
while (propsIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
json += ", ";
|
||||
}
|
||||
ObjectProperty prop = (ObjectProperty) propsIt.next();
|
||||
ObjectProperty prop = propsIt.next();
|
||||
|
||||
String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop);
|
||||
propNameStr = propNameStr.replace("\"","\\\"");
|
||||
propNameStr = propNameStr.replace("\'","\\\'");
|
||||
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./propertyEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"
|
||||
+ propNameStr + "</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='./propertyEdit?uri="+URLEncoder.encode(prop.getURI())+"'>"
|
||||
+ propNameStr + "</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + propNameStr + "\", ";
|
||||
}
|
||||
|
||||
json += "\"data\": { \"internalName\": \"" + prop.getLocalNameWithPrefix() + "\", ";
|
||||
json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", ";
|
||||
|
||||
VClass vc = (prop.getDomainVClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainVClassURI()) : null;
|
||||
String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : "";
|
||||
json += "\"domainVClass\": \"" + domainStr + "\", " ;
|
||||
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
|
||||
|
||||
vc = (prop.getRangeVClassURI() != null) ? vcDao.getVClassByURI(prop.getRangeVClassURI()) : null;
|
||||
String rangeStr = (vc != null) ? vc.getLocalNameWithPrefix() : "";
|
||||
json += "\"rangeVClass\": \"" + rangeStr + "\", " ;
|
||||
json += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", " ;
|
||||
|
||||
if (prop.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
||||
json += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" } } " ;
|
||||
json += "\"group\": " + JSONUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ;
|
||||
} else {
|
||||
json += "\"group\": \"unspecified\" } }" ;
|
||||
}
|
||||
|
|
|
@ -3,30 +3,22 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -52,87 +44,80 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
|
|||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
try {
|
||||
|
||||
body.put("displayOption", "all");
|
||||
body.put("pageTitle", "All Classes");
|
||||
body.put("displayOption", "all");
|
||||
body.put("pageTitle", "All Classes");
|
||||
|
||||
List<VClass> classes = null;
|
||||
List<VClass> classes = null;
|
||||
|
||||
if (vreq.getParameter("showPropertyRestrictions") != null) {
|
||||
PropertyDao pdao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
||||
classes = pdao.getClassesWithRestrictionOnProperty(vreq.getParameter("propertyURI"));
|
||||
} else {
|
||||
VClassDao vcdao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
if (vreq.getParameter("showPropertyRestrictions") != null) {
|
||||
PropertyDao pdao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
||||
classes = pdao.getClassesWithRestrictionOnProperty(vreq.getParameter("propertyURI"));
|
||||
} else {
|
||||
VClassDao vcdao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
|
||||
if (vreq.getParameter("iffRoot") != null) {
|
||||
classes = vcdao.getRootClasses();
|
||||
} else {
|
||||
classes = vcdao.getAllVclasses();
|
||||
}
|
||||
if (vreq.getParameter("iffRoot") != null) {
|
||||
classes = vcdao.getRootClasses();
|
||||
} else {
|
||||
classes = vcdao.getAllVclasses();
|
||||
}
|
||||
|
||||
}
|
||||
String json = new String();
|
||||
int counter = 0;
|
||||
}
|
||||
String json = new String();
|
||||
int counter = 0;
|
||||
|
||||
String ontologyURI = vreq.getParameter("ontologyUri");
|
||||
String ontologyURI = vreq.getParameter("ontologyUri");
|
||||
|
||||
if (classes != null) {
|
||||
Collections.sort(classes);
|
||||
Iterator<VClass> classesIt = classes.iterator();
|
||||
while (classesIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
json += ", ";
|
||||
}
|
||||
VClass cls = (VClass) classesIt.next();
|
||||
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
|
||||
if (cls.getName() != null)
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getLocalNameWithPrefix()+"</a>\", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + cls.getLocalNameWithPrefix() + "\", ";
|
||||
}
|
||||
else
|
||||
json += "{ \"name\": \"\"";
|
||||
String shortDef = (cls.getShortDef()==null) ? "" : cls.getShortDef();
|
||||
|
||||
json += "\"data\": { \"shortDef\": \"" + shortDef + "\", ";
|
||||
|
||||
// get group name
|
||||
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
|
||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
||||
String groupURI = cls.getGroupURI();
|
||||
String groupName = "";
|
||||
VClassGroup classGroup = null;
|
||||
if(groupURI != null) {
|
||||
classGroup = groupDao.getGroupByURI(groupURI);
|
||||
if (classGroup!=null) {
|
||||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
|
||||
json += "\"classGroup\": \"" + groupName + "\", ";
|
||||
|
||||
// get ontology name
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = null;
|
||||
try {
|
||||
Ontology ont = ontDao.getOntologyByURI(cls.getNamespace());
|
||||
ontName = ont.getName();
|
||||
} catch (Exception e) {}
|
||||
ontName = (ontName == null) ? "" : ontName;
|
||||
|
||||
json += "\"ontology\": \"" + ontName + "\"} }";
|
||||
|
||||
counter += 1;
|
||||
|
||||
}
|
||||
if (classes != null) {
|
||||
Collections.sort(classes);
|
||||
Iterator<VClass> classesIt = classes.iterator();
|
||||
while (classesIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
json += ", ";
|
||||
}
|
||||
body.put("jsonTree",json);
|
||||
}
|
||||
VClass cls = (VClass) classesIt.next();
|
||||
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
|
||||
if (cls.getName() != null)
|
||||
try {
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getLocalNameWithPrefix()+"</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": " + JSONUtils.quote(cls.getLocalNameWithPrefix()) + ", ";
|
||||
}
|
||||
else
|
||||
json += "{ \"name\": \"\"";
|
||||
String shortDef = (cls.getShortDef() == null) ? "" : cls.getShortDef();
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
json += "\"data\": { \"shortDef\": " + JSONUtils.quote(shortDef) + ", ";
|
||||
|
||||
// get group name
|
||||
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
|
||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
||||
String groupURI = cls.getGroupURI();
|
||||
String groupName = "";
|
||||
VClassGroup classGroup = null;
|
||||
if(groupURI != null) {
|
||||
classGroup = groupDao.getGroupByURI(groupURI);
|
||||
if (classGroup!=null) {
|
||||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
|
||||
json += "\"classGroup\": " + JSONUtils.quote(groupName) + ", ";
|
||||
|
||||
// get ontology name
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = cls.getNamespace();
|
||||
Ontology ont = ontDao.getOntologyByURI(ontName);
|
||||
if (ont != null && ont.getName() != null) {
|
||||
ontName = ont.getName();
|
||||
}
|
||||
json += "\"ontology\": " + JSONUtils.quote(ontName) + "} }";
|
||||
|
||||
counter++;
|
||||
|
||||
}
|
||||
}
|
||||
body.put("jsonTree",json);
|
||||
}
|
||||
|
||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -50,77 +52,73 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
try {
|
||||
String displayOption = "";
|
||||
|
||||
if ( vreq.getParameter("displayOption") != null ) {
|
||||
displayOption = vreq.getParameter("displayOption");
|
||||
}
|
||||
else {
|
||||
displayOption = "asserted";
|
||||
}
|
||||
String displayOption = "";
|
||||
|
||||
body.put("displayOption", displayOption);
|
||||
boolean inferred = ( displayOption.equals("inferred") );
|
||||
if ( inferred ) {
|
||||
body.put("pageTitle", "Inferred Class Hierarchy");
|
||||
}
|
||||
else {
|
||||
body.put("pageTitle", "Asserted Class Hierarchy");
|
||||
}
|
||||
|
||||
if (!inferred) {
|
||||
vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
||||
} else {
|
||||
vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
}
|
||||
String json = new String();
|
||||
|
||||
String ontologyUri = vreq.getParameter("ontologyUri");
|
||||
String startClassUri = vreq.getParameter("vclassUri");
|
||||
|
||||
List<VClass> roots = null;
|
||||
|
||||
if (ontologyUri != null) {
|
||||
roots = vcDao.getOntologyRootClasses(ontologyUri);
|
||||
} else if (startClassUri != null) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vcDao.getVClassByURI(startClassUri));
|
||||
} else {
|
||||
roots = vcDao.getRootClasses();
|
||||
}
|
||||
|
||||
if (roots.isEmpty()) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vreq.getUnfilteredWebappDaoFactory().getVClassDao()
|
||||
.getTopConcept());
|
||||
}
|
||||
Collections.sort(roots);
|
||||
int counter = 0;
|
||||
|
||||
Iterator rootIt = roots.iterator();
|
||||
if (!rootIt.hasNext()) {
|
||||
VClass vcw = new VClass();
|
||||
vcw.setName("<strong>No classes found.</strong>");
|
||||
json += addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw,0,ontologyUri,counter);
|
||||
} else {
|
||||
while (rootIt.hasNext()) {
|
||||
VClass root = (VClass) rootIt.next();
|
||||
if (root != null) {
|
||||
json += addChildren(vreq.getUnfilteredWebappDaoFactory(), root, 0, ontologyUri,counter);
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
int length = json.length();
|
||||
if ( length > 0 ) {
|
||||
json += " }";
|
||||
}
|
||||
}
|
||||
body.put("jsonTree",json);
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
if ( vreq.getParameter("displayOption") != null ) {
|
||||
displayOption = vreq.getParameter("displayOption");
|
||||
}
|
||||
else {
|
||||
displayOption = "asserted";
|
||||
}
|
||||
|
||||
body.put("displayOption", displayOption);
|
||||
boolean inferred = ( displayOption.equals("inferred") );
|
||||
if ( inferred ) {
|
||||
body.put("pageTitle", "Inferred Class Hierarchy");
|
||||
}
|
||||
else {
|
||||
body.put("pageTitle", "Asserted Class Hierarchy");
|
||||
}
|
||||
|
||||
if (!inferred) {
|
||||
vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
||||
} else {
|
||||
vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
}
|
||||
String json = new String();
|
||||
|
||||
String ontologyUri = vreq.getParameter("ontologyUri");
|
||||
String startClassUri = vreq.getParameter("vclassUri");
|
||||
|
||||
List<VClass> roots = null;
|
||||
|
||||
if (ontologyUri != null) {
|
||||
roots = vcDao.getOntologyRootClasses(ontologyUri);
|
||||
} else if (startClassUri != null) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vcDao.getVClassByURI(startClassUri));
|
||||
} else {
|
||||
roots = vcDao.getRootClasses();
|
||||
}
|
||||
|
||||
if (roots.isEmpty()) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vreq.getUnfilteredWebappDaoFactory().getVClassDao()
|
||||
.getTopConcept());
|
||||
}
|
||||
Collections.sort(roots);
|
||||
int counter = 0;
|
||||
|
||||
Iterator<VClass> rootIt = roots.iterator();
|
||||
if (!rootIt.hasNext()) {
|
||||
VClass vcw = new VClass();
|
||||
vcw.setName("<strong>No classes found.</strong>");
|
||||
json += addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw,0,ontologyUri,counter);
|
||||
} else {
|
||||
while (rootIt.hasNext()) {
|
||||
VClass root = (VClass) rootIt.next();
|
||||
if (root != null) {
|
||||
json += addChildren(vreq.getUnfilteredWebappDaoFactory(), root, 0, ontologyUri,counter);
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
int length = json.length();
|
||||
if ( length > 0 ) {
|
||||
json += " }";
|
||||
}
|
||||
}
|
||||
body.put("jsonTree",json);
|
||||
|
||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
}
|
||||
|
@ -131,21 +129,21 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
int length = rowElts.length();
|
||||
String leaves = "";
|
||||
leaves += rowElts;
|
||||
List childURIstrs = vcDao.getSubClassURIs(parent.getURI());
|
||||
List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List childClasses = new ArrayList();
|
||||
Iterator childURIstrIt = childURIstrs.iterator();
|
||||
List<VClass> childClasses = new ArrayList<VClass>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = (String) childURIstrIt.next();
|
||||
String URIstr = childURIstrIt.next();
|
||||
try {
|
||||
VClass child = (VClass) vcDao.getVClassByURI(URIstr);
|
||||
VClass child = vcDao.getVClassByURI(URIstr);
|
||||
if (!child.getURI().equals(OWL.Nothing.getURI())) {
|
||||
childClasses.add(child);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
Collections.sort(childClasses);
|
||||
Iterator childClassIt = childClasses.iterator();
|
||||
Iterator<VClass> childClassIt = childClasses.iterator();
|
||||
while (childClassIt.hasNext()) {
|
||||
VClass child = (VClass) childClassIt.next();
|
||||
leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter);
|
||||
|
@ -197,15 +195,16 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
tempString += "}, { \"name\": ";
|
||||
}
|
||||
try {
|
||||
tempString += "\"<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"'>"+ vcw.getLocalNameWithPrefix() +"</a>\", ";
|
||||
tempString += JSONUtils.quote("<a href='vclassEdit?uri=" +
|
||||
URLEncoder.encode(vcw.getURI(),"UTF-8") + "'>" +
|
||||
vcw.getLocalNameWithPrefix() + "</a>") +", ";
|
||||
} catch (Exception e) {
|
||||
tempString += "\" " + ((vcw.getLocalNameWithPrefix() == null) ? "" : vcw.getLocalNameWithPrefix()) + "\", ";
|
||||
tempString += JSONUtils.quote(((vcw.getLocalNameWithPrefix() == null)
|
||||
? "" : vcw.getLocalNameWithPrefix())) + ", ";
|
||||
}
|
||||
|
||||
String shortDef = ((vcw.getShortDef() == null) ? "" : vcw.getShortDef()) ;
|
||||
shortDef = shortDef.replace("\"","\\\"");
|
||||
shortDef = shortDef.replace("\'","\\\'");
|
||||
tempString += "\"data\": { \"shortDef\": \"" + shortDef + "\", ";
|
||||
tempString += "\"data\": { \"shortDef\": " + JSONUtils.quote(shortDef) + ", ";
|
||||
|
||||
// Get group name if it exists
|
||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
||||
|
@ -218,16 +217,17 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
tempString += "\"classGroup\": \"" + ((groupName == null) ? "" : groupName) + "\", ";
|
||||
tempString += "\"classGroup\": " + JSONUtils.quote(
|
||||
(groupName == null) ? "" : groupName) + ", ";
|
||||
// Get ontology name
|
||||
String ontName = null;
|
||||
try {
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
Ontology ont = ontDao.getOntologyByURI(vcw.getNamespace());
|
||||
ontName = ont.getName();
|
||||
} catch (Exception e) {}
|
||||
|
||||
tempString += "\"ontology\": \"" + ((ontName == null) ? "" : ontName) + "\"}, \"children\": [";
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = vcw.getNamespace();
|
||||
Ontology ont = ontDao.getOntologyByURI(ontName);
|
||||
if (ont != null && ont.getName() != null) {
|
||||
ontName = ont.getName();
|
||||
}
|
||||
tempString += "\"ontology\": " + JSONUtils.quote(
|
||||
(ontName == null) ? "" : ontName) + "}, \"children\": [";
|
||||
|
||||
previous_posn = position;
|
||||
}
|
||||
|
|
|
@ -2,19 +2,17 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -25,7 +23,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -33,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
||||
|
||||
|
@ -106,7 +104,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
Iterator<DataProperty> rootIt = roots.iterator();
|
||||
if (!rootIt.hasNext()) {
|
||||
DataProperty dp = new DataProperty();
|
||||
dp.setURI(ontologyUri+"fake");
|
||||
dp.setURI(ontologyUri + "fake");
|
||||
String notFoundMessage = "<strong>No data properties found.</strong>";
|
||||
dp.setName(notFoundMessage);
|
||||
dp.setName(notFoundMessage);
|
||||
|
@ -142,19 +140,19 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
int length = details.length();
|
||||
String leaves = "";
|
||||
leaves += details;
|
||||
List childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List childProps = new ArrayList();
|
||||
Iterator childURIstrIt = childURIstrs.iterator();
|
||||
List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
|
||||
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
|
||||
List<DataProperty> childProps = new ArrayList<DataProperty>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = (String) childURIstrIt.next();
|
||||
DataProperty child = (DataProperty) dpDao.getDataPropertyByURI(URIstr);
|
||||
String URIstr = childURIstrIt.next();
|
||||
DataProperty child = dpDao.getDataPropertyByURI(URIstr);
|
||||
childProps.add(child);
|
||||
}
|
||||
Collections.sort(childProps);
|
||||
Iterator childPropIt = childProps.iterator();
|
||||
Iterator<DataProperty> childPropIt = childProps.iterator();
|
||||
while (childPropIt.hasNext()) {
|
||||
DataProperty child = (DataProperty) childPropIt.next();
|
||||
DataProperty child = childPropIt.next();
|
||||
leaves += addChildren(child, position+1, ontologyUri, counter);
|
||||
if (!childPropIt.hasNext()) {
|
||||
if ( ontologyUri == null ) {
|
||||
|
@ -206,34 +204,40 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
tempString += "}, { \"name\": ";
|
||||
}
|
||||
|
||||
String nameStr = dp.getPublicName()==null ? dp.getName()==null ? dp.getURI()==null ? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName();
|
||||
nameStr = nameStr.replace("\"","\\\"");
|
||||
nameStr = nameStr.replace("\'","\\\'");
|
||||
try {
|
||||
tempString += "\"<a href='datapropEdit?uri="+URLEncoder.encode(dp.getURI(),"UTF-8")+"'>" + nameStr + "</a>\", ";
|
||||
} catch (Exception e) {
|
||||
tempString += "\"" + nameStr + "\", ";
|
||||
log.error("Unsupported: URLEncoder.encode() with UTF-8");
|
||||
}
|
||||
String nameStr = dp.getPublicName() == null
|
||||
? dp.getName() == null
|
||||
? dp.getURI() == null
|
||||
? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName();
|
||||
|
||||
tempString += "\"data\": { \"internalName\": \"" + dp.getLocalNameWithPrefix() + "\", ";
|
||||
tempString += JSONUtils.quote(
|
||||
"<a href='datapropEdit?uri=" + URLEncoder.encode(
|
||||
dp.getURI()) + "'>" + nameStr + "</a>") + ", ";
|
||||
|
||||
tempString += "\"data\": { \"internalName\": " + JSONUtils.quote(
|
||||
dp.getLocalNameWithPrefix()) + ", ";
|
||||
|
||||
VClass tmp = null;
|
||||
try {
|
||||
tempString += "\"domainVClass\": \"" + (((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(dp.getDomainClassURI()).getLocalNameWithPrefix()) + "\", " ;
|
||||
tempString += "\"domainVClass\": " + JSONUtils.quote(
|
||||
((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null
|
||||
&& (tmp.getLocalNameWithPrefix() == null))
|
||||
? ""
|
||||
: vcDao.getVClassByURI(
|
||||
dp.getDomainClassURI())
|
||||
.getLocalNameWithPrefix()) + ", " ;
|
||||
} catch (NullPointerException e) {
|
||||
tempString += "\"domainVClass\": \"\",";
|
||||
}
|
||||
try {
|
||||
Datatype rangeDatatype = dDao.getDatatypeByURI(dp.getRangeDatatypeURI());
|
||||
String rangeDatatypeStr = (rangeDatatype==null)?dp.getRangeDatatypeURI():rangeDatatype.getName();
|
||||
tempString += "\"rangeVClass\": \"" + ((rangeDatatypeStr != null) ? rangeDatatypeStr : "") + "\", " ;
|
||||
tempString += "\"rangeVClass\": " + JSONUtils.quote((rangeDatatypeStr != null) ? rangeDatatypeStr : "") + ", " ;
|
||||
} catch (NullPointerException e) {
|
||||
tempString += "\"rangeVClass\": \"\",";
|
||||
}
|
||||
if (dp.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(dp.getGroupURI());
|
||||
tempString += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" " ;
|
||||
tempString += "\"group\": " + JSONUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName());
|
||||
} else {
|
||||
tempString += "\"group\": \"unspecified\"";
|
||||
}
|
||||
|
@ -244,10 +248,4 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
return tempString;
|
||||
}
|
||||
|
||||
private class DataPropertyAlphaComparator implements Comparator {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return Collator.getInstance().compare( ((DataProperty)o1).getName(), ((DataProperty)o2).getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,22 +2,18 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -26,13 +22,13 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet {
|
||||
|
||||
|
@ -146,19 +142,19 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
|
|||
int length = details.length();
|
||||
String leaves = "";
|
||||
leaves += details;
|
||||
List childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List childProps = new ArrayList();
|
||||
Iterator childURIstrIt = childURIstrs.iterator();
|
||||
List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
|
||||
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
|
||||
List<ObjectProperty> childProps = new ArrayList<ObjectProperty>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = (String) childURIstrIt.next();
|
||||
ObjectProperty child = (ObjectProperty) opDao.getObjectPropertyByURI(URIstr);
|
||||
String URIstr = childURIstrIt.next();
|
||||
ObjectProperty child = opDao.getObjectPropertyByURI(URIstr);
|
||||
childProps.add(child);
|
||||
}
|
||||
Collections.sort(childProps);
|
||||
Iterator childPropIt = childProps.iterator();
|
||||
Iterator<ObjectProperty> childPropIt = childProps.iterator();
|
||||
while (childPropIt.hasNext()) {
|
||||
ObjectProperty child = (ObjectProperty) childPropIt.next();
|
||||
ObjectProperty child = childPropIt.next();
|
||||
leaves += addChildren(child, position+1, ontologyUri, counter);
|
||||
if (!childPropIt.hasNext()) {
|
||||
if ( ontologyUri == null ) {
|
||||
|
@ -208,34 +204,45 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
|
|||
tempString += "}, { \"name\": ";
|
||||
}
|
||||
|
||||
String nameStr = getDisplayLabel(op)==null ? "(no name)" : getDisplayLabel(op);
|
||||
nameStr = nameStr.replace("\"","\\\"");
|
||||
nameStr = nameStr.replace("\'","\\\'");
|
||||
String nameStr = getDisplayLabel(op) == null ? "(no name)" : getDisplayLabel(op);
|
||||
|
||||
try {
|
||||
tempString += "\"<a href='propertyEdit?uri="+URLEncoder.encode(op.getURI(),"UTF-8") + "'>" + nameStr +"</a>\", ";
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
tempString += "\"" + nameStr + "\"";
|
||||
log.error("Unsupported: URLEncoder.encode() with UTF-8");
|
||||
}
|
||||
tempString += JSONUtils.quote(
|
||||
"<a href='propertyEdit?uri=" + URLEncoder.encode(
|
||||
op.getURI()) + "'>" + nameStr + "</a>") + ", ";
|
||||
|
||||
tempString += "\"data\": { \"internalName\": \"" + op.getLocalNameWithPrefix() + "\", ";
|
||||
tempString += "\"data\": { \"internalName\": " + JSONUtils.quote(
|
||||
op.getLocalNameWithPrefix()) + ", ";
|
||||
|
||||
VClass tmp = null;
|
||||
|
||||
try {
|
||||
tempString += "\"domainVClass\": \"" + (((tmp = vcDao.getVClassByURI(op.getDomainVClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(op.getDomainVClassURI()).getLocalNameWithPrefix()) + "\", " ;
|
||||
tempString += "\"domainVClass\": " + JSONUtils.quote(
|
||||
((tmp = vcDao.getVClassByURI(
|
||||
op.getDomainVClassURI())) != null
|
||||
&& (tmp.getLocalNameWithPrefix() == null))
|
||||
? ""
|
||||
: vcDao.getVClassByURI(
|
||||
op.getDomainVClassURI())
|
||||
.getLocalNameWithPrefix()) + ", " ;
|
||||
} catch (NullPointerException e) {
|
||||
tempString += "\"domainVClass\": \"\",";
|
||||
}
|
||||
try {
|
||||
tempString += "\"rangeVClass\": \"" + (((tmp = vcDao.getVClassByURI(op.getRangeVClassURI())) != null && (tmp.getLocalNameWithPrefix() == null)) ? "" : vcDao.getVClassByURI(op.getRangeVClassURI()).getLocalNameWithPrefix()) + "\", " ;
|
||||
tempString += "\"rangeVClass\": " + JSONUtils.quote(
|
||||
((tmp = vcDao.getVClassByURI(
|
||||
op.getRangeVClassURI())) != null
|
||||
&& (tmp.getLocalNameWithPrefix() == null))
|
||||
? ""
|
||||
: vcDao.getVClassByURI(
|
||||
op.getRangeVClassURI())
|
||||
.getLocalNameWithPrefix()) + ", " ;
|
||||
} catch (NullPointerException e) {
|
||||
tempString += "\"rangeVClass\": \"\",";
|
||||
}
|
||||
if (op.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(op.getGroupURI());
|
||||
tempString += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" " ;
|
||||
tempString += "\"group\": " + JSONUtils.quote(
|
||||
(pGroup == null) ? "unknown group" : pGroup.getName());
|
||||
} else {
|
||||
tempString += "\"group\": \"unspecified\"";
|
||||
}
|
||||
|
|
|
@ -46,8 +46,9 @@ public class VitroVocabulary {
|
|||
|
||||
public static final String DESCRIPTION_ANNOT = vitroURI + "descriptionAnnot";
|
||||
public static final String PUBLIC_DESCRIPTION_ANNOT = vitroURI + "publicDescriptionAnnot";
|
||||
public static final String SHORTDEF = vitroURI+"shortDef";
|
||||
public static final String EXAMPLE_ANNOT = vitroURI+"exampleAnnot";
|
||||
public static final String SHORTDEF = "http://purl.obolibrary.org/obo/IAO_0000115";
|
||||
public static final String EXAMPLE_ANNOT = "http://purl.obolibrary.org/obo/IAO_0000112";
|
||||
|
||||
|
||||
public static final String EXTERNALID = vitroURI+"externalId";
|
||||
public static final String DATAPROPERTY_ISEXTERNALID = vitroURI+"isExternalId";
|
||||
|
|
Loading…
Add table
Reference in a new issue