Class JenaBaseDao

    • Field Detail

      • log

        protected static final org.apache.commons.logging.Log log
      • PSEUDO_BNODE_NS

        protected String PSEUDO_BNODE_NS
      • xsdDateFormat

        protected DateFormat xsdDateFormat
      • xsdDateTimeFormat

        protected DateFormat xsdDateTimeFormat
      • DEFAULT_NAMESPACE

        protected String DEFAULT_NAMESPACE
      • NONUSER_NAMESPACES

        protected Set<String> NONUSER_NAMESPACES
      • PREFERRED_LANGUAGES

        protected List<String> PREFERRED_LANGUAGES
    • Method Detail

      • getOntModel

        protected org.apache.jena.ontology.OntModel getOntModel()
      • getWritableOntModelList

        protected List<org.apache.jena.ontology.OntModel> getWritableOntModelList()
      • getPropertyStringValue

        protected String getPropertyStringValue​(org.apache.jena.ontology.OntResource res,
                                                org.apache.jena.rdf.model.Property dataprop)
        convenience method
      • addPropertyStringValue

        protected void addPropertyStringValue​(org.apache.jena.rdf.model.Resource res,
                                              org.apache.jena.rdf.model.Property dataprop,
                                              String value,
                                              org.apache.jena.rdf.model.Model model)
        convenience method
      • getPropertyBooleanValue

        protected Boolean getPropertyBooleanValue​(org.apache.jena.ontology.OntResource res,
                                                  org.apache.jena.rdf.model.Property dataprop)
        convenience method
      • addPropertyBooleanValue

        protected void addPropertyBooleanValue​(org.apache.jena.rdf.model.Resource res,
                                               org.apache.jena.rdf.model.Property prop,
                                               Boolean value,
                                               org.apache.jena.rdf.model.Model model)
        convenience method
      • updatePropertyStringValue

        protected void updatePropertyStringValue​(org.apache.jena.rdf.model.Resource res,
                                                 org.apache.jena.rdf.model.Property dataprop,
                                                 String value,
                                                 org.apache.jena.rdf.model.Model model)
        convenience method for use with functional datatype properties
      • updatePropertyBooleanValue

        protected void updatePropertyBooleanValue​(org.apache.jena.rdf.model.Resource res,
                                                  org.apache.jena.rdf.model.Property dataprop,
                                                  Boolean value,
                                                  org.apache.jena.rdf.model.Model model,
                                                  boolean keepOnlyIfTrue)
        Convenience method for use with functional datatype properties. Pass keepOnlyIfTrue if a lack of a value in the model indicates false. See ObjectPropertyDaoJena and PROPERTY_OFFERCREATENEWOPTIONANNOT for an example.
      • getPropertyNonNegativeIntValue

        protected int getPropertyNonNegativeIntValue​(org.apache.jena.ontology.OntResource res,
                                                     org.apache.jena.rdf.model.Property dataprop)
        convenience method
      • getPropertyNonNegativeIntegerValue

        protected Integer getPropertyNonNegativeIntegerValue​(org.apache.jena.ontology.OntResource res,
                                                             org.apache.jena.rdf.model.Property dataprop)
        convenience method
      • addPropertyIntValue

        protected void addPropertyIntValue​(org.apache.jena.rdf.model.Resource res,
                                           org.apache.jena.rdf.model.Property dataprop,
                                           int value,
                                           org.apache.jena.rdf.model.Model model)
        convenience method
      • addPropertyLongValue

        protected void addPropertyLongValue​(org.apache.jena.rdf.model.Resource res,
                                            org.apache.jena.rdf.model.Property dataprop,
                                            long value,
                                            org.apache.jena.rdf.model.Model model)
        convenience method
      • updatePropertyIntValue

        protected void updatePropertyIntValue​(org.apache.jena.rdf.model.Resource res,
                                              org.apache.jena.rdf.model.Property dataprop,
                                              int value,
                                              org.apache.jena.rdf.model.Model model)
        convenience method for use with functional datatype properties
      • getPropertyIntValue

        protected int getPropertyIntValue​(org.apache.jena.ontology.OntResource res,
                                          org.apache.jena.rdf.model.Property dataprop)
        convenience method
      • addPropertyNonNegativeIntValue

        protected void addPropertyNonNegativeIntValue​(org.apache.jena.rdf.model.Resource res,
                                                      org.apache.jena.rdf.model.Property dataprop,
                                                      int value,
                                                      org.apache.jena.rdf.model.Model model)
        convenience method
      • updatePropertyNonNegativeIntValue

        protected void updatePropertyNonNegativeIntValue​(org.apache.jena.rdf.model.Resource res,
                                                         org.apache.jena.rdf.model.Property dataprop,
                                                         int value,
                                                         org.apache.jena.rdf.model.Model model)
        convenience method for use with functional datatype properties
      • updatePropertyNonNegativeIntegerValue

        protected void updatePropertyNonNegativeIntegerValue​(org.apache.jena.rdf.model.Resource res,
                                                             org.apache.jena.rdf.model.Property dataprop,
                                                             Integer value,
                                                             org.apache.jena.rdf.model.Model model)
        convenience method for use with functional datatype properties
      • updatePropertyLongValue

        protected void updatePropertyLongValue​(org.apache.jena.rdf.model.Resource res,
                                               org.apache.jena.rdf.model.Property dataprop,
                                               Long value,
                                               org.apache.jena.rdf.model.Model model)
        convenience method for use with functional datatype properties
      • getPropertyLongValue

        protected long getPropertyLongValue​(org.apache.jena.ontology.OntResource res,
                                            org.apache.jena.rdf.model.Property dataprop)
        convenience method
      • addPropertyFloatValue

        protected void addPropertyFloatValue​(org.apache.jena.rdf.model.Resource res,
                                             org.apache.jena.rdf.model.Property dataprop,
                                             Float value,
                                             org.apache.jena.rdf.model.Model model)
        convenience method
      • updatePropertyFloatValue

        protected void updatePropertyFloatValue​(org.apache.jena.rdf.model.Resource res,
                                                org.apache.jena.rdf.model.Property dataprop,
                                                Float value,
                                                org.apache.jena.rdf.model.Model model)
        convenience method for use with functional properties
      • getPropertyFloatValue

        protected Float getPropertyFloatValue​(org.apache.jena.ontology.OntResource res,
                                              org.apache.jena.rdf.model.Property prop)
      • getPropertyDateValue

        protected Date getPropertyDateValue​(org.apache.jena.ontology.OntResource res,
                                            org.apache.jena.ontology.DatatypeProperty dataprop)
        convenience method
      • addPropertyDateValue

        protected void addPropertyDateValue​(org.apache.jena.rdf.model.Resource res,
                                            org.apache.jena.ontology.DatatypeProperty dataprop,
                                            Date value,
                                            org.apache.jena.rdf.model.Model model)
        convenience method
        Parameters:
        res - Resource
        dataprop - Datatype property
        value - Date
        model - Jena Model
      • updatePropertyDateValue

        protected void updatePropertyDateValue​(org.apache.jena.rdf.model.Resource res,
                                               org.apache.jena.ontology.DatatypeProperty dataprop,
                                               Date value,
                                               org.apache.jena.rdf.model.Model model)
        convenience method for use with functional datatype properties
      • getPropertyDateTimeValue

        protected Date getPropertyDateTimeValue​(org.apache.jena.ontology.OntResource res,
                                                org.apache.jena.rdf.model.Property dataprop)
        convenience method
      • addPropertyDateTimeValue

        protected void addPropertyDateTimeValue​(org.apache.jena.rdf.model.Resource res,
                                                org.apache.jena.rdf.model.Property dataprop,
                                                Date value,
                                                org.apache.jena.rdf.model.Model model)
        convenience method
      • updatePropertyDateTimeValue

        protected void updatePropertyDateTimeValue​(org.apache.jena.rdf.model.Resource res,
                                                   org.apache.jena.rdf.model.Property dataprop,
                                                   Date value,
                                                   org.apache.jena.rdf.model.Model model)
        convenience method for use with functional datatype properties
      • getPropertyResourceURIValues

        protected Collection<String> getPropertyResourceURIValues​(org.apache.jena.rdf.model.Resource res,
                                                                  org.apache.jena.ontology.ObjectProperty prop)
        convenience method for use with functional object properties
      • getMostRestrictiveRoleLevel

        protected BaseResourceBean.RoleLevel getMostRestrictiveRoleLevel​(org.apache.jena.rdf.model.Resource res,
                                                                         org.apache.jena.rdf.model.Property prop)
      • addPropertyResourceURIValue

        protected void addPropertyResourceURIValue​(org.apache.jena.rdf.model.Resource res,
                                                   org.apache.jena.ontology.ObjectProperty prop,
                                                   String objectURI)
        convenience method for use with functional object properties
      • updatePropertyResourceURIValue

        protected void updatePropertyResourceURIValue​(org.apache.jena.rdf.model.Resource res,
                                                      org.apache.jena.rdf.model.Property prop,
                                                      String objectURI)
        convenience method for use with functional properties
      • updatePropertyResourceURIValue

        protected void updatePropertyResourceURIValue​(org.apache.jena.rdf.model.Resource res,
                                                      org.apache.jena.rdf.model.Property prop,
                                                      String uri,
                                                      org.apache.jena.rdf.model.Model model)
        convenience method for use with functional properties
      • addPropertyResourceValue

        protected void addPropertyResourceValue​(org.apache.jena.rdf.model.Resource res,
                                                org.apache.jena.rdf.model.Property prop,
                                                org.apache.jena.rdf.model.Resource objectRes)
        convenience method for use with functional object properties
      • updatePropertyResourceValue

        protected void updatePropertyResourceValue​(org.apache.jena.rdf.model.Resource res,
                                                   org.apache.jena.rdf.model.Property prop,
                                                   org.apache.jena.rdf.model.Resource objectRes)
        convenience method for use with functional properties
      • updatePropertyResourceValue

        protected void updatePropertyResourceValue​(org.apache.jena.rdf.model.Resource res,
                                                   org.apache.jena.rdf.model.Property prop,
                                                   org.apache.jena.rdf.model.Resource objectRes,
                                                   org.apache.jena.rdf.model.Model model)
        convenience method for use with functional properties
      • updatePropertyResourceURIValues

        protected void updatePropertyResourceURIValues​(org.apache.jena.rdf.model.Resource res,
                                                       org.apache.jena.rdf.model.Property prop,
                                                       Collection<String> uris,
                                                       org.apache.jena.rdf.model.Model model)
        convenience method to update the value(s) of a one-to-many object property NOTE: this should be run from within a CriticalSection(WRITE)
      • updateRDFSLabel

        protected void updateRDFSLabel​(org.apache.jena.ontology.OntResource ontRes,
                                       String lexicalForm)
        Add to an OntResource an rdfs:label value with lexical form and default language tag. Remove any other existing values in default language. If lexicalForm parameter is null, remove all plain literal values of Property in default language.
        Parameters:
        ontRes - may not be null
        lexicalForm - may be null. If null, existing values will be deleted but none will be added.
      • updateRDFSLabel

        protected void updateRDFSLabel​(org.apache.jena.ontology.OntResource ontRes,
                                       String lexicalForm,
                                       String lang)
        Add to an OntResource an rdfs:label value with lexical form and optional language tag. Remove any other existing plain literal values that match specified language or lack language tags if no language is supplied. If lexicalForm parameter is null, remove all plain literal labels in specified language, or all existing language-less labels if no language is specified.
        Parameters:
        ontRes - may not be null
        lexicalForm - may be null. If null, existing values will be deleted but none will be added.
        lang - may be null. If null, method acts on language-less plain literal labels and ignores those with language tags.
      • updatePlainLiteralValue

        protected void updatePlainLiteralValue​(org.apache.jena.ontology.OntResource ontRes,
                                               org.apache.jena.rdf.model.Property property,
                                               String lexicalForm)
        Add to an OntResource a Property value with lexical form and default language tag. Remove any other existing values in default language. If lexicalForm parameter is null, remove all plain literal values of Property in default language.
        Parameters:
        ontRes - may not be null
        lexicalForm - may be null. If null, existing values will be deleted but none will be added.
      • updatePlainLiteralValue

        protected void updatePlainLiteralValue​(org.apache.jena.ontology.OntResource ontRes,
                                               org.apache.jena.rdf.model.Property property,
                                               String lexicalForm,
                                               String lang)
        Add to an OntResource a Property value with lexical form and optional language tag. Remove any other existing plain literal values that match specified language or lack language tags if no language is supplied. If lexicalForm parameter is null, remove all plain literal values of Property in specified language, or all existing language-less literals if no language is specified.
        Parameters:
        ontRes - may not be null
        lexicalForm - may be null. If null, existing values will be deleted but none will be added.
        lang - may be null. If null, method acts on language-less plain literal values and ignores those with language tags.
      • getLabelOrId

        protected String getLabelOrId​(org.apache.jena.ontology.OntResource r)
        Get the rdfs:label or vitro:label, working through PERFERED_LANGUAGES, or get local name, bnode Id, or full URI if no labels found.
      • getLabel

        protected String getLabel​(org.apache.jena.ontology.OntResource r)
      • getLabelLiteral

        protected org.apache.jena.rdf.model.Literal getLabelLiteral​(String individualUri)
      • getLabelLiteral

        protected org.apache.jena.rdf.model.Literal getLabelLiteral​(org.apache.jena.ontology.OntResource r)
        works through list of PREFERRED_LANGUAGES to find an appropriate label, or NULL if not found.
      • getLocalNameOrId

        protected String getLocalNameOrId​(org.apache.jena.ontology.OntResource r)
        Get the local name, bnode or URI of the resource.
      • tryLiteralForPreferredLanguages

        protected org.apache.jena.rdf.model.Literal tryLiteralForPreferredLanguages​(List<org.apache.jena.rdf.model.Literal> labels)
        Searches for literal in preferred language.
        Parameters:
        labels - the literals to search; must not be null
        Returns:
        the literal in preferred language if its containing in given list; otherwise the first entry will returned; returns null if an empty list was given
      • getDefaultLanguage

        protected String getDefaultLanguage()
      • checkURI

        protected String checkURI​(String uri)
        Checks a URI for validity. Jena models can store invalid URIs, but this causes RDF/XML output serialization to fail.
        Parameters:
        uri - URI
        Returns:
        null if URI is good, otherwise an error message String
      • isBooleanClassExpression

        public boolean isBooleanClassExpression​(org.apache.jena.ontology.OntClass cls)
      • getOntClass

        protected org.apache.jena.ontology.OntClass getOntClass​(org.apache.jena.ontology.OntModel ontModel,
                                                                String vitroURIStr)
      • getClassURIStr

        protected String getClassURIStr​(org.apache.jena.rdf.model.Resource cls)
      • makeNodeForURI

        protected org.apache.jena.graph.Node makeNodeForURI​(String vitroURIStr)
      • listDirectObjectPropertyValues

        protected List<org.apache.jena.rdf.model.Resource> listDirectObjectPropertyValues​(org.apache.jena.rdf.model.Resource subj,
                                                                                          org.apache.jena.rdf.model.Property prop)
      • listDirectObjectPropertySubjects

        protected List<org.apache.jena.rdf.model.Resource> listDirectObjectPropertySubjects​(org.apache.jena.rdf.model.Resource value,
                                                                                            org.apache.jena.rdf.model.Property prop)
      • getSmartRemoval

        protected org.apache.jena.rdf.model.Model[] getSmartRemoval​(org.apache.jena.ontology.OntResource ontRes,
                                                                    org.apache.jena.ontology.OntModel ontModel)
        Returns additions and retractions to perform
        Parameters:
        ontRes - Ontology resource
        ontModel - Ontology model
        Returns:
        Model[] where [0] is retractions and [1] is additions
      • smartRemove

        protected void smartRemove​(org.apache.jena.ontology.OntResource ontRes,
                                   org.apache.jena.ontology.OntModel ontModel)
      • removeRulesMentioningResource

        public void removeRulesMentioningResource​(org.apache.jena.rdf.model.Resource res,
                                                  org.apache.jena.ontology.OntModel ontModel)