diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java index 4a18fb6c6..e0a67114b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java @@ -50,10 +50,8 @@ public class VclassEditController extends BaseEditController { VClass vcl = (VClass)vcwDao.getVClassByURI(request.getParameter("uri")); if (vcl == null) { - if (VitroModelProperties.isRDFS(request.getFullWebappDaoFactory().getLanguageProfile()) - && ( (RDF.getURI()+"Resource").equals(request.getParameter("uri")))) { - vcl = new VClass(RDF.getURI()+"Resource"); - } + vcl = request.getFullWebappDaoFactory() + .getVClassDao().getTopConcept(); } request.setAttribute("VClass",vcl); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ClassHierarchyListingController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ClassHierarchyListingController.java index 95c3e50c5..64b619880 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ClassHierarchyListingController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ClassHierarchyListingController.java @@ -84,36 +84,15 @@ public class ClassHierarchyListingController extends BaseEditController { } else if (startClassUri != null) { roots = new LinkedList(); roots.add(vcDao.getVClassByURI(startClassUri)); - } else { - /* TODO: this needs more thinking */ - if (false) { // (getWebappDaoFactory() instanceof WebappDaoFactoryJena) { - String topConceptURI = null; - int langProfile = ((WebappDaoFactoryJena) vrequest.getFullWebappDaoFactory()).getLanguageProfile(); - if (langProfile==WebappDaoFactoryJena.OWL_CONST) { - topConceptURI = OWL.Thing.getURI(); - } else if (langProfile==WebappDaoFactoryJena.RDFS_CONST) { - topConceptURI = RDFS.Resource.getURI(); - } - VClass top = vcDao.getVClassByURI(topConceptURI); - if (top != null) { - roots = new LinkedList(); - roots.add(top); - } else { - roots = vcDao.getRootClasses(); - } - } else { - roots = vcDao.getRootClasses(); - } + } else { + roots = vcDao.getRootClasses(); } // DEBUGGING if (roots == null) { roots = new LinkedList(); - if (VitroModelProperties.isOWL(vrequest.getFullWebappDaoFactory().getLanguageProfile())) { - roots.add(vcDao.getVClassByURI(OWL.Thing.getURI())); - } else if (VitroModelProperties.isRDFS(vrequest.getFullWebappDaoFactory().getLanguageProfile())) { - roots.add(new VClass(RDF.getURI()+"Resource")); - } + roots.add(vrequest.getFullWebappDaoFactory().getVClassDao() + .getTopConcept()); } Collections.sort(roots); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/FlagDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/FlagDao.java deleted file mode 100644 index 52bb021c9..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/FlagDao.java +++ /dev/null @@ -1,16 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao; - -/** - * Created by IntelliJ IDEA. - * User: bdc34 - * Date: Apr 18, 2007 - * Time: 4:32:30 PM - * To change this template use File | Settings | File Templates. - */ -public interface FlagDao { - String getFlagNames(String table, String field); - public String convertNumericFlagToInsertString(int numeric,String column,String table); - public String convertNumericFlagToInsertString(int numeric,String flagColumns); -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java index 38c393fdf..4bc12674f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java @@ -8,27 +8,33 @@ import java.util.Set; public interface WebappDaoFactory { + /** + * Free any resources associated with this WebappDaoFactory + */ + public void close(); + /** - * Retrieves a map containing arbitrary key-value pairs describing this WebappDaoFactory + * Retrieves a map containing arbitrary key-value pairs describing this + * WebappDaoFactory */ public Map getProperties(); /** - * Checks a URI String for two things: well-formedness and uniqueness in the model. - * Ill-formed strings or those matching URIs already in use will cause an error message to be returned. + * Checks a URI String for two things: well-formedness and uniqueness in the + * model. Ill-formed strings or those matching URIs already in use will + * cause an error message to be returned. * @return error message String if invalid; otherwise null */ public String checkURI(String uriStr); /** - * Checks a URI String for two things: well-formedness and, optionally, uniqueness in the model. - * Ill-formed strings or those matching URIs already in use will cause an error message to be returned. + * Checks a URI String for two things: well-formedness and, optionally, + * uniqueness in the model. Ill-formed strings or those matching URIs + * already in use will cause an error message to be returned. * @return error message String if invalid; otherwise null */ public String checkURI(String uriStr, boolean checkUniqueness); - public int getLanguageProfile(); - public String getDefaultNamespace(); public Set getNonuserNamespaces(); @@ -36,33 +42,37 @@ public interface WebappDaoFactory { public String[] getPreferredLanguages(); /** - * BJL23 2008-05-20: Putting this here for lack of a more logical place. We need to build better support for the RDFS vocabulary into our API. - * Returns a list of the simple lexical form strings of the rdfs:comment values for a resource; empty list if none found. + * BJL23 2008-05-20: Putting this here for lack of a more logical place. + * We need to build better support for the RDFS vocabulary into our API. + * Returns a list of the simple lexical form strings of the rdfs:comment + * values for a resource; empty list if none found. */ public List getCommentsForResource(String resourceURI); /** - * Copy this DAO factory to a new object associated with the specified user URI, or return the same factory if a user-aware version cannot be used. + * Copy this DAO factory to a new object associated with the specified user + * URI, or return the same factory if a user-aware version cannot be used. * @param userURI * @return */ public WebappDaoFactory getUserAwareDaoFactory(String userURI); /** - * Return URI of user associated with this WebappDaoFactory, or null if not applicable. + * Return URI of user associated with this WebappDaoFactory, + * or null if not applicable. * @return */ public String getUserURI(); - /* ======================== DAOs for ontology (TBox) manipulation ======================== */ + /* =============== DAOs for ontology (TBox) manipulation =============== */ /** - * returns a Data Access Object for working with class subsumption axioms in the model + * returns a Data Access Object for working with class subsumption axioms */ public Classes2ClassesDao getClasses2ClassesDao(); /** - * returns a Data Access Object for working with DataProperties in the model + * returns a Data Access Object for working with DataProperties */ public DataPropertyDao getDataPropertyDao(); @@ -72,42 +82,42 @@ public interface WebappDaoFactory { public DatatypeDao getDatatypeDao(); /** - * returns a Data Access Object for working with ObjectProperties in the model + * returns a Data Access Object for working with ObjectProperties */ public ObjectPropertyDao getObjectPropertyDao(); /** - * returns a Data Access Object for working with Ontologies in the model + * returns a Data Access Object for working with Ontologies */ public OntologyDao getOntologyDao(); /** - * returns a Data Access Object for working with ontology class objects in the model + * returns a Data Access Object for working with ontology class objects */ public VClassDao getVClassDao(); - /* ======================== DAOs for ABox manipulation ======================== */ + /* ==================== DAOs for ABox manipulation ===================== */ /** - * returns a Data Access Object for working with DatatypePropertyStatements in the model + * returns a Data Access Object for working with DatatypePropertyStatements */ public DataPropertyStatementDao getDataPropertyStatementDao(); /** - * returns a Data Access Object for working with Individuals in the model + * returns a Data Access Object for working with Individuals */ public IndividualDao getIndividualDao(); /** - * returns a Data Access Object for working with ObjectPropertyStatements in the model + * returns a Data Access Object for working with ObjectPropertyStatements */ public ObjectPropertyStatementDao getObjectPropertyStatementDao(); public DisplayModelDao getDisplayModelDao(); - /* ======================== DAOs for other objects ======================== */ + /* ====================== DAOs for other objects ======================= */ public ApplicationDao getApplicationDao(); @@ -125,5 +135,4 @@ public interface WebappDaoFactory { public MenuDao getMenuDao(); - public void close(); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java index 17020905a..e018d21b7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java @@ -93,10 +93,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory { //TODO: need to clone the filtering factory return innerWebappDaoFactory.getUserAwareDaoFactory(userURI); } - - public int getLanguageProfile() { - return innerWebappDaoFactory.getLanguageProfile(); - } public String getDefaultNamespace() { return innerWebappDaoFactory.getDefaultNamespace(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java index 17076ba7a..d0cffb4ee 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java @@ -887,22 +887,6 @@ public class JenaBaseDao extends JenaBaseDaoCon { protected String getDefaultLanguage() { return PREFERRED_LANGUAGES[0]; } - - protected MapgetFlag2ValueMap() { - try { - return ((WebappDaoFactoryJena) this.webappDaoFactory).getFlag2ValueMap(); - } catch (ClassCastException cce) { - return null; - } - } - - protected MapgetFlag2ClassLabelMap() { - try { - return ((WebappDaoFactoryJena) this.webappDaoFactory).getFlag2ClassLabelMap(); - } catch (ClassCastException cce) { - return null; - } - } /** * Checks a URI for validity. Jena models can store invalid URIs, but this causes RDF/XML output serialization to fail. diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModel.java deleted file mode 100644 index 6dc424f31..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModel.java +++ /dev/null @@ -1,36 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena; - -import com.hp.hpl.jena.ontology.OntModel; - -import edu.cornell.mannlib.vitro.webapp.dao.VitroModelProperties; - -public class VitroJenaModel { - - private String graphURI = null; - private OntModel jenaOntModel = null; - private VitroModelProperties vitroModelProperties = null; - - public String getGraphURI() { - return graphURI; - } - public void setGraphURI(String graphURI) { - this.graphURI = graphURI; - } - - public OntModel getJenaOntModel() { - return this.jenaOntModel; - } - public void setJenaOntModel(OntModel ontModel) { - this.jenaOntModel = ontModel; - } - - public VitroModelProperties getVitroModelProperties() { - return this.vitroModelProperties; - } - public void setVitroModelProperties(VitroModelProperties vitroModelProperties) { - this.vitroModelProperties = vitroModelProperties; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModelSource.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModelSource.java deleted file mode 100644 index 4ba900aaf..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModelSource.java +++ /dev/null @@ -1,19 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena; - -public interface VitroJenaModelSource { - - public abstract VitroJenaModel getVitroJenaModel(); - - public abstract VitroJenaModel getVitroJenaModel(String namespace); - - public abstract VitroJenaModel getMutableVitroJenaModel(); - - public abstract VitroJenaModel getMutableVitroJenaModel(String namespace); - - public abstract VitroJenaModel getVitroAnnotationsJenaModel(); - - public abstract VitroJenaModel getVitroAnnotationsJenaModel(String namespace); - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java index e34b3344d..30961799a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java @@ -13,7 +13,6 @@ import java.util.Set; 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.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.ontology.OntResource; @@ -27,20 +26,18 @@ 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.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; -import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao; import edu.cornell.mannlib.vitro.webapp.dao.Classes2ClassesDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao; -import edu.cornell.mannlib.vitro.webapp.dao.FlagDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.LinksDao; import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao; @@ -63,7 +60,6 @@ import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; public class WebappDaoFactoryJena implements WebappDaoFactory { protected IndividualDao entityWebappDao; - protected FlagDao flagDao; protected LinksDao linksDao; protected LinktypeDao linktypeDao; protected ApplicationDaoJena applicationDao; @@ -84,19 +80,13 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { protected String userURI; - protected Map flag2ValueMap; - protected Map flag2ClassLabelMap; - protected boolean INCLUDE_TOP_CONCEPT = false; protected boolean INCLUDE_BOTTOM_CONCEPT = false; private Map properties = new HashMap(); protected DatasetWrapperFactory dwf; - - // for temporary use to construct URIs for the things that still use integer IDs. - // As these objects get changed to support getURI(), this should become unnecessary. - + /* **************** constructors **************** */ public WebappDaoFactoryJena(WebappDaoFactoryJena base, String userURI) { @@ -105,8 +95,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { this.nonuserNamespaces = base.nonuserNamespaces; this.preferredLanguages = base.preferredLanguages; this.userURI = userURI; - this.flag2ValueMap = base.flag2ValueMap; - this.flag2ClassLabelMap = base.flag2ClassLabelMap; this.dwf = base.dwf; } @@ -120,17 +108,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { this.ontModelSelector = ontModelSelector; - // BJL23 2009-04-27 - // As I understand it, the the following setting should allow more - // relaxed use of .as() in Jena's polymorphic framework and avoid - // ClassCastExceptions deep in Jena when, for example, a resource - // used as a class is not explicitly typed as such. In reality, - // this setting seems to have dangerous consequences and causes - // bizarre other exceptions to be thrown in ways that make the model - // seem to behave even *more* strictly. Uncomment at your own risk: - - // this.ontModel.setStrictMode(false); - if (defaultNamespace != null) { this.defaultNamespace = defaultNamespace; } else { @@ -151,17 +128,22 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { if (INCLUDE_TOP_CONCEPT) { Resource top = getTopConcept(); if (top != null) { - languageUniversalsModel.add(top, RDF.type, this.ontModelSelector.getTBoxModel().getProfile().CLASS()); + languageUniversalsModel.add(top, RDF.type, + this.ontModelSelector.getTBoxModel().getProfile() + .CLASS()); } } if (INCLUDE_BOTTOM_CONCEPT) { Resource bottom = getBottomConcept(); if (bottom != null) { - languageUniversalsModel.add(bottom, RDF.type, this.ontModelSelector.getTBoxModel().getProfile().CLASS()); + languageUniversalsModel.add(bottom, RDF.type, + this.ontModelSelector.getTBoxModel().getProfile() + .CLASS()); } } if (languageUniversalsModel.size()>0) { - this.ontModelSelector.getTBoxModel().addSubModel(languageUniversalsModel); + this.ontModelSelector.getTBoxModel().addSubModel( + languageUniversalsModel); } Model assertions = (baseOntModelSelector != null) @@ -176,13 +158,13 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } - public static Dataset makeInMemoryDataset(Model assertions, Model inferences) { - DataSource dataset = DatasetFactory.create(); - - OntModel union = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - + public static Dataset makeInMemoryDataset(Model assertions, + Model inferences) { + DataSource dataset = DatasetFactory.create(); + OntModel union = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); if (assertions != null) { - dataset.addNamedModel(JenaDataSourceSetupBase.JENA_DB_MODEL, assertions); + dataset.addNamedModel( + JenaDataSourceSetupBase.JENA_DB_MODEL, assertions); union.addSubModel(assertions); } if (inferences != null) { @@ -208,28 +190,62 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { userURI); } - public WebappDaoFactoryJena(OntModelSelector ontModelSelector, String defaultNamespace, HashSet nonuserNamespaces, String[] preferredLanguages){ - this(ontModelSelector, defaultNamespace, nonuserNamespaces, preferredLanguages, null); + public WebappDaoFactoryJena(OntModelSelector ontModelSelector, + String defaultNamespace, + HashSet nonuserNamespaces, + String[] preferredLanguages) { + this(ontModelSelector, + defaultNamespace, + nonuserNamespaces, + preferredLanguages, + null); } - public WebappDaoFactoryJena(OntModelSelector ontModelSelector, OntModelSelector baseOntModelSelector, OntModelSelector inferenceOntModelSelector, String defaultNamespace, HashSet nonuserNamespaces, String[] preferredLanguages){ - this(ontModelSelector, baseOntModelSelector, inferenceOntModelSelector, defaultNamespace, nonuserNamespaces, preferredLanguages, null); + public WebappDaoFactoryJena(OntModelSelector ontModelSelector, + OntModelSelector baseOntModelSelector, + OntModelSelector inferenceOntModelSelector, + String defaultNamespace, + HashSet nonuserNamespaces, + String[] preferredLanguages){ + this(ontModelSelector, + baseOntModelSelector, + inferenceOntModelSelector, + defaultNamespace, + nonuserNamespaces, + preferredLanguages, + null); } public WebappDaoFactoryJena(OntModelSelector ontModelSelector) { this(ontModelSelector, null, null, null, null, null); } - public WebappDaoFactoryJena(OntModel ontModel, String defaultNamespace, HashSet nonuserNamespaces, String[] preferredLanguages, String userURI){ - this(new SimpleOntModelSelector(ontModel), defaultNamespace, nonuserNamespaces, preferredLanguages, userURI); + public WebappDaoFactoryJena(OntModel ontModel, + String defaultNamespace, + HashSet nonuserNamespaces, + String[] preferredLanguages, + String userURI) { + this(new SimpleOntModelSelector(ontModel), + defaultNamespace, + nonuserNamespaces, + preferredLanguages, + userURI); } - public WebappDaoFactoryJena(OntModel ontModel, String defaultNamespace, HashSet nonuserNamespaces, String[] preferredLanguages){ - this(new SimpleOntModelSelector(ontModel), defaultNamespace, nonuserNamespaces, preferredLanguages, null); + public WebappDaoFactoryJena(OntModel ontModel, + String defaultNamespace, + HashSet nonuserNamespaces, + String[] preferredLanguages) { + this(new SimpleOntModelSelector(ontModel), + defaultNamespace, + nonuserNamespaces, + preferredLanguages, + null); } public WebappDaoFactoryJena(OntModel ontModel) { - this(new SimpleOntModelSelector(ontModel), null, null, null, null, null); + this(new SimpleOntModelSelector( + ontModel), null, null, null, null, null); } public OntModelSelector getOntModelSelector() { @@ -241,13 +257,15 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } /** - * Return the current language profile's Top concept as a Jena resource, or null if not applicable. - * The special case is RDFS, where we use rdfs:Resource as the analog of Top, rather than returning null. + * Return the current language profile's Top concept as a Jena resource, + * or null if not applicable. The special case is RDFS, where we use + * rdfs:Resource as the analog of Top, rather than returning null. * @return */ public Resource getTopConcept() { Resource top = null; - if (this.ontModelSelector.getTBoxModel().getProfile().NAMESPACE().equals(RDFS.getURI())) { + if (this.ontModelSelector.getTBoxModel().getProfile().NAMESPACE() + .equals(RDFS.getURI())) { top = RDFS.Resource; } else { top = this.ontModelSelector.getTBoxModel().getProfile().THING(); @@ -256,7 +274,8 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } /** - * Return the current language profile's Bottom concept as a Jena resource, or null if not applicable. + * Return the current language profile's Bottom concept as a Jena resource, + * or null if not applicable. * @return */ public Resource getBottomConcept() { @@ -269,11 +288,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { private void initNonuserNamespaces() { nonuserNamespaces = new HashSet(); - //nonuserNamespaces.add(VitroVocabulary.RDF); - //nonuserNamespaces.add(VitroVocabulary.RDFS); - //nonuserNamespaces.add(VitroVocabulary.OWL); nonuserNamespaces.add(VitroVocabulary.vitroURI); - nonuserNamespaces.add("http://lowe.mannlib.cornell.edu/ns/vitro0.1/vitro.owl#"); // obsolete Vitro URI } private void initPreferredLanguages() { @@ -294,22 +309,25 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } public String checkURI(String uriStr, boolean checkUniqueness) { - uriStr = (uriStr == null) ? " " : uriStr; + uriStr = (uriStr == null) ? " " : uriStr; boolean validURI = true; String errorMsg = ""; - String duplicateMsg = "URI is already in use. Please enter another URI. "; + String duplicateMsg = "URI is already in use. " + + "Please enter another URI. "; IRIFactory factory = IRIFactory.jenaImplementation(); IRI iri = factory.create( uriStr ); if (iri.hasViolation(false) ) { validURI = false; - errorMsg += ((Violation)iri.violations(false).next()).getShortMessage()+" "; + errorMsg += ((Violation)iri.violations(false).next()) + .getShortMessage() + " "; } else if (checkUniqueness) { OntModel ontModel = ontModelSelector.getFullModel(); ontModel.enterCriticalSection(Lock.READ); try { Resource newURIAsRes = ResourceFactory.createResource(uriStr); Property newURIAsProp = ResourceFactory.createProperty(uriStr); - ClosableIterator closeIt = ontModel.listStatements(newURIAsRes, null, (RDFNode)null); + StmtIterator closeIt = ontModel.listStatements( + newURIAsRes, null, (RDFNode)null); if (closeIt.hasNext()) { validURI = false; errorMsg+="Not a valid URI. Please enter another URI. "; @@ -323,7 +341,8 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } } if (validURI) { - closeIt = ontModel.listStatements(null, newURIAsProp, (RDFNode)null); + closeIt = ontModel.listStatements( + null, newURIAsProp, (RDFNode)null); if (closeIt.hasNext()) { validURI = false; errorMsg+=duplicateMsg; @@ -337,7 +356,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } public WebappDaoFactory getUserAwareDaoFactory(String userURI) { - // TODO: put the user-aware factories in a hashmap so we don't keep re-creating them return new WebappDaoFactoryJena(this, userURI); } @@ -351,20 +369,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { return defaultNamespace; } - public static int OWL_CONST = 202; - public static int RDFS_CONST = 100; - - public int getLanguageProfile() { - OntModel ontModel = ontModelSelector.getTBoxModel(); - if (ontModel.getProfile().NAMESPACE().equals(OWL.NAMESPACE.getURI())) { - return OWL_CONST; - } else if (ontModel.getProfile().NAMESPACE().equals(RDFS.getURI())) { - return RDFS_CONST; - } else { - return -1; - } - } - public String[] getPreferredLanguages() { return this.preferredLanguages; } @@ -392,9 +396,9 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { try { OntResource res = ontModel.getOntResource(resourceURI); if (res != null) { - ClosableIterator closeIt = res.listComments(null); + ClosableIterator closeIt = res.listComments(null); try { - for (Iterator commIt = closeIt; commIt.hasNext();) { + for(Iterator commIt = closeIt; commIt.hasNext();) { Literal lit = (Literal) commIt.next(); commentList.add(lit.getLexicalForm()); } @@ -532,14 +536,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { return jenaBaseDao; } - public Map getFlag2ValueMap() { - return this.flag2ValueMap; - } - - public Map getFlag2ClassLabelMap() { - return this.flag2ClassLabelMap; - } - @Override public PageDao getPageDao() { if( pageDao == null ) @@ -566,85 +562,85 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } } - //Method for creating a copy - does not pass the same object + /** + * Method for creating a copy - does not pass the same object + * @param base + */ public WebappDaoFactoryJena (WebappDaoFactoryJena base) { - //Not sure if selector somehow has greater longevity so making a copy instead of reference - + // Not sure if selector somehow has greater longevity so + // making a copy instead of reference. if(base.ontModelSelector instanceof OntModelSelectorImpl) { OntModelSelectorImpl selector = new OntModelSelectorImpl(); selector.setABoxModel(base.ontModelSelector.getABoxModel()); - selector.setApplicationMetadataModel(base.ontModelSelector.getApplicationMetadataModel()); + selector.setApplicationMetadataModel( + base.ontModelSelector.getApplicationMetadataModel()); selector.setDisplayModel(base.ontModelSelector.getDisplayModel()); selector.setFullModel(base.ontModelSelector.getFullModel()); selector.setTBoxModel(base.ontModelSelector.getTBoxModel()); - selector.setUserAccountsModel(base.ontModelSelector.getUserAccountsModel()); + selector.setUserAccountsModel( + base.ontModelSelector.getUserAccountsModel()); this.ontModelSelector = selector; } else if(base.ontModelSelector instanceof SimpleOntModelSelector) { SimpleOntModelSelector selector = new SimpleOntModelSelector(); selector.setABoxModel(base.ontModelSelector.getABoxModel()); - selector.setApplicationMetadataModel(base.ontModelSelector.getApplicationMetadataModel()); + selector.setApplicationMetadataModel( + base.ontModelSelector.getApplicationMetadataModel()); selector.setDisplayModel(base.ontModelSelector.getDisplayModel()); selector.setFullModel(base.ontModelSelector.getFullModel()); selector.setTBoxModel(base.ontModelSelector.getTBoxModel()); - selector.setUserAccountsModel(base.ontModelSelector.getUserAccountsModel()); + selector.setUserAccountsModel( + base.ontModelSelector.getUserAccountsModel()); this.ontModelSelector = selector; } else { //Not sure what this is but will set to equivalence here - this.ontModelSelector =base.ontModelSelector; - } - + this.ontModelSelector = base.ontModelSelector; + } this.defaultNamespace = base.defaultNamespace; this.nonuserNamespaces = base.nonuserNamespaces; this.preferredLanguages = base.preferredLanguages; this.userURI = base.userURI; - if(base.flag2ValueMap != null) { - this.flag2ValueMap = new HashMap(); - this.flag2ValueMap.putAll(base.flag2ValueMap); - } else { - this.flag2ValueMap = null; - } - if(base.flag2ClassLabelMap != null) { - this.flag2ClassLabelMap = new HashMap(); - this.flag2ClassLabelMap.putAll(base.flag2ClassLabelMap); - } else { - this.flag2ClassLabelMap = null; - } this.dwf = base.dwf; } /** - * Method for using special model for webapp dao factory, such as display model. - * The goal here is to modify this WebappDaoFactory so that it is using the - * specialModel, specialTboxModel and the specialDisplayModel for individual - * editing. + * Method for using a special model, such as the display model, with the + * WebappDaoFactory. The goal here is to modify this WebappDaoFactory so + * that it is using specialModel, specialTboxModel and specialDisplayModel + * for individual editing. * - * DAOs related to the application configuration, user accounts, and namespaces + * DAOs related to the application configuration and user accounts * should remain unchanged. */ - public void setSpecialDataModel(OntModel specialModel, OntModel specialTboxModel, OntModel specialDisplayModel) { + public void setSpecialDataModel(OntModel specialModel, + OntModel specialTboxModel, + OntModel specialDisplayModel) { if( specialModel == null ) - throw new IllegalStateException( "specialModel must not be null"); + throw new IllegalStateException("specialModel must not be null"); //Can we get the "original" models here from somewhere? OntModelSelector originalSelector = this.getOntModelSelector(); - //Set up model selector for this special WDF - //The selector is used by the object property DAO, therefore should be set up even though we - //use the new webapp dao factory object to generate portions to overwrite the regular webapp dao factory + // Set up model selector for this special WDF + // The selector is used by the object property DAO, therefore should be + // set up even though we use the new webapp dao factory object to + // generate portions to overwrite the regular webapp dao factory. //The WDF expects the full model in the OntModelSelect that has //both the ABox and TBox. This is used to run SPARQL queries against. - OntModel unionModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); + OntModel unionModel = ModelFactory.createOntologyModel( + OntModelSpec.OWL_MEM); unionModel.addSubModel(specialModel); OntModelSelectorImpl specialSelector = new OntModelSelectorImpl(); specialSelector.setFullModel(unionModel); - //Keeping original application metadata model and adding special model - //adding both allows us to prevent errors in ApplicationDao which may depend on - //a specific individual from the regular application metadata model to pick theme - //Adding the new model would take care of special situations where the switch model may - //contain important information - OntModel newApplicationModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); + // Keeping original application metadata model and adding special model. + // Adding both allows us to prevent errors in ApplicationDao which may + // depend on a specific individual from the regular application metadata + // model to pick the theme. Adding the new model would take care of + // special situations where the switch model may contain important + // information. + OntModel newApplicationModel = ModelFactory.createOntologyModel( + OntModelSpec.OWL_MEM); newApplicationModel.add(specialModel); newApplicationModel.add(originalSelector.getApplicationMetadataModel()); specialSelector.setApplicationMetadataModel(newApplicationModel); @@ -655,7 +651,8 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } else { OntModel selectorDisplayModel = originalSelector.getDisplayModel(); if(selectorDisplayModel != null) { - specialSelector.setDisplayModel(originalSelector.getDisplayModel()); + specialSelector.setDisplayModel( + originalSelector.getDisplayModel()); } } if(specialTboxModel != null) { @@ -670,22 +667,25 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { specialSelector.setABoxModel(specialModel); specialSelector.setUserAccountsModel(specialModel); - //although we're only use part of the new wadf and copy over below, the object property dao - //utilizes methods that will employ the display model returned from the simple ontmodel selector - //so if the object property dao is to be copied over we need to ensure we have the correct display model - //and tbox model - WebappDaoFactoryJena specialWadfj = new WebappDaoFactoryJena(specialSelector); + // Although we're only using part of the new wadf and copy over below, + // the object property dao utilizes methods that will employ the display + // model returned from the simple ontmodel selector, so if the object + // property dao is to be copied over we need to ensure we have the + // correct display model and tbox model. + WebappDaoFactoryJena specialWadfj = new WebappDaoFactoryJena( + specialSelector); entityWebappDao = specialWadfj.getIndividualDao(); vClassGroupDao = specialWadfj.getVClassGroupDao(); - //To allow for testing, add a property group, this will allow - //the unassigned group method section to be executed and main Image to be assigned to that group - //otherwise the dummy group does not allow for the unassigned group to be executed + // To allow for testing, add a property group, this will allow + // the unassigned group method section to be executed and main Image to + // be assigned to that group. Otherwise, the dummy group does not allow + // for the unassigned group to be executed. propertyGroupDao = specialWadfj.getPropertyGroupDao(); objectPropertyDao = specialWadfj.getObjectPropertyDao(); objectPropertyStatementDao = specialWadfj.getObjectPropertyStatementDao(); dataPropertyDao = specialWadfj.getDataPropertyDao(); dataPropertyStatementDao = specialWadfj.getDataPropertyStatementDao(); - //Why can't we set the selector to be the same? + // Why can't we set the selector to be the same? ontModelSelector = specialSelector; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactorySDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactorySDB.java index 6ceee057d..b83a24a37 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactorySDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactorySDB.java @@ -86,8 +86,6 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena { this.nonuserNamespaces = base.nonuserNamespaces; this.preferredLanguages = base.preferredLanguages; this.userURI = userURI; - this.flag2ValueMap = base.flag2ValueMap; - this.flag2ClassLabelMap = base.flag2ClassLabelMap; this.dwf = base.dwf; } diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java index 5605fac82..e9a36b2bb 100644 --- a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java @@ -104,12 +104,6 @@ public class WebappDaoFactoryStub implements WebappDaoFactory { "WebappDaoFactory.checkURI() not implemented."); } - @Override - public int getLanguageProfile() { - throw new RuntimeException( - "WebappDaoFactory.getLanguageProfile() not implemented."); - } - @Override public String getDefaultNamespace() { throw new RuntimeException(