catch up with branch development

Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.xtext.datamartdsl/emf-gen/org/eclipse/osbp/xtext/datamartdsl/DatamartDSLPackage.java b/org.eclipse.osbp.xtext.datamartdsl/emf-gen/org/eclipse/osbp/xtext/datamartdsl/DatamartDSLPackage.java
index be6a2a6..87a56c1 100644
--- a/org.eclipse.osbp.xtext.datamartdsl/emf-gen/org/eclipse/osbp/xtext/datamartdsl/DatamartDSLPackage.java
+++ b/org.eclipse.osbp.xtext.datamartdsl/emf-gen/org/eclipse/osbp/xtext/datamartdsl/DatamartDSLPackage.java
@@ -39,7 +39,7 @@
  * <!-- end-user-doc -->
  * @see org.eclipse.osbp.xtext.datamartdsl.DatamartDSLFactory
  * @model kind="package"
- *        annotation="http://www.eclipse.org/emf/2002/GenModel modelName='DatamartDSL' prefix='DatamartDSL' updateClasspath='false' copyrightText='Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)\n All rights reserved. This program and the accompanying materials \n are made available under the terms of the Eclipse Public License 2.0  \n which accompanies this distribution, and is available at \n https://www.eclipse.org/legal/epl-2.0/ \n \n SPDX-License-Identifier: EPL-2.0 \n\n Based on ideas from Xtext, Xtend, Xcore\n  \n Contributors:  \n \t\tJoerg Riegel - Initial implementation \n ' basePackage='org.eclipse.osbp.xtext'"
+ *        annotation="http://www.eclipse.org/emf/2002/GenModel modelName='DatamartDSL' prefix='DatamartDSL' updateClasspath='false' loadInitialization='false' literalsInterface='true' copyrightText='Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)\r\n All rights reserved. This program and the accompanying materials \r\n are made available under the terms of the Eclipse Public License 2.0  \r\n which accompanies this distribution, and is available at \r\n https://www.eclipse.org/legal/epl-2.0/ \r\n \r\n SPDX-License-Identifier: EPL-2.0 \r\n\r\n Based on ideas from Xtext, Xtend, Xcore\r\n  \r\n Contributors:  \r\n \t\tJoerg Riegel - Initial implementation \r\n ' basePackage='org.eclipse.osbp.xtext'"
  *        annotation="http://www.eclipse.org/emf/2002/Ecore rootPackage='datamartdsl'"
  * @generated
  */
diff --git a/org.eclipse.osbp.xtext.datamartdsl/model/DatamartDSL.xcore b/org.eclipse.osbp.xtext.datamartdsl/model/DatamartDSL.xcore
index 1449c45..18f3582 100644
--- a/org.eclipse.osbp.xtext.datamartdsl/model/DatamartDSL.xcore
+++ b/org.eclipse.osbp.xtext.datamartdsl/model/DatamartDSL.xcore
@@ -1,6 +1,8 @@
 @GenModel(modelName="DatamartDSL")
 @GenModel(prefix="DatamartDSL")
 @GenModel(updateClasspath="false")
+@GenModel(loadInitialization="false")
+@GenModel(literalsInterface="true")
 @GenModel(copyrightText="Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
  All rights reserved. This program and the accompanying materials 
  are made available under the terms of the Eclipse Public License 2.0  
diff --git a/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.xtend b/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.xtend
index 8fe377c..1c407e6 100644
--- a/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.xtend
+++ b/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.xtend
@@ -518,16 +518,22 @@
 			]
 			type.members += field
 			field = definition.toField("axisMap",
-				_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(Integer),
+				_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(Integer),
 					_typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(String)))) [
 				setInitializer([append('''new HashMap<Integer,ArrayList<String>>() «definition.createAxisMap(entityMap)»''')])
 			]
 			type.members += field
+			field = definition.toField("aliasMap",
+				_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
+					_typeReferenceBuilder.typeRef(String))) [
+				setInitializer([append('''new HashMap<String,String>() «definition.createAliasMap(entityMap)»''')])
+			]
+			type.members += field
 		}
 
 		if (definition.source instanceof DatamartTask) {
 			field = definition.toField("axisMap",
-				_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(Integer),
+				_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(Integer),
 					_typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(String)))) [
 				setInitializer([append('''new HashMap<Integer,ArrayList<String>>() «definition.createAxisMap(entityMap)»''')])
 			]
@@ -539,7 +545,7 @@
 		}
 		// must be made after createSQLStatement
 		field = definition.toField("idMap",
-			_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
+			_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
 				_typeReferenceBuilder.typeRef(EType))) [
 			setInitializer([append('''new HashMap<String,EType>() «definition.createIdMap»''')])
 		]
