Package com.aquima.interactions.rule.tms
Class TmsProfile
java.lang.Object
com.aquima.interactions.profile.wrapper.ProfileDelegate
com.aquima.interactions.rule.tms.TmsProfile
- All Implemented Interfaces:
IEventChannel
,IProfile
,IProfileLifecycle
,InferenceContext
,Serializable
This profile wrapper adds truth maintenance to the wrapped profile.
- Since:
- 5.0
- Author:
- O. Kerpershoek
- See Also:
-
Constructor Summary
ConstructorDescriptionTmsProfile
(IProfile profile, IRuleEngine inferenceEngine) Constructs a truth maintenance wrapper using a profile and rule engine.TmsProfile
(IProfile profile, IRuleEngine inferenceEngine, boolean haltOnConflictingRules) Constructs a truth maintenance wrapper using a profile and rule engine. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(IProfileActivationContext profileActivationContext) This method may be used for activating the profile after deserialization.boolean
addEventListener
(IEventListener listener) This method will add the passed event listener to the list of listeners.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.getActiveInstance
(String entityName) This method returns the active instance for the specified type.getAllInstancesForEntity
(String entityName, boolean includeChildren) This method returns all existing instances of a certain type in the profile.protected IEntityInstance[]
getAllInternalInstancesForEntity
(String entityName, boolean includeChildren) protected boolean
getInferenceDetails
(ValueReference attributeReference) This method may be used to request detailed inference information for a specific attribute.protected IRuleEngine
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.protected TmsEntityInstance
getTmsInstance
(EntityValue instanceReference) protected TmsStateManager
protected void
popSourceTarget
(ValueReference sourceTarget) Pops the attribute to source from the source stack.protected void
pushSourceTarget
(ValueReference sourceTarget) Pushes the attribute to source to the source stack.boolean
removeEventListener
(IEventListener listener) This method will remove the specified event listener from the list of listeners.protected TmsEntityInstance
wrapInstance
(IEntityInstance instance) Methods inherited from class com.aquima.interactions.profile.wrapper.ProfileDelegate
commitTransaction, deleteInstance, getEntityDefinition, getProfile, getState, getSupportedEvents, passivate, restore, rollbackTransaction, startTransaction
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aquima.interactions.foundation.events.IEventChannel
getSupportedEvents
Methods inherited from interface com.aquima.interactions.profile.IProfile
commitTransaction, deleteInstance, getEntityDefinition, getState, restore, rollbackTransaction, startTransaction
Methods inherited from interface com.aquima.interactions.profile.IProfileLifecycle
passivate
-
Constructor Details
-
TmsProfile
Constructs a truth maintenance wrapper using a profile and rule engine. This constructor will halt on conflicting results by default.- Parameters:
profile
- The profile to which truth maintenance should be added.inferenceEngine
- The rule engine that should be used to inference unknown values.
-
TmsProfile
Constructs a truth maintenance wrapper using a profile and rule engine.- Parameters:
profile
- The profile to which truth maintenance should be added.inferenceEngine
- The rule engine that should be used to inference unknown values.haltOnConflictingRules
- Boolean indicating if conflicting results are allowed for attributes.
-
-
Method Details
-
createInstance
Description copied from interface:IProfile
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.- Specified by:
createInstance
in interfaceIProfile
- Overrides:
createInstance
in classProfileDelegate
- 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.
-
createInstance
Description copied from interface:IProfile
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 ).- Specified by:
createInstance
in interfaceIProfile
- Overrides:
createInstance
in classProfileDelegate
- 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.
-
getAllInternalInstancesForEntity
protected IEntityInstance[] getAllInternalInstancesForEntity(String entityName, boolean includeChildren) -
getAllInstancesForEntity
Description copied from interface:IProfile
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.- Specified by:
getAllInstancesForEntity
in interfaceIProfile
- Overrides:
getAllInstancesForEntity
in classProfileDelegate
- 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).
-
getInstance
Description copied from interface:IProfile
This method can be used to lookup an instance based on a reference.- Specified by:
getInstance
in interfaceIProfile
- Overrides:
getInstance
in classProfileDelegate
- Parameters:
instance
- InstanceReference of the instance that should be returned.- Returns:
- IEntityInstance The entity instance for the specified ID.
-
getInstanceByName
Description copied from interface:IProfile
This method returns an instance of the specified type for the given instance name.- Specified by:
getInstanceByName
in interfaceIProfile
- Overrides:
getInstanceByName
in classProfileDelegate
- 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.
-
getInstanceById
Description copied from interface:IProfile
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.- Specified by:
getInstanceById
in interfaceIProfile
- Overrides:
getInstanceById
in classProfileDelegate
- 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.
-
getSingletonInstance
Description copied from interface:IProfile
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.
- Specified by:
getSingletonInstance
in interfaceIProfile
- Overrides:
getSingletonInstance
in classProfileDelegate
- 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.
-
getActiveInstance
Description copied from interface:InferenceContext
This method returns the active instance for the specified type. When no active instance can be found for the specified type, the type is assumed to be a singleton instance. When this method is invoked for a non singleton type without any active instance, the call to the getSingletonInstance will fail due to a CreateInstanceException.- Specified by:
getActiveInstance
in interfaceInferenceContext
- Parameters:
entityName
- The entity type for which the active instance is requested.- Returns:
- The instance that is active for the specified type.
-
getHaltOnConflictingRules
protected boolean getHaltOnConflictingRules() -
getInferenceEngine
-
getTmsStateManager
-
getTmsInstance
-
wrapInstance
-
getInferenceDetails
Description copied from interface:InferenceContext
This method may be used to request detailed inference information for a specific attribute. The details object contains information like which rule inferenced the value, and what other values were used by the rule engine to determine the current result.- Specified by:
getInferenceDetails
in interfaceInferenceContext
- Parameters:
attributeReference
- The reference to the attribute whose inference information is requested.- Returns:
- Object containing detailed information about the value related to the inference process.
-
pushSourceTarget
Pushes the attribute to source to the source stack.- Parameters:
sourceTarget
- The attribute to source- Throws:
RuleEngineException
- on circular reasoning
-
popSourceTarget
Pops the attribute to source from the source stack.- Parameters:
sourceTarget
- The attribute that was sourced
-
addEventListener
Description copied from interface:IEventChannel
This method will add the passed event listener to the list of listeners.- Specified by:
addEventListener
in interfaceIEventChannel
- Overrides:
addEventListener
in classProfileDelegate
- Parameters:
listener
- The event listener that should be added.- Returns:
- boolean indicating is the listener was actually added.
-
removeEventListener
Description copied from interface:IEventChannel
This method will remove the specified event listener from the list of listeners.- Specified by:
removeEventListener
in interfaceIEventChannel
- Overrides:
removeEventListener
in classProfileDelegate
- Parameters:
listener
- The event listener that should be removed.- Returns:
- boolean indicating if the listener was actually removed.
-
activate
Description copied from interface:IProfileLifecycle
This method may be used for activating the profile after deserialization.- Specified by:
activate
in interfaceIProfileLifecycle
- Overrides:
activate
in classProfileDelegate
- Parameters:
profileActivationContext
- the current profile activation context.
-