Interface IEntityInstance

All Superinterfaces:
IEventChannel, IPropertyContainer, Serializable
All Known Implementing Classes:
ConcurrentEntityInstance, DependencyInstance, EntityInstance, InstanceDelegate, ReadonlyInstance, TmsEntityInstance, TxEntityInstance

public interface IEntityInstance extends IEventChannel, IPropertyContainer
An entity instance is an instantiation of an entity type at runtime.
Since:
5.0
Author:
O. Kerpershoek, F. v.d. Meer
  • Method Details

    • getId

      GUID getId()
      This method returns the unique ID of this instance. The id of an instance is generated upon creation.
      Returns:
      long containing the unique identifier of this instance.
    • getName

      String getName()
      This method returns the unique name of the instance. The name of an instance is either provided upon construction with createInstance, provided as a property of a static instance, or automatically generated when none was available.
      Returns:
      Unique name of the instance
    • getInstanceReference

      EntityValue getInstanceReference()
      returns the instance identifier denoting this instance.
      Returns:
      EntityValue never null.
    • instanceOf

      boolean instanceOf(String entityName)
      This method checks if the instance is of the specified type. The instance is considered to be of the given type when either the type matches the actual type directly, or when the actual type is a specialization of the supplied type.

      Example: An instance of polygon that extends shape will return true for the types polygon and shape, but false for the type square (which extends the polygon type).

      This method is the direct equivalent of getEntityDefinition().typeOf( String entityName ).
      Parameters:
      entityName - The name of the entity type that should be used to check this instance against.
      Returns:
      boolean indicating if the instance is either directly of the supplied type, or extends the type.
    • getReferringInstances

      InstanceReferrer[] getReferringInstances()
      This method returns information about the instances that are referring this instance. The InstanceReferrer objects can be used to determine what instance is referring this one, and through what attribute. The attribute by which this instance is referenced is needed, as an instance may have multiple references to another through different attributes.
      Returns:
      Array of reference objects containing information about the referring instance.
      Throws:
      UnknownInstanceException - This exception is thrown when the instance is no longer valid (deleted).
    • setValue

      boolean setValue(String attributeName, Object objValue)
      This method sets the specified value for the given attribute. Possible objects to pass to this method:
      • IEntityInstance denoting an instance.
      • EntityValue denoting an instance.
      • Number/NumberValue/IntegerValue/Currency/Percentage denoting one of [ number, currency, percentage ]
      • Boolean/BooleanValue denoting a boolean type.
      • Date/DateValue/DateTimeValue denoting a date object
      • String/StringValue denoting a string object, domain's short value
      • Collection containing any combination of above. Mixed is allowed i.e. [ EntityValue, IEntityInstance ]
      • Object[] containing any combination of above. Mixed is allowed i.e. [ EntityValue, IEntityInstance ]
      Parameters:
      attributeName - the attribute name, preferred name instead of Person.name
      objValue - The objects value to set as value (can be null).
      Returns:
      Boolean indicating whether the value of the attribute did change.
      Throws:
      AppException - This exception is thrown when the parameters are incorrect (for instance an invalid attribute name).
    • getValue

      IValue getValue(String attributeName)
      This method can be used to retrieve a value for an attribute of this instance in a non-type safe manner.
      • DataType.Boolean returns a BooleanValue
      • DataType.Currency returns a DoubleValue
      • DataType.Date returns a DateValue
      • DataType.Number returns a NumberValue
      • DataType.Integer returns a IntegerValue
      • DataType.Percentage returns a DoubleValue
      • DataType.String returns a StringValue
      • DataType.Domain returns a StringValue containing the short value, and has the display value as well.
      • DataType.Entity returns an EntityValue object denoting the instance this relation was pointing to.
      N.B.
      1. If the value was not answered the return value is as specified but on the IValue object the isUnknown function renders true
      2. If the value was answered and the single value was null the return value is not null, but the isUnknown function results in true
      3. If the value is a multivalued attribute a collection containing the only the object types listed above.
      Parameters:
      attributeName - String (without the entity name)
      Returns:
      The value for the specified attribute name.
      Throws:
      AppException - This exception is raised when for instance the attribute name is not known within the entity definition.
    • getInstanceValue

      IEntityInstance getInstanceValue(String attributeName)
      This method returns the instances that is referred to by the given attribute. If the attribute does not refer to an instance, a null value is returned.
      Parameters:
      attributeName - The name of the attribute containing the instance.
      Returns:
      The IEntityInstance referred to by the attribute.
      Throws:
      AppException - This exception is raised when for instance the attribute name is not known within the entity definition.
    • getInstanceValues

      IEntityInstance[] getInstanceValues(String attributeName)
      This method returns an array containing all the instances that are referred to by the given attribute. If the attribute does not refer to any instance, an empty array is returned.
      Parameters:
      attributeName - The name of the attribute containing the instances.
      Returns:
      An array containing all the instances that are referred to by the attribute.
      Throws:
      AppException - This exception is raised when for instance the attribute name is not known within the entity definition.
    • removeValue

      boolean removeValue(String attributeName, ISingleValue singleValue)
      Removes a specified value from the multivalued-attribute. Possible datatypes for singleValue:
      • DataType.IEntityInstance denoting an instance.
      • DataType.EntityValue denoting an instance.
      • DataType.Number denoting one of [ domainValueId, number, currency, percentage ]
      • DataType.Boolean denoting a boolean type.
      • DataType.Date denoting a date object
      • DataType.String denoting a string object, domain's short value
      Parameters:
      attributeName - the attribute name ( without the entity name )
      singleValue - The value that should be removed.
      Returns:
      boolean if the value was found in the original value list.
      Throws:
      AppException - This exception is raised when for instance the attribute name is not known within the entity definition.
    • addValue

      boolean addValue(String attributeName, ISingleValue singleValue)
      This function will add the designated value to the existing profile's value. If there was one, otherwise a single value is put in. Duplicate values are not allowed, and invoking this method with a value that is already present in the attribute has no effect.
      Parameters:
      attributeName - The name of the attribute to which the value should be added.
      singleValue - The value that should be added to the attribute specified.
      Returns:
      boolean indicating whether the value was actually added (a duplicate value will result in false).
      Throws:
      AppException - This exception is raised when for instance the attribute name is not known within the entity definition.
    • clearValue

      boolean clearValue(String attributeName)
      Clears the designated value, returning its state to UNKNOWN.
      Parameters:
      attributeName - String the attribute name.
      Returns:
      boolean true whether the attribute-value was changed by this action.
      Throws:
      AppException - This exception is raised when for instance the attribute name is not known within the entity definition.
    • getAttributeState

      IAttributeValue getAttributeState(String attributeName)
      When the attribute is known, it will return the state of the attribute.
      Parameters:
      attributeName - String Preferably without the entity name
      Returns:
      The state information of the attribute.
      Throws:
      AppException - When the attribute or instance could not be found
    • isSingletonInstance

      boolean isSingletonInstance()
      This method returns a boolean indicating whether this instance is the singleton instance for its entity type. A singleton instance always has the same id (zero), and is guaranteed to be the only instance of its type.
      Returns:
      boolean indicating whether this instance is the singleton instance for its entity type.
    • isStaticInstance

      boolean isStaticInstance()
      Checks whether the entity instance is a static instance. Static instances are defined in KnowledgeStudio and will always be present in the profile with the same name.
      Returns:
      boolean indicating whether the entity instance is a static instance.
    • isDeleted

      boolean isDeleted()

      This method returns a boolean indicating if the instance has been deleted. A reference to a deleted instance may still be used, but certain methods will no longer be available. Any method that would modify the state of the instance, for example the setValue method, will throw an UnknownInstanceException when invoked on a deleted instance. Methods that return information about the state, for example the getValue method, will still be available.

      Note: Deleted instances never refer to other instances, so the getInstanceValue(s) method will not be available. Requesting the value for any relation attribute on a deleted instance will always result in an unknown value.

      Returns:
      A boolean indicating if the instance has been deleted.
    • getEntityDefinition

      IEntityDefinition getEntityDefinition()
      This method returns the entity definition of this instance. The entity definition object can be used to retrieve the static information of the entity.
      Returns:
      IEntityDefinition object containing the static information about an entity.