Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop
This commit is contained in:
commit
8d520895ac
27 changed files with 480 additions and 457 deletions
|
@ -4,6 +4,7 @@
|
|||
@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> .
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix action: <java:edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission#> .
|
||||
|
||||
### This file defines the default menu for vitro. ###
|
||||
|
||||
|
@ -35,39 +36,3 @@ display:Home
|
|||
|
||||
<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#homeDataGetter>
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.BrowseDataGetter> .
|
||||
|
||||
########## Page Management ##########
|
||||
display:pageListPage
|
||||
a display:Page ;
|
||||
display:title "Pages" ;
|
||||
display:urlMapping "/pageList" ;
|
||||
display:requiresBodyTemplate "pageList.ftl" ;
|
||||
display:hasDataGetter display:pageListData;
|
||||
display:cannotDeletePage "true" .
|
||||
|
||||
display:pageListData
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter>;
|
||||
display:queryModel <vitro:contextDisplayModel> ;
|
||||
display:saveToVar "pages" ;
|
||||
|
||||
display:query """
|
||||
PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#>
|
||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
SELECT ?listedPageUri ?listedPageTitle ?listedPageUrlMapping ?listedPageTemplate ?listedPageMenuItem ?listedPageCannotDeletePage
|
||||
WHERE {
|
||||
?listedPageUri a display:Page .
|
||||
OPTIONAL{ ?listedPageUri display:urlMapping ?listedPageUrlMapping. }
|
||||
OPTIONAL{ ?listedPageUri display:title ?listedPageTitle. }
|
||||
OPTIONAL {?listedPageUri display:requiresBodyTemplate ?listedPageTemplate .}
|
||||
OPTIONAL {?listedPageMenuItem display:toPage ?listedPageUri .}
|
||||
OPTIONAL {?listedPageUri display:cannotDeletePage ?listedPageCannotDeletePage .}
|
||||
} ORDER BY ?listedPageTitle """ .
|
||||
###Page Management and Data Getters
|
||||
#Data getter type labels
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData> rdfs:label "Class Group Page" .
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.BrowseDataGetter> rdfs:label "Browse Page" .
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter> rdfs:label "Class Group Page - Selected Classes" .
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter> rdfs:label "Sparql Query Results" .
|
||||
|
||||
|
||||
|
46
webapp/rdf/display/firsttime/pageList.n3
Normal file
46
webapp/rdf/display/firsttime/pageList.n3
Normal file
|
@ -0,0 +1,46 @@
|
|||
# $This file is distributed under the terms of the license in /doc/license.txt$
|
||||
|
||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||
@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> .
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix action: <java:edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission#> .
|
||||
|
||||
### This file defines the page list menu for vitro. ###
|
||||
|
||||
display:pageListPage
|
||||
a display:Page ;
|
||||
display:title "Pages" ;
|
||||
display:urlMapping "/pageList" ;
|
||||
display:requiresBodyTemplate "pageList.ftl" ;
|
||||
display:hasDataGetter display:pageListData;
|
||||
display:requiredAction <java:edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission#ManageMenus> ;
|
||||
display:cannotDeletePage "true" .
|
||||
|
||||
display:pageListData
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter>;
|
||||
display:queryModel <vitro:contextDisplayModel> ;
|
||||
display:saveToVar "pages" ;
|
||||
|
||||
display:query """
|
||||
PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#>
|
||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
SELECT ?listedPageUri ?listedPageTitle ?listedPageUrlMapping ?listedPageTemplate ?listedPageMenuItem ?listedPageCannotDeletePage
|
||||
WHERE {
|
||||
?listedPageUri a display:Page .
|
||||
OPTIONAL{ ?listedPageUri display:urlMapping ?listedPageUrlMapping. }
|
||||
OPTIONAL{ ?listedPageUri display:title ?listedPageTitle. }
|
||||
OPTIONAL {?listedPageUri display:requiresBodyTemplate ?listedPageTemplate .}
|
||||
OPTIONAL {?listedPageMenuItem display:toPage ?listedPageUri .}
|
||||
OPTIONAL {?listedPageUri display:cannotDeletePage ?listedPageCannotDeletePage .}
|
||||
} ORDER BY ?listedPageTitle """ .
|
||||
###Page Management and Data Getters
|
||||
|
||||
#Data getter type labels
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData> rdfs:label "Class Group Page" .
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.BrowseDataGetter> rdfs:label "Browse Page" .
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter> rdfs:label "Class Group Page - Selected Classes" .
|
||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter> rdfs:label "Sparql Query Results" .
|
||||
|
||||
|
||||
|
|
@ -155,26 +155,6 @@ public class BaseEditController extends VitroHttpServlet {
|
|||
}
|
||||
}
|
||||
|
||||
protected OntModel getOntModel( HttpServletRequest request, ServletContext ctx ) {
|
||||
|
||||
// TODO: JB - This method gets the UNION FULL model from the session, if there is one,
|
||||
// TODO and the BASE_TBOX model otherwise.
|
||||
OntModel ontModel = null;
|
||||
try {
|
||||
ontModel = ModelAccess.on(request.getSession()).getJenaOntModel();
|
||||
} catch (Exception e) {
|
||||
// ignoring any problems here - we're not really expecting
|
||||
// this attribute to be populated anyway
|
||||
}
|
||||
|
||||
if ( ontModel == null ) {
|
||||
ontModel = ModelAccess.on(ctx).getOntModel(ModelID.BASE_TBOX);
|
||||
}
|
||||
|
||||
return ontModel;
|
||||
|
||||
}
|
||||
|
||||
protected WebappDaoFactory getWebappDaoFactory() {
|
||||
return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -23,11 +23,14 @@ import com.hp.hpl.jena.rdf.model.Model;
|
|||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.vocabulary.DAML_OIL;
|
||||
|
||||
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
|
||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||
|
||||
public class RestrictionOperationController extends BaseEditController {
|
||||
|
@ -44,7 +47,8 @@ public class RestrictionOperationController extends BaseEditController {
|
|||
|
||||
try {
|
||||
|
||||
OntModel ontModel = getOntModel(request, getServletContext());
|
||||
OntModel ontModel = ModelAccess.on(
|
||||
getServletContext()).getOntModel(ModelID.BASE_TBOX);
|
||||
|
||||
HashMap epoHash = null;
|
||||
EditProcessObject epo = null;
|
||||
|
|
|
@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
import com.ibm.icu.text.Collator;
|
||||
|
||||
|
@ -63,7 +64,7 @@ public class RestrictionRetryController extends BaseEditController {
|
|||
List<Option> onPropertyList = new LinkedList<Option>();
|
||||
Collections.sort(pList, new PropSorter());
|
||||
for (Property p: pList) {
|
||||
onPropertyList.add( new Option(p.getURI(),p.getLocalNameWithPrefix()) );
|
||||
onPropertyList.add( new Option(p.getURI(),p.getPickListName()));
|
||||
}
|
||||
|
||||
epo.setFormObject(new FormObject());
|
||||
|
@ -117,8 +118,20 @@ public class RestrictionRetryController extends BaseEditController {
|
|||
private List<Option> getValueClassOptionList(VitroRequest request) {
|
||||
List<Option> valueClassOptionList = new LinkedList<Option>();
|
||||
VClassDao vcDao = request.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
for (VClass vc: vcDao.getAllVclasses()) {
|
||||
valueClassOptionList.add(new Option(vc.getURI(), vc.getLocalNameWithPrefix()));
|
||||
List<VClass> vclasses = vcDao.getAllVclasses();
|
||||
boolean addOwlThing = true;
|
||||
for (VClass vclass : vclasses) {
|
||||
if (OWL.Thing.getURI().equals(vclass.getURI())) {
|
||||
addOwlThing = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(addOwlThing) {
|
||||
vclasses.add(new VClass(OWL.Thing.getURI()));
|
||||
}
|
||||
Collections.sort(vclasses);
|
||||
for (VClass vc: vclasses) {
|
||||
valueClassOptionList.add(new Option(vc.getURI(), vc.getPickListName()));
|
||||
}
|
||||
return valueClassOptionList;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ 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.edit.utils.RoleLevelOptionsSetup;
|
||||
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.VClassGroupDao;
|
||||
|
@ -64,10 +65,12 @@ public class VclassRetryController extends BaseEditController {
|
|||
action = epo.getAction();
|
||||
}
|
||||
|
||||
VClassDao vcwDao = request.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
||||
WebappDaoFactory wadf = ModelAccess.on(getServletContext()).getWebappDaoFactory();
|
||||
|
||||
VClassDao vcwDao = wadf.getVClassDao();
|
||||
epo.setDataAccessObject(vcwDao);
|
||||
VClassGroupDao cgDao = request.getUnfilteredWebappDaoFactory().getVClassGroupDao();
|
||||
OntologyDao oDao = request.getUnfilteredWebappDaoFactory().getOntologyDao();
|
||||
VClassGroupDao cgDao = wadf.getVClassGroupDao();
|
||||
OntologyDao oDao = wadf.getOntologyDao();
|
||||
|
||||
VClass vclassForEditing = null;
|
||||
if (!epo.getUseRecycledBean()){
|
||||
|
@ -82,18 +85,12 @@ public class VclassRetryController extends BaseEditController {
|
|||
} else {
|
||||
vclassForEditing = new VClass();
|
||||
if (request.getParameter("GroupId") != null) {
|
||||
try {
|
||||
vclassForEditing.setGroupURI(request.getParameter("GroupURI"));
|
||||
} catch (NumberFormatException e) {
|
||||
// too bad
|
||||
}
|
||||
vclassForEditing.setGroupURI(request.getParameter("GroupURI"));
|
||||
}
|
||||
}
|
||||
epo.setOriginalBean(vclassForEditing);
|
||||
} else {
|
||||
vclassForEditing = (VClass) epo.getNewBean();
|
||||
// action = "update";
|
||||
// log.error("using newBean");
|
||||
}
|
||||
|
||||
//make a simple mask for the class's id
|
||||
|
|
|
@ -2,17 +2,12 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -26,6 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
|
||||
public class ListClassGroupsController extends FreemarkerHttpServlet {
|
||||
|
@ -64,12 +60,10 @@ public class ListClassGroupsController extends FreemarkerHttpServlet {
|
|||
if ( StringUtils.isBlank(publicName) ) {
|
||||
publicName = "(unnamed group)";
|
||||
}
|
||||
publicName = publicName.replace("\"","\\\"");
|
||||
publicName = publicName.replace("\'","\\\'");
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI(),"UTF-8")+"&controller=Classgroup'>"+publicName+"</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI())+"&controller=Classgroup'>"+publicName+"</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + publicName + "\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote(publicName) + ", ";
|
||||
}
|
||||
Integer t;
|
||||
|
||||
|
@ -83,18 +77,16 @@ public class ListClassGroupsController extends FreemarkerHttpServlet {
|
|||
VClass vcw = classIt.next();
|
||||
if (vcw.getName() != null && vcw.getURI() != null) {
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"'>"+vcw.getName()+"</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI())+"'>"+vcw.getName()+"</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "\"" + vcw.getName() + "\", ";
|
||||
json += "" + JSONUtils.quote(vcw.getName()) + ", ";
|
||||
}
|
||||
} else {
|
||||
json += "\"\", ";
|
||||
}
|
||||
|
||||
String shortDefStr = (vcw.getShortDef() == null) ? "" : vcw.getShortDef();
|
||||
shortDefStr = shortDefStr.replace("\"","\\\"");
|
||||
shortDefStr = shortDefStr.replace("\'","\\\'");
|
||||
json += "\"data\": { \"shortDef\": \"" + shortDefStr + "\"}, \"children\": [] ";
|
||||
json += "\"data\": { \"shortDef\": " + JSONUtils.quote(shortDefStr) + "}, \"children\": [] ";
|
||||
if (classIt.hasNext())
|
||||
json += "} , ";
|
||||
else
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -13,8 +11,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -25,7 +22,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -33,7 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
|
||||
|
||||
|
@ -112,15 +108,14 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName();
|
||||
nameStr = nameStr.replace("\"","\\\"");
|
||||
nameStr = nameStr.replace("\'","\\\'");
|
||||
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='datapropEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>" + nameStr + "</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='datapropEdit?uri="+ URLEncoder.encode(prop.getURI())+"'>" + nameStr + "</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + nameStr + "\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote(nameStr) + ", ";
|
||||
}
|
||||
|
||||
json += "\"data\": { \"internalName\": \"" + prop.getLocalNameWithPrefix() + "\", ";
|
||||
json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", ";
|
||||
|
||||
/* VClass vc = null;
|
||||
String domainStr="";
|
||||
|
@ -137,15 +132,15 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
|
|||
*/
|
||||
VClass vc = (prop.getDomainClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainClassURI()) : null;
|
||||
String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : "";
|
||||
json += "\"domainVClass\": \"" + domainStr + "\", " ;
|
||||
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
|
||||
|
||||
Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI());
|
||||
String rangeDatatypeStr = (rangeDatatype==null)?prop.getRangeDatatypeURI():rangeDatatype.getName();
|
||||
json += "\"rangeVClass\": \"" + rangeDatatypeStr + "\", " ;
|
||||
json += "\"rangeVClass\": " + JSONUtils.quote(rangeDatatypeStr) + ", " ;
|
||||
|
||||
if (prop.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
||||
json += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" } } " ;
|
||||
json += "\"group\": " + JSONUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ;
|
||||
} else {
|
||||
json += "\"group\": \"unspecified\" } }" ;
|
||||
}
|
||||
|
|
|
@ -3,29 +3,23 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -70,12 +64,10 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
|
|||
if ( StringUtils.isBlank(publicName) ) {
|
||||
publicName = "(unnamed group)";
|
||||
}
|
||||
publicName = publicName.replace("\"","\\\"");
|
||||
publicName = publicName.replace("\'","\\\'");
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./editForm?uri="+URLEncoder.encode(pg.getURI(),"UTF-8")+"&controller=PropertyGroup'>" + publicName + "</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(pg.getURI(),"UTF-8")+"&controller=PropertyGroup'>" + publicName + "</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + publicName + "\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote(publicName) + ", ";
|
||||
}
|
||||
Integer t;
|
||||
|
||||
|
@ -100,10 +92,10 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
|
|||
}
|
||||
if (prop.getURI() != null) {
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='" + controllerStr
|
||||
+ "?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"+ nameStr +"</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='" + controllerStr
|
||||
+ "?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"+ nameStr +"</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "\"" + nameStr + "\", ";
|
||||
json += JSONUtils.quote(nameStr) + ", ";
|
||||
}
|
||||
} else {
|
||||
json += "\"\", ";
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -12,8 +11,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -25,7 +23,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -35,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
||||
private static Log log = LogFactory.getLog( ListPropertyWebappsController.class );
|
||||
|
@ -67,7 +65,7 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
|
||||
String vclassURI = vreq.getParameter("vclassUri");
|
||||
|
||||
List props = new ArrayList();
|
||||
List<ObjectProperty> props = new ArrayList<ObjectProperty>();
|
||||
if (vreq.getParameter("propsForClass") != null) {
|
||||
noResultsMsgStr = "There are no object properties that apply to this class.";
|
||||
|
||||
|
@ -87,8 +85,8 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
propInsts.addAll(propInstMap.values());
|
||||
Collections.sort(propInsts);
|
||||
|
||||
Iterator propInstIt = propInsts.iterator();
|
||||
HashSet propURIs = new HashSet();
|
||||
Iterator<PropertyInstance> propInstIt = propInsts.iterator();
|
||||
HashSet<String> propURIs = new HashSet<String>();
|
||||
while (propInstIt.hasNext()) {
|
||||
PropertyInstance pi = (PropertyInstance) propInstIt.next();
|
||||
if (!(propURIs.contains(pi.getPropertyURI()))) {
|
||||
|
@ -108,13 +106,13 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
OntologyDao oDao = vreq.getUnfilteredWebappDaoFactory().getOntologyDao();
|
||||
HashMap<String,String> ontologyHash = new HashMap<String,String>();
|
||||
|
||||
Iterator propIt = props.iterator();
|
||||
List<ObjectProperty> scratch = new ArrayList();
|
||||
Iterator<ObjectProperty> propIt = props.iterator();
|
||||
List<ObjectProperty> scratch = new ArrayList<ObjectProperty>();
|
||||
while (propIt.hasNext()) {
|
||||
ObjectProperty p = (ObjectProperty) propIt.next();
|
||||
if (p.getNamespace()!=null) {
|
||||
ObjectProperty p = propIt.next();
|
||||
if (p.getNamespace() != null) {
|
||||
if( !ontologyHash.containsKey( p.getNamespace() )){
|
||||
Ontology o = (Ontology)oDao.getOntologyByURI(p.getNamespace());
|
||||
Ontology o = oDao.getOntologyByURI(p.getNamespace());
|
||||
if (o==null) {
|
||||
if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) {
|
||||
log.debug("doGet(): no ontology object found for the namespace "+p.getNamespace());
|
||||
|
@ -144,36 +142,35 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
if (props.size()==0) {
|
||||
json = "{ \"name\": \"" + noResultsMsgStr + "\" }";
|
||||
} else {
|
||||
Iterator propsIt = props.iterator();
|
||||
Iterator<ObjectProperty> propsIt = props.iterator();
|
||||
while (propsIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
json += ", ";
|
||||
}
|
||||
ObjectProperty prop = (ObjectProperty) propsIt.next();
|
||||
ObjectProperty prop = propsIt.next();
|
||||
|
||||
String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop);
|
||||
propNameStr = propNameStr.replace("\"","\\\"");
|
||||
propNameStr = propNameStr.replace("\'","\\\'");
|
||||
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./propertyEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"
|
||||
+ propNameStr + "</a>\", ";
|
||||
json += "{ \"name\": " + JSONUtils.quote("<a href='./propertyEdit?uri="+URLEncoder.encode(prop.getURI())+"'>"
|
||||
+ propNameStr + "</a>") + ", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + propNameStr + "\", ";
|
||||
}
|
||||
|
||||
json += "\"data\": { \"internalName\": \"" + prop.getLocalNameWithPrefix() + "\", ";
|
||||
json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", ";
|
||||
|
||||
VClass vc = (prop.getDomainVClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainVClassURI()) : null;
|
||||
String domainStr = (vc != null) ? vc.getLocalNameWithPrefix() : "";
|
||||
json += "\"domainVClass\": \"" + domainStr + "\", " ;
|
||||
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
|
||||
|
||||
vc = (prop.getRangeVClassURI() != null) ? vcDao.getVClassByURI(prop.getRangeVClassURI()) : null;
|
||||
String rangeStr = (vc != null) ? vc.getLocalNameWithPrefix() : "";
|
||||
json += "\"rangeVClass\": \"" + rangeStr + "\", " ;
|
||||
json += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", " ;
|
||||
|
||||
if (prop.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
||||
json += "\"group\": \"" + ((pGroup == null) ? "unknown group" : pGroup.getName()) + "\" } } " ;
|
||||
json += "\"group\": " + JSONUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ;
|
||||
} else {
|
||||
json += "\"group\": \"unspecified\" } }" ;
|
||||
}
|
||||
|
|
|
@ -3,30 +3,22 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -50,90 +42,83 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
|
|||
|
||||
@Override
|
||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
try {
|
||||
|
||||
body.put("displayOption", "all");
|
||||
body.put("pageTitle", "All Classes");
|
||||
|
||||
List<VClass> classes = null;
|
||||
body.put("displayOption", "all");
|
||||
body.put("pageTitle", "All Classes");
|
||||
|
||||
List<VClass> classes = null;
|
||||
|
||||
if (vreq.getParameter("showPropertyRestrictions") != null) {
|
||||
PropertyDao pdao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
||||
classes = pdao.getClassesWithRestrictionOnProperty(vreq.getParameter("propertyURI"));
|
||||
} else {
|
||||
VClassDao vcdao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
if (vreq.getParameter("showPropertyRestrictions") != null) {
|
||||
PropertyDao pdao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
||||
classes = pdao.getClassesWithRestrictionOnProperty(vreq.getParameter("propertyURI"));
|
||||
} else {
|
||||
VClassDao vcdao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
|
||||
if (vreq.getParameter("iffRoot") != null) {
|
||||
classes = vcdao.getRootClasses();
|
||||
} else {
|
||||
classes = vcdao.getAllVclasses();
|
||||
}
|
||||
if (vreq.getParameter("iffRoot") != null) {
|
||||
classes = vcdao.getRootClasses();
|
||||
} else {
|
||||
classes = vcdao.getAllVclasses();
|
||||
}
|
||||
|
||||
}
|
||||
String json = new String();
|
||||
int counter = 0;
|
||||
|
||||
String ontologyURI = vreq.getParameter("ontologyUri");
|
||||
|
||||
if (classes != null) {
|
||||
Collections.sort(classes);
|
||||
Iterator<VClass> classesIt = classes.iterator();
|
||||
while (classesIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
json += ", ";
|
||||
}
|
||||
VClass cls = (VClass) classesIt.next();
|
||||
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
|
||||
if (cls.getName() != null)
|
||||
try {
|
||||
json += "{ \"name\": \"<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getLocalNameWithPrefix()+"</a>\", ";
|
||||
} catch (Exception e) {
|
||||
json += "{ \"name\": \"" + cls.getLocalNameWithPrefix() + "\", ";
|
||||
}
|
||||
else
|
||||
json += "{ \"name\": \"\"";
|
||||
String shortDef = (cls.getShortDef()==null) ? "" : cls.getShortDef();
|
||||
|
||||
json += "\"data\": { \"shortDef\": \"" + shortDef + "\", ";
|
||||
|
||||
// get group name
|
||||
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
|
||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
||||
String groupURI = cls.getGroupURI();
|
||||
String groupName = "";
|
||||
VClassGroup classGroup = null;
|
||||
if(groupURI != null) {
|
||||
classGroup = groupDao.getGroupByURI(groupURI);
|
||||
if (classGroup!=null) {
|
||||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
|
||||
json += "\"classGroup\": \"" + groupName + "\", ";
|
||||
|
||||
// get ontology name
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = null;
|
||||
try {
|
||||
Ontology ont = ontDao.getOntologyByURI(cls.getNamespace());
|
||||
ontName = ont.getName();
|
||||
} catch (Exception e) {}
|
||||
ontName = (ontName == null) ? "" : ontName;
|
||||
|
||||
json += "\"ontology\": \"" + ontName + "\"} }";
|
||||
|
||||
counter += 1;
|
||||
|
||||
}
|
||||
}
|
||||
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<VClass> classesIt = classes.iterator();
|
||||
while (classesIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
json += ", ";
|
||||
}
|
||||
VClass cls = (VClass) classesIt.next();
|
||||
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
|
||||
if (cls.getName() != null)
|
||||
try {
|
||||
json += "{ \"name\": " + 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();
|
||||
|
||||
json += "\"data\": { \"shortDef\": " + JSONUtils.quote(shortDef) + ", ";
|
||||
|
||||
// get group name
|
||||
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
|
||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
||||
String groupURI = cls.getGroupURI();
|
||||
String groupName = "";
|
||||
VClassGroup classGroup = null;
|
||||
if(groupURI != null) {
|
||||
classGroup = groupDao.getGroupByURI(groupURI);
|
||||
if (classGroup!=null) {
|
||||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
|
||||
json += "\"classGroup\": " + JSONUtils.quote(groupName) + ", ";
|
||||
|
||||
// get ontology name
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = cls.getNamespace();
|
||||
Ontology ont = ontDao.getOntologyByURI(ontName);
|
||||
if (ont != null && ont.getName() != null) {
|
||||
ontName = ont.getName();
|
||||
}
|
||||
json += "\"ontology\": " + JSONUtils.quote(ontName) + "} }";
|
||||
|
||||
counter++;
|
||||
|
||||
}
|
||||
}
|
||||
body.put("jsonTree",json);
|
||||
}
|
||||
|
||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -50,77 +52,73 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
try {
|
||||
String displayOption = "";
|
||||
|
||||
if ( vreq.getParameter("displayOption") != null ) {
|
||||
displayOption = vreq.getParameter("displayOption");
|
||||
}
|
||||
else {
|
||||
displayOption = "asserted";
|
||||
}
|
||||
|
||||
body.put("displayOption", displayOption);
|
||||
boolean inferred = ( displayOption.equals("inferred") );
|
||||
if ( inferred ) {
|
||||
body.put("pageTitle", "Inferred Class Hierarchy");
|
||||
}
|
||||
else {
|
||||
body.put("pageTitle", "Asserted Class Hierarchy");
|
||||
}
|
||||
|
||||
if (!inferred) {
|
||||
vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
||||
} else {
|
||||
vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||
}
|
||||
String json = new String();
|
||||
|
||||
String ontologyUri = vreq.getParameter("ontologyUri");
|
||||
String startClassUri = vreq.getParameter("vclassUri");
|
||||
|
||||
List<VClass> roots = null;
|
||||
|
||||
if (ontologyUri != null) {
|
||||
roots = vcDao.getOntologyRootClasses(ontologyUri);
|
||||
} else if (startClassUri != null) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vcDao.getVClassByURI(startClassUri));
|
||||
} else {
|
||||
roots = vcDao.getRootClasses();
|
||||
}
|
||||
|
||||
if (roots.isEmpty()) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vreq.getUnfilteredWebappDaoFactory().getVClassDao()
|
||||
.getTopConcept());
|
||||
}
|
||||
Collections.sort(roots);
|
||||
int counter = 0;
|
||||
|
||||
Iterator rootIt = roots.iterator();
|
||||
if (!rootIt.hasNext()) {
|
||||
VClass vcw = new VClass();
|
||||
vcw.setName("<strong>No classes found.</strong>");
|
||||
json += addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw,0,ontologyUri,counter);
|
||||
} else {
|
||||
while (rootIt.hasNext()) {
|
||||
VClass root = (VClass) rootIt.next();
|
||||
if (root != null) {
|
||||
json += addChildren(vreq.getUnfilteredWebappDaoFactory(), root, 0, ontologyUri,counter);
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
int length = json.length();
|
||||
if ( length > 0 ) {
|
||||
json += " }";
|
||||
}
|
||||
}
|
||||
body.put("jsonTree",json);
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
|
||||
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<VClass> roots = null;
|
||||
|
||||
if (ontologyUri != null) {
|
||||
roots = vcDao.getOntologyRootClasses(ontologyUri);
|
||||
} else if (startClassUri != null) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vcDao.getVClassByURI(startClassUri));
|
||||
} else {
|
||||
roots = vcDao.getRootClasses();
|
||||
}
|
||||
|
||||
if (roots.isEmpty()) {
|
||||
roots = new LinkedList<VClass>();
|
||||
roots.add(vreq.getUnfilteredWebappDaoFactory().getVClassDao()
|
||||
.getTopConcept());
|
||||
}
|
||||
Collections.sort(roots);
|
||||
int counter = 0;
|
||||
|
||||
Iterator<VClass> rootIt = roots.iterator();
|
||||
if (!rootIt.hasNext()) {
|
||||
VClass vcw = new VClass();
|
||||
vcw.setName("<strong>No classes found.</strong>");
|
||||
json += addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw,0,ontologyUri,counter);
|
||||
} else {
|
||||
while (rootIt.hasNext()) {
|
||||
VClass root = (VClass) rootIt.next();
|
||||
if (root != null) {
|
||||
json += addChildren(vreq.getUnfilteredWebappDaoFactory(), root, 0, ontologyUri,counter);
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
int length = json.length();
|
||||
if ( length > 0 ) {
|
||||
json += " }";
|
||||
}
|
||||
}
|
||||
body.put("jsonTree",json);
|
||||
|
||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
}
|
||||
|
@ -131,21 +129,21 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
int length = rowElts.length();
|
||||
String leaves = "";
|
||||
leaves += rowElts;
|
||||
List childURIstrs = vcDao.getSubClassURIs(parent.getURI());
|
||||
List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List childClasses = new ArrayList();
|
||||
Iterator childURIstrIt = childURIstrs.iterator();
|
||||
List<VClass> childClasses = new ArrayList<VClass>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = (String) childURIstrIt.next();
|
||||
String URIstr = childURIstrIt.next();
|
||||
try {
|
||||
VClass child = (VClass) vcDao.getVClassByURI(URIstr);
|
||||
VClass child = vcDao.getVClassByURI(URIstr);
|
||||
if (!child.getURI().equals(OWL.Nothing.getURI())) {
|
||||
childClasses.add(child);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
Collections.sort(childClasses);
|
||||
Iterator childClassIt = childClasses.iterator();
|
||||
Iterator<VClass> childClassIt = childClasses.iterator();
|
||||
while (childClassIt.hasNext()) {
|
||||
VClass child = (VClass) childClassIt.next();
|
||||
leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter);
|
||||
|
@ -197,15 +195,16 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
tempString += "}, { \"name\": ";
|
||||
}
|
||||
try {
|
||||
tempString += "\"<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"'>"+ vcw.getLocalNameWithPrefix() +"</a>\", ";
|
||||
tempString += JSONUtils.quote("<a href='vclassEdit?uri=" +
|
||||
URLEncoder.encode(vcw.getURI(),"UTF-8") + "'>" +
|
||||
vcw.getLocalNameWithPrefix() + "</a>") +", ";
|
||||
} catch (Exception e) {
|
||||
tempString += "\" " + ((vcw.getLocalNameWithPrefix() == null) ? "" : vcw.getLocalNameWithPrefix()) + "\", ";
|
||||
tempString += JSONUtils.quote(((vcw.getLocalNameWithPrefix() == null)
|
||||
? "" : vcw.getLocalNameWithPrefix())) + ", ";
|
||||
}
|
||||
|
||||
String shortDef = ((vcw.getShortDef() == null) ? "" : vcw.getShortDef()) ;
|
||||
shortDef = shortDef.replace("\"","\\\"");
|
||||
shortDef = shortDef.replace("\'","\\\'");
|
||||
tempString += "\"data\": { \"shortDef\": \"" + shortDef + "\", ";
|
||||
tempString += "\"data\": { \"shortDef\": " + JSONUtils.quote(shortDef) + ", ";
|
||||
|
||||
// Get group name if it exists
|
||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
||||
|
@ -218,16 +217,17 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
tempString += "\"classGroup\": \"" + ((groupName == null) ? "" : groupName) + "\", ";
|
||||
tempString += "\"classGroup\": " + JSONUtils.quote(
|
||||
(groupName == null) ? "" : groupName) + ", ";
|
||||
// Get ontology name
|
||||
String ontName = null;
|
||||
try {
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
Ontology ont = ontDao.getOntologyByURI(vcw.getNamespace());
|
||||
ontName = ont.getName();
|
||||
} catch (Exception e) {}
|
||||
|
||||
tempString += "\"ontology\": \"" + ((ontName == null) ? "" : ontName) + "\"}, \"children\": [";
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = vcw.getNamespace();
|
||||
Ontology ont = ontDao.getOntologyByURI(ontName);
|
||||
if (ont != null && ont.getName() != null) {
|
||||
ontName = ont.getName();
|
||||
}
|
||||
tempString += "\"ontology\": " + JSONUtils.quote(
|
||||
(ontName == null) ? "" : ontName) + "}, \"children\": [";
|
||||
|
||||
previous_posn = position;
|
||||
}
|
||||
|
|
|
@ -2,19 +2,17 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -25,7 +23,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
@ -33,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
||||
|
||||
|
@ -106,7 +104,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
Iterator<DataProperty> rootIt = roots.iterator();
|
||||
if (!rootIt.hasNext()) {
|
||||
DataProperty dp = new DataProperty();
|
||||
dp.setURI(ontologyUri+"fake");
|
||||
dp.setURI(ontologyUri + "fake");
|
||||
String notFoundMessage = "<strong>No data properties found.</strong>";
|
||||
dp.setName(notFoundMessage);
|
||||
dp.setName(notFoundMessage);
|
||||
|
@ -142,19 +140,19 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
int length = details.length();
|
||||
String leaves = "";
|
||||
leaves += details;
|
||||
List childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List childProps = new ArrayList();
|
||||
Iterator childURIstrIt = childURIstrs.iterator();
|
||||
List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
|
||||
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
|
||||
List<DataProperty> childProps = new ArrayList<DataProperty>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = (String) childURIstrIt.next();
|
||||
DataProperty child = (DataProperty) dpDao.getDataPropertyByURI(URIstr);
|
||||
String URIstr = childURIstrIt.next();
|
||||
DataProperty child = dpDao.getDataPropertyByURI(URIstr);
|
||||
childProps.add(child);
|
||||
}
|
||||
Collections.sort(childProps);
|
||||
Iterator childPropIt = childProps.iterator();
|
||||
Iterator<DataProperty> childPropIt = childProps.iterator();
|
||||
while (childPropIt.hasNext()) {
|
||||
DataProperty child = (DataProperty) childPropIt.next();
|
||||
DataProperty child = childPropIt.next();
|
||||
leaves += addChildren(child, position+1, ontologyUri, counter);
|
||||
if (!childPropIt.hasNext()) {
|
||||
if ( ontologyUri == null ) {
|
||||
|
@ -206,34 +204,40 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
tempString += "}, { \"name\": ";
|
||||
}
|
||||
|
||||
String nameStr = dp.getPublicName()==null ? dp.getName()==null ? dp.getURI()==null ? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName();
|
||||
nameStr = nameStr.replace("\"","\\\"");
|
||||
nameStr = nameStr.replace("\'","\\\'");
|
||||
try {
|
||||
tempString += "\"<a href='datapropEdit?uri="+URLEncoder.encode(dp.getURI(),"UTF-8")+"'>" + nameStr + "</a>\", ";
|
||||
} catch (Exception e) {
|
||||
tempString += "\"" + nameStr + "\", ";
|
||||
log.error("Unsupported: URLEncoder.encode() with UTF-8");
|
||||
}
|
||||
String nameStr = dp.getPublicName() == null
|
||||
? dp.getName() == null
|
||||
? dp.getURI() == null
|
||||
? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName();
|
||||
|
||||
tempString += JSONUtils.quote(
|
||||
"<a href='datapropEdit?uri=" + URLEncoder.encode(
|
||||
dp.getURI()) + "'>" + nameStr + "</a>") + ", ";
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,22 +2,18 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -26,13 +22,13 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet {
|
||||
|
||||
|
@ -146,19 +142,19 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
|
|||
int length = details.length();
|
||||
String leaves = "";
|
||||
leaves += details;
|
||||
List childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List childProps = new ArrayList();
|
||||
Iterator childURIstrIt = childURIstrs.iterator();
|
||||
List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
|
||||
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
|
||||
List<ObjectProperty> childProps = new ArrayList<ObjectProperty>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = (String) childURIstrIt.next();
|
||||
ObjectProperty child = (ObjectProperty) opDao.getObjectPropertyByURI(URIstr);
|
||||
String URIstr = childURIstrIt.next();
|
||||
ObjectProperty child = opDao.getObjectPropertyByURI(URIstr);
|
||||
childProps.add(child);
|
||||
}
|
||||
Collections.sort(childProps);
|
||||
Iterator childPropIt = childProps.iterator();
|
||||
Iterator<ObjectProperty> childPropIt = childProps.iterator();
|
||||
while (childPropIt.hasNext()) {
|
||||
ObjectProperty child = (ObjectProperty) childPropIt.next();
|
||||
ObjectProperty child = childPropIt.next();
|
||||
leaves += addChildren(child, position+1, ontologyUri, counter);
|
||||
if (!childPropIt.hasNext()) {
|
||||
if ( ontologyUri == null ) {
|
||||
|
@ -208,34 +204,45 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
|
|||
tempString += "}, { \"name\": ";
|
||||
}
|
||||
|
||||
String nameStr = getDisplayLabel(op)==null ? "(no name)" : getDisplayLabel(op);
|
||||
nameStr = nameStr.replace("\"","\\\"");
|
||||
nameStr = nameStr.replace("\'","\\\'");
|
||||
String nameStr = getDisplayLabel(op) == null ? "(no name)" : getDisplayLabel(op);
|
||||
|
||||
try {
|
||||
tempString += "\"<a href='propertyEdit?uri="+URLEncoder.encode(op.getURI(),"UTF-8") + "'>" + nameStr +"</a>\", ";
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
tempString += "\"" + nameStr + "\"";
|
||||
log.error("Unsupported: URLEncoder.encode() with UTF-8");
|
||||
}
|
||||
|
||||
tempString += "\"data\": { \"internalName\": \"" + op.getLocalNameWithPrefix() + "\", ";
|
||||
tempString += JSONUtils.quote(
|
||||
"<a href='propertyEdit?uri=" + URLEncoder.encode(
|
||||
op.getURI()) + "'>" + nameStr + "</a>") + ", ";
|
||||
|
||||
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\"";
|
||||
}
|
||||
|
|
|
@ -822,13 +822,11 @@ public class JenaIngestController extends BaseEditController {
|
|||
|
||||
private void doAttachModel(String modelName, ModelMaker modelMaker) {
|
||||
if (attachedModels.containsKey(modelName)) {
|
||||
return;
|
||||
doDetachModel(modelName, modelMaker);
|
||||
}
|
||||
Model m = modelMaker.getModel(modelName);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_ABOX).addSubModel(m);
|
||||
Model m = ModelFactory.createDefaultModel();
|
||||
m.add(modelMaker.getModel(modelName));
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX).addSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_ABOX).addSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_TBOX).addSubModel(m);
|
||||
attachedModels.put(modelName, m);
|
||||
log.info("Attached " + modelName + " (" + m.hashCode() + ") to webapp");
|
||||
}
|
||||
|
@ -838,10 +836,7 @@ public class JenaIngestController extends BaseEditController {
|
|||
if (m == null) {
|
||||
return;
|
||||
}
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_ABOX).removeSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX).removeSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_ABOX).removeSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_TBOX).removeSubModel(m);
|
||||
attachedModels.remove(modelName);
|
||||
log.info("Detached " + modelName + " (" + m.hashCode() + ") from webapp");
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -183,9 +183,11 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
|||
if (!VitroVocabulary.vitroURI.equals(dp.getNamespace())) {
|
||||
log.debug("datapropFromOntProperty(): no ontology object found for the namespace "+dp.getNamespace());
|
||||
}
|
||||
dp.setLocalNameWithPrefix(dp.getLocalName());
|
||||
dp.setPickListName(getLabelOrId(op));
|
||||
} else {
|
||||
dp.setLocalNameWithPrefix(o.getPrefix()==null?(o.getName()==null?"unspec:"+dp.getLocalName():o.getName()+":"+dp.getLocalName()):o.getPrefix()+":"+dp.getLocalName());
|
||||
dp.setPickListName(dp.getLocalName()+o.getPrefix()==null?(o.getName()==null?" (unspec:)":" ("+o.getName()+")"):" ("+o.getPrefix()+")");
|
||||
dp.setPickListName(getLabelOrId(op)+o.getPrefix()==null?(o.getName()==null?" (unspec:)":" ("+o.getName()+")"):" ("+o.getPrefix()+")");
|
||||
}
|
||||
dp.setName(op.getLocalName());
|
||||
dp.setPublicName(getLabelOrId(op));
|
||||
|
|
|
@ -96,15 +96,17 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
p.setLocalName(op.getLocalName());
|
||||
OntologyDao oDao=getWebappDaoFactory().getOntologyDao();
|
||||
Ontology o = oDao.getOntologyByURI(p.getNamespace());
|
||||
if (o==null) {
|
||||
if (o == null) {
|
||||
if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) {
|
||||
log.debug("propertyFromOntProperty(): no ontology object found for the namespace "+p.getNamespace());
|
||||
}
|
||||
p.setLocalNameWithPrefix(p.getLocalName());
|
||||
p.setPickListName(getLabelOrId(op));
|
||||
} else {
|
||||
String prefix = o.getPrefix()==null?(o.getName()==null?"unspec":o.getName()):o.getPrefix();
|
||||
p.setLocalNameWithPrefix(prefix+":"+p.getLocalName());
|
||||
//log.warn("setting pickListName to: "+p.getLocalName()+" ("+prefix+")");
|
||||
p.setPickListName(p.getLocalName()+" ("+prefix+")");
|
||||
p.setPickListName(getLabelOrId(op) + " ("+prefix+")");
|
||||
}
|
||||
String propertyName = getPropertyStringValue(op,PROPERTY_FULLPROPERTYNAMEANNOT);
|
||||
if (op.getLabel(null) != null)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -61,7 +60,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||
|
||||
|
@ -148,8 +147,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
labelStr += getLabelForClass(ccls.getOperand(),withPrefix,forPickList);
|
||||
} else if (cls.isIntersectionClass()) {
|
||||
IntersectionClass icls = cls.as(IntersectionClass.class);
|
||||
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) {
|
||||
OntClass operand = (OntClass) operandIt.next();
|
||||
for (Iterator<? extends OntClass> operandIt =
|
||||
icls.listOperands(); operandIt.hasNext();) {
|
||||
OntClass operand = operandIt.next();
|
||||
labelStr += getLabelForClass(operand,withPrefix,forPickList);
|
||||
if (operandIt.hasNext()) {
|
||||
labelStr += " and ";
|
||||
|
@ -157,8 +157,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
}
|
||||
} else if (cls.isUnionClass()) {
|
||||
UnionClass icls = cls.as(UnionClass.class);
|
||||
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) {
|
||||
OntClass operand = (OntClass) operandIt.next();
|
||||
for (Iterator<? extends OntClass> operandIt =
|
||||
icls.listOperands(); operandIt.hasNext();) {
|
||||
OntClass operand = operandIt.next();
|
||||
labelStr += getLabelForClass(operand,withPrefix,forPickList);
|
||||
if (operandIt.hasNext()) {
|
||||
labelStr += " or ";
|
||||
|
@ -170,7 +171,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
// BJL23 2009-02-19
|
||||
// I'm putting the link markup in because I need it,
|
||||
// but obviously we need to factor this out into the display layer.
|
||||
return "<a href=\"vclassEdit?uri="+URLEncoder.encode(getClassURIStr(cls),"UTF-8")+"\">[anonymous class]</a>";
|
||||
return "<a href=\"vclassEdit?uri=" +
|
||||
URLEncoder.encode(getClassURIStr(cls)) +
|
||||
"\">[anonymous class]</a>";
|
||||
}
|
||||
} else {
|
||||
if (withPrefix || forPickList) {
|
||||
|
@ -244,8 +247,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
List<String> uriList = new ArrayList<String>();
|
||||
getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
for (Iterator i = ontClass.listDisjointWith(); i.hasNext(); ) {
|
||||
OntClass disjointClass = (OntClass) i.next();
|
||||
for (Iterator<? extends OntClass> i =
|
||||
ontClass.listDisjointWith(); i.hasNext(); ) {
|
||||
OntClass disjointClass = i.next();
|
||||
uriList.add(getClassURIStr(disjointClass));
|
||||
}
|
||||
} catch (ProfileException pe) {
|
||||
|
@ -288,10 +292,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
OntClass ontClass = getOntClass(getOntModel(), classURI);
|
||||
ClosableIterator equivalentOntClassIt = ontClass.listEquivalentClasses();
|
||||
ClosableIterator<OntClass> equivalentOntClassIt = ontClass.listEquivalentClasses();
|
||||
try {
|
||||
for (Iterator eqOntClassIt = equivalentOntClassIt; eqOntClassIt.hasNext(); ) {
|
||||
OntClass eqClass = (OntClass) eqOntClassIt.next();
|
||||
for (Iterator<OntClass> eqOntClassIt =
|
||||
equivalentOntClassIt; eqOntClassIt.hasNext(); ) {
|
||||
OntClass eqClass = eqOntClassIt.next();
|
||||
equivalentClassURIs.add(getClassURIStr(eqClass));
|
||||
}
|
||||
} finally {
|
||||
|
@ -482,10 +487,6 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
return classes;
|
||||
}
|
||||
|
||||
private Iterator<OntClass> smarterListHierarchyRootClasses(OntModel ontModel) {
|
||||
return smarterListHierarchyRootClasses(ontModel, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The basic idea here is that we ignore anonymous superclasses for the purpose
|
||||
* of determining whether something is a root class.
|
||||
|
@ -569,16 +570,21 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
OntModel ontModel = getOntModel();
|
||||
ontModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
Iterator<OntClass> ontClassIt = ontModel.listClasses();
|
||||
Iterator<Resource> ontClassIt = ontModel.listResourcesWithProperty(
|
||||
RDF.type, OWL.Class);
|
||||
while (ontClassIt.hasNext()) {
|
||||
OntClass ontClass = ontClassIt.next();
|
||||
Resource ontClass = ontClassIt.next();
|
||||
if (ontologyURI.equals(ontClass.getNameSpace())) {
|
||||
boolean root = true;
|
||||
StmtIterator superStmtIt = ontModel.listStatements(ontClass, RDFS.subClassOf, (RDFNode) null);
|
||||
StmtIterator superStmtIt = ontModel.listStatements(
|
||||
ontClass, RDFS.subClassOf, (RDFNode) null);
|
||||
try {
|
||||
while (superStmtIt.hasNext()) {
|
||||
Statement superStmt = superStmtIt.nextStatement();
|
||||
if ( superStmt.getObject().isResource() && ontologyURI.equals(((Resource) superStmt.getObject()).getNameSpace()) ) {
|
||||
if ( superStmt.getObject().isResource()
|
||||
&& ontologyURI.equals(
|
||||
((Resource) superStmt.getObject())
|
||||
.getNameSpace()) ) {
|
||||
root = false;
|
||||
break;
|
||||
}
|
||||
|
@ -586,8 +592,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
} finally {
|
||||
superStmtIt.close();
|
||||
}
|
||||
if (root) {
|
||||
ontologyRootClasses.add(new VClassJena(ontClass,getWebappDaoFactory()));
|
||||
if (root && ontClass.canAs(OntClass.class)) {
|
||||
ontologyRootClasses.add(new VClassJena(
|
||||
(OntClass) ontClass.as(OntClass.class),
|
||||
getWebappDaoFactory()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -598,12 +606,12 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
}
|
||||
|
||||
public List <String> getSubClassURIs(String classURI) {
|
||||
List subURIs = new ArrayList();
|
||||
List<String> subURIs = new ArrayList<String>();
|
||||
OntClass superClass = getOntClass(getOntModel(),classURI);
|
||||
try {
|
||||
Iterator subIt = superClass.listSubClasses(true);
|
||||
Iterator<OntClass> subIt = superClass.listSubClasses(true);
|
||||
while (subIt.hasNext()) {
|
||||
OntClass cls = (OntClass) subIt.next();
|
||||
OntClass cls = subIt.next();
|
||||
subURIs.add(getClassURIStr(cls));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -617,10 +625,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
}
|
||||
|
||||
public List <String> getSuperClassURIs(String classURI, boolean direct) {
|
||||
List supURIs = new ArrayList();
|
||||
List<String> supURIs = new ArrayList<String>();
|
||||
OntClass subClass = getOntClass(getOntModel(), classURI);
|
||||
try {
|
||||
Iterator supIt = subClass.listSuperClasses(direct);
|
||||
Iterator<OntClass> supIt = subClass.listSuperClasses(direct);
|
||||
while (supIt.hasNext()) {
|
||||
OntClass cls = (OntClass) supIt.next();
|
||||
supURIs.add(getClassURIStr(cls));
|
||||
|
@ -717,12 +725,16 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
OntResource superclass = null;
|
||||
if (vclassURI != null) {
|
||||
// TODO need a getAllSuperPropertyURIs method in ObjectPropertyDao
|
||||
List<String> superproperties = getWebappDaoFactory().getObjectPropertyDao().getSuperPropertyURIs(propertyURI,false);
|
||||
List<String> superproperties = getWebappDaoFactory()
|
||||
.getObjectPropertyDao()
|
||||
.getSuperPropertyURIs(propertyURI, false);
|
||||
superproperties.add(propertyURI);
|
||||
HashSet<String> subjSuperclasses = new HashSet<String>(getAllSuperClassURIs(vclassURI));
|
||||
HashSet<String> subjSuperclasses = new HashSet<String>(
|
||||
getAllSuperClassURIs(vclassURI));
|
||||
subjSuperclasses.add(vclassURI);
|
||||
for (String objectPropertyURI : superproperties) {
|
||||
for (Iterator restStmtIt = getOntModel().listStatements(null,OWL.onProperty,getOntModel().getProperty(objectPropertyURI)); restStmtIt.hasNext();) {
|
||||
for (Iterator restStmtIt = getOntModel().listStatements(
|
||||
null,OWL.onProperty,getOntModel().getProperty(objectPropertyURI)); restStmtIt.hasNext();) {
|
||||
Statement restStmt = (Statement) restStmtIt.next();
|
||||
Resource restRes = restStmt.getSubject();
|
||||
for (Iterator axStmtIt = getOntModel().listStatements(null,null,restRes); axStmtIt.hasNext();) {
|
||||
|
|
|
@ -94,21 +94,25 @@ public class KnowledgeBaseUpdater {
|
|||
|
||||
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel());
|
||||
|
||||
//process the TBox before the ABox
|
||||
try {
|
||||
log.debug("\tupdating tbox annotations");
|
||||
updateTBoxAnnotations();
|
||||
} catch (Exception e) {
|
||||
log.error(e,e);
|
||||
// Only modify the TBox and migration metadata the first time
|
||||
if(updateRequired(servletContext)) {
|
||||
//process the TBox before the ABox
|
||||
try {
|
||||
log.debug("\tupdating tbox annotations");
|
||||
updateTBoxAnnotations();
|
||||
} catch (Exception e) {
|
||||
log.error(e,e);
|
||||
}
|
||||
|
||||
try {
|
||||
migrateMigrationMetadata(servletContext);
|
||||
logger.log("Migrated migration metadata");
|
||||
} catch (Exception e) {
|
||||
log.error("unable to migrate migration metadata " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
migrateMigrationMetadata(servletContext);
|
||||
logger.log("Migrated migration metadata");
|
||||
} catch (Exception e) {
|
||||
log.error("unable to migrate migration metadata " + e.getMessage());
|
||||
}
|
||||
|
||||
// update ABox data any time
|
||||
log.info("performing SPARQL CONSTRUCT additions");
|
||||
performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD);
|
||||
|
||||
|
|
|
@ -138,24 +138,26 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
|||
KnowledgeBaseUpdater ontologyUpdater = new KnowledgeBaseUpdater(settings);
|
||||
boolean requiredUpdate = ontologyUpdater.updateRequired(ctx);
|
||||
|
||||
try {
|
||||
ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE);
|
||||
log.info("Data migration required");
|
||||
migrationChangesMade = ontologyUpdater.update(ctx);
|
||||
if (tryMigrateDisplay) {
|
||||
try {
|
||||
migrateDisplayModel(settings);
|
||||
log.info("Migrated display model");
|
||||
} catch (Exception e) {
|
||||
log.warn("unable to successfully update display model: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
// reload the display model since the TBoxUpdater may have
|
||||
// modified it
|
||||
new ApplicationModelSetup().contextInitialized(sce);
|
||||
} catch (Exception ioe) {
|
||||
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", ioe);
|
||||
}
|
||||
if(!JenaDataSourceSetupBase.isFirstStartup()) {
|
||||
try {
|
||||
ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE);
|
||||
log.info("Data migration required");
|
||||
migrationChangesMade = ontologyUpdater.update(ctx);
|
||||
if (tryMigrateDisplay) {
|
||||
try {
|
||||
migrateDisplayModel(settings);
|
||||
log.info("Migrated display model");
|
||||
} catch (Exception e) {
|
||||
log.warn("unable to successfully update display model: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
// reload the display model since the TBoxUpdater may have
|
||||
// modified it
|
||||
new ApplicationModelSetup().contextInitialized(sce);
|
||||
} catch (Exception ioe) {
|
||||
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
SimpleReasoner simpleReasoner = (SimpleReasoner) sce.getServletContext()
|
||||
.getAttribute(SimpleReasoner.class.getName());
|
||||
|
|
|
@ -476,6 +476,19 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
return null;
|
||||
}
|
||||
|
||||
public PropertyTemplateModel getProperty(String propertyUri, String rangeUri) {
|
||||
|
||||
for (PropertyGroupTemplateModel pgtm : groups) {
|
||||
List<PropertyTemplateModel> properties = pgtm.getProperties();
|
||||
for (PropertyTemplateModel ptm : properties) {
|
||||
if (propertyUri.equals(ptm.getUri()) && rangeUri.equals(ptm.getRangeUri())) {
|
||||
return ptm;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PropertyTemplateModel pullProperty(String propertyUri) {
|
||||
return pullProperty(propertyUri, null);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ function init(){
|
|||
<input type="hidden" name="action" value="attachModel"/>
|
||||
<input type="hidden" name="modelName" value="${modelName}"/>
|
||||
<input type="hidden" name="modelType" value="${modelType}"/>
|
||||
<input type="submit" name="submit" value="attach to TBox (ontology)"/>
|
||||
<input type="submit" name="submit" value="attach snapshot to ontology"/>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -104,7 +104,7 @@ function init(){
|
|||
<input type="hidden" name="action" value="detachModel"/>
|
||||
<input type="hidden" name="modelName" value="${modelName}"/>
|
||||
<input type="hidden" name="modelType" value="${modelType}"/>
|
||||
<input type="submit" name="submit" value="detach from TBox (ontology)"/>
|
||||
<input type="submit" name="submit" value="detach snapshot from ontology"/>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -22,6 +22,24 @@
|
|||
</#if>
|
||||
</#function>
|
||||
|
||||
<#-- Return true iff there are statements for this property -->
|
||||
<#function hasVisualizationStatements propertyGroups propertyName rangeUri>
|
||||
|
||||
<#local property = propertyGroups.getProperty(propertyName, rangeUri)!>
|
||||
|
||||
<#-- First ensure that the property is defined
|
||||
(an unpopulated property while logged out is undefined) -->
|
||||
<#if ! property?has_content>
|
||||
<#return false>
|
||||
</#if>
|
||||
|
||||
<#if property.collatedBySubclass!false> <#-- collated object property-->
|
||||
<#return property.subclasses?has_content>
|
||||
<#else>
|
||||
<#return property.statements?has_content> <#-- data property or uncollated object property -->
|
||||
</#if>
|
||||
|
||||
</#function>
|
||||
|
||||
<#-----------------------------------------------------------------------------
|
||||
Macros for generating property lists
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue