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

This commit is contained in:
hudajkhan 2013-10-01 11:24:30 -04:00
commit 8d520895ac
27 changed files with 480 additions and 457 deletions

View file

@ -4,6 +4,7 @@
@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> . @prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @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. ### ### This file defines the default menu for vitro. ###
@ -35,39 +36,3 @@ display:Home
<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#homeDataGetter> <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#homeDataGetter>
a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.BrowseDataGetter> . 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" .

View 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" .

View file

@ -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() { protected WebappDaoFactory getWebappDaoFactory() {
return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory(); return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory();
} }

View file

@ -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;

View file

@ -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.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.shared.Lock; 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.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.controller.BaseEditController; 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.controller.VitroRequest; 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; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
public class RestrictionOperationController extends BaseEditController { public class RestrictionOperationController extends BaseEditController {
@ -44,7 +47,8 @@ public class RestrictionOperationController extends BaseEditController {
try { try {
OntModel ontModel = getOntModel(request, getServletContext()); OntModel ontModel = ModelAccess.on(
getServletContext()).getOntModel(ModelID.BASE_TBOX);
HashMap epoHash = null; HashMap epoHash = null;
EditProcessObject epo = null; EditProcessObject epo = null;

View file

@ -14,6 +14,7 @@ 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;
import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDFS; import com.hp.hpl.jena.vocabulary.RDFS;
import com.ibm.icu.text.Collator; import com.ibm.icu.text.Collator;
@ -63,7 +64,7 @@ public class RestrictionRetryController extends BaseEditController {
List<Option> onPropertyList = new LinkedList<Option>(); List<Option> onPropertyList = new LinkedList<Option>();
Collections.sort(pList, new PropSorter()); Collections.sort(pList, new PropSorter());
for (Property p: pList) { for (Property p: pList) {
onPropertyList.add( new Option(p.getURI(),p.getLocalNameWithPrefix()) ); onPropertyList.add( new Option(p.getURI(),p.getPickListName()));
} }
epo.setFormObject(new FormObject()); epo.setFormObject(new FormObject());
@ -117,8 +118,20 @@ public class RestrictionRetryController extends BaseEditController {
private List<Option> getValueClassOptionList(VitroRequest request) { private List<Option> getValueClassOptionList(VitroRequest request) {
List<Option> valueClassOptionList = new LinkedList<Option>(); List<Option> valueClassOptionList = new LinkedList<Option>();
VClassDao vcDao = request.getUnfilteredWebappDaoFactory().getVClassDao(); VClassDao vcDao = request.getUnfilteredWebappDaoFactory().getVClassDao();
for (VClass vc: vcDao.getAllVclasses()) { List<VClass> vclasses = vcDao.getAllVclasses();
valueClassOptionList.add(new Option(vc.getURI(), vc.getLocalNameWithPrefix())); 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; return valueClassOptionList;
} }

View file

@ -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.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; 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.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.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
@ -64,10 +65,12 @@ public class VclassRetryController extends BaseEditController {
action = epo.getAction(); action = epo.getAction();
} }
VClassDao vcwDao = request.getUnfilteredAssertionsWebappDaoFactory().getVClassDao(); WebappDaoFactory wadf = ModelAccess.on(getServletContext()).getWebappDaoFactory();
VClassDao vcwDao = wadf.getVClassDao();
epo.setDataAccessObject(vcwDao); epo.setDataAccessObject(vcwDao);
VClassGroupDao cgDao = request.getUnfilteredWebappDaoFactory().getVClassGroupDao(); VClassGroupDao cgDao = wadf.getVClassGroupDao();
OntologyDao oDao = request.getUnfilteredWebappDaoFactory().getOntologyDao(); OntologyDao oDao = wadf.getOntologyDao();
VClass vclassForEditing = null; VClass vclassForEditing = null;
if (!epo.getUseRecycledBean()){ if (!epo.getUseRecycledBean()){
@ -82,18 +85,12 @@ public class VclassRetryController extends BaseEditController {
} else { } else {
vclassForEditing = new VClass(); vclassForEditing = new VClass();
if (request.getParameter("GroupId") != null) { if (request.getParameter("GroupId") != null) {
try { vclassForEditing.setGroupURI(request.getParameter("GroupURI"));
vclassForEditing.setGroupURI(request.getParameter("GroupURI"));
} catch (NumberFormatException e) {
// too bad
}
} }
} }
epo.setOriginalBean(vclassForEditing); epo.setOriginalBean(vclassForEditing);
} else { } else {
vclassForEditing = (VClass) epo.getNewBean(); vclassForEditing = (VClass) epo.getNewBean();
// action = "update";
// log.error("using newBean");
} }
//make a simple mask for the class's id //make a simple mask for the class's id

View file

@ -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")+"&amp;controller=Classgroup'>"+publicName+"</a>\", "; json += "{ \"name\": " + JSONUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI())+"&amp;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

View file

@ -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\" } }" ;
} }

View file

@ -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")+"&amp;controller=PropertyGroup'>" + publicName + "</a>\", "; json += "{ \"name\": " + JSONUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(pg.getURI(),"UTF-8")+"&amp;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 += "\"\", ";

View file

@ -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\" } }" ;
} }

View file

@ -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);

View file

@ -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;
} }

