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