Package com.aquima.interactions.profile
Interface IProfile
- All Superinterfaces:
IEventChannel
,IProfileLifecycle
,Serializable
- All Known Subinterfaces:
IComposerContext
,InferenceContext
- All Known Implementing Classes:
ComposerContext
,ConcurrentInferenceContext
,DefaultContext
,DependencyProfile
,DependentValueContext
,InferenceContextDelegate
,InstanceContext
,InstanceStackContext
,PortalProfile
,Profile
,ProfileDelegate
,ReadonlyInferenceContext
,ReadonlyProfile
,TmsProfile
,TxInferenceContext
,TxProfile
,UsedValuesInferenceContext
This interface contains various methods to retrieve information about the current state of the profile.
- Since:
- 5.0
- Author:
- O. Kerpershoek, F. v.d. Meer
-
Method Summary
Modifier and TypeMethodDescriptionvoid
commitTransaction
(String name) Commits the current transaction in the profile.createInstance
(String entityName) This method creates a new empty instance for the specified entity type.createInstance
(String entityName, GUID instanceId, String instanceName) This method creates a new empty instance for the specified entity type.void
deleteInstance
(IEntityInstance instance, boolean autoDetach) Deletes the given instance, rendering the parameter useless.getAllInstancesForEntity
(String entityName, boolean includeChildren) This method returns all existing instances of a certain type in the profile.getEntityDefinition
(String entityName) This method returns an entity definition for the supplied entity name.getInstance
(EntityValue instance) This method can be used to lookup an instance based on a reference.getInstanceById
(String entityName, GUID instanceId) This method returns the instance of the specified type for the given instance id.getInstanceByName
(String entityName, String instanceName) This method returns an instance of the specified type for the given instance name.getSingletonInstance
(String entityName, boolean create) This method can be used to retrieve the singleton instance from the profile for a specific entity type.getState()
Returns the state of the profile (for serialization)void
restore
(IProfileState state) Clears the current state and overrides it with the provided state.void
rollbackTransaction
(String name) Performs a roll-back of all changes since the last start of a transaction.void
startTransaction
(String name) Starts a new transaction in the profile.Methods inherited from interface com.aquima.interactions.foundation.events.IEventChannel
addEventListener, getSupportedEvents, removeEventListener
Methods inherited from interface com.aquima.interactions.profile.IProfileLifecycle
activate, passivate
-
Method Details
-
getInstance
This method can be used to lookup an instance based on a reference.- Parameters:
instance
- InstanceReference of the instance that should be returned.- Returns:
- IEntityInstance The entity instance for the specified ID.
- Throws:
UnknownEntityException
- This exception is thrown when the entity value contains an invalid entity name.UnknownInstanceException
- This exception is thrown when the entity value refers to an unknown instance.InstanceCastException
- This exception is thrown when the ID of the entity value does not match the actual type.
-
getInstanceByName
This method returns an instance of the specified type for the given instance name.- Parameters:
entityName
- The name of the entity (type) of which the instance should be.instanceName
- The name of the instance.- Returns:
- IEntityInstance object of the correct type for the specified name.
- Throws:
UnknownEntityException
- This exception is raised when the specified entity name is not known by the profile.UnknownInstanceException
- This exception is raised when no instance of the requested type can be found for the specified name.InstanceCastException
- This exception is raised when the type of the instance referred by the specified name could not be cast to the requested type.
-
getInstanceById
This method returns the instance of the specified type for the given instance id. The id of an instance is generated when the instance is created, and can thus only be used within the same session.- Parameters:
entityName
- The name of the entity (type) of which the instance should be.instanceId
- The (unique) id of the instance.- Returns:
- IEntityInstance object of the correct type for the specified name.
- Throws:
UnknownEntityException
- This exception is raised when the specified entity name is not known by the profile.UnknownInstanceException
- This exception is raised when no instance of the requested type can be found for the specified name.InstanceCastException
- This exception is raised when the type of the instance referred by the specified name could not be cast to the requested type.
-
getSingletonInstance
This method can be used to retrieve the singleton instance from the profile for a specific entity type. Depending on the value of the create parameter that is passed, the behavior of this method differs slightly.
- When there is a singleton instance present in the profile for the specified type, this method will return that instance regardless the value of create.
- When no instance is present for the specified type and create is set to true, the singleton instance will be created and returned.
- When no instance is present for the specified type and create is set to false, an UnknownInstanceException will be thrown.
- Parameters:
entityName
- String the Name of the entitycreate
- boolean indicating whether the singleton instance should be created in case it does not exist yet.- Returns:
- IEntityInstance interface pointing to the singleton ('0'th) instance for the specified entity type.
- Throws:
UnknownEntityException
- When the specified entity name is invalid/unknown.UnknownInstanceException
- When the singleton instance did not exist and/or could not be created.CreateInstanceException
- This type of exception may be raised when a singleton instance is requested for a non-singleton entity type.
-
getAllInstancesForEntity
This method returns all existing instances of a certain type in the profile. Even when there are no instances available for a certain type an empty array will be returned.- Parameters:
entityName
- The entity type for which the instances are requested.includeChildren
- when this option is passed as true, all child entity-types are also returned.- Returns:
- An array of instances for the specified type (never null).
- Throws:
UnknownEntityException
- When the specified entity name is invalid/unknown.
-
createInstance
This method creates a new empty instance for the specified entity type. The name and id of this new instance are generated by the profile itself.- Parameters:
entityName
- The name of the entity for which a new instance should be created.- Returns:
- A new instance for the specified type. Never null.
- Throws:
UnknownEntityException
- The passed entity name argument is invalid, the type is unknown.CreateInstanceException
- This type of exception is raised when the instance could not be created.
-
createInstance
This method creates a new empty instance for the specified entity type. This method may supply either a name or ID which will be used by the profile to determine these values. When ID and instanceName are supplied with null, the behavior of this function is exactly the same as createInstance( String entityName ).- Parameters:
entityName
- The name of the entity for which a new instance should be created.instanceId
- Unique ID of the new instance. When null is supplied, an ID will be generated by the profile.instanceName
- Unique name of the new instance. when null is supplied a name will be generated by the profile.- Returns:
- A new instance for the specified type. Never null.
- Throws:
UnknownEntityException
- The passed entity name argument is invalid, the type is unknown.CreateInstanceException
- This exception is raised when the instance could not be created.
-
deleteInstance
Deletes the given instance, rendering the parameter useless. Please ensure no calls to the parameter IEntityInstance will be done after the deleteInstance.- Parameters:
instance
- IEntityInstance the instance to delete.autoDetach
- Boolean indicating if references to this instance should automatically be updated.- Throws:
UnknownInstanceException
- When entity or instance does not exist.RemoveInstanceException
- When the instance could not be removed (for instance when it is still referred to by others).
-
getEntityDefinition
This method returns an entity definition for the supplied entity name.- Parameters:
entityName
- The name of the entity for which the definition is requested.- Returns:
- IEntityDefinition object containing the static entity information.
- Throws:
UnknownEntityException
- This exception is raised when the specified entity name is not known by the profile.
-
startTransaction
Starts a new transaction in the profile.- Parameters:
name
- Unique name identifying the transaction.
-
commitTransaction
Commits the current transaction in the profile.- Parameters:
name
- Unique name identifying the transaction.- Throws:
AppException
- when no transaction has been started.
-
rollbackTransaction
Performs a roll-back of all changes since the last start of a transaction.- Parameters:
name
- Unique name identifying the transaction.- Throws:
AppException
- when no transaction has been started.
-
getState
IProfileState getState()Returns the state of the profile (for serialization)- Returns:
- returns the current state of the profile.
-
restore
Clears the current state and overrides it with the provided state.- Parameters:
state
- The new state for this profile.
-