Class ValidatorDefinition

  • All Implemented Interfaces:
    Comparable<ValidatorDefinition>

    public class ValidatorDefinition
    extends Object
    implements Comparable<ValidatorDefinition>
    Represents the configuration of a validator. A validator is a mechanism that allows to check certain conditions related to a given inventory object and embed the results in a BusinessObjectLight instance. For example, a validator may check if an object has a particular operationalState (say "In Operation", "Decommissioned") and return the result in the BusinessObjectLight instance, instead of having to retrieve the whole object (a BusinessObject instance) to check the condition at client side. This is particularly useful when calling methods like getObjectChildren, since the result is a list of BusinessObjectLight instances, not BusinessObjects. The value of a validator can be then used to, among other things, render the objects matching a condition in a certain way, for example, in a Navigation Tree, all connected ports can be displayed in red, while those reserved in orange.
    Author:
    Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
    • Constructor Detail

      • ValidatorDefinition

        public ValidatorDefinition​(long id,
                                   String name,
                                   String description,
                                   String classToBeApplied,
                                   String script,
                                   boolean enabled)
    • Method Detail

      • getId

        public long getId()
      • setId

        public void setId​(long id)
      • getName

        public String getName()
      • setName

        public void setName​(String name)
      • getDescription

        public String getDescription()
      • setDescription

        public void setDescription​(String description)
      • getClassToBeApplied

        public String getClassToBeApplied()
      • setClassToBeApplied

        public void setClassToBeApplied​(String classToBeApplied)
      • getScript

        public String getScript()
      • setScript

        public void setScript​(String script)
      • isEnabled

        public boolean isEnabled()
      • setEnabled

        public void setEnabled​(boolean enabled)
      • run

        public Validator run​(String objectClass,
                             String objectId,
                             ConnectionManager cm,
                             MetadataEntityManager mem,
                             BusinessEntityManager bem,
                             ApplicationEntityManager aem)
        This method should be implemented by all validator definition scripts (which must define a subclass of ValidatorDefinition), and contains the logic to evaluate the condition.Two variables are injected as parameters: the objectClass and the objectId.
        Parameters:
        objectClass - The class of the object to be evaluated.
        objectId - The id of the object to be evaluated.
        cm - Reference to the connection manager. Mainly useful to run raw queries in the database.
        mem - Reference to the Metadata Entity Manager.
        bem - Reference to the Business Entity Manager.
        aem - Reference to the Application Entity Manager.
        Returns:
        The validator product of evaluating the definition condition