Seeding valuetranslations

Prev Next

Basics

The valuetranslation database is not multi-tenant, meaning it can contain contain configuration for just one tenant.

Clients

Start by creating the clients:

DECLARE @clientCrm UNIQUEIDENTIFIER
DECLARE @clientDocuments UNIQUEIDENTIFIER
DECLARE @clientMobileApp UNIQUEIDENTIFIER
EXEC CreateOrGetClient 'crm-lime', @clientCrm OUTPUT
EXEC CreateOrGetClient 'documents-sharepoint', @clientDocuments OUTPUT
EXEC CreateOrGetClient 'mobileapp-acme', @clientMobileApp OUTPUT

Possible naming conventions

  • [capability]-[system], e.g. "crm-lime"
  • [capability]-[supplier], e.g. "mobileapp-acme"
  • [capability], e.g. "crm"
  • [system], e.g. "lime"

Note!

To be able to translate values from Nexus Business Events, use the same client names as in the businessevents database.

Concepts and Contexts

Nexus Value Translator can translate id:s and enumerations. What these represent is called a Concept, which could be "person.id", "person.gender", "product.id", usually a property of an entity.

A client will have a context, a set of values, for a certain concept. A client either has it's own context or share a context with other clients. It's possible to create a "default" context in Nexus Value Translator, which can automatically translate values if they don't have values. This is especially useful for external clients such as webs and mobile apps.

Use stored procedures to handle the configuration for you:

DECLARE @conceptId UNIQUEIDENTIFIER
DECLARE @contextId UNIQUEIDENTIFIER

Enum concepts

When there is a predefined set of values, e.g. for "gender", use an enumeration:

EXEC CreateOrGetEnumConcept 'gender', @conceptId OUTPUT

-- Forms
DECLARE @formId1 UNIQUEIDENTIFIER
DECLARE @formId2 UNIQUEIDENTIFIER
EXEC CreateOrGetForm @conceptId, 'f', @formId1 OUTPUT
EXEC CreateOrGetForm @conceptId, 'm', @formId2 OUTPUT

-- se
EXEC CreateOrGetContext @conceptId, 'se', 0, @contextId OUTPUT
EXEC CreateOrUpdateClientContext @clientCrm, @conceptId, @contextId

DECLARE @instanceValueKvinna VARCHAR(300) = 'kvinna'
DECLARE @instanceValueMan VARCHAR(300) = 'man'
EXEC CreateOrUpdateInstance @contextId, @formId1, @instanceValueKvinna
EXEC CreateOrUpdateInstance @contextId, @formId2, @instanceValueMan

-- en
EXEC CreateOrGetContext @conceptId, 'en', 0, @contextId OUTPUT
EXEC CreateOrUpdateClientContext @clientMobileApp, @conceptId, @contextId

DECLARE @instanceValueWoman VARCHAR(300) = 'woman'
DECLARE @instanceValueMale VARCHAR(300) = 'male'
EXEC CreateOrUpdateInstance @contextId, @formId1,  @instanceValueWoman
EXEC CreateOrUpdateInstance @contextId, @formId2, @instanceValueMale
Attribute Description
'gender' The name of the concept to create
CreateOrGetEnumConcept Creates an enumeration concept if it is not present
@conceptId The id of the created Concept
CreateOrGetForm Forms represents enumerations of the concept. These have different values in different contexts.
@formId1 The id of the created form representing "Woman" of the concept "Gender".
CreateOrGetContext Creates a context for a concept if it is not present
@contextId The id of the created Context
CreateOrUpdateClientContext Associates a client with context
CreateOrUpdateInstance Creates an instance of a form, i.e. setting a value for the form in a context.
@instanceValueKvinna For clients using context "se", the "Woman" value will be "kvinna"

Id concepts

Id concepts are dynamic in that association and creation of new value instances occurs continously.

EXEC CreateOrGetIdConcept 'person.id', @conceptId OUTPUT

EXEC CreateOrGetContext @conceptId, 'lime', 1, @contextId OUTPUT
EXEC CreateOrUpdateClientContext @clientCrm, @conceptId, @contextId

EXEC CreateOrGetContext @conceptId, 'external', 1, @contextId OUTPUT
EXEC CreateOrUpdateClientContext @clientMobileApp, @conceptId, @contextId
Attribute Description
'person.id' The name of the concept to create
CreateOrGetIdConcept Creates an id concept if it is not present
@conceptId The id of the created Concept
CreateOrGetContext Creates a context for a concept if it is not present
@contextId The id of the created Context
CreateOrUpdateClientContext Associates a client with context

More details

There is a lot more to the Nexus Value Translator setup. Please contact XLENT Link for more information.

Automation

One way to use continous integration for the seeding is like in this guide: Continuous integration for database seeding