2021-02-16 - Translations - Functions

From Izara Wiki
Jump to navigation Jump to search

Service - Translations

Lambda Functions

CreateSubjectVertex

/**
 * 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

  1. create vertex by invoking 2021-02-16 - Graph Handler - Functions#CreateVertex
    1. vertexId: vertexId
    2. vertexLabel: vertexLabel
    3. vertexProperties: vertexProperties

CreateTranslationVertex

/**
 * Create a new vertex for a translation
 * @param {string} vertexId
 * @param {string} vertexLabel
 * @param {string} translation
 *
 * @returns {string} vertexId
 */

HdrInv

Validator: (standard)

handler logic

(standard)

logic

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

  1. create vertex by invoking 2021-02-16 - Graph Handler - Functions#CreateVertex
    1. vertexId: vertexId
    2. vertexLabel: vertexLabel
    3. vertexProperties: {translation: translation}

CreateTranslation

/**
 * Create a new translation for a source object
 * @param {string} subjectId
 * @param {string} translationLabel
 * @param {string} languageCode
 * @param {string} translation
 * @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 (will not create subject with label/properties).

  1. const translationObjectId = NPM module - izara-shared#neptuneGraphSharedLib.createVertexId
    1. vertexTag: 'translation'
    2. uniqueId: {random uuid}
  2. create translation vertex by invoking async 2021-02-16 - Translations - Functions#CreateTranslationVertex
    1. vertexId: translationObjectId
    2. vertexLabel: translationLabel + 'Translation'
    3. translation: translation
  3. create edgeId for possiblyTranslatesTo edge:
    1. const possiblyTranslatesToEdgeId = subjectId + '_Possible_' + translationLabel + '_' + languageCode + '_' + translationObjectId
  4. create possiblyTranslatesTo graph statement by invoking 2021-02-16 - Graph Handler - Functions#CreateStatement
    1. subjectId: subjectId
    2. edgeLabel: 'possiblyTranslatesTo'
    3. edgeId: possiblyTranslatesToEdgeId
    4. objectId: translationObjectId
    5. edgeProperties:
      1. languageCode: languageCode
  5. create edgeId for translatesTo edge:
    1. const translatesToEdgeId = subjectId + '_' + translationLabel + '_' + languageCode + '_' + translationObjectId
  6. create translatesTo graph statement by invoking async 2021-02-16 - Graph Handler - Functions#CreateStatement
    1. subjectId: subjectId
    2. edgeLabel: 'translatesTo'
    3. edgeId: translatesToEdgeId
    4. objectId: translationObjectId
    5. edgeProperties:
      1. languageCode: languageCode
  7. create edgeId for defaultTranslatesTo edge:
    1. const defaultTranslatesToEdgeId = subjectId + '_Default_' + translationLabel + '_' + translationObjectId
  8. create defaultTranslatesTo graph statement by invoking async 2021-02-16 - Graph Handler - Functions#CreateStatement
    1. subjectId: subjectId
    2. edgeLabel: 'defaultTranslatesTo'
    3. edgeId: defaultTranslatesToEdgeId
    4. objectId: translationObjectId
  9. const userVertexId = NPM module - izara-shared#neptuneGraphSharedLib.createVertexId
    1. vertexTag: 'user'
    2. uniqueId: userId
  10. create edgeId for translation createdBy edge:
    1. const createdByEdgeId = translationObjectId + '_CreatedBy_' + userVertexId
  11. create createdBy graph statement by invoking async 2021-02-16 - Graph Handler - Functions#CreateStatement
    1. subjectId: translationObjectId
    2. edgeLabel: 'createdBy'
    3. edgeId: createdByEdgeId
    4. objectId: userVertexId
    5. edgeProperties:
      1. timestamp: {current timestamp}