2021-02-16 - Translations - Functions
Revision as of 14:54, 16 February 2021 by Sven the Barbarian (talk | contribs) (Created page with "Service - Translations = Lambda Functions = == CreateTranslation == <syntaxhighlight lang="JavaScript"> /** * Create a new translation for a source object * @param {s...")
Lambda Functions
CreateTranslation
/**
* Create a new translation for a source object
* @param {string} subjectId
* @param {string} translationLabel
* @param {string} languageCode
* @param {string} userId
*
* @returns {Object[]} ?translation vertex id?
*/
HdrInv
Validator: (standard)
handler logic
(standard)
logic
Main job is to create statements in Project Graph.
- create ids for translation vertex:
- const objectId = NPM module - izara-shared#projectGraphSharedLib.createVertexId('translation_', {random uuid})
- const objectLabel = translationLabel + Translation
- create id for PossiblyTranslatesTo edge:
- const possiblyTranslatesToEdgeId = subjectId + '_Possible' + translationLabel + '_' + languageCode + '_' + objectId
- create PossiblyTranslatesTo graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
- subjectId: subjectId
- edgeLabel: 'PossiblyTranslatesTo'
- edgeId: possiblyTranslatesToEdgeId
- objectId: objectId
- objectLabel: 'PossiblyTranslatesTo'
- objectProperties:
- languageCode: languageCode
- create id for TranslatesTo edge:
- const translatesToEdgeId = subjectId + '_' + translationLabel + '_' + languageCode + '_' + objectId
- create TranslatesTo graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
- subjectId: subjectId
- edgeLabel: 'TranslatesTo'
- edgeId: translatesToEdgeId
- objectId: objectId
- create id for DefaultTranslatesTo edge:
- const defaultTranslatesToEdgeId = subjectId + '_Default' + translationLabel + '_' + objectId
- create DefaultTranslatesTo graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
- subjectId: subjectId
- edgeLabel: 'DefaultTranslatesTo'
- edgeId: defaultTranslatesToEdgeId
- objectId: objectId
- create ids for user vertex:
- const userVertexId = NPM module - izara-shared#projectGraphSharedLib.createVertexId('user_', {userId})
- create id for translation CreatedBy edge:
- const createdByEdgeId = objectId + '_CreatedBy_' + userVertexId
- create CreatedBy graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
- subjectId: objectId
- edgeLabel: 'CreatedBy'
- edgeId: createdByEdgeId
- objectId: userVertexId