Merge branch 'develop' into feature/fauxEditing
This commit is contained in:
commit
7c920e81cb
206 changed files with 6754 additions and 2884 deletions
BIN
webapp/lib/hamcrest-all-1.3.jar
Normal file
BIN
webapp/lib/hamcrest-all-1.3.jar
Normal file
Binary file not shown.
BIN
webapp/lib/junit-4.11.jar
Normal file
BIN
webapp/lib/junit-4.11.jar
Normal file
Binary file not shown.
Binary file not shown.
|
@ -10,7 +10,7 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vedit.controller;
|
package edu.cornell.mannlib.vedit.controller;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption.ASSERTIONS_ONLY;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -29,7 +31,8 @@ import edu.cornell.mannlib.vedit.util.FormUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||||
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.modelaccess.ModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
|
||||||
public class BaseEditController extends VitroHttpServlet {
|
public class BaseEditController extends VitroHttpServlet {
|
||||||
|
@ -193,7 +196,7 @@ public class BaseEditController extends VitroHttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WebappDaoFactory getWebappDaoFactory() {
|
protected WebappDaoFactory getWebappDaoFactory() {
|
||||||
return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory();
|
return ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WebappDaoFactory getWebappDaoFactory(String userURI) {
|
protected WebappDaoFactory getWebappDaoFactory(String userURI) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import edu.cornell.mannlib.vitro.webapp.modules.ComponentStartupStatus;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.fileStorage.FileStorage;
|
import edu.cornell.mannlib.vitro.webapp.modules.fileStorage.FileStorage;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.imageProcessor.ImageProcessor;
|
import edu.cornell.mannlib.vitro.webapp.modules.imageProcessor.ImageProcessor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
||||||
import edu.cornell.mannlib.vitro.webapp.searchengine.SearchEngineWrapper;
|
import edu.cornell.mannlib.vitro.webapp.searchengine.InstrumentedSearchEngineWrapper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.searchengine.solr.SolrSearchEngine;
|
import edu.cornell.mannlib.vitro.webapp.searchengine.solr.SolrSearchEngine;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.ComponentStartupStatusImpl;
|
import edu.cornell.mannlib.vitro.webapp.startup.ComponentStartupStatusImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
|
@ -85,7 +85,7 @@ public class ApplicationImpl implements Application {
|
||||||
ComponentStartupStatus css = new ComponentStartupStatusImpl(
|
ComponentStartupStatus css = new ComponentStartupStatusImpl(
|
||||||
this, ss);
|
this, ss);
|
||||||
|
|
||||||
SearchEngine searchEngine = new SearchEngineWrapper(
|
SearchEngine searchEngine = new InstrumentedSearchEngineWrapper(
|
||||||
new SolrSearchEngine());
|
new SolrSearchEngine());
|
||||||
searchEngine.startup(application, css);
|
searchEngine.startup(application, css);
|
||||||
application.setSearchEngine(searchEngine);
|
application.setSearchEngine(searchEngine);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier;
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current user is blacklisted for this reason.
|
* The current user is blacklisted for this reason.
|
||||||
|
@ -153,7 +153,7 @@ public class IsBlacklisted extends AbstractCommonIdentifier implements
|
||||||
return NOT_BLACKLISTED;
|
return NOT_BLACKLISTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
OntModel model = ModelAccess.on(context).getJenaOntModel();
|
OntModel model = ModelAccess.on(context).getOntModel();
|
||||||
|
|
||||||
queryString = queryString.replaceAll("\\?individualURI",
|
queryString = queryString.replaceAll("\\?individualURI",
|
||||||
"<" + ind.getURI() + ">");
|
"<" + ind.getURI() + ">");
|
||||||
|
|
|
@ -6,7 +6,7 @@ import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundleFactory;
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundleFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
|
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount.Status;
|
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount.Status;
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
|
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.auth.policy.bean;
|
package edu.cornell.mannlib.vitro.webapp.auth.policy.bean;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -14,7 +16,7 @@ import edu.cornell.mannlib.vedit.beans.EditProcessObject;
|
||||||
import edu.cornell.mannlib.vedit.listener.ChangeListener;
|
import edu.cornell.mannlib.vedit.listener.ChangeListener;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add this ChangeListener to your EditProcessObject when modifying the
|
* Add this ChangeListener to your EditProcessObject when modifying the
|
||||||
|
@ -98,8 +100,8 @@ public class PropertyRestrictionListener implements ChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAndSetBean() {
|
private void createAndSetBean() {
|
||||||
OntModel model = ModelAccess.on(ctx).getJenaOntModel();
|
OntModel model = ModelAccess.on(ctx).getOntModel();
|
||||||
Model displayModel = ModelAccess.on(ctx).getDisplayModel();
|
Model displayModel = ModelAccess.on(ctx).getOntModel(DISPLAY);
|
||||||
PropertyRestrictionPolicyHelper bean = PropertyRestrictionPolicyHelper
|
PropertyRestrictionPolicyHelper bean = PropertyRestrictionPolicyHelper
|
||||||
.createBean(model, displayModel);
|
.createBean(model, displayModel);
|
||||||
PropertyRestrictionPolicyHelper.setBean(ctx, bean);
|
PropertyRestrictionPolicyHelper.setBean(ctx, bean);
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.auth.policy.bean;
|
package edu.cornell.mannlib.vitro.webapp.auth.policy.bean;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -33,8 +35,8 @@ import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||||
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.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ApplicationConfigurationOntologyUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.ApplicationConfigurationOntologyUtils;
|
||||||
|
|
||||||
|
@ -489,12 +491,12 @@ public class PropertyRestrictionPolicyHelper {
|
||||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OntModel model = ModelAccess.on(ctx).getJenaOntModel();
|
OntModel model = ModelAccess.on(ctx).getOntModel();
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
"jenaOntModel has not been initialized.");
|
"jenaOntModel has not been initialized.");
|
||||||
}
|
}
|
||||||
Model displayModel = ModelAccess.on(ctx).getDisplayModel();
|
Model displayModel = ModelAccess.on(ctx).getOntModel(DISPLAY);
|
||||||
if (displayModel == null) {
|
if (displayModel == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
"display model has not been initialized.");
|
"display model has not been initialized.");
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller;
|
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_UNION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.USER_ACCOUNTS;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -19,14 +22,13 @@ import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class with some utility routines for page handler (created by
|
* A base class with some utility routines for page handler (created by
|
||||||
|
@ -56,8 +58,8 @@ public abstract class AbstractPageHandler {
|
||||||
this.i18n = I18n.bundle(vreq);
|
this.i18n = I18n.bundle(vreq);
|
||||||
this.ctx = vreq.getSession().getServletContext();
|
this.ctx = vreq.getSession().getServletContext();
|
||||||
|
|
||||||
userAccountsModel = ModelAccess.on(ctx).getUserAccountsModel();
|
userAccountsModel = ModelAccess.on(ctx).getOntModel(USER_ACCOUNTS);
|
||||||
unionModel = ModelAccess.on(ctx).getOntModel(ModelNames.FULL_UNION);
|
unionModel = ModelAccess.on(ctx).getOntModel(FULL_UNION);
|
||||||
|
|
||||||
WebappDaoFactory wdf = ModelAccess.on(ctx).getWebappDaoFactory();
|
WebappDaoFactory wdf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||||
userAccountsDao = wdf.getUserAccountsDao();
|
userAccountsDao = wdf.getUserAccountsDao();
|
||||||
|
|
|
@ -42,9 +42,9 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import fedora.client.FedoraClient;
|
import fedora.client.FedoraClient;
|
||||||
import fedora.common.Constants;
|
import fedora.common.Constants;
|
||||||
import fedora.server.management.FedoraAPIM;
|
import fedora.server.management.FedoraAPIM;
|
||||||
|
@ -101,7 +101,7 @@ public class FedoraDatastreamController extends VitroHttpServlet implements Cons
|
||||||
log.debug("In doGet");
|
log.debug("In doGet");
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(req);
|
VitroRequest vreq = new VitroRequest(req);
|
||||||
OntModel sessionOntModel = ModelAccess.on(vreq.getSession()).getJenaOntModel();
|
OntModel sessionOntModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
|
|
||||||
synchronized (FedoraDatastreamController.class) {
|
synchronized (FedoraDatastreamController.class) {
|
||||||
if( fedoraUrl == null ){
|
if( fedoraUrl == null ){
|
||||||
|
@ -241,7 +241,7 @@ public class FedoraDatastreamController extends VitroHttpServlet implements Cons
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if fedora is on line
|
//check if fedora is on line
|
||||||
OntModel sessionOntModel = ModelAccess.on(rawRequest.getSession()).getJenaOntModel();
|
OntModel sessionOntModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
synchronized (FedoraDatastreamController.class) {
|
synchronized (FedoraDatastreamController.class) {
|
||||||
if( fedoraUrl == null ){
|
if( fedoraUrl == null ){
|
||||||
setup( sessionOntModel, getServletContext() );
|
setup( sessionOntModel, getServletContext() );
|
||||||
|
|
|
@ -3,6 +3,7 @@ package edu.cornell.mannlib.vitro.webapp.controller;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.RdfResultMediaType.RDF_XML;
|
import static edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.RdfResultMediaType.RDF_XML;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.RDF_TYPE;
|
import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.RDF_TYPE;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_ACCEPTABLE;
|
import static javax.servlet.http.HttpServletResponse.SC_NOT_ACCEPTABLE;
|
||||||
|
@ -29,7 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.api.VitroApiServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.InvalidQueryTypeException;
|
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.InvalidQueryTypeException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.RdfResultMediaType;
|
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.RdfResultMediaType;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.SparqlQueryApiExecutor;
|
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.SparqlQueryApiExecutor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
|
@ -94,7 +95,7 @@ public class IndividualListRdfController extends VitroApiServlet {
|
||||||
ObjectProperty property = new ObjectProperty();
|
ObjectProperty property = new ObjectProperty();
|
||||||
property.setURI(RDF_TYPE);
|
property.setURI(RDF_TYPE);
|
||||||
RequestedAction dops = new PublishObjectPropertyStatement(ModelAccess
|
RequestedAction dops = new PublishObjectPropertyStatement(ModelAccess
|
||||||
.on(req).getBaseOntModel(), RequestedAction.SOME_URI, property,
|
.on(req).getOntModel(FULL_ASSERTIONS), RequestedAction.SOME_URI, property,
|
||||||
vclassUri);
|
vclassUri);
|
||||||
return !PolicyHelper.isAuthorizedForActions(req, dops);
|
return !PolicyHelper.isAuthorizedForActions(req, dops);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -27,7 +26,7 @@ import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaOutputUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaOutputUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.ContentType;
|
import edu.cornell.mannlib.vitro.webapp.web.ContentType;
|
||||||
|
|
||||||
|
@ -128,7 +127,7 @@ public class OntologyController extends VitroHttpServlet{
|
||||||
String url = ontology;
|
String url = ontology;
|
||||||
|
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(vreq.getSession()).getJenaOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
Model newModel = ModelFactory.createDefaultModel();
|
Model newModel = ModelFactory.createDefaultModel();
|
||||||
|
|
|
@ -6,6 +6,12 @@ package edu.cornell.mannlib.vitro.webapp.controller;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ATTRIBUTE_FILE_ITEM_MAP;
|
import static edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ATTRIBUTE_FILE_ITEM_MAP;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ATTRIBUTE_FILE_SIZE_EXCEPTION;
|
import static edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ATTRIBUTE_FILE_SIZE_EXCEPTION;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ATTRIBUTE_IS_MULTIPART;
|
import static edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ATTRIBUTE_IS_MULTIPART;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ASSERTIONS_ONLY;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.CONTENT;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LANGUAGE_NEUTRAL;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.POLICY_NEUTRAL;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -24,13 +30,12 @@ import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource.ModelName;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource.ModelName;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|
||||||
|
|
||||||
public class VitroRequest extends HttpServletRequestWrapper {
|
public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
|
@ -52,64 +57,34 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RDFService getRDFService() {
|
public RDFService getRDFService() {
|
||||||
Object o = getAttribute("rdfService");
|
return ModelAccess.on(this).getRDFService();
|
||||||
if (o instanceof RDFService) {
|
|
||||||
return (RDFService) o;
|
|
||||||
} else {
|
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFService(this);
|
|
||||||
setAttribute("rdfService", rdfService);
|
|
||||||
return rdfService;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RDFService getUnfilteredRDFService() {
|
public RDFService getUnfilteredRDFService() {
|
||||||
Object o = getAttribute("unfilteredRDFService");
|
return ModelAccess.on(this).getRDFService(CONTENT, LANGUAGE_NEUTRAL);
|
||||||
if (o instanceof RDFService) {
|
|
||||||
return (RDFService) o;
|
|
||||||
} else {
|
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFService(this);
|
|
||||||
setAttribute("unfilteredRDFService", rdfService);
|
|
||||||
return rdfService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRDFService(RDFService rdfService) {
|
|
||||||
setAttribute("rdfService", rdfService);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnfilteredRDFService(RDFService rdfService) {
|
|
||||||
setAttribute("unfilteredRDFService", rdfService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets WebappDaoFactory with appropriate filtering for the request */
|
/** Gets WebappDaoFactory with appropriate filtering for the request */
|
||||||
public WebappDaoFactory getWebappDaoFactory(){
|
public WebappDaoFactory getWebappDaoFactory(){
|
||||||
return ModelAccess.on(this).getWebappDaoFactory(FactoryID.UNION);
|
return ModelAccess.on(this).getWebappDaoFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** gets assertions+inference WebappDaoFactory with no policy filtering */
|
/** gets assertions+inference WebappDaoFactory with no policy filtering */
|
||||||
public WebappDaoFactory getUnfilteredWebappDaoFactory() {
|
public WebappDaoFactory getUnfilteredWebappDaoFactory() {
|
||||||
return ModelAccess.on(this).getWebappDaoFactory(FactoryID.UNFILTERED_UNION);
|
return ModelAccess.on(this).getWebappDaoFactory(POLICY_NEUTRAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** gets assertions-only WebappDaoFactory with no policy filtering */
|
/** gets assertions-only WebappDaoFactory with no policy filtering */
|
||||||
public WebappDaoFactory getUnfilteredAssertionsWebappDaoFactory() {
|
public WebappDaoFactory getUnfilteredAssertionsWebappDaoFactory() {
|
||||||
return ModelAccess.on(this).getWebappDaoFactory(FactoryID.UNFILTERED_BASE);
|
return ModelAccess.on(this).getWebappDaoFactory(POLICY_NEUTRAL, ASSERTIONS_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset getDataset() {
|
public Dataset getDataset() {
|
||||||
return (Dataset) getAttribute("dataset");
|
return ModelAccess.on(this).getDataset(CONTENT);
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataset(Dataset dataset) {
|
|
||||||
setAttribute("dataset", dataset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset getUnfilteredDataset() {
|
public Dataset getUnfilteredDataset() {
|
||||||
return (Dataset) getAttribute("unfilteredDataset");
|
return ModelAccess.on(this).getDataset(CONTENT, LANGUAGE_NEUTRAL);
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnfilteredDataset(Dataset dataset) {
|
|
||||||
setAttribute("unfilteredDataset", dataset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Method that retrieves write model, returns special model in case of write model
|
//Method that retrieves write model, returns special model in case of write model
|
||||||
|
@ -127,21 +102,15 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OntModel getJenaOntModel() {
|
public OntModel getJenaOntModel() {
|
||||||
return ModelAccess.on(this).getJenaOntModel();
|
return ModelAccess.on(this).getOntModel(ModelNames.FULL_UNION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** JB - surprising that this comes from session. */
|
|
||||||
public OntModel getAssertionsOntModel() {
|
public OntModel getAssertionsOntModel() {
|
||||||
return ModelAccess.on(this.getSession()).getBaseOntModel();
|
return ModelAccess.on(this).getOntModel(FULL_ASSERTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** JB - surprising that this comes from session. */
|
|
||||||
public OntModel getInferenceOntModel() {
|
|
||||||
return ModelAccess.on(this.getSession()).getInferenceOntModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getDisplayModel(){
|
public OntModel getDisplayModel(){
|
||||||
return ModelAccess.on(this).getDisplayModel();
|
return ModelAccess.on(this).getOntModel(DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,12 +185,8 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
return _req.getParameterValues(name);
|
return _req.getParameterValues(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguageNeutralUnionFullModel(OntModel model) {
|
|
||||||
setAttribute("languageNeutralUnionFullModel", model);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getLanguageNeutralUnionFullModel() {
|
public OntModel getLanguageNeutralUnionFullModel() {
|
||||||
return (OntModel) getAttribute("languageNeutralUnionFullModel");
|
return ModelAccess.on(this).getOntModel(ModelNames.FULL_UNION, LANGUAGE_NEUTRAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollator(Collator collator) {
|
public void setCollator(Collator collator) {
|
||||||
|
@ -232,12 +197,8 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
return (Collator) getAttribute("collator");
|
return (Collator) getAttribute("collator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguageNeutralWebappDaoFactory(WebappDaoFactory wadf) {
|
|
||||||
setAttribute("languageNeutralWebappDaoFactory", wadf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebappDaoFactory getLanguageNeutralWebappDaoFactory() {
|
public WebappDaoFactory getLanguageNeutralWebappDaoFactory() {
|
||||||
return (WebappDaoFactory) getAttribute("languageNeutralWebappDaoFactory");
|
return edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.on(this).getWebappDaoFactory(LANGUAGE_NEUTRAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ajax;
|
package edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ajax;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.USER_ACCOUNTS;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -20,8 +22,8 @@ import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.ajax.AbstractAjaxResponder;
|
import edu.cornell.mannlib.vitro.webapp.controller.ajax.AbstractAjaxResponder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.images.PlaceholderUtil;
|
import edu.cornell.mannlib.vitro.webapp.web.images.PlaceholderUtil;
|
||||||
|
@ -58,7 +60,7 @@ public class BasicProxiesGetter extends AbstractAjaxResponder {
|
||||||
super(servlet, vreq, resp);
|
super(servlet, vreq, resp);
|
||||||
term = getStringParameter(PARAMETER_SEARCH_TERM, "");
|
term = getStringParameter(PARAMETER_SEARCH_TERM, "");
|
||||||
|
|
||||||
userAccountsModel = ModelAccess.on(vreq).getUserAccountsModel();
|
userAccountsModel = ModelAccess.on(vreq).getOntModel(USER_ACCOUNTS);
|
||||||
|
|
||||||
placeholderImageUrl = UrlBuilder.getUrl(PlaceholderUtil
|
placeholderImageUrl = UrlBuilder.getUrl(PlaceholderUtil
|
||||||
.getPlaceholderImagePathForType(vreq,
|
.getPlaceholderImagePathForType(vreq,
|
||||||
|
|
|
@ -0,0 +1,252 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.admin;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest.AUTHORIZED;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption.LANGUAGE_NEUTRAL;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONFIGURATION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.graph.Graph;
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
|
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.modelaccess.ContextModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.RequestModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ComplexStringFormatter;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the details of where our RDF data is coming from. What are the
|
||||||
|
* structures that supply the triples?
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* Display like this:
|
||||||
|
*
|
||||||
|
* ModelAccess for Context
|
||||||
|
* blah-blah
|
||||||
|
*
|
||||||
|
* ModelAccess for Request
|
||||||
|
* blah-blah
|
||||||
|
*
|
||||||
|
* RDFServices
|
||||||
|
* CONTEXT REQUEST
|
||||||
|
* CONTENT blah-blah argle-bargle
|
||||||
|
* CONFIGURATION balderdash obstreporous
|
||||||
|
*
|
||||||
|
* Datasets [same]
|
||||||
|
*
|
||||||
|
* Models
|
||||||
|
* Name ContextOnly
|
||||||
|
* DISPLAY blah-blah
|
||||||
|
* filegraph:tbox/junk.owl bork-bork-bork
|
||||||
|
*
|
||||||
|
* OntModels
|
||||||
|
* Name Context REQUEST
|
||||||
|
* DISPLAY blah-blah song-and-dance
|
||||||
|
* filegraph:tbox/junk.owl bork-bork-bork bogus-malarkey
|
||||||
|
*
|
||||||
|
* For the request object,
|
||||||
|
* Get the LANGUAGE_NEUTRAL versions, since they have fewer decorators.
|
||||||
|
* If the string is the same as the corresponding object in the context, show as "SAME AS CONTEXT"
|
||||||
|
*
|
||||||
|
* Structure for freemarker:
|
||||||
|
* map:
|
||||||
|
* modelAccess:
|
||||||
|
* context: text
|
||||||
|
* request: text
|
||||||
|
* rdfServices:
|
||||||
|
* content:
|
||||||
|
* context: text
|
||||||
|
* request: text
|
||||||
|
* configuration:
|
||||||
|
* context: text
|
||||||
|
* request: text
|
||||||
|
* datasets:
|
||||||
|
* [same]
|
||||||
|
* models:
|
||||||
|
* content:
|
||||||
|
* name1:
|
||||||
|
* context: text
|
||||||
|
* name2:
|
||||||
|
* context: text
|
||||||
|
* ...
|
||||||
|
* configuration:
|
||||||
|
* name3:
|
||||||
|
* context: text
|
||||||
|
* request: text
|
||||||
|
* ...
|
||||||
|
* ontModels:
|
||||||
|
* name1:
|
||||||
|
* context: text
|
||||||
|
* request: text
|
||||||
|
* ...
|
||||||
|
*
|
||||||
|
* At the same time, write these to the log as INFO messages, without the fancy formatting.
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public class ShowSourcesController extends FreemarkerHttpServlet {
|
||||||
|
private static final Log log = LogFactory
|
||||||
|
.getLog(ShowSourcesController.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
|
return AUTHORIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
return new TemplateResponseValues("admin-showSources.ftl",
|
||||||
|
new SourcesMap(vreq));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SourcesMap extends HashMap<String, Object> {
|
||||||
|
private static final Object SAME_AS_CONTEXT = "Same as Context";
|
||||||
|
|
||||||
|
private final RequestModelAccess reqModels;
|
||||||
|
private final ContextModelAccess ctxModels;
|
||||||
|
|
||||||
|
private final SortedSet<String> contentModelNames;
|
||||||
|
private final SortedSet<String> configurationModelNames;
|
||||||
|
private final SortedSet<String> allModelNames;
|
||||||
|
|
||||||
|
public SourcesMap(VitroRequest vreq) {
|
||||||
|
this.reqModels = ModelAccess.on(vreq);
|
||||||
|
this.ctxModels = ModelAccess.on(vreq.getSession()
|
||||||
|
.getServletContext());
|
||||||
|
|
||||||
|
this.contentModelNames = new TreeSet<>(ctxModels
|
||||||
|
.getModelMaker(CONTENT).listModels().toList());
|
||||||
|
this.configurationModelNames = new TreeSet<>(ctxModels
|
||||||
|
.getModelMaker(CONFIGURATION).listModels().toList());
|
||||||
|
this.allModelNames = new TreeSet<>(contentModelNames);
|
||||||
|
this.allModelNames.addAll(configurationModelNames);
|
||||||
|
|
||||||
|
addStructures(ctxModels, reqModels, "modelAccess");
|
||||||
|
|
||||||
|
addStructures(ctxModels.getRDFService(CONTENT),
|
||||||
|
reqModels.getRDFService(CONTENT, LANGUAGE_NEUTRAL),
|
||||||
|
"rdfServices", CONTENT);
|
||||||
|
addStructures(ctxModels.getRDFService(CONFIGURATION),
|
||||||
|
reqModels.getRDFService(CONFIGURATION, LANGUAGE_NEUTRAL),
|
||||||
|
"rdfServices", CONFIGURATION);
|
||||||
|
|
||||||
|
addStructures(ctxModels.getDataset(CONTENT),
|
||||||
|
reqModels.getDataset(CONTENT, LANGUAGE_NEUTRAL),
|
||||||
|
"datasets", CONTENT);
|
||||||
|
addStructures(ctxModels.getDataset(CONFIGURATION),
|
||||||
|
reqModels.getDataset(CONFIGURATION, LANGUAGE_NEUTRAL),
|
||||||
|
"datasets", CONFIGURATION);
|
||||||
|
|
||||||
|
for (String modelName : contentModelNames) {
|
||||||
|
addContextModel(
|
||||||
|
ctxModels.getModelMaker(CONTENT).getModel(modelName),
|
||||||
|
"models", CONTENT, ToString.modelName(modelName));
|
||||||
|
}
|
||||||
|
for (String modelName : configurationModelNames) {
|
||||||
|
addContextModel(ctxModels.getModelMaker(CONFIGURATION)
|
||||||
|
.getModel(modelName), "models", CONFIGURATION,
|
||||||
|
ToString.modelName(modelName));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String modelName : allModelNames) {
|
||||||
|
addStructures(ctxModels.getOntModel(modelName),
|
||||||
|
reqModels.getOntModel(modelName, LANGUAGE_NEUTRAL),
|
||||||
|
"ontModels", ToString.modelName(modelName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addStructures(Object contextDataStructure,
|
||||||
|
Object requestDataStructure, Object... keys) {
|
||||||
|
Map<String, Object> map = followPath(keys);
|
||||||
|
map.put("context", formatStructure(contextDataStructure));
|
||||||
|
|
||||||
|
if (String.valueOf(contextDataStructure).equals(
|
||||||
|
String.valueOf(requestDataStructure))) {
|
||||||
|
map.put("request", SAME_AS_CONTEXT);
|
||||||
|
} else {
|
||||||
|
map.put("request", formatStructure(requestDataStructure));
|
||||||
|
}
|
||||||
|
|
||||||
|
writeToLog(keys, "context", contextDataStructure);
|
||||||
|
writeToLog(keys, "request", requestDataStructure);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addContextModel(Model model, Object... keys) {
|
||||||
|
Map<String, Object> map = followPath(keys);
|
||||||
|
map.put("context", formatStructure(model));
|
||||||
|
writeToLog(keys, "context", model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the inner map that corresponds to this set of keys. If there is
|
||||||
|
* no such map, create one.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Map<String, Object> followPath(Object[] keys) {
|
||||||
|
Map<String, Object> m = this;
|
||||||
|
for (Object key : keys) {
|
||||||
|
String stringKey = String.valueOf(key);
|
||||||
|
if (!m.containsKey(stringKey)) {
|
||||||
|
m.put(stringKey, new TreeMap<String, Object>());
|
||||||
|
}
|
||||||
|
m = (Map<String, Object>) m.get(stringKey);
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeToLog(Object[] keys, String lastKey,
|
||||||
|
Object dataStructure) {
|
||||||
|
List<Object> allKeys = new ArrayList<>();
|
||||||
|
allKeys.addAll(Arrays.asList(keys));
|
||||||
|
allKeys.add(lastKey);
|
||||||
|
log.info("Data structure: " + allKeys + " "
|
||||||
|
+ dsToString(dataStructure));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String dsToString(Object dataStructure) {
|
||||||
|
if (dataStructure instanceof OntModel) {
|
||||||
|
return ToString.ontModelToString((OntModel) dataStructure);
|
||||||
|
} else if (dataStructure instanceof Model) {
|
||||||
|
return ToString.modelToString((Model) dataStructure);
|
||||||
|
} else if (dataStructure instanceof Graph) {
|
||||||
|
return ToString.graphToString((Graph) dataStructure);
|
||||||
|
} else if (dataStructure instanceof RequestModelAccess
|
||||||
|
|| dataStructure instanceof ContextModelAccess) {
|
||||||
|
return ToString
|
||||||
|
.replaceModelNames(String.valueOf(dataStructure));
|
||||||
|
} else {
|
||||||
|
return String.valueOf(dataStructure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatStructure(Object dataStructure) {
|
||||||
|
String dsString = dsToString(dataStructure);
|
||||||
|
if (dataStructure instanceof RequestModelAccess
|
||||||
|
|| dataStructure instanceof ContextModelAccess) {
|
||||||
|
return new ComplexStringFormatter(dsString, ". ").toString();
|
||||||
|
} else {
|
||||||
|
return new ComplexStringFormatter(dsString).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,9 +33,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
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.OntologyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.http.AcceptHeaderParsingException;
|
import edu.cornell.mannlib.vitro.webapp.utils.http.AcceptHeaderParsingException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.http.NotAcceptableException;
|
import edu.cornell.mannlib.vitro.webapp.utils.http.NotAcceptableException;
|
||||||
|
@ -103,8 +103,8 @@ public class SparqlQueryController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private void respondToQuery(HttpServletRequest req, HttpServletResponse resp)
|
private void respondToQuery(HttpServletRequest req, HttpServletResponse resp)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(
|
RDFService rdfService = ModelAccess.on(getServletContext())
|
||||||
getServletContext()).getRDFService();
|
.getRDFService();
|
||||||
|
|
||||||
String queryString = req.getParameter("query");
|
String queryString = req.getParameter("query");
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.ajax;
|
package edu.cornell.mannlib.vitro.webapp.controller.ajax;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.USER_ACCOUNTS;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -20,7 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.ajax.SparqlUtils.AjaxControllerException;
|
import edu.cornell.mannlib.vitro.webapp.controller.ajax.SparqlUtils.AjaxControllerException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an AJAX request for a SPARQL query. On entry, the "query" parameter
|
* Handle an AJAX request for a SPARQL query. On entry, the "query" parameter
|
||||||
|
@ -78,9 +79,9 @@ public class SparqlQueryAjaxController extends VitroAjaxController {
|
||||||
|
|
||||||
private Model locateModel(VitroRequest vreq, String modelParam) {
|
private Model locateModel(VitroRequest vreq, String modelParam) {
|
||||||
if (OPTION_MODEL_USER_ACCOUNTS.equals(modelParam)) {
|
if (OPTION_MODEL_USER_ACCOUNTS.equals(modelParam)) {
|
||||||
return ModelAccess.on(vreq).getUserAccountsModel();
|
return ModelAccess.on(vreq).getOntModel(USER_ACCOUNTS);
|
||||||
} else {
|
} else {
|
||||||
return ModelAccess.on(vreq).getJenaOntModel();
|
return ModelAccess.on(vreq).getOntModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.InvalidQueryTypeException;
|
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.InvalidQueryTypeException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.SparqlQueryApiExecutor;
|
import edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery.SparqlQueryApiExecutor;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.http.AcceptHeaderParsingException;
|
import edu.cornell.mannlib.vitro.webapp.utils.http.AcceptHeaderParsingException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.http.NotAcceptableException;
|
import edu.cornell.mannlib.vitro.webapp.utils.http.NotAcceptableException;
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ public class SparqlQueryApiController extends VitroApiServlet {
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(
|
RDFService rdfService = ModelAccess.on(getServletContext())
|
||||||
getServletContext()).getRDFService();
|
.getRDFService();
|
||||||
|
|
||||||
String acceptHeader = req.getHeader("Accept");
|
String acceptHeader = req.getHeader("Accept");
|
||||||
String queryString = req.getParameter("query");
|
String queryString = req.getParameter("query");
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
@ -19,18 +18,17 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsRootUser;
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsRootUser;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount.Status;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount.Status;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate;
|
import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginEvent;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.LogoutEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.LogoutEvent;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,9 +8,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.BadRequestException;
|
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.BadRequestException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some utility methods that are common to the Action classes.
|
* Some utility methods that are common to the Action classes.
|
||||||
|
|
|
@ -16,10 +16,10 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.BadRequestException;
|
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.BadRequestException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.DumpFormat;
|
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.DumpFormat;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user has requested a dump.
|
* The user has requested a dump.
|
||||||
|
|
|
@ -34,11 +34,11 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.BadRequestException;
|
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.BadRequestException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.RestoreFormat;
|
import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.RestoreFormat;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ModelSerializationFormat;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ModelSerializationFormat;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load from a dump file of NQuads, or something equivalent.
|
* Load from a dump file of NQuads, or something equivalent.
|
||||||
|
|
|
@ -39,7 +39,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginInProcessFl
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginRedirector;
|
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginRedirector;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginLogoutEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginLogoutEvent;
|
||||||
|
|
||||||
public class Authenticate extends VitroHttpServlet {
|
public class Authenticate extends VitroHttpServlet {
|
||||||
|
@ -559,7 +559,7 @@ public class Authenticate extends VitroHttpServlet {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OntModel jenaOntModel = ModelAccess.on(session).getJenaOntModel();
|
OntModel jenaOntModel = ModelAccess.on(context).getOntModel();
|
||||||
jenaOntModel.getBaseModel().notifyEvent(event);
|
jenaOntModel.getBaseModel().notifyEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Classes2Classes;
|
import edu.cornell.mannlib.vitro.webapp.beans.Classes2Classes;
|
||||||
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.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
|
|
||||||
public class Classes2ClassesRetryController extends BaseEditController {
|
public class Classes2ClassesRetryController extends BaseEditController {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
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.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ 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.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ 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.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
public class NamespacePrefixOperationController extends BaseEditController {
|
public class NamespacePrefixOperationController extends BaseEditController {
|
||||||
|
@ -69,7 +69,7 @@ public class NamespacePrefixOperationController extends BaseEditController {
|
||||||
|
|
||||||
if (request.getParameter("_cancel") == null) {
|
if (request.getParameter("_cancel") == null) {
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
String namespaceStr = request.getParameter("namespace");
|
String namespaceStr = request.getParameter("namespace");
|
||||||
String prefixStr = request.getParameter("prefix");
|
String prefixStr = request.getParameter("prefix");
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
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.Controllers;
|
||||||
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.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||||
|
|
||||||
public class PropertyGroupRetryController extends BaseEditController {
|
public class PropertyGroupRetryController extends BaseEditController {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
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.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.USER_ACCOUNTS;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
@ -48,9 +53,8 @@ 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.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.dao.ModelAccess;
|
|
||||||
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.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.FileGraphSetup;
|
import edu.cornell.mannlib.vitro.webapp.servlet.setup.FileGraphSetup;
|
||||||
|
|
||||||
public class RefactorOperationController extends BaseEditController {
|
public class RefactorOperationController extends BaseEditController {
|
||||||
|
@ -72,7 +76,7 @@ public class RefactorOperationController extends BaseEditController {
|
||||||
request.setAttribute("title","Check Datatype Properties");
|
request.setAttribute("title","Check Datatype Properties");
|
||||||
request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""+vreq.getAppBean().getThemeDir()+"css/edit.css\"/>");
|
request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""+vreq.getAppBean().getThemeDir()+"css/edit.css\"/>");
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS);
|
||||||
ontModel.enterCriticalSection(Lock.WRITE);
|
ontModel.enterCriticalSection(Lock.WRITE);
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
ArrayList<String> results = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -233,11 +237,11 @@ public class RefactorOperationController extends BaseEditController {
|
||||||
boolean doNotify = false;
|
boolean doNotify = false;
|
||||||
Model model = null;
|
Model model = null;
|
||||||
|
|
||||||
if (ModelNames.TBOX_ASSERTIONS.equals(graphURI)) {
|
if (TBOX_ASSERTIONS.equals(graphURI)) {
|
||||||
model = ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_ASSERTIONS);
|
model = ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS);
|
||||||
doNotify = true;
|
doNotify = true;
|
||||||
} else if (ModelNames.ABOX_ASSERTIONS.equals(graphURI)) {
|
} else if (ABOX_ASSERTIONS.equals(graphURI)) {
|
||||||
model = ModelAccess.on(getServletContext()).getOntModel(ModelNames.ABOX_ASSERTIONS);
|
model = ModelAccess.on(getServletContext()).getOntModel(ABOX_ASSERTIONS);
|
||||||
doNotify = true;
|
doNotify = true;
|
||||||
} else {
|
} else {
|
||||||
model = dataset.getNamedModel(graphURI);
|
model = dataset.getNamedModel(graphURI);
|
||||||
|
@ -250,7 +254,7 @@ public class RefactorOperationController extends BaseEditController {
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
renameResourceInModel(ModelAccess.on(getServletContext()).getUserAccountsModel(),
|
renameResourceInModel(ModelAccess.on(getServletContext()).getOntModel(USER_ACCOUNTS),
|
||||||
userURI, oldURIStr, newURIStr, !NOTIFY);
|
userURI, oldURIStr, newURIStr, !NOTIFY);
|
||||||
|
|
||||||
// there are no statements to delete, but we want indexes updated appropriately
|
// there are no statements to delete, but we want indexes updated appropriately
|
||||||
|
@ -327,7 +331,7 @@ public class RefactorOperationController extends BaseEditController {
|
||||||
private void doMovePropertyStatements(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
private void doMovePropertyStatements(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
||||||
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS);
|
||||||
|
|
||||||
Model tempRetractModel = ModelFactory.createDefaultModel();
|
Model tempRetractModel = ModelFactory.createDefaultModel();
|
||||||
Model tempAddModel = ModelFactory.createDefaultModel();
|
Model tempAddModel = ModelFactory.createDefaultModel();
|
||||||
|
@ -411,7 +415,7 @@ public class RefactorOperationController extends BaseEditController {
|
||||||
private void doMoveInstances(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
private void doMoveInstances(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
||||||
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS);
|
||||||
|
|
||||||
String oldClassURIStr = (String) epo.getAttribute("VClassURI");
|
String oldClassURIStr = (String) epo.getAttribute("VClassURI");
|
||||||
String newClassURIStr = (String) request.getParameter("NewVClassURI");
|
String newClassURIStr = (String) request.getParameter("NewVClassURI");
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@ -28,9 +30,8 @@ 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.jena.event.EditEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public class RestrictionOperationController extends BaseEditController {
|
public class RestrictionOperationController extends BaseEditController {
|
||||||
|
|
||||||
|
@ -45,9 +46,8 @@ public class RestrictionOperationController extends BaseEditController {
|
||||||
String defaultLandingPage = getDefaultLandingPage(request);
|
String defaultLandingPage = getDefaultLandingPage(request);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
OntModel ontModel = ModelAccess.on(getServletContext())
|
||||||
OntModel ontModel = ModelAccess.on(
|
.getOntModel(TBOX_ASSERTIONS);
|
||||||
getServletContext()).getOntModel(ModelNames.TBOX_ASSERTIONS);
|
|
||||||
|
|
||||||
HashMap epoHash = null;
|
HashMap epoHash = null;
|
||||||
EditProcessObject epo = null;
|
EditProcessObject epo = null;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption.ASSERTIONS_ONLY;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -25,10 +27,10 @@ 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.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.dao.ModelAccess;
|
|
||||||
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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public class VclassEditController extends BaseEditController {
|
public class VclassEditController extends BaseEditController {
|
||||||
|
|
||||||
|
@ -45,7 +47,7 @@ public class VclassEditController extends BaseEditController {
|
||||||
EditProcessObject epo = super.createEpo(request, FORCE_NEW);
|
EditProcessObject epo = super.createEpo(request, FORCE_NEW);
|
||||||
request.setAttribute("epoKey", epo.getKey());
|
request.setAttribute("epoKey", epo.getKey());
|
||||||
|
|
||||||
VClassDao vcwDao = ModelAccess.on(getServletContext()).getBaseWebappDaoFactory().getVClassDao();
|
VClassDao vcwDao = ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
|
||||||
VClass vcl = (VClass)vcwDao.getVClassByURI(request.getParameter("uri"));
|
VClass vcl = (VClass)vcwDao.getVClassByURI(request.getParameter("uri"));
|
||||||
|
|
||||||
if (vcl == null) {
|
if (vcl == null) {
|
||||||
|
@ -149,7 +151,7 @@ public class VclassEditController extends BaseEditController {
|
||||||
request.setAttribute("formSelect",formSelect);
|
request.setAttribute("formSelect",formSelect);
|
||||||
|
|
||||||
// if supported, we want to show only the asserted superclasses and subclasses.
|
// if supported, we want to show only the asserted superclasses and subclasses.
|
||||||
VClassDao vcDao = ModelAccess.on(getServletContext()).getBaseWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
|
||||||
VClassDao displayVcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getVClassDao();
|
VClassDao displayVcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getVClassDao();
|
||||||
|
|
||||||
List<VClass> superVClasses = getVClassesForURIList(
|
List<VClass> superVClasses = getVClassesForURIList(
|
||||||
|
|
|
@ -31,11 +31,11 @@ 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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public class VclassRetryController extends BaseEditController {
|
public class VclassRetryController extends BaseEditController {
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ 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.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.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public class NamespacesListingController extends BaseEditController {
|
public class NamespacesListingController extends BaseEditController {
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public class NamespacesListingController extends BaseEditController {
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
VitroRequest vrequest = new VitroRequest(request);
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
|
|
||||||
ArrayList results = new ArrayList();
|
ArrayList results = new ArrayList();
|
||||||
request.setAttribute("results",results);
|
request.setAttribute("results",results);
|
||||||
|
|
|
@ -33,9 +33,9 @@ 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.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public class RestrictionsListingController extends BaseEditController {
|
public class RestrictionsListingController extends BaseEditController {
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class RestrictionsListingController extends BaseEditController {
|
||||||
|
|
||||||
epo = super.createEpo(request);
|
epo = super.createEpo(request);
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
|
|
||||||
ObjectPropertyDao opDao = vrequest.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
ObjectPropertyDao opDao = vrequest.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
||||||
VClassDao vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||||
|
|
|
@ -19,10 +19,10 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||||
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.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||||
/*
|
/*
|
||||||
* Custom deletion controller to which deletion requests from default property form are sent. May be replaced
|
* Custom deletion controller to which deletion requests from default property form are sent. May be replaced
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_INFERENCES;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -43,8 +46,8 @@ import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
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.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public class JenaAdminActions extends BaseEditController {
|
public class JenaAdminActions extends BaseEditController {
|
||||||
|
|
||||||
|
@ -88,7 +91,7 @@ public class JenaAdminActions extends BaseEditController {
|
||||||
* This doesn't really print just the TBox. It takes a copy of the model, removes all the individuals, and writes the result.
|
* This doesn't really print just the TBox. It takes a copy of the model, removes all the individuals, and writes the result.
|
||||||
*/
|
*/
|
||||||
private void outputTbox(HttpServletResponse response) {
|
private void outputTbox(HttpServletResponse response) {
|
||||||
OntModel memoryModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
OntModel memoryModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS);
|
||||||
try {
|
try {
|
||||||
OntModel tempOntModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
|
OntModel tempOntModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
|
||||||
memoryModel.enterCriticalSection(Lock.READ);
|
memoryModel.enterCriticalSection(Lock.READ);
|
||||||
|
@ -158,7 +161,7 @@ public class JenaAdminActions extends BaseEditController {
|
||||||
private String testWriteXML() {
|
private String testWriteXML() {
|
||||||
StringBuffer output = new StringBuffer();
|
StringBuffer output = new StringBuffer();
|
||||||
output.append("<html><head><title>Test Write XML</title></head><body><pre>\n");
|
output.append("<html><head><title>Test Write XML</title></head><body><pre>\n");
|
||||||
OntModel model = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel model = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
Model tmp = ModelFactory.createDefaultModel();
|
Model tmp = ModelFactory.createDefaultModel();
|
||||||
boolean valid = true;
|
boolean valid = true;
|
||||||
for (Statement stmt : model.listStatements().toList() ) {
|
for (Statement stmt : model.listStatements().toList() ) {
|
||||||
|
@ -214,7 +217,7 @@ public class JenaAdminActions extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeLongLiterals() {
|
private void removeLongLiterals() {
|
||||||
OntModel memoryModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel memoryModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
memoryModel.enterCriticalSection(Lock.WRITE);
|
memoryModel.enterCriticalSection(Lock.WRITE);
|
||||||
try {
|
try {
|
||||||
List<Statement> statementsToRemove = new LinkedList<Statement>();
|
List<Statement> statementsToRemove = new LinkedList<Statement>();
|
||||||
|
@ -257,7 +260,7 @@ public class JenaAdminActions extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionStr.equals("checkURIs")) {
|
if (actionStr.equals("checkURIs")) {
|
||||||
OntModel memoryModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel memoryModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
StmtIterator stmtIt = memoryModel.listStatements();
|
StmtIterator stmtIt = memoryModel.listStatements();
|
||||||
try {
|
try {
|
||||||
for (Statement stmt : stmtIt.toList() ) {
|
for (Statement stmt : stmtIt.toList() ) {
|
||||||
|
@ -288,16 +291,16 @@ public class JenaAdminActions extends BaseEditController {
|
||||||
if (actionStr.equals("output")) {
|
if (actionStr.equals("output")) {
|
||||||
OntModel memoryModel = null;
|
OntModel memoryModel = null;
|
||||||
if (request.getParameter("assertionsOnly") != null) {
|
if (request.getParameter("assertionsOnly") != null) {
|
||||||
memoryModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
memoryModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS);
|
||||||
System.out.println("baseOntModel");
|
System.out.println("baseOntModel");
|
||||||
} else if (request.getParameter("inferences") != null) {
|
} else if (request.getParameter("inferences") != null) {
|
||||||
memoryModel = ModelAccess.on(getServletContext()).getInferenceOntModel();
|
memoryModel = ModelAccess.on(getServletContext()).getOntModel(FULL_INFERENCES);
|
||||||
System.out.println("inferenceOntModel");
|
System.out.println("inferenceOntModel");
|
||||||
} else if (request.getParameter("pellet") != null) {
|
} else if (request.getParameter("pellet") != null) {
|
||||||
memoryModel = (OntModel) getServletContext().getAttribute("pelletOntModel");
|
memoryModel = (OntModel) getServletContext().getAttribute("pelletOntModel");
|
||||||
System.out.println("pelletOntModel");
|
System.out.println("pelletOntModel");
|
||||||
} else {
|
} else {
|
||||||
memoryModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
memoryModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
System.out.println("jenaOntModel");
|
System.out.println("jenaOntModel");
|
||||||
}
|
}
|
||||||
int subModelCount = memoryModel.listSubModels().toList().size();
|
int subModelCount = memoryModel.listSubModels().toList().size();
|
||||||
|
@ -319,7 +322,7 @@ public class JenaAdminActions extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionStr.equals("outputTaxonomy")) {
|
if (actionStr.equals("outputTaxonomy")) {
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS);
|
||||||
Model taxonomyModel = extractTaxonomy(ontModel);
|
Model taxonomyModel = extractTaxonomy(ontModel);
|
||||||
try {
|
try {
|
||||||
taxonomyModel.write(response.getOutputStream());
|
taxonomyModel.write(response.getOutputStream());
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.APPLICATION_METADATA;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_UNION;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -28,9 +34,8 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
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.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
|
@ -118,7 +123,7 @@ public class JenaExportController extends BaseEditController {
|
||||||
if( "abox".equals(subgraphParam)){
|
if( "abox".equals(subgraphParam)){
|
||||||
model = ModelFactory.createDefaultModel();
|
model = ModelFactory.createDefaultModel();
|
||||||
if("inferred".equals(assertedOrInferredParam)){
|
if("inferred".equals(assertedOrInferredParam)){
|
||||||
model = ModelAccess.on(getServletContext()).getOntModel(ModelNames.ABOX_INFERENCES);
|
model = ModelAccess.on(getServletContext()).getOntModel(ABOX_INFERENCES);
|
||||||
}
|
}
|
||||||
else if("full".equals(assertedOrInferredParam)){
|
else if("full".equals(assertedOrInferredParam)){
|
||||||
outputSparqlConstruct(ABOX_FULL_CONSTRUCT, formatParam, response);
|
outputSparqlConstruct(ABOX_FULL_CONSTRUCT, formatParam, response);
|
||||||
|
@ -133,9 +138,9 @@ public class JenaExportController extends BaseEditController {
|
||||||
// so we'll extract the whole ontology and then include
|
// so we'll extract the whole ontology and then include
|
||||||
// only those statements that are in the inferred graph
|
// only those statements that are in the inferred graph
|
||||||
Model tempModel = xutil.extractTBox(
|
Model tempModel = xutil.extractTBox(
|
||||||
ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_UNION),
|
ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION),
|
||||||
ontologyURI);
|
ontologyURI);
|
||||||
Model inferenceModel = ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_INFERENCES);
|
Model inferenceModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES);
|
||||||
inferenceModel.enterCriticalSection(Lock.READ);
|
inferenceModel.enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
model = tempModel.intersection(inferenceModel);
|
model = tempModel.intersection(inferenceModel);
|
||||||
|
@ -144,20 +149,20 @@ public class JenaExportController extends BaseEditController {
|
||||||
}
|
}
|
||||||
} else if ("full".equals(assertedOrInferredParam)) {
|
} else if ("full".equals(assertedOrInferredParam)) {
|
||||||
model = xutil.extractTBox(
|
model = xutil.extractTBox(
|
||||||
ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_UNION),
|
ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION),
|
||||||
ontologyURI);
|
ontologyURI);
|
||||||
} else {
|
} else {
|
||||||
model = xutil.extractTBox(
|
model = xutil.extractTBox(
|
||||||
ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_ASSERTIONS), ontologyURI);
|
ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS), ontologyURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if("full".equals(subgraphParam)){
|
else if("full".equals(subgraphParam)){
|
||||||
if("inferred".equals(assertedOrInferredParam)){
|
if("inferred".equals(assertedOrInferredParam)){
|
||||||
ontModel = xutil.extractTBox(
|
ontModel = xutil.extractTBox(
|
||||||
dataset, ontologyURI, ModelNames.ABOX_INFERENCES);
|
dataset, ontologyURI, ABOX_INFERENCES);
|
||||||
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ModelNames.ABOX_INFERENCES));
|
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ABOX_INFERENCES));
|
||||||
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_INFERENCES));
|
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES));
|
||||||
}
|
}
|
||||||
else if("full".equals(assertedOrInferredParam)){
|
else if("full".equals(assertedOrInferredParam)){
|
||||||
outputSparqlConstruct(FULL_FULL_CONSTRUCT, formatParam, response);
|
outputSparqlConstruct(FULL_FULL_CONSTRUCT, formatParam, response);
|
||||||
|
@ -228,7 +233,7 @@ public class JenaExportController extends BaseEditController {
|
||||||
|
|
||||||
private void outputSparqlConstruct(String queryStr, String formatParam,
|
private void outputSparqlConstruct(String queryStr, String formatParam,
|
||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(getServletContext()).getRDFService();
|
RDFService rdfService = ModelAccess.on(getServletContext()).getRDFService();
|
||||||
try {
|
try {
|
||||||
setHeaders(response, formatParam);
|
setHeaders(response, formatParam);
|
||||||
OutputStream out = response.getOutputStream();
|
OutputStream out = response.getOutputStream();
|
||||||
|
@ -284,19 +289,19 @@ public class JenaExportController extends BaseEditController {
|
||||||
|
|
||||||
private static final String ABOX_FULL_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
private static final String ABOX_FULL_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
||||||
"WHERE { GRAPH ?g { ?s ?p ?o } FILTER (!regex(str(?g), \"tbox\")) " +
|
"WHERE { GRAPH ?g { ?s ?p ?o } FILTER (!regex(str(?g), \"tbox\")) " +
|
||||||
"FILTER (?g != <" + ModelNames.APPLICATION_METADATA + ">) }";
|
"FILTER (?g != <" + APPLICATION_METADATA + ">) }";
|
||||||
|
|
||||||
private static final String ABOX_ASSERTED_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
private static final String ABOX_ASSERTED_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
||||||
"WHERE { GRAPH ?g { ?s ?p ?o } FILTER (!regex(str(?g), \"tbox\")) " +
|
"WHERE { GRAPH ?g { ?s ?p ?o } FILTER (!regex(str(?g), \"tbox\")) " +
|
||||||
"FILTER (?g != <" + ModelNames.ABOX_INFERENCES + ">) " +
|
"FILTER (?g != <" + ABOX_INFERENCES + ">) " +
|
||||||
"FILTER (?g != <" + ModelNames.APPLICATION_METADATA + ">) }";
|
"FILTER (?g != <" + APPLICATION_METADATA + ">) }";
|
||||||
|
|
||||||
private static final String FULL_FULL_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
private static final String FULL_FULL_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
||||||
"WHERE { ?s ?p ?o }";
|
"WHERE { ?s ?p ?o }";
|
||||||
|
|
||||||
private static final String FULL_ASSERTED_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
private static final String FULL_ASSERTED_CONSTRUCT = "CONSTRUCT { ?s ?p ?o } " +
|
||||||
"WHERE { GRAPH ?g { ?s ?p ?o } " +
|
"WHERE { GRAPH ?g { ?s ?p ?o } " +
|
||||||
"FILTER (?g != <" + ModelNames.ABOX_INFERENCES + ">) " +
|
"FILTER (?g != <" + ABOX_INFERENCES + ">) " +
|
||||||
"FILTER (?g != <" + ModelNames.TBOX_INFERENCES + ">) }";
|
"FILTER (?g != <" + TBOX_INFERENCES + ">) }";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelMakerID.CONFIGURATION;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONFIGURATION;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelMakerID.CONTENT;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_UNION;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -63,18 +67,15 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
||||||
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.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelMakerID;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.BlankNodeFilteringModelMaker;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.BlankNodeFilteringModelMaker;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
||||||
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.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaIngestUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaIngestUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaIngestUtils.MergeResult;
|
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaIngestUtils.MergeResult;
|
||||||
|
@ -122,7 +123,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
ModelMaker maker = getModelMaker(vreq);
|
ModelMaker maker = getModelMaker(vreq);
|
||||||
ModelMakerID modelType = getModelType(vreq);
|
WhichService modelType = getModelType(vreq);
|
||||||
|
|
||||||
String actionStr = vreq.getParameter("action");
|
String actionStr = vreq.getParameter("action");
|
||||||
actionStr = (actionStr != null) ? actionStr : "";
|
actionStr = (actionStr != null) ? actionStr : "";
|
||||||
|
@ -203,7 +204,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processListModelsRequest(VitroRequest vreq, ModelMaker maker, ModelMakerID modelType) {
|
private void processListModelsRequest(VitroRequest vreq, ModelMaker maker, WhichService modelType) {
|
||||||
showModelList(vreq, maker, modelType);
|
showModelList(vreq, maker, modelType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +224,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
showModelList(vreq, vsmm, CONTENT);
|
showModelList(vreq, vsmm, CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCreateModelRequest(VitroRequest vreq, ModelMaker maker, ModelMakerID modelType) {
|
private void processCreateModelRequest(VitroRequest vreq, ModelMaker maker, WhichService modelType) {
|
||||||
String modelName = vreq.getParameter("modelName");
|
String modelName = vreq.getParameter("modelName");
|
||||||
|
|
||||||
if (modelName != null) {
|
if (modelName != null) {
|
||||||
|
@ -248,7 +249,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processRemoveModelRequest(VitroRequest vreq, ModelMaker maker, ModelMakerID modelType) {
|
private void processRemoveModelRequest(VitroRequest vreq, ModelMaker maker, WhichService modelType) {
|
||||||
String modelName = vreq.getParameter("modelName");
|
String modelName = vreq.getParameter("modelName");
|
||||||
if (modelName!=null) {
|
if (modelName!=null) {
|
||||||
doRemoveModel(modelName, maker);
|
doRemoveModel(modelName, maker);
|
||||||
|
@ -256,7 +257,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
showModelList(vreq, maker, modelType);
|
showModelList(vreq, maker, modelType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processClearModelRequest(VitroRequest vreq, ModelMaker maker, ModelMakerID modelType) {
|
private void processClearModelRequest(VitroRequest vreq, ModelMaker maker, WhichService modelType) {
|
||||||
String modelName = vreq.getParameter("modelName");
|
String modelName = vreq.getParameter("modelName");
|
||||||
if (modelName != null) {
|
if (modelName != null) {
|
||||||
doClearModel(modelName,maker);
|
doClearModel(modelName,maker);
|
||||||
|
@ -316,7 +317,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
vreq.setAttribute("bodyJsp",INGEST_MENU_JSP);
|
vreq.setAttribute("bodyJsp",INGEST_MENU_JSP);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processAttachModelRequest(VitroRequest vreq, ModelMaker maker, ModelMakerID modelType) {
|
private void processAttachModelRequest(VitroRequest vreq, ModelMaker maker, WhichService modelType) {
|
||||||
String modelName = vreq.getParameter("modelName");
|
String modelName = vreq.getParameter("modelName");
|
||||||
if (modelName != null) {
|
if (modelName != null) {
|
||||||
doAttachModel(modelName,maker);
|
doAttachModel(modelName,maker);
|
||||||
|
@ -324,7 +325,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
showModelList(vreq, maker, modelType);
|
showModelList(vreq, maker, modelType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processDetachModelRequest(VitroRequest vreq, ModelMaker maker, ModelMakerID modelType) {
|
private void processDetachModelRequest(VitroRequest vreq, ModelMaker maker, WhichService modelType) {
|
||||||
String modelName = vreq.getParameter("modelName");
|
String modelName = vreq.getParameter("modelName");
|
||||||
if (modelName != null) {
|
if (modelName != null) {
|
||||||
doDetachModel(modelName);
|
doDetachModel(modelName);
|
||||||
|
@ -464,7 +465,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
vreq.setAttribute("title", "Choose Workflow Step");
|
vreq.setAttribute("title", "Choose Workflow Step");
|
||||||
vreq.setAttribute("bodyJsp", WORKFLOW_STEP_JSP);
|
vreq.setAttribute("bodyJsp", WORKFLOW_STEP_JSP);
|
||||||
} else {
|
} else {
|
||||||
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
jenaOntModel.enterCriticalSection(Lock.READ);
|
jenaOntModel.enterCriticalSection(Lock.READ);
|
||||||
List<Individual> savedQueryList = new LinkedList<Individual>();
|
List<Individual> savedQueryList = new LinkedList<Individual>();
|
||||||
try {
|
try {
|
||||||
|
@ -481,7 +482,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
|
|
||||||
private void processExecuteSparqlRequest(VitroRequest vreq) {
|
private void processExecuteSparqlRequest(VitroRequest vreq) {
|
||||||
String sparqlQueryStr = vreq.getParameter("sparqlQueryStr");
|
String sparqlQueryStr = vreq.getParameter("sparqlQueryStr");
|
||||||
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
jenaOntModel.enterCriticalSection(Lock.READ);
|
jenaOntModel.enterCriticalSection(Lock.READ);
|
||||||
List<Individual> savedQueryList = new LinkedList<Individual>();
|
List<Individual> savedQueryList = new LinkedList<Individual>();
|
||||||
try {
|
try {
|
||||||
|
@ -607,8 +608,8 @@ public class JenaIngestController extends BaseEditController {
|
||||||
/*
|
/*
|
||||||
* get baseOnt and infOnt models
|
* get baseOnt and infOnt models
|
||||||
*/
|
*/
|
||||||
OntModel baseOntModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
OntModel baseOntModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS);
|
||||||
OntModel tboxOntModel = ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_UNION);
|
OntModel tboxOntModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calling method that does the merge operation.
|
* calling method that does the merge operation.
|
||||||
|
@ -679,7 +680,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
/**
|
/**
|
||||||
* Get the model type from the request, or from the session.
|
* Get the model type from the request, or from the session.
|
||||||
*/
|
*/
|
||||||
protected ModelMakerID getModelType(VitroRequest vreq) {
|
protected WhichService getModelType(VitroRequest vreq) {
|
||||||
String modelType = vreq.getParameter("modelType");
|
String modelType = vreq.getParameter("modelType");
|
||||||
if (modelType != null) {
|
if (modelType != null) {
|
||||||
if (modelType.equals(CONFIGURATION.toString())) {
|
if (modelType.equals(CONFIGURATION.toString())) {
|
||||||
|
@ -757,7 +758,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
}
|
}
|
||||||
Model m = ModelFactory.createDefaultModel();
|
Model m = ModelFactory.createDefaultModel();
|
||||||
m.add(modelMaker.getModel(modelName));
|
m.add(modelMaker.getModel(modelName));
|
||||||
ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_ASSERTIONS).addSubModel(m);
|
ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS).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");
|
||||||
}
|
}
|
||||||
|
@ -767,7 +768,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
if (m == null) {
|
if (m == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ModelAccess.on(getServletContext()).getOntModel(ModelNames.TBOX_ASSERTIONS).removeSubModel(m);
|
ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS).removeSubModel(m);
|
||||||
attachedModels.remove(modelName);
|
attachedModels.remove(modelName);
|
||||||
log.info("Detached " + modelName + " (" + m.hashCode() + ") from webapp");
|
log.info("Detached " + modelName + " (" + m.hashCode() + ") from webapp");
|
||||||
}
|
}
|
||||||
|
@ -835,7 +836,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long doExecuteSparql(VitroRequest vreq) {
|
private long doExecuteSparql(VitroRequest vreq) {
|
||||||
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
OntModel source = null;
|
OntModel source = null;
|
||||||
if ("pellet".equals(vreq.getParameter("reasoning"))) {
|
if ("pellet".equals(vreq.getParameter("reasoning"))) {
|
||||||
source = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
source = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
||||||
|
@ -1073,13 +1074,13 @@ public class JenaIngestController extends BaseEditController {
|
||||||
String result = null;
|
String result = null;
|
||||||
Integer counter = 0;
|
Integer counter = 0;
|
||||||
Boolean namespacePresent = false;
|
Boolean namespacePresent = false;
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(
|
RDFService rdfService = ModelAccess.on(getServletContext())
|
||||||
getServletContext()).getRDFService();
|
.getRDFService();
|
||||||
try {
|
try {
|
||||||
Model baseOntModel = RDFServiceGraph.createRDFServiceModel
|
Model baseOntModel = RDFServiceGraph.createRDFServiceModel
|
||||||
(new RDFServiceGraph(
|
(new RDFServiceGraph(
|
||||||
rdfService, ModelNames.ABOX_ASSERTIONS));
|
rdfService, ABOX_ASSERTIONS));
|
||||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
List<String> urisToChange = new LinkedList<String>();
|
List<String> urisToChange = new LinkedList<String>();
|
||||||
ontModel.enterCriticalSection(Lock.READ);
|
ontModel.enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
|
@ -1117,7 +1118,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
log.debug("Renaming "+ oldURIStr + " to " + newURIStr);
|
log.debug("Renaming "+ oldURIStr + " to " + newURIStr);
|
||||||
|
|
||||||
String whereClause = "} WHERE { \n" +
|
String whereClause = "} WHERE { \n" +
|
||||||
" GRAPH <" + ModelNames.ABOX_ASSERTIONS + "> { \n" +
|
" GRAPH <" + ABOX_ASSERTIONS + "> { \n" +
|
||||||
" { <" + oldURIStr + "> ?p <" + oldURIStr + "> } \n " +
|
" { <" + oldURIStr + "> ?p <" + oldURIStr + "> } \n " +
|
||||||
" UNION \n" +
|
" UNION \n" +
|
||||||
" { <" + oldURIStr + "> ?q ?o } \n " +
|
" { <" + oldURIStr + "> ?q ?o } \n " +
|
||||||
|
@ -1140,11 +1141,11 @@ public class JenaIngestController extends BaseEditController {
|
||||||
cs.addAddition(rdfService.sparqlConstructQuery(
|
cs.addAddition(rdfService.sparqlConstructQuery(
|
||||||
addQuery, RDFService.ModelSerializationFormat.N3),
|
addQuery, RDFService.ModelSerializationFormat.N3),
|
||||||
RDFService.ModelSerializationFormat.N3,
|
RDFService.ModelSerializationFormat.N3,
|
||||||
ModelNames.ABOX_ASSERTIONS);
|
ABOX_ASSERTIONS);
|
||||||
cs.addRemoval(rdfService.sparqlConstructQuery(
|
cs.addRemoval(rdfService.sparqlConstructQuery(
|
||||||
removeQuery, RDFService.ModelSerializationFormat.N3),
|
removeQuery, RDFService.ModelSerializationFormat.N3),
|
||||||
RDFService.ModelSerializationFormat.N3,
|
RDFService.ModelSerializationFormat.N3,
|
||||||
ModelNames.ABOX_ASSERTIONS);
|
ABOX_ASSERTIONS);
|
||||||
rdfService.changeSetUpdate(cs);
|
rdfService.changeSetUpdate(cs);
|
||||||
} catch (RDFServiceException e) {
|
} catch (RDFServiceException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -1165,7 +1166,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showModelList(VitroRequest vreq, ModelMaker maker, ModelMakerID modelType) {
|
protected void showModelList(VitroRequest vreq, ModelMaker maker, WhichService modelType) {
|
||||||
vreq.setAttribute("modelType", modelType.toString());
|
vreq.setAttribute("modelType", modelType.toString());
|
||||||
if(modelType == CONTENT){
|
if(modelType == CONTENT){
|
||||||
vreq.setAttribute("infoLine", "Main Store models");
|
vreq.setAttribute("infoLine", "Main Store models");
|
||||||
|
@ -1205,19 +1206,14 @@ public class JenaIngestController extends BaseEditController {
|
||||||
protected static ModelMaker getModelMaker(HttpServletRequest req){
|
protected static ModelMaker getModelMaker(HttpServletRequest req){
|
||||||
ServletContext ctx = req.getSession().getServletContext();
|
ServletContext ctx = req.getSession().getServletContext();
|
||||||
if (isUsingMainStoreForIngest(req)) {
|
if (isUsingMainStoreForIngest(req)) {
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(ctx,
|
RDFService rdfService = ModelAccess.on(ctx).getRDFService(CONTENT);
|
||||||
WhichService.CONTENT).getRDFService();
|
|
||||||
return new BlankNodeFilteringModelMaker(rdfService, ModelAccess.on(
|
return new BlankNodeFilteringModelMaker(rdfService, ModelAccess.on(
|
||||||
ctx).getModelMaker(CONTENT));
|
ctx).getModelMaker(CONTENT));
|
||||||
} else {
|
} else {
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(ctx,
|
RDFService rdfService = ModelAccess.on(ctx).getRDFService(CONFIGURATION);
|
||||||
WhichService.CONFIGURATION).getRDFService();
|
|
||||||
return new BlankNodeFilteringModelMaker(rdfService, ModelAccess.on(
|
return new BlankNodeFilteringModelMaker(rdfService, ModelAccess.on(
|
||||||
ctx).getModelMaker(CONFIGURATION));
|
ctx).getModelMaker(CONFIGURATION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -16,7 +19,6 @@ import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.commons.fileupload.FileItem;
|
import org.apache.commons.fileupload.FileItem;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -34,15 +36,14 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
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.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.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelMakerID;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.BulkUpdateEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.BulkUpdateEvent;
|
||||||
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.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
|
@ -112,7 +113,7 @@ public class RDFUploadController extends JenaIngestController {
|
||||||
String uploadDesc ="";
|
String uploadDesc ="";
|
||||||
|
|
||||||
OntModel uploadModel = (directRead)
|
OntModel uploadModel = (directRead)
|
||||||
? getABoxModel(request.getSession(), getServletContext())
|
? getABoxModel(getServletContext())
|
||||||
: ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
: ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
|
|
||||||
/* ********************* GET RDF by URL ********************** */
|
/* ********************* GET RDF by URL ********************** */
|
||||||
|
@ -184,9 +185,9 @@ public class RDFUploadController extends JenaIngestController {
|
||||||
|
|
||||||
JenaModelUtils xutil = new JenaModelUtils();
|
JenaModelUtils xutil = new JenaModelUtils();
|
||||||
|
|
||||||
OntModel tboxModel = getTBoxModel(request.getSession());
|
OntModel tboxModel = getTBoxModel();
|
||||||
OntModel aboxModel = getABoxModel(
|
OntModel aboxModel = getABoxModel(
|
||||||
request.getSession(), getServletContext());
|
getServletContext());
|
||||||
OntModel tboxChangeModel = null;
|
OntModel tboxChangeModel = null;
|
||||||
Model aboxChangeModel = null;
|
Model aboxChangeModel = null;
|
||||||
OntModelSelector ontModelSelector = ModelAccess.on(getServletContext()).getOntModelSelector();
|
OntModelSelector ontModelSelector = ModelAccess.on(getServletContext()).getOntModelSelector();
|
||||||
|
@ -233,7 +234,7 @@ public class RDFUploadController extends JenaIngestController {
|
||||||
? RDFService.ModelSerializationFormat.RDFXML
|
? RDFService.ModelSerializationFormat.RDFXML
|
||||||
: RDFService.ModelSerializationFormat.N3;
|
: RDFService.ModelSerializationFormat.N3;
|
||||||
changeSet.addAddition(in, format,
|
changeSet.addAddition(in, format,
|
||||||
ModelNames.ABOX_ASSERTIONS);
|
ABOX_ASSERTIONS);
|
||||||
try {
|
try {
|
||||||
rdfService.changeSetUpdate(changeSet);
|
rdfService.changeSetUpdate(changeSet);
|
||||||
} catch (RDFServiceException rdfse) {
|
} catch (RDFServiceException rdfse) {
|
||||||
|
@ -262,7 +263,7 @@ public class RDFUploadController extends JenaIngestController {
|
||||||
} finally {
|
} finally {
|
||||||
rdfService.close();
|
rdfService.close();
|
||||||
}
|
}
|
||||||
ModelMakerID modelType = getModelType(request);
|
WhichService modelType = getModelType(request);
|
||||||
showModelList(request, maker, modelType);
|
showModelList(request, maker, modelType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,8 +283,7 @@ public class RDFUploadController extends JenaIngestController {
|
||||||
private RDFService getRDFService(VitroRequest vreq, ModelMaker maker, String modelName) {
|
private RDFService getRDFService(VitroRequest vreq, ModelMaker maker, String modelName) {
|
||||||
if (isUsingMainStoreForIngest(vreq)) {
|
if (isUsingMainStoreForIngest(vreq)) {
|
||||||
log.debug("Using main RDFService");
|
log.debug("Using main RDFService");
|
||||||
return RDFServiceUtils.getRDFServiceFactory(
|
return ModelAccess.on(getServletContext()).getRDFService();
|
||||||
getServletContext()).getRDFService();
|
|
||||||
} else {
|
} else {
|
||||||
log.debug("Making RDFService for single model from ModelMaker");
|
log.debug("Making RDFService for single model from ModelMaker");
|
||||||
Model m = maker.getModel(modelName);
|
Model m = maker.getModel(modelName);
|
||||||
|
@ -431,15 +431,15 @@ public class RDFUploadController extends JenaIngestController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OntModel getABoxModel(HttpSession session, ServletContext ctx) {
|
private OntModel getABoxModel(ServletContext ctx) {
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(ctx).getRDFService();
|
RDFService rdfService = ModelAccess.on(ctx).getRDFService();
|
||||||
Model abox = RDFServiceGraph.createRDFServiceModel(
|
Model abox = RDFServiceGraph.createRDFServiceModel(
|
||||||
new RDFServiceGraph(rdfService, ModelNames.ABOX_ASSERTIONS));
|
new RDFServiceGraph(rdfService, ABOX_ASSERTIONS));
|
||||||
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, abox);
|
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, abox);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OntModel getTBoxModel(HttpSession session) {
|
private OntModel getTBoxModel() {
|
||||||
return ModelAccess.on(session).getOntModel(ModelNames.TBOX_ASSERTIONS);
|
return ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(
|
private static final Log log = LogFactory.getLog(
|
||||||
|
|
|
@ -1,322 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao;
|
|
||||||
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelectorImpl;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.VitroModelFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hierarchical storage for models. TODO
|
|
||||||
*
|
|
||||||
* Could this be extended? Could it be used to replace or implement these
|
|
||||||
* methods?
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* VitroRequest.getAssertionsWebappDaoFactory()
|
|
||||||
* VitroRequest.getFullWebappDaoFactory()
|
|
||||||
* VitroRequest.getRDFService()
|
|
||||||
* VitroRequest.getUnfilteredRDFService()
|
|
||||||
* VitroRequest.getWebappDaoFactory()
|
|
||||||
* VitroRequest.getWriteModel()
|
|
||||||
*
|
|
||||||
* OntModelSelector.getABoxModel
|
|
||||||
* OntModelSelector.getFullModel()
|
|
||||||
* OntModelSelector.getTBoxModel()
|
|
||||||
* VitroModelSource.getModel(URL)
|
|
||||||
* VitroModelSource.getModel(URL, loadIfAbsent)
|
|
||||||
* VitroModelSource.openModel(name)
|
|
||||||
* VitroModelSource.openModelIfPresent(string)
|
|
||||||
* ServletContext.getAttribute("pelletOntModel")
|
|
||||||
* JenaDataSourceSetupBase.getStartupDataset()
|
|
||||||
* HttpSession.getAttribute("jenaAuditModel")
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ModelAccess {
|
|
||||||
private static final Log log = LogFactory.getLog(ModelAccess.class);
|
|
||||||
|
|
||||||
/** These attributes should only be accessed through this class. */
|
|
||||||
private static final String ATTRIBUTE_NAME = ModelAccess.class.getName();
|
|
||||||
|
|
||||||
public enum FactoryID {
|
|
||||||
BASE, UNION, UNFILTERED_BASE, UNFILTERED_UNION
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ModelMakerID {
|
|
||||||
CONTENT, CONFIGURATION
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum Scope {
|
|
||||||
CONTEXT, SESSION, REQUEST
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Factory methods
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public static ModelAccess on(HttpServletRequest req) {
|
|
||||||
Object o = req.getAttribute(ATTRIBUTE_NAME);
|
|
||||||
if (o instanceof ModelAccess) {
|
|
||||||
return (ModelAccess) o;
|
|
||||||
} else {
|
|
||||||
ModelAccess parent = on(req.getSession());
|
|
||||||
ModelAccess ma = new ModelAccess(Scope.REQUEST, parent);
|
|
||||||
req.setAttribute(ATTRIBUTE_NAME, ma);
|
|
||||||
return ma;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModelAccess on(HttpSession session) {
|
|
||||||
Object o = session.getAttribute(ATTRIBUTE_NAME);
|
|
||||||
if (o instanceof ModelAccess) {
|
|
||||||
return (ModelAccess) o;
|
|
||||||
} else {
|
|
||||||
ModelAccess parent = on(session.getServletContext());
|
|
||||||
ModelAccess ma = new ModelAccess(Scope.SESSION, parent);
|
|
||||||
session.setAttribute(ATTRIBUTE_NAME, ma);
|
|
||||||
return ma;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModelAccess on(ServletContext ctx) {
|
|
||||||
Object o = ctx.getAttribute(ATTRIBUTE_NAME);
|
|
||||||
if (o instanceof ModelAccess) {
|
|
||||||
return (ModelAccess) o;
|
|
||||||
} else {
|
|
||||||
ModelAccess ma = new ModelAccess(Scope.CONTEXT, null);
|
|
||||||
ctx.setAttribute(ATTRIBUTE_NAME, ma);
|
|
||||||
return ma;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// The instance
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
private final Scope scope;
|
|
||||||
private final ModelAccess parent;
|
|
||||||
private final Map<String, OntModel> modelMap = new HashMap<>();
|
|
||||||
private final Map<FactoryID, WebappDaoFactory> factoryMap = new EnumMap<>(
|
|
||||||
FactoryID.class);
|
|
||||||
private final Map<ModelMakerID, ModelMaker> modelMakerMap = new EnumMap<>(
|
|
||||||
ModelMakerID.class);
|
|
||||||
|
|
||||||
public ModelAccess(Scope scope, ModelAccess parent) {
|
|
||||||
this.scope = scope;
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Accessing the models
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public OntModel getApplicationMetadataModel() {
|
|
||||||
return getOntModel(ModelNames.APPLICATION_METADATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getUserAccountsModel() {
|
|
||||||
return getOntModel(ModelNames.USER_ACCOUNTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getDisplayModel() {
|
|
||||||
return getOntModel(ModelNames.DISPLAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getJenaOntModel() {
|
|
||||||
return getOntModel(ModelNames.FULL_UNION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getBaseOntModel() {
|
|
||||||
return getOntModel(ModelNames.FULL_ASSERTIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getInferenceOntModel() {
|
|
||||||
return getOntModel(ModelNames.FULL_INFERENCES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOntModel(String id, OntModel ontModel) {
|
|
||||||
if (ontModel == null) {
|
|
||||||
modelMap.remove(id);
|
|
||||||
} else {
|
|
||||||
modelMap.put(id, ontModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModel getOntModel(String id) {
|
|
||||||
if (modelMap.containsKey(id)) {
|
|
||||||
log.debug("Using " + id + " model from " + scope);
|
|
||||||
return modelMap.get(id);
|
|
||||||
} else if (parent != null) {
|
|
||||||
return parent.getOntModel(id);
|
|
||||||
} else {
|
|
||||||
log.warn("No model found for " + id);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Accessing the Webapp DAO factories.
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public void setWebappDaoFactory(WebappDaoFactory wadf) {
|
|
||||||
setWebappDaoFactory(FactoryID.UNION, wadf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebappDaoFactory getWebappDaoFactory() {
|
|
||||||
return getWebappDaoFactory(FactoryID.UNION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBaseWebappDaoFactory(WebappDaoFactory wadf) {
|
|
||||||
setWebappDaoFactory(FactoryID.BASE, wadf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebappDaoFactory getBaseWebappDaoFactory() {
|
|
||||||
return getWebappDaoFactory(FactoryID.BASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWebappDaoFactory(FactoryID id, WebappDaoFactory wadf) {
|
|
||||||
if (wadf == null) {
|
|
||||||
factoryMap.remove(id);
|
|
||||||
} else {
|
|
||||||
factoryMap.put(id, wadf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeWebappDaoFactory(FactoryID id) {
|
|
||||||
setWebappDaoFactory(id, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebappDaoFactory getWebappDaoFactory(FactoryID id) {
|
|
||||||
if (factoryMap.containsKey(id)) {
|
|
||||||
log.debug("Using " + id + " DAO factory from " + scope);
|
|
||||||
return factoryMap.get(id);
|
|
||||||
} else if (parent != null) {
|
|
||||||
return parent.getWebappDaoFactory(id);
|
|
||||||
} else {
|
|
||||||
log.warn("No DAO factory found for " + id);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Accessing the OntModelSelectors
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public OntModelSelector getOntModelSelector() {
|
|
||||||
return getUnionOntModelSelector();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModelSelector getBaseOntModelSelector() {
|
|
||||||
return createOntModelSelector(ModelNames.ABOX_ASSERTIONS,
|
|
||||||
ModelNames.TBOX_ASSERTIONS, ModelNames.FULL_ASSERTIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModelSelector getInferenceOntModelSelector() {
|
|
||||||
return createOntModelSelector(ModelNames.ABOX_INFERENCES,
|
|
||||||
ModelNames.TBOX_INFERENCES, ModelNames.FULL_INFERENCES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OntModelSelector getUnionOntModelSelector() {
|
|
||||||
return createOntModelSelector(ModelNames.ABOX_UNION,
|
|
||||||
ModelNames.TBOX_UNION, ModelNames.FULL_UNION);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Accessing the ModelMakers
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public ModelMaker getModelMaker(ModelMakerID id) {
|
|
||||||
if (modelMakerMap.containsKey(id)) {
|
|
||||||
log.debug("Using " + id + " modelMaker from " + scope);
|
|
||||||
return modelMakerMap.get(id);
|
|
||||||
} else if (parent != null) {
|
|
||||||
return parent.getModelMaker(id);
|
|
||||||
} else {
|
|
||||||
log.warn("No modelMaker found for " + id);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModelMaker(ModelMakerID id, ModelMaker modelMaker) {
|
|
||||||
modelMakerMap.put(id, modelMaker);
|
|
||||||
if (id == ModelMakerID.CONFIGURATION) {
|
|
||||||
setOntModel(modelMaker, ModelNames.USER_ACCOUNTS);
|
|
||||||
setOntModel(modelMaker, ModelNames.DISPLAY);
|
|
||||||
setOntModel(modelMaker, ModelNames.DISPLAY_DISPLAY);
|
|
||||||
setOntModel(modelMaker, ModelNames.DISPLAY_TBOX);
|
|
||||||
} else {
|
|
||||||
setOntModel(modelMaker, ModelNames.APPLICATION_METADATA);
|
|
||||||
setOntModel(modelMaker, ModelNames.TBOX_ASSERTIONS);
|
|
||||||
setOntModel(modelMaker, ModelNames.TBOX_INFERENCES);
|
|
||||||
setOntModel(modelMaker, ModelNames.TBOX_UNION);
|
|
||||||
setOntModel(modelMaker, ModelNames.ABOX_ASSERTIONS);
|
|
||||||
setOntModel(modelMaker, ModelNames.ABOX_INFERENCES);
|
|
||||||
setOntModel(modelMaker, ModelNames.ABOX_UNION);
|
|
||||||
setOntModel(modelMaker, ModelNames.FULL_ASSERTIONS);
|
|
||||||
setOntModel(modelMaker, ModelNames.FULL_INFERENCES);
|
|
||||||
setOntModel(modelMaker, ModelNames.FULL_UNION);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* KLUGE
|
|
||||||
*
|
|
||||||
* For some reason, the union of two OntModels (like this) works
|
|
||||||
* fine as the TBOX_UNION, but an OntModel wrapped around the union
|
|
||||||
* of two Models (from ModelMakers) does not work.
|
|
||||||
*
|
|
||||||
* See also the Kluge in RequestModelsPrep.
|
|
||||||
*/
|
|
||||||
setOntModel(ModelNames.TBOX_UNION, VitroModelFactory.createUnion(
|
|
||||||
getOntModel(ModelNames.TBOX_ASSERTIONS),
|
|
||||||
getOntModel(ModelNames.TBOX_INFERENCES)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setOntModel(ModelMaker mm, String name) {
|
|
||||||
setOntModel(name,
|
|
||||||
VitroModelFactory.createOntologyModel(mm.getModel(name)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private OntModelSelector createOntModelSelector(String aboxName,
|
|
||||||
String tboxName, String fullName) {
|
|
||||||
OntModelSelectorImpl oms = new OntModelSelectorImpl();
|
|
||||||
|
|
||||||
oms.setApplicationMetadataModel(getOntModel(ModelNames.APPLICATION_METADATA));
|
|
||||||
oms.setDisplayModel(getOntModel(ModelNames.DISPLAY));
|
|
||||||
oms.setUserAccountsModel(getOntModel(ModelNames.USER_ACCOUNTS));
|
|
||||||
|
|
||||||
oms.setABoxModel(getOntModel(aboxName));
|
|
||||||
oms.setTBoxModel(getOntModel(tboxName));
|
|
||||||
oms.setFullModel(getOntModel(fullName));
|
|
||||||
|
|
||||||
return oms;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Close all locally stored models, WADFs, etc.
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
if (this.scope == Scope.REQUEST) {
|
|
||||||
for (WebappDaoFactory wadf : factoryMap.values()) {
|
|
||||||
wadf.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -16,6 +16,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
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.dao.jena.VClassGroupCache;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request-based image of the VClassGroupCache. That means that the names of
|
* A request-based image of the VClassGroupCache. That means that the names of
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
|
||||||
|
@ -73,9 +72,15 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
|
||||||
this.innerWebappDaoFactory = innerDao;
|
this.innerWebappDaoFactory = innerDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WebappDaoFactoryFiltering[inner=" + innerWebappDaoFactory + "]";
|
||||||
|
}
|
||||||
|
|
||||||
/* ******************* filtering *********************** */
|
/* ******************* filtering *********************** */
|
||||||
|
|
||||||
public String checkURI(String uriStr) {
|
|
||||||
|
public String checkURI(String uriStr) {
|
||||||
return innerWebappDaoFactory.checkURI(uriStr);
|
return innerWebappDaoFactory.checkURI(uriStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import com.hp.hpl.jena.shared.PrefixMapping;
|
||||||
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
||||||
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class BlankNodeFilteringGraph implements Graph {
|
public class BlankNodeFilteringGraph implements Graph {
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import com.hp.hpl.jena.shared.PrefixMapping;
|
||||||
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
||||||
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class DifferenceGraph implements Graph {
|
public class DifferenceGraph implements Graph {
|
||||||
|
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.graph.Graph;
|
|
||||||
import com.hp.hpl.jena.rdf.listeners.StatementListener;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Statement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This listener will open and close DB models as it performs edits to avoid
|
|
||||||
* wasting DB connections
|
|
||||||
* @author bjl23
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class MemToDBModelSynchronizer extends StatementListener {
|
|
||||||
|
|
||||||
private static long IDLE_MILLIS = 2000; // how long to let a model site idle
|
|
||||||
// after an edit has been performed
|
|
||||||
|
|
||||||
SQLGraphGenerator generator;
|
|
||||||
Model model;
|
|
||||||
boolean editInProgress;
|
|
||||||
boolean cleanupThreadActive;
|
|
||||||
long lastEditTimeMillis;
|
|
||||||
|
|
||||||
public MemToDBModelSynchronizer(SQLGraphGenerator generator) {
|
|
||||||
this.generator = generator;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model getModel() {
|
|
||||||
if ( model != null && !model.isClosed() ) {
|
|
||||||
return model;
|
|
||||||
} else {
|
|
||||||
Graph g = generator.generateGraph();
|
|
||||||
model = ModelFactory.createModelForGraph(g);
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addedStatement(Statement stmt) {
|
|
||||||
this.editInProgress = true;
|
|
||||||
try {
|
|
||||||
getModel().add(stmt);
|
|
||||||
} finally {
|
|
||||||
lastEditTimeMillis = System.currentTimeMillis();
|
|
||||||
this.editInProgress = false;
|
|
||||||
if (!cleanupThreadActive) {
|
|
||||||
(new Thread(
|
|
||||||
new Cleanup(this), "MemToDBModelSynchronizer")).start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedStatement(Statement stmt) {
|
|
||||||
this.editInProgress = true;
|
|
||||||
try {
|
|
||||||
getModel().remove(stmt);
|
|
||||||
} finally {
|
|
||||||
lastEditTimeMillis = System.currentTimeMillis();
|
|
||||||
this.editInProgress = false;
|
|
||||||
if (!cleanupThreadActive) {
|
|
||||||
(new Thread(
|
|
||||||
new Cleanup(this), "MemToDBModelSynchronizer")).start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Cleanup implements Runnable {
|
|
||||||
|
|
||||||
private MemToDBModelSynchronizer s;
|
|
||||||
|
|
||||||
public Cleanup(MemToDBModelSynchronizer s) {
|
|
||||||
this.s = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
s.cleanupThreadActive = true;
|
|
||||||
while( (s.editInProgress)
|
|
||||||
|| (System.currentTimeMillis()
|
|
||||||
- s.lastEditTimeMillis < IDLE_MILLIS ) ) {
|
|
||||||
try {
|
|
||||||
Thread.currentThread().sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Interrupted cleanup thread in "
|
|
||||||
+ this.getClass().getName(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (s.model != null) {
|
|
||||||
s.model.close();
|
|
||||||
s.model = null;
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(
|
|
||||||
this.getClass().getName() + "Model already null");
|
|
||||||
}
|
|
||||||
java.sql.Connection c = generator.getConnection();
|
|
||||||
try {
|
|
||||||
if ( (c != null) && (!c.isClosed()) ) {
|
|
||||||
c.close();
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
s.cleanupThreadActive = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,117 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelChangedListener;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Statement;
|
|
||||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
|
||||||
import com.hp.hpl.jena.rdf.model.impl.StmtIteratorImpl;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.CloseEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple change listener to keep a model (the 'synchronizee') in synch with the
|
|
||||||
* model with which it is registered.
|
|
||||||
*
|
|
||||||
* @author bjl23
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ModelSynchronizer implements ModelChangedListener {
|
|
||||||
private static final Log log = LogFactory.getLog(ModelSynchronizer.class);
|
|
||||||
|
|
||||||
private Model m;
|
|
||||||
private String hash;
|
|
||||||
|
|
||||||
public ModelSynchronizer(Model synchronizee, String name) {
|
|
||||||
this.m = synchronizee;
|
|
||||||
this.hash = Integer.toHexString(this.hashCode());
|
|
||||||
log.debug(String.format("create: %s, wraps %s(%s) as %s", hash, this.m
|
|
||||||
.getClass().getName(), Integer.toHexString(this.m.hashCode()),
|
|
||||||
name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addedStatement(Statement s) {
|
|
||||||
log.debug(hash + " addedStatement" + s);
|
|
||||||
m.add(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addedStatements(Statement[] statements) {
|
|
||||||
log.debug(hash + " addedStatements: " + statements.length);
|
|
||||||
m.add(statements);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addedStatements(List<Statement> statements) {
|
|
||||||
log.debug(hash + " addedStatements: " + statements.size());
|
|
||||||
m.add(statements);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addedStatements(StmtIterator statements) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
Set<Statement> set = statements.toSet();
|
|
||||||
log.debug(hash + " addedStatements: " + set.size());
|
|
||||||
m.add(new StmtIteratorImpl(set.iterator()));
|
|
||||||
} else {
|
|
||||||
m.add(new StmtIteratorImpl(statements));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addedStatements(Model model) {
|
|
||||||
log.debug(hash + " addedStatements: " + model.size());
|
|
||||||
m.add(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyEvent(Model model, Object event) {
|
|
||||||
if (event instanceof CloseEvent) {
|
|
||||||
m.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedStatement(Statement s) {
|
|
||||||
log.debug(hash + " removedStatement" + s);
|
|
||||||
m.remove(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedStatements(Statement[] statements) {
|
|
||||||
log.debug(hash + " removedStatements: " + statements.length);
|
|
||||||
m.remove(statements);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedStatements(List<Statement> statements) {
|
|
||||||
log.debug(hash + " removedStatements: " + statements.size());
|
|
||||||
m.remove(statements);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedStatements(StmtIterator statements) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
Set<Statement> set = statements.toSet();
|
|
||||||
log.debug(hash + " removedStatements: " + set.size());
|
|
||||||
m.remove(new StmtIteratorImpl(set.iterator()));
|
|
||||||
} else {
|
|
||||||
m.remove(new StmtIteratorImpl(statements));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedStatements(Model model) {
|
|
||||||
log.debug(hash + " removedStatements: " + model.size());
|
|
||||||
m.remove(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -12,7 +12,7 @@ public class OntModelSelectorImpl implements OntModelSelector {
|
||||||
private OntModel fullModel;
|
private OntModel fullModel;
|
||||||
private OntModel tboxModel;
|
private OntModel tboxModel;
|
||||||
private OntModel userAccountsModel;
|
private OntModel userAccountsModel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OntModel getABoxModel() {
|
public OntModel getABoxModel() {
|
||||||
return this.aboxModel;
|
return this.aboxModel;
|
||||||
|
@ -42,11 +42,11 @@ public class OntModelSelectorImpl implements OntModelSelector {
|
||||||
public OntModel getUserAccountsModel() {
|
public OntModel getUserAccountsModel() {
|
||||||
return this.userAccountsModel;
|
return this.userAccountsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setABoxModel(OntModel m) {
|
public void setABoxModel(OntModel m) {
|
||||||
this.aboxModel = m;
|
this.aboxModel = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApplicationMetadataModel(OntModel m) {
|
public void setApplicationMetadataModel(OntModel m) {
|
||||||
this.applicationMetadataModel = m;
|
this.applicationMetadataModel = m;
|
||||||
}
|
}
|
||||||
|
@ -54,17 +54,26 @@ public class OntModelSelectorImpl implements OntModelSelector {
|
||||||
public void setDisplayModel(OntModel m) {
|
public void setDisplayModel(OntModel m) {
|
||||||
this.displayModel = m;
|
this.displayModel = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTBoxModel(OntModel m) {
|
public void setTBoxModel(OntModel m) {
|
||||||
this.tboxModel = m;
|
this.tboxModel = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserAccountsModel(OntModel m) {
|
public void setUserAccountsModel(OntModel m) {
|
||||||
this.userAccountsModel = m;
|
this.userAccountsModel = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFullModel(OntModel m) {
|
public void setFullModel(OntModel m) {
|
||||||
this.fullModel = m;
|
this.fullModel = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OntModelSelectorImpl[abox=" + hashHex(aboxModel) + ", tbox="
|
||||||
|
+ hashHex(tboxModel) + ", full=" + hashHex(fullModel) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String hashHex(Object o) {
|
||||||
|
return (o == null) ? "00000000" : Integer.toString(o.hashCode(), 16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import com.hp.hpl.jena.sparql.core.DatasetGraph;
|
||||||
import com.hp.hpl.jena.sparql.util.Context;
|
import com.hp.hpl.jena.sparql.util.Context;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class RDFServiceDataset implements Dataset {
|
public class RDFServiceDataset implements Dataset {
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class RDFServiceDatasetGraph implements DatasetGraph {
|
public class RDFServiceDatasetGraph implements DatasetGraph {
|
||||||
|
|
||||||
|
@ -224,4 +225,9 @@ public class RDFServiceDatasetGraph implements DatasetGraph {
|
||||||
return (node == null || node.isVariable() || node == Node.ANY);
|
return (node == null || node.isVariable() || node == Node.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RDFServiceDatasetGraph[" + ToString.hashHex(this)
|
||||||
|
+ ", " + rdfService + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.VitroModelFactory;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.VitroModelFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class RDFServiceGraph implements GraphWithPerform {
|
public class RDFServiceGraph implements GraphWithPerform {
|
||||||
|
|
||||||
|
|
|
@ -160,4 +160,9 @@ public class RDFServiceModelMaker implements ModelMaker {
|
||||||
return dataset.getNamedModel(name);
|
return dataset.getNamedModel(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RDFServiceModelMaker[service=" + service + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
||||||
import com.hp.hpl.jena.vocabulary.DCTerms;
|
import com.hp.hpl.jena.vocabulary.DCTerms;
|
||||||
import com.hp.hpl.jena.vocabulary.RDF;
|
import com.hp.hpl.jena.vocabulary.RDF;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class RegeneratingGraph implements Graph, Regenerable {
|
public class RegeneratingGraph implements Graph, Regenerable {
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
||||||
import com.hp.hpl.jena.util.iterator.SingletonIterator;
|
import com.hp.hpl.jena.util.iterator.SingletonIterator;
|
||||||
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class SparqlGraph implements GraphWithPerform {
|
public class SparqlGraph implements GraphWithPerform {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.hp.hpl.jena.shared.AddDeniedException;
|
||||||
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
||||||
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
public class SparqlGraphMultilingual extends SparqlGraph implements GraphWithPerform {
|
public class SparqlGraphMultilingual extends SparqlGraph implements GraphWithPerform {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||||
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.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
@ -35,6 +34,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchFacetField;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchFacetField;
|
||||||
|
@ -498,7 +498,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
} else if(VitroVocabulary.DISPLAY_RANK.equals(stmt.getPredicate().getURI())){
|
} else if(VitroVocabulary.DISPLAY_RANK.equals(stmt.getPredicate().getURI())){
|
||||||
requestCacheUpdate();
|
requestCacheUpdate();
|
||||||
} else {
|
} else {
|
||||||
OntModel jenaOntModel = ModelAccess.on(context).getJenaOntModel();
|
OntModel jenaOntModel = ModelAccess.on(context).getOntModel();
|
||||||
if( isClassNameChange(stmt, jenaOntModel) ) {
|
if( isClassNameChange(stmt, jenaOntModel) ) {
|
||||||
requestCacheUpdate();
|
requestCacheUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelReader;
|
import com.hp.hpl.jena.rdf.model.ModelReader;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelSource;
|
import com.hp.hpl.jena.rdf.model.ModelSource;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,11 +107,11 @@ public class VitroModelSource implements ModelSource {
|
||||||
private Model getNamedModel( ModelName pmn ){
|
private Model getNamedModel( ModelName pmn ){
|
||||||
switch( pmn ){
|
switch( pmn ){
|
||||||
case ABOX:
|
case ABOX:
|
||||||
return ModelAccess.on(context).getJenaOntModel();
|
return ModelAccess.on(context).getOntModel();
|
||||||
case TBOX:
|
case TBOX:
|
||||||
return (Model) context.getAttribute("tboxmodel???");
|
return (Model) context.getAttribute("tboxmodel???");
|
||||||
case DISPLAY:
|
case DISPLAY:
|
||||||
return ModelAccess.on(context).getDisplayModel();
|
return ModelAccess.on(context).getOntModel(ModelNames.DISPLAY);
|
||||||
case DISPLAY_TBOX:
|
case DISPLAY_TBOX:
|
||||||
return ModelAccess.on(context).getOntModel(ModelNames.DISPLAY_TBOX);
|
return ModelAccess.on(context).getOntModel(ModelNames.DISPLAY_TBOX);
|
||||||
case DISPLAY_DISPLAY:
|
case DISPLAY_DISPLAY:
|
||||||
|
|
|
@ -49,8 +49,14 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
this.datasetMode = datasetMode;
|
this.datasetMode = datasetMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebappDaoFactorySDB(WebappDaoFactorySDB base, String userURI) {
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WebappDaoFactorySDB[" + Integer.toString(hashCode(), 16) + ", "
|
||||||
|
+ datasetMode + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebappDaoFactorySDB(WebappDaoFactorySDB base, String userURI) {
|
||||||
super(base.ontModelSelector);
|
super(base.ontModelSelector);
|
||||||
this.ontModelSelector = base.ontModelSelector;
|
this.ontModelSelector = base.ontModelSelector;
|
||||||
this.config = base.config;
|
this.config = base.config;
|
||||||
|
@ -94,6 +100,7 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
return vClassDao = new VClassDaoSDB(dwf, datasetMode, this, config.isUnderlyingStoreReasoned());
|
return vClassDao = new VClassDaoSDB(dwf, datasetMode, this, config.isUnderlyingStoreReasoned());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
|
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
|
||||||
return new WebappDaoFactorySDB(this, userURI);
|
return new WebappDaoFactorySDB(this, userURI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is a class to support Direct Web Remoting(DWR) in
|
This is a class to support Direct Web Remoting(DWR) in
|
||||||
|
|
|
@ -23,11 +23,11 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
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.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
|
||||||
public class EditConfigurationUtils {
|
public class EditConfigurationUtils {
|
||||||
|
@ -215,7 +215,7 @@ public class EditConfigurationUtils {
|
||||||
public static DataPropertyStatement getDataPropertyStatement(VitroRequest vreq, HttpSession session, Integer dataHash, String predicateUri) {
|
public static DataPropertyStatement getDataPropertyStatement(VitroRequest vreq, HttpSession session, Integer dataHash, String predicateUri) {
|
||||||
DataPropertyStatement dps = null;
|
DataPropertyStatement dps = null;
|
||||||
if( dataHash != 0) {
|
if( dataHash != 0) {
|
||||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
||||||
dps = RdfLiteralHash.getPropertyStmtByHash(EditConfigurationUtils.getSubjectUri(vreq), predicateUri, dataHash, model);
|
dps = RdfLiteralHash.getPropertyStmtByHash(EditConfigurationUtils.getSubjectUri(vreq), predicateUri, dataHash, model);
|
||||||
}
|
}
|
||||||
return dps;
|
return dps;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,12 +18,10 @@ import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.QuerySolutionMap;
|
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
||||||
|
@ -32,10 +31,9 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ModelChangePreprocessor;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ModelChangePreprocessor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetter;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils;
|
||||||
|
|
||||||
public class N3EditUtils {
|
public class N3EditUtils {
|
||||||
|
@ -52,7 +50,7 @@ public class N3EditUtils {
|
||||||
|
|
||||||
List<ModelChangePreprocessor> modelChangePreprocessors = editConfiguration.getModelChangePreprocessors();
|
List<ModelChangePreprocessor> modelChangePreprocessors = editConfiguration.getModelChangePreprocessors();
|
||||||
//Check if there is a default set of preprocessors for the whole application
|
//Check if there is a default set of preprocessors for the whole application
|
||||||
List<ModelChangePreprocessor> defaultPreprocessors = getDefaultModelChangePreprocessors(request, ModelAccess.on(request).getDisplayModel());
|
List<ModelChangePreprocessor> defaultPreprocessors = getDefaultModelChangePreprocessors(request, ModelAccess.on(request).getOntModel(DISPLAY));
|
||||||
if(modelChangePreprocessors != null) {
|
if(modelChangePreprocessors != null) {
|
||||||
//if preprocessors exist for the configuration, add default preprocessors to the end
|
//if preprocessors exist for the configuration, add default preprocessors to the end
|
||||||
modelChangePreprocessors.addAll(defaultPreprocessors);
|
modelChangePreprocessors.addAll(defaultPreprocessors);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelMakerID.CONTENT;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -9,8 +9,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public class IdModelSelector implements ModelSelector {
|
public class IdModelSelector implements ModelSelector {
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_UNION;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@ -10,15 +12,14 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
|
||||||
|
|
||||||
public class StandardModelSelector implements ModelSelector {
|
public class StandardModelSelector implements ModelSelector {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(StandardModelSelector.class);
|
private static final Log log = LogFactory.getLog(StandardModelSelector.class);
|
||||||
|
|
||||||
public OntModel getModel(HttpServletRequest request, ServletContext context) {
|
@Override
|
||||||
return ModelAccess.on(request.getSession()).getOntModel(ModelNames.ABOX_UNION);
|
public OntModel getModel(HttpServletRequest request, ServletContext context) {
|
||||||
|
return ModelAccess.on(context).getOntModel(ABOX_UNION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ModelSelector selector = new StandardModelSelector();
|
public static final ModelSelector selector = new StandardModelSelector();
|
||||||
|
|
|
@ -11,11 +11,11 @@ import org.apache.commons.lang.StringUtils;
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
|
||||||
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.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.IdModelSelector;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.IdModelSelector;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.StandardModelSelector;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.StandardModelSelector;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
|
||||||
//setup the model selectors for query, write and display models on editConfig
|
//setup the model selectors for query, write and display models on editConfig
|
||||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||||
|
|
||||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
OntModel queryModel = ModelAccess.on(vreq).getOntModel();
|
||||||
|
|
||||||
if( editConfig.getSubjectUri() == null)
|
if( editConfig.getSubjectUri() == null)
|
||||||
editConfig.setSubjectUri( EditConfigurationUtils.getSubjectUri(vreq));
|
editConfig.setSubjectUri( EditConfigurationUtils.getSubjectUri(vreq));
|
||||||
|
|
|
@ -16,19 +16,18 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
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.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.DefaultAddMissingIndividualFormModelPreprocessor;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.DefaultAddMissingIndividualFormModelPreprocessor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the edit configuration for a default property form.
|
* Generates the edit configuration for a default property form.
|
||||||
|
@ -355,7 +354,7 @@ public class DefaultAddMissingIndividualFormGenerator implements EditConfigurati
|
||||||
|
|
||||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||||
//Here, retrieve model from
|
//Here, retrieve model from
|
||||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
||||||
//if object property
|
//if object property
|
||||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
||||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -22,7 +24,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
|
@ -31,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaObjectPropetyOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaObjectPropetyOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
|
||||||
|
@ -468,7 +470,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
||||||
|
|
||||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||||
//Here, retrieve model from
|
//Here, retrieve model from
|
||||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
||||||
//if object property
|
//if object property
|
||||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
||||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||||
|
@ -499,7 +501,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
||||||
if(isSelectFromExisting(vreq)) {
|
if(isSelectFromExisting(vreq)) {
|
||||||
// set ProhibitedFromSearch object so picklist doesn't show
|
// set ProhibitedFromSearch object so picklist doesn't show
|
||||||
// individuals from classes that should be hidden from list views
|
// individuals from classes that should be hidden from list views
|
||||||
OntModel displayOntModel = ModelAccess.on(session.getServletContext()).getDisplayModel();
|
OntModel displayOntModel = ModelAccess.on(session.getServletContext()).getOntModel(DISPLAY);
|
||||||
ProhibitedFromSearch pfs = new ProhibitedFromSearch(
|
ProhibitedFromSearch pfs = new ProhibitedFromSearch(
|
||||||
DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel);
|
DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel);
|
||||||
if( editConfig != null )
|
if( editConfig != null )
|
||||||
|
|
|
@ -36,7 +36,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
|
@ -46,6 +45,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocesso
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3Utils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3Utils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.menuManagement.MenuManagementDataUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.menuManagement.MenuManagementDataUtils;
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
void prepare(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
void prepare(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
||||||
//setup the model selectors for query, write and display models on editConfig
|
//setup the model selectors for query, write and display models on editConfig
|
||||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
OntModel queryModel = ModelAccess.on(vreq).getOntModel();
|
||||||
if (editConfig.isParamUpdate()) {
|
if (editConfig.isParamUpdate()) {
|
||||||
editConfig.prepareForParamUpdate(queryModel);
|
editConfig.prepareForParamUpdate(queryModel);
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
if (editConfig.isParamUpdate()) {
|
if (editConfig.isParamUpdate()) {
|
||||||
//setup the model selectors for query, write and display models on editConfig
|
//setup the model selectors for query, write and display models on editConfig
|
||||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
OntModel queryModel = ModelAccess.on(vreq).getOntModel();
|
||||||
retrieveExistingDataGetterInfo(context, editConfig, queryModel);
|
retrieveExistingDataGetterInfo(context, editConfig, queryModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ private String getExistingIsSelfContainedTemplateQuery() {
|
||||||
int maxMenuPosition = 0;
|
int maxMenuPosition = 0;
|
||||||
Literal menuPosition = null;
|
Literal menuPosition = null;
|
||||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
OntModel queryModel = ModelAccess.on(vreq).getOntModel();
|
||||||
|
|
||||||
String maxMenuPositionQuery = getMaxMenuPositionQueryString();
|
String maxMenuPositionQuery = getMaxMenuPositionQueryString();
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
|
|
|
@ -17,12 +17,12 @@ import com.hp.hpl.jena.vocabulary.XSD;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
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.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the edit configuration for a default property form.
|
* Generates the edit configuration for a default property form.
|
||||||
|
@ -240,7 +240,7 @@ public class NewIndividualFormGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||||
//Here, retrieve model from
|
//Here, retrieve model from
|
||||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
||||||
//This form is always doing a non-update
|
//This form is always doing a non-update
|
||||||
editConfiguration.prepareForNonUpdate( model );
|
editConfiguration.prepareForNonUpdate( model );
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,18 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.vocabulary.XSD;
|
import com.hp.hpl.jena.vocabulary.XSD;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
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.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
/**
|
/**
|
||||||
* Generates the edit configuration for RDFS Label form.
|
* Generates the edit configuration for RDFS Label form.
|
||||||
*
|
*
|
||||||
|
@ -299,7 +298,7 @@ public class RDFSLabelGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||||
//Here, retrieve model from
|
//Here, retrieve model from
|
||||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
||||||
if( editConfiguration.isDataPropertyUpdate() ){
|
if( editConfiguration.isDataPropertyUpdate() ){
|
||||||
editConfiguration.prepareForDataPropUpdate(model, vreq.getWebappDaoFactory().getDataPropertyDao());
|
editConfiguration.prepareForDataPropUpdate(model, vreq.getWebappDaoFactory().getDataPropertyDao());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,10 @@ import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.SWITCH_TO_D
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_DISPLAY_MODEL_PARAM;
|
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_DISPLAY_MODEL_PARAM;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_MODEL_PARAM;
|
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_MODEL_PARAM;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_TBOX_MODEL_PARAM;
|
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_TBOX_MODEL_PARAM;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService.CONFIGURATION;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONFIGURATION;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService.CONTENT;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY_TBOX;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -25,15 +27,15 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
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.policy.PolicyHelper;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
||||||
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.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.RequestModelAccessImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle model switching, if requested for the editing framework.
|
* Handle model switching, if requested for the editing framework.
|
||||||
|
@ -86,8 +88,8 @@ public class ModelSwitcher {
|
||||||
|
|
||||||
// If they asked for the display model, give it to them.
|
// If they asked for the display model, give it to them.
|
||||||
if (isParameterPresent(vreq, SWITCH_TO_DISPLAY_MODEL)) {
|
if (isParameterPresent(vreq, SWITCH_TO_DISPLAY_MODEL)) {
|
||||||
OntModel mainOntModel = ModelAccess.on(_context).getDisplayModel();
|
OntModel mainOntModel = ModelAccess.on(_context).getOntModel(DISPLAY);
|
||||||
OntModel tboxOntModel = ModelAccess.on(_context).getOntModel(ModelNames.DISPLAY_TBOX);
|
OntModel tboxOntModel = ModelAccess.on(_context).getOntModel(DISPLAY_TBOX);
|
||||||
setSpecialWriteModel(vreq, mainOntModel);
|
setSpecialWriteModel(vreq, mainOntModel);
|
||||||
|
|
||||||
vreq.setAttribute(VitroRequest.ID_FOR_ABOX_MODEL, VitroModelSource.ModelName.DISPLAY.toString());
|
vreq.setAttribute(VitroRequest.ID_FOR_ABOX_MODEL, VitroModelSource.ModelName.DISPLAY.toString());
|
||||||
|
@ -120,8 +122,8 @@ public class ModelSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSpecialWriteModel(VitroRequest vreq, OntModel mainOntModel) {
|
private void setSpecialWriteModel(VitroRequest vreq, OntModel mainOntModel) {
|
||||||
if (mainOntModel != null) {
|
if (mainOntModel != null) {
|
||||||
ModelAccess.on(vreq).setOntModel(ModelNames.FULL_UNION, mainOntModel);
|
((RequestModelAccessImpl) ModelAccess.on(vreq)).setSpecialWriteModel(mainOntModel);
|
||||||
vreq.setAttribute(SPECIAL_WRITE_MODEL, mainOntModel);
|
vreq.setAttribute(SPECIAL_WRITE_MODEL, mainOntModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.PageController;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.PageController;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PageDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.PageDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
/**
|
/**
|
||||||
* This filter is intended to route requests to pages defined in the display model.
|
* This filter is intended to route requests to pages defined in the display model.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,21 +2,14 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.filters;
|
package edu.cornell.mannlib.vitro.webapp.filters;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelMakerID.CONTENT;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.FilterConfig;
|
import javax.servlet.FilterConfig;
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
|
@ -25,67 +18,24 @@ 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 org.apache.jena.atlas.lib.Pair;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||||
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.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.HideFromDisplayByPolicyFilter;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelectorImpl;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelMakerUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringRDFService;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This sets up several objects in the Request scope for each incoming HTTP
|
* This used to set up a lot of request-based objects. Now, most of them are
|
||||||
* request. This is done in a Filter so that controllers and JSPs get the same
|
* obtained through ModelAccess, which does not require setup here. However, it
|
||||||
* setup.
|
* does require teardown.
|
||||||
*
|
*
|
||||||
* This code configures the WebappDaoFactory for each request.
|
* This is done in a filter, so it applies to both Servlets and JSPs.
|
||||||
*/
|
*/
|
||||||
public class RequestModelsPrep implements Filter {
|
public class RequestModelsPrep implements Filter {
|
||||||
private final static Log log = LogFactory.getLog(RequestModelsPrep.class);
|
private final static Log log = LogFactory.getLog(RequestModelsPrep.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* The filter will be applied to all incoming urls, this is a list of URI
|
|
||||||
* patterns to skip. These are matched against the requestURI sans query
|
|
||||||
* parameters, e.g. "/vitro/index.jsp" "/vitro/themes/enhanced/css/edit.css"
|
|
||||||
*/
|
|
||||||
private final static Pattern[] skipPatterns = {
|
|
||||||
Pattern.compile(".*\\.(gif|GIF|jpg|jpeg|png|PNG)$"),
|
|
||||||
Pattern.compile(".*\\.css$"), Pattern.compile(".*\\.js$"),
|
|
||||||
Pattern.compile("/.*/themes/.*/site_icons/.*"),
|
|
||||||
Pattern.compile("/.*/images/.*") };
|
|
||||||
|
|
||||||
private ServletContext ctx;
|
|
||||||
private ConfigurationProperties props;
|
|
||||||
private String defaultNamespace;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(FilterConfig fc) throws ServletException {
|
public void init(FilterConfig fc) throws ServletException {
|
||||||
ctx = fc.getServletContext();
|
// Nothing to do
|
||||||
props = ConfigurationProperties.getBean(ctx);
|
|
||||||
defaultNamespace = props.getProperty("Vitro.defaultNamespace");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,251 +51,19 @@ public class RequestModelsPrep implements Filter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thisRequestNeedsModels(req) || modelsAreAlreadySetUp(req)) {
|
try {
|
||||||
|
setCollator(new VitroRequest(req));
|
||||||
filterChain.doFilter(req, resp);
|
filterChain.doFilter(req, resp);
|
||||||
} else {
|
} finally {
|
||||||
RDFService contentRdfService = RDFServiceUtils
|
if (ModelAccess.isPresent(req)) {
|
||||||
.getRDFServiceFactory(ctx, WhichService.CONTENT)
|
ModelAccess.on(req).close();
|
||||||
.getShortTermRDFService();
|
|
||||||
RDFService configurationRdfService = RDFServiceUtils
|
|
||||||
.getRDFServiceFactory(ctx, WhichService.CONFIGURATION)
|
|
||||||
.getShortTermRDFService();
|
|
||||||
try {
|
|
||||||
setUpTheRequestModels(contentRdfService, configurationRdfService, req);
|
|
||||||
filterChain.doFilter(req, resp);
|
|
||||||
tearDownTheRequestModels(req);
|
|
||||||
} finally {
|
|
||||||
contentRdfService.close();
|
|
||||||
configurationRdfService.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean thisRequestNeedsModels(HttpServletRequest req) {
|
|
||||||
String requestURI = req.getRequestURI();
|
|
||||||
for (Pattern skipPattern : skipPatterns) {
|
|
||||||
if (skipPattern.matcher(requestURI).matches()) {
|
|
||||||
log.debug("request matched skipPattern '" + skipPattern
|
|
||||||
+ "', skipping RequestModelsPrep");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean modelsAreAlreadySetUp(HttpServletRequest req) {
|
|
||||||
String attributeName = RequestModelsPrep.class.getName() + "-setup";
|
|
||||||
if (req.getAttribute(attributeName) != null) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
req.setAttribute(attributeName, Boolean.TRUE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpTheRequestModels(RDFService contentRdfService, RDFService configurationRdfService,
|
|
||||||
HttpServletRequest req) {
|
|
||||||
VitroRequest vreq = new VitroRequest(req);
|
|
||||||
|
|
||||||
setRdfServicesAndDatasets(contentRdfService, vreq);
|
|
||||||
|
|
||||||
setRawModels(contentRdfService, configurationRdfService, vreq);
|
|
||||||
|
|
||||||
RDFService rdfService = vreq.getRDFService();
|
|
||||||
|
|
||||||
// We need access to some language-neutral items - either because we
|
|
||||||
// need to see all contents regardless of language, or because we need
|
|
||||||
// to see the blank nodes that are removed during language filtering.
|
|
||||||
vreq.setLanguageNeutralUnionFullModel(ModelAccess.on(vreq).getOntModel(
|
|
||||||
ModelNames.FULL_UNION));
|
|
||||||
vreq.setLanguageNeutralWebappDaoFactory(new WebappDaoFactorySDB(
|
|
||||||
rdfService, createLanguageNeutralOntModelSelector(vreq),
|
|
||||||
createWadfConfig(vreq)));
|
|
||||||
|
|
||||||
wrapModelsWithLanguageAwareness(vreq);
|
|
||||||
|
|
||||||
setCollator(vreq);
|
|
||||||
|
|
||||||
setWebappDaoFactories(vreq, rdfService);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set language-neutral and language-aware versions of the RdfService and
|
|
||||||
* Dataset.
|
|
||||||
*/
|
|
||||||
private void setRdfServicesAndDatasets(RDFService rawRdfService,
|
|
||||||
VitroRequest vreq) {
|
|
||||||
vreq.setUnfilteredRDFService(rawRdfService);
|
|
||||||
vreq.setUnfilteredDataset(new RDFServiceDataset(rawRdfService));
|
|
||||||
|
|
||||||
RDFService rdfService = addLanguageAwareness(vreq, rawRdfService);
|
|
||||||
vreq.setRDFService(rdfService);
|
|
||||||
|
|
||||||
Dataset dataset = new RDFServiceDataset(rdfService);
|
|
||||||
vreq.setDataset(dataset);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setRawModels(RDFService contentRdfService, RDFService configurationRdfService, VitroRequest vreq) {
|
|
||||||
ModelAccess models = ModelAccess.on(vreq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* KLUGE -- VIVO-843
|
|
||||||
*
|
|
||||||
* We happen to know that the short-term configuration models are the
|
|
||||||
* same as the long-term ones. But if we wrap them in OntModels again,
|
|
||||||
* we will lose the everytime sub-models. So for now, just skip that.
|
|
||||||
*/
|
|
||||||
// ModelMaker configMM = ModelMakerUtils.getShortTermModelMaker(ctx,
|
|
||||||
// configurationRdfService, WhichService.CONFIGURATION);
|
|
||||||
// models.setModelMaker(CONFIGURATION, configMM);
|
|
||||||
|
|
||||||
ModelMaker contentMM = ModelMakerUtils.getShortTermModelMaker(ctx,
|
|
||||||
contentRdfService, WhichService.CONTENT);
|
|
||||||
models.setModelMaker(CONTENT, contentMM);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* KLUGE
|
|
||||||
*
|
|
||||||
* The TBOX_ASSERTIONS in the context is wrapped by an OntModel with
|
|
||||||
* sub-models (file-graph models). If we wrap a new OntModel around it,
|
|
||||||
* we will lose those sub-models, so use the OntModel from the context.
|
|
||||||
*
|
|
||||||
* Do we need to do the same with TBOX_INFERENCES and TBOX_UNION? Maybe
|
|
||||||
* not.
|
|
||||||
*
|
|
||||||
* See also the Kluge in ModelAccess.
|
|
||||||
*/
|
|
||||||
useModelFromContext(vreq, ModelNames.TBOX_ASSERTIONS);
|
|
||||||
useModelFromContext(vreq, ModelNames.TBOX_INFERENCES);
|
|
||||||
useModelFromContext(vreq, ModelNames.TBOX_UNION);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void useModelFromContext(VitroRequest vreq, String modelId) {
|
|
||||||
OntModel contextModel = ModelAccess.on(ctx).getOntModel(modelId);
|
|
||||||
ModelAccess.on(vreq).setOntModel(modelId, contextModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an OntModelSelector that will hold the un-language-filtered
|
|
||||||
* models.
|
|
||||||
*/
|
|
||||||
private OntModelSelector createLanguageNeutralOntModelSelector(
|
|
||||||
VitroRequest vreq) {
|
|
||||||
OntModelSelectorImpl oms = new OntModelSelectorImpl();
|
|
||||||
oms.setABoxModel(ModelAccess.on(vreq).getOntModel(ModelNames.ABOX_UNION));
|
|
||||||
oms.setTBoxModel(ModelAccess.on(vreq).getOntModel(ModelNames.TBOX_UNION));
|
|
||||||
oms.setFullModel(ModelAccess.on(vreq).getOntModel(ModelNames.FULL_UNION));
|
|
||||||
oms.setApplicationMetadataModel(ModelAccess.on(vreq).getOntModel(
|
|
||||||
ModelNames.APPLICATION_METADATA));
|
|
||||||
oms.setDisplayModel(ModelAccess.on(vreq).getOntModel(ModelNames.DISPLAY));
|
|
||||||
oms.setUserAccountsModel(ModelAccess.on(vreq).getOntModel(
|
|
||||||
ModelNames.USER_ACCOUNTS));
|
|
||||||
return oms;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void wrapModelsWithLanguageAwareness(VitroRequest vreq) {
|
|
||||||
wrapModelWithLanguageAwareness(vreq, ModelNames.DISPLAY);
|
|
||||||
wrapModelWithLanguageAwareness(vreq, ModelNames.APPLICATION_METADATA);
|
|
||||||
wrapModelWithLanguageAwareness(vreq, ModelNames.TBOX_ASSERTIONS);
|
|
||||||
wrapModelWithLanguageAwareness(vreq, ModelNames.TBOX_UNION);
|
|
||||||
wrapModelWithLanguageAwareness(vreq, ModelNames.FULL_UNION);
|
|
||||||
wrapModelWithLanguageAwareness(vreq, ModelNames.FULL_ASSERTIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void wrapModelWithLanguageAwareness(HttpServletRequest req,
|
|
||||||
String name) {
|
|
||||||
if (isLanguageAwarenessEnabled()) {
|
|
||||||
OntModel unaware = ModelAccess.on(req).getOntModel(name);
|
|
||||||
OntModel aware = LanguageFilteringUtils
|
|
||||||
.wrapOntModelInALanguageFilter(unaware, req);
|
|
||||||
ModelAccess.on(req).setOntModel(name, aware);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setWebappDaoFactories(VitroRequest vreq, RDFService rdfService) {
|
|
||||||
WebappDaoFactoryConfig config = createWadfConfig(vreq);
|
|
||||||
|
|
||||||
WebappDaoFactory unfilteredWadf = new WebappDaoFactorySDB(rdfService,
|
|
||||||
ModelAccess.on(vreq).getUnionOntModelSelector(), config);
|
|
||||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.UNFILTERED_UNION,
|
|
||||||
unfilteredWadf);
|
|
||||||
|
|
||||||
WebappDaoFactory unfilteredAssertionsWadf = new WebappDaoFactorySDB(
|
|
||||||
rdfService, ModelAccess.on(vreq).getBaseOntModelSelector(),
|
|
||||||
config, SDBDatasetMode.ASSERTIONS_ONLY);
|
|
||||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.BASE,
|
|
||||||
unfilteredAssertionsWadf);
|
|
||||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.UNFILTERED_BASE,
|
|
||||||
unfilteredAssertionsWadf);
|
|
||||||
|
|
||||||
WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, ModelAccess
|
|
||||||
.on(vreq).getUnionOntModelSelector(), config);
|
|
||||||
|
|
||||||
// Do model switching and replace the WebappDaoFactory with
|
|
||||||
// a different version if requested by parameters
|
|
||||||
WebappDaoFactory switchedWadf = new ModelSwitcher()
|
|
||||||
.checkForModelSwitching(vreq, wadf);
|
|
||||||
// Switch the language-neutral one also.
|
|
||||||
vreq.setLanguageNeutralWebappDaoFactory(new ModelSwitcher()
|
|
||||||
.checkForModelSwitching(vreq,
|
|
||||||
vreq.getLanguageNeutralWebappDaoFactory()));
|
|
||||||
|
|
||||||
HideFromDisplayByPolicyFilter filter = new HideFromDisplayByPolicyFilter(
|
|
||||||
RequestIdentifiers.getIdBundleForRequest(vreq),
|
|
||||||
ServletPolicyList.getPolicies(ctx));
|
|
||||||
WebappDaoFactoryFiltering filteredWadf = new WebappDaoFactoryFiltering(
|
|
||||||
switchedWadf, filter);
|
|
||||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.UNION, filteredWadf);
|
|
||||||
}
|
|
||||||
|
|
||||||
private WebappDaoFactoryConfig createWadfConfig(HttpServletRequest req) {
|
|
||||||
List<String> langs = getPreferredLanguages(req);
|
|
||||||
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
|
||||||
config.setDefaultNamespace(defaultNamespace);
|
|
||||||
config.setPreferredLanguages(langs);
|
|
||||||
config.setUnderlyingStoreReasoned(isStoreReasoned(req));
|
|
||||||
config.setCustomListViewConfigFileMap(getCustomListViewConfigFileMap(req
|
|
||||||
.getSession().getServletContext()));
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is also used by VitroHttpServlet to retrieve the right
|
|
||||||
* Collator instance for picklist sorting
|
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Enumeration<Locale> getPreferredLocales(HttpServletRequest req) {
|
|
||||||
return req.getLocales();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getPreferredLanguages(HttpServletRequest req) {
|
|
||||||
log.debug("Accept-Language: " + req.getHeader("Accept-Language"));
|
|
||||||
return LanguageFilteringUtils
|
|
||||||
.localesToLanguages(getPreferredLocales(req));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Language awareness is disabled unless they explicitly enable it.
|
|
||||||
*/
|
|
||||||
private Boolean isLanguageAwarenessEnabled() {
|
|
||||||
return Boolean.valueOf(props.getProperty("RDFService.languageFilter",
|
|
||||||
"false"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private RDFService addLanguageAwareness(HttpServletRequest req,
|
|
||||||
RDFService rawRDFService) {
|
|
||||||
List<String> langs = getPreferredLanguages(req);
|
|
||||||
if (isLanguageAwarenessEnabled()) {
|
|
||||||
return new LanguageFilteringRDFService(rawRDFService, langs);
|
|
||||||
} else {
|
|
||||||
return rawRDFService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCollator(VitroRequest vreq) {
|
private void setCollator(VitroRequest vreq) {
|
||||||
Enumeration<Locale> locales = getPreferredLocales(vreq);
|
@SuppressWarnings("unchecked")
|
||||||
|
Enumeration<Locale> locales = vreq.getLocales();
|
||||||
while (locales.hasMoreElements()) {
|
while (locales.hasMoreElements()) {
|
||||||
Locale locale = locales.nextElement();
|
Locale locale = locales.nextElement();
|
||||||
Collator collator = Collator.getInstance(locale);
|
Collator collator = Collator.getInstance(locale);
|
||||||
|
@ -357,28 +75,6 @@ public class RequestModelsPrep implements Filter {
|
||||||
vreq.setCollator(Collator.getInstance());
|
vreq.setCollator(Collator.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStoreReasoned(ServletRequest req) {
|
|
||||||
String isStoreReasoned = ConfigurationProperties.getBean(req)
|
|
||||||
.getProperty("VitroConnection.DataSource.isStoreReasoned",
|
|
||||||
"true");
|
|
||||||
return ("true".equals(isStoreReasoned));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Pair<String, Pair<ObjectProperty, String>>, String> getCustomListViewConfigFileMap(
|
|
||||||
ServletContext ctx) {
|
|
||||||
Map<Pair<String, Pair<ObjectProperty, String>>, String> map = (Map<Pair<String, Pair<ObjectProperty, String>>, String>) ctx
|
|
||||||
.getAttribute("customListViewConfigFileMap");
|
|
||||||
if (map == null) {
|
|
||||||
map = new ConcurrentHashMap<Pair<String, Pair<ObjectProperty, String>>, String>();
|
|
||||||
ctx.setAttribute("customListViewConfigFileMap", map);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tearDownTheRequestModels(HttpServletRequest req) {
|
|
||||||
ModelAccess.on(req).close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
// Nothing to destroy
|
// Nothing to destroy
|
||||||
|
|
|
@ -21,8 +21,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
import freemarker.cache.WebappTemplateLoader;
|
import freemarker.cache.WebappTemplateLoader;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
|
|
@ -16,8 +16,8 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper;
|
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory;
|
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory;
|
||||||
|
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_ASSERTIONS;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_INFERENCES;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_UNION;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.APPLICATION_METADATA;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_INFERENCES;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_UNION;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_INFERENCES;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_UNION;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService.CONTENT;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.adapters.NamedDefaultModelMaker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.adapters.UnionModelsModelMaker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.adapters.UnionModelsModelMaker.UnionSpec;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common functionality among the Content-based ModelMakerFactorys
|
|
||||||
*/
|
|
||||||
public abstract class ContentModelMakerFactory implements ModelMakerFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* These are the small content models that we want to keep in memory.
|
|
||||||
*/
|
|
||||||
protected static final String[] SMALL_CONTENT_MODELS = {
|
|
||||||
APPLICATION_METADATA, TBOX_ASSERTIONS, TBOX_INFERENCES };
|
|
||||||
|
|
||||||
|
|
||||||
private static final UnionSpec[] CONTENT_UNIONS = new UnionSpec[] {
|
|
||||||
UnionSpec.base(ABOX_ASSERTIONS).plus(ABOX_INFERENCES)
|
|
||||||
.yields(ABOX_UNION),
|
|
||||||
UnionSpec.base(TBOX_ASSERTIONS).plus(TBOX_INFERENCES)
|
|
||||||
.yields(TBOX_UNION),
|
|
||||||
UnionSpec.base(ABOX_ASSERTIONS).plus(TBOX_ASSERTIONS)
|
|
||||||
.yields(FULL_ASSERTIONS),
|
|
||||||
UnionSpec.base(ABOX_INFERENCES).plus(TBOX_INFERENCES)
|
|
||||||
.yields(FULL_INFERENCES) };
|
|
||||||
|
|
||||||
private static final String CONTENT_DEFAULT_MODEL_NAME = FULL_UNION;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* These decorations are added to a Content ModelMaker, regardless of the
|
|
||||||
* source.
|
|
||||||
*
|
|
||||||
* Create the union models and full models. Use the default model as the
|
|
||||||
* full union.
|
|
||||||
*/
|
|
||||||
protected ModelMaker addContentDecorators(ModelMaker sourceMM) {
|
|
||||||
ModelMaker unions = new UnionModelsModelMaker(sourceMM, CONTENT_UNIONS);
|
|
||||||
return new NamedDefaultModelMaker(unions, CONTENT_DEFAULT_MODEL_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WhichService whichModelMaker() {
|
|
||||||
return CONTENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data structures on the context have fewer options than those on a request.
|
||||||
|
*
|
||||||
|
* There is no Preferred Language or Policy restrictions if there is no
|
||||||
|
* "current user".
|
||||||
|
*/
|
||||||
|
public interface ContextModelAccess {
|
||||||
|
/** Get the RDFService for the CONTENT. */
|
||||||
|
public RDFService getRDFService();
|
||||||
|
|
||||||
|
/** Get the RDFService for either CONTENT or CONFIGURATION models. */
|
||||||
|
public RDFService getRDFService(WhichService which);
|
||||||
|
|
||||||
|
/** Get the Dataset for the CONTENT models. */
|
||||||
|
public Dataset getDataset();
|
||||||
|
|
||||||
|
/** Get the Dataset for either CONTENT or CONFIGURATION models. */
|
||||||
|
public Dataset getDataset(WhichService which);
|
||||||
|
|
||||||
|
/** Get the ModelMaker for the CONTENT models. */
|
||||||
|
public ModelMaker getModelMaker();
|
||||||
|
|
||||||
|
/** Get the ModelMaker for either CONTENT or CONFIGURATION models. */
|
||||||
|
public ModelMaker getModelMaker(WhichService which);
|
||||||
|
|
||||||
|
/** Get the FULL_UNION OntModel. */
|
||||||
|
public OntModel getOntModel();
|
||||||
|
|
||||||
|
/** Get an OntModel by name. */
|
||||||
|
public OntModel getOntModel(String name);
|
||||||
|
|
||||||
|
/** Get the ASSERTIONS_AND_INFERENCES OntModelSelector. */
|
||||||
|
public OntModelSelector getOntModelSelector();
|
||||||
|
|
||||||
|
/** Get an OntModelSelector based on ASSERTIONS, INFERENCES, or both. */
|
||||||
|
public OntModelSelector getOntModelSelector(ReasoningOption option);
|
||||||
|
|
||||||
|
/** Get the ASSERTIONS_AND_INFERENCES WebappDaoFactory. */
|
||||||
|
public WebappDaoFactory getWebappDaoFactory();
|
||||||
|
|
||||||
|
/** Get a WebappDaoFactory, based on ASSERTIONS, INFERENCES, or both. */
|
||||||
|
public WebappDaoFactory getWebappDaoFactory(ReasoningOption option);
|
||||||
|
}
|
|
@ -0,0 +1,198 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.ContextModelAccessImpl;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.RequestModelAccessImpl;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.servlet.setup.rdfsetup.DataStructuresProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root access point for the RDF data structures: RDFServices, Datasets,
|
||||||
|
* ModelMakers, OntModels, OntModelSelectors and WebappDaoFactories.
|
||||||
|
*
|
||||||
|
* Get a long-term data structure by accessing from the context. Get a
|
||||||
|
* short-term data structure by accessing from the request.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* ModelAccess.on(ctx).getRDFService(CONFIGURATION);
|
||||||
|
* ModelAccess.on(req).getOntModel(ModelNames.DISPLAY);
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* ------------------------------------
|
||||||
|
*
|
||||||
|
* The elaborate structure of options enums allows us to specify method
|
||||||
|
* signatures like this on RequestModelAccess:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* getOntModelSelector(OntModelSelectorOption... options);
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* Which can be invoked in any of these ways:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* ModelAccess.on(req).getOntModelSelector();
|
||||||
|
* ModelAccess.on(req).getOntModelSelector(LANGUAGE_NEUTRAL);
|
||||||
|
* ModelAccess.on(req).getOntModelSelector(INFERENCES_ONLY);
|
||||||
|
* ModelAccess.on(req).getOntModelSelector(ASSERTIONS_ONLY, LANGUAGE_NEUTRAL);
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* The compiler insures that only appropriate options are specified. However, if
|
||||||
|
* conflicting options are supplied, it will only be caught at runtime.
|
||||||
|
*/
|
||||||
|
public class ModelAccess {
|
||||||
|
private static final Log log = LogFactory.getLog(ModelAccess.class);
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// The options enums.
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It may seem complicated, but it allows us to verify options at compile
|
||||||
|
* time, and to provide or omit them in any order in a method call.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ModelAccessOption {
|
||||||
|
boolean isDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface RdfServiceOption extends ModelAccessOption {
|
||||||
|
// Just a marker interface
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface DatasetOption extends ModelAccessOption {
|
||||||
|
// Just a marker interface
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OntModelSelectorOption extends ModelAccessOption {
|
||||||
|
// Just a marker interface
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface WebappDaoFactoryOption extends ModelAccessOption {
|
||||||
|
// Just a marker interface
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
public enum LanguageOption implements RdfServiceOption, DatasetOption,
|
||||||
|
OntModelSelectorOption, WebappDaoFactoryOption {
|
||||||
|
LANGUAGE_NEUTRAL, LANGUAGE_AWARE;
|
||||||
|
@Override
|
||||||
|
public boolean isDefault() {
|
||||||
|
return this == LANGUAGE_AWARE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
public enum ReasoningOption implements OntModelSelectorOption,
|
||||||
|
WebappDaoFactoryOption {
|
||||||
|
ASSERTIONS_ONLY, INFERENCES_ONLY, ASSERTIONS_AND_INFERENCES;
|
||||||
|
@Override
|
||||||
|
public boolean isDefault() {
|
||||||
|
return this == ASSERTIONS_AND_INFERENCES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
public enum PolicyOption implements WebappDaoFactoryOption {
|
||||||
|
POLICY_NEUTRAL, POLICY_AWARE;
|
||||||
|
@Override
|
||||||
|
public boolean isDefault() {
|
||||||
|
return this == POLICY_AWARE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
public enum WhichService implements RdfServiceOption, DatasetOption {
|
||||||
|
CONTENT, CONFIGURATION;
|
||||||
|
@Override
|
||||||
|
public boolean isDefault() {
|
||||||
|
return this == CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the easiest way to specify an option:
|
||||||
|
* ModelAccess.LANGUAGE_NEUTRAL, instead of
|
||||||
|
* ModelAccess.LanguageOption.LANGUAGE_NEUTRAL
|
||||||
|
*/
|
||||||
|
public static final LanguageOption LANGUAGE_NEUTRAL = LanguageOption.LANGUAGE_NEUTRAL;
|
||||||
|
public static final LanguageOption LANGUAGE_AWARE = LanguageOption.LANGUAGE_AWARE;
|
||||||
|
public static final ReasoningOption ASSERTIONS_ONLY = ReasoningOption.ASSERTIONS_ONLY;
|
||||||
|
public static final ReasoningOption INFERENCES_ONLY = ReasoningOption.INFERENCES_ONLY;
|
||||||
|
public static final ReasoningOption ASSERTIONS_AND_INFERENCES = ReasoningOption.ASSERTIONS_AND_INFERENCES;
|
||||||
|
public static final PolicyOption POLICY_NEUTRAL = PolicyOption.POLICY_NEUTRAL;
|
||||||
|
public static final PolicyOption POLICY_AWARE = PolicyOption.POLICY_AWARE;
|
||||||
|
public static final WhichService CONTENT = WhichService.CONTENT;
|
||||||
|
public static final WhichService CONFIGURATION = WhichService.CONFIGURATION;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// The factory
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private static volatile DataStructuresProvider dataStructuresProvider;
|
||||||
|
private static volatile ModelAccessFactory factory = new ModelAccessFactory();
|
||||||
|
|
||||||
|
/** These attributes should only be accessed through this class. */
|
||||||
|
private static final String ATTRIBUTE_NAME = ModelAccess.class.getName();
|
||||||
|
|
||||||
|
public static void setDataStructuresProvider(DataStructuresProvider provider) {
|
||||||
|
if (dataStructuresProvider != null) {
|
||||||
|
log.warn("Assigning DataStructuresProvider " + provider
|
||||||
|
+ ", but was already set to " + dataStructuresProvider);
|
||||||
|
}
|
||||||
|
dataStructuresProvider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RequestModelAccess on(HttpServletRequest req) {
|
||||||
|
Object o = req.getAttribute(ATTRIBUTE_NAME);
|
||||||
|
if (o instanceof RequestModelAccess) {
|
||||||
|
return (RequestModelAccess) o;
|
||||||
|
} else {
|
||||||
|
RequestModelAccess access = factory.buildRequestModelAccess(req);
|
||||||
|
req.setAttribute(ATTRIBUTE_NAME, access);
|
||||||
|
return access;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPresent(HttpServletRequest req) {
|
||||||
|
return (req.getAttribute(ATTRIBUTE_NAME) instanceof RequestModelAccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ContextModelAccess on(ServletContext ctx) {
|
||||||
|
Object o = ctx.getAttribute(ATTRIBUTE_NAME);
|
||||||
|
if (o instanceof ContextModelAccess) {
|
||||||
|
return (ContextModelAccess) o;
|
||||||
|
} else {
|
||||||
|
ContextModelAccess access = factory.buildContextModelAccess(ctx);
|
||||||
|
ctx.setAttribute(ATTRIBUTE_NAME, access);
|
||||||
|
return access;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// A factory to create the instances, so we can override in unit tests.
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
public static class ModelAccessFactory {
|
||||||
|
public ContextModelAccess buildContextModelAccess(ServletContext ctx) {
|
||||||
|
return new ContextModelAccessImpl(ctx, dataStructuresProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note that the RequestModelAccess must be closed when the request
|
||||||
|
* closes.
|
||||||
|
*/
|
||||||
|
public RequestModelAccess buildRequestModelAccess(HttpServletRequest req) {
|
||||||
|
return new RequestModelAccessImpl(req,
|
||||||
|
dataStructuresProvider
|
||||||
|
.getShortTermDataStructuresProvider(req));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get model makers for long and short-term use.
|
|
||||||
*/
|
|
||||||
public interface ModelMakerFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a model maker that is suitable for long-term use.
|
|
||||||
*/
|
|
||||||
ModelMaker getModelMaker(RDFService longTermRdfService);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a model maker that should not be left idle for long periods of time.
|
|
||||||
*
|
|
||||||
* Because it is based (at least in part) on a short-term RDFService, it
|
|
||||||
* should not be stored in the context or the session, but should be deleted
|
|
||||||
* at the end of the request.
|
|
||||||
*/
|
|
||||||
ModelMaker getShortTermModelMaker(RDFService shortTermRdfService);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is this factory configured to provide CONTENT models or CONFIGURATION models?
|
|
||||||
*/
|
|
||||||
WhichService whichModelMaker();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService.CONFIGURATION;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService.CONTENT;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils.WhichService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience methods for obtaining the ModelMakerFactories.
|
|
||||||
*/
|
|
||||||
public class ModelMakerUtils {
|
|
||||||
public static final String ATTRIBUTE_BASE = ModelMakerUtils.class.getName();
|
|
||||||
|
|
||||||
public static void setContentModelMakerFactory(ServletContext ctx,
|
|
||||||
ModelMakerFactory mmFactory) {
|
|
||||||
if (ctx == null) {
|
|
||||||
throw new NullPointerException("ctx may not be null.");
|
|
||||||
}
|
|
||||||
if (mmFactory == null) {
|
|
||||||
throw new NullPointerException("mmFactory may not be null.");
|
|
||||||
}
|
|
||||||
if (mmFactory.whichModelMaker() != CONTENT) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"mmFactory must be a CONTENT ModelMakerFactory");
|
|
||||||
}
|
|
||||||
ctx.setAttribute(attributeName(CONTENT), mmFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setConfigurationModelMakerFactory(ServletContext ctx,
|
|
||||||
ModelMakerFactory mmFactory) {
|
|
||||||
if (ctx == null) {
|
|
||||||
throw new NullPointerException("ctx may not be null.");
|
|
||||||
}
|
|
||||||
if (mmFactory == null) {
|
|
||||||
throw new NullPointerException("mmFactory may not be null.");
|
|
||||||
}
|
|
||||||
if (mmFactory.whichModelMaker() != CONFIGURATION) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"mmFactory must be a CONFIGURATION ModelMakerFactory");
|
|
||||||
}
|
|
||||||
ctx.setAttribute(attributeName(CONFIGURATION), mmFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModelMaker getModelMaker(ServletContext ctx,
|
|
||||||
WhichService which) {
|
|
||||||
if (ctx == null) {
|
|
||||||
throw new NullPointerException("ctx may not be null.");
|
|
||||||
}
|
|
||||||
if (which == null) {
|
|
||||||
throw new NullPointerException("which may not be null.");
|
|
||||||
}
|
|
||||||
return getFactory(ctx, which).getModelMaker(
|
|
||||||
RDFServiceUtils.getRDFServiceFactory(ctx)
|
|
||||||
.getShortTermRDFService());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModelMaker getShortTermModelMaker(ServletContext ctx,
|
|
||||||
RDFService shortTermRdfService, WhichService which) {
|
|
||||||
if (ctx == null) {
|
|
||||||
throw new NullPointerException("ctx may not be null.");
|
|
||||||
}
|
|
||||||
if (shortTermRdfService == null) {
|
|
||||||
throw new NullPointerException(
|
|
||||||
"shortTermRdfService may not be null.");
|
|
||||||
}
|
|
||||||
if (which == null) {
|
|
||||||
throw new NullPointerException("which may not be null.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return getFactory(ctx, which).getShortTermModelMaker(
|
|
||||||
shortTermRdfService);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ModelMakerFactory getFactory(ServletContext ctx,
|
|
||||||
WhichService which) {
|
|
||||||
Object attribute = ctx.getAttribute(attributeName(which));
|
|
||||||
if (attribute instanceof ModelMakerFactory) {
|
|
||||||
return (ModelMakerFactory) attribute;
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Expected a ModelMakerFactory at '"
|
|
||||||
+ attributeName(which) + "', but found " + attribute);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String attributeName(WhichService which) {
|
|
||||||
return ATTRIBUTE_BASE + "-" + which;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No need for an instance - all methods are static.
|
|
||||||
*/
|
|
||||||
private ModelMakerUtils() {
|
|
||||||
// Nothing to instantiate.
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A central place to record the URIs of the models that we rely on.
|
* A central place to record the URIs of the models that we rely on.
|
||||||
*/
|
*/
|
||||||
|
@ -9,18 +13,44 @@ public class ModelNames {
|
||||||
public static final String ABOX_ASSERTIONS = "http://vitro.mannlib.cornell.edu/default/vitro-kb-2";
|
public static final String ABOX_ASSERTIONS = "http://vitro.mannlib.cornell.edu/default/vitro-kb-2";
|
||||||
public static final String ABOX_INFERENCES = "http://vitro.mannlib.cornell.edu/default/vitro-kb-inf";
|
public static final String ABOX_INFERENCES = "http://vitro.mannlib.cornell.edu/default/vitro-kb-inf";
|
||||||
public static final String ABOX_UNION = "vitro:aboxOntModel";
|
public static final String ABOX_UNION = "vitro:aboxOntModel";
|
||||||
|
|
||||||
public static final String TBOX_ASSERTIONS = "http://vitro.mannlib.cornell.edu/default/asserted-tbox";
|
public static final String TBOX_ASSERTIONS = "http://vitro.mannlib.cornell.edu/default/asserted-tbox";
|
||||||
public static final String TBOX_INFERENCES = "http://vitro.mannlib.cornell.edu/default/inferred-tbox";
|
public static final String TBOX_INFERENCES = "http://vitro.mannlib.cornell.edu/default/inferred-tbox";
|
||||||
public static final String TBOX_UNION = "vitro:tboxOntModel";
|
public static final String TBOX_UNION = "vitro:tboxOntModel";
|
||||||
|
|
||||||
public static final String FULL_ASSERTIONS = "vitro:baseOntModel";
|
public static final String FULL_ASSERTIONS = "vitro:baseOntModel";
|
||||||
public static final String FULL_INFERENCES = "vitro:inferenceOntModel";
|
public static final String FULL_INFERENCES = "vitro:inferenceOntModel";
|
||||||
public static final String FULL_UNION = "vitro:jenaOntModel";
|
public static final String FULL_UNION = "vitro:jenaOntModel";
|
||||||
|
|
||||||
public static final String APPLICATION_METADATA = "http://vitro.mannlib.cornell.edu/default/vitro-kb-applicationMetadata";
|
public static final String APPLICATION_METADATA = "http://vitro.mannlib.cornell.edu/default/vitro-kb-applicationMetadata";
|
||||||
public static final String USER_ACCOUNTS = "http://vitro.mannlib.cornell.edu/default/vitro-kb-userAccounts";
|
public static final String USER_ACCOUNTS = "http://vitro.mannlib.cornell.edu/default/vitro-kb-userAccounts";
|
||||||
public static final String DISPLAY = "http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadata";
|
public static final String DISPLAY = "http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadata";
|
||||||
public static final String DISPLAY_TBOX = "http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadataTBOX";
|
public static final String DISPLAY_TBOX = "http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadataTBOX";
|
||||||
public static final String DISPLAY_DISPLAY = "http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadata-displayModel";
|
public static final String DISPLAY_DISPLAY = "http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadata-displayModel";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of the URIS, keyed by their short names, intended only for display
|
||||||
|
* purposes.
|
||||||
|
*/
|
||||||
|
public static final Map<String, String> namesMap = populateNamesMap();
|
||||||
|
|
||||||
|
private static Map<String, String> populateNamesMap() {
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("ABOX_ASSERTIONS", ABOX_ASSERTIONS);
|
||||||
|
map.put("ABOX_INFERENCES", ABOX_INFERENCES);
|
||||||
|
map.put("ABOX_UNION", ABOX_UNION);
|
||||||
|
map.put("TBOX_ASSERTIONS", TBOX_ASSERTIONS);
|
||||||
|
map.put("TBOX_INFERENCES", TBOX_INFERENCES);
|
||||||
|
map.put("TBOX_UNION", TBOX_UNION);
|
||||||
|
map.put("FULL_ASSERTIONS", FULL_ASSERTIONS);
|
||||||
|
map.put("FULL_INFERENCES", FULL_INFERENCES);
|
||||||
|
map.put("FULL_UNION", FULL_UNION);
|
||||||
|
map.put("APPLICATION_METADATA", APPLICATION_METADATA);
|
||||||
|
map.put("USER_ACCOUNTS", USER_ACCOUNTS);
|
||||||
|
map.put("DISPLAY", DISPLAY);
|
||||||
|
map.put("DISPLAY_TBOX", DISPLAY_TBOX);
|
||||||
|
map.put("DISPLAY_DISPLAY", DISPLAY_DISPLAY);
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.DatasetOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.OntModelSelectorOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.RdfServiceOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WebappDaoFactoryOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data structure on a request have additional options, depending on the
|
||||||
|
* identity and preferences of the user.
|
||||||
|
*/
|
||||||
|
public interface RequestModelAccess {
|
||||||
|
/**
|
||||||
|
* Get an RDFService: CONTENT or CONFIGURATION, Language-aware or not.
|
||||||
|
*/
|
||||||
|
RDFService getRDFService(RdfServiceOption... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Dataset: CONTENT or CONFIGURATION, Language-aware or not.
|
||||||
|
*/
|
||||||
|
Dataset getDataset(DatasetOption... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the FULL_UNION OntModel: Language-aware or not.
|
||||||
|
*/
|
||||||
|
OntModel getOntModel(LanguageOption... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an OntModel: Language-aware or not.
|
||||||
|
*/
|
||||||
|
OntModel getOntModel(String name, LanguageOption... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an OntModelSelector: Language-aware or not, ASSERTIONS or INFERENCES or both.
|
||||||
|
*/
|
||||||
|
OntModelSelector getOntModelSelector(OntModelSelectorOption... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a WebappDaoFactory: Filtered or not, Language-aware or not,
|
||||||
|
* ASSERTIONS or INFERENCES or both.
|
||||||
|
*/
|
||||||
|
WebappDaoFactory getWebappDaoFactory(WebappDaoFactoryOption... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When finished, release any resources.
|
||||||
|
*/
|
||||||
|
void close();
|
||||||
|
}
|
|
@ -21,6 +21,11 @@ public class AbstractModelMakerDecorator implements ModelMaker {
|
||||||
}
|
}
|
||||||
this.inner = inner;
|
this.inner = inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public String toString() {
|
||||||
|
return this.getClass().getSimpleName() + "[inner="
|
||||||
|
+ String.valueOf(inner) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model createDefaultModel() {
|
public Model createDefaultModel() {
|
||||||
|
|
|
@ -10,8 +10,7 @@ import com.hp.hpl.jena.rdf.model.ModelMaker;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelReader;
|
import com.hp.hpl.jena.rdf.model.ModelReader;
|
||||||
import com.hp.hpl.jena.shared.AlreadyExistsException;
|
import com.hp.hpl.jena.shared.AlreadyExistsException;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.MemoryMappedModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.VitroModelFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides fast read access to small models, by creating a "mapped" model in
|
* Provides fast read access to small models, by creating a "mapped" model in
|
||||||
|
@ -34,11 +33,7 @@ public class MemoryMappingModelMaker extends AbstractModelMakerDecorator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model createMemoryMapping(String name) {
|
private Model createMemoryMapping(String name) {
|
||||||
Model externalModel = super.openModel(name);
|
return new MemoryMappedModel(super.openModel(name), name);
|
||||||
Model memoryModel = VitroModelFactory.createModel();
|
|
||||||
memoryModel.add(externalModel);
|
|
||||||
memoryModel.register(new ModelSynchronizer(externalModel, name));
|
|
||||||
return memoryModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMapped(String name) {
|
private boolean isMapped(String name) {
|
||||||
|
|
|
@ -1,140 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.modelaccess.adapters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.graph.GraphMaker;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelReader;
|
|
||||||
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
|
||||||
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow some models in the "shadowing" ModelMaker to hide the corresponding
|
|
||||||
* models in the "shadowed" ModelMaker.
|
|
||||||
*
|
|
||||||
* Specify both ModelMakers, and the list of URIs for the shadowing models.
|
|
||||||
*/
|
|
||||||
public class ShadowingModelMaker extends AbstractModelMakerDecorator {
|
|
||||||
private final ModelMaker shadowing;
|
|
||||||
private final Set<String> shadowUris;
|
|
||||||
|
|
||||||
public ShadowingModelMaker(ModelMaker shadowed, ModelMaker shadowing,
|
|
||||||
String... shadowUris) {
|
|
||||||
super(shadowed);
|
|
||||||
this.shadowing = shadowing;
|
|
||||||
this.shadowUris = new HashSet<>(Arrays.asList(shadowUris));
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isShadow(String name) {
|
|
||||||
return shadowUris.contains(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model createDefaultModel() {
|
|
||||||
return super.createDefaultModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model createFreshModel() {
|
|
||||||
return super.createFreshModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model openModel(String name) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.openModel(name);
|
|
||||||
} else {
|
|
||||||
return super.openModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model openModelIfPresent(String name) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.openModelIfPresent(name);
|
|
||||||
} else {
|
|
||||||
return super.openModelIfPresent(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getModel(String name) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.getModel(name);
|
|
||||||
} else {
|
|
||||||
return super.getModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getModel(String name, ModelReader loadIfAbsent) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.getModel(name, loadIfAbsent);
|
|
||||||
} else {
|
|
||||||
return super.getModel(name, loadIfAbsent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model createModel(String name, boolean strict) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.createModel(name, strict);
|
|
||||||
} else {
|
|
||||||
return super.createModel(name, strict);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model createModel(String name) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.createModel(name);
|
|
||||||
} else {
|
|
||||||
return super.createModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model openModel(String name, boolean strict) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.openModel(name, strict);
|
|
||||||
} else {
|
|
||||||
return super.openModel(name, strict);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeModel(String name) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
shadowing.removeModel(name);
|
|
||||||
} else {
|
|
||||||
super.removeModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasModel(String name) {
|
|
||||||
if (isShadow(name)) {
|
|
||||||
return shadowing.hasModel(name);
|
|
||||||
} else {
|
|
||||||
return super.hasModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
shadowing.close();
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExtendedIterator<String> listModels() {
|
|
||||||
Set<String> allNames = super.listModels().toSet();
|
|
||||||
allNames.addAll(shadowUris);
|
|
||||||
return WrappedIterator.create(allNames.iterator());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,249 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.modelaccess.adapters;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelReader;
|
|
||||||
import com.hp.hpl.jena.shared.AlreadyExistsException;
|
|
||||||
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.VitroModelFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This ModelMaker decorator creates one or more "union models" over the models
|
|
||||||
* provided to it by the inner ModelMaker.
|
|
||||||
*
|
|
||||||
* Each union model contains all of the triples of both its base model and its
|
|
||||||
* "plus" model. Any changes to the union model are delegated to the base model.
|
|
||||||
* If changes are desired in the "plus" model, it must be accessed directly.
|
|
||||||
*
|
|
||||||
* This can create surprises, since the union model will claim to have a given
|
|
||||||
* statement that is part of the plus model, but an attempt to delete that
|
|
||||||
* statement from the union model has no effect.
|
|
||||||
*/
|
|
||||||
public class UnionModelsModelMaker extends AbstractModelMakerDecorator {
|
|
||||||
private final Map<String, UnionSpec> unionModelsMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create it like this:
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* new UnionModelsModelMaker(inner,
|
|
||||||
* UnionSpec.base("baseUri").plus("plusUri").yields("unionUri"),
|
|
||||||
* ...);
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public UnionModelsModelMaker(ModelMaker inner, UnionSpec... unionModelSpecs) {
|
|
||||||
super(inner);
|
|
||||||
|
|
||||||
this.unionModelsMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (UnionSpec spec : unionModelSpecs) {
|
|
||||||
String unionUri = spec.getUnionUri();
|
|
||||||
if (unionModelsMap.containsKey(unionUri)) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Two UnionSpecs may not have the same union URI: "
|
|
||||||
+ spec + ", " + unionModelsMap.get(unionUri));
|
|
||||||
}
|
|
||||||
this.unionModelsMap.put(unionUri, spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (UnionSpec spec1 : unionModelsMap.values()) {
|
|
||||||
if (unionModelsMap.containsKey(spec1.getBaseUri())
|
|
||||||
|| unionModelsMap.containsKey(spec1.getPlusUri())) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"A UnionSpec may not build on another UnionSpec: "
|
|
||||||
+ spec1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasUnionModel(String name) {
|
|
||||||
return unionModelsMap.containsKey(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The union models use lazy initialization, so there is no overhead if the
|
|
||||||
* model is never requested.
|
|
||||||
*/
|
|
||||||
private Model getUnionModel(String name) {
|
|
||||||
UnionSpec spec = unionModelsMap.get(name);
|
|
||||||
synchronized (spec) {
|
|
||||||
if (spec.getUnionModel() == null) {
|
|
||||||
Model baseModel = super.openModel(spec.getBaseUri());
|
|
||||||
Model plusModel = super.openModel(spec.getPlusUri());
|
|
||||||
spec.setUnionModel(VitroModelFactory.createUnion(baseModel,
|
|
||||||
plusModel));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return spec.getUnionModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Overridden methods.
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model createModel(String name) {
|
|
||||||
return createModel(name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model createModel(String name, boolean strict) {
|
|
||||||
if (hasUnionModel(name)) {
|
|
||||||
if (strict) {
|
|
||||||
throw new AlreadyExistsException(name);
|
|
||||||
} else {
|
|
||||||
return getUnionModel(name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return super.createModel(name, strict);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model openModel(String name, boolean strict) {
|
|
||||||
if (hasUnionModel(name)) {
|
|
||||||
return getUnionModel(name);
|
|
||||||
} else {
|
|
||||||
return super.openModel(name, strict);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model openModel(String name) {
|
|
||||||
if (hasUnionModel(name)) {
|
|
||||||
return getUnionModel(name);
|
|
||||||
} else {
|
|
||||||
return super.openModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model openModelIfPresent(String name) {
|
|
||||||
if (hasUnionModel(name)) {
|
|
||||||
return getUnionModel(name);
|
|
||||||
} else {
|
|
||||||
return super.openModelIfPresent(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasModel(String name) {
|
|
||||||
if (hasUnionModel(name)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return super.hasModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExtendedIterator<String> listModels() {
|
|
||||||
return super.listModels().andThen(unionModelsMap
|
|
||||||
.keySet().iterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeModel(String name) {
|
|
||||||
if (hasUnionModel(name)) {
|
|
||||||
unionModelsMap.remove(name);
|
|
||||||
} else {
|
|
||||||
super.removeModel(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getModel(String URL) {
|
|
||||||
if (hasUnionModel(URL)) {
|
|
||||||
return getUnionModel(URL);
|
|
||||||
} else {
|
|
||||||
return super.getModel(URL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getModel(String URL, ModelReader loadIfAbsent) {
|
|
||||||
if (hasUnionModel(URL)) {
|
|
||||||
return getUnionModel(URL);
|
|
||||||
} else {
|
|
||||||
return super.getModel(URL, loadIfAbsent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// UnionSpec and builder classes.
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public static class UnionSpec {
|
|
||||||
public static UnionSpecBase base(String baseUri) {
|
|
||||||
return new UnionSpecBase(baseUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String baseUri;
|
|
||||||
private final String plusUri;
|
|
||||||
private final String unionUri;
|
|
||||||
private Model unionModel;
|
|
||||||
|
|
||||||
public UnionSpec(String baseUri, String plusUri, String unionUri) {
|
|
||||||
this.baseUri = baseUri;
|
|
||||||
this.plusUri = plusUri;
|
|
||||||
this.unionUri = unionUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getUnionModel() {
|
|
||||||
return unionModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnionModel(Model unionModel) {
|
|
||||||
this.unionModel = unionModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBaseUri() {
|
|
||||||
return baseUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPlusUri() {
|
|
||||||
return plusUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUnionUri() {
|
|
||||||
return unionUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "UnionSpec[baseUri=" + baseUri + ", plusUri=" + plusUri
|
|
||||||
+ ", unionUri=" + unionUri + "]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class UnionSpecBase {
|
|
||||||
private final String baseUri;
|
|
||||||
|
|
||||||
UnionSpecBase(String baseUri) {
|
|
||||||
this.baseUri = baseUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnionSpecPair plus(String plusUri) {
|
|
||||||
return new UnionSpecPair(baseUri, plusUri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class UnionSpecPair {
|
|
||||||
private final String baseUri;
|
|
||||||
private final String plusUri;
|
|
||||||
|
|
||||||
public UnionSpecPair(String baseUri, String plusUri) {
|
|
||||||
this.baseUri = baseUri;
|
|
||||||
this.plusUri = plusUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnionSpec yields(String unionUri) {
|
|
||||||
return new UnionSpec(baseUri, plusUri, unionUri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,279 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption.ASSERTIONS_AND_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption.ASSERTIONS_ONLY;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption.INFERENCES_ONLY;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONFIGURATION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_UNION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.APPLICATION_METADATA;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_UNION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_UNION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.USER_ACCOUNTS;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelectorImpl;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels.OntModelCache;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.servlet.setup.rdfsetup.DataStructuresProvider;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The context-based model access is simpler than the request-based model
|
||||||
|
* access.
|
||||||
|
*
|
||||||
|
* There is no "current user", so there can be no preferred language or
|
||||||
|
* policy-based filtering.
|
||||||
|
*
|
||||||
|
* We are confident that each of these structures will be used at some point, so
|
||||||
|
* there is no need for lazy initialization.
|
||||||
|
*/
|
||||||
|
public class ContextModelAccessImpl implements ContextModelAccess {
|
||||||
|
private static final Log log = LogFactory
|
||||||
|
.getLog(ContextModelAccessImpl.class);
|
||||||
|
|
||||||
|
private static final String VITRO_DEFAULT_NAMESPACE = "Vitro.defaultNamespace";
|
||||||
|
|
||||||
|
private final ConfigurationProperties props;
|
||||||
|
|
||||||
|
private final DataStructuresProvider factory;
|
||||||
|
|
||||||
|
private final Map<WhichService, RDFService> rdfServiceMap;
|
||||||
|
private final Map<WhichService, Dataset> datasetMap;
|
||||||
|
private final Map<WhichService, ModelMaker> modelMakerMap;
|
||||||
|
private final OntModelCache ontModelCache;
|
||||||
|
private final Map<ReasoningOption, OntModelSelector> omsMap;
|
||||||
|
private final Map<ReasoningOption, WebappDaoFactory> wadfMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pull all of the items into maps, instead of fetching them from the
|
||||||
|
* factory on demand. We don't know that the factory wouldn't create fresh
|
||||||
|
* ones.
|
||||||
|
*
|
||||||
|
* The exception is the OntModels, for two reasons: first, because the
|
||||||
|
* OntModelCache assures us that it won't create fresh copies, and second
|
||||||
|
* because we may not know the names of all of the models that will be
|
||||||
|
* requested.
|
||||||
|
*/
|
||||||
|
public ContextModelAccessImpl(ServletContext ctx,
|
||||||
|
DataStructuresProvider factory) {
|
||||||
|
this.props = ConfigurationProperties.getBean(ctx);
|
||||||
|
this.factory = factory;
|
||||||
|
|
||||||
|
this.ontModelCache = factory.getOntModelCache();
|
||||||
|
this.rdfServiceMap = populateRdfServiceMap();
|
||||||
|
this.datasetMap = populateDatasetMap();
|
||||||
|
this.modelMakerMap = populateModelMakerMap();
|
||||||
|
this.omsMap = populateOmsMap();
|
||||||
|
this.wadfMap = populateWadfMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ContextModelAccessImpl[" + ToString.hashHex(this)
|
||||||
|
+ ", factory=" + factory + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// RDFServices
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private Map<WhichService, RDFService> populateRdfServiceMap() {
|
||||||
|
Map<WhichService, RDFService> map = new EnumMap<>(WhichService.class);
|
||||||
|
map.put(CONTENT, factory.getRDFService(CONTENT));
|
||||||
|
map.put(CONFIGURATION, factory.getRDFService(CONFIGURATION));
|
||||||
|
log.debug("RdfServiceMap: " + map);
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RDFService getRDFService() {
|
||||||
|
return getRDFService(CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RDFService getRDFService(WhichService which) {
|
||||||
|
RDFService rdfService = rdfServiceMap.get(which);
|
||||||
|
log.debug("getRDFService " + which + ": " + rdfService);
|
||||||
|
return rdfService;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Datasets
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private Map<WhichService, Dataset> populateDatasetMap() {
|
||||||
|
Map<WhichService, Dataset> map = new EnumMap<>(WhichService.class);
|
||||||
|
map.put(CONTENT, factory.getDataset(CONTENT));
|
||||||
|
map.put(CONFIGURATION, factory.getDataset(CONFIGURATION));
|
||||||
|
log.debug("DatasetMap: " + map);
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dataset getDataset() {
|
||||||
|
return getDataset(CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dataset getDataset(WhichService which) {
|
||||||
|
Dataset dataset = datasetMap.get(which);
|
||||||
|
log.debug("getDataset " + which + ": " + dataset);
|
||||||
|
return dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// ModelMakers
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private Map<WhichService, ModelMaker> populateModelMakerMap() {
|
||||||
|
Map<WhichService, ModelMaker> map = new EnumMap<>(WhichService.class);
|
||||||
|
map.put(CONTENT, factory.getModelMaker(CONTENT));
|
||||||
|
map.put(CONFIGURATION, factory.getModelMaker(CONFIGURATION));
|
||||||
|
log.debug("ModelMakerMap: " + map);
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelMaker getModelMaker() {
|
||||||
|
return getModelMaker(CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelMaker getModelMaker(WhichService which) {
|
||||||
|
ModelMaker modelMaker = modelMakerMap.get(which);
|
||||||
|
log.debug("getModelMaker " + which + ": " + modelMaker);
|
||||||
|
return modelMaker;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// OntModels
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModel getOntModel() {
|
||||||
|
return getOntModel(FULL_UNION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModel getOntModel(String name) {
|
||||||
|
OntModel ontModel = ontModelCache.getOntModel(name);
|
||||||
|
log.debug("getOntModel: " + ontModel);
|
||||||
|
return ontModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// OntModelSelectors
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private Map<ReasoningOption, OntModelSelector> populateOmsMap() {
|
||||||
|
Map<ReasoningOption, OntModelSelector> map = new EnumMap<>(
|
||||||
|
ReasoningOption.class);
|
||||||
|
map.put(ASSERTIONS_ONLY,
|
||||||
|
createOntModelSelector(ABOX_ASSERTIONS, TBOX_ASSERTIONS,
|
||||||
|
FULL_ASSERTIONS));
|
||||||
|
map.put(INFERENCES_ONLY,
|
||||||
|
createOntModelSelector(ABOX_INFERENCES, TBOX_INFERENCES,
|
||||||
|
FULL_INFERENCES));
|
||||||
|
map.put(ASSERTIONS_AND_INFERENCES,
|
||||||
|
createOntModelSelector(ABOX_UNION, TBOX_UNION, FULL_UNION));
|
||||||
|
log.debug("OntModelSelectorMap: " + map);
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntModelSelector createOntModelSelector(String aboxName,
|
||||||
|
String tboxName, String fullName) {
|
||||||
|
OntModelSelectorImpl oms = new OntModelSelectorImpl();
|
||||||
|
oms.setABoxModel(getOntModel(aboxName));
|
||||||
|
oms.setTBoxModel(getOntModel(tboxName));
|
||||||
|
oms.setFullModel(getOntModel(fullName));
|
||||||
|
oms.setApplicationMetadataModel(getOntModel(APPLICATION_METADATA));
|
||||||
|
oms.setDisplayModel(getOntModel(DISPLAY));
|
||||||
|
oms.setUserAccountsModel(getOntModel(USER_ACCOUNTS));
|
||||||
|
return oms;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModelSelector getOntModelSelector() {
|
||||||
|
return getOntModelSelector(ASSERTIONS_AND_INFERENCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModelSelector getOntModelSelector(ReasoningOption option) {
|
||||||
|
OntModelSelector ontModelSelector = omsMap.get(option);
|
||||||
|
log.debug("getOntModelSelector: " + ontModelSelector);
|
||||||
|
return ontModelSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// WebappDaoFactories
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private Map<ReasoningOption, WebappDaoFactory> populateWadfMap() {
|
||||||
|
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
||||||
|
config.setDefaultNamespace(getDefaultNamespace());
|
||||||
|
|
||||||
|
RDFService rdfService = getRDFService(CONTENT);
|
||||||
|
|
||||||
|
Map<ReasoningOption, WebappDaoFactory> map = new EnumMap<>(
|
||||||
|
ReasoningOption.class);
|
||||||
|
map.put(ASSERTIONS_ONLY, new WebappDaoFactorySDB(rdfService,
|
||||||
|
getOntModelSelector(ASSERTIONS_ONLY), config,
|
||||||
|
SDBDatasetMode.ASSERTIONS_ONLY));
|
||||||
|
map.put(INFERENCES_ONLY, new WebappDaoFactorySDB(rdfService,
|
||||||
|
getOntModelSelector(INFERENCES_ONLY), config,
|
||||||
|
SDBDatasetMode.INFERENCES_ONLY));
|
||||||
|
map.put(ASSERTIONS_AND_INFERENCES, new WebappDaoFactorySDB(rdfService,
|
||||||
|
getOntModelSelector(ASSERTIONS_AND_INFERENCES), config,
|
||||||
|
SDBDatasetMode.ASSERTIONS_AND_INFERENCES));
|
||||||
|
log.debug("WebappdaoFactoryMap: " + map);
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDefaultNamespace() {
|
||||||
|
return props.getProperty(VITRO_DEFAULT_NAMESPACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebappDaoFactory getWebappDaoFactory() {
|
||||||
|
return getWebappDaoFactory(ASSERTIONS_AND_INFERENCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebappDaoFactory getWebappDaoFactory(ReasoningOption option) {
|
||||||
|
WebappDaoFactory wadf = wadfMap.get(option);
|
||||||
|
log.debug("getWebappDaoFactory: " + wadf);
|
||||||
|
return wadf;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,342 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption.LANGUAGE_AWARE;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption.LANGUAGE_NEUTRAL;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.PolicyOption.POLICY_AWARE;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.APPLICATION_METADATA;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.USER_ACCOUNTS;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.HideFromDisplayByPolicyFilter;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelectorImpl;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.filters.ModelSwitcher;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.DatasetOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.OntModelSelectorOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.RdfServiceOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WebappDaoFactoryOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.RequestModelAccess;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys.DatasetKey;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys.OntModelKey;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys.OntModelSelectorKey;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys.RDFServiceKey;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys.WebappDaoFactoryKey;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringRDFService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.servlet.setup.rdfsetup.ShortTermDataStructuresProvider;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For each category of data structure, the pattern is the same:
|
||||||
|
*
|
||||||
|
* Build a key from the supplied options. If the cache contains a structure with
|
||||||
|
* that key, return it.
|
||||||
|
*
|
||||||
|
* Otherwise, create the requested structure, often from a simplified version.
|
||||||
|
* For example, if the request was for a LANGUAGE_AWARE RDFService, get the
|
||||||
|
* LANGUAGE_NEUTRAL RDFService and wrap it with langauge awareness.
|
||||||
|
*
|
||||||
|
* This second step is a recursive call, so we check again to see if the cache
|
||||||
|
* contains the new requested structure based on a modified key. If it does
|
||||||
|
* contain the structure, use it. Otherwise, create it. Eventually, we reach a
|
||||||
|
* request for the simplest structure, which we fetch from the
|
||||||
|
* ShortTermDataStructuresFactory.
|
||||||
|
*
|
||||||
|
* If the request includes language-awareness, the structure can be created from
|
||||||
|
* the language-neutral version. If language-awareness is disabled, the
|
||||||
|
* language-neutral structure will be cached under two different keys.
|
||||||
|
*
|
||||||
|
* ----------------------------------------
|
||||||
|
*
|
||||||
|
* There are two hacks here to support model switching: one in the OntModels and
|
||||||
|
* one in the WebappDaoFactories. These are hacks for several reasons, not the
|
||||||
|
* least of which is that the model switching will not be available on
|
||||||
|
* WebappDaoFactories based on ASSERTIONS_ONLY or INFERENCES_ONLY, and similarly
|
||||||
|
* for the OntModel.
|
||||||
|
*/
|
||||||
|
public class RequestModelAccessImpl implements RequestModelAccess {
|
||||||
|
private static final Log log = LogFactory
|
||||||
|
.getLog(RequestModelAccessImpl.class);
|
||||||
|
|
||||||
|
private final HttpServletRequest req;
|
||||||
|
private final ServletContext ctx;
|
||||||
|
private final ConfigurationProperties props;
|
||||||
|
private final ShortTermDataStructuresProvider provider;
|
||||||
|
|
||||||
|
public RequestModelAccessImpl(HttpServletRequest req,
|
||||||
|
ShortTermDataStructuresProvider provider) {
|
||||||
|
this.req = req;
|
||||||
|
this.ctx = req.getSession().getServletContext();
|
||||||
|
this.props = ConfigurationProperties.getBean(req);
|
||||||
|
this.provider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language awareness is disabled unless they explicitly enable it.
|
||||||
|
*/
|
||||||
|
private Boolean isLanguageAwarenessEnabled() {
|
||||||
|
return Boolean.valueOf(props.getProperty("RDFService.languageFilter",
|
||||||
|
"false"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getPreferredLanguages() {
|
||||||
|
return LanguageFilteringUtils.localesToLanguages(req.getLocales());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
this.provider.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RequestModelAccessImpl[" + ToString.hashHex(this) + ", req="
|
||||||
|
+ ToString.hashHex(req) + ", provider=" + provider + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// RDFServices
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private final Map<RDFServiceKey, RDFService> rdfServiceMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RDFService getRDFService(RdfServiceOption... options) {
|
||||||
|
return getRDFService(new RDFServiceKey(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
private RDFService getRDFService(RDFServiceKey key) {
|
||||||
|
if (!rdfServiceMap.containsKey(key)) {
|
||||||
|
RDFService rdfService = createRDFService(key);
|
||||||
|
log.debug("Creating: " + key + ", request=" + req.hashCode()
|
||||||
|
+ ", " + rdfService);
|
||||||
|
rdfServiceMap.put(key, rdfService);
|
||||||
|
}
|
||||||
|
RDFService rdfService = rdfServiceMap.get(key);
|
||||||
|
log.debug("getRDFService, " + key + ": " + rdfService);
|
||||||
|
return rdfService;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RDFService createRDFService(RDFServiceKey key) {
|
||||||
|
if (key.getLanguageOption() == LANGUAGE_AWARE) {
|
||||||
|
return addLanguageAwareness(getRDFService(LANGUAGE_NEUTRAL));
|
||||||
|
} else {
|
||||||
|
return provider.getRDFService(key.getWhichService());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RDFService addLanguageAwareness(RDFService unaware) {
|
||||||
|
if (isLanguageAwarenessEnabled()) {
|
||||||
|
return new LanguageFilteringRDFService(unaware,
|
||||||
|
getPreferredLanguages());
|
||||||
|
} else {
|
||||||
|
return unaware;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Datasets
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private final Map<DatasetKey, Dataset> datasetMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dataset getDataset(DatasetOption... options) {
|
||||||
|
return getDataset(new DatasetKey(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dataset getDataset(DatasetKey key) {
|
||||||
|
if (!datasetMap.containsKey(key)) {
|
||||||
|
Dataset dataset = createDataset(key);
|
||||||
|
log.debug("Creating: " + key + ", request=" + req.hashCode()
|
||||||
|
+ ", " + dataset);
|
||||||
|
datasetMap.put(key, dataset);
|
||||||
|
}
|
||||||
|
Dataset dataset = datasetMap.get(key);
|
||||||
|
log.debug("getDataset, " + key + ": " + dataset);
|
||||||
|
return dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dataset createDataset(DatasetKey key) {
|
||||||
|
return new RDFServiceDataset(getRDFService(key.rdfServiceKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// OntModels
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private final Map<OntModelKey, OntModel> ontModelMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModel getOntModel(LanguageOption... options) {
|
||||||
|
return getOntModel(ModelNames.FULL_UNION, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModel getOntModel(String name, LanguageOption... options) {
|
||||||
|
return getOntModel(new OntModelKey(name, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntModel getOntModel(OntModelKey key) {
|
||||||
|
if (!ontModelMap.containsKey(key)) {
|
||||||
|
OntModel ontModel = createOntModel(key);
|
||||||
|
log.debug("Creating: " + key + ", request=" + req.hashCode()
|
||||||
|
+ ", " + ontModel);
|
||||||
|
ontModelMap.put(key, ontModel);
|
||||||
|
}
|
||||||
|
OntModel ontModel = ontModelMap.get(key);
|
||||||
|
log.debug("getOntModel, " + key + ": " + ontModel);
|
||||||
|
return ontModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntModel createOntModel(OntModelKey key) {
|
||||||
|
if (key.getLanguageOption() == LANGUAGE_AWARE) {
|
||||||
|
return addLanguageAwareness(getOntModel(key.getName(),
|
||||||
|
LANGUAGE_NEUTRAL));
|
||||||
|
} else {
|
||||||
|
return provider.getOntModelCache().getOntModel(key.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntModel addLanguageAwareness(OntModel unaware) {
|
||||||
|
if (isLanguageAwarenessEnabled()) {
|
||||||
|
return LanguageFilteringUtils.wrapOntModelInALanguageFilter(
|
||||||
|
unaware, req);
|
||||||
|
} else {
|
||||||
|
return unaware;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Hack for model switching.
|
||||||
|
*/
|
||||||
|
public void setSpecialWriteModel(OntModel mainOntModel) {
|
||||||
|
ontModelMap.put(new OntModelKey(ModelNames.FULL_UNION), mainOntModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// OntModelSelectors
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private final Map<OntModelSelectorKey, OntModelSelector> ontModelSelectorMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModelSelector getOntModelSelector(
|
||||||
|
OntModelSelectorOption... options) {
|
||||||
|
return getOntModelSelector(new OntModelSelectorKey(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntModelSelector getOntModelSelector(OntModelSelectorKey key) {
|
||||||
|
if (!ontModelSelectorMap.containsKey(key)) {
|
||||||
|
OntModelSelector oms = createOntModelSelector(key);
|
||||||
|
log.debug("Creating: " + key + ", request=" + req.hashCode()
|
||||||
|
+ ", " + oms);
|
||||||
|
ontModelSelectorMap.put(key, oms);
|
||||||
|
}
|
||||||
|
OntModelSelector ontModelSelector = ontModelSelectorMap.get(key);
|
||||||
|
log.debug("getOntModelSelector, " + key + ": " + ontModelSelector);
|
||||||
|
return ontModelSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntModelSelector createOntModelSelector(OntModelSelectorKey key) {
|
||||||
|
OntModelSelectorImpl oms = new OntModelSelectorImpl();
|
||||||
|
|
||||||
|
oms.setABoxModel(getOntModel(key.aboxKey()));
|
||||||
|
oms.setTBoxModel(getOntModel(key.tboxKey()));
|
||||||
|
oms.setFullModel(getOntModel(key.fullKey()));
|
||||||
|
|
||||||
|
oms.setApplicationMetadataModel(getOntModel(key
|
||||||
|
.ontModelKey(APPLICATION_METADATA)));
|
||||||
|
oms.setDisplayModel(getOntModel(key.ontModelKey(DISPLAY)));
|
||||||
|
oms.setUserAccountsModel(getOntModel(key.ontModelKey(USER_ACCOUNTS)));
|
||||||
|
|
||||||
|
return oms;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// WebappDaoFactories
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private final Map<WebappDaoFactoryKey, WebappDaoFactory> wadfMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebappDaoFactory getWebappDaoFactory(
|
||||||
|
WebappDaoFactoryOption... options) {
|
||||||
|
return getWebappDaoFactory(new WebappDaoFactoryKey(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
private WebappDaoFactory getWebappDaoFactory(WebappDaoFactoryKey key) {
|
||||||
|
if (!wadfMap.containsKey(key)) {
|
||||||
|
WebappDaoFactory wadf = createWebappDaoFactory(key);
|
||||||
|
log.debug("Creating: " + key + ", request=" + req.hashCode()
|
||||||
|
+ ", " + wadf);
|
||||||
|
wadfMap.put(key, wadf);
|
||||||
|
}
|
||||||
|
WebappDaoFactory wadf = wadfMap.get(key);
|
||||||
|
log.debug("getWebappDaoFactory, " + key + ": " + wadf);
|
||||||
|
return wadf;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WebappDaoFactory createWebappDaoFactory(WebappDaoFactoryKey key) {
|
||||||
|
if (key.getPolicyOption() == POLICY_AWARE) {
|
||||||
|
return addPolicyAwareness(getWebappDaoFactory(key.policyNeutral()));
|
||||||
|
}
|
||||||
|
|
||||||
|
RDFService rdfService = getRDFService(key.rdfServiceKey());
|
||||||
|
OntModelSelector ontModelSelector = getOntModelSelector(key
|
||||||
|
.ontModelSelectorKey());
|
||||||
|
WebappDaoFactoryConfig config = provider.getWebappDaoFactoryConfig();
|
||||||
|
|
||||||
|
switch (key.getReasoningOption()) {
|
||||||
|
case ASSERTIONS_ONLY:
|
||||||
|
return new WebappDaoFactorySDB(rdfService, ontModelSelector,
|
||||||
|
config, SDBDatasetMode.ASSERTIONS_ONLY);
|
||||||
|
case INFERENCES_ONLY:
|
||||||
|
return new WebappDaoFactorySDB(rdfService, ontModelSelector,
|
||||||
|
config, SDBDatasetMode.INFERENCES_ONLY);
|
||||||
|
default: // ASSERTIONS_AND_INFERENCES
|
||||||
|
// TODO Do model switching and replace the WebappDaoFactory with
|
||||||
|
// a different version if requested by parameters
|
||||||
|
WebappDaoFactory unswitched = new WebappDaoFactorySDB(rdfService,
|
||||||
|
ontModelSelector, config);
|
||||||
|
return new ModelSwitcher().checkForModelSwitching(new VitroRequest(
|
||||||
|
req), unswitched);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private WebappDaoFactory addPolicyAwareness(WebappDaoFactory unaware) {
|
||||||
|
HideFromDisplayByPolicyFilter filter = new HideFromDisplayByPolicyFilter(
|
||||||
|
RequestIdentifiers.getIdBundleForRequest(req),
|
||||||
|
ServletPolicyList.getPolicies(ctx));
|
||||||
|
return new WebappDaoFactoryFiltering(unaware, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.DatasetOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable key for storing Dataset objects in the ModelAccess maps.
|
||||||
|
*/
|
||||||
|
public final class DatasetKey extends ModelAccessKey {
|
||||||
|
public DatasetKey(DatasetOption... options) {
|
||||||
|
super(findWhichService(options), findLanguageOption(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WhichService getWhichService() {
|
||||||
|
return super.getWhichService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LanguageOption getLanguageOption() {
|
||||||
|
return super.getLanguageOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How would we access an RDFService that is the basis for the Dataset
|
||||||
|
* accessed by this key?
|
||||||
|
*/
|
||||||
|
public RDFServiceKey rdfServiceKey() {
|
||||||
|
return new RDFServiceKey(getWhichService(), getLanguageOption());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable key that distills a list of LanguageOptions into a single
|
||||||
|
* result.
|
||||||
|
*/
|
||||||
|
public final class LanguageOptionKey extends ModelAccessKey {
|
||||||
|
public LanguageOptionKey(LanguageOption... options) {
|
||||||
|
super(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LanguageOption getLanguageOption() {
|
||||||
|
return super.getLanguageOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ModelAccessOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.PolicyOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable collection of options that can be used as a key in a hashmap.
|
||||||
|
*
|
||||||
|
* The class of the key is part of the hash, so a OntModelKey and a
|
||||||
|
* RDFServiceKey can both be used in the same map without conflict.
|
||||||
|
*/
|
||||||
|
public abstract class ModelAccessKey {
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Static methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
protected static WhichService findWhichService(ModelAccessOption... options) {
|
||||||
|
return findWhichService(Arrays.asList(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static WhichService findWhichService(
|
||||||
|
Iterable<ModelAccessOption> options) {
|
||||||
|
return findOption(options, WhichService.CONTENT, WhichService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static ReasoningOption findReasoningOption(
|
||||||
|
ModelAccessOption... options) {
|
||||||
|
return findReasoningOption(Arrays.asList(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static ReasoningOption findReasoningOption(
|
||||||
|
Iterable<ModelAccessOption> options) {
|
||||||
|
return findOption(options, ReasoningOption.ASSERTIONS_AND_INFERENCES,
|
||||||
|
ReasoningOption.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static LanguageOption findLanguageOption(
|
||||||
|
ModelAccessOption... options) {
|
||||||
|
return findLanguageOption(Arrays.asList(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static LanguageOption findLanguageOption(
|
||||||
|
Iterable<ModelAccessOption> options) {
|
||||||
|
return findOption(options, LanguageOption.LANGUAGE_AWARE,
|
||||||
|
LanguageOption.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static PolicyOption findPolicyOption(ModelAccessOption[] options) {
|
||||||
|
return findPolicyOption(Arrays.asList(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static PolicyOption findPolicyOption(
|
||||||
|
Iterable<ModelAccessOption> options) {
|
||||||
|
return findOption(options, PolicyOption.POLICY_AWARE,
|
||||||
|
PolicyOption.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search through the options for values from the specified class. If none
|
||||||
|
* are found, use the default value.
|
||||||
|
*
|
||||||
|
* Redundant options are silently accepted, but conflicting options will
|
||||||
|
* throw an exception.
|
||||||
|
*/
|
||||||
|
private static <T> T findOption(Iterable<ModelAccessOption> options,
|
||||||
|
T defaultValue, Class<T> clazz) {
|
||||||
|
T found = null;
|
||||||
|
for (ModelAccessOption option : options) {
|
||||||
|
if (found == option) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!clazz.isInstance(option)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (found == null) {
|
||||||
|
found = clazz.cast(option);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Conflicting options: " + found
|
||||||
|
+ " and " + option);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found == null) {
|
||||||
|
return defaultValue;
|
||||||
|
} else {
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// The instance
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
protected final List<ModelAccessOption> keyComponents;
|
||||||
|
private final int hashCode;
|
||||||
|
|
||||||
|
protected ModelAccessKey(ModelAccessOption... options) {
|
||||||
|
this.keyComponents = Collections.unmodifiableList(new ArrayList<>(
|
||||||
|
Arrays.asList(options)));
|
||||||
|
this.hashCode = keyComponents.hashCode() ^ this.getClass().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ReasoningOption getReasoningOption() {
|
||||||
|
return findReasoningOption(keyComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LanguageOption getLanguageOption() {
|
||||||
|
return findLanguageOption(keyComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected WhichService getWhichService() {
|
||||||
|
return findWhichService(keyComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PolicyOption getPolicyOption() {
|
||||||
|
return findPolicyOption(keyComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
} else if (obj == null) {
|
||||||
|
return false;
|
||||||
|
} else if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ModelAccessKey that = (ModelAccessKey) obj;
|
||||||
|
return this.keyComponents.equals(that.keyComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
List<ModelAccessOption> notDefaults = new ArrayList<>();
|
||||||
|
for (ModelAccessOption option : keyComponents) {
|
||||||
|
if (!option.isDefault()) {
|
||||||
|
notDefaults.add(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.getClass().getSimpleName() + notDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable key for storing and retrieving OntModels.
|
||||||
|
*
|
||||||
|
* In addition to the usual options, it has a name, which adds to the
|
||||||
|
* uniqueness.
|
||||||
|
*/
|
||||||
|
public final class OntModelKey extends ModelAccessKey {
|
||||||
|
private final String name;
|
||||||
|
private final int hashCode;
|
||||||
|
|
||||||
|
public OntModelKey(String name, LanguageOption... options) {
|
||||||
|
super(findLanguageOption(options));
|
||||||
|
this.name = name;
|
||||||
|
this.hashCode = super.hashCode() ^ name.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LanguageOption getLanguageOption() {
|
||||||
|
return super.getLanguageOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return super.equals(obj) && ((OntModelKey) obj).name.equals(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " " + ToString.modelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.ABOX_UNION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.FULL_UNION;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_INFERENCES;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_UNION;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.OntModelSelectorOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable key for storing OntModelSelectors in the ModelAccess maps.
|
||||||
|
*/
|
||||||
|
public final class OntModelSelectorKey extends ModelAccessKey {
|
||||||
|
public OntModelSelectorKey(OntModelSelectorOption... options) {
|
||||||
|
super(findLanguageOption(options), findReasoningOption(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LanguageOption getLanguageOption() {
|
||||||
|
return super.getLanguageOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReasoningOption getReasoningOption() {
|
||||||
|
return super.getReasoningOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OntModelKey aboxKey() {
|
||||||
|
switch (getReasoningOption()) {
|
||||||
|
case ASSERTIONS_ONLY:
|
||||||
|
return new OntModelKey(ABOX_ASSERTIONS, getLanguageOption());
|
||||||
|
case INFERENCES_ONLY:
|
||||||
|
return new OntModelKey(ABOX_INFERENCES, getLanguageOption());
|
||||||
|
default: // ASSERTIONS_AND_INFERENCES
|
||||||
|
return new OntModelKey(ABOX_UNION, getLanguageOption());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public OntModelKey tboxKey() {
|
||||||
|
switch (getReasoningOption()) {
|
||||||
|
case ASSERTIONS_ONLY:
|
||||||
|
return new OntModelKey(TBOX_ASSERTIONS, getLanguageOption());
|
||||||
|
case INFERENCES_ONLY:
|
||||||
|
return new OntModelKey(TBOX_INFERENCES, getLanguageOption());
|
||||||
|
default: // ASSERTIONS_AND_INFERENCES
|
||||||
|
return new OntModelKey(TBOX_UNION, getLanguageOption());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public OntModelKey fullKey() {
|
||||||
|
switch (getReasoningOption()) {
|
||||||
|
case ASSERTIONS_ONLY:
|
||||||
|
return new OntModelKey(FULL_ASSERTIONS, getLanguageOption());
|
||||||
|
case INFERENCES_ONLY:
|
||||||
|
return new OntModelKey(FULL_INFERENCES, getLanguageOption());
|
||||||
|
default: // ASSERTIONS_AND_INFERENCES
|
||||||
|
return new OntModelKey(FULL_UNION, getLanguageOption());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get appropriate keys for the DISPLAY, USER_ACCOUNTS, and
|
||||||
|
* APPLICATION_METADATA models.
|
||||||
|
*/
|
||||||
|
public OntModelKey ontModelKey(String name) {
|
||||||
|
return new OntModelKey(name, getLanguageOption());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.RdfServiceOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable key for storing RDFService objects in the ModelAccess maps.
|
||||||
|
*/
|
||||||
|
public final class RDFServiceKey extends ModelAccessKey {
|
||||||
|
public RDFServiceKey(RdfServiceOption... options) {
|
||||||
|
super(findWhichService(options), findLanguageOption(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WhichService getWhichService() {
|
||||||
|
return super.getWhichService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LanguageOption getLanguageOption() {
|
||||||
|
return super.getLanguageOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.impl.keys;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.PolicyOption.POLICY_NEUTRAL;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.PolicyOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WebappDaoFactoryOption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable key for storing RDFService objects in the ModelAccess maps.
|
||||||
|
*/
|
||||||
|
public final class WebappDaoFactoryKey extends ModelAccessKey {
|
||||||
|
public WebappDaoFactoryKey(WebappDaoFactoryOption... options) {
|
||||||
|
super(findLanguageOption(options), findReasoningOption(options),
|
||||||
|
findPolicyOption(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LanguageOption getLanguageOption() {
|
||||||
|
return super.getLanguageOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReasoningOption getReasoningOption() {
|
||||||
|
return super.getReasoningOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyOption getPolicyOption() {
|
||||||
|
return super.getPolicyOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebappDaoFactoryKey policyNeutral() {
|
||||||
|
return new WebappDaoFactoryKey(getLanguageOption(),
|
||||||
|
getReasoningOption(), POLICY_NEUTRAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RDFServiceKey rdfServiceKey() {
|
||||||
|
return new RDFServiceKey(getWhichService(), getLanguageOption());
|
||||||
|
}
|
||||||
|
|
||||||
|
public OntModelSelectorKey ontModelSelectorKey() {
|
||||||
|
return new OntModelSelectorKey(getLanguageOption(),
|
||||||
|
getReasoningOption());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use two OntModelCaches as one.
|
||||||
|
*
|
||||||
|
* If both caches contain models with the same name, a warning will be written
|
||||||
|
* to the log, and the model from the primary cache will be used.
|
||||||
|
*
|
||||||
|
* Any new models will be created on the primary cache.
|
||||||
|
*/
|
||||||
|
public class JoinedOntModelCache implements OntModelCache {
|
||||||
|
private static final Log log = LogFactory.getLog(JoinedOntModelCache.class);
|
||||||
|
|
||||||
|
private final OntModelCache primary;
|
||||||
|
private final OntModelCache secondary;
|
||||||
|
|
||||||
|
public JoinedOntModelCache(OntModelCache primary, OntModelCache secondary) {
|
||||||
|
this.primary = primary;
|
||||||
|
this.secondary = secondary;
|
||||||
|
|
||||||
|
Set<String> duplicateNames = new HashSet<>(primary.getModelNames());
|
||||||
|
duplicateNames.retainAll(secondary.getModelNames());
|
||||||
|
if (!duplicateNames.isEmpty()) {
|
||||||
|
log.warn("These model names appear in both caches: "
|
||||||
|
+ duplicateNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModel getOntModel(String name) {
|
||||||
|
if (primary.getModelNames().contains(name)) {
|
||||||
|
return primary.getOntModel(name);
|
||||||
|
}
|
||||||
|
if (secondary.getModelNames().contains(name)) {
|
||||||
|
return secondary.getOntModel(name);
|
||||||
|
}
|
||||||
|
return primary.getOntModel(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<String> getModelNames() {
|
||||||
|
SortedSet<String> allNames = new TreeSet<>(primary.getModelNames());
|
||||||
|
allNames.addAll(secondary.getModelNames());
|
||||||
|
return allNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JoinedOntModelCache[" + ToString.hashHex(this) + ", primary="
|
||||||
|
+ primary + ", secondary=" + secondary + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The named models in the masking cache will be used in preference to a model
|
||||||
|
* of the same name in the base cache.
|
||||||
|
*
|
||||||
|
* If a named model doesn't exist in the masking cache, a warning is written to
|
||||||
|
* the log and the name will be ignored.
|
||||||
|
*
|
||||||
|
* New models are created in the base cache only.
|
||||||
|
*/
|
||||||
|
public class MaskingOntModelCache implements OntModelCache {
|
||||||
|
private static final Log log = LogFactory
|
||||||
|
.getLog(MaskingOntModelCache.class);
|
||||||
|
|
||||||
|
private final OntModelCache baseCache;
|
||||||
|
private final OntModelCache maskingCache;
|
||||||
|
private final Set<String> maskingNames;
|
||||||
|
|
||||||
|
public MaskingOntModelCache(OntModelCache baseCache,
|
||||||
|
OntModelCache maskingCache, Collection<String> maskingNames) {
|
||||||
|
this.baseCache = baseCache;
|
||||||
|
this.maskingCache = maskingCache;
|
||||||
|
this.maskingNames = new HashSet<>(maskingNames);
|
||||||
|
checkForMissingNamedModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForMissingNamedModels() {
|
||||||
|
Set<String> missingModelNames = new HashSet<>(this.maskingNames);
|
||||||
|
missingModelNames.removeAll(maskingCache.getModelNames());
|
||||||
|
if (!missingModelNames.isEmpty()) {
|
||||||
|
log.warn("Specifed models do not exist in the masking cache: "
|
||||||
|
+ missingModelNames);
|
||||||
|
maskingNames.removeAll(missingModelNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntModel getOntModel(String name) {
|
||||||
|
if (maskingNames.contains(name)) {
|
||||||
|
return maskingCache.getOntModel(name);
|
||||||
|
} else {
|
||||||
|
return baseCache.getOntModel(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The list of names in the baseCache may have changed. */
|
||||||
|
@Override
|
||||||
|
public SortedSet<String> getModelNames() {
|
||||||
|
SortedSet<String> allNames = new TreeSet<>(baseCache.getModelNames());
|
||||||
|
allNames.addAll(maskingNames);
|
||||||
|
return allNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MaskingOntModelCache[" + ToString.hashHex(this)
|
||||||
|
+ ", baseCache=" + baseCache + ", maskingCache=" + maskingCache
|
||||||
|
+ ", maskingNames=" + maskingNames + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue