From 242846bd572aa047d70e54a9473dd0b5f35a00e9 Mon Sep 17 00:00:00 2001
From: Helena Jank <jank@uni-potsdam.de>
Date: Mon, 18 May 2015 18:41:04 +0200
Subject: [PATCH] # adjusted attribute's method equalsTypeOf including synonyms
 # corrected discoverer: constructor and buildAttribute

---
 js/modules/attribute/attribute.js   |  6 +++++-
 js/modules/discoverer/discoverer.js | 26 ++++++++++++++++++++------
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/js/modules/attribute/attribute.js b/js/modules/attribute/attribute.js
index 18e9806..a438a3f 100644
--- a/js/modules/attribute/attribute.js
+++ b/js/modules/attribute/attribute.js
@@ -240,6 +240,7 @@ define(['easejs',
 			 * @public
 			 * @alias getSynonyms
 			 * @memberof Attribute#
+             * @returns {Array}
 			 */
 			'public getSynonyms' : function(){
 				return this.synonymList;
@@ -409,7 +410,10 @@ define(['easejs',
              */
             'public equalsTypeOf' : function(_attribute) {
                 if (Class.isA(Attribute, _attribute)) {
-                    if (this.getName() == _attribute.getName() && this.getType() == _attribute.getType() && this.getParameters().equals(_attribute.getParameters())) {
+                	var name = _attribute.getName();
+                    if ((this.getName() == name || this.getSynonyms().indexOf(name) != -1) && 
+                    		this.getType() == _attribute.getType() && 
+                    		this.getParameters().equals(_attribute.getParameters())) {
                         return true;
                     }
                 }
diff --git a/js/modules/discoverer/discoverer.js b/js/modules/discoverer/discoverer.js
index 4704eb2..0bdbad1 100644
--- a/js/modules/discoverer/discoverer.js
+++ b/js/modules/discoverer/discoverer.js
@@ -4,8 +4,8 @@
  * @module Discoverer
  * @fileOverview
  */
-define([ 'easejs', 'attributeList', 'widget', 'interpreter', 'aggregator' ], function(easejs,
-		AttributeList, Widget, Interpreter, Aggregator) {
+define([ 'easejs', 'attribute', 'attributeList', 'parameter', 'translation', 'widget', 'interpreter', 'aggregator' ], function(easejs,
+		Attribute, AttributeList, Parameter, Translation, Widget, Interpreter, Aggregator) {
 	var Class = easejs.Class;
 	
 	var Discoverer = Class('Discoverer', {
@@ -52,10 +52,12 @@ define([ 'easejs', 'attributeList', 'widget', 'interpreter', 'aggregator' ], fun
 		 * @class Discoverer
 		 * @classdesc The Discoverer handles requests for components and attributes. 
 		 * @requires easejs
-		 * @requires AttributeList
+		 * @param _widgets
+		 * @param _interpreters
+		 * @param _translations
 		 * @constructs Discoverer
 		 */
-		'public __construct' : function(_translations) {
+		'public __construct' : function(_widgets, _interpreters, _translations) {
 			this.translations = _translations;
 		},
 
@@ -252,9 +254,20 @@ define([ 'easejs', 'attributeList', 'widget', 'interpreter', 'aggregator' ], fun
 			return this.translations;
 		},
 		
-		
+		/**
+		 * Returns a newly built attribute.
+		 * 
+		 * @public
+		 * @alias buildAttribute
+		 * @memberof Discoverer#
+		 * @param {string} name the proposed name of the will-be attribute
+		 * @param {string} type its type
+         * @param {Array} parameterList an array of arrays with two elements each: key and value
+		 * @returns {Attribute}
+		 */
 		'public buildAttribute' : function(name, type, parameterList) {
 			var newAttribute = new Attribute().withName(name).withType(type);
+			
 			while (typeof parameterList != 'undefined' && parameterList.length > 0) 
 			{
 				var param = parameterList.pop();
@@ -263,7 +276,8 @@ define([ 'easejs', 'attributeList', 'widget', 'interpreter', 'aggregator' ], fun
 				if (typeof key != 'undefined' && typeof value != 'undefined') 
 					newAttribute = newAttribute.withParameter(new Parameter().withKey(key).withValue(value));
 			}
-			for (translation in this.translations) {
+			for (index in this.translations) {
+				var translation = this.translations[index];
 				if (translation.translates(newAttribute))
 					newAttribute = newAttribute.withSynonym(translation.getSynonym());				
 			}
-- 
GitLab