Class AgentActionSchema

  • All Implemented Interfaces:
    Serializable, Serializable

    public class AgentActionSchema
    extends ConceptSchema
    The class to be used to define schemas of agent actions in an ontology. Note that an AgentActionSchema should also be a ConceptSchema, but this inheritance relation is cut as Java does not support multiple inheritance. As a consequence in practice it will not be possible to define e.g. a ConceptSchema with a slot whose value must be instances of a certain type of agent-action even if in theory this should be possible as a ConceptSchema can have slots of type term and an agent-action is a concept and therefore a term.
    Author:
    Federico Bergenti - Universita` di Parma
    See Also:
    Serialized Form
    • Constructor Detail

      • AgentActionSchema

        public AgentActionSchema​(String typeName)
        Creates an AgentActionSchema with a given type-name.
        Parameters:
        typeName - The name of this AgentActionSchema.
    • Method Detail

      • getBaseSchema

        public static ObjectSchema getBaseSchema()
        Retrieve the generic base schema for all agent actions.
        Returns:
        the generic base schema for all agent actions.
      • add

        public void add​(String name,
                        PredicateSchema slotSchema)
        Add a mandatory slot of type PredicateSchema to this schema.
        Parameters:
        name - The name of the slot.
        slotSchema - The schema of the slot.
      • add

        public void add​(String name,
                        PredicateSchema slotSchema,
                        int optionality)
        Add a slot of type PredicateSchema to this schema.
        Parameters:
        name - The name of the slot.
        slotSchema - The schema of the slot.
        optionality - The optionality, i.e. OPTIONAL or MANDATORY
      • descendsFrom

        protected boolean descendsFrom​(ObjectSchema s)
        Return true if - s is the base schema for the XXXSchema class this schema is an instance of (e.g. s is ConceptSchema.getBaseSchema() and this schema is an instance of ConceptSchema) - s is the base schema for a super-class of the XXXSchema class this schema is an instance of (e.g. s is TermSchema.getBaseSchema() and this schema is an instance of ConceptSchema. Moreover, as AgentActionSchema extends GenericActionSchema, but should also extend ConceptSchema (this is not possible in practice as Java does not support multiple inheritance), this method returns true also in the case that s is equals to, or is an ancestor of, ConceptSchema.getBaseSchema() (i.e. TermSchema.getBaseSchema() descends from s)
        Overrides:
        descendsFrom in class ConceptSchema
      • setResult

        public void setResult​(TermSchema resultSchema)
        Define that the result produced by the execution of an action described by this schema has a structure conforming to a given term schema.
        Parameters:
        resultSchema - the schema of the result
      • setResult

        public void setResult​(TermSchema elementsSchema,
                              int cardMin,
                              int cardMax)
        Define that the result produced by the execution of an action described by this schema is an aggregate of n (with n between cardMin and cardMax) elements each one having a structure conforming to a given term schema.
        Parameters:
        elementsSchema - the schema of the elements in the result aggregate
        cardMin - the result must include at least cardMin elements
        cardMax - the result must include at most cardMax elements
      • getResultSchema

        public TermSchema getResultSchema()
      • getResultFacets

        public Facet[] getResultFacets()
      • add

        protected void add​(String name,
                           ObjectSchema slotSchema,
                           int optionality)
        Add a slot to the schema.
        Specified by:
        add in class ObjectSchema
        Parameters:
        name - The name of the slot.
        slotSchema - The schema defining the type of the slot.
        optionality - The optionality, i.e., OPTIONAL or MANDATORY
      • add

        protected void add​(String name,
                           ObjectSchema slotSchema)
        Add a mandatory slot to the schema.
        Specified by:
        add in class ObjectSchema
        Parameters:
        name - name of the slot.
        slotSchema - schema of the slot.
      • add

        protected void add​(String name,
                           ObjectSchema elementsSchema,
                           int cardMin,
                           int cardMax)
        Add a slot with cardinality between cardMin and cardMax to this schema. Adding such a slot corresponds to add a slot of type Aggregate and then to add proper facets (constraints) to check that the type of the elements in the aggregate are compatible with elementsSchema and that the aggregate contains at least cardMin elements and at most cardMax elements. By default the Aggregate is of type BasicOntology.SEQUENCE.
        Specified by:
        add in class ObjectSchema
        Parameters:
        name - The name of the slot.
        elementsSchema - The schema for the elements of this slot.
        cardMin - This slot must get at least cardMin values
        cardMax - This slot can get at most cardMax values
      • add

        protected void add​(String name,
                           ObjectSchema elementsSchema,
                           int cardMin,
                           int cardMax,
                           String aggType)
        Add a slot with cardinality between cardMin and cardMax to this schema and allow specifying the type of Aggregate to be used for this slot.
        Specified by:
        add in class ObjectSchema
        Parameters:
        name - The name of the slot.
        elementsSchema - The schema for the elements of this slot.
        cardMin - This slot must get at least cardMin values
        cardMax - This slot can get at most cardMax values
        aggType - The type of Aggregate to be used
        See Also:
        ObjectSchema.add(String, ObjectSchema, int, int)
      • addSuperSchema

        protected void addSuperSchema​(ObjectSchema superSchema)
        Add a super schema to this schema, i.e. this schema will inherit all characteristics from the super schema
        Specified by:
        addSuperSchema in class ObjectSchema
        Parameters:
        superSchema - the super schema.
      • getTypeName

        public String getTypeName()
        Retrieves the name of the type of this schema.
        Specified by:
        getTypeName in class ObjectSchema
        Returns:
        the name of the type of this schema.
      • getNames

        public String[] getNames()
        Returns the names of all the slots in this Schema (including slots defined in super schemas).
        Specified by:
        getNames in class ObjectSchema
        Returns:
        the names of all slots.
      • getOwnNames

        public String[] getOwnNames()
        Returns the names of the slots defined in this Schema (excluding slots defined in super schemas).
        Specified by:
        getOwnNames in class ObjectSchema
        Returns:
        the names of the slots defined in this Schema.
      • containsSlot

        public boolean containsSlot​(String name)
        Indicate whether a given String is the name of a slot defined in this Schema
        Specified by:
        containsSlot in class ObjectSchema
        Parameters:
        name - The String to test.
        Returns:
        true if name is the name of a slot defined in this Schema.
      • isOwnSlot

        public boolean isOwnSlot​(String name)
        Indicate whether a given String is the name of a slot actually defined in this Schema (excluding super-schemas)
        Specified by:
        isOwnSlot in class ObjectSchema
        Parameters:
        name - The String to test.
        Returns:
        true if name is the name of a slot actually defined in this Schema (excluding super-schemas).
      • isMandatory

        public boolean isMandatory​(String name)
                            throws OntologyException
        Indicate whether a slot of this schema is mandatory
        Specified by:
        isMandatory in class ObjectSchema
        Parameters:
        name - The name of the slot.
        Returns:
        true if the slot is mandatory.
        Throws:
        OntologyException - If no slot with this name is present in this schema.
      • validateSlots

        protected void validateSlots​(AbsObject abs,
                                     Ontology onto)
                              throws OntologyException
        For each slot - get the corresponding attribute value from the abstract descriptor abs - Check that it is not null if the slot is mandatory - Check that its schema is compatible with the schema of the slot - Check that it is a correct abstract descriptor by validating it against its schema.
        Throws:
        OntologyException
      • isCompatibleWith

        public boolean isCompatibleWith​(ObjectSchema s)
        Check if this schema is compatible with a given schema s. This is the case if 1) This schema is equals to s 2) s is one of the super-schemas of this schema 3) This schema descends from s i.e. - s is the base schema for the XXXSchema class this schema is an instance of (e.g. s is ConceptSchema.getBaseSchema() and this schema is an instance of ConceptSchema) - s is the base schema for a super-class of the XXXSchema class this schema is an instance of (e.g. s is TermSchema.getBaseSchema() and this schema is an instance of ConceptSchema)
        Specified by:
        isCompatibleWith in class ObjectSchema
      • getSuperSchemas

        public ObjectSchema[] getSuperSchemas()
        Description copied from class: ObjectSchema
        Retrieves an array containing the direct super-schemas of this schema. If this schema has no super-schema an empty array is returned
        Specified by:
        getSuperSchemas in class ObjectSchema
        Returns:
        an array containing the direct super-schemas of this schema.
      • getFacets

        public Facet[] getFacets​(String slotName)
        Description copied from class: ObjectSchema
        Retrieves the facets defined upon a slot. More in details this method returns all facets defined in this schema plus all facets defined in super-schemas up to the schema actually declaring the given slot.
        Specified by:
        getFacets in class ObjectSchema
        Parameters:
        slotName - the name of the slot
        Returns:
        the facets defined upon a slot or null if the specified slot is not found.
      • isAssignableFrom

        public boolean isAssignableFrom​(ObjectSchema s)
        Description copied from class: ObjectSchema
        This method checks whether or not an abstract object that is an instance of schema s can be used in place of an abstract object that is an instance of this schema. Note that unlike the method isCompatibleWith() that perform "ontological" checks (i.e. they are related to the reference ontology), this method only performs a structural check on the slots regardless of the fact that the two schemas belong to the same ontology or not.
        Specified by:
        isAssignableFrom in class ObjectSchema