INameMapper is used to convert Datastore Fields and Store names into a format that works with remote databases.
Reference DirectQueryNameMapper
The referenceDirectQueryNameMapper class is responsible for converting names from one format into another. We use this to convert Datastore Fields or Store
names into a name that is more compatible with remote databases. Since some databases have strict naming conventions, we have designed our
DirectQueryNameMapper to handle most database naming conventions.
The reference DirectQueryNameMapper works by taking a datastore name and converting it into one with the following logic:
- Entire name is converted to upper case.
- Spaces are replaced with underscores ‘_’.
- Camel case is split on the hump with underscores.
DirectQueryNameMapper:
| Input (local datastore) Name | Output (remote database) Name | Note |
|---|---|---|
| myvar | MYVAR | Set to uppercase |
| myVar | MY_VAR | camel case |
| MYVar | MYVAR | No change (because not camel case) |
| MYVAR | MYVAR | No change |
| MY_VAR | MY_VAR | No change |
| my var | MY_VAR | Space replaced with underscore |
Custom Naming Conventions
To use custom naming conventions:- Create a custom implementation of the
INameMapperinterface. - Mark it as a Spring component using the
@Primaryannotation, so that your implementation takes precedence over the referenceDirectQueryNameMapper. - Import your custom naming convention Spring component into your main application configuration file.
Custom Naming Convention Example
Here we create a custom naming convention that converts a given name into uppercase and replaces spaces with underscores ‘_’. First, we create a function that will convert one way from the local name to the remote name:CustomNameMapper is created.
We will use the IDatastoreSchemaDescription to help us with our pre-caching.