Class OmlWrite

java.lang.Object
io.opencaesar.oml.util.OmlWrite

public class OmlWrite extends Object
The Write API for the model. It complements the OML setter API by additional utilities. *
  • Constructor Details

    • OmlWrite

      public OmlWrite()
  • Method Details

    • setCrossReference

      protected static void setCrossReference(Ontology ontology, Element subject, org.eclipse.emf.ecore.EReference eRef, Element object)
      Sets the given eRef on the given subject to an object in the context of the given ontology
      Parameters:
      ontology - the given ontology
      subject - the given subject
      eRef - the given eReference
      object - the given object
    • setCrossReferences

      protected static void setCrossReferences(Ontology ontology, Element subject, org.eclipse.emf.ecore.EReference eRef, List<? extends Element> objects)
      Sets the given eRef on the given subject to a List of objects in the context of the given ontology
      Parameters:
      ontology - the given ontology
      subject - the given subject
      eRef - the given eReference
      objects - the given list of objects
    • setContainmentReference

      protected static void setContainmentReference(Ontology ontology, Element subject, org.eclipse.emf.ecore.EReference eRef, Element object)
      Sets the given object to be contained by the given subject in the context of the given ontology
      Parameters:
      ontology - the given ontology
      subject - the given subject
      eRef - the containment eRef to use on subject if it belongs to the given ontology
      object - the given object
    • create

      protected static <T extends Element> T create(Class<T> type)
      Creates an object of the given type using the Oml factory
      Parameters:
      type - the given Java type
      Returns:
      an Oml object of the given type
    • getOrAddRef

      protected static Member getOrAddRef(Ontology ontology, Member member)
      Gets an existing or creates a new ref to the given member in the context of the given ontology
      Parameters:
      ontology - the context ontology
      member - the given member
      Returns:
      a ref to the given member in the context of the given ontology
    • addAnnotation

      public static Annotation addAnnotation(Ontology ontology, AnnotationProperty property, Literal literalValue, Member referencedValue)
      Adds a new annotation with either a literal or reference value (but not both) on a given ontology
      Parameters:
      ontology - the ontology to annotate
      property - the given annotation property
      literalValue - the annotation literal value
      referencedValue - the annotation reference value
      Returns:
      a new annotation on the given ontology
    • addAnnotation

      public static Annotation addAnnotation(Ontology ontology, IdentifiedElement element, AnnotationProperty property, Literal literalValue, Member referencedValue)
      Adds a new annotation with either a literal or reference value (but not both) on a given element in the context of a given ontology
      Parameters:
      ontology - the context ontology that will have the annotation axiom
      element - the annotated element to put the annotation on
      property - the given annotation property
      literalValue - the annotation literal value
      referencedValue - the annotation reference value
      Returns:
      a new annotation on the given member in the context of the given ontology
    • createOntology

      protected static <T extends Ontology> T createOntology(Class<T> type, String namespace, String prefix)
      Creates a new ontology of the given sub type
      Parameters:
      type - the sub type of ontology to create
      namespace - the namespace of the new ontology
      prefix - the prefix of the new ontology
      Returns:
      a newly created ontology added to the contents of a resource with the given URI
    • createVocabulary

      public static Vocabulary createVocabulary(String namespace, String prefix)
      Creates a new vocabulary
      Parameters:
      namespace - the namespace of the new vocabulary
      prefix - the prefix of the new vocabulary
      Returns:
      a newly created vocabulary added to the contents of a resource with the given URI
    • createVocabularyBundle

      public static VocabularyBundle createVocabularyBundle(String namespace, String prefix)
      Creates a new vocabulary bundle
      Parameters:
      namespace - the namespace of the new vocabulary bundle
      prefix - the prefix of the new vocabulary bundle
      Returns:
      a newly created vocabulary bunel added to the contents of a resource with the given URI
    • createDescription

      public static Description createDescription(String namespace, String prefix)
      Creates a new description
      Parameters:
      namespace - the namespace of the new description
      prefix - the prefix of the new description
      Returns:
      a newly created description added to the contents of a resource with the given URI
    • createDescriptionBundle

      public static DescriptionBundle createDescriptionBundle(String namespace, String prefix)
      Creates a new description bundle
      Parameters:
      namespace - the namespace of the new description bundle
      prefix - the prefix of the new description bundle
      Returns:
      a newly created description bundle added to the contents of a resource with the given URI
    • addAspect

      public static Aspect addAspect(Vocabulary vocabulary, String name)
      Creates a new aspect and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new aspect
      Returns:
      a new aspect that is added to the given vocabulary
    • addConcept

      public static Concept addConcept(Vocabulary vocabulary, String name)
      Creates a new concept and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new concept
      Returns:
      a new concept that is added to the given vocabulary
    • addRelationEntity

      public static RelationEntity addRelationEntity(Vocabulary vocabulary, String name, List<Entity> sources, List<Entity> targets, boolean functional, boolean inverseFunctional, boolean symmetric, boolean asymmetric, boolean reflexive, boolean irreflexive, boolean transitive)
      Creates a new relation entity and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new concept
      sources - the given list of source entities
      targets - the given list of target entities
      functional - whether the relation entity is functional
      inverseFunctional - whether the relation entity is inverse functional
      symmetric - whether the relation entity is symmetric
      asymmetric - whether the relation entity is asymmetric
      reflexive - whether the relation entity is reflexive
      irreflexive - whether the relation entity is irreflexive
      transitive - whether the relation entity is transitive
      Returns:
      a new relation entity that is added to the given vocabulary
    • addStructure

      public static Structure addStructure(Vocabulary vocabulary, String name)
      Creates a new structure and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new structure
      Returns:
      a new structure that is added to the given vocabulary
    • addAnnotationProperty

      public static AnnotationProperty addAnnotationProperty(Vocabulary vocabulary, String name)
      Creates a new annotation property and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new annotation property
      Returns:
      a new annotation property that is added to the given vocabulary
    • addScalarProperty

      public static ScalarProperty addScalarProperty(Vocabulary vocabulary, String name, List<Classifier> domains, List<Scalar> ranges, boolean functional)
      Creates a new scalar property and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new scalar property
      domains - the given list of domain classifiers
      ranges - the given list of range scalars
      functional - whether the scalar property is functional
      Returns:
      a new scalar property that is added to the given vocabulary
    • addStructuredProperty

      public static StructuredProperty addStructuredProperty(Vocabulary vocabulary, String name, List<Classifier> domains, List<Structure> ranges, boolean functional)
      Creates a new structured property and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new structured property
      domains - the given list of domain classifiers
      ranges - the given list of target structures
      functional - whether the structured property is functional
      Returns:
      a new structured property that is added to the given vocabulary
    • addScalar

      public static Scalar addScalar(Vocabulary vocabulary, String name)
      Creates a new scalar and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new scalar
      Returns:
      a new scalar that is added to the given vocabulary
    • addForwardRelation

      public static ForwardRelation addForwardRelation(RelationEntity entity, String name)
      Creates a forward relation and adds it to the given relation entity
      Parameters:
      entity - the context relation entity
      name - the name of the new forward relation
      Returns:
      a forward relation that is added to the given relation entity
    • addReverseRelation

      public static ReverseRelation addReverseRelation(RelationBase base, String name)
      Creates a reverse relation and adds it to the given relation base
      Parameters:
      base - the context relation base
      name - the name of the new reverse relation
      Returns:
      a reverse relation that is added to the given relation base
    • addUnreifiedRelation

      public static UnreifiedRelation addUnreifiedRelation(Vocabulary vocabulary, String name, List<Entity> sources, List<Entity> targets, boolean functional, boolean inverseFunctional, boolean symmetric, boolean asymmetric, boolean reflexive, boolean irreflexive, boolean transitive)
      Creates a new unreified relation and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new concept
      sources - the given list of source entities
      targets - the given list of target entities
      functional - whether the relation entity is functional
      inverseFunctional - whether the relation entity is inverse functional
      symmetric - whether the relation entity is symmetric
      asymmetric - whether the relation entity is asymmetric
      reflexive - whether the relation entity is reflexive
      irreflexive - whether the relation entity is irreflexive
      transitive - whether the relation entity is transitive
      Returns:
      a new unreified relation that is added to the given vocabulary
    • addRule

      public static Rule addRule(Vocabulary vocabulary, String name, Predicate[] antecedent, Predicate[] consequent)
      Creates a rule and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new rule
      antecedent - a list of antecedent predicates of the rule
      consequent - a list of consequent predicates of the rule
      Returns:
      a rule that is added to the given vocabulary
    • addBuiltIn

      public static BuiltIn addBuiltIn(Vocabulary vocabulary, String name)
      Creates a builtIn and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      name - the name of the new builtIn
      Returns:
      a builtIn that is added to the given vocabulary
    • createStructureInstance

      public static StructureInstance createStructureInstance(Ontology ontology, Structure structure)
      Creates a structure instance and adds it to the given ontology
      Parameters:
      ontology - the context ontology
      structure - the given structure that is the type of the structure instance
      Returns:
      a structure instance that is added to the given ontology
    • addConceptInstance

      public static ConceptInstance addConceptInstance(Description description, String name)
      Creates a concept instance and adds it to the given description
      Parameters:
      description - the context description
      name - the name of the new concept instance
      Returns:
      a concept instance that is added to the given description
    • addRelationInstance

      public static RelationInstance addRelationInstance(Description description, String name, List<NamedInstance> sources, List<NamedInstance> targets)
      Creates a relation instance and adds it to the given description
      Parameters:
      description - the context description
      name - the name of the new relation instance
      sources - a given list of source instances
      targets - a given list of target instances
      Returns:
      a relation instance that is added to the given description
    • createRef

      protected static <T extends Member> T createRef(T member)
      Creates a ref to the given member
      Parameters:
      member - the given member
      Returns:
      a ref for the given member
    • addImport

      public static Import addImport(Ontology ontology, ImportKind kind, String namespace, String prefix)
      Creates an import and adds it to the given ontology
      Parameters:
      ontology - the importing ontology
      kind - the kind of import
      namespace - the namespace of the imported ontology
      prefix - the prefix of the imported ontology (optional)
      Returns:
      an import that is added to the importing ontology
    • addImport

      public static void addImport(Ontology ontology, Ontology importedOntology)
      Creates an import to a given ontology and adds it to a context ontology
      Parameters:
      ontology - The importing ontology
      importedOntology - The imported ontology
    • addSpecializationAxiom

      public static SpecializationAxiom addSpecializationAxiom(Vocabulary vocabulary, Term subTerm, Term superTerm)
      Creates a specialization axiom between two terms and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      subTerm - the given sub term
      superTerm - the given super term
      Returns:
      a specialization axiom that is added to the vocabulary
    • addClassifierEquivalenceAxiom

      public static ClassifierEquivalenceAxiom addClassifierEquivalenceAxiom(Vocabulary vocabulary, Classifier subClassifier, List<Classifier> superClassifiers)
      Creates a classifier equivalence axiom between the sub classifier and super classifiers and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      subClassifier - the given sub classifier
      superClassifiers - the given super classifiers
      Returns:
      a classifier equivalence axiom that is added to the vocabulary
    • addScalarEquivalenceAxiom

      public static ScalarEquivalenceAxiom addScalarEquivalenceAxiom(Vocabulary vocabulary, Scalar subScalar, Scalar superScalar, Integer length, Integer minLength, Integer maxLength, String pattern, String language, Literal minInclusive, Literal minExclusive, Literal maxInclusive, Literal maxExclusive)
      Creates a scalar equivalence axiom between the sub scalar and super scalar and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      subScalar - the given sub scalar
      superScalar - the given super scalar
      length - the length facet
      minLength - the min length facet
      maxLength - the max length facet
      pattern - the string pattern facet
      language - the language facet
      minInclusive - the min inclusive facet
      minExclusive - the min exclusive facet
      maxInclusive - the max inclusive facet
      maxExclusive - the max exclusive facet
      Returns:
      a scalar equivalence axiom that is added to the vocabulary
    • addPropertyEquivalenceAxiom

      public static PropertyEquivalenceAxiom addPropertyEquivalenceAxiom(Vocabulary vocabulary, SpecializableProperty subProperty, Property superProperty)
      Creates a property equivalence axiom between the sub property and super property and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      subProperty - the given sub property
      superProperty - the given super property
      Returns:
      a property equivalence axiom that is added to the vocabulary
    • addPropertyRangeRestrictionAxiom

      public static PropertyRangeRestrictionAxiom addPropertyRangeRestrictionAxiom(Vocabulary vocabulary, Element owner, SemanticProperty property, Type range, RangeRestrictionKind restrictionKind)
      Creates a property range restriction axiom and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      owner - the given restricting owner (classifier or classifier equivalence axiom)
      property - the given restricted property
      range - given restricted range
      restrictionKind - the kind of the restriction
      Returns:
      a property range restriction axiom that is added to the given vocabulary
    • addPropertyCardinalityRestrictionAxiom

      public static PropertyCardinalityRestrictionAxiom addPropertyCardinalityRestrictionAxiom(Vocabulary vocabulary, Element owner, SemanticProperty property, CardinalityRestrictionKind restrictionKind, int cardinality, Type range)
      Creates a property cardinality restriction axiom and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      owner - the given restricting owner (classifier or classifier equivalence axiom)
      property - the given restricted property
      cardinality - the restricted cardinality
      range - given restricted range
      restrictionKind - the kind of the restriction
      Returns:
      a property cardinality restriction axiom that is added to the given vocabulary
    • addPropertyValueRestrictionAxiom

      public static PropertyValueRestrictionAxiom addPropertyValueRestrictionAxiom(Vocabulary vocabulary, Element owner, ScalarProperty property, Literal value)
      Creates a property value restriction axiom on a scalar property and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      owner - the given restricting owner (classifier or classifier equivalence axiom)
      property - the given scalar property
      value - the restricted literal value
      Returns:
      a property value restriction axiom that is added to the given vocabulary
    • addPropertyValueRestrictionAxiom

      public static PropertyValueRestrictionAxiom addPropertyValueRestrictionAxiom(Vocabulary vocabulary, Element owner, StructuredProperty property, StructureInstance value)
      Creates a property value restriction axiom on a structured property and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      owner - the given restricting owner (classifier or classifier equivalence axiom)
      property - the given structured property
      value - the restricted structure instance value
      Returns:
      a property value restriction axiom that is added to the given vocabulary
    • addPropertyValueRestrictionAxiom

      public static PropertyValueRestrictionAxiom addPropertyValueRestrictionAxiom(Vocabulary vocabulary, Element owner, Relation relation, NamedInstance value)
      Creates a value restriction axiom on a relation and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      owner - the given restricting owner (classifier or classifier equivalence axiom)
      relation - the given relation
      value - the restricted named instance value
      Returns:
      a property value restriction axiom that is added to the given vocabulary
    • addPropertySelfRestrictionAxiom

      public static PropertySelfRestrictionAxiom addPropertySelfRestrictionAxiom(Vocabulary vocabulary, Element owner, Relation relation)
      Creates a self restriction axiom on a relation and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      owner - the given restricting owner (classifier or classifier equivalence axiom)
      relation - the given relation
      Returns:
      a property value restriction axiom that is added to the given vocabulary
    • addKeyAxiom

      public static KeyAxiom addKeyAxiom(Vocabulary vocabulary, Entity domain, List<Property> keyProperties)
      Creates a key axiom and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      domain - the given keyed (entity) domain
      keyProperties - the list of properties that are part of the key
      Returns:
      a key axiom that is added to the given vocabulary
    • addInstanceEnumerationAxiom

      public static InstanceEnumerationAxiom addInstanceEnumerationAxiom(Vocabulary vocabulary, Concept domain, List<ConceptInstance> instances)
      Creates an instance enumeration axiom and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      domain - the given (concept) domain
      instances - the list of concept instances
      Returns:
      an instance enumeration axiom that is added to the given vocabulary
    • addLiteralEnumerationAxiom

      public static LiteralEnumerationAxiom addLiteralEnumerationAxiom(Vocabulary vocabulary, Scalar domain, Literal... literals)
      Creates an literal enumeration axiom and adds it to the given vocabulary
      Parameters:
      vocabulary - the context vocabulary
      domain - the given (scalar) domain
      literals - the list of enumerated literals
      Returns:
      a literal enumeration axiom that is added to the given vocabulary
    • addTypeAssertion

      public static TypeAssertion addTypeAssertion(Description description, NamedInstance instance, Entity type)
      Creates a type assertion and adds it to the given description
      Parameters:
      description - the context description
      instance - the given named instance
      type - the given type
      Returns:
      a type assertion that is added to the given description
    • addPropertyValueAssertion

      public static PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Instance instance, ScalarProperty property, Literal literalValue)
      Creates a property value assertion for a scalar property and adds it to the given ontology.
      Parameters:
      ontology - the context ontology
      instance - the given instance
      property - the given scalar property
      literalValue - the asserted (literal) value of the property
      Returns:
      a property value assertion that is added to the given ontology
    • addPropertyValueAssertion

      public static PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Instance instance, StructuredProperty property, StructureInstance containedeValue)
      Creates a property value assertion for a structured property and adds it to the given ontology.
      Parameters:
      ontology - the context ontology
      instance - the given instance
      property - the given structured property
      containedeValue - the asserted contained value of the property
      Returns:
      a property value assertion that is added to the given ontology
    • addPropertyValueAssertion

      public static PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Instance instance, Relation relation, NamedInstance referencedValue)
      Creates a property value assertion for a relation and adds it to the given ontology.
      Parameters:
      ontology - the context ontology
      instance - the given instance
      relation - the given relation
      referencedValue - the asserted referenced value of the property
      Returns:
      a property value assertion that is added to the given ontology
    • createArgument

      public static Argument createArgument(Vocabulary vocabulary, String variable, Literal literal, NamedInstance instance)
      Creates an argument
      Parameters:
      vocabulary - the context vocabulary
      variable - a given variable name
      literal - a given literal
      instance - a given named instance
      Returns:
      an argument
    • createTypePredicate

      public static TypePredicate createTypePredicate(Vocabulary vocabulary, Type type, Argument argument)
      Creates a type predicate
      Parameters:
      vocabulary - the context vocabulary
      type - the given type
      argument - the argument bound to a value of the type
      Returns:
      a type predicate
    • createRelationEntityPredicate

      public static RelationEntityPredicate createRelationEntityPredicate(Vocabulary vocabulary, RelationEntity type, Argument argument1, Argument argument, Argument argument2)
      Creates an relation entity predicate
      Parameters:
      vocabulary - the context vocabulary
      type - the type of a relation instance
      argument1 - the argument bound to a named instance representing the source of a relation instance
      argument - the argument bound to a relation instance
      argument2 - the argument bound to a named instance representing the target of a relation instance
      Returns:
      a relation entity predicate
    • createPropertyPredicate

      public static PropertyPredicate createPropertyPredicate(Vocabulary vocabulary, Property property, Argument argument1, Argument argument2)
      Creates an relation predicate
      Parameters:
      vocabulary - the context vocabulary
      property - the given property
      argument1 - the argument bound to a instance representing the subject of the given property
      argument2 - the argument bound to a value representing the object of the given property
      Returns:
      a relation predicate
    • createSameAsPredicate

      public static SameAsPredicate createSameAsPredicate(Vocabulary vocabulary, Argument argument1, Argument argument2)
      Creates a sameAs predicate
      Parameters:
      vocabulary - the context vocabulary
      argument1 - the argument bound to the first named instance
      argument2 - the argument bound to the second named instance
      Returns:
      a sameAs predicate
    • createDifferentFromPredicate

      public static DifferentFromPredicate createDifferentFromPredicate(Vocabulary vocabulary, Argument argument1, Argument argument2)
      Creates a differentFrom predicate
      Parameters:
      vocabulary - the context vocabulary
      argument1 - the argument bound to the first named instance
      argument2 - the argument bound to the second named instance
      Returns:
      a differentFrom predicate
    • createBuiltInPredicate

      public static BuiltInPredicate createBuiltInPredicate(Vocabulary vocabulary, BuiltIn builtIn, Argument... arguments)
      Creates a builtIn predicate
      Parameters:
      vocabulary - the context vocabulary
      builtIn - the given builtIn
      arguments - the arguments of the builtin
      Returns:
      a builtIn predicate
    • createLiteral

      public static Literal createLiteral(Object value)
      Creates a literal from the given lexical value in the given ontology
      Parameters:
      value - the lexical value of the literal
      Returns:
      a literal with the given value
    • createQuotedLiteral

      public static QuotedLiteral createQuotedLiteral(Ontology ontology, String value, Scalar type, String langTag)
      Creates a quoted literal in the given ontology
      Parameters:
      ontology - the ontology context
      value - the lexical value of the literal
      type - the given (scalar) type of the literal (optional)
      langTag - the language tag of the literal (optional)
      Returns:
      a quoted literal
    • createIntegerLiteral

      public static IntegerLiteral createIntegerLiteral(int value)
      Creates an integer literal
      Parameters:
      value - the integer value of the literal
      Returns:
      an integer literal
    • createDecimalLiteral

      public static DecimalLiteral createDecimalLiteral(BigDecimal value)
      Creates a decimal literal
      Parameters:
      value - the big decimal value of the literal
      Returns:
      a decimal literal
    • createDoubleLiteral

      public static DoubleLiteral createDoubleLiteral(double value)
      Creates a double literal
      Parameters:
      value - the double value of the literal
      Returns:
      a double literal
    • createBooleanLiteral

      public static BooleanLiteral createBooleanLiteral(boolean value)
      Creates an boolean literal
      Parameters:
      value - the boolean value of the literal
      Returns:
      a boolean literal