Working N3 editing of display model.
This commit is contained in:
parent
c3b33b9cca
commit
f77edc315e
18 changed files with 370 additions and 47 deletions
|
@ -19,13 +19,20 @@ import com.hp.hpl.jena.query.Dataset;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
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.JenaBaseDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource.ModelName;
|
||||||
|
|
||||||
public class VitroRequest extends HttpServletRequestWrapper {
|
public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
final static Log log = LogFactory.getLog(VitroRequest.class);
|
final static Log log = LogFactory.getLog(VitroRequest.class);
|
||||||
|
|
||||||
//Attribute in case of special model editing such as display model editing
|
//Attribute in case of special model editing such as display model editing
|
||||||
public static final String SPECIAL_WRITE_MODEL = "specialWriteModel";
|
public static final String SPECIAL_WRITE_MODEL = "specialWriteModel";
|
||||||
|
|
||||||
|
public static final String ID_FOR_WRITE_MODEL = "idForWriteModel";
|
||||||
|
public static final String ID_FOR_TBOX_MODEL = "idForTboxModel";
|
||||||
|
public static final String ID_FOR_ABOX_MODEL = "idForAboxModel";
|
||||||
|
public static final String ID_FOR_DISPLAY_MODEL = "idForDisplayModel";
|
||||||
|
|
||||||
private HttpServletRequest _req;
|
private HttpServletRequest _req;
|
||||||
|
|
||||||
public VitroRequest(HttpServletRequest _req) {
|
public VitroRequest(HttpServletRequest _req) {
|
||||||
|
@ -175,6 +182,46 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an identifier for the display model associated
|
||||||
|
* with this request. It may have been switched from
|
||||||
|
* the normal display model to a different one.
|
||||||
|
* This could be a URI or a {@link ModelName}
|
||||||
|
*/
|
||||||
|
public String getIdForDisplayModel(){
|
||||||
|
return (String)getAttribute(ID_FOR_DISPLAY_MODEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an identifier for the a-box model associated
|
||||||
|
* with this request. It may have been switched from
|
||||||
|
* the standard one to a different one.
|
||||||
|
* This could be a URI or a {@link ModelName}
|
||||||
|
*/
|
||||||
|
public String getNameForABOXModel(){
|
||||||
|
return (String)getAttribute(ID_FOR_ABOX_MODEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an identifier for the t-box model associated
|
||||||
|
* with this request. It may have been switched from
|
||||||
|
* the standard one to a different one.
|
||||||
|
* This could be a URI or a {@link ModelName}
|
||||||
|
*/
|
||||||
|
public String getNameForTBOXModel(){
|
||||||
|
return (String)getAttribute(ID_FOR_TBOX_MODEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an identifier for the write model associated
|
||||||
|
* with this request. It may have been switched from
|
||||||
|
* the standard one to a different one.
|
||||||
|
* This could be a URI or a {@link ModelName}
|
||||||
|
*/
|
||||||
|
public String getNameForWriteModel(){
|
||||||
|
return (String)getAttribute(ID_FOR_WRITE_MODEL);
|
||||||
|
}
|
||||||
|
|
||||||
public ApplicationBean getAppBean(){
|
public ApplicationBean getAppBean(){
|
||||||
//return (ApplicationBean) getAttribute("appBean");
|
//return (ApplicationBean) getAttribute("appBean");
|
||||||
return getWebappDaoFactory().getApplicationDao().getApplicationBean();
|
return getWebappDaoFactory().getApplicationDao().getApplicationBean();
|
||||||
|
@ -198,4 +245,6 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
public String[] getParameterValues(String name) {
|
public String[] getParameterValues(String name) {
|
||||||
return _req.getParameterValues(name);
|
return _req.getParameterValues(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
|
|
||||||
getOntModel().enterCriticalSection(Lock.READ);
|
getOntModel().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
OntProperty op = getOntModel().getOntProperty(propertyURI);
|
OntProperty op = getOntModel().getObjectProperty(propertyURI);
|
||||||
return propertyFromOntProperty(op);
|
return propertyFromOntProperty(op);
|
||||||
} finally {
|
} finally {
|
||||||
getOntModel().leaveCriticalSection();
|
getOntModel().leaveCriticalSection();
|
||||||
|
|
|
@ -13,30 +13,37 @@ public class OntModelSelectorImpl implements OntModelSelector {
|
||||||
private OntModel tboxModel;
|
private OntModel tboxModel;
|
||||||
private OntModel userAccountsModel;
|
private OntModel userAccountsModel;
|
||||||
|
|
||||||
|
@Override
|
||||||
public OntModel getABoxModel() {
|
public OntModel getABoxModel() {
|
||||||
return this.aboxModel;
|
return this.aboxModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OntModel getApplicationMetadataModel() {
|
public OntModel getApplicationMetadataModel() {
|
||||||
return this.applicationMetadataModel;
|
return this.applicationMetadataModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OntModel getDisplayModel() {
|
public OntModel getDisplayModel() {
|
||||||
return this.displayModel;
|
return this.displayModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OntModel getFullModel() {
|
public OntModel getFullModel() {
|
||||||
return this.fullModel;
|
return this.fullModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OntModel getTBoxModel() {
|
public OntModel getTBoxModel() {
|
||||||
return this.tboxModel;
|
return this.tboxModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OntModel getTBoxModel(String ontologyURI) {
|
public OntModel getTBoxModel(String ontologyURI) {
|
||||||
return this.tboxModel;
|
return this.tboxModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OntModel getUserAccountsModel() {
|
public OntModel getUserAccountsModel() {
|
||||||
return this.userAccountsModel;
|
return this.userAccountsModel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ModelSource that will handle specially named Vitro models such
|
||||||
|
* as display and t-box. Any other models will be retrieved from
|
||||||
|
* the inner ModelSource.
|
||||||
|
*
|
||||||
|
* None of these models will be retrieved
|
||||||
|
* from the attributes of a ServletRequest.
|
||||||
|
*/
|
||||||
|
public class VitroModelSource implements ModelSource {
|
||||||
|
|
||||||
|
private ModelSource innerSource;
|
||||||
|
private ServletContext context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each of these values identifies a model in the system.
|
||||||
|
*/
|
||||||
|
public enum ModelName {
|
||||||
|
/** Name for default assertion model. */
|
||||||
|
ABOX,
|
||||||
|
/** Name of default t-box for default assertion model. */
|
||||||
|
TBOX,
|
||||||
|
/** Name for default display model related to ABOX and TBOX. */
|
||||||
|
DISPLAY,
|
||||||
|
/** Name for t-box for DISPLAY. */
|
||||||
|
DISPLAY_TBOX,
|
||||||
|
/** Name for display model related to DISPLAY and DISPLAY_TBOX. */
|
||||||
|
DISPLAY_DISPLAY,
|
||||||
|
/** Name for user accounts model. */
|
||||||
|
USER_ACCOUNTS
|
||||||
|
|
||||||
|
//may need a way to specify unions of these models and unions of URI models
|
||||||
|
}
|
||||||
|
|
||||||
|
public VitroModelSource(ModelSource innerSource, ServletContext context){
|
||||||
|
this.innerSource = innerSource;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getModel(String arg0) {
|
||||||
|
ModelName pn = getModelName( arg0 );
|
||||||
|
if( pn != null ){
|
||||||
|
return getNamedModel(pn);
|
||||||
|
}else{
|
||||||
|
return innerSource.getModel(arg0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getModel(String arg0, ModelReader arg1) {
|
||||||
|
ModelName pn = getModelName( arg0 );
|
||||||
|
if( pn != null ){
|
||||||
|
return getNamedModel(pn);
|
||||||
|
}else{
|
||||||
|
return innerSource.getModel(arg0,arg1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model createDefaultModel() {
|
||||||
|
return innerSource.createDefaultModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model createFreshModel() {
|
||||||
|
return innerSource.createFreshModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model openModel(String arg0) {
|
||||||
|
ModelName pn = getModelName( arg0 );
|
||||||
|
if( pn != null ){
|
||||||
|
return getNamedModel( pn );
|
||||||
|
}else{
|
||||||
|
return innerSource.openModel(arg0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model openModelIfPresent(String arg0) {
|
||||||
|
ModelName pn = getModelName( arg0 );
|
||||||
|
if( pn != null ){
|
||||||
|
return getNamedModel( pn );
|
||||||
|
}else{
|
||||||
|
return innerSource.openModelIfPresent(arg0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should not return null for any value of pmn in
|
||||||
|
* the enum PrivilegedModelName.
|
||||||
|
*/
|
||||||
|
private Model getNamedModel( ModelName pmn ){
|
||||||
|
switch( pmn ){
|
||||||
|
case ABOX:
|
||||||
|
return (Model) context.getAttribute("jenaOntModel");
|
||||||
|
case TBOX:
|
||||||
|
return (Model) context.getAttribute("tboxmodel???");
|
||||||
|
case DISPLAY:
|
||||||
|
return (Model) context.getAttribute(DisplayVocabulary.DISPLAY_ONT_MODEL );
|
||||||
|
case DISPLAY_TBOX:
|
||||||
|
return (Model) context.getAttribute(DisplayVocabulary.CONTEXT_DISPLAY_TBOX);
|
||||||
|
case DISPLAY_DISPLAY:
|
||||||
|
return (Model) context.getAttribute(DisplayVocabulary.CONTEXT_DISPLAY_DISPLAY);
|
||||||
|
case USER_ACCOUNTS:
|
||||||
|
throw new IllegalArgumentException("getNamedModel() Does not yet handle USER_ACCOUNTS");
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("getNamedModel() should handle all values for enum PrivilegedModelName");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns null if the string is not a ModelName.
|
||||||
|
*/
|
||||||
|
public static ModelName getModelName( String string ){
|
||||||
|
if( StringUtils.isEmpty(string))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
return ModelName.valueOf( string.trim().toUpperCase());
|
||||||
|
}catch(IllegalArgumentException ex){
|
||||||
|
//Did not find value in enum ModelName for the string, no problem.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -147,6 +147,8 @@ public class EditConfigurationVTwo {
|
||||||
private ProhibitedFromSearch prohibitedFromSearch;
|
private ProhibitedFromSearch prohibitedFromSearch;
|
||||||
|
|
||||||
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
||||||
|
//How about we change pageData to something else since page is in the name of just about everything related
|
||||||
|
//to templates.
|
||||||
private HashMap<String, Object> formSpecificData;
|
private HashMap<String, Object> formSpecificData;
|
||||||
|
|
||||||
/** Name of freemarker template to generate form. */
|
/** Name of freemarker template to generate form. */
|
||||||
|
@ -161,6 +163,15 @@ public class EditConfigurationVTwo {
|
||||||
*/
|
*/
|
||||||
private boolean useDependentResourceDelete = true;
|
private boolean useDependentResourceDelete = true;
|
||||||
|
|
||||||
|
/** Model id from write model. */
|
||||||
|
private String writeModelId;
|
||||||
|
|
||||||
|
/** Model id for the abox. */
|
||||||
|
private String aboxModelId;
|
||||||
|
|
||||||
|
/** Model id for the tbox. */
|
||||||
|
private String tboxModelId;
|
||||||
|
|
||||||
/** Model to write changes of a completed edit to. Usually this is null
|
/** Model to write changes of a completed edit to. Usually this is null
|
||||||
* and the edit will be written to the main graph of the system. */
|
* and the edit will be written to the main graph of the system. */
|
||||||
private ModelSelector writeModelSelector;
|
private ModelSelector writeModelSelector;
|
||||||
|
@ -904,12 +915,17 @@ public class EditConfigurationVTwo {
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
||||||
//This is for specific data for a form that will be set by the generator
|
//How about we change pageData to something else since page is in the name of just about everything related
|
||||||
|
//to templates.
|
||||||
|
|
||||||
|
/** This is for specific data for a form that will be set by the generator. */
|
||||||
public void setFormSpecificData(HashMap<String, Object> formSpecificData) {
|
public void setFormSpecificData(HashMap<String, Object> formSpecificData) {
|
||||||
this.formSpecificData = formSpecificData;
|
this.formSpecificData = formSpecificData;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
||||||
|
//How about we change pageData to something else since page is in the name of just about everything related
|
||||||
|
//to templates.
|
||||||
public void addFormSpecificData( String key, Object value){
|
public void addFormSpecificData( String key, Object value){
|
||||||
if( this.formSpecificData == null){
|
if( this.formSpecificData == null){
|
||||||
this.formSpecificData = new HashMap<String,Object>();
|
this.formSpecificData = new HashMap<String,Object>();
|
||||||
|
@ -918,8 +934,10 @@ public class EditConfigurationVTwo {
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
//TODO: can we rename this to match the name "pageData" that is used on the templates for this?
|
||||||
|
//How about we change pageData to something else since page is in the name of just about everything related
|
||||||
|
//to templates.
|
||||||
|
|
||||||
public HashMap<String, Object> getFormSpecificData() {
|
public HashMap<String, Object> getFormSpecificData() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return this.formSpecificData;
|
return this.formSpecificData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,4 +1065,27 @@ public class EditConfigurationVTwo {
|
||||||
return skipToUrl;
|
return skipToUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWriteModelId(String writeModelId) {
|
||||||
|
this.writeModelId = writeModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWriteModelId() {
|
||||||
|
return writeModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAboxModelId(String aboxModelId) {
|
||||||
|
this.aboxModelId = aboxModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAboxModelId() {
|
||||||
|
return aboxModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTboxModelId(String tboxModelId) {
|
||||||
|
this.tboxModelId = tboxModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTboxModelId() {
|
||||||
|
return tboxModelId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,14 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.EditConfigurationGenerator;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.RDFSLabelGenerator;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ModelChangePreprocessor;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ModelChangePreprocessor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
|
||||||
|
|
||||||
|
@ -46,8 +42,6 @@ public class N3EditUtils {
|
||||||
EditConfigurationVTwo configuration,
|
EditConfigurationVTwo configuration,
|
||||||
MultiValueEditSubmission submission,
|
MultiValueEditSubmission submission,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
//TODO: move this method to utils or contorller?
|
|
||||||
|
|
||||||
String returnTo = null;
|
String returnTo = null;
|
||||||
|
|
||||||
//usually the submission should have a returnTo that is
|
//usually the submission should have a returnTo that is
|
||||||
|
@ -67,13 +61,15 @@ public class N3EditUtils {
|
||||||
n3Subber.subInMultiUris(submission.getUrisFromForm(), entityToReturnTo);
|
n3Subber.subInMultiUris(submission.getUrisFromForm(), entityToReturnTo);
|
||||||
n3Subber.subInMultiLiterals(submission.getLiteralsFromForm(), entityToReturnTo);
|
n3Subber.subInMultiLiterals(submission.getLiteralsFromForm(), entityToReturnTo);
|
||||||
|
|
||||||
//TODO: this won't work, must the same new resources as in ProcessRdfForm.process
|
//TODO: this won't work to get new resoruce URIs,
|
||||||
|
//must the same new resources as in ProcessRdfForm.process
|
||||||
//setVarToNewResource(configuration, vreq);
|
//setVarToNewResource(configuration, vreq);
|
||||||
//entityToReturnTo = n3Subber.subInMultiUris(varToNewResource, entityToReturnTo);
|
//entityToReturnTo = n3Subber.subInMultiUris(varToNewResource, entityToReturnTo);
|
||||||
|
|
||||||
returnTo = entityToReturnTo.get(0);
|
returnTo = entityToReturnTo.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: what is this about?
|
//remove brackets from sub in of URIs
|
||||||
if(returnTo != null) {
|
if(returnTo != null) {
|
||||||
returnTo = returnTo.trim().replaceAll("<","").replaceAll(">","");
|
returnTo = returnTo.trim().replaceAll("<","").replaceAll(">","");
|
||||||
}
|
}
|
||||||
|
@ -90,7 +86,7 @@ public class N3EditUtils {
|
||||||
EditConfigurationVTwo editConfig,
|
EditConfigurationVTwo editConfig,
|
||||||
MultiValueEditSubmission submission,
|
MultiValueEditSubmission submission,
|
||||||
VitroRequest vreq,
|
VitroRequest vreq,
|
||||||
OntModel writeModel) {
|
Model writeModel) {
|
||||||
|
|
||||||
//now setup an EditConfiguration so a single back button submissions can be handled
|
//now setup an EditConfiguration so a single back button submissions can be handled
|
||||||
//Do this if data property
|
//Do this if data property
|
||||||
|
|
|
@ -217,22 +217,25 @@ public class ProcessRdfForm {
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: move this to utils or controller?
|
|
||||||
public static void applyChangesToWriteModel(
|
public static void applyChangesToWriteModel(
|
||||||
AdditionsAndRetractions changes,
|
AdditionsAndRetractions changes,
|
||||||
OntModel queryModel, OntModel writeModel, String editorUri) {
|
Model queryModel, Model writeModel, String editorUri) {
|
||||||
//side effect: modify the write model with the changes
|
//side effect: modify the write model with the changes
|
||||||
Lock lock = null;
|
Lock lock = null;
|
||||||
try{
|
try{
|
||||||
lock = writeModel.getLock();
|
lock = writeModel.getLock();
|
||||||
lock.enterCriticalSection(Lock.WRITE);
|
lock.enterCriticalSection(Lock.WRITE);
|
||||||
writeModel.getBaseModel().notifyEvent(new EditEvent(editorUri,true));
|
if( writeModel instanceof OntModel){
|
||||||
|
((OntModel)writeModel).getBaseModel().notifyEvent(new EditEvent(editorUri,true));
|
||||||
|
}
|
||||||
writeModel.add( changes.getAdditions() );
|
writeModel.add( changes.getAdditions() );
|
||||||
writeModel.remove( changes.getRetractions() );
|
writeModel.remove( changes.getRetractions() );
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
log.error("error adding edit change n3required model to in memory model \n"+ t.getMessage() );
|
log.error("error adding edit change n3required model to in memory model \n"+ t.getMessage() );
|
||||||
}finally{
|
}finally{
|
||||||
writeModel.getBaseModel().notifyEvent(new EditEvent(editorUri,false));
|
if( writeModel instanceof OntModel){
|
||||||
|
((OntModel)writeModel).getBaseModel().notifyEvent(new EditEvent(editorUri,false));
|
||||||
|
}
|
||||||
lock.leaveCriticalSection();
|
lock.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||||
*
|
*
|
||||||
* Literals in literalsOnForm and literalsInScope should be escaped and quoted
|
* Literals in literalsOnForm and literalsInScope should be escaped and quoted
|
||||||
* in preparation for N3. They may also be appended with a datatype or lang.
|
* in preparation for N3. They may also be appended with a datatype or lang.
|
||||||
|
*
|
||||||
|
* @deprecated Use EditConfigurationVTwo instead of this class.
|
||||||
*/
|
*/
|
||||||
public class EditConfiguration {
|
public class EditConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||||
|
|
||||||
|
|
||||||
|
public class IdModelSelector implements ModelSelector{
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public IdModelSelector(String name){
|
||||||
|
if( name == null )
|
||||||
|
throw new IllegalArgumentException("Name of model must not be null.");
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getModel(HttpServletRequest request, ServletContext context) {
|
||||||
|
VitroModelSource mSource = JenaDataSourceSetupBase.getVitroModelSource(context);
|
||||||
|
Model m = mSource.getModel( name );
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,8 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
public interface ModelSelector {
|
public interface ModelSelector {
|
||||||
public OntModel getModel(HttpServletRequest request, ServletContext context);
|
public Model getModel(HttpServletRequest request, ServletContext context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.DirectRedirectResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.DirectRedirectResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditSubmissionUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditSubmissionUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
|
@ -61,10 +63,12 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
||||||
|
|
||||||
//The submission for getting the entity to return to is not retrieved from the session but needs
|
//The submission for getting the entity to return to is not retrieved from the session but needs
|
||||||
//to be created - as it is in processRdfForm3.jsp
|
//to be created - as it is in processRdfForm3.jsp
|
||||||
//TODO: this will not work if there entityToReturnTo has a new resource URI
|
if( entityToReturnTo == null ){
|
||||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(vreq.getParameterMap(), editConfig);
|
//this will not work if there entityToReturnTo has a new resource URI,
|
||||||
if( entityToReturnTo == null )
|
//in that case entityToReturnTo should not have been passed to this method as null
|
||||||
|
MultiValueEditSubmission submission = new MultiValueEditSubmission(vreq.getParameterMap(), editConfig);
|
||||||
entityToReturnTo = N3EditUtils.processEntityToReturnTo(editConfig, submission, vreq);
|
entityToReturnTo = N3EditUtils.processEntityToReturnTo(editConfig, submission, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
//Get url pattern
|
//Get url pattern
|
||||||
String urlPattern = Utilities.getPostEditUrlPattern(vreq, editConfig);
|
String urlPattern = Utilities.getPostEditUrlPattern(vreq, editConfig);
|
||||||
|
@ -78,6 +82,7 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
||||||
paramMap.put("extra","true"); //for ie6
|
paramMap.put("extra","true"); //for ie6
|
||||||
//If url already contains an ? then need to add extra params
|
//If url already contains an ? then need to add extra params
|
||||||
String path = UrlBuilder.addParams(urlPattern, paramMap);
|
String path = UrlBuilder.addParams(urlPattern, paramMap);
|
||||||
|
path += getSpecialModelParam( vreq, editConfig);
|
||||||
path += getPredicateAnchor( vreq, editConfig );
|
path += getPredicateAnchor( vreq, editConfig );
|
||||||
return new RedirectResponseValues( path );
|
return new RedirectResponseValues( path );
|
||||||
|
|
||||||
|
@ -95,6 +100,7 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
||||||
paramMap.put("uri", editConfig.getSubjectUri() );
|
paramMap.put("uri", editConfig.getSubjectUri() );
|
||||||
paramMap.put("extra","true"); //for ie6
|
paramMap.put("extra","true"); //for ie6
|
||||||
String path = UrlBuilder.getPath( UrlBuilder.Route.INDIVIDUAL, paramMap);
|
String path = UrlBuilder.getPath( UrlBuilder.Route.INDIVIDUAL, paramMap);
|
||||||
|
path += getSpecialModelParam( vreq, editConfig);
|
||||||
path += getPredicateAnchor( vreq, editConfig );
|
path += getPredicateAnchor( vreq, editConfig );
|
||||||
return new RedirectResponseValues( path );
|
return new RedirectResponseValues( path );
|
||||||
|
|
||||||
|
@ -104,6 +110,16 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getSpecialModelParam(VitroRequest vreq,
|
||||||
|
EditConfigurationVTwo editConfig) {
|
||||||
|
if( editConfig.getAboxModelId() != null &&
|
||||||
|
editConfig.getAboxModelId().equals(VitroModelSource.ModelName.DISPLAY.toString())){
|
||||||
|
return "&"+ DisplayVocabulary.SWITCH_TO_DISPLAY_MODEL + "=1";
|
||||||
|
}else{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void doPostEditCleanup( VitroRequest vreq ) {
|
public static void doPostEditCleanup( VitroRequest vreq ) {
|
||||||
EditConfigurationVTwo configuration = EditConfigurationVTwo.getConfigFromSession(vreq.getSession(), vreq);
|
EditConfigurationVTwo configuration = EditConfigurationVTwo.getConfigFromSession(vreq.getSession(), vreq);
|
||||||
if(configuration == null)
|
if(configuration == null)
|
||||||
|
|
|
@ -72,8 +72,8 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
||||||
return errorResponse;
|
return errorResponse;
|
||||||
|
|
||||||
// get the models to work with in case the write model and query model are not the defaults
|
// get the models to work with in case the write model and query model are not the defaults
|
||||||
OntModel queryModel = configuration.getQueryModelSelector().getModel(vreq, getServletContext());
|
Model queryModel = configuration.getQueryModelSelector().getModel(vreq, getServletContext());
|
||||||
OntModel writeModel = configuration.getWriteModelSelector().getModel(vreq,getServletContext());
|
Model writeModel = configuration.getWriteModelSelector().getModel(vreq,getServletContext());
|
||||||
|
|
||||||
//If data property check for back button confusion
|
//If data property check for back button confusion
|
||||||
boolean isBackButton = checkForBackButtonConfusion(configuration, vreq, queryModel);
|
boolean isBackButton = checkForBackButtonConfusion(configuration, vreq, queryModel);
|
||||||
|
|
|
@ -29,11 +29,15 @@ import com.hp.hpl.jena.vocabulary.XSD;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.elements.EditElement;
|
import edu.cornell.mannlib.vitro.webapp.edit.elements.EditElement;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.BasicValidation;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.BasicValidation;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.N3Validator;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.N3Validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link MultiValueEditSubmission}
|
||||||
|
*/
|
||||||
public class EditSubmission {
|
public class EditSubmission {
|
||||||
String editKey;
|
String editKey;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ 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.HideFromDisplayByPolicyFilter;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
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.WebappDaoFactoryJena;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
||||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||||
|
@ -144,8 +145,9 @@ public class VitroRequestPrep implements Filter {
|
||||||
log.debug("Found a WebappDaoFactory in the session and using it for this request");
|
log.debug("Found a WebappDaoFactory in the session and using it for this request");
|
||||||
}
|
}
|
||||||
|
|
||||||
//replace the WebappDaoFactory with a different version if menu management parameter is found
|
//Do model switching and replace the WebappDaoFactory with
|
||||||
wdf = checkForSpecialWDF(vreq, wdf);
|
//a different version if requested by parameters
|
||||||
|
wdf = checkForModelSwitching(vreq, wdf);
|
||||||
|
|
||||||
//get any filters from the ContextFitlerFactory
|
//get any filters from the ContextFitlerFactory
|
||||||
VitroFilters filters = getFiltersFromContextFilterFactory(req, wdf);
|
VitroFilters filters = getFiltersFromContextFilterFactory(req, wdf);
|
||||||
|
@ -214,7 +216,7 @@ public class VitroRequestPrep implements Filter {
|
||||||
* model for menu management. Also enables the use of a completely different
|
* model for menu management. Also enables the use of a completely different
|
||||||
* model and tbox if uris are passed.
|
* model and tbox if uris are passed.
|
||||||
*/
|
*/
|
||||||
private WebappDaoFactory checkForSpecialWDF(VitroRequest vreq, WebappDaoFactory inputWadf) {
|
private WebappDaoFactory checkForModelSwitching(VitroRequest vreq, WebappDaoFactory inputWadf) {
|
||||||
//TODO: Does the dataset in the vreq get set when using a special WDF? Does it need to?
|
//TODO: Does the dataset in the vreq get set when using a special WDF? Does it need to?
|
||||||
//TODO: Does the unfiltered WDF get set when using a special WDF? Does it need to?
|
//TODO: Does the unfiltered WDF get set when using a special WDF? Does it need to?
|
||||||
|
|
||||||
|
@ -233,6 +235,12 @@ public class VitroRequestPrep implements Filter {
|
||||||
OntModel mainOntModel = (OntModel)_context.getAttribute( DISPLAY_ONT_MODEL);
|
OntModel mainOntModel = (OntModel)_context.getAttribute( DISPLAY_ONT_MODEL);
|
||||||
OntModel tboxOntModel = (OntModel) _context.getAttribute(CONTEXT_DISPLAY_TBOX);
|
OntModel tboxOntModel = (OntModel) _context.getAttribute(CONTEXT_DISPLAY_TBOX);
|
||||||
setSpecialWriteModel(vreq, mainOntModel);
|
setSpecialWriteModel(vreq, mainOntModel);
|
||||||
|
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_ABOX_MODEL, VitroModelSource.ModelName.DISPLAY.toString());
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_TBOX_MODEL, VitroModelSource.ModelName.DISPLAY_TBOX.toString());
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_DISPLAY_MODEL, VitroModelSource.ModelName.DISPLAY_DISPLAY.toString());
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_WRITE_MODEL, VitroModelSource.ModelName.DISPLAY.toString());
|
||||||
|
|
||||||
return createNewWebappDaoFactory(wadf, mainOntModel, tboxOntModel, null);
|
return createNewWebappDaoFactory(wadf, mainOntModel, tboxOntModel, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,6 +253,12 @@ public class VitroRequestPrep implements Filter {
|
||||||
OntModel mainOntModel = createSpecialModel(vreq, USE_MODEL_PARAM, bds, dbType);
|
OntModel mainOntModel = createSpecialModel(vreq, USE_MODEL_PARAM, bds, dbType);
|
||||||
OntModel tboxOntModel = createSpecialModel(vreq, USE_TBOX_MODEL_PARAM, bds, dbType);
|
OntModel tboxOntModel = createSpecialModel(vreq, USE_TBOX_MODEL_PARAM, bds, dbType);
|
||||||
OntModel displayOntModel = createSpecialModel(vreq, USE_DISPLAY_MODEL_PARAM, bds, dbType);
|
OntModel displayOntModel = createSpecialModel(vreq, USE_DISPLAY_MODEL_PARAM, bds, dbType);
|
||||||
|
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_ABOX_MODEL, vreq.getParameter(USE_MODEL_PARAM));
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_WRITE_MODEL, vreq.getParameter(USE_MODEL_PARAM));
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_TBOX_MODEL, vreq.getParameter(USE_TBOX_MODEL_PARAM));
|
||||||
|
vreq.setAttribute(VitroRequest.ID_FOR_DISPLAY_MODEL, vreq.getParameter(USE_DISPLAY_MODEL_PARAM));
|
||||||
|
|
||||||
setSpecialWriteModel(vreq, mainOntModel);
|
setSpecialWriteModel(vreq, mainOntModel);
|
||||||
return createNewWebappDaoFactory(wadf, mainOntModel, tboxOntModel, displayOntModel);
|
return createNewWebappDaoFactory(wadf, mainOntModel, tboxOntModel, displayOntModel);
|
||||||
}
|
}
|
||||||
|
@ -295,10 +309,8 @@ public class VitroRequestPrep implements Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSpecialWriteModel(VitroRequest vreq, OntModel mainOntModel) {
|
private void setSpecialWriteModel(VitroRequest vreq, OntModel mainOntModel) {
|
||||||
//bdc34: not clear where the special model needs to be set.
|
|
||||||
vreq.setAttribute("jenaOntModel", mainOntModel);
|
|
||||||
|
|
||||||
if (mainOntModel != null) {
|
if (mainOntModel != null) {
|
||||||
|
vreq.setAttribute("jenaOntModel", mainOntModel);
|
||||||
vreq.setAttribute(SPECIAL_WRITE_MODEL, mainOntModel);
|
vreq.setAttribute(SPECIAL_WRITE_MODEL, mainOntModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ 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.OntModelSelectorImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
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.jena.VitroJenaSDBModelMaker;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.InitialJenaModelUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.jena.InitialJenaModelUtils;
|
||||||
|
@ -324,9 +325,14 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase
|
||||||
VitroJenaSDBModelMaker vsmm = getVitroJenaSDBModelMaker();
|
VitroJenaSDBModelMaker vsmm = getVitroJenaSDBModelMaker();
|
||||||
setVitroJenaSDBModelMaker(vsmm, ctx);
|
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");
|
log.info("Model makers set up");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we find a "portal1" portal (and we should), its URI should use the
|
* If we find a "portal1" portal (and we should), its URI should use the
|
||||||
* default namespace.
|
* default namespace.
|
||||||
|
|
|
@ -32,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.RegeneratingGraph;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SDBGraphGenerator;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.SDBGraphGenerator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
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.jena.VitroJenaSDBModelMaker;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
|
||||||
|
|
||||||
public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
private static final String VITRO_DEFAULT_NAMESPACE = "Vitro.defaultNamespace";
|
private static final String VITRO_DEFAULT_NAMESPACE = "Vitro.defaultNamespace";
|
||||||
|
@ -394,9 +395,13 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
|
|
||||||
private static VitroJenaModelMaker vjmm = null;
|
private static VitroJenaModelMaker vjmm = null;
|
||||||
private static VitroJenaSDBModelMaker vsmm = null;
|
private static VitroJenaSDBModelMaker vsmm = null;
|
||||||
|
private static VitroModelSource vms = null;
|
||||||
private static final String sdbModelMaker = "vitroJenaSDBModelMaker";
|
private static final String sdbModelMaker = "vitroJenaSDBModelMaker";
|
||||||
private static final String rdbModelMaker = "vitroJenaModelMaker";
|
private static final String rdbModelMaker = "vitroJenaModelMaker";
|
||||||
|
private static final String vitroModelSource = "vitroModelSource";
|
||||||
|
|
||||||
|
//bdc34: is there any good reason that this doesn't just return the objects instead
|
||||||
|
//of oddly passing them around as static properties on this class?
|
||||||
protected void makeModelMakerFromConnectionProperties(TripleStoreType type,
|
protected void makeModelMakerFromConnectionProperties(TripleStoreType type,
|
||||||
ServletContext ctx) {
|
ServletContext ctx) {
|
||||||
String jdbcUrl = getJdbcUrl(ctx);
|
String jdbcUrl = getJdbcUrl(ctx);
|
||||||
|
@ -453,6 +458,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
String format = getRdfFormat( file.getName() );
|
String format = getRdfFormat( file.getName() );
|
||||||
try{
|
try{
|
||||||
model.read( new FileInputStream(file), null, format);
|
model.read( new FileInputStream(file), null, format);
|
||||||
|
log.info("read in file " + file.getCanonicalPath() );
|
||||||
}catch( Throwable th){
|
}catch( Throwable th){
|
||||||
log.warn("Could not load file " +
|
log.warn("Could not load file " +
|
||||||
file.getAbsolutePath() + file.separator + file.getName() +
|
file.getAbsolutePath() + file.separator + file.getName() +
|
||||||
|
@ -474,6 +480,11 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
ctx.setAttribute(sdbModelMaker, vsmm);
|
ctx.setAttribute(sdbModelMaker, vsmm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setVitroModelSource(VitroModelSource vms,ServletContext ctx) {
|
||||||
|
ctx.setAttribute( vitroModelSource, vms);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected String getDefaultNamespace(ServletContext ctx) {
|
protected String getDefaultNamespace(ServletContext ctx) {
|
||||||
String dns = ConfigurationProperties.getBean(ctx).getProperty(
|
String dns = ConfigurationProperties.getBean(ctx).getProperty(
|
||||||
VITRO_DEFAULT_NAMESPACE);
|
VITRO_DEFAULT_NAMESPACE);
|
||||||
|
@ -493,6 +504,10 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
return vsmm;
|
return vsmm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static VitroModelSource getVitroModelSource(ServletContext ctx){
|
||||||
|
return (VitroModelSource)ctx.getAttribute(vitroModelSource);
|
||||||
|
}
|
||||||
|
|
||||||
private static String getDbType(ServletContext ctx) {
|
private static String getDbType(ServletContext ctx) {
|
||||||
return ConfigurationProperties.getBean(ctx).getProperty( // database type
|
return ConfigurationProperties.getBean(ctx).getProperty( // database type
|
||||||
"VitroConnection.DataSource.dbtype", "MySQL");
|
"VitroConnection.DataSource.dbtype", "MySQL");
|
||||||
|
|
|
@ -143,6 +143,7 @@ public class JenaPersistentDataSourceSetup extends JenaDataSourceSetupBase
|
||||||
* in the database and it will be reloaded each time the system starts up.
|
* in the database and it will be reloaded each time the system starts up.
|
||||||
*/
|
*/
|
||||||
private void initializeDisplayLoadedAtStartup(ServletContext ctx, OntModel displayModel){
|
private void initializeDisplayLoadedAtStartup(ServletContext ctx, OntModel displayModel){
|
||||||
|
log.info("loading display model from files in " + ctx.getRealPath(DISPLAY_MODEL_LOAD_AT_STARTUP_DIR) );
|
||||||
Model displayLoadAtStartup = readInDisplayModelLoadAtStartup(ctx);
|
Model displayLoadAtStartup = readInDisplayModelLoadAtStartup(ctx);
|
||||||
|
|
||||||
if( log.isDebugEnabled() ){
|
if( log.isDebugEnabled() ){
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<#assign property = editConfiguration.objectPropertyStatementDisplayPropertyModel />
|
<#assign property = editConfiguration.objectPropertyStatementDisplayPropertyModel />
|
||||||
</#if>
|
</#if>
|
||||||
<#else>
|
<#else>
|
||||||
<#assign statement = editConfiguration.dataStatementDisplay />
|
<#assign statement = editConfiguration.pageData.dataPropertyLexicalValue />
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#assign deletionTemplateName = editConfiguration.deleteTemplate/>
|
<#assign deletionTemplateName = editConfiguration.deleteTemplate/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue