Adding New Cube Measures

This page provides a description of how we can add a measure. It features an example in which we use the ‘CustomProjected’ field from a store which we previously added. For a walk-through on how this store was added to the cube, see Adding New Data Loading or Unloading Topics. The techniques employed are generic examples that can be extended, adapted and repeated for any use case that we need. In all cases, we make minimal changes to the Accelerator Reference Implementation.

 

Step 1 - (Optional) Modify the selection description

If the field we want to turn into a measure is not currently in our schema selection, then the first step is to add it.

The cube selection is made by retrieving all fields from a datastore except unwanted ones, so adding an extra field to an existing store will add it to the selection. Only extra datastore fields will need a change on the selection.

Fields are added to the schema selection by creating a Spring Bean with type UnaryOperator<CanUseOtherReference> and qualifier SchemaSelection_CUBENAME_ (for example, SchemaSelectionStandardisedApproachCube).

For example:


    @Qualifier("SchemaSelectionStandardisedApproachCube")
    @Bean
    UnaryOperator<CanUseOtherReference> extraSchemaSelections() {
        return builder -> builder
            .usingReference(storesToPath(TRADE_BASE_STORE_NAME, "TESTSTORE"))
            .withAllFields()
            .except(AS_OF_DATE, RISK_CLASS);
    }

Step 2 - Define measure

 

In this case we will create a new bean to define our new measure with the qualifier @Qualifier("saMeasures")that extends IMeasureBuilder

@Component
@Qualifier("saMeasures")
public class ExtendedSAMeasureBuilder implements IMeasureBuilder {

    @Override
    public void measures(ICopperContext context) {
        Copper.sum("CustomProjected").publish(context);
    }

    @Override
    public String getCubeName() {
        return SAMeasureBuilder.CUBE;
    }
}

To read more about creating measures with Copper, see Creating and publishing measures.

Step 3 - Application config

Navigate to the application config FRTBConfig.java

/frtb-starter/src/main/java/com/activeviam/frtb/starter/cfg/impl/

Add SAMeasureBuilder to the import classes.

@Configuration
@Import(value = {
...
        ExtendedSAMeasureBuilder.class,
...
})

Suggested further reading

Adding New Cube Hierarchies, Adding New KPIs.

search.js