2021-02-16 - Translations - Functions

From Izara Wiki
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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Service - Translations

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.

  1. create ids for translation vertex:
    1. const objectId = NPM module - izara-shared#projectGraphSharedLib.createVertexId('translation_', {random uuid})
    2. const objectLabel = translationLabel + Translation
  2. create id for PossiblyTranslatesTo edge:
    1. const possiblyTranslatesToEdgeId = subjectId + '_Possible' + translationLabel + '_' + languageCode + '_' + objectId
  3. create PossiblyTranslatesTo graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
    1. subjectId: subjectId
    2. edgeLabel: 'PossiblyTranslatesTo'
    3. edgeId: possiblyTranslatesToEdgeId
    4. objectId: objectId
    5. objectLabel: 'PossiblyTranslatesTo'
    6. objectProperties:
      1. languageCode: languageCode
  4. create id for TranslatesTo edge:
    1. const translatesToEdgeId = subjectId + '_' + translationLabel + '_' + languageCode + '_' + objectId
  5. create TranslatesTo graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
    1. subjectId: subjectId
    2. edgeLabel: 'TranslatesTo'
    3. edgeId: translatesToEdgeId
    4. objectId: objectId
  6. create id for DefaultTranslatesTo edge:
    1. const defaultTranslatesToEdgeId = subjectId + '_Default' + translationLabel + '_' + objectId
  7. create DefaultTranslatesTo graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
    1. subjectId: subjectId
    2. edgeLabel: 'DefaultTranslatesTo'
    3. edgeId: defaultTranslatesToEdgeId
    4. objectId: objectId
  8. create ids for user vertex:
    1. const userVertexId = NPM module - izara-shared#projectGraphSharedLib.createVertexId('user_', {userId})
  9. create id for translation CreatedBy edge:
    1. const createdByEdgeId = objectId + '_CreatedBy_' + userVertexId
  10. create CreatedBy graph statement by invoking async 2021-02-16 - Project Graph - Functions#CreateStatement
    1. subjectId: objectId
    2. edgeLabel: 'CreatedBy'
    3. edgeId: createdByEdgeId
    4. objectId: userVertexId