Adding a Hierarchy

This page provides a description of how you can expose a field as a hierarchy. It features an example in which we expose a previously added field ‘TestField’ as a hierarchy. For a full walk-through on how this was done, see Adding a Field. 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 Reference Implementation.

To expose a field as a hierarchy, make the following modifications to the correct Cube Config class.

  • For the BA Cube, modify cvarc-ba-activepivot/src/main/java/com/activeviam/cvarc/ba/ref/cfg/impl/BACubeDimensionConfig.java.
  • For the SA Cube, modify cvarc-sa-activepivot/src/main/java/com/activeviam/cvarc/sa/ref/cfg/impl/SACubeDimensionsConfig.java.

Step 1 - Modifying Cube Dimension Config

In the ICanBuildCubeDescription<IActivePivotInstanceDescription> dimensions(ICanStartBuildingDimensions builder) method, append the new Hierarchy by adding the following lines just after line 127.

note

Prerequisite information
To learn more about navigating the managerDesc, see Navigating managerDesc .

        .withDimension("TestField")
        .withSingleLevelHierarchy("TestField")

Step 2 - Modifying Schema

Modify the Cube’s schema so that the Field can be found and set to be a hierarchy. In this case, the modifications is made in the createBASelection() method or createSASchemaSelectionDescription() method for the BA or SA cube, respectively. The snippet is from the BA Cube’s Selection config.

note

Make sure that any new field added to the selection does not exist in the selection already, and that it points to a corresponding field in a datastore.

ISelectionDescriptionBuilder.HasAllFields hasSomeFields = StartBuilding.selection(dsSchemaDesc.asDatabaseSchema())
        .fromBaseStore(BAStoreNames.BA_BASE_STORE_NAME)
        .withAllFields()
        
        // BA_BASE_TO_TRADE_DESCRIPTION_REF
        .usingReference(BAStoreNames.BA_BASE_TO_TRADE_DESCRIPTION_REF)
        .withAllFields()
        .except(BAStoreNames.TRADE_DESCRIPTION_AS_OF_DATE,
        BAStoreNames.TRADE_DESCRIPTION_TRADE_ID,
        BAStoreNames.TRADE_DESCRIPTION_REFERENCE_NAME)

        ...
        
        // Adding the TestField to selection
        .usingReference("BaseStore to TestFieldStore") // Reference from the Base Store to our new field's store
        .withAllFields()
        .except("AsOfDate", "TradeId"); // Exclude fields that are found in other stores. The application will not start if the selection has duplicate fields unintentionally.
        ;