2021-02-16 - Translations - Functions

From Izara Wiki
Revision as of 06:10, 21 February 2021 by Sven the Barbarian (talk | contribs)
Jump to navigation Jump to search

Service - Translations

Lambda Functions

CreateTranslationSubject

/**
 * Create a new vertex for the subject of translations
 * @param {string} vertexId
 * @param {string} vertexLabel
 * @param {object} [vertexProperties]
 *
 * @returns {string} vertexId
 */

HdrInv

Validator: (standard)

handler logic

(standard)

logic

Main job is to create statements in graph database. Expects subject vertex to already exist (does not create subject with label/properties).

  1. create vertex by invoking NPM module - izara-shared#neptuneGraphSharedLib.createVertex
    1. vertexId: vertexId
    2. vertexLabel: 'vertexLabel'
    3. vertexProperties: 'vertexProperties'

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 graph database. Expects subject vertex to already exist (does not create subject with label/properties).

  1. create ids for translation vertex:
    1. const objectId = NPM module - izara-shared#neptuneGraphSharedLib.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 NPM module - izara-shared#neptuneGraphSharedLib.createRelationshipStatement
    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 NPM module - izara-shared#neptuneGraphSharedLib.createRelationshipStatement
    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 NPM module - izara-shared#neptuneGraphSharedLib.createRelationshipStatement
    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#neptuneGraphSharedLib.createVertexId('user_', {userId})
  9. create id for translation CreatedBy edge:
    1. const createdByEdgeId = objectId + '_CreatedBy_' + userVertexId
  10. create CreatedBy graph statement by invoking async NPM module - izara-shared#neptuneGraphSharedLib.createRelationshipStatement
    1. subjectId: objectId
    2. edgeLabel: 'CreatedBy'
    3. edgeId: createdByEdgeId
    4. objectId: userVertexId