merged i18n changes in searchPageResults into feature/search-download changes for downloading results and adding counts to facets
This commit is contained in:
commit
16412889b2
216 changed files with 2955 additions and 1882 deletions
|
@ -251,6 +251,11 @@
|
|||
<copyField source="nameRaw" dest="nameText" />
|
||||
<!-- nameLowercaseSingleValued is not copied from nameRaw becasue nameRaw might have multiple values -->
|
||||
|
||||
<!-- field for hash signature, used for comparing to versions from external caches -->
|
||||
<field name="etag" type="string" stored="true" indexed="false" multiValued="false" />
|
||||
|
||||
|
||||
|
||||
<!-- **************************** End Vitro Fields *************************** -->
|
||||
<!-- **************************** Dynamic Fields *************************** -->
|
||||
<dynamicField name="*_string" type="string" indexed="true" stored="true" multiValued="true"/>
|
||||
|
|
|
@ -858,16 +858,12 @@
|
|||
-->
|
||||
<requestHandler name="/update"
|
||||
class="solr.XmlUpdateRequestHandler">
|
||||
<!-- See below for information on defining
|
||||
updateRequestProcessorChains that can be used by name
|
||||
on each Update Request
|
||||
-->
|
||||
<!--
|
||||
<!-- Run the etag processor on each update request. -->
|
||||
<lst name="defaults">
|
||||
<str name="update.processor">dedupe</str>
|
||||
<str name="update.processor">etag</str>
|
||||
</lst>
|
||||
-->
|
||||
</requestHandler>
|
||||
|
||||
<!-- Binary Update Request Handler
|
||||
http://wiki.apache.org/solr/javabin
|
||||
-->
|
||||
|
@ -1480,6 +1476,23 @@
|
|||
</updateRequestProcessorChain>
|
||||
-->
|
||||
|
||||
<!-- ETag generation
|
||||
|
||||
Creates the "etag" field on the fly based on a hash of all other
|
||||
fields.
|
||||
|
||||
-->
|
||||
<updateRequestProcessorChain name="etag">
|
||||
<processor class="solr.processor.SignatureUpdateProcessorFactory">
|
||||
<bool name="enabled">true</bool>
|
||||
<str name="signatureField">etag</str>
|
||||
<bool name="overwriteDupes">false</bool>
|
||||
<str name="signatureClass">solr.processor.Lookup3Signature</str>
|
||||
</processor>
|
||||
<processor class="solr.LogUpdateProcessorFactory" />
|
||||
<processor class="solr.RunUpdateProcessorFactory" />
|
||||
</updateRequestProcessorChain>
|
||||
|
||||
<!-- Response Writers
|
||||
|
||||
http://wiki.apache.org/solr/QueryResponseWriter
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
|
@ -101,13 +102,7 @@ public class LoginStatusBean {
|
|||
}
|
||||
|
||||
ServletContext ctx = session.getServletContext();
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) ctx
|
||||
.getAttribute("webappDaoFactory");
|
||||
if (wadf == null) {
|
||||
log.error("No WebappDaoFactory");
|
||||
return null;
|
||||
}
|
||||
|
||||
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
UserAccountsDao userAccountsDao = wadf.getUserAccountsDao();
|
||||
if (userAccountsDao == null) {
|
||||
log.error("No UserAccountsDao");
|
||||
|
|
|
@ -25,7 +25,9 @@ import edu.cornell.mannlib.vedit.util.FormUtils;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||
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.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
|
||||
public class BaseEditController extends VitroHttpServlet {
|
||||
|
@ -153,39 +155,32 @@ public class BaseEditController extends VitroHttpServlet {
|
|||
}
|
||||
}
|
||||
|
||||
protected String MODEL_ATTR_NAME = "jenaOntModel";
|
||||
|
||||
protected OntModel getOntModel( HttpServletRequest request, ServletContext ctx ) {
|
||||
|
||||
// TODO: JB - This method gets the UNION FULL model from the session, if there is one,
|
||||
// TODO and the BASE_TBOX model otherwise.
|
||||
OntModel ontModel = null;
|
||||
|
||||
try {
|
||||
ontModel = (OntModel) request.getSession().getAttribute(MODEL_ATTR_NAME);
|
||||
ontModel = ModelAccess.on(request.getSession()).getJenaOntModel();
|
||||
} catch (Exception e) {
|
||||
// ignoring any problems here - we're not really expecting
|
||||
// this attribute to be populated anyway
|
||||
}
|
||||
|
||||
if ( ontModel == null ) {
|
||||
ontModel = (OntModel) ModelContext.getBaseOntModelSelector(ctx).getTBoxModel();
|
||||
ontModel = ModelAccess.on(ctx).getOntModel(ModelID.BASE_TBOX);
|
||||
}
|
||||
|
||||
return ontModel;
|
||||
|
||||
}
|
||||
|
||||
protected WebappDaoFactory getWebappDaoFactory(VitroRequest vreq) {
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) getServletContext().getAttribute(
|
||||
"assertionsWebappDaoFactory");
|
||||
if (wadf == null) {
|
||||
log.info("Using vreq.getFullWebappDaoFactory()");
|
||||
wadf = vreq.getFullWebappDaoFactory();
|
||||
}
|
||||
return wadf;
|
||||
protected WebappDaoFactory getWebappDaoFactory() {
|
||||
return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory();
|
||||
}
|
||||
|
||||
protected WebappDaoFactory getWebappDaoFactory(VitroRequest vreq, String userURI) {
|
||||
return getWebappDaoFactory(vreq).getUserAwareDaoFactory(userURI);
|
||||
protected WebappDaoFactory getWebappDaoFactory(String userURI) {
|
||||
return getWebappDaoFactory().getUserAwareDaoFactory(userURI);
|
||||
}
|
||||
|
||||
public String getDefaultLandingPage(HttpServletRequest request) {
|
||||
|
|
|
@ -16,18 +16,19 @@ import org.apache.commons.lang.StringUtils;
|
|||
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.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
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.IdentifierBundle;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
* The current user is blacklisted for this reason.
|
||||
|
@ -152,7 +153,7 @@ public class IsBlacklisted extends AbstractCommonIdentifier implements
|
|||
return NOT_BLACKLISTED;
|
||||
}
|
||||
|
||||
Model model = (Model) context.getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(context).getJenaOntModel();
|
||||
|
||||
queryString = queryString.replaceAll("\\?individualURI",
|
||||
"<" + ind.getURI() + ">");
|
||||
|
|
|
@ -6,6 +6,7 @@ import javax.servlet.ServletContext;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
|
@ -24,16 +25,7 @@ public abstract class BaseIdentifierBundleFactory implements
|
|||
throw new NullPointerException("ctx may not be null.");
|
||||
}
|
||||
this.ctx = ctx;
|
||||
|
||||
Object wdfObject = ctx.getAttribute("webappDaoFactory");
|
||||
if (wdfObject instanceof WebappDaoFactory) {
|
||||
this.wdf = (WebappDaoFactory) wdfObject;
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"Didn't find a WebappDaoFactory in the context. Found '"
|
||||
+ wdfObject + "' instead.");
|
||||
}
|
||||
|
||||
this.wdf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
this.uaDao = wdf.getUserAccountsDao();
|
||||
this.indDao = wdf.getIndividualDao();
|
||||
}
|
||||
|
|
|
@ -114,9 +114,11 @@ public class DisplayByRolePermission extends Permission {
|
|||
ObjectPropertyStatement stmt = action.getObjectPropertyStatement();
|
||||
String subjectUri = stmt.getSubjectURI();
|
||||
String predicateUri = stmt.getPropertyURI();
|
||||
String rangeUri = (stmt.getProperty() == null) ? null
|
||||
: stmt.getProperty().getRangeVClassURI();
|
||||
String objectUri = stmt.getObjectURI();
|
||||
return canDisplayResource(subjectUri)
|
||||
&& canDisplayPredicate(predicateUri)
|
||||
&& canDisplayPredicate(predicateUri, rangeUri)
|
||||
&& canDisplayResource(objectUri);
|
||||
}
|
||||
|
||||
|
@ -126,8 +128,12 @@ public class DisplayByRolePermission extends Permission {
|
|||
}
|
||||
|
||||
private boolean canDisplayPredicate(String predicateUri) {
|
||||
return canDisplayPredicate(predicateUri, null);
|
||||
}
|
||||
|
||||
private boolean canDisplayPredicate(String predicateUri, String rangeUri) {
|
||||
return PropertyRestrictionPolicyHelper.getBean(ctx)
|
||||
.canDisplayPredicate(predicateUri, this.roleLevel);
|
||||
.canDisplayPredicate(predicateUri, rangeUri, this.roleLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,10 +32,10 @@ import com.hp.hpl.jena.vocabulary.RDFS;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
/**
|
||||
|
@ -100,8 +100,7 @@ public class PermissionSetsLoader implements ServletContextListener {
|
|||
this.ctx = ctx;
|
||||
this.ss = ss;
|
||||
|
||||
this.userAccountsModel = ModelContext.getBaseOntModelSelector(ctx)
|
||||
.getUserAccountsModel();
|
||||
this.userAccountsModel = ModelAccess.on(ctx).getUserAccountsModel();
|
||||
this.permissionSetType = this.userAccountsModel
|
||||
.getProperty(VitroVocabulary.PERMISSIONSET);
|
||||
|
||||
|
@ -274,8 +273,7 @@ public class PermissionSetsLoader implements ServletContextListener {
|
|||
this.ctx = ctx;
|
||||
this.ss = ss;
|
||||
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) ctx
|
||||
.getAttribute("webappDaoFactory");
|
||||
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
if (wadf == null) {
|
||||
throw new IllegalStateException(
|
||||
"No webappDaoFactory on the servlet context");
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.auth.policy;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -23,8 +21,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount.Status;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
/**
|
||||
|
@ -79,7 +77,8 @@ public class RootUserPolicy implements PolicyIface {
|
|||
ss = StartupStatus.getBean(ctx);
|
||||
|
||||
try {
|
||||
uaDao = getUserAccountsDao();
|
||||
uaDao = ModelAccess.on(ctx).getWebappDaoFactory()
|
||||
.getUserAccountsDao();
|
||||
configuredRootUser = getRootEmailFromConfig();
|
||||
|
||||
otherRootUsers = getEmailsOfAllRootUsers();
|
||||
|
@ -105,16 +104,6 @@ public class RootUserPolicy implements PolicyIface {
|
|||
}
|
||||
}
|
||||
|
||||
private UserAccountsDao getUserAccountsDao() {
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) ctx
|
||||
.getAttribute("webappDaoFactory");
|
||||
if (wadf == null) {
|
||||
throw new IllegalStateException(
|
||||
"No webappDaoFactory on the servlet context");
|
||||
}
|
||||
return wadf.getUserAccountsDao();
|
||||
}
|
||||
|
||||
private String getRootEmailFromConfig() {
|
||||
String email = ConfigurationProperties.getBean(ctx).getProperty(
|
||||
PROPERTY_ROOT_USER_EMAIL);
|
||||
|
|
|
@ -13,6 +13,7 @@ import edu.cornell.mannlib.vedit.beans.EditProcessObject;
|
|||
import edu.cornell.mannlib.vedit.listener.ChangeListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
* Add this ChangeListener to your EditProcessObject when modifying the
|
||||
|
@ -90,7 +91,7 @@ public class PropertyRestrictionListener implements ChangeListener {
|
|||
}
|
||||
|
||||
private void createAndSetBean() {
|
||||
OntModel model = (OntModel) ctx.getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(ctx).getJenaOntModel();
|
||||
PropertyRestrictionPolicyHelper bean = PropertyRestrictionPolicyHelper
|
||||
.createBean(model);
|
||||
PropertyRestrictionPolicyHelper.setBean(ctx, bean);
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.hp.hpl.jena.rdf.model.impl.Util;
|
|||
import com.hp.hpl.jena.shared.Lock;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
|
@ -257,16 +258,22 @@ public class PropertyRestrictionPolicyHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean canDisplayPredicate(String predicateUri, RoleLevel userRole) {
|
||||
return canDisplayPredicate(predicateUri, null, userRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* If display of a predicate is restricted, the user's role must be at least
|
||||
* as high as the restriction level.
|
||||
*/
|
||||
public boolean canDisplayPredicate(String predicateUri, RoleLevel userRole) {
|
||||
public boolean canDisplayPredicate(String predicateUri, String rangeUri, RoleLevel userRole) {
|
||||
if (predicateUri == null) {
|
||||
log.debug("can't display predicate: predicateUri was null");
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO insert combo logic here
|
||||
|
||||
RoleLevel displayThreshold = displayThresholdMap.get(predicateUri);
|
||||
if (isAuthorized(userRole, displayThreshold)) {
|
||||
log.debug("can display predicate: '" + predicateUri
|
||||
|
@ -344,7 +351,7 @@ public class PropertyRestrictionPolicyHelper {
|
|||
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||
|
||||
try {
|
||||
OntModel model = (OntModel) ctx.getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(ctx).getJenaOntModel();
|
||||
if (model == null) {
|
||||
throw new NullPointerException(
|
||||
"jenaOntModel has not been initialized.");
|
||||
|
|
|
@ -19,12 +19,12 @@ import com.hp.hpl.jena.ontology.OntModel;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
||||
|
||||
|
@ -56,12 +56,10 @@ public abstract class AbstractPageHandler {
|
|||
this.i18n = I18n.bundle(vreq);
|
||||
this.ctx = vreq.getSession().getServletContext();
|
||||
|
||||
OntModelSelector oms = ModelContext.getUnionOntModelSelector(ctx);
|
||||
userAccountsModel = oms.getUserAccountsModel();
|
||||
unionModel = oms.getFullModel();
|
||||
userAccountsModel = ModelAccess.on(ctx).getUserAccountsModel();
|
||||
unionModel = ModelAccess.on(ctx).getOntModel(ModelID.UNION_FULL);
|
||||
|
||||
WebappDaoFactory wdf = (WebappDaoFactory) this.ctx
|
||||
.getAttribute("webappDaoFactory");
|
||||
WebappDaoFactory wdf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
userAccountsDao = wdf.getUserAccountsDao();
|
||||
vclassDao = wdf.getVClassDao();
|
||||
indDao = wdf.getIndividualDao();
|
||||
|
|
|
@ -42,6 +42,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
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.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServletRequest;
|
||||
|
@ -101,7 +102,7 @@ public class FedoraDatastreamController extends VitroHttpServlet implements Cons
|
|||
log.debug("In doGet");
|
||||
|
||||
VitroRequest vreq = new VitroRequest(req);
|
||||
OntModel sessionOntModel = (OntModel)vreq.getSession().getAttribute("jenaOntModel");
|
||||
OntModel sessionOntModel = ModelAccess.on(vreq.getSession()).getJenaOntModel();
|
||||
|
||||
synchronized (FedoraDatastreamController.class) {
|
||||
if( fedoraUrl == null ){
|
||||
|
@ -231,7 +232,7 @@ public class FedoraDatastreamController extends VitroHttpServlet implements Cons
|
|||
}
|
||||
|
||||
//check if fedora is on line
|
||||
OntModel sessionOntModel = (OntModel)rawRequest.getSession().getAttribute("jenaOntModel");
|
||||
OntModel sessionOntModel = ModelAccess.on(rawRequest.getSession()).getJenaOntModel();
|
||||
synchronized (FedoraDatastreamController.class) {
|
||||
if( fedoraUrl == null ){
|
||||
setup( sessionOntModel, getServletContext() );
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.hp.hpl.jena.rdf.model.Resource;
|
|||
import com.hp.hpl.jena.shared.Lock;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaOutputUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.ContentType;
|
||||
|
||||
|
@ -127,12 +128,7 @@ public class OntologyController extends VitroHttpServlet{
|
|||
String url = ontology;
|
||||
|
||||
|
||||
OntModel ontModel = null;
|
||||
HttpSession session = vreq.getSession(false);
|
||||
if( session != null )
|
||||
ontModel =(OntModel)session.getAttribute("jenaOntModel");
|
||||
if( ontModel == null)
|
||||
ontModel = (OntModel)getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel ontModel = ModelAccess.on(vreq.getSession()).getJenaOntModel();
|
||||
|
||||
boolean found = false;
|
||||
Model newModel = ModelFactory.createDefaultModel();
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -17,8 +15,8 @@ import com.hp.hpl.jena.ontology.OntModel;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
|
||||
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.jena.JenaBaseDao;
|
||||
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.rdfservice.RDFService;
|
||||
|
@ -73,13 +71,9 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
|||
setAttribute("unfilteredRDFService", rdfService);
|
||||
}
|
||||
|
||||
public void setWebappDaoFactory( WebappDaoFactory wdf){
|
||||
setAttribute("webappDaoFactory",wdf);
|
||||
}
|
||||
|
||||
/** gets WebappDaoFactory with appropriate filtering for the request */
|
||||
public WebappDaoFactory getWebappDaoFactory(){
|
||||
return (WebappDaoFactory) getAttribute("webappDaoFactory");
|
||||
return ModelAccess.on(this).getWebappDaoFactory();
|
||||
}
|
||||
|
||||
public void setUnfilteredWebappDaoFactory(WebappDaoFactory wdf) {
|
||||
|
@ -94,10 +88,6 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
|||
return (WebappDaoFactory) getAttribute("unfilteredWebappDaoFactory");
|
||||
}
|
||||
|
||||
public void setFullWebappDaoFactory(WebappDaoFactory wdf) {
|
||||
setAttribute("fullWebappDaoFactory", wdf);
|
||||
}
|
||||
|
||||
public Dataset getDataset() {
|
||||
return (Dataset) getAttribute("dataset");
|
||||
}
|
||||
|
@ -106,61 +96,14 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
|||
setAttribute("dataset", dataset);
|
||||
}
|
||||
|
||||
public void setJenaOntModel(OntModel ontModel) {
|
||||
setAttribute("jenaOntModel", ontModel);
|
||||
}
|
||||
|
||||
public void setOntModelSelector(OntModelSelector oms) {
|
||||
setAttribute("ontModelSelector", oms);
|
||||
}
|
||||
|
||||
/** gets assertions + inferences WebappDaoFactory with no filtering **/
|
||||
public WebappDaoFactory getFullWebappDaoFactory() {
|
||||
Object webappDaoFactoryAttr = _req.getAttribute("fullWebappDaoFactory");
|
||||
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
|
||||
return (WebappDaoFactory) webappDaoFactoryAttr;
|
||||
} else {
|
||||
webappDaoFactoryAttr = _req.getSession().getAttribute("webappDaoFactory");
|
||||
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
|
||||
return (WebappDaoFactory) webappDaoFactoryAttr;
|
||||
} else {
|
||||
return (WebappDaoFactory) _req.getSession().getServletContext().getAttribute("webappDaoFactory");
|
||||
}
|
||||
}
|
||||
return ModelAccess.on(this).getWebappDaoFactory();
|
||||
}
|
||||
|
||||
/** gets assertions-only WebappDaoFactory with no filtering */
|
||||
public WebappDaoFactory getAssertionsWebappDaoFactory() {
|
||||
Object webappDaoFactoryAttr = _req.getSession().getAttribute("assertionsWebappDaoFactory");
|
||||
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
|
||||
log.debug("Returning assertionsWebappDaoFactory from session");
|
||||
return (WebappDaoFactory) webappDaoFactoryAttr;
|
||||
} else {
|
||||
webappDaoFactoryAttr = getAttribute("assertionsWebappDaoFactory");
|
||||
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
|
||||
log.debug("returning assertionsWebappDaoFactory from request attribute");
|
||||
return (WebappDaoFactory) webappDaoFactoryAttr;
|
||||
} else {
|
||||
log.debug("Returning assertionsWebappDaoFactory from context");
|
||||
return (WebappDaoFactory) _req.getSession().getServletContext().getAttribute("assertionsWebappDaoFactory");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** gets assertions-only WebappDaoFactory with no filtering */
|
||||
public void setAssertionsWebappDaoFactory(WebappDaoFactory wadf) {
|
||||
setAttribute("assertionsWebappDaoFactory", wadf);
|
||||
}
|
||||
|
||||
/** gets inferences-only WebappDaoFactory with no filtering */
|
||||
public WebappDaoFactory getDeductionsWebappDaoFactory() {
|
||||
Object webappDaoFactoryAttr = _req.getSession().getAttribute("deductionsWebappDaoFactory");
|
||||
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
|
||||
return (WebappDaoFactory) webappDaoFactoryAttr;
|
||||
} else {
|
||||
return (WebappDaoFactory) _req.getSession().getServletContext().getAttribute("deductionsWebappDaoFactory");
|
||||
}
|
||||
return ModelAccess.on(this).getBaseWebappDaoFactory();
|
||||
}
|
||||
|
||||
//Method that retrieves write model, returns special model in case of write model
|
||||
|
@ -173,73 +116,26 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public OntModelSelector getOntModelSelector() {
|
||||
return ModelAccess.on(this).getOntModelSelector();
|
||||
}
|
||||
|
||||
public OntModel getJenaOntModel() {
|
||||
Object ontModel = getAttribute("jenaOntModel");
|
||||
if (ontModel instanceof OntModel) {
|
||||
return (OntModel) ontModel;
|
||||
}
|
||||
OntModel jenaOntModel = (OntModel)_req.getSession().getAttribute( JenaBaseDao.JENA_ONT_MODEL_ATTRIBUTE_NAME );
|
||||
if ( jenaOntModel == null ) {
|
||||
jenaOntModel = (OntModel)_req.getSession().getServletContext().getAttribute( JenaBaseDao.JENA_ONT_MODEL_ATTRIBUTE_NAME );
|
||||
}
|
||||
return jenaOntModel;
|
||||
return ModelAccess.on(this).getJenaOntModel();
|
||||
}
|
||||
|
||||
public OntModelSelector getOntModelSelector() {
|
||||
Object o = this.getAttribute("ontModelSelector");
|
||||
if (o instanceof OntModelSelector) {
|
||||
return (OntModelSelector) o;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** JB - surprising that this comes from session. */
|
||||
public OntModel getAssertionsOntModel() {
|
||||
OntModel jenaOntModel = (OntModel)_req.getSession().getAttribute( JenaBaseDao.ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME );
|
||||
if ( jenaOntModel == null ) {
|
||||
jenaOntModel = (OntModel)_req.getSession().getServletContext().getAttribute( JenaBaseDao.ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME );
|
||||
}
|
||||
return jenaOntModel;
|
||||
return ModelAccess.on(this.getSession()).getBaseOntModel();
|
||||
}
|
||||
|
||||
/** JB - surprising that this comes from session. */
|
||||
public OntModel getInferenceOntModel() {
|
||||
OntModel jenaOntModel = (OntModel)_req.getSession().getAttribute( JenaBaseDao.INFERENCE_ONT_MODEL_ATTRIBUTE_NAME );
|
||||
if ( jenaOntModel == null ) {
|
||||
jenaOntModel = (OntModel)_req.getSession().getServletContext().getAttribute( JenaBaseDao.INFERENCE_ONT_MODEL_ATTRIBUTE_NAME );
|
||||
}
|
||||
return jenaOntModel;
|
||||
return ModelAccess.on(this.getSession()).getInferenceOntModel();
|
||||
}
|
||||
|
||||
//Get the display and editing configuration model
|
||||
public OntModel getDisplayModel(){
|
||||
//bdc34: I have no idea what the correct way to get this model is
|
||||
|
||||
//try from the request
|
||||
if( _req.getAttribute("displayOntModel") != null ){
|
||||
return (OntModel) _req.getAttribute(DISPLAY_ONT_MODEL);
|
||||
|
||||
//try from the session
|
||||
} else {
|
||||
HttpSession session = _req.getSession(false);
|
||||
if( session != null ){
|
||||
if( session.getAttribute(DISPLAY_ONT_MODEL) != null ){
|
||||
return (OntModel) session.getAttribute(DISPLAY_ONT_MODEL);
|
||||
|
||||
//try from the context
|
||||
}else{
|
||||
if( session.getServletContext().getAttribute(DISPLAY_ONT_MODEL) != null){
|
||||
return (OntModel)session.getServletContext().getAttribute(DISPLAY_ONT_MODEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//nothing worked, could not find display model
|
||||
log.error("No display model could be found.");
|
||||
return null;
|
||||
return ModelAccess.on(this).getDisplayModel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -21,9 +20,8 @@ import com.hp.hpl.jena.query.QuerySolution;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.ajax.AbstractAjaxResponder;
|
||||
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.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryRunner;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.images.PlaceholderUtil;
|
||||
|
@ -60,9 +58,7 @@ public class BasicProxiesGetter extends AbstractAjaxResponder {
|
|||
super(servlet, vreq, resp);
|
||||
term = getStringParameter(PARAMETER_SEARCH_TERM, "");
|
||||
|
||||
ServletContext ctx = vreq.getSession().getServletContext();
|
||||
OntModelSelector oms = ModelContext.getUnionOntModelSelector(ctx);
|
||||
userAccountsModel = oms.getUserAccountsModel();
|
||||
userAccountsModel = ModelAccess.on(vreq).getUserAccountsModel();
|
||||
|
||||
placeholderImageUrl = UrlBuilder.getUrl(PlaceholderUtil
|
||||
.getPlaceholderImagePathForType(vreq,
|
||||
|
|
|
@ -178,7 +178,7 @@ public abstract class UserAccountsMyAccountPageStrategy extends
|
|||
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
||||
.createNewMessage(vreq);
|
||||
email.addRecipient(TO, page.getUserAccount().getEmailAddress());
|
||||
email.setSubject(i18n.text("email_changed_subject"));
|
||||
email.setSubject(i18n.text("email_changed_subject", getSiteName()));
|
||||
email.setTemplate(EMAIL_TEMPLATE);
|
||||
email.setBodyMap(body);
|
||||
email.processTemplate();
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.ajax;
|
||||
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -15,22 +13,14 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.query.DatasetFactory;
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.query.ResultSetFormatter;
|
||||
import com.hp.hpl.jena.query.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.ajax.SparqlUtils.AjaxControllerException;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
* Handle an AJAX request for a SPARQL query. On entry, the "query" parameter
|
||||
|
@ -86,29 +76,12 @@ public class SparqlQueryAjaxController extends VitroAjaxController {
|
|||
|
||||
}
|
||||
|
||||
private Model locateModel(VitroRequest vreq, String modelParam)
|
||||
throws AjaxControllerException {
|
||||
Object o = getServletContext().getAttribute("baseOntModelSelector");
|
||||
if (!(o instanceof OntModelSelector)) {
|
||||
throw new AjaxControllerException(SC_INTERNAL_SERVER_ERROR,
|
||||
"OntModelSelector not found");
|
||||
}
|
||||
OntModelSelector oms = (OntModelSelector) o;
|
||||
|
||||
Model model = null;
|
||||
private Model locateModel(VitroRequest vreq, String modelParam) {
|
||||
if (OPTION_MODEL_USER_ACCOUNTS.equals(modelParam)) {
|
||||
model = oms.getUserAccountsModel();
|
||||
return ModelAccess.on(vreq).getUserAccountsModel();
|
||||
} else {
|
||||
// TODO What is the appropriate way to do this?
|
||||
// model = oms.getFullModel();
|
||||
model = vreq.getJenaOntModel();
|
||||
return ModelAccess.on(vreq).getJenaOntModel();
|
||||
}
|
||||
if (model == null) {
|
||||
throw new AjaxControllerException(SC_INTERNAL_SERVER_ERROR,
|
||||
"Model '' not found.");
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private String locateQueryParam(VitroRequest vreq)
|
||||
|
|
|
@ -25,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginEvent;
|
||||
|
@ -302,14 +303,7 @@ public class BasicAuthenticator extends Authenticator {
|
|||
}
|
||||
|
||||
ServletContext servletContext = session.getServletContext();
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) servletContext
|
||||
.getAttribute("webappDaoFactory");
|
||||
if (wadf == null) {
|
||||
log.error("no WebappDaoFactory");
|
||||
return null;
|
||||
}
|
||||
|
||||
return wadf;
|
||||
return ModelAccess.on(servletContext).getWebappDaoFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ 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.Message;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginLogoutEvent;
|
||||
|
||||
public class Authenticate extends VitroHttpServlet {
|
||||
|
@ -557,16 +558,7 @@ public class Authenticate extends VitroHttpServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
OntModel jenaOntModel = (OntModel) session.getAttribute("jenaOntModel");
|
||||
if (jenaOntModel == null) {
|
||||
jenaOntModel = (OntModel) context.getAttribute("jenaOntModel");
|
||||
}
|
||||
if (jenaOntModel == null) {
|
||||
log.error("Unable to notify audit model of login event "
|
||||
+ "because no model could be found");
|
||||
return;
|
||||
}
|
||||
|
||||
OntModel jenaOntModel = ModelAccess.on(session).getJenaOntModel();
|
||||
jenaOntModel.getBaseModel().notifyEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,8 +79,7 @@ public class EntityRetryController extends BaseEditController {
|
|||
}
|
||||
|
||||
LoginStatusBean loginBean = LoginStatusBean.getBean(request);
|
||||
WebappDaoFactory myWebappDaoFactory = getWebappDaoFactory(
|
||||
vreq, loginBean.getUserURI());
|
||||
WebappDaoFactory myWebappDaoFactory = getWebappDaoFactory(loginBean.getUserURI());
|
||||
|
||||
IndividualDao ewDao = myWebappDaoFactory.getIndividualDao();
|
||||
epo.setDataAccessObject(ewDao);
|
||||
|
|
|
@ -24,6 +24,7 @@ import edu.cornell.mannlib.vedit.beans.EditProcessObject;
|
|||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
public class NamespacePrefixOperationController extends BaseEditController {
|
||||
|
@ -68,7 +69,7 @@ public class NamespacePrefixOperationController extends BaseEditController {
|
|||
|
||||
if (request.getParameter("_cancel") == null) {
|
||||
|
||||
OntModel ontModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
String namespaceStr = request.getParameter("namespace");
|
||||
String prefixStr = request.getParameter("prefix");
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -40,7 +39,6 @@ import com.hp.hpl.jena.rdf.model.StmtIterator;
|
|||
import com.hp.hpl.jena.shared.InvalidPropertyURIException;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.util.ResourceUtils;
|
||||
import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
||||
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
|
||||
|
@ -50,7 +48,8 @@ import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.FileGraphSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||
|
@ -74,7 +73,7 @@ public class RefactorOperationController extends BaseEditController {
|
|||
request.setAttribute("title","Check Datatype Properties");
|
||||
request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""+vreq.getAppBean().getThemeDir()+"css/edit.css\"/>");
|
||||
|
||||
OntModel ontModel = (OntModel) getServletContext().getAttribute("baseOntModel");
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
||||
ontModel.enterCriticalSection(Lock.WRITE);
|
||||
ArrayList<String> results = new ArrayList<String>();
|
||||
|
||||
|
@ -236,10 +235,10 @@ public class RefactorOperationController extends BaseEditController {
|
|||
Model model = null;
|
||||
|
||||
if (JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL.equals(graphURI)) {
|
||||
model = ModelContext.getBaseOntModelSelector(getServletContext()).getTBoxModel();
|
||||
model = ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX);
|
||||
doNotify = true;
|
||||
} else if (JenaDataSourceSetupBase.JENA_DB_MODEL.equals(graphURI)) {
|
||||
model = ModelContext.getBaseOntModelSelector(getServletContext()).getABoxModel();
|
||||
model = ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_ABOX);
|
||||
doNotify = true;
|
||||
} else {
|
||||
model = dataset.getNamedModel(graphURI);
|
||||
|
@ -252,8 +251,7 @@ public class RefactorOperationController extends BaseEditController {
|
|||
dataset.getLock().leaveCriticalSection();
|
||||
}
|
||||
|
||||
renameResourceInModel(ModelContext.getOntModelSelector(
|
||||
getServletContext()).getUserAccountsModel(),
|
||||
renameResourceInModel(ModelAccess.on(getServletContext()).getUserAccountsModel(),
|
||||
userURI, oldURIStr, newURIStr, !NOTIFY);
|
||||
|
||||
// there are no statements to delete, but we want indexes updated appropriately
|
||||
|
@ -330,7 +328,7 @@ public class RefactorOperationController extends BaseEditController {
|
|||
private void doMovePropertyStatements(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
||||
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
||||
|
||||
OntModel ontModel = ModelContext.getBaseOntModel(getServletContext());
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
||||
|
||||
Model tempRetractModel = ModelFactory.createDefaultModel();
|
||||
Model tempAddModel = ModelFactory.createDefaultModel();
|
||||
|
@ -414,7 +412,7 @@ public class RefactorOperationController extends BaseEditController {
|
|||
private void doMoveInstances(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
||||
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
||||
|
||||
OntModel ontModel = ModelContext.getBaseOntModel(getServletContext());
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
||||
|
||||
String oldClassURIStr = (String) epo.getAttribute("VClassURI");
|
||||
String newClassURIStr = (String) request.getParameter("NewVClassURI");
|
||||
|
|
|
@ -27,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||
|
@ -52,8 +53,8 @@ public class ClassHierarchyListingController extends BaseEditController {
|
|||
try {
|
||||
boolean inferred = (vrequest.getParameter("inferred") != null);
|
||||
|
||||
if (vrequest.getAssertionsWebappDaoFactory() != null && !inferred) {
|
||||
vcDao = vrequest.getAssertionsWebappDaoFactory().getVClassDao();
|
||||
if (!inferred) {
|
||||
vcDao = ModelAccess.on(vrequest).getBaseWebappDaoFactory().getVClassDao();
|
||||
} else {
|
||||
vcDao = vrequest.getFullWebappDaoFactory().getVClassDao();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
public class NamespacesListingController extends BaseEditController {
|
||||
|
@ -34,7 +35,7 @@ public class NamespacesListingController extends BaseEditController {
|
|||
|
||||
VitroRequest vrequest = new VitroRequest(request);
|
||||
|
||||
OntModel ontModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
|
||||
ArrayList results = new ArrayList();
|
||||
request.setAttribute("results",results);
|
||||
|
|
|
@ -33,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.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.VClassDao;
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class RestrictionsListingController extends BaseEditController {
|
|||
|
||||
epo = super.createEpo(request);
|
||||
|
||||
OntModel ontModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
|
||||
ObjectPropertyDao opDao = vrequest.getFullWebappDaoFactory().getObjectPropertyDao();
|
||||
VClassDao vcDao = vrequest.getFullWebappDaoFactory().getVClassDao();
|
||||
|
|
|
@ -17,6 +17,7 @@ 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.ResponseValues;
|
||||
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.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils;
|
||||
|
@ -200,7 +201,7 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
|
||||
Individual object = EditConfigurationUtils.getIndividual(vreq, objectUri);
|
||||
if(object == null) {
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) vreq.getSession().getServletContext().getAttribute("webappDaoFactory");
|
||||
WebappDaoFactory wadf = ModelAccess.on(vreq.getSession().getServletContext()).getWebappDaoFactory();
|
||||
object = wadf.getIndividualDao().getIndividualByURI(objectUri);
|
||||
}
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ public class UrlBuilder {
|
|||
}
|
||||
|
||||
public static String urlEncode(String str) {
|
||||
String encoding = "ISO-8859-1";
|
||||
String encoding = "UTF-8";
|
||||
String encodedUrl = null;
|
||||
try {
|
||||
encodedUrl = URLEncoder.encode(str, encoding);
|
||||
|
@ -314,7 +314,7 @@ public class UrlBuilder {
|
|||
}
|
||||
|
||||
public static String urlDecode(String str) {
|
||||
String encoding = "ISO-8859-1";
|
||||
String encoding = "UTF-8";
|
||||
String decodedUrl = null;
|
||||
try {
|
||||
decodedUrl = URLDecoder.decode(str, encoding);
|
||||
|
|
|
@ -18,12 +18,10 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
import com.hp.hpl.jena.iri.IRI;
|
||||
import com.hp.hpl.jena.iri.IRIFactory;
|
||||
import com.hp.hpl.jena.iri.Violation;
|
||||
import com.hp.hpl.jena.ontology.AllValuesFromRestriction;
|
||||
import com.hp.hpl.jena.ontology.OntClass;
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.ontology.OntResource;
|
||||
import com.hp.hpl.jena.ontology.Restriction;
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
|
@ -35,11 +33,9 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
|||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Statement;
|
||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
|
@ -47,6 +43,7 @@ import com.hp.hpl.jena.vocabulary.RDFS;
|
|||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
public class JenaAdminActions extends BaseEditController {
|
||||
|
@ -59,7 +56,7 @@ public class JenaAdminActions extends BaseEditController {
|
|||
if (iri.hasViolation(false) ) {
|
||||
log.error("Bad URI: "+uri);
|
||||
log.error( "Only well-formed absolute URIrefs can be included in RDF/XML output: "
|
||||
+ ((Violation)iri.violations(false).next()).getShortMessage());
|
||||
+ iri.violations(false).next().getShortMessage());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -71,8 +68,7 @@ public class JenaAdminActions extends BaseEditController {
|
|||
private static final String AKT_PORTAL = "http://www.aktors.org/ontology/portal#";
|
||||
|
||||
private void copyStatements(Model src, Model dest, Resource subj, Property pred, RDFNode obj) {
|
||||
for (Iterator i = src.listStatements(subj,pred,obj); i.hasNext();) {
|
||||
Statement stmt = (Statement) i.next();
|
||||
for (Statement stmt : src.listStatements(subj,pred,obj).toList()) {
|
||||
String subjNs = stmt.getSubject().getNameSpace();
|
||||
if (subjNs == null || (! (subjNs.equals(VITRO) || subjNs.equals(AKT_SUPPORT) || subjNs.equals(AKT_PORTAL) ) ) ) {
|
||||
if (stmt.getObject().isLiteral()) {
|
||||
|
@ -90,14 +86,11 @@ 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.
|
||||
* @param response
|
||||
*/
|
||||
private void outputTbox(HttpServletResponse response) {
|
||||
OntModel memoryModel = (OntModel) getServletContext().getAttribute("baseOntModel");
|
||||
OntModel memoryModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
||||
try {
|
||||
OntModel tempOntModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
|
||||
Property DescriptionProp = ResourceFactory.createProperty(VitroVocabulary.DESCRIPTION_ANNOT);
|
||||
Property ExampleProp = ResourceFactory.createProperty(VitroVocabulary.EXAMPLE_ANNOT);
|
||||
memoryModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
copyStatements(memoryModel,tempOntModel,null,RDF.type,OWL.Class);
|
||||
|
@ -109,8 +102,6 @@ public class JenaAdminActions extends BaseEditController {
|
|||
copyStatements(memoryModel,tempOntModel,null,RDFS.domain,null);
|
||||
copyStatements(memoryModel,tempOntModel,null,RDFS.range,null);
|
||||
copyStatements(memoryModel,tempOntModel,null,OWL.inverseOf,null);
|
||||
//copyStatements(memoryModel,tempOntModel,null,DescriptionProp,null);
|
||||
//copyStatements(memoryModel,tempOntModel,null,ExampleProp,null);
|
||||
} finally {
|
||||
memoryModel.leaveCriticalSection();
|
||||
}
|
||||
|
@ -130,19 +121,15 @@ public class JenaAdminActions extends BaseEditController {
|
|||
Model taxonomyModel = ModelFactory.createDefaultModel();
|
||||
try {
|
||||
HashSet<Resource> typeSet = new HashSet<Resource>();
|
||||
for (Iterator classIt = ontModel.listStatements((Resource)null,RDF.type,(RDFNode)null); classIt.hasNext();) {
|
||||
Statement stmt = (Statement) classIt.next();
|
||||
for (Statement stmt : ontModel.listStatements((Resource)null,RDF.type,(RDFNode)null).toList()) {
|
||||
if (stmt.getObject().isResource()) {
|
||||
Resource ontClass = (Resource) stmt.getObject();
|
||||
typeSet.add(ontClass);
|
||||
typeSet.add((Resource) stmt.getObject());
|
||||
}
|
||||
}
|
||||
for (Iterator classIt = ontModel.listClasses(); classIt.hasNext();) {
|
||||
Resource classRes = (Resource) classIt.next();
|
||||
for (Resource classRes : ontModel.listClasses().toList()) {
|
||||
typeSet.add(classRes);
|
||||
}
|
||||
for (Iterator<Resource> typeIt = typeSet.iterator(); typeIt.hasNext();) {
|
||||
Resource ontClass = typeIt.next();
|
||||
for (Resource ontClass : typeSet) {
|
||||
if (!ontClass.isAnon()) { // Only query for named classes
|
||||
System.out.println("Describing "+ontClass.getURI());
|
||||
// We want a subgraph describing this class, including related BNodes
|
||||
|
@ -171,10 +158,10 @@ public class JenaAdminActions extends BaseEditController {
|
|||
private String testWriteXML() {
|
||||
StringBuffer output = new StringBuffer();
|
||||
output.append("<html><head><title>Test Write XML</title></head><body><pre>\n");
|
||||
Model model = (Model) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
Model tmp = ModelFactory.createDefaultModel();
|
||||
boolean valid = true;
|
||||
for (Statement stmt : ((List<Statement>)model.listStatements().toList()) ) {
|
||||
for (Statement stmt : model.listStatements().toList() ) {
|
||||
tmp.add(stmt);
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
|
@ -201,17 +188,15 @@ public class JenaAdminActions extends BaseEditController {
|
|||
|
||||
private void printRestrictions() {
|
||||
OntModel memoryModel = (OntModel) getServletContext().getAttribute("pelletOntModel");
|
||||
for (Iterator i = memoryModel.listRestrictions(); i.hasNext(); ) {
|
||||
Restriction rest = (Restriction) i.next();
|
||||
for (Restriction rest : memoryModel.listRestrictions().toList() ) {
|
||||
//System.out.println();
|
||||
if (rest.isAllValuesFromRestriction()) {
|
||||
log.trace("All values from: ");
|
||||
AllValuesFromRestriction avfr = rest.asAllValuesFromRestriction();
|
||||
Resource res = avfr.getAllValuesFrom();
|
||||
if (res.canAs(OntClass.class)) {
|
||||
OntClass resClass = (OntClass) res.as(OntClass.class);
|
||||
for (Iterator resInstIt = resClass.listInstances(); resInstIt.hasNext(); ) {
|
||||
Resource inst = (Resource) resInstIt.next();
|
||||
OntClass resClass = res.as(OntClass.class);
|
||||
for (Resource inst : resClass.listInstances().toList() ) {
|
||||
log.trace(" -"+inst.getURI());
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +206,7 @@ public class JenaAdminActions extends BaseEditController {
|
|||
log.trace("Has value: ");
|
||||
}
|
||||
log.trace("On property "+rest.getOnProperty().getURI());
|
||||
for (Iterator indIt = rest.listInstances(); indIt.hasNext(); ) {
|
||||
Resource inst = (Resource) indIt.next();
|
||||
for (Resource inst : rest.listInstances().toList() ) {
|
||||
log.trace(" "+inst.getURI());
|
||||
}
|
||||
|
||||
|
@ -230,12 +214,11 @@ public class JenaAdminActions extends BaseEditController {
|
|||
}
|
||||
|
||||
private void removeLongLiterals() {
|
||||
OntModel memoryModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel memoryModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
memoryModel.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
List<Statement> statementsToRemove = new LinkedList<Statement>();
|
||||
for (Iterator i = memoryModel.listStatements(null,null,(Literal)null); i.hasNext(); ) {
|
||||
Statement stmt = (Statement) i.next();
|
||||
for (Statement stmt : memoryModel.listStatements(null,null,(Literal)null).toList() ) {
|
||||
if (stmt.getObject().isLiteral()) {
|
||||
Literal lit = (Literal) stmt.getObject();
|
||||
if ( lit.getString().length() > 24) {
|
||||
|
@ -252,6 +235,7 @@ public class JenaAdminActions extends BaseEditController {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest req, HttpServletResponse response) {
|
||||
if (!isAuthorizedToDisplayPage(req, response, SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTIONS)) {
|
||||
return;
|
||||
|
@ -273,17 +257,16 @@ public class JenaAdminActions extends BaseEditController {
|
|||
}
|
||||
|
||||
if (actionStr.equals("checkURIs")) {
|
||||
OntModel memoryModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
ClosableIterator stmtIt = memoryModel.listStatements();
|
||||
OntModel memoryModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
StmtIterator stmtIt = memoryModel.listStatements();
|
||||
try {
|
||||
for (Iterator i = stmtIt; i.hasNext(); ) {
|
||||
for (Statement stmt : stmtIt.toList() ) {
|
||||
boolean sFailed = false;
|
||||
boolean pFailed = false;
|
||||
boolean oFailed = false;
|
||||
String sURI = "<bNode>";
|
||||
String pURI = "???";
|
||||
String oURI = "<bNode>";
|
||||
Statement stmt = (Statement) i.next();
|
||||
if (stmt.getSubject().getURI() != null) {
|
||||
sFailed = checkURI(sURI = stmt.getSubject().getURI());
|
||||
}
|
||||
|
@ -305,23 +288,19 @@ public class JenaAdminActions extends BaseEditController {
|
|||
if (actionStr.equals("output")) {
|
||||
OntModel memoryModel = null;
|
||||
if (request.getParameter("assertionsOnly") != null) {
|
||||
memoryModel = (OntModel) getServletContext().getAttribute("baseOntModel");
|
||||
memoryModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
||||
System.out.println("baseOntModel");
|
||||
} else if (request.getParameter("inferences") != null) {
|
||||
memoryModel = (OntModel) getServletContext().getAttribute("inferenceOntModel");
|
||||
memoryModel = ModelAccess.on(getServletContext()).getInferenceOntModel();
|
||||
System.out.println("inferenceOntModel");
|
||||
} else if (request.getParameter("pellet") != null) {
|
||||
memoryModel = (OntModel) getServletContext().getAttribute("pelletOntModel");
|
||||
System.out.println("pelletOntModel");
|
||||
} else {
|
||||
memoryModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
memoryModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
System.out.println("jenaOntModel");
|
||||
}
|
||||
int subModelCount = 0;
|
||||
for (Iterator subIt = memoryModel.listSubModels(); subIt.hasNext();) {
|
||||
subIt.next();
|
||||
++subModelCount;
|
||||
}
|
||||
int subModelCount = memoryModel.listSubModels().toList().size();
|
||||
System.out.println("Submodels: "+subModelCount);
|
||||
try {
|
||||
//response.setContentType("application/rdf+xml");
|
||||
|
@ -339,42 +318,8 @@ public class JenaAdminActions extends BaseEditController {
|
|||
removeLongLiterals();
|
||||
}
|
||||
|
||||
if (actionStr.equals("isIsomorphic")) {
|
||||
OntModel memoryModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel persistentModel = (OntModel) getServletContext().getAttribute("jenaPersistentOntModel");
|
||||
if ((memoryModel != null) && (persistentModel != null)) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (memoryModel.isIsomorphicWith(persistentModel)) {
|
||||
log.trace("In-memory and persistent models are isomorphic");
|
||||
} else {
|
||||
log.trace("In-memory and persistent models are NOT isomorphic");
|
||||
log.trace("In-memory model has "+memoryModel.size()+" statements");
|
||||
log.trace("Persistent model has "+persistentModel.size()+" statements");
|
||||
Model diff = memoryModel.difference(persistentModel);
|
||||
ClosableIterator stmtIt = diff.listStatements();
|
||||
log.trace("Delta = "+diff.size()+" statments");
|
||||
while (stmtIt.hasNext()) {
|
||||
Statement s = (Statement) stmtIt.next();
|
||||
try {
|
||||
log.trace(s.getSubject().getURI()+" : "+s.getPredicate().getURI()); // + ((Literal)s.getObject()).getString());
|
||||
} catch (ClassCastException cce) {}
|
||||
}
|
||||
}
|
||||
log.trace((System.currentTimeMillis()-startTime)/1000+" seconds to check isomorphism");
|
||||
}
|
||||
} else if (actionStr.equals("removeUntypedResources")) {
|
||||
OntModel memoryModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel persistentModel = (OntModel) getServletContext().getAttribute("jenaPersistentOntModel");
|
||||
ClosableIterator rIt = memoryModel.listSubjects();
|
||||
clean(rIt,memoryModel);
|
||||
ClosableIterator oIt = memoryModel.listObjects();
|
||||
clean(oIt,memoryModel);
|
||||
ClosableIterator rrIt = persistentModel.listSubjects();
|
||||
clean(rIt,persistentModel);
|
||||
ClosableIterator ooIt = persistentModel.listObjects();
|
||||
clean(oIt,persistentModel);
|
||||
} else if (actionStr.equals("outputTaxonomy")) {
|
||||
OntModel ontModel = (OntModel) getServletContext().getAttribute("baseOntModel");
|
||||
if (actionStr.equals("outputTaxonomy")) {
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
||||
Model taxonomyModel = extractTaxonomy(ontModel);
|
||||
try {
|
||||
taxonomyModel.write(response.getOutputStream());
|
||||
|
@ -385,31 +330,7 @@ public class JenaAdminActions extends BaseEditController {
|
|||
}
|
||||
|
||||
|
||||
private void clean(ClosableIterator rIt, OntModel model) {
|
||||
try {
|
||||
while (rIt.hasNext()) {
|
||||
try {
|
||||
OntResource r = (OntResource) rIt.next();
|
||||
try {
|
||||
Resource t = r.getRDFType();
|
||||
if (t == null) {
|
||||
r.remove();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
r.remove();
|
||||
}
|
||||
} catch (ClassCastException cce) {
|
||||
Resource r = (Resource) rIt.next();
|
||||
model.removeAll(r,null,null);
|
||||
model.removeAll(null,null,r);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
rIt.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) {
|
||||
doGet(request ,response);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.jena;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -30,8 +28,9 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
|
@ -121,8 +120,7 @@ public class JenaExportController extends BaseEditController {
|
|||
if( "abox".equals(subgraphParam)){
|
||||
model = ModelFactory.createDefaultModel();
|
||||
if("inferred".equals(assertedOrInferredParam)){
|
||||
model = ModelContext.getInferenceOntModelSelector(
|
||||
getServletContext()).getABoxModel();
|
||||
model = ModelAccess.on(getServletContext()).getOntModel(ModelID.INFERRED_ABOX);
|
||||
}
|
||||
else if("full".equals(assertedOrInferredParam)){
|
||||
outputSparqlConstruct(ABOX_FULL_CONSTRUCT, formatParam, response);
|
||||
|
@ -137,10 +135,9 @@ public class JenaExportController extends BaseEditController {
|
|||
// so we'll extract the whole ontology and then include
|
||||
// only those statements that are in the inferred graph
|
||||
Model tempModel = xutil.extractTBox(
|
||||
ModelContext.getUnionOntModelSelector(
|
||||
getServletContext()).getTBoxModel(), ontologyURI);
|
||||
Model inferenceModel = ModelContext.getInferenceOntModelSelector(
|
||||
getServletContext()).getTBoxModel();
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_TBOX),
|
||||
ontologyURI);
|
||||
Model inferenceModel = ModelAccess.on(getServletContext()).getOntModel(ModelID.INFERRED_TBOX);
|
||||
inferenceModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
model = tempModel.intersection(inferenceModel);
|
||||
|
@ -149,12 +146,11 @@ public class JenaExportController extends BaseEditController {
|
|||
}
|
||||
} else if ("full".equals(assertedOrInferredParam)) {
|
||||
model = xutil.extractTBox(
|
||||
ModelContext.getUnionOntModelSelector(
|
||||
getServletContext()).getTBoxModel(), ontologyURI);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_TBOX),
|
||||
ontologyURI);
|
||||
} else {
|
||||
model = xutil.extractTBox(
|
||||
ModelContext.getBaseOntModelSelector(
|
||||
getServletContext()).getTBoxModel(), ontologyURI);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX), ontologyURI);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -162,10 +158,8 @@ public class JenaExportController extends BaseEditController {
|
|||
if("inferred".equals(assertedOrInferredParam)){
|
||||
ontModel = xutil.extractTBox(
|
||||
dataset, ontologyURI, INFERENCE_GRAPH);
|
||||
ontModel.addSubModel(ModelContext.getInferenceOntModelSelector(
|
||||
getServletContext()).getABoxModel());
|
||||
ontModel.addSubModel(ModelContext.getInferenceOntModelSelector(
|
||||
getServletContext()).getTBoxModel());
|
||||
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ModelID.INFERRED_ABOX));
|
||||
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ModelID.INFERRED_TBOX));
|
||||
}
|
||||
else if("full".equals(assertedOrInferredParam)){
|
||||
outputSparqlConstruct(FULL_FULL_CONSTRUCT, formatParam, response);
|
||||
|
@ -283,9 +277,6 @@ public class JenaExportController extends BaseEditController {
|
|||
}
|
||||
}
|
||||
|
||||
static final String FULL_ONT_MODEL_ATTR = "jenaOntModel";
|
||||
static final String ASSERTIONS_ONT_MODEL_ATTR = "baseOntModel";
|
||||
static final String INFERENCES_ONT_MODEL_ATTR = "inferenceOntModel";
|
||||
static final String FULL_GRAPH = "?g";
|
||||
static final String ASSERTIONS_GRAPH = "<http://vitro.mannlib.cornell.edu/default/vitro-kb-2>";
|
||||
static final String INFERENCE_GRAPH = "<http://vitro.mannlib.cornell.edu/default/vitro-kb-inf>";
|
||||
|
|
|
@ -67,8 +67,9 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
||||
|
@ -79,8 +80,8 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
|||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.ContentModelSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.WebappDaoSetup;
|
||||
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.MergeResult;
|
||||
|
@ -520,7 +521,7 @@ public class JenaIngestController extends BaseEditController {
|
|||
vreq.setAttribute("title", "Choose Workflow Step");
|
||||
vreq.setAttribute("bodyJsp", WORKFLOW_STEP_JSP);
|
||||
} else {
|
||||
OntModel jenaOntModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
jenaOntModel.enterCriticalSection(Lock.READ);
|
||||
List<Individual> savedQueryList = new LinkedList<Individual>();
|
||||
try {
|
||||
|
@ -537,7 +538,7 @@ public class JenaIngestController extends BaseEditController {
|
|||
|
||||
private void processExecuteSparqlRequest(VitroRequest vreq, ModelMaker maker, String modelType) {
|
||||
String sparqlQueryStr = vreq.getParameter("sparqlQueryStr");
|
||||
OntModel jenaOntModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
jenaOntModel.enterCriticalSection(Lock.READ);
|
||||
List<Individual> savedQueryList = new LinkedList<Individual>();
|
||||
try {
|
||||
|
@ -660,10 +661,8 @@ public class JenaIngestController extends BaseEditController {
|
|||
/*
|
||||
* get baseOnt and infOnt models
|
||||
*/
|
||||
OntModel baseOntModel = ModelContext.getBaseOntModel(
|
||||
getServletContext());
|
||||
OntModel tboxOntModel = ModelContext.getUnionOntModelSelector(
|
||||
getServletContext()).getTBoxModel();
|
||||
OntModel baseOntModel = ModelAccess.on(getServletContext()).getBaseOntModel();
|
||||
OntModel tboxOntModel = ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_TBOX);
|
||||
|
||||
/*
|
||||
* calling method that does the merge operation.
|
||||
|
@ -826,10 +825,10 @@ public class JenaIngestController extends BaseEditController {
|
|||
return;
|
||||
}
|
||||
Model m = modelMaker.getModel(modelName);
|
||||
ModelContext.getBaseOntModelSelector(getServletContext()).getTBoxModel().addSubModel(m);
|
||||
ModelContext.getBaseOntModelSelector(getServletContext()).getABoxModel().addSubModel(m);
|
||||
ModelContext.getUnionOntModelSelector(getServletContext()).getABoxModel().addSubModel(m);
|
||||
ModelContext.getUnionOntModelSelector(getServletContext()).getTBoxModel().addSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_ABOX).addSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX).addSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_ABOX).addSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_TBOX).addSubModel(m);
|
||||
attachedModels.put(modelName, m);
|
||||
log.info("Attached " + modelName + " (" + m.hashCode() + ") to webapp");
|
||||
}
|
||||
|
@ -839,10 +838,10 @@ public class JenaIngestController extends BaseEditController {
|
|||
if (m == null) {
|
||||
return;
|
||||
}
|
||||
ModelContext.getBaseOntModelSelector(getServletContext()).getTBoxModel().removeSubModel(m);
|
||||
ModelContext.getBaseOntModelSelector(getServletContext()).getABoxModel().removeSubModel(m);
|
||||
ModelContext.getUnionOntModelSelector(getServletContext()).getABoxModel().removeSubModel(m);
|
||||
ModelContext.getUnionOntModelSelector(getServletContext()).getTBoxModel().removeSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_ABOX).removeSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.BASE_TBOX).removeSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_ABOX).removeSubModel(m);
|
||||
ModelAccess.on(getServletContext()).getOntModel(ModelID.UNION_TBOX).removeSubModel(m);
|
||||
attachedModels.remove(modelName);
|
||||
log.info("Detached " + modelName + " (" + m.hashCode() + ") from webapp");
|
||||
}
|
||||
|
@ -910,7 +909,7 @@ public class JenaIngestController extends BaseEditController {
|
|||
}
|
||||
|
||||
private long doExecuteSparql(VitroRequest vreq) {
|
||||
OntModel jenaOntModel = (OntModel) getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
OntModel source = null;
|
||||
if ("pellet".equals(vreq.getParameter("reasoning"))) {
|
||||
source = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
||||
|
@ -984,7 +983,7 @@ public class JenaIngestController extends BaseEditController {
|
|||
log.debug("Connecting to DB at "+jdbcUrl);
|
||||
StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash,dbTypeObj) ;
|
||||
ServletContext ctx = vreq.getSession().getServletContext();
|
||||
DataSource bds = WebappDaoSetup.makeBasicDataSource(
|
||||
DataSource bds = ContentModelSetup.makeBasicDataSource(
|
||||
driver, jdbcUrl, username, password, ctx);
|
||||
try {
|
||||
VitroJenaSDBModelMaker vsmm = new VitroJenaSDBModelMaker(storeDesc, bds);
|
||||
|
@ -1193,8 +1192,7 @@ public class JenaIngestController extends BaseEditController {
|
|||
Model baseOntModel = RDFServiceGraph.createRDFServiceModel
|
||||
(new RDFServiceGraph(
|
||||
rdfService, JenaDataSourceSetupBase.JENA_DB_MODEL));
|
||||
OntModel ontModel = (OntModel)
|
||||
getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel ontModel = ModelAccess.on(getServletContext()).getJenaOntModel();
|
||||
List<String> urisToChange = new LinkedList<String>();
|
||||
ontModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
|
@ -1312,26 +1310,11 @@ public class JenaIngestController extends BaseEditController {
|
|||
|
||||
public static Model getModel(String name, HttpServletRequest request, ServletContext context) {
|
||||
if ("vitro:jenaOntModel".equals(name)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("jenaOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
return (OntModel) context.getAttribute("jenaOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getJenaOntModel();
|
||||
} else if ("vitro:baseOntModel".equals(name)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("baseOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
return (OntModel) context.getAttribute("baseOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getBaseOntModel();
|
||||
} else if ("vitro:inferenceOntModel".equals(name)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("inferenceOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
return (OntModel) context.getAttribute("inferenceOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getInferenceOntModel();
|
||||
} else {
|
||||
return getVitroJenaModelMaker(request,context).getModel(name);
|
||||
}
|
||||
|
|
|
@ -34,9 +34,10 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
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.event.BulkUpdateEvent;
|
||||
|
@ -170,14 +171,12 @@ public class RDFUploadController extends JenaIngestController {
|
|||
|
||||
JenaModelUtils xutil = new JenaModelUtils();
|
||||
|
||||
OntModel tboxModel = getTBoxModel(
|
||||
request.getSession(), getServletContext());
|
||||
OntModel tboxModel = getTBoxModel(request.getSession());
|
||||
OntModel aboxModel = getABoxModel(
|
||||
request.getSession(), getServletContext());
|
||||
OntModel tboxChangeModel = null;
|
||||
Model aboxChangeModel = null;
|
||||
OntModelSelector ontModelSelector = ModelContext.getOntModelSelector(
|
||||
getServletContext());
|
||||
OntModelSelector ontModelSelector = ModelAccess.on(getServletContext()).getOntModelSelector();
|
||||
|
||||
if (tboxModel != null) {
|
||||
boolean AGGRESSIVE = true;
|
||||
|
@ -428,17 +427,8 @@ public class RDFUploadController extends JenaIngestController {
|
|||
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, abox);
|
||||
}
|
||||
|
||||
private OntModel getTBoxModel(HttpSession session, ServletContext ctx) {
|
||||
if (session != null
|
||||
&& session.getAttribute("baseOntModelSelector")
|
||||
instanceof OntModelSelector) {
|
||||
return ((OntModelSelector)
|
||||
session.getAttribute("baseOntModelSelector"))
|
||||
.getTBoxModel();
|
||||
} else {
|
||||
return ((OntModelSelector)
|
||||
ctx.getAttribute("baseOntModelSelector")).getTBoxModel();
|
||||
}
|
||||
private OntModel getTBoxModel(HttpSession session) {
|
||||
return ModelAccess.on(session).getOntModel(ModelID.BASE_TBOX);
|
||||
}
|
||||
|
||||
private static final Log log = LogFactory.getLog(
|
||||
|
|
|
@ -115,13 +115,6 @@ public class DisplayVocabulary {
|
|||
public static final String USE_TBOX_MODEL_PARAM = "useThisTboxModel";
|
||||
public static final String USE_DISPLAY_MODEL_PARAM = "useThisDisplayModel";
|
||||
|
||||
//Attribute values used to store display tbox/display display model in servlet context
|
||||
public static final String CONTEXT_DISPLAY_TBOX = "displayOntModelTBOX";
|
||||
public static final String CONTEXT_DISPLAY_DISPLAY = "displayOntModelDisplayModel";
|
||||
|
||||
/** Key for display model in request, session or context attributes */
|
||||
public static final String DISPLAY_ONT_MODEL = "displayOntModel";
|
||||
|
||||
//URL for menu management
|
||||
public static final String PROCESS_MENU_MANAGEMENT_URL = "/menuManagementEdit";
|
||||
public static final String REORDER_MENU_URL = PROCESS_MENU_MANAGEMENT_URL + "?cmd=Reorder&" + SWITCH_TO_DISPLAY_MODEL + "=true";
|
||||
|
|
323
webapp/src/edu/cornell/mannlib/vitro/webapp/dao/ModelAccess.java
Normal file
323
webapp/src/edu/cornell/mannlib/vitro/webapp/dao/ModelAccess.java
Normal file
|
@ -0,0 +1,323 @@
|
|||
/* $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.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 edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
|
||||
/**
|
||||
* 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()
|
||||
* vreq.setUnfilteredWebappDaoFactory(wadf);
|
||||
*
|
||||
* OntModelSelector.getABoxModel
|
||||
* OntModelSelector.getFullModel()
|
||||
* OntModelSelector.getTBoxModel()
|
||||
* VitroModelSource.getModel(URL)
|
||||
* VitroModelSource.getModel(URL, loadIfAbsent)
|
||||
* VitroModelSource.openModel(name)
|
||||
* VitroModelSource.openModelIfPresent(string)
|
||||
* ServletContext.getAttribute("jenaPersistentOntModel")
|
||||
* ServletContext.getAttribute("pelletOntModel")
|
||||
* VitroJenaModelMaker
|
||||
* VitroJenaSpecialModelMaker
|
||||
* JenaDataSourceSetupBase.getApplicationDataSource(ctx)
|
||||
* 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 ModelID {
|
||||
APPLICATION_METADATA,
|
||||
|
||||
USER_ACCOUNTS,
|
||||
|
||||
DISPLAY, DISPLAY_DISPLAY, DISPLAY_TBOX,
|
||||
|
||||
BASE_ABOX, BASE_TBOX, BASE_FULL,
|
||||
|
||||
INFERRED_ABOX, INFERRED_TBOX, INFERRED_FULL,
|
||||
|
||||
UNION_ABOX, UNION_TBOX, UNION_FULL
|
||||
}
|
||||
|
||||
public enum FactoryID {
|
||||
BASE, UNION
|
||||
}
|
||||
|
||||
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<ModelID, OntModel> modelMap = new EnumMap<>(ModelID.class);
|
||||
private final Map<FactoryID, WebappDaoFactory> factoryMap = new EnumMap<>(
|
||||
FactoryID.class);
|
||||
|
||||
public ModelAccess(Scope scope, ModelAccess parent) {
|
||||
this.scope = scope;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Accessing the models
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public OntModel getApplicationMetadataModel() {
|
||||
return getOntModel(ModelID.APPLICATION_METADATA);
|
||||
}
|
||||
|
||||
public void setUserAccountsModel(OntModel m) {
|
||||
setOntModel(ModelID.USER_ACCOUNTS, m);
|
||||
}
|
||||
|
||||
public OntModel getUserAccountsModel() {
|
||||
return getOntModel(ModelID.USER_ACCOUNTS);
|
||||
}
|
||||
|
||||
public void setDisplayModel(OntModel m) {
|
||||
setOntModel(ModelID.DISPLAY, m);
|
||||
}
|
||||
|
||||
public OntModel getDisplayModel() {
|
||||
return getOntModel(ModelID.DISPLAY);
|
||||
}
|
||||
|
||||
public void setJenaOntModel(OntModel m) {
|
||||
setOntModel(ModelID.UNION_FULL, m);
|
||||
}
|
||||
|
||||
public OntModel getJenaOntModel() {
|
||||
return getOntModel(ModelID.UNION_FULL);
|
||||
}
|
||||
|
||||
public void setBaseOntModel(OntModel m) {
|
||||
setOntModel(ModelID.BASE_FULL, m);
|
||||
}
|
||||
|
||||
public OntModel getBaseOntModel() {
|
||||
return getOntModel(ModelID.BASE_FULL);
|
||||
}
|
||||
|
||||
public OntModel getInferenceOntModel() {
|
||||
return getOntModel(ModelID.INFERRED_FULL);
|
||||
}
|
||||
|
||||
public void setOntModel(ModelID id, OntModel ontModel) {
|
||||
if (ontModel == null) {
|
||||
modelMap.remove(id);
|
||||
} else {
|
||||
modelMap.put(id, ontModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeOntModel(ModelID id) {
|
||||
setOntModel(id, null);
|
||||
}
|
||||
|
||||
public OntModel getOntModel(ModelID 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 new FacadeOntModelSelector(this, ModelID.BASE_ABOX,
|
||||
ModelID.BASE_TBOX, ModelID.BASE_FULL);
|
||||
}
|
||||
|
||||
public OntModelSelector getInferenceOntModelSelector() {
|
||||
return new FacadeOntModelSelector(this, ModelID.INFERRED_ABOX,
|
||||
ModelID.INFERRED_TBOX, ModelID.INFERRED_FULL);
|
||||
}
|
||||
|
||||
public OntModelSelector getUnionOntModelSelector() {
|
||||
return new FacadeOntModelSelector(this, ModelID.UNION_ABOX,
|
||||
ModelID.UNION_TBOX, ModelID.UNION_FULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Helper classes
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This OntModelSelector doesn't actually hold any OntModels. Instead, it
|
||||
* links back to the ModelAccess that it was created from. So, if you change
|
||||
* a model on the ModelAccess, it will change on the OntModelSelector also.
|
||||
* Even if the OntModelSelector was created first.
|
||||
*/
|
||||
private static class FacadeOntModelSelector implements OntModelSelector {
|
||||
private final ModelAccess parent;
|
||||
private final ModelID aboxID;
|
||||
private final ModelID tboxID;
|
||||
private final ModelID fullID;
|
||||
|
||||
public FacadeOntModelSelector(ModelAccess parent, ModelID aboxID,
|
||||
ModelID tboxID, ModelID fullID) {
|
||||
this.parent = parent;
|
||||
this.aboxID = aboxID;
|
||||
this.tboxID = tboxID;
|
||||
this.fullID = fullID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getABoxModel() {
|
||||
return parent.getOntModel(aboxID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getTBoxModel() {
|
||||
return parent.getOntModel(tboxID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getFullModel() {
|
||||
return parent.getOntModel(fullID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getApplicationMetadataModel() {
|
||||
return parent.getOntModel(ModelID.APPLICATION_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getUserAccountsModel() {
|
||||
return parent.getOntModel(ModelID.USER_ACCOUNTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getDisplayModel() {
|
||||
return parent.getOntModel(ModelID.DISPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -41,7 +41,7 @@ public interface ObjectPropertyStatementDao {
|
|||
public Map<String, String> getMostSpecificTypesInClassgroupsForIndividual(String subjectUri);
|
||||
|
||||
List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
|
||||
String subjectUri, String propertyUri, String objectKey,
|
||||
String subjectUri, String propertyUri, String objectKey, String rangeUri,
|
||||
String queryString, Set<String> constructQueryStrings,
|
||||
String sortDirection);
|
||||
|
||||
|
|
|
@ -86,12 +86,12 @@ class ObjectPropertyStatementDaoFiltering extends BaseFiltering implements Objec
|
|||
|
||||
@Override
|
||||
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
|
||||
String subjectUri, String propertyUri, String objectKey, String query,
|
||||
Set<String> queryStrings, String sortDirection) {
|
||||
String subjectUri, String propertyUri, String objectKey, String rangeUri,
|
||||
String query, Set<String> queryStrings, String sortDirection) {
|
||||
|
||||
List<Map<String, String>> data =
|
||||
innerObjectPropertyStatementDao.getObjectPropertyStatementsForIndividualByProperty(
|
||||
subjectUri, propertyUri, objectKey, query, queryStrings,sortDirection);
|
||||
subjectUri, propertyUri, objectKey, rangeUri, query, queryStrings,sortDirection);
|
||||
|
||||
/* Filter the data
|
||||
*
|
||||
|
@ -105,6 +105,10 @@ class ObjectPropertyStatementDaoFiltering extends BaseFiltering implements Objec
|
|||
for (Map<String, String> map : data) {
|
||||
String objectUri = map.get(objectKey);
|
||||
ObjectPropertyStatement statement = new ObjectPropertyStatementImpl(subjectUri, propertyUri, objectUri);
|
||||
ObjectProperty op = new ObjectProperty();
|
||||
op.setURI(propertyUri);
|
||||
op.setRangeVClassURI(rangeUri);
|
||||
statement.setProperty(op);
|
||||
stmtsToData.put(statement, map);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,10 +54,6 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
|||
public static final boolean KEEP_ONLY_IF_TRUE = true; //used for updatePropertyBooleanValue()
|
||||
public static final boolean KEEP_ONLY_IF_FALSE = false; //used for updatePropertyBooleanValue()
|
||||
|
||||
public static final String JENA_ONT_MODEL_ATTRIBUTE_NAME = "jenaOntModel";
|
||||
public static final String ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME = "baseOntModel";
|
||||
public static final String INFERENCE_ONT_MODEL_ATTRIBUTE_NAME = "inferenceOntModel";
|
||||
|
||||
protected static final Log log = LogFactory.getLog(JenaBaseDao.class.getName());
|
||||
|
||||
/* ******************* static constants ****************** */
|
||||
|
|
|
@ -7,84 +7,14 @@ 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.rdf.model.ModelChangedListener;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
|
||||
public class ModelContext {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ModelContext.class);
|
||||
|
||||
private static final String ONT_MODEL_SELECTOR = "ontModelSelector";
|
||||
private static final String UNION_ONT_MODEL_SELECTOR = "unionOntModelSelector";
|
||||
private static final String BASE_ONT_MODEL_SELECTOR = "baseOntModelSelector";
|
||||
private static final String INFERENCE_ONT_MODEL_SELECTOR = "inferenceOntModelSelector";
|
||||
|
||||
private static final String JENA_ONT_MODEL = "jenaOntModel";
|
||||
private static final String BASE_ONT_MODEL = "baseOntModel";
|
||||
private static final String INFERENCE_ONT_MODEL = "inferenceOntModel";
|
||||
|
||||
public ModelContext() {}
|
||||
|
||||
public static OntModelSelector getOntModelSelector(ServletContext ctx) {
|
||||
return (OntModelSelector) ctx.getAttribute(ONT_MODEL_SELECTOR);
|
||||
}
|
||||
|
||||
public static void setOntModelSelector(OntModelSelector oms, ServletContext ctx) {
|
||||
ctx.setAttribute(ONT_MODEL_SELECTOR, oms);
|
||||
}
|
||||
|
||||
public static OntModelSelector getUnionOntModelSelector(ServletContext ctx) {
|
||||
return (OntModelSelector) ctx.getAttribute(UNION_ONT_MODEL_SELECTOR);
|
||||
}
|
||||
|
||||
public static void setUnionOntModelSelector(OntModelSelector oms, ServletContext ctx) {
|
||||
ctx.setAttribute(UNION_ONT_MODEL_SELECTOR, oms);
|
||||
}
|
||||
|
||||
public static OntModelSelector getBaseOntModelSelector(ServletContext ctx) {
|
||||
return (OntModelSelector) ctx.getAttribute(BASE_ONT_MODEL_SELECTOR);
|
||||
}
|
||||
|
||||
public static void setBaseOntModelSelector(OntModelSelector oms, ServletContext ctx) {
|
||||
ctx.setAttribute(BASE_ONT_MODEL_SELECTOR, oms);
|
||||
}
|
||||
|
||||
public static OntModelSelector getInferenceOntModelSelector(ServletContext ctx) {
|
||||
return (OntModelSelector) ctx.getAttribute(INFERENCE_ONT_MODEL_SELECTOR);
|
||||
}
|
||||
|
||||
public static void setInferenceOntModelSelector(OntModelSelector oms, ServletContext ctx) {
|
||||
ctx.setAttribute(INFERENCE_ONT_MODEL_SELECTOR, oms);
|
||||
}
|
||||
|
||||
public static OntModel getJenaOntModel(ServletContext ctx) {
|
||||
return (OntModel) ctx.getAttribute(JENA_ONT_MODEL);
|
||||
}
|
||||
|
||||
public static void setJenaOntModel(OntModel ontModel, ServletContext ctx) {
|
||||
ctx.setAttribute(JENA_ONT_MODEL, ontModel);
|
||||
}
|
||||
|
||||
public static OntModel getBaseOntModel(ServletContext ctx) {
|
||||
return (OntModel) ctx.getAttribute(BASE_ONT_MODEL);
|
||||
}
|
||||
|
||||
public static void setBaseOntModel(OntModel ontModel, ServletContext ctx) {
|
||||
ctx.setAttribute(BASE_ONT_MODEL, ontModel);
|
||||
}
|
||||
|
||||
public static OntModel getInferenceOntModel(ServletContext ctx) {
|
||||
return (OntModel) ctx.getAttribute(INFERENCE_ONT_MODEL);
|
||||
}
|
||||
|
||||
public static void setInferenceOntModel(OntModel ontModel, ServletContext ctx) {
|
||||
ctx.setAttribute(INFERENCE_ONT_MODEL, ontModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a listener to the models needed to get changes to:
|
||||
* Basic abox statemetns:
|
||||
|
@ -113,10 +43,4 @@ public class ModelContext {
|
|||
|
||||
}
|
||||
|
||||
public static OntModel getDisplayModel(ServletContext ctx){
|
||||
return(OntModel) ctx.getAttribute( DisplayVocabulary.DISPLAY_ONT_MODEL );
|
||||
}
|
||||
public static void setDisplayModel(OntModel ontModel, ServletContext ctx){
|
||||
ctx.setAttribute(DisplayVocabulary.DISPLAY_ONT_MODEL,ontModel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.hp.hpl.jena.query.QueryExecutionFactory;
|
|||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
@ -38,6 +39,7 @@ import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
|||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
import com.hp.hpl.jena.sdb.util.Pair;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
|
@ -859,12 +861,16 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
}
|
||||
}
|
||||
|
||||
Map<ObjectProperty, String> customListViewConfigFileMap = null;
|
||||
//TODO private void addPropertyClassCombinationsToListViewMap(HashMap)
|
||||
|
||||
// Map key is pair of object property and range class URI
|
||||
// If range is unspecified, OWL.Thing.getURI() is used in the key.
|
||||
Map<Pair<ObjectProperty, String>, String> customListViewConfigFileMap = null;
|
||||
|
||||
@Override
|
||||
public String getCustomListViewConfigFileName(ObjectProperty op) {
|
||||
if (customListViewConfigFileMap == null) {
|
||||
customListViewConfigFileMap = new HashMap<ObjectProperty, String>();
|
||||
customListViewConfigFileMap = new HashMap<Pair<ObjectProperty, String>, String>();
|
||||
OntModel displayModel = getOntModelSelector().getDisplayModel();
|
||||
//Get all property to list view config file mappings in the system
|
||||
QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel);
|
||||
|
@ -883,12 +889,18 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
}
|
||||
} else {
|
||||
String filename = soln.getLiteral("filename").getLexicalForm();
|
||||
customListViewConfigFileMap.put(prop, filename);
|
||||
customListViewConfigFileMap.put(new Pair<ObjectProperty, String>(prop, OWL.Thing.getURI()), filename);
|
||||
}
|
||||
}
|
||||
qexec.close();
|
||||
}
|
||||
return customListViewConfigFileMap.get(op);
|
||||
|
||||
String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<ObjectProperty, String>(op, op.getRangeVClassURI()));
|
||||
if (customListViewConfigFileName == null) {
|
||||
customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<ObjectProperty, String>(op, OWL.Thing.getURI()));
|
||||
}
|
||||
|
||||
return customListViewConfigFileName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -271,6 +271,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
|||
String subjectUri,
|
||||
String propertyUri,
|
||||
String objectKey,
|
||||
String rangeUri,
|
||||
String queryString,
|
||||
Set<String> constructQueryStrings,
|
||||
String sortDirection) {
|
||||
|
@ -296,6 +297,9 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
|||
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
||||
initialBindings.add("subject", ResourceFactory.createResource(subjectUri));
|
||||
initialBindings.add("property", ResourceFactory.createResource(propertyUri));
|
||||
if (rangeUri != null) {
|
||||
initialBindings.add("objectType", ResourceFactory.createResource(rangeUri));
|
||||
}
|
||||
|
||||
// Run the SPARQL query to get the properties
|
||||
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
||||
|
|
|
@ -37,11 +37,7 @@ public interface OntModelSelector {
|
|||
public OntModel getTBoxModel();
|
||||
|
||||
/**
|
||||
* @param ontologyURI
|
||||
* @return OntModel containing TBox axioms for the specified ontology
|
||||
* @return OntModel containing all RDF statements in the Display model.
|
||||
*/
|
||||
public OntModel getTBoxModel(String ontologyURI);
|
||||
|
||||
public OntModel getDisplayModel();
|
||||
|
||||
}
|
||||
|
|
|
@ -38,11 +38,6 @@ public class OntModelSelectorImpl implements OntModelSelector {
|
|||
return this.tboxModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getTBoxModel(String ontologyURI) {
|
||||
return this.tboxModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getUserAccountsModel() {
|
||||
return this.userAccountsModel;
|
||||
|
|
|
@ -89,26 +89,27 @@ public class SimpleOntModelSelector implements OntModelSelector {
|
|||
this.fullModel = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getABoxModel() {
|
||||
return aboxModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getApplicationMetadataModel() {
|
||||
return applicationMetadataModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getFullModel() {
|
||||
return fullModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getTBoxModel() {
|
||||
return tboxModel;
|
||||
}
|
||||
|
||||
public OntModel getTBoxModel(String ontologyURI) {
|
||||
return tboxModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OntModel getUserAccountsModel() {
|
||||
return userAccountsModel;
|
||||
}
|
||||
|
@ -120,6 +121,7 @@ public class SimpleOntModelSelector implements OntModelSelector {
|
|||
public void setDisplayModel(OntModel displayModel) {
|
||||
this.displayModel = displayModel;
|
||||
}
|
||||
@Override
|
||||
public OntModel getDisplayModel(){
|
||||
return this.displayModel;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||
|
||||
|
||||
import com.hp.hpl.jena.ontology.AnnotationProperty;
|
||||
import com.hp.hpl.jena.ontology.OntClass;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
|
@ -13,9 +14,11 @@ import com.hp.hpl.jena.query.ResultSet;
|
|||
import com.hp.hpl.jena.query.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Statement;
|
||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
|
@ -53,9 +56,9 @@ public class VClassDaoSDB extends VClassDaoJena {
|
|||
try {
|
||||
if ((group != null) && (group.getURI() != null)) {
|
||||
Resource groupRes = ResourceFactory.createResource(group.getURI());
|
||||
AnnotationProperty inClassGroup = getOntModel().getAnnotationProperty(VitroVocabulary.IN_CLASSGROUP);
|
||||
Property inClassGroup = ResourceFactory.createProperty(VitroVocabulary.IN_CLASSGROUP);
|
||||
if (inClassGroup != null) {
|
||||
ClosableIterator annotIt = getOntModel().listStatements((OntClass)null,inClassGroup,groupRes);
|
||||
StmtIterator annotIt = getOntModel().listStatements((Resource)null,inClassGroup, groupRes);
|
||||
try {
|
||||
while (annotIt.hasNext()) {
|
||||
try {
|
||||
|
@ -91,7 +94,7 @@ public class VClassDaoSDB extends VClassDaoJena {
|
|||
Model aboxModel = getOntModelSelector().getABoxModel();
|
||||
aboxModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
ClosableIterator countIt = aboxModel.listStatements(null,RDF.type,cls);
|
||||
StmtIterator countIt = aboxModel.listStatements(null,RDF.type,cls);
|
||||
try {
|
||||
if (countIt.hasNext()) {
|
||||
classIsInstantiated = true;
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.hp.hpl.jena.vocabulary.RDFS;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
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.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
@ -173,12 +174,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
|||
}
|
||||
|
||||
protected VClassGroupDao getVCGDao() {
|
||||
WebappDaoFactory wdf = (WebappDaoFactory) context.getAttribute("webappDaoFactory");
|
||||
if (wdf == null) {
|
||||
log.error("Cannot get webappDaoFactory from context");
|
||||
return null;
|
||||
} else
|
||||
return wdf.getVClassGroupDao();
|
||||
return ModelAccess.on(context).getWebappDaoFactory().getVClassGroupDao();
|
||||
}
|
||||
|
||||
public void doSynchronousRebuild(){
|
||||
|
@ -241,11 +237,8 @@ public class VClassGroupCache implements IndexingEventListener {
|
|||
*/
|
||||
protected static void rebuildCacheUsingSolr( VClassGroupCache cache ) throws SolrServerException{
|
||||
long start = System.currentTimeMillis();
|
||||
WebappDaoFactory wdFactory = (WebappDaoFactory) cache.context.getAttribute("webappDaoFactory");
|
||||
if (wdFactory == null){
|
||||
log.error("Unable to rebuild cache: could not get 'webappDaoFactory' from Servletcontext");
|
||||
return;
|
||||
}
|
||||
WebappDaoFactory wdFactory = ModelAccess.on(cache.context).getWebappDaoFactory();
|
||||
|
||||
SolrServer solrServer = (SolrServer)cache.context.getAttribute(SolrSetup.SOLR_SERVER);
|
||||
if( solrServer == null){
|
||||
log.error("Unable to rebuild cache: could not get solrServer from ServletContext");
|
||||
|
@ -494,7 +487,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
|||
} else if(VitroVocabulary.DISPLAY_RANK.equals(stmt.getPredicate().getURI())){
|
||||
requestCacheUpdate();
|
||||
} else {
|
||||
OntModel jenaOntModel = ModelContext.getJenaOntModel(context);
|
||||
OntModel jenaOntModel = ModelAccess.on(context).getJenaOntModel();
|
||||
if( isClassNameChange(stmt, jenaOntModel) ) {
|
||||
requestCacheUpdate();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
|||
import com.hp.hpl.jena.util.iterator.WrappedIterator;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||
|
||||
/**
|
||||
|
@ -311,28 +312,11 @@ public class VitroJenaModelMaker implements ModelMaker {
|
|||
private Model getSpecialModel(String modelName) {
|
||||
if (request != null) {
|
||||
if ("vitro:jenaOntModel".equals(modelName)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("jenaOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
log.debug("Returning jenaOntModel from session");
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
log.debug("Returning jenaOntModel from context");
|
||||
return (OntModel) request.getSession().getServletContext().getAttribute("jenaOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getJenaOntModel();
|
||||
} else if ("vitro:baseOntModel".equals(modelName)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("baseOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
return (OntModel) request.getSession().getServletContext().getAttribute("baseOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getBaseOntModel();
|
||||
} else if ("vitro:inferenceOntModel".equals(modelName)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("inferenceOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
return (OntModel) request.getSession().getServletContext().getAttribute("inferenceOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getInferenceOntModel();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,12 +8,13 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.graph.GraphMaker;
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
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 edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
* Wraps a model maker and returns Models from the servlet context when
|
||||
* certain model URIs are requested
|
||||
|
@ -115,28 +116,11 @@ public class VitroJenaSpecialModelMaker implements ModelMaker {
|
|||
private Model getSpecialModel(String modelName) {
|
||||
if (request != null) {
|
||||
if ("vitro:jenaOntModel".equals(modelName)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("jenaOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
log.debug("Returning jenaOntModel from session");
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
log.debug("Returning jenaOntModel from context");
|
||||
return (OntModel) request.getSession().getServletContext().getAttribute("jenaOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getJenaOntModel();
|
||||
} else if ("vitro:baseOntModel".equals(modelName)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("baseOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
return (OntModel) request.getSession().getServletContext().getAttribute("baseOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getBaseOntModel();
|
||||
} else if ("vitro:inferenceOntModel".equals(modelName)) {
|
||||
Object sessionOntModel = request.getSession().getAttribute("inferenceOntModel");
|
||||
if (sessionOntModel != null && sessionOntModel instanceof OntModel) {
|
||||
return (OntModel) sessionOntModel;
|
||||
} else {
|
||||
return (OntModel) request.getSession().getServletContext().getAttribute("inferenceOntModel");
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getInferenceOntModel();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ import com.hp.hpl.jena.rdf.model.Model;
|
|||
import com.hp.hpl.jena.rdf.model.ModelReader;
|
||||
import com.hp.hpl.jena.rdf.model.ModelSource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
|
||||
/**
|
||||
* ModelSource that will handle specially named Vitro models such
|
||||
|
@ -106,15 +107,15 @@ public class VitroModelSource implements ModelSource {
|
|||
private Model getNamedModel( ModelName pmn ){
|
||||
switch( pmn ){
|
||||
case ABOX:
|
||||
return (Model) context.getAttribute("jenaOntModel");
|
||||
return ModelAccess.on(context).getJenaOntModel();
|
||||
case TBOX:
|
||||
return (Model) context.getAttribute("tboxmodel???");
|
||||
case DISPLAY:
|
||||
return (Model) context.getAttribute(DisplayVocabulary.DISPLAY_ONT_MODEL );
|
||||
return ModelAccess.on(context).getDisplayModel();
|
||||
case DISPLAY_TBOX:
|
||||
return (Model) context.getAttribute(DisplayVocabulary.CONTEXT_DISPLAY_TBOX);
|
||||
return ModelAccess.on(context).getOntModel(ModelID.DISPLAY_TBOX);
|
||||
case DISPLAY_DISPLAY:
|
||||
return (Model) context.getAttribute(DisplayVocabulary.CONTEXT_DISPLAY_DISPLAY);
|
||||
return ModelAccess.on(context).getOntModel(ModelID.DISPLAY_DISPLAY);
|
||||
case USER_ACCOUNTS:
|
||||
throw new IllegalArgumentException("getNamedModel() Does not yet handle USER_ACCOUNTS");
|
||||
default:
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.dwr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -18,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.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
This is a class to support Direct Web Remoting(DWR) in
|
||||
|
@ -31,7 +28,7 @@ public class EntityDWR {
|
|||
public EntityDWR(){
|
||||
WebContext ctx = WebContextFactory.get();
|
||||
ServletContext sc= ctx.getServletContext();
|
||||
entityWADao = ((WebappDaoFactory)sc.getAttribute("webappDaoFactory")).getIndividualDao();
|
||||
entityWADao = ModelAccess.on(sc).getWebappDaoFactory().getIndividualDao();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,8 +14,8 @@ 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.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
|
@ -23,6 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfigurationLoader;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
@ -189,7 +190,7 @@ public class EditConfigurationUtils {
|
|||
public static DataPropertyStatement getDataPropertyStatement(VitroRequest vreq, HttpSession session, Integer dataHash, String predicateUri) {
|
||||
DataPropertyStatement dps = null;
|
||||
if( dataHash != 0) {
|
||||
Model model = (Model)session.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
||||
dps = RdfLiteralHash.getPropertyStmtByHash(EditConfigurationUtils.getSubjectUri(vreq), predicateUri, dataHash, model);
|
||||
}
|
||||
return dps;
|
||||
|
|
|
@ -10,35 +10,15 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
|
||||
public class StandardModelSelector implements ModelSelector {
|
||||
|
||||
private static final Log log = LogFactory.getLog(StandardModelSelector.class);
|
||||
|
||||
public OntModel getModel(HttpServletRequest request, ServletContext context) {
|
||||
VitroRequest vreq = new VitroRequest( request );
|
||||
|
||||
Object sessionOntModel = null;
|
||||
if( vreq.getSession() != null) {
|
||||
OntModelSelector oms = (OntModelSelector) vreq.getSession()
|
||||
.getAttribute("unionOntModelSelector");
|
||||
if (oms != null) {
|
||||
sessionOntModel = oms.getABoxModel();
|
||||
}
|
||||
}
|
||||
if(sessionOntModel != null && sessionOntModel instanceof OntModel ) {
|
||||
log.debug("using OntModelSelector from session");
|
||||
return (OntModel)sessionOntModel;
|
||||
} else if (vreq.getOntModelSelector() != null) {
|
||||
log.debug("using OntModelSelector from request");
|
||||
return vreq.getOntModelSelector().getABoxModel();
|
||||
} else {
|
||||
log.debug("using OntModelSelector from context");
|
||||
return ((OntModelSelector) context
|
||||
.getAttribute("unionOntModelSelector")).getABoxModel();
|
||||
}
|
||||
return ModelAccess.on(request.getSession()).getOntModel(ModelID.UNION_ABOX);
|
||||
}
|
||||
|
||||
public static final ModelSelector selector = new StandardModelSelector();
|
||||
|
|
|
@ -4,8 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -13,13 +11,11 @@ import org.apache.commons.lang.StringUtils;
|
|||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
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.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.IdModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.ModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.StandardModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep;
|
||||
|
||||
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||
|
||||
|
@ -66,7 +62,7 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
|
|||
//setup the model selectors for query, write and display models on editConfig
|
||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||
|
||||
OntModel queryModel = vreq.getJenaOntModel(); // (OntModel)vreq.getAttribute("jenaOntModel");
|
||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
||||
|
||||
if( editConfig.getSubjectUri() == null)
|
||||
editConfig.setSubjectUri( EditConfigurationUtils.getSubjectUri(vreq));
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
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.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
|
@ -21,6 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
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.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
|
@ -350,7 +352,7 @@ public class DefaultAddMissingIndividualFormGenerator implements EditConfigurati
|
|||
|
||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
//Here, retrieve model from
|
||||
Model model = (Model) session.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
||||
//if object property
|
||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -24,13 +22,13 @@ import org.apache.solr.common.SolrDocumentList;
|
|||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
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.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
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.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
|
@ -377,7 +375,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
|
||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
//Here, retrieve model from
|
||||
Model model = (Model) session.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
||||
//if object property
|
||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
|
@ -408,18 +406,13 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
if(isSelectFromExisting(vreq)) {
|
||||
// set ProhibitedFromSearch object so picklist doesn't show
|
||||
// individuals from classes that should be hidden from list views
|
||||
//TODO: Check how model is retrieved
|
||||
OntModel displayOntModel =
|
||||
(OntModel) session.getServletContext()
|
||||
.getAttribute(DISPLAY_ONT_MODEL);
|
||||
if (displayOntModel != null) {
|
||||
OntModel displayOntModel = ModelAccess.on(session.getServletContext()).getDisplayModel();
|
||||
ProhibitedFromSearch pfs = new ProhibitedFromSearch(
|
||||
DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel);
|
||||
if( editConfig != null )
|
||||
editConfig.setProhibitedFromSearch(pfs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Form specific data
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.hp.hpl.jena.vocabulary.XSD;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
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.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
@ -207,7 +208,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
|||
void prepare(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
||||
//setup the model selectors for query, write and display models on editConfig
|
||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||
OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel");
|
||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
||||
if (editConfig.isParamUpdate()) {
|
||||
editConfig.prepareForParamUpdate(queryModel);
|
||||
|
||||
|
@ -224,7 +225,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
|||
if (editConfig.isParamUpdate()) {
|
||||
//setup the model selectors for query, write and display models on editConfig
|
||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||
OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel");
|
||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
||||
retrieveExistingDataGetterInfo(context, editConfig, queryModel);
|
||||
}
|
||||
|
||||
|
@ -589,7 +590,8 @@ private String getExistingIsSelfContainedTemplateQuery() {
|
|||
int maxMenuPosition = 0;
|
||||
Literal menuPosition = null;
|
||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||
OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel");
|
||||
OntModel queryModel = ModelAccess.on(vreq).getJenaOntModel();
|
||||
|
||||
String maxMenuPositionQuery = getMaxMenuPositionQueryString();
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
|
|
|
@ -10,13 +10,14 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
import com.hp.hpl.jena.vocabulary.XSD;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
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.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
|
@ -239,7 +240,7 @@ public class NewIndividualFormGenerator implements EditConfigurationGenerator {
|
|||
|
||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
//Here, retrieve model from
|
||||
Model model = (Model) session.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
||||
//This form is always doing a non-update
|
||||
editConfiguration.prepareForNonUpdate( model );
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ 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.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.vocabulary.XSD;
|
||||
|
@ -21,6 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
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.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
|
@ -297,7 +299,7 @@ public class RDFSLabelGenerator implements EditConfigurationGenerator {
|
|||
|
||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
//Here, retrieve model from
|
||||
Model model = (Model) session.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel model = ModelAccess.on(session.getServletContext()).getJenaOntModel();
|
||||
if( editConfiguration.isDataPropertyUpdate() ){
|
||||
editConfiguration.prepareForDataPropUpdate(model, vreq.getWebappDaoFactory().getDataPropertyDao());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,354 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.filters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.collections.EnumerationUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrServer;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
|
||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.FieldMap;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResultsParser;
|
||||
|
||||
/**
|
||||
* Assist in cache management for individual profile pages.
|
||||
*
|
||||
* Only works for users who are not logged in.
|
||||
*
|
||||
* The Solr index must be configured to keep an ETAG on each individual's
|
||||
* record. The ETAG is a hash of the record's content and is updated each time
|
||||
* the individual is re-indexed.
|
||||
*
|
||||
* But this ETAG is not sufficient, since the page may have different versions
|
||||
* for different languages. So we append a hash of the Locales from the request
|
||||
* to the ETAG to make it unique. NOTE: If we allow users to choose their
|
||||
* preferred languages, the LocalSelectionFilter must execute before this one.
|
||||
*
|
||||
* When an external cache (e.g. Squid) is asked for an individual's profile
|
||||
* page, it will ask VIVO whether the version in the cache is still current, and
|
||||
* to provide a new version if it is not. This is a conditional request.
|
||||
*
|
||||
* When a conditional request is received, this filter will check to see whether
|
||||
* the request is on behalf of a logged-in user. If so, a fresh response is
|
||||
* generated, with a Cache-Control header that should prevent the cache from
|
||||
* storing that response.
|
||||
*
|
||||
* If the requesting user is not logged in, this filter will ask Solr for the
|
||||
* ETAG on the requested individual. If it is the same as the ETAG supplied by
|
||||
* the cache in the request, then the response is 304 Not Modified. Otherwise, a
|
||||
* fresh response is generated.
|
||||
*
|
||||
* An unconditional request may mean that there is no external cache, or that
|
||||
* the cache doesn't have a copy of this particular page.
|
||||
*
|
||||
* @see http://tools.ietf.org/pdf/rfc2616
|
||||
*/
|
||||
public class CachingResponseFilter implements Filter {
|
||||
private static final Log log = LogFactory
|
||||
.getLog(CachingResponseFilter.class);
|
||||
|
||||
private static final String PROPERTY_DEFAULT_NAMESPACE = "Vitro.defaultNamespace";
|
||||
private static final String ETAG_FIELD = "etag";
|
||||
|
||||
private static final FieldMap parserFieldMap = SolrQueryUtils.fieldMap()
|
||||
.put(ETAG_FIELD, ETAG_FIELD);
|
||||
|
||||
private ServletContext ctx;
|
||||
private String defaultNamespace;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig fc) throws ServletException {
|
||||
ctx = fc.getServletContext();
|
||||
defaultNamespace = ConfigurationProperties.getBean(ctx).getProperty(
|
||||
PROPERTY_DEFAULT_NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// Nothing to tear down.
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an HTTP request.
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
|
||||
/*
|
||||
* If this request is not for a profile page, or if the individual
|
||||
* doesn't appear in the search index, create a basic, cache-neutral
|
||||
* response.
|
||||
*/
|
||||
String individualUri = figureIndividualUriFromRequest(req);
|
||||
if (individualUri == null) {
|
||||
produceBasicResponse(req, resp, chain);
|
||||
return;
|
||||
}
|
||||
String rawEtag = findEtagForIndividual(individualUri);
|
||||
String etag = produceLanguageSpecificEtag(req, rawEtag);
|
||||
if (etag == null) {
|
||||
produceBasicResponse(req, resp, chain);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a logged-in user asks for an individual profile page, the response
|
||||
* should not come from the cache, nor should it be stored in the cache.
|
||||
*/
|
||||
if (userIsLoggedIn(req)) {
|
||||
produceUncacheableResponse(req, resp, chain);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the request is not conditional then there is no cached version of
|
||||
* this page. If the request is conditional and the condition is met,
|
||||
* then the cached version is stale. In either case, create a fresh
|
||||
* response to be stored in the cache.
|
||||
*/
|
||||
if (!isConditionalRequest(req)) {
|
||||
produceCacheableResponse(req, resp, chain, etag);
|
||||
return;
|
||||
}
|
||||
if (cacheIsStale(req, etag)) {
|
||||
produceCacheableResponse(req, resp, chain, etag);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the request is conditional and the condition is not met
|
||||
* (individual has not changed), send a "not-modified" response, so the
|
||||
* cached version will be used.
|
||||
*/
|
||||
produceCacheHitResponse(resp, etag);
|
||||
}
|
||||
|
||||
private boolean isConditionalRequest(HttpServletRequest req) {
|
||||
if (req.getHeader("If-None-Match") == null) {
|
||||
log.debug("Not conditional request.");
|
||||
return false;
|
||||
} else {
|
||||
log.debug("Conditional request.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean userIsLoggedIn(HttpServletRequest req) {
|
||||
UserAccount currentUser = LoginStatusBean.getCurrentUser(req);
|
||||
if (currentUser == null) {
|
||||
log.debug("Not logged in.");
|
||||
return false;
|
||||
} else {
|
||||
log.debug("Logged in as '" + currentUser.getEmailAddress() + "'");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This rejects some of the requests as being obviously not individuals, and
|
||||
* then assumes that the last part of any request is a Localname.
|
||||
*
|
||||
* This is not always true, of course, but it will work because we will
|
||||
* prepend the default namespace and look for the resulting "URI" in the URI
|
||||
* field of the search index. If we find it there, then it is valid.
|
||||
*
|
||||
* If we were to make this more rigorous, it would reduce the number of
|
||||
* unnecessary searches.
|
||||
*/
|
||||
private String figureIndividualUriFromRequest(HttpServletRequest req) {
|
||||
String requestPath = req.getRequestURI();
|
||||
if (requestPath == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!mightBeProfileRequest(requestPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] pathParts = requestPath.split("/");
|
||||
String uri = defaultNamespace + pathParts[pathParts.length - 1];
|
||||
|
||||
log.debug("Request path = '" + requestPath + "', uri = '" + uri + "'");
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests for profile pages come in many forms, but we can still narrow
|
||||
* them down.
|
||||
*
|
||||
* Eliminate CSS files, JavaScript files, and images.
|
||||
*
|
||||
* That leaves these acceptable forms:
|
||||
*
|
||||
* <pre>
|
||||
* /individual?uri=urlencodedURI
|
||||
* /individual?netId=bdc34
|
||||
* /individual?netid=bdc34
|
||||
* /individual/localname
|
||||
* /display/localname
|
||||
* /individual/localname/localname.rdf
|
||||
* /individual/localname/localname.n3
|
||||
* /individual/localname/localname.ttl
|
||||
* </pre>
|
||||
*/
|
||||
private boolean mightBeProfileRequest(String requestPath) {
|
||||
String path = requestPath.toLowerCase();
|
||||
String[] extensions = { ".css", ".js", ".gif", ".png", ".jpg", ".jpeg" };
|
||||
for (String ext : extensions) {
|
||||
if (path.endsWith(ext)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return requestPath.endsWith("/individual")
|
||||
|| requestPath.contains("/individual/")
|
||||
|| requestPath.contains("/display/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask Solr whether it has an ETAG for this URI.
|
||||
*/
|
||||
private String findEtagForIndividual(String individualUri) {
|
||||
SolrQuery query = new SolrQuery("URI:" + individualUri)
|
||||
.setFields(ETAG_FIELD);
|
||||
|
||||
SolrServer solr = SolrSetup.getSolrServer(ctx);
|
||||
|
||||
try {
|
||||
QueryResponse response = solr.query(query);
|
||||
List<Map<String, String>> maps = new SolrResultsParser(response,
|
||||
parserFieldMap).parse();
|
||||
log.debug("Solr response for '" + query.getQuery() + "' was "
|
||||
+ maps);
|
||||
|
||||
if (maps.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return maps.get(0).get(ETAG_FIELD);
|
||||
}
|
||||
} catch (SolrServerException e) {
|
||||
log.warn(
|
||||
"Solr query '" + query.getQuery() + "' threw an exception",
|
||||
e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The ETAG from the Solr index is not specific enough, since we may have
|
||||
* different versions for different languages. Add the Locales from the
|
||||
* request to make it unique.
|
||||
*/
|
||||
private String produceLanguageSpecificEtag(HttpServletRequest req,
|
||||
String rawEtag) {
|
||||
if (rawEtag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Locale> locales = EnumerationUtils.toList(req.getLocales());
|
||||
|
||||
StringBuilder buffer = new StringBuilder('"').append(rawEtag);
|
||||
for (Locale locale : locales) {
|
||||
buffer.append(locale.toString()).append(" ");
|
||||
}
|
||||
buffer.append('"');
|
||||
|
||||
String etag = buffer.toString();
|
||||
log.debug("Language-specific ETAG = " + etag);
|
||||
return etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the etag does not match any of the etags in any of the "If-None-Match"
|
||||
* headers, then they are all stale. An asterisk matches anything.
|
||||
*/
|
||||
private boolean cacheIsStale(HttpServletRequest req, String etag) {
|
||||
for (Enumeration<?> values = req.getHeaders("If-None-Match"); values
|
||||
.hasMoreElements();) {
|
||||
String value = (String) values.nextElement();
|
||||
log.debug("If-None-Match: " + value);
|
||||
|
||||
String[] matches = value.split("\\s*,\\s*");
|
||||
for (String match : matches) {
|
||||
if (etag.equalsIgnoreCase(match) || "*".equals(match)) {
|
||||
log.debug("Cache is not stale: etag=" + match);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("Cache is stale.");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void produceBasicResponse(HttpServletRequest req,
|
||||
HttpServletResponse resp, FilterChain chain) throws IOException,
|
||||
ServletException {
|
||||
chain.doFilter(req, resp);
|
||||
}
|
||||
|
||||
private void produceUncacheableResponse(HttpServletRequest req,
|
||||
HttpServletResponse resp, FilterChain chain) throws IOException,
|
||||
ServletException {
|
||||
String etag = generateArbitraryUniqueEtag(req);
|
||||
log.debug("Produce uncacheable response: etag='" + etag + "'");
|
||||
|
||||
resp.addHeader("ETag", etag);
|
||||
resp.addHeader("Vary", "*");
|
||||
resp.addHeader("Cache-Control", "no-store");
|
||||
chain.doFilter(req, resp);
|
||||
}
|
||||
|
||||
private void produceCacheableResponse(HttpServletRequest req,
|
||||
HttpServletResponse resp, FilterChain chain, String etag)
|
||||
throws IOException, ServletException {
|
||||
log.debug("Produce cacheable response: etag='" + etag + "'");
|
||||
resp.addHeader("ETag", etag);
|
||||
resp.addHeader("Vary", "Accept-Language");
|
||||
chain.doFilter(req, resp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Technically, if the request is not GET or HEAD, we should return 412
|
||||
* PreconditionFailed. However, we usually treat GET and POST as equivalent.
|
||||
*/
|
||||
private void produceCacheHitResponse(HttpServletResponse resp, String etag)
|
||||
throws IOException {
|
||||
log.debug("Produce cache hit response: etag='" + etag + "'");
|
||||
resp.addHeader("ETag", etag);
|
||||
resp.addHeader("Vary", "Accept-Language");
|
||||
resp.sendError(HttpServletResponse.SC_NOT_MODIFIED, "Not Modified");
|
||||
}
|
||||
|
||||
private String generateArbitraryUniqueEtag(HttpServletRequest req) {
|
||||
return String.format("%s-%d", req.getSession().getId(),
|
||||
System.currentTimeMillis());
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ import javax.servlet.Filter;
|
|||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
@ -21,6 +22,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
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.WebappDaoFactory;
|
||||
/**
|
||||
|
@ -52,7 +54,9 @@ public class PageRoutingFilter implements Filter{
|
|||
@Override
|
||||
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
PageDao pageDao = getPageDao();
|
||||
ServletContext ctx = filterConfig.getServletContext();
|
||||
|
||||
PageDao pageDao = ModelAccess.on(ctx).getWebappDaoFactory().getPageDao();
|
||||
Map<String,String> urlMappings = pageDao.getPageMappings();
|
||||
|
||||
// get URL without hostname or servlet context
|
||||
|
@ -81,7 +85,7 @@ public class PageRoutingFilter implements Filter{
|
|||
String controllerName = getControllerToForwardTo(req, pageUri, pageDao);
|
||||
log.debug(path + " is being forwarded to controller " + controllerName);
|
||||
|
||||
RequestDispatcher rd = filterConfig.getServletContext().getNamedDispatcher( controllerName );
|
||||
RequestDispatcher rd = ctx.getNamedDispatcher( controllerName );
|
||||
if( rd == null ){
|
||||
log.error(path + " should be forwarded to controller " + controllerName + " but there " +
|
||||
"is no servlet named that defined for the web application in web.xml");
|
||||
|
@ -91,7 +95,7 @@ public class PageRoutingFilter implements Filter{
|
|||
rd.forward(req, response);
|
||||
}else if( "/".equals( path ) || path.isEmpty() ){
|
||||
log.debug("url '" +path + "' is being forward to home controller" );
|
||||
RequestDispatcher rd = filterConfig.getServletContext().getNamedDispatcher( HOME_CONTROLLER_NAME );
|
||||
RequestDispatcher rd = ctx.getNamedDispatcher( HOME_CONTROLLER_NAME );
|
||||
rd.forward(req, response);
|
||||
}else{
|
||||
doNonDisplayPage(path,arg0,arg1,chain);
|
||||
|
@ -132,12 +136,6 @@ public class PageRoutingFilter implements Filter{
|
|||
return false;
|
||||
}
|
||||
|
||||
protected PageDao getPageDao(){
|
||||
WebappDaoFactory wdf = (WebappDaoFactory)
|
||||
filterConfig.getServletContext().getAttribute("webappDaoFactory");
|
||||
return wdf.getPageDao();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
//nothing to do here
|
||||
|
|
|
@ -21,7 +21,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
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.startup.StartupStatus;
|
||||
import freemarker.cache.WebappTemplateLoader;
|
||||
|
@ -116,8 +116,7 @@ public class StartupStatusDisplayFilter implements Filter {
|
|||
private Object getApplicationName() {
|
||||
String name = "";
|
||||
try {
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) ctx
|
||||
.getAttribute("webappDaoFactory");
|
||||
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
ApplicationBean app = wadf.getApplicationDao().getApplicationBean();
|
||||
name = app.getApplicationName();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.util.List;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
@ -18,6 +17,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.openrdf.model.URI;
|
||||
import org.openrdf.model.impl.URIImpl;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory;
|
||||
|
@ -36,7 +36,7 @@ public class URLRewritingHttpServletResponse extends HttpServletResponseWrapper/
|
|||
super(response);
|
||||
this._response = response;
|
||||
this._context = context;
|
||||
this.wadf = (WebappDaoFactory) context.getAttribute("webappDaoFactory");
|
||||
this.wadf = ModelAccess.on(context).getWebappDaoFactory();
|
||||
this.contextPathDepth = slashPattern.split(request.getContextPath()).length-1;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.filters;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.controller.VitroRequest.SPECIAL_WRITE_MODEL;
|
||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.CONTEXT_DISPLAY_TBOX;
|
||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL;
|
||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.SWITCH_TO_DISPLAY_MODEL;
|
||||
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;
|
||||
|
@ -41,15 +39,17 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
|||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FilterFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.HideFromDisplayByPolicyFilter;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
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.WebappDaoFactorySDB;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||
|
||||
|
@ -123,14 +123,15 @@ public class VitroRequestPrep implements Filter {
|
|||
VitroRequest vreq = new VitroRequest(req);
|
||||
|
||||
//-- setup DAO factory --//
|
||||
WebappDaoFactory wdf = getWebappDaoFactory(vreq);
|
||||
//TODO: get accept-language from request and set as preferred languages
|
||||
WebappDaoFactory wdf = ModelAccess.on(vreq.getSession()).getWebappDaoFactory();
|
||||
|
||||
// if there is a WebappDaoFactory in the session, use it
|
||||
Object o = req.getSession().getAttribute("webappDaoFactory");
|
||||
if (o instanceof WebappDaoFactory) {
|
||||
wdf = (WebappDaoFactory) o;
|
||||
log.debug("Found a WebappDaoFactory in the session and using it for this request");
|
||||
// Set up the DisplayModel with language filtering, if appropriate.
|
||||
ConfigurationProperties props = ConfigurationProperties.getBean(req);
|
||||
Boolean languageFilteringEnabled = Boolean.valueOf(props.getProperty("RDFService.languageFilter", "true"));
|
||||
if (languageFilteringEnabled) {
|
||||
OntModel displayModel = ModelAccess.on(req.getSession()).getDisplayModel();
|
||||
OntModel filteredDisplayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(displayModel, req);
|
||||
ModelAccess.on(req).setDisplayModel(filteredDisplayModel);
|
||||
}
|
||||
|
||||
//Do model switching and replace the WebappDaoFactory with
|
||||
|
@ -151,7 +152,7 @@ public class VitroRequestPrep implements Filter {
|
|||
HideFromDisplayByPolicyFilter filter = new HideFromDisplayByPolicyFilter(
|
||||
RequestIdentifiers.getIdBundleForRequest(req),
|
||||
ServletPolicyList.getPolicies(_context));
|
||||
vreq.setWebappDaoFactory(new WebappDaoFactoryFiltering(wdf, filter));
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(new WebappDaoFactoryFiltering(wdf, filter));
|
||||
|
||||
// support for Dataset interface if using Jena in-memory model
|
||||
if (vreq.getDataset() == null) {
|
||||
|
@ -165,20 +166,13 @@ public class VitroRequestPrep implements Filter {
|
|||
if (vreq.getUnfilteredWebappDaoFactory() == null) {
|
||||
vreq.setUnfilteredWebappDaoFactory(new WebappDaoFactorySDB(
|
||||
RDFServiceUtils.getRDFServiceFactory(ctx).getRDFService(),
|
||||
ModelContext.getUnionOntModelSelector(
|
||||
ctx)));
|
||||
ModelAccess.on(ctx).getUnionOntModelSelector()));
|
||||
}
|
||||
|
||||
req.setAttribute("VitroRequestPrep.setup", new Integer(1));
|
||||
chain.doFilter(req, response);
|
||||
}
|
||||
|
||||
private WebappDaoFactory getWebappDaoFactory(VitroRequest vreq){
|
||||
WebappDaoFactory webappDaoFactory = vreq.getWebappDaoFactory();
|
||||
return (webappDaoFactory != null) ? webappDaoFactory :
|
||||
(WebappDaoFactory) _context.getAttribute("webappDaoFactory");
|
||||
}
|
||||
|
||||
private VitroFilters getFiltersFromContextFilterFactory( HttpServletRequest request, WebappDaoFactory wdf){
|
||||
FilterFactory ff = (FilterFactory)_context.getAttribute("FilterFactory");
|
||||
if( ff == null ){
|
||||
|
@ -224,8 +218,8 @@ public class VitroRequestPrep implements Filter {
|
|||
|
||||
// If they asked for the display model, give it to them.
|
||||
if (isParameterPresent(vreq, SWITCH_TO_DISPLAY_MODEL)) {
|
||||
OntModel mainOntModel = (OntModel)_context.getAttribute( DISPLAY_ONT_MODEL);
|
||||
OntModel tboxOntModel = (OntModel) _context.getAttribute(CONTEXT_DISPLAY_TBOX);
|
||||
OntModel mainOntModel = ModelAccess.on(_context).getDisplayModel();
|
||||
OntModel tboxOntModel = ModelAccess.on(_context).getOntModel(ModelID.DISPLAY_TBOX);
|
||||
setSpecialWriteModel(vreq, mainOntModel);
|
||||
|
||||
vreq.setAttribute(VitroRequest.ID_FOR_ABOX_MODEL, VitroModelSource.ModelName.DISPLAY.toString());
|
||||
|
@ -302,7 +296,7 @@ public class VitroRequestPrep implements Filter {
|
|||
|
||||
private void setSpecialWriteModel(VitroRequest vreq, OntModel mainOntModel) {
|
||||
if (mainOntModel != null) {
|
||||
vreq.setAttribute("jenaOntModel", mainOntModel);
|
||||
ModelAccess.on(vreq).setJenaOntModel(mainOntModel);
|
||||
vreq.setAttribute(SPECIAL_WRITE_MODEL, mainOntModel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.filters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -22,15 +19,16 @@ 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.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
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.WebappDaoFactoryConfig;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
||||
|
@ -38,6 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetM
|
|||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
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;
|
||||
|
||||
public class WebappDaoFactorySDBPrep implements Filter {
|
||||
|
@ -83,23 +82,13 @@ public class WebappDaoFactorySDBPrep implements Filter {
|
|||
}
|
||||
}
|
||||
|
||||
OntModelSelector oms = ModelContext.getUnionOntModelSelector(_ctx);
|
||||
OntModelSelector baseOms = ModelContext.getBaseOntModelSelector(_ctx);
|
||||
String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace");
|
||||
WebappDaoFactory wadf = null;
|
||||
VitroRequest vreq = new VitroRequest((HttpServletRequest) request);
|
||||
|
||||
List<String> langs = new ArrayList<String>();
|
||||
|
||||
log.debug("Accept-Language: " + vreq.getHeader("Accept-Language"));
|
||||
Enumeration<Locale> locs = vreq.getLocales();
|
||||
while (locs.hasMoreElements()) {
|
||||
Locale locale = locs.nextElement();
|
||||
langs.add(locale.toString().replace("_", "-"));
|
||||
}
|
||||
if (langs.isEmpty()) {
|
||||
langs.add("en");
|
||||
}
|
||||
List<String> langs = LanguageFilteringUtils.localesToLanguages(vreq.getLocales());
|
||||
|
||||
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
||||
config.setDefaultNamespace(defaultNamespace);
|
||||
config.setPreferredLanguages(langs);
|
||||
|
@ -110,30 +99,36 @@ public class WebappDaoFactorySDBPrep implements Filter {
|
|||
RDFService unfilteredRDFService = factory.getShortTermRDFService();
|
||||
RDFService rdfService = null;
|
||||
|
||||
if (!"false".equals(
|
||||
ConfigurationProperties.getBean(vreq).getProperty(
|
||||
if (Boolean.valueOf(ConfigurationProperties.getBean(vreq).getProperty(
|
||||
"RDFService.languageFilter", "true"))) {
|
||||
rdfService = new LanguageFilteringRDFService(unfilteredRDFService, langs);
|
||||
|
||||
OntModel rawDisplayModel = ModelAccess.on(vreq.getSession()).getDisplayModel();
|
||||
OntModel filteredDisplayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(rawDisplayModel, request);
|
||||
ModelAccess.on(vreq).setDisplayModel(filteredDisplayModel);
|
||||
} else {
|
||||
rdfService = unfilteredRDFService;
|
||||
}
|
||||
|
||||
Dataset dataset = new RDFServiceDataset(rdfService);
|
||||
|
||||
OntModelSelector oms = ModelAccess.on(_ctx).getUnionOntModelSelector();
|
||||
wadf = new WebappDaoFactorySDB(rdfService, oms, config);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(wadf);
|
||||
|
||||
OntModelSelector baseOms = ModelAccess.on(_ctx).getBaseOntModelSelector();
|
||||
WebappDaoFactory assertions = new WebappDaoFactorySDB(
|
||||
rdfService, baseOms, config, SDBDatasetMode.ASSERTIONS_ONLY);
|
||||
|
||||
vreq.setRDFService(rdfService);
|
||||
vreq.setUnfilteredRDFService(unfilteredRDFService);
|
||||
vreq.setWebappDaoFactory(wadf);
|
||||
vreq.setAssertionsWebappDaoFactory(assertions);
|
||||
vreq.setFullWebappDaoFactory(wadf);
|
||||
ModelAccess.on(vreq).setBaseWebappDaoFactory(assertions);
|
||||
vreq.setUnfilteredWebappDaoFactory(new WebappDaoFactorySDB(
|
||||
rdfService, ModelContext.getUnionOntModelSelector(_ctx)));
|
||||
rdfService, ModelAccess.on(_ctx).getUnionOntModelSelector()));
|
||||
vreq.setDataset(dataset);
|
||||
vreq.setOntModelSelector(baseOms);
|
||||
|
||||
vreq.setJenaOntModel(ModelFactory.createOntologyModel(
|
||||
OntModelSpec.OWL_MEM, dataset.getDefaultModel()));
|
||||
ModelAccess.on(vreq).setJenaOntModel(
|
||||
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getDefaultModel()));
|
||||
|
||||
request.setAttribute("WebappDaoFactorySDBPrep.setup", 1);
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ 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.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.query.DataSource;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.query.DatasetFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
@ -39,10 +38,11 @@ import com.hp.hpl.jena.sdb.sql.SDBConnection;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.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.SingleContentOntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SparqlDatasetGraph;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SparqlGraphMultilingual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||
|
@ -93,7 +93,6 @@ public class WebappDaoFactorySparqlPrep implements Filter {
|
|||
|
||||
javax.sql.DataSource ds = JenaDataSourceSetupBase.getApplicationDataSource(_ctx);
|
||||
StoreDesc storeDesc = (StoreDesc) _ctx.getAttribute("storeDesc");
|
||||
OntModelSelector oms = (OntModelSelector) _ctx.getAttribute("unionOntModelSelector");
|
||||
String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace");
|
||||
Connection sqlConn = null;
|
||||
SDBConnection conn = null;
|
||||
|
@ -102,7 +101,7 @@ public class WebappDaoFactorySparqlPrep implements Filter {
|
|||
WebappDaoFactory wadf = null;
|
||||
|
||||
try {
|
||||
if (ds == null || storeDesc == null || oms == null) {
|
||||
if (ds == null || storeDesc == null) {
|
||||
throw new RuntimeException("SDB store not property set up");
|
||||
}
|
||||
|
||||
|
@ -147,25 +146,18 @@ public class WebappDaoFactorySparqlPrep implements Filter {
|
|||
|
||||
Model m = ModelFactory.createModelForGraph(g);
|
||||
OntModel om = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, m);
|
||||
oms = new SingleContentOntModelSelector(om, oms.getDisplayModel(), oms.getUserAccountsModel());
|
||||
ModelAccess.on(vreq).setOntModel(ModelID.UNION_ABOX, om);
|
||||
ModelAccess.on(vreq).setOntModel(ModelID.UNION_TBOX, om);
|
||||
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, om);
|
||||
|
||||
OntModelSelector oms = ModelAccess.on(vreq).getOntModelSelector();
|
||||
wadf = new WebappDaoFactoryJena(oms, config);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(wadf);
|
||||
ModelAccess.on(vreq).setBaseWebappDaoFactory(wadf);
|
||||
vreq.setUnfilteredWebappDaoFactory(wadf);
|
||||
|
||||
dataset = DatasetFactory.create(new SparqlDatasetGraph(endpointURI));
|
||||
|
||||
//DataSource datasource = DatasetFactory.create();
|
||||
//datasource.addNamedModel("fake:fake", m);
|
||||
//dataset = datasource;
|
||||
|
||||
vreq.setAssertionsWebappDaoFactory(wadf);
|
||||
|
||||
wadf = new WebappDaoFactoryJena(oms, config);
|
||||
//wadf = new WebappDaoFactorySDB(oms, dataset, config);
|
||||
vreq.setWebappDaoFactory(wadf);
|
||||
vreq.setFullWebappDaoFactory(wadf);
|
||||
vreq.setUnfilteredWebappDaoFactory(wadf);
|
||||
vreq.setWebappDaoFactory(wadf);
|
||||
vreq.setDataset(dataset);
|
||||
vreq.setJenaOntModel(om);
|
||||
vreq.setOntModelSelector(oms);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
log.error("Unable to filter request to set up SDB connection", t);
|
||||
|
|
|
@ -8,8 +8,10 @@ import java.io.InputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -368,17 +370,20 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
|
||||
int index = langs.indexOf(lang);
|
||||
if (index >= 0) {
|
||||
log.debug("languageIndex for '" + lang + "' is " + index);
|
||||
return index;
|
||||
}
|
||||
|
||||
if (lang.length() > 2) {
|
||||
index = langs.indexOf(lang.substring(0, 2));
|
||||
if (index >= 0) {
|
||||
log.debug("languageIndex for '" + lang + "' is " + index + inexactMatchPenalty);
|
||||
return index + inexactMatchPenalty;
|
||||
}
|
||||
}
|
||||
|
||||
if (lang.isEmpty()) {
|
||||
log.debug("languageIndex for '" + lang + "' is " + noLanguage);
|
||||
return noLanguage;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.rdfservice.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||
|
||||
/**
|
||||
* Some methods that will come in handy when dealing with Language Filtering
|
||||
*/
|
||||
public class LanguageFilteringUtils {
|
||||
|
||||
/**
|
||||
* Take an Enumeration of Locale objects, such as we might get from a
|
||||
* request, and convert to a List of langauage strings, such as are needed
|
||||
* by the LanguageFilteringRDFService.
|
||||
*
|
||||
* While converting, change all underscores (as in Locale names) to hyphens
|
||||
* (as in RDF language specifiers).
|
||||
*/
|
||||
public static List<String> localesToLanguages(Enumeration<?> locales) {
|
||||
List<String> langs = new ArrayList<>();
|
||||
while (locales.hasMoreElements()) {
|
||||
Locale locale = (Locale) locales.nextElement();
|
||||
langs.add(locale.toString().replace("_", "-"));
|
||||
}
|
||||
if (langs.isEmpty()) {
|
||||
langs.add("en");
|
||||
}
|
||||
return langs;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Language Filtering layer to an OntModel by treating it as an RDFService.
|
||||
*/
|
||||
public static OntModel wrapOntModelInALanguageFilter(OntModel rawModel,
|
||||
ServletRequest req) {
|
||||
/** This is some nasty layering. Could we do this more easily? */
|
||||
List<String> languages = localesToLanguages(req.getLocales());
|
||||
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
|
||||
RDFServiceGraph.createRDFServiceModel(
|
||||
new RDFServiceGraph(
|
||||
new LanguageFilteringRDFService(
|
||||
new RDFServiceModel(rawModel), languages))));
|
||||
}
|
||||
|
||||
private LanguageFilteringUtils() {
|
||||
// Nothing to instantiate
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
@ -11,19 +10,16 @@ import java.util.List;
|
|||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.solr.client.solrj.SolrServer;
|
||||
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
|
||||
import org.apache.solr.client.solrj.impl.XMLResponseParser;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
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.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
|
||||
|
@ -31,8 +27,6 @@ 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.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.FileBasedProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForContextNodes;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForDataProperties;
|
||||
|
@ -119,8 +113,8 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
|||
context.setAttribute(SOLR_SERVER, server);
|
||||
|
||||
/* set up the individual to solr doc translation */
|
||||
OntModel jenaOntModel = ModelContext.getJenaOntModel(context);
|
||||
Model displayModel = ModelContext.getDisplayModel(context);
|
||||
OntModel jenaOntModel = ModelAccess.on(context).getJenaOntModel();
|
||||
OntModel displayModel = ModelAccess.on(context).getDisplayModel();
|
||||
|
||||
/* try to get context attribute DocumentModifiers
|
||||
* and use that as the start of the list of DocumentModifier
|
||||
|
@ -161,7 +155,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
|||
// This is where the builder gets the list of places to try to
|
||||
// get objects to index. It is filtered so that non-public text
|
||||
// does not get into the search index.
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) context.getAttribute("webappDaoFactory");
|
||||
WebappDaoFactory wadf = ModelAccess.on(context).getWebappDaoFactory();
|
||||
VitroFilters vf = VitroFilterUtils.getPublicFilter(context);
|
||||
wadf = new WebappDaoFactoryFiltering(wadf, vf);
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import javax.servlet.ServletContextEvent;
|
|||
import javax.servlet.ServletContextListener;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -23,7 +22,8 @@ import com.hp.hpl.jena.query.QueryFactory;
|
|||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
|
@ -64,7 +64,7 @@ implements ServletContextListener {
|
|||
OntModel displayModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC);
|
||||
displayModel.add(displayDbModel);
|
||||
displayModel.getBaseModel().register(new ModelSynchronizer(displayDbModel));
|
||||
ModelContext.setDisplayModel(displayModel, ctx);
|
||||
ModelAccess.on(ctx).setDisplayModel(displayModel);
|
||||
|
||||
//at each startup load all RDF files from directory to sub-models of display model
|
||||
initializeDisplayLoadedAtStartup(ctx, displayModel);
|
||||
|
@ -84,7 +84,7 @@ implements ServletContextListener {
|
|||
MEM_ONT_MODEL_SPEC);
|
||||
appTBOXModel.add(displayTboxModel);
|
||||
appTBOXModel.getBaseModel().register(new ModelSynchronizer(displayTboxModel));
|
||||
ctx.setAttribute("displayOntModelTBOX", appTBOXModel);
|
||||
ModelAccess.on(ctx).setOntModel(ModelID.DISPLAY_TBOX, appTBOXModel);
|
||||
log.debug("Loaded file " + APPPATH_LOAD + "displayTBOX.n3 into display tbox model");
|
||||
} catch (Throwable t) {
|
||||
log.error("Unable to load user application configuration model TBOX", t);
|
||||
|
@ -102,7 +102,7 @@ implements ServletContextListener {
|
|||
MEM_ONT_MODEL_SPEC);
|
||||
appDisplayDisplayModel.add(displayDisplayModel);
|
||||
appDisplayDisplayModel.getBaseModel().register(new ModelSynchronizer(displayDisplayModel));
|
||||
ctx.setAttribute("displayOntModelDisplayModel", appDisplayDisplayModel);
|
||||
ModelAccess.on(ctx).setOntModel(ModelID.DISPLAY_DISPLAY, appDisplayDisplayModel);
|
||||
log.debug("Loaded file " + APPPATH_LOAD + "displayDisplay.n3 into display display model");
|
||||
} catch (Throwable t) {
|
||||
log.error("Unable to load user application configuration model Display Model", t);
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
|||
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
|
||||
|
||||
/**
|
||||
|
@ -42,14 +43,7 @@ public class AssembleModelsSetup implements ServletContextListener {
|
|||
private String SYNTAX = "N3";
|
||||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
|
||||
OntModel jenaOntModel = null;
|
||||
try {
|
||||
jenaOntModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
||||
} catch (Exception e) {
|
||||
log.error("No baseOntModel found to which to attach assembled models");
|
||||
return;
|
||||
}
|
||||
OntModel jenaOntModel = ModelAccess.on(sce.getServletContext()).getBaseOntModel();
|
||||
// read assemblers out of assemblers directory
|
||||
Set pathSet = sce.getServletContext().getResourcePaths(ASSEMBLERS_DIR_PATH);
|
||||
for (String path : (Set<String>)pathSet) {
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode.ASSERTIONS_ONLY;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.graph.BulkUpdateHandler;
|
||||
import com.hp.hpl.jena.graph.Graph;
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.ResIterator;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.util.ResourceUtils;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SpecialBulkUpdateHandlerGraph;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.InitialJenaModelUtils;
|
||||
|
||||
/**
|
||||
* Sets up the content models, OntModelSelectors and webapp DAO factories.
|
||||
*/
|
||||
public class ContentModelSetup extends JenaDataSourceSetupBase
|
||||
implements javax.servlet.ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ContentModelSetup.class);
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
setUpJenaDataSource(ctx);
|
||||
ss.info(this, secondsSince(begin) + " seconds to set up models and DAO factories");
|
||||
}
|
||||
|
||||
private void setUpJenaDataSource(ServletContext ctx) {
|
||||
RDFServiceFactory rdfServiceFactory = RDFServiceUtils.getRDFServiceFactory(ctx);
|
||||
RDFService rdfService = rdfServiceFactory.getRDFService();
|
||||
Dataset dataset = new RDFServiceDataset(rdfService);
|
||||
setStartupDataset(dataset, ctx);
|
||||
|
||||
OntModel applicationMetadataModel = createdMemoryMappedModel(dataset, JENA_APPLICATION_METADATA_MODEL, "application metadata model");
|
||||
if (applicationMetadataModel.size()== 0) {
|
||||
JenaDataSourceSetupBase.thisIsFirstStartup();
|
||||
}
|
||||
|
||||
ModelAccess models = ModelAccess.on(ctx);
|
||||
OntModel baseABoxModel = createNamedModelFromDataset(dataset, JENA_DB_MODEL);
|
||||
OntModel inferenceABoxModel = createNamedModelFromDataset(dataset, JENA_INF_MODEL);
|
||||
OntModel baseTBoxModel = createdMemoryMappedModel(dataset, JENA_TBOX_ASSERTIONS_MODEL, "tbox assertions");
|
||||
OntModel inferenceTBoxModel = createdMemoryMappedModel(dataset, JENA_TBOX_INF_MODEL, "tbox inferences");
|
||||
OntModel unionABoxModel = createCombinedBulkUpdatingModel(baseABoxModel, inferenceABoxModel);
|
||||
OntModel unionTBoxModel = createCombinedBulkUpdatingModel(baseTBoxModel, inferenceTBoxModel);
|
||||
|
||||
if (isFirstStartup()) {
|
||||
loadInitialApplicationMetadataModel(applicationMetadataModel, ctx);
|
||||
loadDataFromFilesystem(baseABoxModel, baseTBoxModel, applicationMetadataModel, ctx);
|
||||
}
|
||||
|
||||
log.info("Setting up union models");
|
||||
OntModel baseFullModel = createCombinedBulkUpdatingModel(baseABoxModel, baseTBoxModel);
|
||||
OntModel inferenceFullModel = createCombinedModel(inferenceABoxModel, inferenceTBoxModel);
|
||||
OntModel unionFullModel = ModelFactory.createOntologyModel(DB_ONT_MODEL_SPEC, dataset.getDefaultModel());
|
||||
|
||||
models.setOntModel(ModelID.APPLICATION_METADATA, applicationMetadataModel);
|
||||
|
||||
models.setOntModel(ModelID.BASE_ABOX, baseABoxModel);
|
||||
models.setOntModel(ModelID.BASE_TBOX, baseTBoxModel);
|
||||
models.setOntModel(ModelID.BASE_FULL, baseFullModel);
|
||||
models.setOntModel(ModelID.INFERRED_ABOX, inferenceABoxModel);
|
||||
models.setOntModel(ModelID.INFERRED_TBOX, inferenceTBoxModel);
|
||||
models.setOntModel(ModelID.INFERRED_FULL, inferenceFullModel);
|
||||
models.setOntModel(ModelID.UNION_ABOX, unionABoxModel);
|
||||
models.setOntModel(ModelID.UNION_TBOX, unionTBoxModel);
|
||||
models.setOntModel(ModelID.UNION_FULL, unionFullModel);
|
||||
|
||||
checkForNamespaceMismatch( applicationMetadataModel, ctx );
|
||||
|
||||
log.info("Setting up DAO factories");
|
||||
|
||||
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
||||
config.setDefaultNamespace(getDefaultNamespace(ctx));
|
||||
|
||||
OntModelSelector baseOms = models.getBaseOntModelSelector();
|
||||
WebappDaoFactory baseWadf = new WebappDaoFactorySDB(rdfService, baseOms, config, ASSERTIONS_ONLY);
|
||||
ModelAccess.on(ctx).setBaseWebappDaoFactory(baseWadf);
|
||||
|
||||
OntModelSelector unionOms = models.getUnionOntModelSelector();
|
||||
WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, unionOms, config);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(FactoryID.UNION, wadf);
|
||||
|
||||
log.info("Model makers set up");
|
||||
|
||||
ctx.setAttribute("defaultNamespace", getDefaultNamespace(ctx));
|
||||
}
|
||||
|
||||
private OntModel createNamedModelFromDataset(Dataset dataset, String name) {
|
||||
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getNamedModel(name));
|
||||
}
|
||||
|
||||
private OntModel createdMemoryMappedModel(Dataset dataset, String name, String label) {
|
||||
try {
|
||||
Model dbModel = dataset.getNamedModel(name);
|
||||
OntModel memoryModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC);
|
||||
|
||||
if (dbModel != null) {
|
||||
long begin = System.currentTimeMillis();
|
||||
log.info("Copying cached " + label + " into memory");
|
||||
memoryModel.add(dbModel);
|
||||
log.info(secondsSince(begin) + " seconds to load " + label);
|
||||
memoryModel.getBaseModel().register(new ModelSynchronizer(dbModel));
|
||||
}
|
||||
return memoryModel;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Unable to load " + label + " from DB", e);
|
||||
}
|
||||
}
|
||||
|
||||
private OntModel createCombinedModel(OntModel oneModel, OntModel otherModel) {
|
||||
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
|
||||
ModelFactory.createUnion(oneModel, otherModel));
|
||||
}
|
||||
|
||||
private OntModel createCombinedBulkUpdatingModel(OntModel baseModel,
|
||||
OntModel otherModel) {
|
||||
BulkUpdateHandler bulkUpdateHandler = baseModel.getGraph().getBulkUpdateHandler();
|
||||
Graph unionGraph = ModelFactory.createUnion(baseModel, otherModel).getGraph();
|
||||
Model unionModel = ModelFactory.createModelForGraph(
|
||||
new SpecialBulkUpdateHandlerGraph(unionGraph, bulkUpdateHandler));
|
||||
return ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC, unionModel);
|
||||
}
|
||||
|
||||
private void loadInitialApplicationMetadataModel(OntModel applicationMetadataModel,
|
||||
ServletContext ctx) {
|
||||
try {
|
||||
applicationMetadataModel.add(
|
||||
InitialJenaModelUtils.loadInitialModel(ctx, getDefaultNamespace(ctx)));
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Unable to load application metadata model cache from DB", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadDataFromFilesystem(OntModel baseABoxModel, OntModel baseTBoxModel, OntModel applicationMetadataModel,
|
||||
ServletContext ctx) {
|
||||
Long startTime = System.currentTimeMillis();
|
||||
log.info("Initializing models from RDF files");
|
||||
|
||||
readOntologyFilesInPathSet(USER_ABOX_PATH, ctx, baseABoxModel);
|
||||
readOntologyFilesInPathSet(USER_TBOX_PATH, ctx, baseTBoxModel);
|
||||
readOntologyFilesInPathSet(USER_APPMETA_PATH, ctx, applicationMetadataModel);
|
||||
|
||||
log.debug(((System.currentTimeMillis() - startTime) / 1000)
|
||||
+ " seconds to read RDF files ");
|
||||
}
|
||||
|
||||
private long secondsSince(long startTime) {
|
||||
return (System.currentTimeMillis() - startTime) / 1000;
|
||||
}
|
||||
|
||||
/* ===================================================================== */
|
||||
|
||||
/**
|
||||
* If we find a "portal1" portal (and we should), its URI should use the
|
||||
* default namespace.
|
||||
*/
|
||||
private void checkForNamespaceMismatch(OntModel model, ServletContext ctx) {
|
||||
String expectedNamespace = getDefaultNamespace(ctx);
|
||||
|
||||
List<Resource> portals = getPortal1s(model);
|
||||
|
||||
if(!portals.isEmpty() && noPortalForNamespace(
|
||||
portals, expectedNamespace)) {
|
||||
// There really should be only one portal 1, but if there happen to
|
||||
// be multiple, just arbitrarily pick the first in the list.
|
||||
Resource portal = portals.get(0);
|
||||
String oldNamespace = portal.getNameSpace();
|
||||
renamePortal(portal, expectedNamespace, model);
|
||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||
ss.warning(this, "\nThe default namespace has been changed \n" +
|
||||
"from " + oldNamespace +
|
||||
"\nto " + expectedNamespace + ".\n" +
|
||||
"The application will function normally, but " +
|
||||
"any individuals in the \n" + oldNamespace + " " +
|
||||
"namespace will need to have their URIs \n" +
|
||||
"changed in order to be served as linked data. " +
|
||||
"You can use the Ingest Tools \nto change the " +
|
||||
"URIs for a batch of resources.");
|
||||
}
|
||||
}
|
||||
|
||||
private List<Resource> getPortal1s(Model model) {
|
||||
List<Resource> portals = new ArrayList<Resource>();
|
||||
try {
|
||||
model.enterCriticalSection(Lock.READ);
|
||||
ResIterator portalIt = model.listResourcesWithProperty(
|
||||
RDF.type, PORTAL);
|
||||
while (portalIt.hasNext()) {
|
||||
Resource portal = portalIt.nextResource();
|
||||
if ("portal1".equals(portal.getLocalName())) {
|
||||
portals.add(portal);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
model.leaveCriticalSection();
|
||||
}
|
||||
return portals;
|
||||
}
|
||||
|
||||
private boolean noPortalForNamespace(List<Resource> portals, String expectedNamespace) {
|
||||
for (Resource portal : portals) {
|
||||
if(expectedNamespace.equals(portal.getNameSpace())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void renamePortal(Resource portal, String namespace, Model model) {
|
||||
model.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
ResourceUtils.renameResource(portal, namespace + portal.getLocalName());
|
||||
} finally {
|
||||
model.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
|
||||
/* ===================================================================== */
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ import com.hp.hpl.jena.query.Dataset;
|
|||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
|
@ -48,16 +48,16 @@ public class FileGraphSetup implements ServletContextListener {
|
|||
boolean tboxChanged = false; // indicates whether any TBox file graph model has changed
|
||||
OntModelSelector baseOms = null;
|
||||
|
||||
try {
|
||||
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
|
||||
try {
|
||||
OntDocumentManager.getInstance().setProcessImports(true);
|
||||
baseOms = ModelContext.getBaseOntModelSelector(sce.getServletContext());
|
||||
Dataset dataset = JenaDataSourceSetupBase.getStartupDataset(sce.getServletContext());
|
||||
baseOms = ModelAccess.on(ctx).getBaseOntModelSelector();
|
||||
Dataset dataset = JenaDataSourceSetupBase.getStartupDataset(ctx);
|
||||
RDFServiceModelMaker maker = new RDFServiceModelMaker(RDFServiceUtils.getRDFServiceFactory(ctx));
|
||||
|
||||
// ABox files
|
||||
Set<String> pathSet = sce.getServletContext().getResourcePaths(PATH_ROOT + ABOX);
|
||||
Set<String> pathSet = ctx.getResourcePaths(PATH_ROOT + ABOX);
|
||||
|
||||
cleanupDB(dataset, pathToURI(pathSet, ABOX), ABOX);
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class FileGraphSetup implements ServletContextListener {
|
|||
}
|
||||
|
||||
// TBox files
|
||||
pathSet = sce.getServletContext().getResourcePaths(PATH_ROOT + TBOX);
|
||||
pathSet = ctx.getResourcePaths(PATH_ROOT + TBOX);
|
||||
|
||||
cleanupDB(dataset, pathToURI(pathSet, TBOX),TBOX);
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
|||
} else if (TripleStoreType.SDB.equals(type)) {
|
||||
StoreDesc storeDesc = new StoreDesc(
|
||||
LayoutType.LayoutTripleNodesHash, DatabaseType.fetch(dbtypeStr));
|
||||
DataSource bds = WebappDaoSetup.makeC3poDataSource(
|
||||
DataSource bds = ContentModelSetup.makeC3poDataSource(
|
||||
getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
||||
// DataSource bds = WebappDaoSetup.makeBasicDataSource(
|
||||
// getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
/**
|
||||
* Sets up the content models, OntModelSelectors and webapp DAO factories.
|
||||
*/
|
||||
public class ModelMakerSetup extends JenaDataSourceSetupBase
|
||||
implements javax.servlet.ServletContextListener {
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
|
||||
RDFServiceFactory rdfServiceFactory = RDFServiceUtils.getRDFServiceFactory(ctx);
|
||||
makeModelMakerFromConnectionProperties(TripleStoreType.RDB, ctx);
|
||||
VitroJenaModelMaker vjmm = getVitroJenaModelMaker();
|
||||
setVitroJenaModelMaker(vjmm, ctx);
|
||||
makeModelMakerFromConnectionProperties(TripleStoreType.SDB, ctx);
|
||||
RDFServiceModelMaker vsmm = new RDFServiceModelMaker(rdfServiceFactory);
|
||||
setVitroJenaSDBModelMaker(vsmm, ctx);
|
||||
|
||||
//bdc34: I have no reason for vsmm vs vjmm.
|
||||
//I don't know what are the implications of this choice.
|
||||
setVitroModelSource( new VitroModelSource(vsmm,ctx), ctx);
|
||||
|
||||
ss.info(this, secondsSince(begin) + " seconds to set up models and DAO factories");
|
||||
}
|
||||
|
||||
private long secondsSince(long startTime) {
|
||||
return (System.currentTimeMillis() - startTime) / 1000;
|
||||
}
|
||||
|
||||
/* ===================================================================== */
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
|
|
@ -13,15 +13,15 @@ import net.sf.jga.fn.UnaryFunctor;
|
|||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.EntityPropertyListFilter;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao;
|
||||
|
||||
public class PropertyMaskingSetup implements ServletContextListener {
|
||||
|
||||
private final static String ENTITY_PROPERTY_LIST_FILTER_ATTR_NAME = "entityPropertyListFilter";
|
||||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
OntModel jenaOntModel = (OntModel) sce.getServletContext().getAttribute(JenaBaseDao.JENA_ONT_MODEL_ATTRIBUTE_NAME);
|
||||
OntModel jenaOntModel = ModelAccess.on(sce.getServletContext()).getJenaOntModel();
|
||||
sce.getServletContext().setAttribute(ENTITY_PROPERTY_LIST_FILTER_ATTR_NAME, new EntityPropertyListFilter(jenaOntModel));
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Iterator;
|
|||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
|
@ -28,6 +29,7 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
|||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.util.ResourceUtils;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
public class RunSparqlConstructs implements ServletContextListener {
|
||||
|
@ -42,18 +44,20 @@ public class RunSparqlConstructs implements ServletContextListener {
|
|||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try {
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) sce.getServletContext().getAttribute("webappDaoFactory");
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
|
||||
String namespace = (wadf != null && wadf.getDefaultNamespace() != null)
|
||||
? wadf.getDefaultNamespace() : DEFAULT_DEFAULT_NAMESPACE;
|
||||
|
||||
OntModel baseOntModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel baseOntModel = ModelAccess.on(ctx).getBaseOntModel();
|
||||
Model anonModel = ModelFactory.createDefaultModel();
|
||||
Model namedModel = ModelFactory.createDefaultModel();
|
||||
|
||||
Set<String> resourcePaths = sce.getServletContext().getResourcePaths(SPARQL_DIR);
|
||||
Set<String> resourcePaths = ctx.getResourcePaths(SPARQL_DIR);
|
||||
for (String path : resourcePaths) {
|
||||
log.debug("Attempting to execute SPARQL at " + path);
|
||||
File file = new File(sce.getServletContext().getRealPath(path));
|
||||
File file = new File(ctx.getRealPath(path));
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
StringBuffer fileContents = new StringBuffer();
|
||||
|
|
|
@ -22,7 +22,8 @@ import com.hp.hpl.jena.rdf.model.Model;
|
|||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
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.RDFServiceDataset;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||
|
@ -33,7 +34,6 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|||
import edu.cornell.mannlib.vitro.webapp.reasoner.ReasonerPlugin;
|
||||
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
|
||||
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasonerTBoxListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase.TripleStoreType;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
public class SimpleReasonerSetup implements ServletContextListener {
|
||||
|
@ -48,15 +48,15 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
|||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
|
||||
try {
|
||||
// set up Pellet reasoning for the TBox
|
||||
OntModelSelector assertionsOms = ModelAccess.on(ctx).getBaseOntModelSelector();
|
||||
OntModelSelector inferencesOms = ModelAccess.on(ctx).getInferenceOntModelSelector();
|
||||
OntModelSelector unionOms = ModelAccess.on(ctx).getUnionOntModelSelector();
|
||||
|
||||
OntModelSelector assertionsOms = ModelContext.getBaseOntModelSelector(sce.getServletContext());
|
||||
OntModelSelector inferencesOms = ModelContext.getInferenceOntModelSelector(sce.getServletContext());
|
||||
OntModelSelector unionOms = ModelContext.getUnionOntModelSelector(sce.getServletContext());
|
||||
|
||||
WebappDaoFactoryJena wadf = (WebappDaoFactoryJena) sce.getServletContext().getAttribute("webappDaoFactory");
|
||||
WebappDaoFactoryJena wadf = (WebappDaoFactoryJena) ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
|
||||
if (!assertionsOms.getTBoxModel().getProfile().NAMESPACE().equals(OWL.NAMESPACE.getNameSpace())) {
|
||||
log.error("Not connecting Pellet reasoner - the TBox assertions model is not an OWL model");
|
||||
|
@ -83,7 +83,6 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
|||
|
||||
// set up simple reasoning for the ABox
|
||||
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
DataSource bds = JenaDataSourceSetupBase
|
||||
.getApplicationDataSource(ctx);
|
||||
String dbType = ConfigurationProperties.getBean(ctx).getProperty( // database type
|
||||
|
|
|
@ -23,7 +23,9 @@ import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean.ThemeInfo;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
|
@ -91,8 +93,7 @@ public class ThemeInfoSetup implements ServletContextListener {
|
|||
}
|
||||
|
||||
private String getCurrentThemeName(ServletContext ctx) {
|
||||
OntModel ontModel = ModelContext.getBaseOntModelSelector(ctx)
|
||||
.getApplicationMetadataModel();
|
||||
OntModel ontModel = ModelAccess.on(ctx).getApplicationMetadataModel();
|
||||
|
||||
ontModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
|
|
|
@ -32,8 +32,8 @@ import com.hp.hpl.jena.vocabulary.RDF;
|
|||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.ontology.update.KnowledgeBaseUpdater;
|
||||
import edu.cornell.mannlib.vitro.webapp.ontology.update.UpdateSettings;
|
||||
|
||||
|
@ -99,14 +99,14 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
|||
settings.setErrorLogFile(ctx.getRealPath(errorLogFileName));
|
||||
settings.setAddedDataFile(ctx.getRealPath(ADDED_DATA_FILE));
|
||||
settings.setRemovedDataFile(ctx.getRealPath(REMOVED_DATA_FILE));
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) ctx.getAttribute("webappDaoFactory");
|
||||
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
settings.setDefaultNamespace(wadf.getDefaultNamespace());
|
||||
settings.setAssertionOntModelSelector(ModelContext.getBaseOntModelSelector(ctx));
|
||||
settings.setInferenceOntModelSelector(ModelContext.getInferenceOntModelSelector(ctx));
|
||||
settings.setUnionOntModelSelector(ModelContext.getUnionOntModelSelector(ctx));
|
||||
settings.setAssertionOntModelSelector(ModelAccess.on(ctx).getBaseOntModelSelector());
|
||||
settings.setInferenceOntModelSelector(ModelAccess.on(ctx).getInferenceOntModelSelector());
|
||||
settings.setUnionOntModelSelector(ModelAccess.on(ctx).getUnionOntModelSelector());
|
||||
boolean tryMigrateDisplay = true;
|
||||
try {
|
||||
settings.setDisplayModel(ModelContext.getDisplayModel(ctx));
|
||||
settings.setDisplayModel(ModelAccess.on(ctx).getDisplayModel());
|
||||
OntModel oldTBoxModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_MODEL_DIR));
|
||||
settings.setOldTBoxModel(oldTBoxModel);
|
||||
OntModel newTBoxModel = loadModelFromDirectory(ctx.getRealPath(NEW_TBOX_MODEL_DIR));
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.servlet.ServletContextListener;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
@ -99,8 +100,7 @@ public class UpdatePermissionSetUris implements ServletContextListener {
|
|||
this.ctx = ctx;
|
||||
this.stats = stats;
|
||||
|
||||
WebappDaoFactory wadf = (WebappDaoFactory) ctx
|
||||
.getAttribute("webappDaoFactory");
|
||||
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
|
||||
userAccountsDao = wadf.getUserAccountsDao();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import javax.servlet.ServletContextEvent;
|
|||
import javax.servlet.ServletContextListener;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -14,6 +13,7 @@ import com.hp.hpl.jena.ontology.OntModel;
|
|||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class UserModelSetup extends JenaDataSourceSetupBase
|
|||
userAccountsModel.add(userAccountsDbModel);
|
||||
userAccountsModel.getBaseModel().register(
|
||||
new ModelSynchronizer(userAccountsDbModel));
|
||||
ctx.setAttribute("userAccountsOntModel", userAccountsModel);
|
||||
ModelAccess.on(ctx).setUserAccountsModel(userAccountsModel);
|
||||
|
||||
} catch (Throwable t) {
|
||||
log.error("Unable to load user accounts model from DB", t);
|
||||
|
|
|
@ -1,385 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.ResIterator;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Statement;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.util.ResourceUtils;
|
||||
import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
|
||||
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.RDFServiceModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SpecialBulkUpdateHandlerGraph;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.InitialJenaModelUtils;
|
||||
|
||||
/**
|
||||
* Primarily sets up webapp DAO factories.
|
||||
*/
|
||||
public class WebappDaoSetup extends JenaDataSourceSetupBase
|
||||
implements javax.servlet.ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(WebappDaoSetup.class);
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
setUpJenaDataSource(ctx, ss);
|
||||
log.info((System.currentTimeMillis() - startTime) / 1000 +
|
||||
" seconds to set up models and DAO factories");
|
||||
} catch (Throwable t) {
|
||||
log.error("Throwable in " + this.getClass().getName(), t);
|
||||
ss.fatal(this, "Throwable in " + this.getClass().getName(), t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setUpJenaDataSource(ServletContext ctx, StartupStatus ss) {
|
||||
OntModelSelectorImpl baseOms = new OntModelSelectorImpl();
|
||||
OntModelSelectorImpl inferenceOms = new OntModelSelectorImpl();
|
||||
OntModelSelectorImpl unionOms = new OntModelSelectorImpl();
|
||||
|
||||
OntModel userAccountsModel = ontModelFromContextAttribute(
|
||||
ctx, "userAccountsOntModel");
|
||||
baseOms.setUserAccountsModel(userAccountsModel);
|
||||
inferenceOms.setUserAccountsModel(userAccountsModel);
|
||||
unionOms.setUserAccountsModel(userAccountsModel);
|
||||
|
||||
OntModel displayModel = ontModelFromContextAttribute(
|
||||
ctx,DISPLAY_ONT_MODEL);
|
||||
baseOms.setDisplayModel(displayModel);
|
||||
inferenceOms.setDisplayModel(displayModel);
|
||||
unionOms.setDisplayModel(displayModel);
|
||||
|
||||
RDFServiceFactory rdfServiceFactory = RDFServiceUtils.getRDFServiceFactory(ctx);
|
||||
RDFService rdfService = rdfServiceFactory.getRDFService();
|
||||
Dataset dataset = new RDFServiceDataset(rdfService);
|
||||
setStartupDataset(dataset, ctx);
|
||||
|
||||
// ABox assertions
|
||||
baseOms.setABoxModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getNamedModel(JenaDataSourceSetupBase.JENA_DB_MODEL)));
|
||||
|
||||
// ABox inferences
|
||||
inferenceOms.setABoxModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getNamedModel(JenaDataSourceSetupBase.JENA_INF_MODEL)));
|
||||
|
||||
// TBox assertions
|
||||
try {
|
||||
Model tboxAssertionsDB = dataset.getNamedModel(
|
||||
JENA_TBOX_ASSERTIONS_MODEL);
|
||||
OntModel tboxAssertions = ModelFactory.createOntologyModel(
|
||||
MEM_ONT_MODEL_SPEC);
|
||||
|
||||
if (tboxAssertionsDB != null) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("Copying cached tbox assertions into memory");
|
||||
tboxAssertions.add(tboxAssertionsDB);
|
||||
log.info((System.currentTimeMillis() - startTime)/ 1000 + " seconds to load tbox assertions");
|
||||
tboxAssertions.getBaseModel().register(new ModelSynchronizer(tboxAssertionsDB));
|
||||
}
|
||||
|
||||
baseOms.setTBoxModel(tboxAssertions);
|
||||
} catch (Throwable e) {
|
||||
log.error("Unable to load tbox assertion cache from DB", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// TBox inferences
|
||||
try {
|
||||
Model tboxInferencesDB = dataset.getNamedModel(JENA_TBOX_INF_MODEL);
|
||||
OntModel tboxInferences = ModelFactory.createOntologyModel(
|
||||
MEM_ONT_MODEL_SPEC);
|
||||
|
||||
if (tboxInferencesDB != null) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info(
|
||||
"Copying cached tbox inferences into memory");
|
||||
tboxInferences.add(tboxInferencesDB);
|
||||
System.out.println((System.currentTimeMillis() - startTime)
|
||||
/ 1000 + " seconds to load tbox inferences");
|
||||
|
||||
tboxInferences.getBaseModel().register(new ModelSynchronizer(
|
||||
tboxInferencesDB));
|
||||
}
|
||||
inferenceOms.setTBoxModel(tboxInferences);
|
||||
} catch (Throwable e) {
|
||||
log.error("Unable to load tbox inference cache from DB", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// union ABox
|
||||
Model m = ModelFactory.createUnion(
|
||||
baseOms.getABoxModel(), inferenceOms.getABoxModel());
|
||||
m = ModelFactory.createModelForGraph(
|
||||
new SpecialBulkUpdateHandlerGraph(
|
||||
m.getGraph(),
|
||||
baseOms.getABoxModel().getGraph().getBulkUpdateHandler()));
|
||||
OntModel unionABoxModel = ModelFactory.createOntologyModel(
|
||||
MEM_ONT_MODEL_SPEC, m);
|
||||
unionOms.setABoxModel(unionABoxModel);
|
||||
|
||||
// union TBox
|
||||
m = ModelFactory.createUnion(baseOms.getTBoxModel(), inferenceOms.getTBoxModel());
|
||||
m = ModelFactory.createModelForGraph(
|
||||
new SpecialBulkUpdateHandlerGraph(
|
||||
m.getGraph(),
|
||||
baseOms.getTBoxModel().getGraph().getBulkUpdateHandler()));
|
||||
OntModel unionTBoxModel = ModelFactory.createOntologyModel(
|
||||
MEM_ONT_MODEL_SPEC, m);
|
||||
unionOms.setTBoxModel(unionTBoxModel);
|
||||
|
||||
|
||||
// Application metadata model is cached in memory.
|
||||
try {
|
||||
|
||||
Model applicationMetadataModelDB = dataset.getNamedModel(
|
||||
JENA_APPLICATION_METADATA_MODEL);
|
||||
OntModel applicationMetadataModel =
|
||||
ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
System.out.println(
|
||||
"Copying cached application metadata model into memory");
|
||||
applicationMetadataModel.add(applicationMetadataModelDB);
|
||||
System.out.println((System.currentTimeMillis() - startTime)
|
||||
/ 1000 + " seconds to load application metadata model " +
|
||||
"assertions of size " + applicationMetadataModel.size());
|
||||
applicationMetadataModel.getBaseModel().register(
|
||||
new ModelSynchronizer(applicationMetadataModelDB));
|
||||
|
||||
if (applicationMetadataModel.size()== 0 /* isFirstStartup() */) {
|
||||
JenaDataSourceSetupBase.thisIsFirstStartup();
|
||||
applicationMetadataModel.add(
|
||||
InitialJenaModelUtils.loadInitialModel(
|
||||
ctx, getDefaultNamespace(ctx)));
|
||||
}
|
||||
|
||||
baseOms.setApplicationMetadataModel(applicationMetadataModel);
|
||||
inferenceOms.setApplicationMetadataModel(
|
||||
baseOms.getApplicationMetadataModel());
|
||||
unionOms.setApplicationMetadataModel(
|
||||
baseOms.getApplicationMetadataModel());
|
||||
|
||||
} catch (Throwable e) {
|
||||
log.error("Unable to load application metadata model cache from DB"
|
||||
, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
checkForNamespaceMismatch( baseOms.getApplicationMetadataModel(), ctx );
|
||||
|
||||
if (isFirstStartup()) {
|
||||
loadDataFromFilesystem(baseOms, ctx);
|
||||
}
|
||||
|
||||
log.info("Setting up union models and DAO factories");
|
||||
|
||||
// create TBox + ABox union models and set up webapp DAO factories
|
||||
Model baseDynamicUnion = ModelFactory.createUnion(baseOms.getABoxModel(),
|
||||
baseOms.getTBoxModel());
|
||||
baseDynamicUnion = ModelFactory.createModelForGraph(
|
||||
new SpecialBulkUpdateHandlerGraph(
|
||||
baseDynamicUnion.getGraph(),
|
||||
baseOms.getABoxModel().getGraph().getBulkUpdateHandler()) );
|
||||
OntModel baseUnion = ModelFactory.createOntologyModel(
|
||||
OntModelSpec.OWL_MEM, baseDynamicUnion);
|
||||
baseOms.setFullModel(baseUnion);
|
||||
ModelContext.setBaseOntModel(baseOms.getFullModel(), ctx);
|
||||
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
||||
config.setDefaultNamespace(getDefaultNamespace(ctx));
|
||||
WebappDaoFactory baseWadf = new WebappDaoFactorySDB(
|
||||
rdfService, baseOms, config,
|
||||
WebappDaoFactorySDB.SDBDatasetMode.ASSERTIONS_ONLY);
|
||||
ctx.setAttribute("assertionsWebappDaoFactory",baseWadf);
|
||||
|
||||
OntModel inferenceUnion = ModelFactory.createOntologyModel(
|
||||
OntModelSpec.OWL_MEM,
|
||||
ModelFactory.createUnion(
|
||||
inferenceOms.getABoxModel(),
|
||||
inferenceOms.getTBoxModel()));
|
||||
inferenceOms.setFullModel(inferenceUnion);
|
||||
ModelContext.setInferenceOntModel(inferenceOms.getFullModel(), ctx);
|
||||
WebappDaoFactory infWadf = new WebappDaoFactorySDB(
|
||||
rdfService, inferenceOms, config,
|
||||
WebappDaoFactorySDB.SDBDatasetMode.INFERENCES_ONLY);
|
||||
ctx.setAttribute("deductionsWebappDaoFactory", infWadf);
|
||||
|
||||
OntModel masterUnion = ModelFactory.createOntologyModel(
|
||||
DB_ONT_MODEL_SPEC, dataset.getDefaultModel());
|
||||
unionOms.setFullModel(masterUnion);
|
||||
ctx.setAttribute("jenaOntModel", masterUnion);
|
||||
WebappDaoFactory wadf = new WebappDaoFactorySDB(
|
||||
rdfService, unionOms, config);
|
||||
ctx.setAttribute("webappDaoFactory",wadf);
|
||||
|
||||
ModelContext.setOntModelSelector(unionOms, ctx);
|
||||
ModelContext.setUnionOntModelSelector(unionOms, ctx);
|
||||
// assertions and inferences
|
||||
ModelContext.setBaseOntModelSelector(baseOms, ctx);
|
||||
// assertions
|
||||
ModelContext.setInferenceOntModelSelector(inferenceOms, ctx);
|
||||
// inferences
|
||||
|
||||
ctx.setAttribute("defaultNamespace", getDefaultNamespace(ctx));
|
||||
|
||||
makeModelMakerFromConnectionProperties(TripleStoreType.RDB, ctx);
|
||||
VitroJenaModelMaker vjmm = getVitroJenaModelMaker();
|
||||
setVitroJenaModelMaker(vjmm, ctx);
|
||||
makeModelMakerFromConnectionProperties(TripleStoreType.SDB, ctx);
|
||||
RDFServiceModelMaker vsmm = new RDFServiceModelMaker(rdfServiceFactory);
|
||||
setVitroJenaSDBModelMaker(vsmm, ctx);
|
||||
|
||||
//bdc34: I have no reason for vsmm vs vjmm.
|
||||
//I don't know what are the implications of this choice.
|
||||
setVitroModelSource( new VitroModelSource(vsmm,ctx), ctx);
|
||||
|
||||
log.info("Model makers set up");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If we find a "portal1" portal (and we should), its URI should use the
|
||||
* default namespace.
|
||||
*/
|
||||
private void checkForNamespaceMismatch(OntModel model, ServletContext ctx) {
|
||||
String expectedNamespace = getDefaultNamespace(ctx);
|
||||
|
||||
List<Resource> portals = getPortal1s(model);
|
||||
|
||||
if(!portals.isEmpty() && noPortalForNamespace(
|
||||
portals, expectedNamespace)) {
|
||||
// There really should be only one portal 1, but if there happen to
|
||||
// be multiple, just arbitrarily pick the first in the list.
|
||||
Resource portal = portals.get(0);
|
||||
String oldNamespace = portal.getNameSpace();
|
||||
renamePortal(portal, expectedNamespace, model);
|
||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||
ss.warning(this, "\nThe default namespace has been changed \n" +
|
||||
"from " + oldNamespace +
|
||||
"\nto " + expectedNamespace + ".\n" +
|
||||
"The application will function normally, but " +
|
||||
"any individuals in the \n" + oldNamespace + " " +
|
||||
"namespace will need to have their URIs \n" +
|
||||
"changed in order to be served as linked data. " +
|
||||
"You can use the Ingest Tools \nto change the " +
|
||||
"URIs for a batch of resources.");
|
||||
}
|
||||
}
|
||||
|
||||
private List<Resource> getPortal1s(Model model) {
|
||||
List<Resource> portals = new ArrayList<Resource>();
|
||||
try {
|
||||
model.enterCriticalSection(Lock.READ);
|
||||
ResIterator portalIt = model.listResourcesWithProperty(
|
||||
RDF.type, PORTAL);
|
||||
while (portalIt.hasNext()) {
|
||||
Resource portal = portalIt.nextResource();
|
||||
if ("portal1".equals(portal.getLocalName())) {
|
||||
portals.add(portal);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
model.leaveCriticalSection();
|
||||
}
|
||||
return portals;
|
||||
}
|
||||
|
||||
private boolean noPortalForNamespace(List<Resource> portals,
|
||||
String expectedNamespace) {
|
||||
for (Resource portal : portals) {
|
||||
if(expectedNamespace.equals(portal.getNameSpace())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void renamePortal(Resource portal, String namespace, Model model) {
|
||||
model.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
ResourceUtils.renameResource(
|
||||
portal, namespace + portal.getLocalName());
|
||||
} finally {
|
||||
model.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ===================================================================== */
|
||||
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
private boolean isEmpty(Model model) {
|
||||
ClosableIterator<Statement> closeIt = model.listStatements(
|
||||
null, RDF.type, ResourceFactory.createResource(
|
||||
VitroVocabulary.PORTAL));
|
||||
try {
|
||||
if (closeIt.hasNext()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} finally {
|
||||
closeIt.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadDataFromFilesystem(OntModelSelector baseOms,
|
||||
ServletContext ctx) {
|
||||
Long startTime = System.currentTimeMillis();
|
||||
log.info("Initializing models from RDF files");
|
||||
|
||||
readOntologyFilesInPathSet(USER_ABOX_PATH, ctx, baseOms.getABoxModel());
|
||||
readOntologyFilesInPathSet(USER_TBOX_PATH, ctx, baseOms.getTBoxModel());
|
||||
readOntologyFilesInPathSet(
|
||||
USER_APPMETA_PATH, ctx, baseOms.getApplicationMetadataModel());
|
||||
|
||||
log.debug(((System.currentTimeMillis() - startTime) / 1000)
|
||||
+ " seconds to read RDF files ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
|
||||
public class ApplicationConfigurationOntologyUtils {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ApplicationConfigurationOntologyUtils.class);
|
||||
|
||||
public static List<ObjectProperty> getAdditionalFauxSubpropertiesForList(List<ObjectProperty> propList, VitroRequest vreq) {
|
||||
ServletContext ctx = vreq.getSession().getServletContext();
|
||||
Model displayModel = ModelAccess.on(ctx).getDisplayModel();
|
||||
Model tboxModel = ModelAccess.on(ctx).getOntModel(ModelID.UNION_TBOX);
|
||||
return getAdditionalFauxSubpropertiesForList(propList, displayModel, tboxModel);
|
||||
}
|
||||
|
||||
public static List<ObjectProperty> getAdditionalFauxSubpropertiesForList(List<ObjectProperty> propList,
|
||||
Model displayModel,
|
||||
Model tboxModel) {
|
||||
List<ObjectProperty> additionalProps = new ArrayList<ObjectProperty>();
|
||||
Model union = ModelFactory.createUnion(displayModel, tboxModel);
|
||||
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
|
||||
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
||||
"SELECT ?range ?label ?listView ?group WHERE { \n" +
|
||||
" ?p rdfs:subPropertyOf ?property . \n" +
|
||||
" ?context config:configContextFor ?p . \n" +
|
||||
" ?context config:qualifiedBy ?range . \n" +
|
||||
" ?context config:hasConfiguration ?configuration . \n" +
|
||||
" OPTIONAL { ?configuration config:propertyGroup ?group } \n" +
|
||||
" OPTIONAL { ?configuration config:displayName ?label } \n" +
|
||||
" OPTIONAL { ?configuration config:hasListView ?lv . ?lv config:listViewConfigFile ?listView } \n" +
|
||||
"}";
|
||||
|
||||
for (ObjectProperty op : propList) {
|
||||
log.debug("Checking " + op.getURI() + " for additional properties");
|
||||
String queryStr = propQuery.replaceAll("\\?property", "<" + op.getURI() + ">");
|
||||
log.debug(queryStr);
|
||||
Query q = QueryFactory.create(queryStr);
|
||||
QueryExecution qe = QueryExecutionFactory.create(q, union);
|
||||
try {
|
||||
ResultSet rs = qe.execSelect();
|
||||
while (rs.hasNext()) {
|
||||
ObjectProperty newProp = new ObjectProperty();
|
||||
newProp.setURI(op.getURI());
|
||||
QuerySolution qsoln = rs.nextSolution();
|
||||
log.debug(qsoln);
|
||||
Resource rangeRes = qsoln.getResource("range");
|
||||
if (rangeRes != null) {
|
||||
newProp.setRangeVClassURI(rangeRes.getURI());
|
||||
} else {
|
||||
newProp.setRangeVClassURI(op.getRangeVClassURI());
|
||||
}
|
||||
Resource groupRes = qsoln.getResource("group");
|
||||
if (groupRes != null) {
|
||||
newProp.setGroupURI(groupRes.getURI());
|
||||
} else {
|
||||
newProp.setGroupURI(op.getURI());
|
||||
}
|
||||
Literal labelLit = qsoln.getLiteral("label");
|
||||
if (labelLit != null) {
|
||||
newProp.setDomainPublic(labelLit.getLexicalForm());
|
||||
} else {
|
||||
newProp.setDomainPublic(op.getDomainPublic());
|
||||
}
|
||||
Literal listViewLit = qsoln.getLiteral("listView");
|
||||
if (listViewLit != null) {
|
||||
// TODO where do we get the list views from?
|
||||
} else {
|
||||
// newProp.set
|
||||
}
|
||||
additionalProps.add(newProp);
|
||||
}
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
}
|
||||
|
||||
return additionalProps;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -11,9 +9,7 @@ import com.hp.hpl.jena.rdf.model.Model;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.jena.JenaIngestController;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaSDBModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
public abstract class DataGetterBase implements DataGetter {
|
||||
|
||||
|
@ -29,7 +25,7 @@ public abstract class DataGetterBase implements DataGetter {
|
|||
}else if( REQUEST_JENA_ONT_MODEL.equals(modelName)){
|
||||
return vreq.getJenaOntModel();
|
||||
}else if( CONTEXT_DISPLAY_MODEL.equals(modelName)){
|
||||
return (Model)context.getAttribute( DisplayVocabulary.DISPLAY_ONT_MODEL);
|
||||
return ModelAccess.on(context).getDisplayModel();
|
||||
}else if( ! StringUtils.isEmpty( modelName)){
|
||||
Model model = JenaIngestController.getModel( modelName, vreq, context);
|
||||
if( model == null )
|
||||
|
|
|
@ -37,13 +37,13 @@ public class SolrResultsParser {
|
|||
List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
|
||||
|
||||
if (queryResponse == null) {
|
||||
log.error("Query response for a search was null");
|
||||
log.debug("Query response for a search was null");
|
||||
return maps;
|
||||
}
|
||||
|
||||
SolrDocumentList docs = queryResponse.getResults();
|
||||
if (docs == null) {
|
||||
log.error("Docs for a search was null");
|
||||
log.debug("Docs for a search was null");
|
||||
return maps;
|
||||
}
|
||||
log.debug("Total number of hits = " + docs.getNumFound());
|
||||
|
@ -65,13 +65,13 @@ public class SolrResultsParser {
|
|||
List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
|
||||
|
||||
if (queryResponse == null) {
|
||||
log.error("Query response for a search was null");
|
||||
log.debug("Query response for a search was null");
|
||||
return maps;
|
||||
}
|
||||
|
||||
SolrDocumentList docs = queryResponse.getResults();
|
||||
if (docs == null) {
|
||||
log.error("Docs for a search was null");
|
||||
log.debug("Docs for a search was null");
|
||||
return maps;
|
||||
}
|
||||
log.debug("Total number of hits = " + docs.getNumFound());
|
||||
|
|
|
@ -25,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.ApplicationConfigurationOntologyUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||
|
||||
/*
|
||||
|
@ -72,6 +73,20 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
// so we cannot just rely on getting that list.
|
||||
List<ObjectProperty> populatedObjectPropertyList = subject
|
||||
.getPopulatedObjectPropertyList();
|
||||
|
||||
List<ObjectProperty> additions = ApplicationConfigurationOntologyUtils
|
||||
.getAdditionalFauxSubpropertiesForList(
|
||||
populatedObjectPropertyList, vreq);
|
||||
if (log.isDebugEnabled()) {
|
||||
for (ObjectProperty t : additions) {
|
||||
log.debug(t.getDomainPublic() + " " + t.getGroupURI());
|
||||
}
|
||||
log.debug("Added " + additions.size() +
|
||||
" properties due to application configuration ontology");
|
||||
}
|
||||
|
||||
populatedObjectPropertyList.addAll(additions);
|
||||
|
||||
propertyList.addAll(populatedObjectPropertyList);
|
||||
|
||||
// If editing this page, merge in object properties applicable to the individual that are currently
|
||||
|
@ -351,7 +366,6 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
} else {
|
||||
String groupUriForProperty = p.getGroupURI();
|
||||
boolean assignedToGroup = false;
|
||||
|
||||
if (groupUriForProperty != null) {
|
||||
for (PropertyGroup pg : groupList) {
|
||||
String groupUri = pg.getURI();
|
||||
|
|
|
@ -80,6 +80,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
private PropertyListConfig config;
|
||||
private String objectKey;
|
||||
private String sortDirection;
|
||||
private String rangeURI;
|
||||
|
||||
ObjectPropertyTemplateModel(ObjectProperty op, Individual subject, VitroRequest vreq,
|
||||
boolean editing)
|
||||
|
@ -89,6 +90,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
setName(op.getDomainPublic());
|
||||
|
||||
sortDirection = op.getDomainEntitySortDirection();
|
||||
rangeURI = op.getRangeVClassURI();
|
||||
|
||||
// Get the config for this object property
|
||||
try {
|
||||
|
@ -147,8 +149,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
|
||||
protected List<Map<String, String>> getStatementData() {
|
||||
ObjectPropertyStatementDao opDao = vreq.getWebappDaoFactory().getObjectPropertyStatementDao();
|
||||
|
||||
return opDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, getSelectQuery(), getConstructQueries(), sortDirection);
|
||||
return opDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, objectKey, rangeURI, getSelectQuery(), getConstructQueries(), sortDirection);
|
||||
}
|
||||
|
||||
protected abstract boolean isEmpty();
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -107,6 +108,7 @@ public abstract class Widget {
|
|||
|
||||
private String processMacroToString(Environment env, String widgetName, Macro macro, Map<String, Object> map) {
|
||||
StringWriter out = new StringWriter();
|
||||
|
||||
try {
|
||||
String templateString = macro.getChildNodes().get(0).toString();
|
||||
// NB Using this method of creating a template from a string does not allow the widget template to import
|
||||
|
@ -118,7 +120,15 @@ public abstract class Widget {
|
|||
// We need to give each widget macro template a unique key in the StringTemplateLoader, and check
|
||||
// if it's already there or else add it. Leave this for later.
|
||||
Template template = new Template("widget", new StringReader(templateString), env.getConfiguration());
|
||||
template.process(map, out);
|
||||
|
||||
// JB KLUGE The widget is processed in its own environment, which doesn't include these custom attributes.
|
||||
// JB KLUGE Put them in.
|
||||
Environment widgetEnv = template.createProcessingEnvironment(map, out);
|
||||
ServletRequest request = (ServletRequest) env.getCustomAttribute("request");
|
||||
widgetEnv.setCustomAttribute("request", request);
|
||||
widgetEnv.setCustomAttribute("context", env.getCustomAttribute("context"));
|
||||
widgetEnv.setLocale(request.getLocale());
|
||||
widgetEnv.process();
|
||||
} catch (Exception e) {
|
||||
log.error("Could not process widget " + widgetName, e);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.PermissionRegistry;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
* Can we tell whether a user is logged in as root?
|
||||
|
@ -79,7 +80,7 @@ public class HasPermissionFactoryTest extends AbstractTestClass {
|
|||
wdf.setUserAccountsDao(uaDao);
|
||||
|
||||
ctx = new ServletContextStub();
|
||||
ctx.setAttribute("webappDaoFactory", wdf);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
|
||||
|
||||
session = new HttpSessionStub();
|
||||
session.setServletContext(ctx);
|
||||
|
|
|
@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.ArrayIdentifierBundle;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsRootUser;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
* Can we tell whether a user is logged in as root?
|
||||
|
@ -56,7 +57,7 @@ public class IsRootUserFactoryTest extends AbstractTestClass {
|
|||
wdf.setUserAccountsDao(uaDao);
|
||||
|
||||
ctx = new ServletContextStub();
|
||||
ctx.setAttribute("webappDaoFactory", wdf);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
|
||||
|
||||
session = new HttpSessionStub();
|
||||
session.setServletContext(ctx);
|
||||
|
|
|
@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.ArrayIdentifierBundle;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsUser;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
* The simplest of the IdentifierBundleFactory classes.
|
||||
|
@ -46,7 +47,7 @@ public class IsUserFactoryTest extends AbstractTestClass {
|
|||
wdf.setUserAccountsDao(uaDao);
|
||||
|
||||
ctx = new ServletContextStub();
|
||||
ctx.setAttribute("webappDaoFactory", wdf);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
|
||||
|
||||
session = new HttpSessionStub();
|
||||
session.setServletContext(ctx);
|
||||
|
|
|
@ -47,6 +47,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.AuthenticatorStub;
|
||||
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.dao.ModelAccess;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -147,7 +148,7 @@ public class AuthenticateTest extends AbstractTestClass {
|
|||
webappDaoFactory.setIndividualDao(individualDao);
|
||||
|
||||
servletContext = new ServletContextStub();
|
||||
servletContext.setAttribute("webappDaoFactory", webappDaoFactory);
|
||||
ModelAccess.on(servletContext).setWebappDaoFactory(webappDaoFactory);
|
||||
servletContext.setAttribute(AuthenticatorStub.FACTORY_ATTRIBUTE_NAME,
|
||||
authenticatorFactory);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import stubs.javax.servlet.http.HttpSessionStub;
|
|||
import stubs.org.apache.solr.client.solrj.SolrServerStub;
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
||||
|
||||
/**
|
||||
|
@ -106,8 +107,7 @@ public class JsonServletTest extends AbstractTestClass {
|
|||
resp = new HttpServletResponseStub();
|
||||
|
||||
wadf = new WebappDaoFactoryStub();
|
||||
req.setAttribute("webappDaoFactory", wadf);
|
||||
ctx.setAttribute("webappDaoFactory", wadf);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(wadf);
|
||||
|
||||
vcDao = new VClassDaoStub();
|
||||
wadf.setVClassDao(vcDao);
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler;
|
|||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
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.jena.SimpleOntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||
|
@ -48,7 +49,7 @@ public class PageDataGetterUtilsTest extends AbstractTestClass{
|
|||
@Test
|
||||
public void testGetPageDataGetterObjects() throws Exception{
|
||||
VitroRequest vreq = new VitroRequest( new HttpServletRequestStub() );
|
||||
vreq.setWebappDaoFactory(wdf);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(wdf);
|
||||
|
||||
List<PageDataGetter> pdgList = PageDataGetterUtils.getPageDataGetterObjects(vreq, pageURI);
|
||||
Assert.assertNotNull(pdgList);
|
||||
|
@ -58,7 +59,7 @@ public class PageDataGetterUtilsTest extends AbstractTestClass{
|
|||
@Test
|
||||
public void testGetNonPageDataGetterObjects() throws Exception{
|
||||
VitroRequest vreq = new VitroRequest( new HttpServletRequestStub() );
|
||||
vreq.setWebappDaoFactory(wdf);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(wdf);
|
||||
|
||||
List<PageDataGetter> pdgList = PageDataGetterUtils.getPageDataGetterObjects(vreq, pageURI_2);
|
||||
Assert.assertNotNull(pdgList);
|
||||
|
|
|
@ -25,6 +25,10 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDaoStub;
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryStub;
|
||||
import stubs.freemarker.cache.TemplateLoaderStub;
|
||||
|
@ -36,6 +40,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.customlistview.InvalidConfigurationException;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.customlistview.PropertyListConfig;
|
||||
|
@ -123,7 +129,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
|
|||
hreq.setSession(session);
|
||||
|
||||
vreq = new VitroRequest(hreq);
|
||||
vreq.setWebappDaoFactory(wadf);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(wadf);
|
||||
|
||||
subject = new IndividualImpl();
|
||||
|
||||
|
@ -273,6 +279,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
|
|||
@Test
|
||||
public void constructQueryNodeMissing()
|
||||
throws InvalidConfigurationException {
|
||||
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, emptyOntModel());
|
||||
op = buildOperation("constructQueryMissing");
|
||||
optm = new NonCollatingOPTM(op, subject, vreq, true);
|
||||
// Not an error.
|
||||
|
@ -281,6 +288,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
|
|||
@Test
|
||||
public void constructQueryMultipleValues()
|
||||
throws InvalidConfigurationException {
|
||||
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, emptyOntModel());
|
||||
op = buildOperation("constructQueryMultiple");
|
||||
optm = new NonCollatingOPTM(op, subject, vreq, true);
|
||||
assertConstructQueries("multiple construct queries", "ONE", "TWO",
|
||||
|
@ -367,6 +375,10 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
|
|||
// Helper methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private OntModel emptyOntModel() {
|
||||
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up an operation with name "foobar" and adds it to the
|
||||
* ObjectPropertyDaoStub.
|
||||
|
|
|
@ -216,7 +216,7 @@ public class ObjectPropertyStatementDaoStub implements
|
|||
|
||||
@Override
|
||||
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(
|
||||
String subjectUri, String propertyUri, String objectKey,
|
||||
String subjectUri, String propertyUri, String objectKey, String rangeUri,
|
||||
String query, Set<String> constructQueries, String sortDir) {
|
||||
throw new RuntimeException(
|
||||
"ObjectPropertyStatementDaoStub.getObjectPropertyStatementsForIndividualByProperty() not implemented.");
|
||||
|
|
|
@ -12,10 +12,11 @@ import javax.servlet.http.HttpSession;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import stubs.javax.servlet.ServletContextStub;
|
||||
|
||||
/**
|
||||
* A simple stand-in for the HttpSession, for use in unit tests.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HttpSessionStub implements HttpSession {
|
||||
private static final Log log = LogFactory.getLog(HttpSessionStub.class);
|
||||
|
||||
|
@ -49,8 +50,12 @@ public class HttpSessionStub implements HttpSession {
|
|||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
if (this.context == null) {
|
||||
return new ServletContextStub();
|
||||
} else {
|
||||
return this.context;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
|
@ -149,6 +154,7 @@ public class HttpSessionStub implements HttpSession {
|
|||
"HttpSessionStub.putValue() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValue(String arg0) {
|
||||
throw new RuntimeException(
|
||||
"HttpSessionStub.removeValue() not implemented.");
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
<#if copyright??>
|
||||
<small>©${copyright.year?c}
|
||||
<#if copyright.url??>
|
||||
<a href="${copyright.url}" title="copyright">${copyright.text}</a>
|
||||
<a href="${copyright.url}" title="${i18n().copyright}">${copyright.text}</a>
|
||||
<#else>
|
||||
${copyright.text}
|
||||
</#if>
|
||||
| <a class="terms" href="${urls.termsOfUse}" title="terms of use">Terms of Use</a></small> |
|
||||
| <a class="terms" href="${urls.termsOfUse}" title="${i18n().terms_of_use}">${i18n().terms_of_use}</a></small> |
|
||||
</#if>
|
||||
Powered by <a class="powered-by-vitro" href="http://vitro.sourceforge.net"><strong>Vitro</strong></a>
|
||||
${i18n().powered_by} <a class="powered-by-vitro" href="http://vitro.sourceforge.net"><strong>Vitro</strong></a>
|
||||
<#if user.hasRevisionInfoAccess>
|
||||
| Version <a href="${version.moreInfoUrl}" title="version">${version.label}</a>
|
||||
| ${i18n().version} <a href="${version.moreInfoUrl}" title="${i18n().version}">${version.label}</a>
|
||||
</#if>
|
||||
</p>
|
||||
|
||||
<nav role="navigation">
|
||||
<ul id="footer-nav" role="list">
|
||||
<li role="listitem"><a href="${urls.about}" title="about">About</a></li>
|
||||
<li role="listitem"><a href="${urls.about}" title="${i18n().about}">${i18n().about}</a></li>
|
||||
<#if urls.contact??>
|
||||
<li role="listitem"><a href="${urls.contact}" title="contact us">Contact Us</a></li>
|
||||
<li role="listitem"><a href="${urls.contact}" title="${i18n().contact_us}">${i18n().contact_us}</a></li>
|
||||
</#if>
|
||||
<li role="listitem"><a href="http://www.vivoweb.org/support" target="blank" title="support">Support</a></li>
|
||||
<li role="listitem"><a href="http://www.vivoweb.org/support" target="blank" title="${i18n().support}">${i18n().support}</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</footer>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<header id="branding" role="banner">
|
||||
<h1 class="vitro-logo"><a title="VITRO | web-based ontology & instance editor" href="${urls.home}"><span class="displace">${siteName}</span></a></h1>
|
||||
<h1 class="vitro-logo"><a title="${siteName}" href="${urls.home}"><span class="displace">${siteName}</span></a></h1>
|
||||
<#-- Since we are using a graphic text for the tagline, we won't render ${siteTagline}
|
||||
<#if siteTagline?has_content>
|
||||
<em>${siteTagline}</em>
|
||||
|
@ -10,19 +10,19 @@
|
|||
<nav role="navigation">
|
||||
<ul id="header-nav" role="list">
|
||||
<#include "languageSelector.ftl">
|
||||
<li role="listitem"><a href="${urls.index}" title="index">Index</a></li>
|
||||
<li role="listitem"><a href="${urls.index}" title="${i18n().index}">${i18n().index}</a></li>
|
||||
<#if user.loggedIn>
|
||||
<#if user.hasSiteAdminAccess>
|
||||
<li role="listitem"><a href="${urls.siteAdmin}" title="site admin">Site Admin</a></li>
|
||||
<li role="listitem"><a href="${urls.siteAdmin}" title="${i18n().site_admin}">${i18n().site_admin}</a></li>
|
||||
</#if>
|
||||
<li>
|
||||
<ul class="dropdown">
|
||||
<li id="user-menu"><a href="#" title="user">${user.loginName}</a>
|
||||
<li id="user-menu"><a href="#" title="${i18n().current_user}">${user.loginName}</a>
|
||||
<ul class="sub_menu">
|
||||
<#if urls.myAccount??>
|
||||
<li role="listitem"><a href="${urls.myAccount}" title="my account">My account</a></li>
|
||||
<li role="listitem"><a href="${urls.myAccount}" title="${i18n().myAccount_heading}">${i18n().myAccount_heading}</a></li>
|
||||
</#if>
|
||||
<li role="listitem"><a href="${urls.logout}" title="log out">Log out</a></li>
|
||||
<li role="listitem"><a href="${urls.logout}" title="${i18n().log_out}">${i18n().log_out}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -31,7 +31,7 @@
|
|||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/userMenu/userMenuUtils.js"></script>')}
|
||||
|
||||
<#else>
|
||||
<li role="listitem"><a class="log-out" title="log in to manage this site" href="${urls.login}">Log in</a></li>
|
||||
<li role="listitem"><a class="log-out" title="${i18n().login_to_manage_site}" href="${urls.login}">${i18n().login_button}</a></li>
|
||||
</#if>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<nav role="navigation">
|
||||
<ul id="main-nav" role="list">
|
||||
<#list menu.items as item>
|
||||
<li role="listitem"><a href="${item.url}" <#if item.active> class="selected" </#if>>${item.linkText}</a></li>
|
||||
<li role="listitem"><a href="${item.url}" <#if item.active> class="selected" </#if> title="${i18n().menu_item}">${item.linkText}</a></li>
|
||||
</#list>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -25,6 +25,6 @@
|
|||
|
||||
<!--[if lte IE 8]>
|
||||
<noscript>
|
||||
<p class="ie-alert">This site uses HTML elements that are not recognized by Internet Explorer 8 and below in the absence of JavaScript. As a result, the site will not be rendered appropriately. To correct this, please either enable JavaScript, upgrade to Internet Explorer 9, or use another browser. Here are the <a href="http://www.enable-javascript.com" title="javascript instructions">instructions for enabling JavaScript in your web browser</a>.</p>
|
||||
<p class="ie-alert">${i18n().javascript_ie_alert_text} Here are the <a href="http://www.enable-javascript.com" title="javascript instructions">${i18n().to_enable_javascript}</a>.</p>
|
||||
</noscript>
|
||||
<![endif]-->
|
|
@ -15,34 +15,34 @@
|
|||
<#include "menu.ftl">
|
||||
|
||||
<section id="intro" role="region">
|
||||
<h2>What is VITRO?</h2>
|
||||
<h2>${i18n().what_is_vitro}</h2>
|
||||
|
||||
<p>Vitro is a general-purpose web-based ontology and instance editor with customizable public browsing. Vitro is a Java web application that runs in a Tomcat servlet container.</p>
|
||||
<p>With Vitro, you can:</p>
|
||||
<p>${i18n().vitro_description}</p>
|
||||
<p>${i18n().with_vitro}</p>
|
||||
|
||||
<ul>
|
||||
<li>Create or load ontologies in OWL format</li>
|
||||
<li>Edit instances and relationships</li>
|
||||
<li>Build a public web site to display your data</li>
|
||||
<li>Search your data</li>
|
||||
<li>${i18n().vitro_bullet_one}</li>
|
||||
<li>${i18n().vitro_bullet_two}</li>
|
||||
<li>${i18n().vitro_bullet_three}</li>
|
||||
<li>${i18n().vitro_bullet_four}</li>
|
||||
</ul>
|
||||
|
||||
<section id="search-home" role="region">
|
||||
<h3>Search VITRO <span class="search-filter-selected">filteredSearch</span></h3>
|
||||
<h3>${i18n().search_vitro} <span class="search-filter-selected">filteredSearch</span></h3>
|
||||
|
||||
<fieldset>
|
||||
<legend>Search form</legend>
|
||||
<legend>${i18n().search_form}</legend>
|
||||
<form id="search-homepage" action="${urls.search}" name="search-home" role="search" method="post" >
|
||||
<div id="search-home-field">
|
||||
<input type="text" name="querytext" class="search-homepage" value="${querytext!}" autocapitalize="off" />
|
||||
<input type="submit" value="Search" class="search" />
|
||||
<input type="submit" value="${i18n().search_button}" class="search" />
|
||||
<input type="hidden" name="classgroup" class="search-homepage" value="" autocapitalize="off" />
|
||||
</div>
|
||||
|
||||
<a class="filter-search filter-default" href="#" title="Filter search"><span class="displace">filter search</span></a>
|
||||
<a class="filter-search filter-default" href="#" title="${i18n().filter_search}"><span class="displace">${i18n().filter_search}</span></a>
|
||||
|
||||
<ul id="filter-search-nav">
|
||||
<li><a class="active" href="">All</a></li>
|
||||
<li><a class="active" href="">${i18n().all_capitalized}</a></li>
|
||||
<@lh.allClassGroupNames vClassGroups! />
|
||||
</ul>
|
||||
</form>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue