diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropRetryController.java
index ac443de7c..bc60934c8 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropRetryController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropRetryController.java
@@ -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;
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java
index b87f93dfe..eb42252c3 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java
@@ -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\": \""+publicName+"\", ";
+ json += "{ \"name\": " + JSONUtils.quote(""+publicName+"") + ", ";
} 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\": \""+vcw.getName()+"\", ";
+ json += "{ \"name\": " + JSONUtils.quote(""+vcw.getName()+"") + ", ";
} 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
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java
index cfa06ae55..56fc35a39 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java
@@ -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\": \"" + nameStr + "\", ";
+ json += "{ \"name\": " + JSONUtils.quote("" + nameStr + "") + ", ";
} 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\" } }" ;
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java
index 9eaf9cf47..468d57f76 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java
@@ -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\": \"" + publicName + "\", ";
+ json += "{ \"name\": " + JSONUtils.quote("" + publicName + "") + ", ";
} 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\": \""+ nameStr +"\", ";
+ json += "{ \"name\": " + JSONUtils.quote(""+ nameStr +"") + ", ";
} catch (Exception e) {
- json += "\"" + nameStr + "\", ";
+ json += JSONUtils.quote(nameStr) + ", ";
}
} else {
json += "\"\", ";
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java
index 81a12a4f0..df632a860 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java
@@ -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 props = new ArrayList();
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 propInstIt = propInsts.iterator();
+ HashSet propURIs = new HashSet();
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 ontologyHash = new HashMap();
- Iterator propIt = props.iterator();
- List scratch = new ArrayList();
+ Iterator propIt = props.iterator();
+ List scratch = new ArrayList();
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 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\": \""
- + propNameStr + "\", ";
+ json += "{ \"name\": " + JSONUtils.quote(""
+ + propNameStr + "") + ", ";
} 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\" } }" ;
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java
index 5db89a942..d07ea6743 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java
@@ -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;
@@ -50,90 +42,83 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
@Override
protected ResponseValues processRequest(VitroRequest vreq) {
-
+
Map body = new HashMap();
- try {
- body.put("displayOption", "all");
- body.put("pageTitle", "All Classes");
-
- List classes = null;
+ body.put("displayOption", "all");
+ body.put("pageTitle", "All Classes");
+
+ List 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 ontologyURI = vreq.getParameter("ontologyUri");
-
- if (classes != null) {
- Collections.sort(classes);
- Iterator 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\": \""+cls.getLocalNameWithPrefix()+"\", ";
- } 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;
-
- }
- }
- body.put("jsonTree",json);
- }
-
- } catch (Throwable t) {
- t.printStackTrace();
}
+ String json = new String();
+ int counter = 0;
+
+ String ontologyURI = vreq.getParameter("ontologyUri");
+
+ if (classes != null) {
+ Collections.sort(classes);
+ Iterator 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\": " + JSONUtils.quote(""+cls.getLocalNameWithPrefix()+"") + ", ";
+ } catch (Exception e) {
+ json += "{ \"name\": " + JSONUtils.quote(cls.getLocalNameWithPrefix()) + ", ";
+ }
+ else
+ json += "{ \"name\": \"\"";
+ String shortDef = (cls.getShortDef() == null) ? "" : cls.getShortDef();
+
+ 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);
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java
index d06861ab7..f703b4318 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java
@@ -11,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 body = new HashMap();
- try {
- String displayOption = "";
-
- if ( vreq.getParameter("displayOption") != null ) {
- displayOption = vreq.getParameter("displayOption");
- }
- else {
- displayOption = "asserted";
- }
-
- body.put("displayOption", displayOption);
- boolean inferred = ( displayOption.equals("inferred") );
- if ( inferred ) {
- body.put("pageTitle", "Inferred Class Hierarchy");
- }
- else {
- body.put("pageTitle", "Asserted Class Hierarchy");
- }
-
- if (!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 roots = null;
-
- if (ontologyUri != null) {
- roots = vcDao.getOntologyRootClasses(ontologyUri);
- } else if (startClassUri != null) {
- roots = new LinkedList();
- roots.add(vcDao.getVClassByURI(startClassUri));
- } else {
- roots = vcDao.getRootClasses();
- }
-
- if (roots.isEmpty()) {
- roots = new LinkedList();
- 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("No classes found.");
- 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();
+
+ String displayOption = "";
+
+ if ( vreq.getParameter("displayOption") != null ) {
+ displayOption = vreq.getParameter("displayOption");
}
+ else {
+ displayOption = "asserted";
+ }
+
+ body.put("displayOption", displayOption);
+ boolean inferred = ( displayOption.equals("inferred") );
+ if ( inferred ) {
+ body.put("pageTitle", "Inferred Class Hierarchy");
+ }
+ else {
+ body.put("pageTitle", "Asserted Class Hierarchy");
+ }
+
+ if (!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 roots = null;
+
+ if (ontologyUri != null) {
+ roots = vcDao.getOntologyRootClasses(ontologyUri);
+ } else if (startClassUri != null) {
+ roots = new LinkedList();
+ roots.add(vcDao.getVClassByURI(startClassUri));
+ } else {
+ roots = vcDao.getRootClasses();
+ }
+
+ if (roots.isEmpty()) {
+ roots = new LinkedList();
+ 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("No classes found.");
+ 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 childURIstrs = vcDao.getSubClassURIs(parent.getURI());
if ((childURIstrs.size()>0) && position childClasses = new ArrayList();
+ Iterator 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 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 += "\""+ vcw.getLocalNameWithPrefix() +"\", ";
+ tempString += JSONUtils.quote("" +
+ vcw.getLocalNameWithPrefix() + "") +", ";
} 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;
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java
index 586ec5c73..7c5dcf90a 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java
@@ -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 rootIt = roots.iterator();
if (!rootIt.hasNext()) {
DataProperty dp = new DataProperty();
- dp.setURI(ontologyUri+"fake");
+ dp.setURI(ontologyUri + "fake");
String notFoundMessage = "No data properties found.";
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 childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
+ if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
+ List childProps = new ArrayList();
+ Iterator 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 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 += "\"" + nameStr + "\", ";
- } 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 += JSONUtils.quote(
+ "" + nameStr + "") + ", ";
- tempString += "\"data\": { \"internalName\": \"" + dp.getLocalNameWithPrefix() + "\", ";
+ 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());
- }
- }
-
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java
index 5e2c02f5b..b7547cf74 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java
@@ -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 childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
+ if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
+ List childProps = new ArrayList();
+ Iterator 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 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 += "\"" + nameStr +"\", ";
- } catch (UnsupportedEncodingException uee) {
- tempString += "\"" + nameStr + "\"";
- log.error("Unsupported: URLEncoder.encode() with UTF-8");
- }
-
- tempString += "\"data\": { \"internalName\": \"" + op.getLocalNameWithPrefix() + "\", ";
+ tempString += JSONUtils.quote(
+ "" + nameStr + "") + ", ";
+
+ 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\"";
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java
index d06f6ccab..0a6e6fc13 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java
@@ -46,9 +46,10 @@ 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";