View file

@ -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());
}
}
} }

View file

@ -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\"";
} }

View file

@ -822,13 +822,11 @@ public class JenaIngestController extends BaseEditController {
private void doAttachModel(String modelName, ModelMaker modelMaker) { private void doAttachModel(String modelName, ModelMaker modelMaker) {
if (attachedModels.containsKey(modelName)) { if (attachedModels.containsKey(modelName)) {
return; doDetachModel(modelName, modelMaker);
} }
Model m = modelMaker.getModel(modelName); Model m = ModelFactory.createDefaultModel();
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_ABOX).addSubModel(m); m.add(modelMaker.getModel(modelName));
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX).addSubModel(m); 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); attachedModels.put(modelName, m);
log.info("Attached " + modelName + " (" + m.hashCode() + ") to webapp"); log.info("Attached " + modelName + " (" + m.hashCode() + ") to webapp");
} }
@ -838,10 +836,7 @@ public class JenaIngestController extends BaseEditController {
if (m == null) { if (m == null) {
return; return;
} }
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_ABOX).removeSubModel(m);
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX).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); attachedModels.remove(modelName);
log.info("Detached " + modelName + " (" + m.hashCode() + ") from webapp"); log.info("Detached " + modelName + " (" + m.hashCode() + ") from webapp");
} }

View file

@ -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";

View file