@@ -553,17 +559,16 @@
 		type.members += field
 
 		field = definition.toField("typesMap",
-			_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
-				_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
-					_typeReferenceBuilder.typeRef(EType)))) [
+			_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
+				_typeReferenceBuilder.typeRef(EType))) [
 			setInitializer([
-				append('''new HashMap<String,HashMap<String,EType>>() «definition.createTypesMaps(typesMap)»''')
+				append('''new HashMap<String,EType>() «definition.createTypesMaps(typesMap)»''')
 			])
 		]
 		type.members += field
 
 		field = definition.toField("typesProp",
-			_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
+			_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
 				_typeReferenceBuilder.typeRef(String))) [
 			setInitializer([
 				append('''new HashMap<String, String>() «definition.createTypesProps(typesMap)»''')
@@ -572,7 +577,7 @@
 		type.members += field
 
 		field = definition.toField("resultAttributes",
-			_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
+			_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
 				_typeReferenceBuilder.typeRef(String)))[setInitializer([append('''new HashMap<String,String>()''')])]
 		type.members += field
 	}
@@ -584,24 +589,31 @@
 	def void toGetterSetter(JvmDeclaredType type, DatamartDefinition definition) {
 		var JvmOperation operation = null
 		operation = definition.toGetter("idMap",
-			_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
+			_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
 				_typeReferenceBuilder.typeRef(EType)))
 		operation.visibility = JvmVisibility::PUBLIC
 		type.members += operation
 		operation = definition.toGetter("primaryList",
-			_typeReferenceBuilder.typeRef(ArrayList,
+			_typeReferenceBuilder.typeRef(List,
 				getTypeForName(DatamartPrimary, definition, _typeReferenceBuilder.wildcard())))
 		operation.visibility = JvmVisibility::PUBLIC
 		type.members += operation
 		if (definition.source instanceof DatamartEntity || definition.source instanceof DatamartTask) {
 			operation = definition.toGetter("axisMap",
-				_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(Integer),
+				_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(Integer),
 					_typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(String))))
 			operation.visibility = JvmVisibility::PUBLIC
 			type.members += operation
 		}
+		if (definition.source instanceof DatamartEntity) {
+			operation = definition.toGetter("aliasMap",
+				_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
+					_typeReferenceBuilder.typeRef(String)))
+			operation.visibility = JvmVisibility::PUBLIC
+			type.members += operation
+		}
 		operation = definition.toGetter("typesProp",
-			_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
+			_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
 				_typeReferenceBuilder.typeRef(String)))
 		operation.visibility = JvmVisibility::PUBLIC
 		type.members += operation
@@ -668,11 +680,11 @@
 		type.members += operation
 
 		operation = definition.toMethod("getTypesMap",
-			_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String),
+			_typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String),
 				_typeReferenceBuilder.typeRef(EType)), [
 				body = [
 					append('''
-						return typesMap.get("«IUserAccessService.ADMINISTRATOR»");
+						return typesMap;
 					''')
 				]
 			])
