Adding a Hierarchy
This page provides a description of how we 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 please see this documentation. 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 we need to make two modifications to the OlapModelConfig class inside
/cvarc-starter/src/main/java/com/activeviam/cvarc/starter/cfg/impl/OlapModelConfig.java
.
Step 1 - Modifying Manager Description
In the managerDescription()
method we want to append the managerDesc by adding the following lines above the return statement for the method.
Prerequisite information: To learn more about navigating the managerDesc please CLICK HERE.
AxisDimensionDescription testDimension = new AxisDimensionDescription("TestField");
IAxisHierarchyDescription testHierarchy = new AxisHierarchyDescription("TestField");
IAxisLevelDescription testLevel = new AxisLevelDescription("TestField");
List<IAxisHierarchyDescription> testHierarchiesList = new ArrayList();
List<IAxisLevelDescription> testLevelsList = new ArrayList();
testHierarchy.setAllMembersEnabled(true);
testDimension.setDimensionType(REGULAR);
testHierarchiesList.add(testHierarchy);
testLevelsList.add(testLevel);
testDimension.setHierarchies(testHierarchiesList);
testHierarchy.setLevels(testLevelsList);
managerDesc.getSchemas().get(1).getActivePivotSchemaDescription().getActivePivotInstanceDescriptions().
get(0).getActivePivotDescription().getAxisDimensions().getValues().add(testDimension);
return managerDesc;
}
}
Step 2 - Modifying Schema
Modify our Cube’s schema so that the Field can be found and set to be a hierarchy, in this case our modifications will be made in the createSASchemaSelectionDescription()
method.
.withField(RiskMeasureEnum.Vega.displayName()+" " + SAStoreNames.SA_EXPLICIT_BUCKET, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SAStoreNames.SA_EXPLICIT_BUCKET)
.withField(RiskMeasureEnum.Vega.displayName()+" " + SAStoreNames.SA_BUCKET_SUFFIX, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SAStoreNames.SA_BUCKET_SUFFIX)
.withField(RiskMeasureEnum.Vega.displayName()+" " +SharedDataStoreNames.INSTRUMENT_CURVE_TYPE, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SharedDataStoreNames.VEGA_TO_INSTRUMENT_REF+"/"+SharedDataStoreNames.INSTRUMENT_CURVE_TYPE)
.withField(RiskMeasureEnum.Vega.displayName()+" " +SharedDataStoreNames.INSTRUMENT_COMMODITY_GROUP, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SharedDataStoreNames.VEGA_TO_INSTRUMENT_REF+"/"+SharedDataStoreNames.INSTRUMENT_COMMODITY_GROUP)
.withField(RiskMeasureEnum.Vega.displayName()+" " +SharedDataStoreNames.INSTRUMENT_SECTOR, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SharedDataStoreNames.VEGA_TO_INSTRUMENT_REF+"/"+SharedDataStoreNames.INSTRUMENT_SECTOR)
.withField(RiskMeasureEnum.Vega.displayName()+" " +SharedDataStoreNames.INSTRUMENT_SIZE, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SharedDataStoreNames.VEGA_TO_INSTRUMENT_REF+"/"+SharedDataStoreNames.INSTRUMENT_SIZE)
.withField(RiskMeasureEnum.Vega.displayName()+" " +SharedDataStoreNames.INSTRUMENT_ECONOMY, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SharedDataStoreNames.VEGA_TO_INSTRUMENT_REF+"/"+SharedDataStoreNames.INSTRUMENT_ECONOMY)
.withField(RiskMeasureEnum.Vega.displayName()+" " +SharedDataStoreNames.INSTRUMENT_CREDIT_QUALITY, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SharedDataStoreNames.VEGA_TO_INSTRUMENT_REF+"/"+SharedDataStoreNames.INSTRUMENT_CREDIT_QUALITY)
.withField(RiskMeasureEnum.Vega.displayName()+" " +SharedDataStoreNames.INSTRUMENT_RISK_FACTORY_CCY, SAStoreNames.SA_BASE_TO_VEGA_REF+"/"+SharedDataStoreNames.VEGA_TO_INSTRUMENT_REF+"/"+SharedDataStoreNames.INSTRUMENT_RISK_FACTORY_CCY)
.withField(SharedDataStoreNames.TRADE_DESCRIPTION_IS_BA_ELIGIBLE, SAStoreNames.SA_BASE_TO_TRADE_DESCRIPTION_REF+"/"+SharedDataStoreNames.TRADE_DESCRIPTION_IS_BA_ELIGIBLE)
.withField(SharedDataStoreNames.TRADE_DESCRIPTION_IS_SA_ELIGIBLE, SAStoreNames.SA_BASE_TO_TRADE_DESCRIPTION_REF+"/"+SharedDataStoreNames.TRADE_DESCRIPTION_IS_SA_ELIGIBLE)
.withField(BAStoreNames.NETTING_SET_CAPITAL_TREATMENT, SharedDataStoreNames.CAPITAL_TREATMENT_TO_SA_BASE_STORE_REF+"/"+BAStoreNames.NETTING_SET_CAPITAL_TREATMENT)
.withField(SharedDataStoreNames.IS_CARVED_OUT,SharedDataStoreNames.CAPITAL_TREATMENT_TO_SA_BASE_STORE_REF+"/"+SharedDataStoreNames.IS_CARVED_OUT)
.withField(SAStoreNames.SA_DOMAIN)
.withField("TestField", SAStoreNames.SA_BASE_TO_VEGA_REF+"/TestField") // here we describe the path from the base store to the field we wish to expose as a hierarchy
.build();
}