Class HigsonEngineImpl

java.lang.Object
io.higson.runtime.core.HigsonEngineImpl
All Implemented Interfaces:
HigsonEngine

public class HigsonEngineImpl extends Object implements HigsonEngine
Default engine implementation for accessing crucial aspects of the system.
Author:
przemek hertel
  • Constructor Details

    • HigsonEngineImpl

      public HigsonEngineImpl(ParamEngine engine, DomainCache domainCache, VersionInterceptor versionInterceptor, boolean valueNeverNull)
      Creates a HigsonEngineImpl instance with required arguments.
      Parameters:
      engine - engine for parameters and functions
      domainCache - domain cache
      versionInterceptor - version interceptor
      valueNeverNull - flag, if fetched value can't be null for parameters results
  • Method Details

    • get

      public ParamValue get(String parameterName, ParamContext ctx)
      Description copied from interface: HigsonEngine
      This method tries to fetch parameter's value for given parameterName and context ctx. If parameter requires context for proper working(context is defined parameter's metadata), then it must be provided, so values could be fetched for matched context.

      Example:

      
       HigsonEngine engine = .. // might be injected or created from HigsonEngineFactory
       ParamValue paramValue = engine.get("parameter.code", new HigsonContext());
       
      Specified by:
      get in interface HigsonEngine
      Parameters:
      parameterName - parameter name
      ctx - context that is required for proper parameter fetching
      Returns:
      parameter value if found, or might be null
      See Also:
    • get0

      @Deprecated public ParamValue get0(String uid, ParamContext ctx)
      Deprecated.
      should not be exposed. It will be hidden in the future.
      Parameters:
      uid - uid
      ctx - ctx
      Returns:
      PramValue object
    • call

      public Object call(String functionName, ParamContext ctx, Object... args)
      Description copied from interface: HigsonEngine
      This method calls function defined within higson, with context and optional arguments. Function might return value as Object.

      Example:

      
       HigsonEngine engine = .. // might be injected or created from HigsonEngineFactory
       Object result = engine.call("function.name", new HigsonContext(), 1, 2, 3);
       
      Specified by:
      call in interface HigsonEngine
      Parameters:
      functionName - function name
      ctx - context used by function
      args - optional argument, if function requires them
      Returns:
      possible result of function call
      See Also:
    • flow

      public FlowResult flow(String flowName, ParamContext ctx, Object... args)
      Description copied from interface: HigsonEngine
      This method calls flow defined within higson, with context and optional arguments. Flow might return value as FlowResult.

      Example:

      
       HigsonEngine engine = .. // might be injected or created from HigsonEngineFactory
       Object result = engine.flow("flow.name", new HigsonContext(), 1, 2, 3);
       
      Specified by:
      flow in interface HigsonEngine
      Parameters:
      flowName - flow name
      ctx - context used by function
      args - optional argument, if function requires them
      Returns:
      FlowResult containing map with flow output and trace
      See Also:
    • runtimeConfiguration

      public ParamEngineRuntimeConfig runtimeConfiguration()
      Description copied from interface: HigsonEngine
      Return runtime configuration of this instance of parameter/function engine.
      Specified by:
      runtimeConfiguration in interface HigsonEngine
      Returns:
      runtime config
    • setEffectiveVersion

      public void setEffectiveVersion(String region, String version)
      Description copied from interface: HigsonEngine
      Enables to change version for given region, so it will acts as effective version. System version based on schedule will not be altered. If given region is attached to more than one profile, AmbiguousProfileException is thrown. Use HigsonEngine.setEffectiveVersion(String, String, String) in such situation.
      Specified by:
      setEffectiveVersion in interface HigsonEngine
      Parameters:
      region - region code
      version - effective version
      See Also:
    • setEffectiveVersion

      public void setEffectiveVersion(String profileCode, String regionCode, String version)
      Description copied from interface: HigsonEngine
      Enables to change version for given region in given profile, so it will acts as effective version. System version based on schedule will not be altered.
      Specified by:
      setEffectiveVersion in interface HigsonEngine
      Parameters:
      profileCode - profile code
      regionCode - region code
      version - effective version
      See Also:
    • setEffectiveDate

      public void setEffectiveDate(Date date)
      Description copied from interface: HigsonEngine
      Enables to change effective date that will alter work of a schedule (if there is any). After proper schedule was fetched, then version of parameters and functions is changed according to new schedule(based on given date).
      Warning Current implementation doesn't affect fetching domain objects from engine. It might be changed in the future.
      Specified by:
      setEffectiveDate in interface HigsonEngine
      Parameters:
      date - effective date to be used for schedule
      See Also:
    • clearEffectiveVersion

      public void clearEffectiveVersion(String region)
      Description copied from interface: HigsonEngine
      Removes effective version for given region, if there was any. If given region is attached to more than one profile, AmbiguousProfileException is thrown. Use HigsonEngine.clearEffectiveVersion(String, String) in such situation.
      Specified by:
      clearEffectiveVersion in interface HigsonEngine
      Parameters:
      region - region code to reset
      See Also:
    • clearEffectiveVersion

      public void clearEffectiveVersion(String profileCode, String regionCode)
      Description copied from interface: HigsonEngine
      Removes effective version for given region, if there was any.
      Specified by:
      clearEffectiveVersion in interface HigsonEngine
      Parameters:
      profileCode - profile code
      regionCode - region code to reset
      See Also:
    • clearEffectiveVersions

      public void clearEffectiveVersions()
      Description copied from interface: HigsonEngine
      Removes all effective versions that were once set, even for multiple regions.
      Specified by:
      clearEffectiveVersions in interface HigsonEngine
      See Also:
    • clearEffectiveDate

      public void clearEffectiveDate()
      Description copied from interface: HigsonEngine
      Removes effective date, that was once set. If there was no date, nothing happens.
      Specified by:
      clearEffectiveDate in interface HigsonEngine
      See Also:
    • clearEffectiveSetup

      public void clearEffectiveSetup()
      Description copied from interface: HigsonEngine
      Removes both effective date and effective versions for all regions.
      Specified by:
      clearEffectiveSetup in interface HigsonEngine
      See Also:
    • getProfiles

      public List<String> getProfiles()
      Description copied from interface: HigsonEngine
      Returns codes of profiles with at least one domain element.
      Specified by:
      getProfiles in interface HigsonEngine
      Returns:
      List of profile codes for all profiles with at least one domain element, or empty list if there are no such profiles.
    • getExistingProfiles

      public Set<String> getExistingProfiles()
      Description copied from interface: HigsonEngine
      Returns codes of profiles with at least one domain element.
      Specified by:
      getExistingProfiles in interface HigsonEngine
      Returns:
      Set of profile codes for all profiles with at least one domain element, or empty list if there are no such profiles.
    • getDomain

      public DomainObject getDomain(String profile, String objectPath)
      Description copied from interface: HigsonEngine
      Get domain object based on given profile and objectPath. It will be either head object or from user's session.
      How objectPath is defined: "/PLANS[LIAB]/OPTIONS[OPT1]" - where
      • /PLANS[LIAB] - LIAB code element within PLANS collection
      • / - acts as separator between child and parent
      • /OPTIONS[OPT1] - OPT1 code element within OPTIONS collection, that is child of PLANS[LIAB]

      Example:

      
        HigsonEngine engine = .. // might be injected or created from HigsonEngineFactory
        HigsonDomainObject root = engine.getDomain("PROFILE1", "/");   // root domain object for PROFILE1
        HigsonDomainObject adminElement = engine.getDomain("PROFILE1", "/USERS[ADMIN]");   // domain object with code "ADMIN" within collection "USERS"
       
      Specified by:
      getDomain in interface HigsonEngine
      Parameters:
      profile - profile code
      objectPath - full path to domain object
      Returns:
      domain object if found, or null
      See Also:
    • getDigest

      public String getDigest(Type type, String elementCode)
      Description copied from interface: HigsonEngine
      Return digest of one of given Parameter/Funcion/Literal value
      Specified by:
      getDigest in interface HigsonEngine
      Parameters:
      type - of Higson element to calculate its digest
      elementCode - code of parameter/function or literal value
      Returns:
      digest as string of given element or null, if digest is not available.
    • isValueNeverNull

      @Deprecated public boolean isValueNeverNull()
      Deprecated.
      Shouldn't be exposed. Will be removed in the future.
      Returns:
      valueNeverNull
    • getDomainCache

      @Deprecated public DomainCache getDomainCache()
      Deprecated.
      Shouldn't expose cache. Will be removed in the future.
      Returns:
      DomainCache instance