@@ -1116,7 +1128,7 @@
 					}
 					if (rs != null) {
 						try {
-							cellSet = new SqlCellSet(rs, getAxisMap(), getIdMap(), datamartDtoMapper, operativeDtoClass, operativeDtos, getPrimaryList());
+							cellSet = new SqlCellSet(rs, getAxisMap(), getIdMap(), getAliasMap(), datamartDtoMapper, operativeDtoClass, operativeDtos, getPrimaryList(), «binderClassName».getUserAccessService());
 							registerFirstLine(rs, user);
 							metaData = rs.getMetaData();
 							rs.close();
@@ -1318,10 +1330,8 @@
 	) {
 
 		var listTxt = '''
-		new HashMap<String,EType>()«definition.createTypesMap(typesMap)»;'''
-		listTxt = '''
 		{{
-			«listTxt»
+			«definition.createTypesMap(typesMap)»
 		}}'''
 		return listTxt
 	}
@@ -1363,10 +1373,6 @@
 			«listTxt»
 			put("«attribute»", EType.«type.toString»);'''
 		}
-		listTxt = '''
-		{{
-			«listTxt»
-		}}'''
 		return listTxt
 	}
 
@@ -1455,6 +1461,21 @@
 		}
 	}
 
+	def addAxisAttribute(String name, Integer weight, Map<Integer, Map<String, Integer>> map, int axisNumber) {
+		var found = false
+		for (axNum : map.keySet()) {
+			if (axNum == axisNumber) {
+				map.get(axNum).put(name, weight)
+				found = true
+			}
+		}
+		if (!found) {
+			var columns = <String, Integer>newHashMap
+			columns.put(name, weight)
+			map.put(axisNumber, columns)
+		}
+	}
+
 	/**
 	 * <p>recursively create an axis map for entities.</p> 
 	 * 
@@ -1476,18 +1497,49 @@
 		}
 	}
 	
-	def addAxisAttribute(String name, Integer weight, Map<Integer, Map<String, Integer>> map, int axisNumber) {
-		var found = false
-		for (axNum : map.keySet()) {
-			if (axNum == axisNumber) {
-				map.get(axNum).put(name, weight)
-				found = true
-			}
+	/**
+	 * <p>build the alias map.</p> 
+	 * 
+	 */
+	def String createAliasMap(DatamartDefinition definition, Map<String, LEntity> entityMap) {
+		var aliases = <String, String>newHashMap
+		if (definition.source !== null && definition.source instanceof DatamartEntity) {
+			(definition.source as DatamartEntity).createAliasMap(aliases)
 		}
-		if (!found) {
-			var columns = <String, Integer>newHashMap
-			columns.put(name, weight)
-			map.put(axisNumber, columns)
+		var text = '''
+		{{
+			«aliases.entrySet.map['''put("«it.key»","«it.value»");'''].join("\n")»
+		}}'''
+		return text
+	}
+
+	def void recursAliasMap(LScalarType type, DatamartAttribute attribute, Map<String, String> map) {
+		if (type instanceof LBean) {
+			var bean = type as LBean
+			for (attr : bean.allAttributes) {
+				if (attr.type instanceof LBean) {
+					recursAliasMap(attr.type, attribute, map)
+				} else {
+					map.put(attr.name, attr.fullyQualifiedName.toString)
+				}
+			}
+		} else {
+			map.put(DatamartAttributeUtil.getAliasedAttributeName(attribute), attribute.attributeRef.entity.fullyQualifiedName.toString+"."+attribute.attributeRef.name)
+		}
+	}
+
+	/**
+	 * <p>recursively create an alias map for entities.</p> 
+	 * 
+	 */
+	def void createAliasMap(DatamartEntity entity, Map<String, String> map) {
+		var entityAttributes = entity.entityAttributes
+		for (attribute : entityAttributes) {
+			var type = attribute.attributeRef.type as LScalarType
+			recursAliasMap(type, attribute, map)
+		}
+		for (navigation : entity.navigations) {
+			navigation.datamartEntity.createAliasMap(map)
 		}
 	}
 
@@ -2896,11 +2948,11 @@
 	 */
 	def void findAllEntites(DatamartCube datamartCube, Set<LEntity> entities) {
 		entities.add(datamartCube.cubeRef.cubeTypeEntity.entityRef.entityValue)
-//		for (dimensionUsage : datamartCube.cubeRef.cubeTypeEntity.dimensionUsages) {
-//			for (hierarchy : dimensionUsage.sourceValue.hierarchies) {
-//				entities.add(hierarchy.cubeDimEntity.entityRef.entityValue)
-//			}
-//		}
+		for (dimensionUsage : datamartCube.cubeRef.cubeTypeEntity.dimensionUsages) {
+			for (hierarchy : dimensionUsage.sourceValue.hierarchies) {
+				entities.add(hierarchy.cubeDimEntity.entityRef.entityValue)
+			}
+		}
 	}
 
 	def List<DatamartAttribute> allEntityAttributes(DatamartDefinition datamart) {
diff --git a/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.xtend b/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.xtend
index e48662f..72e0741 100644
--- a/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.xtend
+++ b/org.eclipse.osbp.xtext.datamartdsl/src/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.xtend
@@ -22,6 +22,7 @@
 import java.sql.ResultSet
 import java.sql.SQLException
 import java.sql.Timestamp
+import java.util.HashMap
 import java.util.List
 import java.util.Locale
 import java.util.ResourceBundle
@@ -86,6 +87,7 @@
 			,ReferenceCardinality
 			,ReferencePolicy
 			,User
+			,HashMap
 	
 			// workload handling
 			,IDto
diff --git a/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.java b/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.java
index 77fd0ab..9be8a6c 100644
--- a/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.java
+++ b/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartDSLJvmModelInferrer.java
@@ -59,6 +59,8 @@
 import org.eclipse.osbp.utils.common.EntityUtils;
 import org.eclipse.osbp.utils.entityhelper.DataType;
 import org.eclipse.osbp.xtext.cubedsl.CubeDimension;
+import org.eclipse.osbp.xtext.cubedsl.CubeDimensionUsage;
+import org.eclipse.osbp.xtext.cubedsl.CubeHierarchy;
 import org.eclipse.osbp.xtext.cubedsl.CubeLevel;
 import org.eclipse.osbp.xtext.cubedsl.CubePackage;
 import org.eclipse.osbp.xtext.cubedsl.CubeTypeEntity;
@@ -820,114 +822,128 @@
         this._jvmTypesBuilder.setInitializer(it, _function_9);
       };
       field = this._jvmTypesBuilder.toField(definition, "axisMap", 
-        this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(Integer.class), 
+        this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(Integer.class), 
           this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(String.class))), _function_8);
       EList<JvmMember> _members_9 = type.getMembers();
       this._jvmTypesBuilder.<JvmField>operator_add(_members_9, field);
+      final Procedure1<JvmField> _function_9 = (JvmField it) -> {
+        final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
+          StringConcatenation _builder = new StringConcatenation();
+          _builder.append("new HashMap<String,String>() ");
+          String _createAliasMap = this.createAliasMap(definition, entityMap);
+          _builder.append(_createAliasMap);
+          it_1.append(_builder);
+        };
+        this._jvmTypesBuilder.setInitializer(it, _function_10);
+      };
+      field = this._jvmTypesBuilder.toField(definition, "aliasMap", 
+        this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
+          this._typeReferenceBuilder.typeRef(String.class)), _function_9);
+      EList<JvmMember> _members_10 = type.getMembers();
+      this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field);
     }
     DatamartSource _source_2 = definition.getSource();
     if ((_source_2 instanceof DatamartTask)) {
-      final Procedure1<JvmField> _function_9 = (JvmField it) -> {
-        final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
+      final Procedure1<JvmField> _function_10 = (JvmField it) -> {
+        final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           _builder.append("new HashMap<Integer,ArrayList<String>>() ");
           String _createAxisMap = this.createAxisMap(definition, entityMap);
           _builder.append(_createAxisMap);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setInitializer(it, _function_10);
+        this._jvmTypesBuilder.setInitializer(it, _function_11);
       };
       field = this._jvmTypesBuilder.toField(definition, "axisMap", 
-        this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(Integer.class), 
-          this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(String.class))), _function_9);
-      EList<JvmMember> _members_10 = type.getMembers();
-      this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field);
-      final Procedure1<JvmField> _function_10 = (JvmField it) -> {
-        final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
+        this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(Integer.class), 
+          this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(String.class))), _function_10);
+      EList<JvmMember> _members_11 = type.getMembers();
+      this._jvmTypesBuilder.<JvmField>operator_add(_members_11, field);
+      final Procedure1<JvmField> _function_11 = (JvmField it) -> {
+        final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           _builder.append("new DatamartDtoMapper()");
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setInitializer(it, _function_11);
+        this._jvmTypesBuilder.setInitializer(it, _function_12);
       };
-      field = this._jvmTypesBuilder.toField(definition, "datamartDtoMapper", this._typeReferenceBuilder.typeRef(DatamartDtoMapper.class), _function_10);
-      EList<JvmMember> _members_11 = type.getMembers();
-      this._jvmTypesBuilder.<JvmField>operator_add(_members_11, field);
+      field = this._jvmTypesBuilder.toField(definition, "datamartDtoMapper", this._typeReferenceBuilder.typeRef(DatamartDtoMapper.class), _function_11);
+      EList<JvmMember> _members_12 = type.getMembers();
+      this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field);
     }
-    final Procedure1<JvmField> _function_11 = (JvmField it) -> {
-      final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
+    final Procedure1<JvmField> _function_12 = (JvmField it) -> {
+      final Procedure1<ITreeAppendable> _function_13 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("new HashMap<String,EType>() ");
         String _createIdMap = this.createIdMap(definition);
         _builder.append(_createIdMap);
         it_1.append(_builder);
       };
-      this._jvmTypesBuilder.setInitializer(it, _function_12);
+      this._jvmTypesBuilder.setInitializer(it, _function_13);
     };
     field = this._jvmTypesBuilder.toField(definition, "idMap", 
-      this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
-        this._typeReferenceBuilder.typeRef(IDataMart.EType.class)), _function_11);
-    EList<JvmMember> _members_12 = type.getMembers();
-    this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field);
-    final Procedure1<JvmField> _function_12 = (JvmField it) -> {
-      final Procedure1<ITreeAppendable> _function_13 = (ITreeAppendable it_1) -> {
+      this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
+        this._typeReferenceBuilder.typeRef(IDataMart.EType.class)), _function_12);
+    EList<JvmMember> _members_13 = type.getMembers();
+    this._jvmTypesBuilder.<JvmField>operator_add(_members_13, field);
+    final Procedure1<JvmField> _function_13 = (JvmField it) -> {
+      final Procedure1<ITreeAppendable> _function_14 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("new ArrayList<DatamartPrimary<?>>() ");
         String _createPrimaryList = this.createPrimaryList(definition);
         _builder.append(_createPrimaryList);
         it_1.append(_builder);
       };
-      this._jvmTypesBuilder.setInitializer(it, _function_13);
+      this._jvmTypesBuilder.setInitializer(it, _function_14);
     };
     field = this._jvmTypesBuilder.toField(definition, "primaryList", 
       this._typeReferenceBuilder.typeRef(ArrayList.class, 
-        this._typeReferences.getTypeForName(DatamartPrimary.class, definition, this._typeReferenceBuilder.wildcard())), _function_12);
-    EList<JvmMember> _members_13 = type.getMembers();
-    this._jvmTypesBuilder.<JvmField>operator_add(_members_13, field);
-    final Procedure1<JvmField> _function_13 = (JvmField it) -> {
-      final Procedure1<ITreeAppendable> _function_14 = (ITreeAppendable it_1) -> {
-        StringConcatenation _builder = new StringConcatenation();
-        _builder.append("new HashMap<String,HashMap<String,EType>>() ");
-        String _createTypesMaps = this.createTypesMaps(definition, typesMap);
-        _builder.append(_createTypesMaps);
-        it_1.append(_builder);
-      };
-      this._jvmTypesBuilder.setInitializer(it, _function_14);
-    };
-    field = this._jvmTypesBuilder.toField(definition, "typesMap", 
-      this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
-        this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
-          this._typeReferenceBuilder.typeRef(IDataMart.EType.class))), _function_13);
+        this._typeReferences.getTypeForName(DatamartPrimary.class, definition, this._typeReferenceBuilder.wildcard())), _function_13);
     EList<JvmMember> _members_14 = type.getMembers();
     this._jvmTypesBuilder.<JvmField>operator_add(_members_14, field);
     final Procedure1<JvmField> _function_14 = (JvmField it) -> {
       final Procedure1<ITreeAppendable> _function_15 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
+        _builder.append("new HashMap<String,EType>() ");
+        String _createTypesMaps = this.createTypesMaps(definition, typesMap);
+        _builder.append(_createTypesMaps);
+        it_1.append(_builder);
+      };
+      this._jvmTypesBuilder.setInitializer(it, _function_15);
+    };
+    field = this._jvmTypesBuilder.toField(definition, "typesMap", 
+      this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
+        this._typeReferenceBuilder.typeRef(IDataMart.EType.class)), _function_14);
+    EList<JvmMember> _members_15 = type.getMembers();
+    this._jvmTypesBuilder.<JvmField>operator_add(_members_15, field);
+    final Procedure1<JvmField> _function_15 = (JvmField it) -> {
+      final Procedure1<ITreeAppendable> _function_16 = (ITreeAppendable it_1) -> {
+        StringConcatenation _builder = new StringConcatenation();
         _builder.append("new HashMap<String, String>() ");
         String _createTypesProps = this.createTypesProps(definition, typesMap);
         _builder.append(_createTypesProps);
         it_1.append(_builder);
       };
-      this._jvmTypesBuilder.setInitializer(it, _function_15);
+      this._jvmTypesBuilder.setInitializer(it, _function_16);
     };
     field = this._jvmTypesBuilder.toField(definition, "typesProp", 
-      this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
-        this._typeReferenceBuilder.typeRef(String.class)), _function_14);
-    EList<JvmMember> _members_15 = type.getMembers();
-    this._jvmTypesBuilder.<JvmField>operator_add(_members_15, field);
-    final Procedure1<JvmField> _function_15 = (JvmField it) -> {
-      final Procedure1<ITreeAppendable> _function_16 = (ITreeAppendable it_1) -> {
+      this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
+        this._typeReferenceBuilder.typeRef(String.class)), _function_15);
+    EList<JvmMember> _members_16 = type.getMembers();
+    this._jvmTypesBuilder.<JvmField>operator_add(_members_16, field);
+    final Procedure1<JvmField> _function_16 = (JvmField it) -> {
+      final Procedure1<ITreeAppendable> _function_17 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("new HashMap<String,String>()");
         it_1.append(_builder);
       };
-      this._jvmTypesBuilder.setInitializer(it, _function_16);
+      this._jvmTypesBuilder.setInitializer(it, _function_17);
     };
     field = this._jvmTypesBuilder.toField(definition, "resultAttributes", 
-      this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
-        this._typeReferenceBuilder.typeRef(String.class)), _function_15);
-    EList<JvmMember> _members_16 = type.getMembers();
-    this._jvmTypesBuilder.<JvmField>operator_add(_members_16, field);
+      this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
+        this._typeReferenceBuilder.typeRef(String.class)), _function_16);
+    EList<JvmMember> _members_17 = type.getMembers();
+    this._jvmTypesBuilder.<JvmField>operator_add(_members_17, field);
   }
   
   /**
@@ -936,39 +952,48 @@
   public void toGetterSetter(final JvmDeclaredType type, final DatamartDefinition definition) {
     JvmOperation operation = null;
     operation = this._jvmTypesBuilder.toGetter(definition, "idMap", 
-      this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
+      this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
         this._typeReferenceBuilder.typeRef(IDataMart.EType.class)));
     operation.setVisibility(JvmVisibility.PUBLIC);
     EList<JvmMember> _members = type.getMembers();
     this._jvmTypesBuilder.<JvmOperation>operator_add(_members, operation);
     operation = this._jvmTypesBuilder.toGetter(definition, "primaryList", 
-      this._typeReferenceBuilder.typeRef(ArrayList.class, 
+      this._typeReferenceBuilder.typeRef(List.class, 
         this._typeReferences.getTypeForName(DatamartPrimary.class, definition, this._typeReferenceBuilder.wildcard())));
     operation.setVisibility(JvmVisibility.PUBLIC);
     EList<JvmMember> _members_1 = type.getMembers();
     this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, operation);
     if (((definition.getSource() instanceof DatamartEntity) || (definition.getSource() instanceof DatamartTask))) {
       operation = this._jvmTypesBuilder.toGetter(definition, "axisMap", 
-        this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(Integer.class), 
+        this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(Integer.class), 
           this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(String.class))));
       operation.setVisibility(JvmVisibility.PUBLIC);
       EList<JvmMember> _members_2 = type.getMembers();
       this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, operation);
     }
+    DatamartSource _source = definition.getSource();
+    if ((_source instanceof DatamartEntity)) {
+      operation = this._jvmTypesBuilder.toGetter(definition, "aliasMap", 
+        this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
+          this._typeReferenceBuilder.typeRef(String.class)));
+      operation.setVisibility(JvmVisibility.PUBLIC);
+      EList<JvmMember> _members_3 = type.getMembers();
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, operation);
+    }
     operation = this._jvmTypesBuilder.toGetter(definition, "typesProp", 
-      this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
+      this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
         this._typeReferenceBuilder.typeRef(String.class)));
     operation.setVisibility(JvmVisibility.PUBLIC);
-    EList<JvmMember> _members_3 = type.getMembers();
-    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, operation);
-    operation = this._jvmTypesBuilder.toGetter(definition, "user", this._typeReferenceBuilder.typeRef(IUser.class));
-    operation.setVisibility(JvmVisibility.PUBLIC);
     EList<JvmMember> _members_4 = type.getMembers();
     this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, operation);
-    operation = this._jvmTypesBuilder.toSetter(definition, "user", this._typeReferenceBuilder.typeRef(IUser.class));
+    operation = this._jvmTypesBuilder.toGetter(definition, "user", this._typeReferenceBuilder.typeRef(IUser.class));
     operation.setVisibility(JvmVisibility.PUBLIC);
     EList<JvmMember> _members_5 = type.getMembers();
     this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, operation);
+    operation = this._jvmTypesBuilder.toSetter(definition, "user", this._typeReferenceBuilder.typeRef(IUser.class));
+    operation.setVisibility(JvmVisibility.PUBLIC);
+    EList<JvmMember> _members_6 = type.getMembers();
+    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, operation);
   }
   
   /**
@@ -1072,16 +1097,14 @@
     final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> {
       final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
-        _builder.append("return typesMap.get(\"");
-        _builder.append(IUserAccessService.ADMINISTRATOR);
-        _builder.append("\");");
-        _builder.newLineIfNotEmpty();
+        _builder.append("return typesMap;");
+        _builder.newLine();
         it_1.append(_builder);
       };
       this._jvmTypesBuilder.setBody(it, _function_5);
     };
     operation = this._jvmTypesBuilder.toMethod(definition, "getTypesMap", 
-      this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), 
+      this._typeReferenceBuilder.typeRef(Map.class, this._typeReferenceBuilder.typeRef(String.class), 
         this._typeReferenceBuilder.typeRef(IDataMart.EType.class)), _function_4);
     operation.setVisibility(JvmVisibility.PUBLIC);
     EList<JvmMember> _members_4 = type.getMembers();
@@ -2024,8 +2047,10 @@
           _builder_2.append("try {");
           _builder_2.newLine();
           _builder_2.append("\t\t");
-          _builder_2.append("cellSet = new SqlCellSet(rs, getAxisMap(), getIdMap(), datamartDtoMapper, operativeDtoClass, operativeDtos, getPrimaryList());");
-          _builder_2.newLine();
+          _builder_2.append("cellSet = new SqlCellSet(rs, getAxisMap(), getIdMap(), getAliasMap(), datamartDtoMapper, operativeDtoClass, operativeDtos, getPrimaryList(), ");
+          _builder_2.append(this.binderClassName, "\t\t");
+          _builder_2.append(".getUserAccessService());");
+          _builder_2.newLineIfNotEmpty();
           _builder_2.append("\t\t");
           _builder_2.append("registerFirstLine(rs, user);");
           _builder_2.newLine();
@@ -2449,19 +2474,14 @@
    */
   public String createTypesMaps(final DatamartDefinition definition, final HashMap<String, LAttribute> typesMap) {
     StringConcatenation _builder = new StringConcatenation();
-    _builder.append("new HashMap<String,EType>()");
+    _builder.append("{{");
+    _builder.newLine();
+    _builder.append("\t");
     String _createTypesMap = this.createTypesMap(definition, typesMap);
-    _builder.append(_createTypesMap);
-    _builder.append(";");
+    _builder.append(_createTypesMap, "\t");
+    _builder.newLineIfNotEmpty();
+    _builder.append("}}");
     String listTxt = _builder.toString();
-    StringConcatenation _builder_1 = new StringConcatenation();
-    _builder_1.append("{{");
-    _builder_1.newLine();
-    _builder_1.append("\t");
-    _builder_1.append(listTxt, "\t");
-    _builder_1.newLineIfNotEmpty();
-    _builder_1.append("}}");
-    listTxt = _builder_1.toString();
     return listTxt;
   }
   
@@ -2520,14 +2540,6 @@
         listTxt = _builder.toString();
       }
     }
-    StringConcatenation _builder = new StringConcatenation();
-    _builder.append("{{");
-    _builder.newLine();
-    _builder.append("\t");
-    _builder.append(listTxt, "\t");
-    _builder.newLineIfNotEmpty();
-    _builder.append("}}");
-    listTxt = _builder.toString();
     return listTxt;
   }
   
@@ -2645,6 +2657,32 @@
     }
   }
   
+  public Map<String, Integer> addAxisAttribute(final String name, final Integer weight, final Map<Integer, Map<String, Integer>> map, final int axisNumber) {
+    Map<String, Integer> _xblockexpression = null;
+    {
+      boolean found = false;
+      Set<Integer> _keySet = map.keySet();
+      for (final Integer axNum : _keySet) {
+        if (((axNum).intValue() == axisNumber)) {
+          map.get(axNum).put(name, weight);
+          found = true;
+        }
+      }
+      Map<String, Integer> _xifexpression = null;
+      if ((!found)) {
+        Map<String, Integer> _xblockexpression_1 = null;
+        {
+          HashMap<String, Integer> columns = CollectionLiterals.<String, Integer>newHashMap();
+          columns.put(name, weight);
+          _xblockexpression_1 = map.put(Integer.valueOf(axisNumber), columns);
+        }
+        _xifexpression = _xblockexpression_1;
+      }
+      _xblockexpression = _xifexpression;
+    }
+    return _xblockexpression;
+  }
+  
   /**
    * <p>recursively create an axis map for entities.</p>
    */
@@ -2671,30 +2709,76 @@
     }
   }
   
-  public Map<String, Integer> addAxisAttribute(final String name, final Integer weight, final Map<Integer, Map<String, Integer>> map, final int axisNumber) {
-    Map<String, Integer> _xblockexpression = null;
-    {
-      boolean found = false;
-      Set<Integer> _keySet = map.keySet();
-      for (final Integer axNum : _keySet) {
-        if (((axNum).intValue() == axisNumber)) {
-          map.get(axNum).put(name, weight);
-          found = true;
-        }
-      }
-      Map<String, Integer> _xifexpression = null;
-      if ((!found)) {
-        Map<String, Integer> _xblockexpression_1 = null;
-        {
-          HashMap<String, Integer> columns = CollectionLiterals.<String, Integer>newHashMap();
-          columns.put(name, weight);
-          _xblockexpression_1 = map.put(Integer.valueOf(axisNumber), columns);
-        }
-        _xifexpression = _xblockexpression_1;
-      }
-      _xblockexpression = _xifexpression;
+  /**
+   * <p>build the alias map.</p>
+   */
+  public String createAliasMap(final DatamartDefinition definition, final Map<String, LEntity> entityMap) {
+    HashMap<String, String> aliases = CollectionLiterals.<String, String>newHashMap();
+    if (((definition.getSource() != null) && (definition.getSource() instanceof DatamartEntity))) {
+      DatamartSource _source = definition.getSource();
+      this.createAliasMap(((DatamartEntity) _source), aliases);
     }
-    return _xblockexpression;
+    StringConcatenation _builder = new StringConcatenation();
+    _builder.append("{{");
+    _builder.newLine();
+    _builder.append("\t");
+    final Function1<Map.Entry<String, String>, String> _function = (Map.Entry<String, String> it) -> {
+      StringConcatenation _builder_1 = new StringConcatenation();
+      _builder_1.append("put(\"");
+      String _key = it.getKey();
+      _builder_1.append(_key);
+      _builder_1.append("\",\"");
+      String _value = it.getValue();
+      _builder_1.append(_value);
+      _builder_1.append("\");");
+      return _builder_1.toString();
+    };
+    String _join = IterableExtensions.join(IterableExtensions.<Map.Entry<String, String>, String>map(aliases.entrySet(), _function), "\n");
+    _builder.append(_join, "\t");
+    _builder.newLineIfNotEmpty();
+    _builder.append("}}");
+    String text = _builder.toString();
+    return text;
+  }
+  
+  public void recursAliasMap(final LScalarType type, final DatamartAttribute attribute, final Map<String, String> map) {
+    if ((type instanceof LBean)) {
+      LBean bean = ((LBean) type);
+      List<LBeanAttribute> _allAttributes = bean.getAllAttributes();
+      for (final LBeanAttribute attr : _allAttributes) {
+        LScalarType _type = attr.getType();
+        if ((_type instanceof LBean)) {
+          this.recursAliasMap(attr.getType(), attribute, map);
+        } else {
+          map.put(attr.getName(), this._iQualifiedNameProvider.getFullyQualifiedName(attr).toString());
+        }
+      }
+    } else {
+      String _aliasedAttributeName = DatamartAttributeUtil.getAliasedAttributeName(attribute);
+      String _string = this._iQualifiedNameProvider.getFullyQualifiedName(attribute.getAttributeRef().getEntity()).toString();
+      String _plus = (_string + ".");
+      String _name = attribute.getAttributeRef().getName();
+      String _plus_1 = (_plus + _name);
+      map.put(_aliasedAttributeName, _plus_1);
+    }
+  }
+  
+  /**
+   * <p>recursively create an alias map for entities.</p>
+   */
+  public void createAliasMap(final DatamartEntity entity, final Map<String, String> map) {
+    ArrayList<DatamartAttribute> entityAttributes = this.entityAttributes(entity);
+    for (final DatamartAttribute attribute : entityAttributes) {
+      {
+        LScalarType _type = attribute.getAttributeRef().getType();
+        LScalarType type = ((LScalarType) _type);
+        this.recursAliasMap(type, attribute, map);
+      }
+    }
+    EList<DatamartNavigation> _navigations = entity.getNavigations();
+    for (final DatamartNavigation navigation : _navigations) {
+      this.createAliasMap(navigation.getDatamartEntity(), map);
+    }
   }
   
   public LScalarType getAttributeType(final DatamartAttribute prop) {
@@ -5449,6 +5533,13 @@
    */
   public void findAllEntites(final DatamartCube datamartCube, final Set<LEntity> entities) {
     entities.add(datamartCube.getCubeRef().getCubeTypeEntity().getEntityRef().getEntityValue());
+    EList<CubeDimensionUsage> _dimensionUsages = datamartCube.getCubeRef().getCubeTypeEntity().getDimensionUsages();
+    for (final CubeDimensionUsage dimensionUsage : _dimensionUsages) {
+      EList<CubeHierarchy> _hierarchies = dimensionUsage.getSourceValue().getHierarchies();
+      for (final CubeHierarchy hierarchy : _hierarchies) {
+        entities.add(hierarchy.getCubeDimEntity().getEntityRef().getEntityValue());
+      }
+    }
   }
   
   public List<DatamartAttribute> allEntityAttributes(final DatamartDefinition datamart) {
diff --git a/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.java b/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.java
index b73cfd8..2c3b604 100644
--- a/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.java
+++ b/org.eclipse.osbp.xtext.datamartdsl/xtend-gen/org/eclipse/osbp/xtext/datamartdsl/jvmmodel/DatamartModelGenerator.java
@@ -20,6 +20,7 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Timestamp;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -69,7 +70,7 @@
     TreeAppendable _xblockexpression = null;
     {
       this.setBuilder(context.eResource());
-      this._basicDslGeneratorUtils.addImportFor(this, importManager, this._typeReferenceBuilder, DriverManager.class, SQLException.class, List.class, DerivedAxis.class, DerivedPosition.class, DerivedMember.class, ResultSet.class, SqlCellSet.class, Axis.class, IPersistenceService.class, ProductConfiguration.class, IDataMart.EType.class, IDualData.class, SimpleDateFormatter.class, DatamartData.class, DatamartFilter.class, ReferenceCardinality.class, ReferencePolicy.class, User.class, IDto.class, DatamartDtoMapper.class, BPMTaskSummary.class, Notification.class, BigDecimal.class, Timestamp.class, Date.class, ResourceBundle.class, Locale.class, ITranslator.class);
+      this._basicDslGeneratorUtils.addImportFor(this, importManager, this._typeReferenceBuilder, DriverManager.class, SQLException.class, List.class, DerivedAxis.class, DerivedPosition.class, DerivedMember.class, ResultSet.class, SqlCellSet.class, Axis.class, IPersistenceService.class, ProductConfiguration.class, IDataMart.EType.class, IDualData.class, SimpleDateFormatter.class, DatamartData.class, DatamartFilter.class, ReferenceCardinality.class, ReferencePolicy.class, User.class, HashMap.class, IDto.class, DatamartDtoMapper.class, BPMTaskSummary.class, Notification.class, BigDecimal.class, Timestamp.class, Date.class, ResourceBundle.class, Locale.class, ITranslator.class);
       _xblockexpression = super.createAppendable(context, importManager, config);
     }
     return _xblockexpression;