| /** |
| * |
| * 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 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.xtext.datamartdsl.util |
| |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartAttribute |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartAttributeBase |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity |
| import org.eclipse.xtext.EcoreUtil2 |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartDSLFactory |
| import org.eclipse.osbp.xtext.datamartdsl.AxisEnum |
| import org.eclipse.osbp.dsl.semantic.entity.LEntity |
| |
| class DatamartAttributeUtil { |
| |
| def static getAliasedAttributeName(DatamartAttributeBase attributeBase){ |
| if (attributeBase instanceof DatamartAttribute){ |
| var attribute = attributeBase as DatamartAttribute |
| if (attribute.aliased){ |
| return '''«attribute?.aliasName?.replace("^", "")»''' |
| } |
| } |
| return '''«attributeBase?.attributeRef?.name?.replace("^", "")»''' |
| } |
| |
| def static fillEmptyAttributes(DatamartEntity datamartEntity){ |
| var entity = datamartEntity?.entityRef |
| if (entity.eIsProxy) { |
| entity = EcoreUtil2.resolve(entity, datamartEntity.eResource) as LEntity |
| } |
| for (attribute : entity.attributes) { |
| var datamartAttribute = DatamartDSLFactory.eINSTANCE.createDatamartAttribute |
| datamartAttribute.attributeRef = attribute |
| var axis = DatamartDSLFactory.eINSTANCE.createDatamartAxis |
| axis.name = AxisEnum.COLUMNS |
| datamartAttribute.axis = axis |
| datamartEntity?.attributes?.add(datamartAttribute) |
| } |
| } |
| |
| } |