Skip to content
Snippets Groups Projects
Commit 91c95186 authored by Helena Jank's avatar Helena Jank
Browse files

+ added module Translation (as part of discoverer)

parent 21f656e6
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ requirejs.config({
interpreterDescription: 'modules/descriptions/interpreterDescription',
widgetDescription: 'modules/descriptions/widgetDescription',
discoverer: 'modules/discoverer/discoverer',
translation: 'modules/discoverer/translation',
interpreter: 'modules/interpreter/interpreter',
interpreterResult: 'modules/interpreter/interpreterResult',
callback: 'modules/subscriber/callback',
......
......@@ -37,6 +37,15 @@ define([ 'easejs', 'attributeTypeList', 'widget', 'interpreter', 'aggregator' ],
*/
'private interpreter' : {},
/**
* @alias translations
* @private
* @type {Array}
* @memberof Discoverer#
* @desc List of available attributeType translations (or synonyms).
*/
'private translations' : {},
/**
* Constructor: All known components given in the associated functions will be registered as startup.
*
......@@ -46,7 +55,8 @@ define([ 'easejs', 'attributeTypeList', 'widget', 'interpreter', 'aggregator' ],
* @requires AttributeTypeList
* @constructs Discoverer
*/
'public __construct' : function() {
'public __construct' : function(_translations) {
this.translations = _translations;
this.register();
},
......@@ -327,6 +337,18 @@ define([ 'easejs', 'attributeTypeList', 'widget', 'interpreter', 'aggregator' ],
}
return componentList;
},
/**
* Returns the (associative array of) this discoverer's translations.
*
* @public
* @alias getTranslations
* @memberof Discoverer#
* @returns {Object}
*/
'public getTranslations' : function() {
return this.translations;
},
/***********************************************************************
* Helper *
......
/**
* This module represents the helper class Translation.
*
* @module Translation
* @fileOverview
*/
define('translation', ['easejs', 'attributeType'], function(easejs, AttributeType) {
var Class = easejs.Class;
var Translation = Class('Translation', {
'private fromAttributeType' : {},
'private toAttributeType' : {},
/**
* Constructor: Constructs a translation tuple.
*
* @class Translation
* @classdesc This class represents a translation tuple.
* It holds two synonymous attribute types.
* @requires easejs
* @requires attributeType
* @constructs Translation
*/
'public __construct' : function(_fromAttributeType, _toAttributeType) {
this.fromAttributeType = _fromAttributeType;
this.toAttributeType = _toAttributeType;
},
/**
* Look for a translation and return the found synonym.
*
* @public
* @alias getSynonym
* @memberof Translation#
* @param {AttributeType} attributeType AttributeType whose synonym is queried
* @returns {AttributeType} The synonym if one exists, otherwise the given attributeType
*/
'public getSynonym': function(_attributeType) {
return this.hasSynonym(_attributeType) ? this.toAttributeType : _attributeType;
},
/**
* Look for a translation and return true if one exists.
*
* @public
* @alias hasSynonym
* @memberof Translation#
* @param {AttributeType} attributeType AttributeType whose synonym is queried
* @returns {boolean}
*/
'public hasSynonym': function(_attributeType) {
return this.fromAttributeType.equals(_attributeType);
}
});
return Translation;
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment