Basic usage

Accessing domain

Before proceeding please be familiar with Domain concepts.

Lets assume we have a sample domain configured (see Hyperon Studio sample domain):

We have a rating plan configured: FULL - Rating Plan for summer 2016. This plan has multiple coverages attached, e.g. BI, COLL, COMP. Each coverage has its attributes, e.g. POSITION, LIMIT1, LIMIT2, PREMIUM.

We will now evaluate a position of a coverage BI on the screen (attribute POSITION).

To get value from Hyperon engine simply inject Hyperon Engine (part of Hyperon Runtime Library) into your Spring Component/Service:

private HyperonEngine engine;

prepare a running context:

HyperonContext ctx = new HyperonContext(
    "coverage.code", "COLL"

and execute following code:

HyperonDomainObject domainObject = engine.getDomain(
        /** Profile code **/ "DEMO", 
        /** Domain element path **/ "/PLANS[FULL]/COVERAGES[BI]/");
ParamValue pv = domainObject.getAttribute(/** Attribute code **/ "POSITION").getValue(ctx);"my value: {}", pv);

the output will be:

1) Domain tree cache creation (done once):

( main)[MpDomainCacheProvider] - finishing createTreeFor(profile=DEMO,sessionId=-1) in time 33
( main)[MpParameterProvider] - enter load, uid=demo.motor.coverage.position
( main)[ParameterJdbcDao] - enter getParameter, param=demo.motor.coverage.position, ver=null, sid=0, mid=0
( main)[ParameterJdbcDao] - leave fetchMatrix, pid=904, mid=904, size=9
( main)[ParameterJdbcDao] - leave getParameter, time=10, p=MpParameter#904[demo.motor.coverage.position, last=2017-03-03 14:23:51.588, levels=1/1, notnull, entries=0]

2) Attribute execution:

( main)[SampleComponent] - my value:
ParamValue (1)
  1. [8]

As you can see on the screen above, attribute POSITION is configured to be evaluated by parameter ($p): demo.motor.coverage.position. So execution (2) is done by this parameter.

Now we would like to list all coverages attached to this plan. To do this simple execute following code:

domainObject = engine.getDomain(
        /** Profile code **/ "DEMO", 
        /** Domain element path **/ "/PLANS[FULL]/");

List<HyperonDomainObject> coverages = domainObject.getChildren(/** Collection code **/ "COVERAGES");

for(HyperonDomainObject coverageObject : coverages) {"Coverage code: {}", coverageObject.getCode());

the output goes as follows:

( main)[SampleComponent] - Coverage code: BI
( main)[SampleComponent] - Coverage code: COLL
( main)[SampleComponent] - Coverage code: COMP
( main)[SampleComponent] - Coverage code: ERS
( main)[SampleComponent] - Coverage code: MED
( main)[SampleComponent] - Coverage code: PD
( main)[SampleComponent] - Coverage code: PIP
( main)[SampleComponent] - Coverage code: UMBI
( main)[SampleComponent] - Coverage code: UMPD

Read Using the domain to see how to design and use domain in detail.