2021-02-16 - Translations - Functions
Revision as of 04:05, 1 March 2021 by Sven the Barbarian (talk | contribs)
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
- create vertex by invoking 2021-02-16 - Graph Handler - Functions#CreateVertex
- vertexId: vertexId
- vertexLabel: vertexLabel
- 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).
- create vertex by invoking 2021-02-16 - Graph Handler - Functions#CreateVertex
- vertexId: vertexId
- vertexLabel: vertexLabel
- vertexProperties: {translation: translation}
CreateTranslation
/**
* Create a new translation for a source object
* @param {string} subjectVertexId
* @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).
- const translationVertexId = NPM module - izara-shared#neptuneGraphSharedLib.createVertexId
- vertexTag: 'translation'
- uniqueId: {random uuid}
- create translation vertex by invoking async 2021-02-16 - Translations - Functions#CreateTranslationVertex
- vertexId: translationVertexId
- vertexLabel: translationLabel + 'Translation'
- translation: translation
- create edgeId for possiblyTranslatesTo edge:
- const possiblyTranslatesToEdgeId = subjectVertexId + '_Possible_' + translationLabel + '_' + languageCode + '_' + translationVertexId
- create possiblyTranslatesTo graph statement by invoking 2021-02-16 - Graph Handler - Functions#CreateStatement
- subjectId: subjectVertexId
- edgeLabel: 'possiblyTranslatesTo'
- edgeId: possiblyTranslatesToEdgeId
- objectId: translationVertexId
- edgeProperties:
- languageCode: languageCode
- create edgeId for translatesTo edge:
- const translatesToEdgeId = subjectVertexId + '_' + translationLabel + '_' + languageCode + '_' + translationVertexId
- create translatesTo graph statement by invoking async 2021-02-16 - Graph Handler - Functions#CreateStatement
- subjectId: subjectVertexId
- edgeLabel: 'translatesTo'
- edgeId: translatesToEdgeId
- objectId: translationVertexId
- edgeProperties:
- languageCode: languageCode
- create edgeId for defaultTranslatesTo edge:
- const defaultTranslatesToEdgeId = subjectVertexId + '_Default_' + translationLabel + '_' + translationVertexId
- create defaultTranslatesTo graph statement by invoking async 2021-02-16 - Graph Handler - Functions#CreateStatement
- subjectId: subjectVertexId
- edgeLabel: 'defaultTranslatesTo'
- edgeId: defaultTranslatesToEdgeId
- objectId: translationVertexId
- const userVertexId = NPM module - izara-shared#neptuneGraphSharedLib.createVertexId
- vertexTag: 'user'
- uniqueId: userId
- create edgeId for translation createdBy edge:
- const createdByEdgeId = translationVertexId + '_CreatedBy_' + userVertexId
- create createdBy graph statement by invoking async 2021-02-16 - Graph Handler - Functions#CreateStatement
- subjectId: translationVertexId
- edgeLabel: 'createdBy'
- edgeId: createdByEdgeId
- objectId: userVertexId
- edgeProperties:
- timestamp: {current timestamp}