Class ValidatorDefinition
- java.lang.Object
-
- org.neotropic.kuwaiba.core.apis.persistence.application.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 Summary
Constructors Constructor Description ValidatorDefinition(long id, String name, String description, String classToBeApplied, String script, boolean enabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ValidatorDefinition o)
String
getClassToBeApplied()
String
getDescription()
long
getId()
String
getName()
String
getScript()
boolean
isEnabled()
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: theobjectClass
and theobjectId
.void
setClassToBeApplied(String classToBeApplied)
void
setDescription(String description)
void
setEnabled(boolean enabled)
void
setId(long id)
void
setName(String name)
void
setScript(String script)
-
-
-
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)
-
compareTo
public int compareTo(ValidatorDefinition o)
- Specified by:
compareTo
in interfaceComparable<ValidatorDefinition>
-
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: theobjectClass
and theobjectId
.- 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
-
-