java.lang.Object
com.aquima.interactions.matching.impl.model.CaseBase
All Implemented Interfaces:
ICaseBase, IMutableCaseBase

public class CaseBase extends Object implements ICaseBase, IMutableCaseBase
This class contains all the cases of a specific entity type.

Cases of super or sub-types of the entity this casebase was created for will be located in their own casebase. The casebase will thus only contain cases that are exactly of the specified type.

The match definitions are sorted on threshold, master-slave relations and weight, see MatchDefinitionComparator. If this casebase has a supertype, then cases of this casebase can also be used in a match on the supertype. The list of match definitions of this casebase must start with the match definitions of the supertype, and the match definitions must be in the same order as in the supertype. Therefore, the match definitions must be sorted per casebase.

Example:
Person has attributes A, B, C where B has a threshold of 15.
Customer has one attribute D with a threshold of 25.
The sorted list of match definitions becomes B,A,C,D, even though D has the highest threshold.

Since:
6.2
Author:
O. Kerpershoek, F. van der Meer
  • Constructor Details

  • Method Details

    • initializeMatchDefinitions

      protected void initializeMatchDefinitions(MatchEngine matchEngine, ICaseBaseDS datasource)
    • onStartup

      protected void onStartup()
    • onLoadComplete

      protected void onLoadComplete()
    • addMatchDefinition

      protected void addMatchDefinition(MatchDefinition definition)
    • initializeCases

      protected void initializeCases(CaseBaseList casebases, ICaseBaseDS datasource)
    • initializeCaseValues

      protected void initializeCaseValues(CaseBaseList casebases, ICaseBaseDS datasource)
    • iterateInserts

      protected void iterateInserts(ICaseBaseDS datasource)
    • iterateDeletes

      protected void iterateDeletes()
    • iterateUpdates

      protected void iterateUpdates(ICaseBaseDS datasource)
    • getEntityDefinition

      protected IEntityDefinition getEntityDefinition()
    • getEntityName

      public String getEntityName()
      Description copied from interface: ICaseBase
      This method returns the entity name for which the cases in this casebase are defined.
      Specified by:
      getEntityName in interface ICaseBase
      Returns:
      the entity name for which the cases in this casebase are defined.
    • getSuperType

      public ICaseBase getSuperType()
      Description copied from interface: ICaseBase
      This method returns the casebase for the super type of the entity this casebase is defined for. When the entity of this casebase does not have a super type defined, this method will return null.
      Specified by:
      getSuperType in interface ICaseBase
      Returns:
      The casebase for the super type of the entity, or null when the entity does not have a super type.
    • getSubTypes

      public ICaseBase[] getSubTypes()
      Description copied from interface: ICaseBase
      This method returns an array of casebases containing the casebases of the sub types of the entity this casebase is defined for. When the entity does not have any sub types, this method will return an empty array.
      Specified by:
      getSubTypes in interface ICaseBase
      Returns:
      An array containing the casebases for the sub types of the entity this casebase is defined for.
    • containsCase

      protected boolean containsCase(String caseName)
    • addCase

      protected void addCase(Case matchableCase)
    • insertCase

      public void insertCase(String caseName)
      Description copied from interface: IMutableCaseBase
      Registers a new case for this casebase.
      Specified by:
      insertCase in interface IMutableCaseBase
      Parameters:
      caseName - The case name.
    • updateCase

      public void updateCase(String caseName)
      Description copied from interface: IMutableCaseBase
      Registers that the values of an existing case in this casebase must be updated.
      Specified by:
      updateCase in interface IMutableCaseBase
      Parameters:
      caseName - The case name.
    • deleteCase

      public void deleteCase(String caseName)
      Description copied from interface: IMutableCaseBase
      Registers that an existing case in this casebase must be deleted.
      Specified by:
      deleteCase in interface IMutableCaseBase
      Parameters:
      caseName - The case name.
    • isChanged

      public boolean isChanged()
      Description copied from interface: IMutableCaseBase
      Indicates if any changes are registered for this casebase.
      Specified by:
      isChanged in interface IMutableCaseBase
      Returns:
      true if changes to the case data are registered but not yet applied.
    • getCases

      public ICase[] getCases(boolean includeSubTypes)
      Description copied from interface: ICaseBase
      This method returns all the cases of this casebase. The boolean argument 'includeSubTypes' may be used to request only the cases that are defined for the entity type of this casebase, or to retrieve all cases that match the current type.
      Specified by:
      getCases in interface ICaseBase
      Parameters:
      includeSubTypes - Boolean that may be used to request all the cases matching the entity type (true), or just the cases defined in this casebase (false).
      Returns:
      Array containing the cases defined for the entity type of this casebase.
    • getCases

      protected void getCases(List<ICase> result, boolean includeSubTypes)
    • getCase

      public ICase getCase(String caseName)
      Description copied from interface: ICaseBase
      This method locates the case with the given name within this casebase or it's parent case base.
      Specified by:
      getCase in interface ICaseBase
      Parameters:
      caseName - The case name, the lookup will be case insensitive.
      Returns:
      The matching case, never null.
    • findCase

      protected Case findCase(String caseName)
    • getMatchDefinitions

      public IMatchDefinition[] getMatchDefinitions()
      Description copied from interface: ICaseBase
      This returns all the match definitions that should be used to match the values of a case from this casebase. The array of the match definition matches the order of the array from ICase.getValues.

      Important note: This ordering of the output array is a design v.s. optimization issue which has favored to the optimization side. Since a casebase consisting of 1,000,000 cases matching over 20 attributes per case will result in 20 million hash map lookups. Since the order is known from the clients point of view one can access this array directly resulting in a much faster process.

      Specified by:
      getMatchDefinitions in interface ICaseBase
      Returns:
      The match definitions that should be used to match the values of a case from this casebase.
    • getMatchDefinitions

      protected void getMatchDefinitions(List<IMatchDefinition> matchDefinitions)
    • getDefaultCaseThreshold

      public int getDefaultCaseThreshold()
      Description copied from interface: ICaseBase
      This method returns the threshold that will be used for cases when the match request does not specify a threshold.
      Specified by:
      getDefaultCaseThreshold in interface ICaseBase
      Returns:
      the threshold that will be used for cases when the match request does not specify a threshold.
    • getDefaultMaxResults

      public int getDefaultMaxResults()
      Description copied from interface: ICaseBase
      This method returns the maximum number of result that will be returned by a match action when the match request does not specify a maximum.
      Specified by:
      getDefaultMaxResults in interface ICaseBase
      Returns:
      The maximum number of results from a match action.
    • getDefaultKeyField

      public String getDefaultKeyField()
      Description copied from interface: ICaseBase
      This method returns the name of the attribute whose values should be used to group the results on. The key field is optional, so this method may return null when no key field has been specified. Note: Only attributes that are matched may be used as key field.
      Specified by:
      getDefaultKeyField in interface ICaseBase
      Returns:
      the name of the attribute whose values should be used to group the results on.
    • getDefaultMaxKeyResults

      public int getDefaultMaxKeyResults()
      Description copied from interface: ICaseBase
      This method returns the maximum number of values that may be grouped on one unique key value.
      Specified by:
      getDefaultMaxKeyResults in interface ICaseBase
      Returns:
      the maximum number of values that may be grouped on one unique key value.