2021-02-16 - Translations - Functions
Revision as of 03:04, 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 NPM module - izara-graph-service#vertexLib.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 NPM module - izara-graph-service#vertexLib.createVertex
- vertexId: vertexId
- vertexLabel: 'vertexLabel'
- 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 (does not create subject with label/properties).
- create ids for translation vertex:
- const objectId = NPM module - izara-shared#neptuneGraphSharedLib.createVertexId('translation', {random uuid})
- const objectLabel = translationLabel + Translation
- create translation vertex by invoking async 2021-02-16 - Translations - Functions#CreateTranslationVertex
- vertexId: objectId
- vertexLabel: 'translation'
- translation: translation
- create id for PossiblyTranslatesTo edge:
- const possiblyTranslatesToEdgeId = subjectId + '_Possible' + translationLabel + '_' + languageCode + '_' + objectId
- create PossiblyTranslatesTo graph statement by invoking NPM module - izara-graph-service#edgeLib.createRelationshipStatement
- 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 NPM module - izara-graph-service#edgeLib.createRelationshipStatement
- 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 NPM module - izara-graph-service#edgeLib.createRelationshipStatement
- subjectId: subjectId
- edgeLabel: 'DefaultTranslatesTo'
- edgeId: defaultTranslatesToEdgeId
- objectId: objectId
- create ids for user vertex:
- const userVertexId = NPM module - izara-shared#neptuneGraphSharedLib.createVertexId('user', {userId})
- create id for translation CreatedBy edge:
- const createdByEdgeId = objectId + '_CreatedBy_' + userVertexId
- create CreatedBy graph statement by invoking async NPM module - izara-graph-service#edgeLib.createRelationshipStatement
- subjectId: objectId
- edgeLabel: 'CreatedBy'
- edgeId: createdByEdgeId
- objectId: userVertexId