@ -183,9 +183,11 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
if (!VitroVocabulary.vitroURI.equals(dp.getNamespace())) { if (!VitroVocabulary.vitroURI.equals(dp.getNamespace())) {
log.debug("datapropFromOntProperty(): no ontology object found for the namespace "+dp.getNamespace()); log.debug("datapropFromOntProperty(): no ontology object found for the namespace "+dp.getNamespace());
} }
dp.setLocalNameWithPrefix(dp.getLocalName());
dp.setPickListName(getLabelOrId(op));
} else { } else {
dp.setLocalNameWithPrefix(o.getPrefix()==null?(o.getName()==null?"unspec:"+dp.getLocalName():o.getName()+":"+dp.getLocalName()):o.getPrefix()+":"+dp.getLocalName()); 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.setName(op.getLocalName());
dp.setPublicName(getLabelOrId(op)); dp.setPublicName(getLabelOrId(op));

View file

@ -96,15 +96,17 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
p.setLocalName(op.getLocalName()); p.setLocalName(op.getLocalName());
OntologyDao oDao=getWebappDaoFactory().getOntologyDao(); OntologyDao oDao=getWebappDaoFactory().getOntologyDao();
Ontology o = 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("propertyFromOntProperty(): no ontology object found for the namespace "+p.getNamespace()); log.debug("propertyFromOntProperty(): no ontology object found for the namespace "+p.getNamespace());
} }
p.setLocalNameWithPrefix(p.getLocalName());
p.setPickListName(getLabelOrId(op));
} else { } else {
String prefix = o.getPrefix()==null?(o.getName()==null?"unspec":o.getName()):o.getPrefix(); String prefix = o.getPrefix()==null?(o.getName()==null?"unspec":o.getName()):o.getPrefix();
p.setLocalNameWithPrefix(prefix+":"+p.getLocalName()); p.setLocalNameWithPrefix(prefix+":"+p.getLocalName());
//log.warn("setting pickListName to: "+p.getLocalName()+" ("+prefix+")"); //log.warn("setting pickListName to: "+p.getLocalName()+" ("+prefix+")");
p.setPickListName(p.getLocalName()+" ("+prefix+")"); p.setPickListName(getLabelOrId(op) + " ("+prefix+")");
} }
String propertyName = getPropertyStringValue(op,PROPERTY_FULLPROPERTYNAMEANNOT); String propertyName = getPropertyStringValue(op,PROPERTY_FULLPROPERTYNAMEANNOT);
if (op.getLabel(null) != null) if (op.getLabel(null) != null)

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena; package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; 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.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; 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.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 { public class VClassDaoJena extends JenaBaseDao implements VClassDao {
@ -148,8 +147,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
labelStr += getLabelForClass(ccls.getOperand(),withPrefix,forPickList); labelStr += getLabelForClass(ccls.getOperand(),withPrefix,forPickList);
} else if (cls.isIntersectionClass()) { } else if (cls.isIntersectionClass()) {
IntersectionClass icls = cls.as(IntersectionClass.class); IntersectionClass icls = cls.as(IntersectionClass.class);
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) { for (Iterator<? extends OntClass> operandIt =
OntClass operand = (OntClass) operandIt.next(); icls.listOperands(); operandIt.hasNext();) {
OntClass operand = operandIt.next();
labelStr += getLabelForClass(operand,withPrefix,forPickList); labelStr += getLabelForClass(operand,withPrefix,forPickList);
if (operandIt.hasNext()) { if (operandIt.hasNext()) {
labelStr += " and "; labelStr += " and ";
@ -157,8 +157,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
} }
} else if (cls.isUnionClass()) { } else if (cls.isUnionClass()) {
UnionClass icls = cls.as(UnionClass.class); UnionClass icls = cls.as(UnionClass.class);
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) { for (Iterator<? extends OntClass> operandIt =
OntClass operand = (OntClass) operandIt.next(); icls.listOperands(); operandIt.hasNext();) {
OntClass operand = operandIt.next();
labelStr += getLabelForClass(operand,withPrefix,forPickList); labelStr += getLabelForClass(operand,withPrefix,forPickList);
if (operandIt.hasNext()) { if (operandIt.hasNext()) {
labelStr += " or "; labelStr += " or ";
@ -170,7 +171,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
// BJL23 2009-02-19 // BJL23 2009-02-19
// I'm putting the link markup in because I need it, // I'm putting the link markup in because I need it,
// but obviously we need to factor this out into the display layer. // 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 { } else {
if (withPrefix || forPickList) { if (withPrefix || forPickList) {
@ -244,8 +247,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
List<String> uriList = new ArrayList<String>(); List<String> uriList = new ArrayList<String>();
getOntModel().enterCriticalSection(Lock.READ); getOntModel().enterCriticalSection(Lock.READ);
try { try {
for (Iterator i = ontClass.listDisjointWith(); i.hasNext(); ) { for (Iterator<? extends OntClass> i =
OntClass disjointClass = (OntClass) i.next(); ontClass.listDisjointWith(); i.hasNext(); ) {
OntClass disjointClass = i.next();
uriList.add(getClassURIStr(disjointClass)); uriList.add(getClassURIStr(disjointClass));
} }
} catch (ProfileException pe) { } catch (ProfileException pe) {
@ -288,10 +292,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
getOntModel().enterCriticalSection(Lock.READ); getOntModel().enterCriticalSection(Lock.READ);
try { try {
OntClass ontClass = getOntClass(getOntModel(), classURI); OntClass ontClass = getOntClass(getOntModel(), classURI);
ClosableIterator equivalentOntClassIt = ontClass.listEquivalentClasses(); ClosableIterator<OntClass> equivalentOntClassIt = ontClass.listEquivalentClasses();
try { try {
for (Iterator eqOntClassIt = equivalentOntClassIt; eqOntClassIt.hasNext(); ) { for (Iterator<OntClass> eqOntClassIt =
OntClass eqClass = (OntClass) eqOntClassIt.next(); equivalentOntClassIt; eqOntClassIt.hasNext(); ) {
OntClass eqClass = eqOntClassIt.next();
equivalentClassURIs.add(getClassURIStr(eqClass)); equivalentClassURIs.add(getClassURIStr(eqClass));
} }
} finally { } finally {
@ -482,10 +487,6 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
return classes; 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 * The basic idea here is that we ignore anonymous superclasses for the purpose
* of determining whether something is a root class. * of determining whether something is a root class.
@ -569,16 +570,21 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
OntModel ontModel = getOntModel(); OntModel ontModel = getOntModel();
ontModel.enterCriticalSection(Lock.READ); ontModel.enterCriticalSection(Lock.READ);
try { try {
Iterator<OntClass> ontClassIt = ontModel.listClasses(); Iterator<Resource> ontClassIt = ontModel.listResourcesWithProperty(
RDF.type, OWL.Class);
while (ontClassIt.hasNext()) { while (ontClassIt.hasNext()) {
OntClass ontClass = ontClassIt.next(); Resource ontClass = ontClassIt.next();
if (ontologyURI.equals(ontClass.getNameSpace())) { if (ontologyURI.equals(ontClass.getNameSpace())) {
boolean root = true; boolean root = true;
StmtIterator superStmtIt = ontModel.listStatements(ontClass, RDFS.subClassOf, (RDFNode) null); StmtIterator superStmtIt = ontModel.listStatements(
ontClass, RDFS.subClassOf, (RDFNode) null);
try { try {
while (superStmtIt.hasNext()) { while (superStmtIt.hasNext()) {
Statement superStmt = superStmtIt.nextStatement(); 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; root = false;
break; break;
} }
@ -586,8 +592,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
} finally { } finally {
superStmtIt.close(); superStmtIt.close();
} }
if (root) { if (root && ontClass.canAs(OntClass.class)) {
ontologyRootClasses.add(new VClassJena(ontClass,getWebappDaoFactory())); 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) { public List <String> getSubClassURIs(String classURI) {
List subURIs = new ArrayList(); List<String> subURIs = new ArrayList<String>();
OntClass superClass = getOntClass(getOntModel(),classURI); OntClass superClass = getOntClass(getOntModel(),classURI);
try { try {
Iterator subIt = superClass.listSubClasses(true); Iterator<OntClass> subIt = superClass.listSubClasses(true);
while (subIt.hasNext()) { while (subIt.hasNext()) {
OntClass cls = (OntClass) subIt.next(); OntClass cls = subIt.next();
subURIs.add(getClassURIStr(cls)); subURIs.add(getClassURIStr(cls));
} }
} catch (Exception e) { } catch (Exception e) {
@ -617,10 +625,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
} }
public List <String> getSuperClassURIs(String classURI, boolean direct) { public List <String> getSuperClassURIs(String classURI, boolean direct) {
List supURIs = new ArrayList(); List<String> supURIs = new ArrayList<String>();
OntClass subClass = getOntClass(getOntModel(), classURI); OntClass subClass = getOntClass(getOntModel(), classURI);
try { try {
Iterator supIt = subClass.listSuperClasses(direct); Iterator<OntClass> supIt = subClass.listSuperClasses(direct);
while (supIt.hasNext()) { while (supIt.hasNext()) {
OntClass cls = (OntClass) supIt.next(); OntClass cls = (OntClass) supIt.next();
supURIs.add(getClassURIStr(cls)); supURIs.add(getClassURIStr(cls));
@ -717,12 +725,16 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
OntResource superclass = null; OntResource superclass = null;
if (vclassURI != null) { if (vclassURI != null) {
// TODO need a getAllSuperPropertyURIs method in ObjectPropertyDao // 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); superproperties.add(propertyURI);
HashSet<String> subjSuperclasses = new HashSet<String>(getAllSuperClassURIs(vclassURI)); HashSet<String> subjSuperclasses = new HashSet<String>(
getAllSuperClassURIs(vclassURI));
subjSuperclasses.add(vclassURI); subjSuperclasses.add(vclassURI);
for (String objectPropertyURI : superproperties) { 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(); Statement restStmt = (Statement) restStmtIt.next();
Resource restRes = restStmt.getSubject(); Resource restRes = restStmt.getSubject();
for (Iterator axStmtIt = getOntModel().listStatements(null,null,restRes); axStmtIt.hasNext();) { for (Iterator axStmtIt = getOntModel().listStatements(null,null,restRes); axStmtIt.hasNext();) {

View file

@ -94,21 +94,25 @@ public class KnowledgeBaseUpdater {
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel()); AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel());
//process the TBox before the ABox // Only modify the TBox and migration metadata the first time
try { if(updateRequired(servletContext)) {
log.debug("\tupdating tbox annotations"); //process the TBox before the ABox
updateTBoxAnnotations(); try {
} catch (Exception e) { log.debug("\tupdating tbox annotations");
log.error(e,e); 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 { // update ABox data any time
migrateMigrationMetadata(servletContext);
logger.log("Migrated migration metadata");
} catch (Exception e) {
log.error("unable to migrate migration metadata " + e.getMessage());
}
log.info("performing SPARQL CONSTRUCT additions"); log.info("performing SPARQL CONSTRUCT additions");
performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD); performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD);

View file

@ -138,23 +138,25 @@ public class UpdateKnowledgeBase implements ServletContextListener {
KnowledgeBaseUpdater ontologyUpdater = new KnowledgeBaseUpdater(settings); KnowledgeBaseUpdater ontologyUpdater = new KnowledgeBaseUpdater(settings);
boolean requiredUpdate = ontologyUpdater.updateRequired(ctx); boolean requiredUpdate = ontologyUpdater.updateRequired(ctx);
try { if(!JenaDataSourceSetupBase.isFirstStartup()) {
ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE); try {
log.info("Data migration required"); ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE);
migrationChangesMade = ontologyUpdater.update(ctx); log.info("Data migration required");
if (tryMigrateDisplay) { migrationChangesMade = ontologyUpdater.update(ctx);
try { if (tryMigrateDisplay) {
migrateDisplayModel(settings); try {
log.info("Migrated display model"); migrateDisplayModel(settings);
} catch (Exception e) { log.info("Migrated display model");
log.warn("unable to successfully update display model: " + e.getMessage()); } catch (Exception e) {
} log.warn("unable to successfully update display model: " + e.getMessage());
} }
// reload the display model since the TBoxUpdater may have }
// modified it // reload the display model since the TBoxUpdater may have
new ApplicationModelSetup().contextInitialized(sce); // modified it
} catch (Exception ioe) { new ApplicationModelSetup().contextInitialized(sce);
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", ioe); } catch (Exception ioe) {
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", ioe);
}
} }
SimpleReasoner simpleReasoner = (SimpleReasoner) sce.getServletContext() SimpleReasoner simpleReasoner = (SimpleReasoner) sce.getServletContext()

View file

@ -476,6 +476,19 @@ public class GroupedPropertyList extends BaseTemplateModel {
return null; 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) { public PropertyTemplateModel pullProperty(String propertyUri) {
return pullProperty(propertyUri, null); return pullProperty(propertyUri, null);
} }

View file

@ -96,7 +96,7 @@ function init(){
<input type="hidden" name="action" value="attachModel"/> <input type="hidden" name="action" value="attachModel"/>
<input type="hidden" name="modelName" value="${modelName}"/> <input type="hidden" name="modelName" value="${modelName}"/>
<input type="hidden" name="modelType" value="${modelType}"/> <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> </form>
</td> </td>
<td> <td>
@ -104,7 +104,7 @@ function init(){
<input type="hidden" name="action" value="detachModel"/> <input type="hidden" name="action" value="detachModel"/>
<input type="hidden" name="modelName" value="${modelName}"/> <input type="hidden" name="modelName" value="${modelName}"/>
<input type="hidden" name="modelType" value="${modelType}"/> <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> </form>
</td> </td>
<td> <td>

View file

@ -22,6 +22,24 @@
</#if> </#if>
</#function> </#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 Macros for generating property lists