| /** |
| * Copyright (c) 2013, 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 v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.xtext.datamartdsl.jvmmodel; |
| |
| import com.google.common.base.Objects; |
| import java.sql.Connection; |
| import java.util.ArrayList; |
| import java.util.Arrays; |
| import java.util.Collection; |
| import java.util.HashMap; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.Locale; |
| import java.util.Map; |
| import java.util.Set; |
| import javax.inject.Inject; |
| import mondrian.rolap.RolapConnection; |
| import org.apache.commons.lang3.StringUtils; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.osbp.bpm.api.IBPMEngine; |
| import org.eclipse.osbp.bpm.api.IBPMTaskClient; |
| import org.eclipse.osbp.dsl.common.datatypes.IDto; |
| import org.eclipse.osbp.dsl.common.xtext.extensions.AnnotationExtension; |
| import org.eclipse.osbp.dsl.entity.xtext.extensions.NamingExtensions; |
| import org.eclipse.osbp.dsl.semantic.common.types.LAttribute; |
| import org.eclipse.osbp.dsl.semantic.common.types.LDataType; |
| import org.eclipse.osbp.dsl.semantic.common.types.LScalarType; |
| import org.eclipse.osbp.dsl.semantic.entity.LBean; |
| import org.eclipse.osbp.dsl.semantic.entity.LBeanAttribute; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntity; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityFeature; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityPersistenceInfo; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityReference; |
| import org.eclipse.osbp.persistence.IPersistenceService; |
| import org.eclipse.osbp.preferences.EnumDatabaseVendor; |
| import org.eclipse.osbp.ui.api.datamart.IDataMart; |
| import org.eclipse.osbp.ui.api.datamart.IDualData; |
| import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService; |
| import org.eclipse.osbp.ui.api.user.IUser; |
| import org.eclipse.osbp.ui.api.useraccess.IUserAccessService; |
| import org.eclipse.osbp.utils.common.EntityUtils; |
| import org.eclipse.osbp.utils.common.IEntityIdModificationListenerView; |
| import org.eclipse.osbp.utils.constants.GeneratorConstants; |
| import org.eclipse.osbp.utils.entityhelper.DataType; |
| import org.eclipse.osbp.utils.fillertext.FillerTextProvider; |
| import org.eclipse.osbp.xtext.authorizationdsl.Role; |
| import org.eclipse.osbp.xtext.authorizationdsl.RoleElement; |
| import org.eclipse.osbp.xtext.authorizationdsl.RoleEntity; |
| import org.eclipse.osbp.xtext.authorizationdsl.RoleEntityAttribute; |
| import org.eclipse.osbp.xtext.authorizationdsl.RoleEntityFeature; |
| import org.eclipse.osbp.xtext.authorizationdsl.RoleEntityReference; |
| import org.eclipse.osbp.xtext.authorizationdsl.RolePropertyEnum; |
| import org.eclipse.osbp.xtext.cubedsl.CubeDimension; |
| import org.eclipse.osbp.xtext.cubedsl.CubeEntity; |
| import org.eclipse.osbp.xtext.cubedsl.CubeHierarchy; |
| import org.eclipse.osbp.xtext.cubedsl.CubeLevel; |
| import org.eclipse.osbp.xtext.cubedsl.CubeMeasure; |
| import org.eclipse.osbp.xtext.cubedsl.CubePackage; |
| import org.eclipse.osbp.xtext.cubedsl.CubeType; |
| import org.eclipse.osbp.xtext.cubedsl.CubeTypeEntity; |
| import org.eclipse.osbp.xtext.datamart.common.ACubeDatamart; |
| import org.eclipse.osbp.xtext.datamart.common.AEntityDatamart; |
| import org.eclipse.osbp.xtext.datamart.common.ATaskDatamart; |
| import org.eclipse.osbp.xtext.datamart.common.DatamartDefinitionUtil; |
| import org.eclipse.osbp.xtext.datamart.common.DatamartDtoMapper; |
| import org.eclipse.osbp.xtext.datamart.common.olap.DerivedCellSet; |
| import org.eclipse.osbp.xtext.datamart.common.sql.FillerTextResultSet; |
| import org.eclipse.osbp.xtext.datamartdsl.Addition; |
| import org.eclipse.osbp.xtext.datamartdsl.AggregationEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.AxisEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.ConditionalExpression; |
| import org.eclipse.osbp.xtext.datamartdsl.Conjunction; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartAggregation; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartAggregationFunction; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartAggregationFunctionInterface; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartAxis; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartColumn; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartCondition; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartCube; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartCubeElement; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartDefineDerivedMeasure; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartDefinition; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartDerivedMeasure; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartElement; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartFunction; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartFunctionIntParameter; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartFunctionInterface; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartHierarchy; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartMeasure; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartMember; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartMemberTuple; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartNavigation; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartOrder; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartOwner; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartPackage; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartParameterFunction; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartProperty; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartReference; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartRole; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSetAggregation; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSetAggregationFunction; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSetFunction; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSetFunctionInterface; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSetParameterFunction; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSetTuple; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSlicer; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartSource; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartTask; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartTaskFilter; |
| import org.eclipse.osbp.xtext.datamartdsl.Disjunction; |
| import org.eclipse.osbp.xtext.datamartdsl.Division; |
| import org.eclipse.osbp.xtext.datamartdsl.Expression; |
| import org.eclipse.osbp.xtext.datamartdsl.FunctionEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.Multiplication; |
| import org.eclipse.osbp.xtext.datamartdsl.OperatorEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.OrderEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.ParameterFunctionEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerData; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerDateFuture; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerDatePast; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerDateRange; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerDateType; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerDoubleType; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerIntegerType; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerSignedDoubleRandom; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerSignedDoubleRange; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerSignedIntegerRandom; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerSignedIntegerRange; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerTextParagraphs; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerTextRandom; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerTextSentences; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerTextType; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerTextWords; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerType; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerUnsignedDoubleRandom; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerUnsignedDoubleRange; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerUnsignedIntegerRandom; |
| import org.eclipse.osbp.xtext.datamartdsl.PropertyFillerUnsignedIntegerRange; |
| import org.eclipse.osbp.xtext.datamartdsl.SetAggregationEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.SetFunctionEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.SetParameterFunctionEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.SqlAggregationEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.Subtraction; |
| import org.eclipse.osbp.xtext.datamartdsl.TaskFilterEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.TaskQueryColumnEnum; |
| import org.eclipse.osbp.xtext.datamartdsl.jvmmodel.DatamartModelGenerator; |
| import org.eclipse.xtend2.lib.StringConcatenation; |
| import org.eclipse.xtext.common.types.JvmAnnotationReference; |
| import org.eclipse.xtext.common.types.JvmDeclaredType; |
| import org.eclipse.xtext.common.types.JvmField; |
| import org.eclipse.xtext.common.types.JvmFormalParameter; |
| import org.eclipse.xtext.common.types.JvmGenericType; |
| import org.eclipse.xtext.common.types.JvmMember; |
| import org.eclipse.xtext.common.types.JvmOperation; |
| import org.eclipse.xtext.common.types.JvmTypeReference; |
| import org.eclipse.xtext.common.types.JvmVisibility; |
| import org.eclipse.xtext.common.types.util.TypeReferences; |
| import org.eclipse.xtext.naming.IQualifiedNameProvider; |
| import org.eclipse.xtext.naming.QualifiedName; |
| import org.eclipse.xtext.xbase.compiler.output.ITreeAppendable; |
| import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer; |
| import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor; |
| import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder; |
| import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
| import org.eclipse.xtext.xbase.lib.Conversions; |
| import org.eclipse.xtext.xbase.lib.Extension; |
| import org.eclipse.xtext.xbase.lib.IterableExtensions; |
| import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; |
| import org.eclipse.xtext.xbase.lib.StringExtensions; |
| import org.junit.Test; |
| import org.osgi.service.component.annotations.Component; |
| import org.osgi.service.component.annotations.Reference; |
| import org.osgi.service.component.annotations.ReferenceCardinality; |
| import org.osgi.service.component.annotations.ReferencePolicy; |
| import org.slf4j.Logger; |
| |
| /** |
| * <p>Infers a JVM model from the source model.</p> |
| * |
| * <p>The JVM model should contain all elements that would appear in the Java code |
| * which is generated from the source model. Other models link against the JVM model rather than the source model.</p> |
| */ |
| @SuppressWarnings("all") |
| public class DatamartDSLJvmModelInferrer extends AbstractModelInferrer { |
| /** |
| * convenience API to build and initialize JVM types and their members. |
| */ |
| @Inject |
| @Extension |
| private JvmTypesBuilder _jvmTypesBuilder; |
| |
| @Inject |
| @Extension |
| private IQualifiedNameProvider _iQualifiedNameProvider; |
| |
| @Inject |
| @Extension |
| private NamingExtensions _namingExtensions; |
| |
| @Inject |
| @Extension |
| private DatamartModelGenerator generator; |
| |
| @Inject |
| @Extension |
| private TypeReferences _typeReferences; |
| |
| @Inject |
| @Extension |
| private AnnotationExtension _annotationExtension; |
| |
| @Inject |
| @Extension |
| private DataType dtType; |
| |
| private HashMap<String, Integer> sqlAliasCounter = CollectionLiterals.<String, Integer>newHashMap(); |
| |
| private HashMap<String, DatamartProperty> sqlFilterMap = CollectionLiterals.<String, DatamartProperty>newHashMap(); |
| |
| private ArrayList<String> sqlGrouping = CollectionLiterals.<String>newArrayList(); |
| |
| private HashMap<String, LEntityAttribute> idMap = CollectionLiterals.<String, LEntityAttribute>newHashMap(); |
| |
| private String datamartDtoMapper = ((String) null); |
| |
| private HashMap<String, LEntity> entityGrouping = new HashMap<String, LEntity>(); |
| |
| private boolean ignoreEntityGrouping = false; |
| |
| private boolean sqlHasAggregate = false; |
| |
| private boolean sqlHasOrder = false; |
| |
| public static String pckgName = null; |
| |
| private String binderClassName = ""; |
| |
| private Locale locale; |
| |
| public void generatePckgName(final DatamartPackage pckg, final IJvmDeclaredTypeAcceptor acceptor) { |
| String _name = pckg.getName(); |
| DatamartDSLJvmModelInferrer.pckgName = _name; |
| } |
| |
| /** |
| * <p>infer method dispatches the neccessary routines to build fields, setter, getter, constructors and methods of the generated code.</p> |
| */ |
| protected void _infer(final DatamartPackage datamart, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| this.generatePckgName(datamart, acceptor); |
| String _name = datamart.getName(); |
| String _string = _name.toString(); |
| String _concat = _string.concat("TestClass"); |
| JvmGenericType cls = this._jvmTypesBuilder.toClass(datamart, _concat); |
| String _simpleName = cls.getSimpleName(); |
| String _firstUpper = StringExtensions.toFirstUpper(_simpleName); |
| cls.setSimpleName(_firstUpper); |
| final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(SuppressWarnings.class, "serial"); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| QualifiedName _fullyQualifiedName = DatamartDSLJvmModelInferrer.this._iQualifiedNameProvider.getFullyQualifiedName(datamart); |
| String _string = _fullyQualifiedName.toString(); |
| it.setPackageName(_string); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION); |
| DatamartDSLJvmModelInferrer.this.toTestCalls(it, datamart); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(cls, _function); |
| QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(datamart); |
| String _string_1 = _fullyQualifiedName.toString(); |
| String _plus = (_string_1 + "."); |
| QualifiedName _fullyQualifiedName_1 = this._iQualifiedNameProvider.getFullyQualifiedName(datamart); |
| String _lastSegment = _fullyQualifiedName_1.getLastSegment(); |
| String _firstUpper_1 = StringExtensions.toFirstUpper(_lastSegment); |
| String _plus_1 = (_plus + _firstUpper_1); |
| String _plus_2 = (_plus_1 + "ServiceBinder"); |
| this.binderClassName = _plus_2; |
| String _name_1 = datamart.getName(); |
| String _string_2 = _name_1.toString(); |
| String _concat_1 = _string_2.concat("ServiceBinder"); |
| JvmGenericType _class = this._jvmTypesBuilder.toClass(datamart, _concat_1); |
| cls = _class; |
| String _simpleName_1 = cls.getSimpleName(); |
| String _firstUpper_2 = StringExtensions.toFirstUpper(_simpleName_1); |
| cls.setSimpleName(_firstUpper_2); |
| final Procedure1<JvmGenericType> _function_1 = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(SuppressWarnings.class, "serial"); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef_1 = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Component.class); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1); |
| QualifiedName _fullyQualifiedName = DatamartDSLJvmModelInferrer.this._iQualifiedNameProvider.getFullyQualifiedName(datamart); |
| String _string = _fullyQualifiedName.toString(); |
| it.setPackageName(_string); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION); |
| DatamartDSLJvmModelInferrer.this.toBinderFields(it, datamart); |
| DatamartDSLJvmModelInferrer.this.toBinderOperations(it, datamart); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(cls, _function_1); |
| EList<DatamartDefinition> _definitions = datamart.getDefinitions(); |
| for (final DatamartDefinition definition : _definitions) { |
| QualifiedName _fullyQualifiedName_2 = this._iQualifiedNameProvider.getFullyQualifiedName(definition); |
| String _plus_3 = (_fullyQualifiedName_2 + IDataMart.DATAMART_CLASS_POSTFIX); |
| JvmGenericType _class_1 = this._jvmTypesBuilder.toClass(definition, _plus_3); |
| final Procedure1<JvmGenericType> _function_2 = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(SuppressWarnings.class, "serial"); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| QualifiedName _fullyQualifiedName = DatamartDSLJvmModelInferrer.this._iQualifiedNameProvider.getFullyQualifiedName(datamart); |
| String _string = _fullyQualifiedName.toString(); |
| it.setPackageName(_string); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION); |
| DatamartSource _source = definition.getSource(); |
| if ((_source instanceof DatamartEntity)) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(AEntityDatamart.class); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| } |
| DatamartSource _source_1 = definition.getSource(); |
| if ((_source_1 instanceof DatamartCube)) { |
| EList<JvmTypeReference> _superTypes_1 = it.getSuperTypes(); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ACubeDatamart.class); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_1, _typeRef_1); |
| } |
| DatamartSource _source_2 = definition.getSource(); |
| if ((_source_2 instanceof DatamartTask)) { |
| EList<JvmTypeReference> _superTypes_2 = it.getSuperTypes(); |
| JvmTypeReference _typeRef_2 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ATaskDatamart.class); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_2, _typeRef_2); |
| } |
| DatamartDSLJvmModelInferrer.this.toFields(it, definition); |
| DatamartDSLJvmModelInferrer.this.toGetterSetter(it, definition); |
| DatamartDSLJvmModelInferrer.this.toOperations(it, definition); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(_class_1, _function_2); |
| } |
| } |
| |
| public void toTestCalls(final JvmGenericType type, final DatamartPackage datamart) { |
| JvmOperation operation = null; |
| EList<DatamartDefinition> _definitions = datamart.getDefinitions(); |
| for (final DatamartDefinition definition : _definitions) { |
| { |
| String _name = definition.getName(); |
| String _concat = "test".concat(_name); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Test.class); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _allTestcalls = DatamartDSLJvmModelInferrer.this.getAllTestcalls(definition); |
| _builder.append(_allTestcalls, ""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(definition, _concat, _typeRef, _function); |
| operation = _method; |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members, operation); |
| } |
| } |
| } |
| |
| public String getAllTestcalls(final DatamartDefinition definition) { |
| String body = ""; |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(body, ""); |
| String _name = definition.getName(); |
| _builder.append(_name, ""); |
| _builder.append("Datamart.Test"); |
| String _name_1 = definition.getName(); |
| _builder.append(_name_1, ""); |
| _builder.append("();"); |
| _builder.newLineIfNotEmpty(); |
| body = _builder.toString(); |
| return body; |
| } |
| |
| public void toBinderFields(final JvmDeclaredType type, final DatamartPackage datamart) { |
| JvmField field = null; |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Logger.class); |
| final Procedure1<JvmField> _function = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("org.slf4j.LoggerFactory.getLogger(\"servicebinder\")"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field = this._jvmTypesBuilder.toField(datamart, "log", _typeRef, _function); |
| field = _field; |
| field.setStatic(true); |
| field.setVisibility(JvmVisibility.PRIVATE); |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| JvmField _field_1 = this._jvmTypesBuilder.toField(datamart, "persistenceService", _typeRef_1); |
| field = _field_1; |
| field.setStatic(true); |
| field.setVisibility(JvmVisibility.PRIVATE); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(IBPMEngine.class); |
| JvmField _field_2 = this._jvmTypesBuilder.toField(datamart, "bpmEngine", _typeRef_2); |
| field = _field_2; |
| field.setStatic(true); |
| field.setVisibility(JvmVisibility.PRIVATE); |
| EList<JvmMember> _members_2 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field); |
| JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(IUserAccessService.class); |
| JvmField _field_3 = this._jvmTypesBuilder.toField(datamart, "userAccessService", _typeRef_3); |
| field = _field_3; |
| field.setStatic(true); |
| field.setVisibility(JvmVisibility.PRIVATE); |
| EList<JvmMember> _members_3 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_3, field); |
| JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(IDSLMetadataService.class); |
| JvmField _field_4 = this._jvmTypesBuilder.toField(datamart, "dslMetadataService", _typeRef_4); |
| field = _field_4; |
| field.setStatic(true); |
| field.setVisibility(JvmVisibility.PRIVATE); |
| EList<JvmMember> _members_4 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_4, field); |
| } |
| |
| public void toBinderOperations(final JvmDeclaredType type, final DatamartPackage datamart) { |
| JvmOperation operation = null; |
| EList<JvmMember> _members = type.getMembers(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setStatic(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return persistenceService;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(datamart, "getPersistenceService", _typeRef, _function); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IBPMEngine.class); |
| final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setStatic(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return bpmEngine;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(datamart, "getBpmEngine", _typeRef_1, _function_1); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1); |
| EList<JvmMember> _members_2 = type.getMembers(); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(IUserAccessService.class); |
| final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setStatic(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return userAccessService;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(datamart, "getUserAccessService", _typeRef_2, _function_2); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2); |
| EList<JvmMember> _members_3 = type.getMembers(); |
| JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(IDSLMetadataService.class); |
| final Procedure1<JvmOperation> _function_3 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setStatic(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return dslMetadataService;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(datamart, "getDSLMetadataService", _typeRef_3, _function_3); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3); |
| EList<JvmMember> _members_4 = type.getMembers(); |
| JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_4 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| JvmAnnotationReference annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Reference.class); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "cardinality", ReferenceCardinality.MANDATORY); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "policy", ReferencePolicy.STATIC); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef); |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "persistenceService", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.persistenceService = persistenceService;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart PersistenceService bound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(datamart, this.generator.bindPersistenceMethod, _typeRef_4, _function_4); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4); |
| EList<JvmMember> _members_5 = type.getMembers(); |
| JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_5 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "persistenceService", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.persistenceService = null;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart PersistenceService unbound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(datamart, this.generator.unbindPersistenceMethod, _typeRef_5, _function_5); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5); |
| EList<JvmMember> _members_6 = type.getMembers(); |
| JvmTypeReference _typeRef_6 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_6 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| JvmAnnotationReference annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Reference.class); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "cardinality", ReferenceCardinality.OPTIONAL); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "policy", ReferencePolicy.DYNAMIC); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef); |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IBPMEngine.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "bpmEngine", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.bpmEngine = bpmEngine;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart BPMEngine bound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(datamart, this.generator.bindBPMMethod, _typeRef_6, _function_6); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6); |
| EList<JvmMember> _members_7 = type.getMembers(); |
| JvmTypeReference _typeRef_7 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_7 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IBPMEngine.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "bpmEngine", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.bpmEngine = null;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart BPMEngine unbound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(datamart, this.generator.unbindBPMMethod, _typeRef_7, _function_7); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7); |
| EList<JvmMember> _members_8 = type.getMembers(); |
| JvmTypeReference _typeRef_8 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_8 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| JvmAnnotationReference annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Reference.class); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "cardinality", ReferenceCardinality.MANDATORY); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "policy", ReferencePolicy.STATIC); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef); |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUserAccessService.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "userAccessService", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.userAccessService = userAccessService;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart UserAccessService bound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(datamart, this.generator.bindUserAccessMethod, _typeRef_8, _function_8); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8); |
| EList<JvmMember> _members_9 = type.getMembers(); |
| JvmTypeReference _typeRef_9 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_9 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUserAccessService.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "userAccessService", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.userAccessService = null;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart UserAccessService unbound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(datamart, this.generator.unbindUserAccessMethod, _typeRef_9, _function_9); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9); |
| EList<JvmMember> _members_10 = type.getMembers(); |
| JvmTypeReference _typeRef_10 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_10 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| JvmAnnotationReference annotationRef = DatamartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Reference.class); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "cardinality", ReferenceCardinality.MANDATORY); |
| DatamartDSLJvmModelInferrer.this._annotationExtension.addAnnAttr(annotationRef, datamart, "policy", ReferencePolicy.STATIC); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef); |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IDSLMetadataService.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "dslMetadataService", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.dslMetadataService = dslMetadataService;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart DSLMetadataService bound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(datamart, this.generator.bindDSLMetadataService, _typeRef_10, _function_10); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10); |
| EList<JvmMember> _members_11 = type.getMembers(); |
| JvmTypeReference _typeRef_11 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_11 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IDSLMetadataService.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(datamart, "dslMetadataService", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("this.dslMetadataService = null;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"Datamart DSLMetadataService unbound\");"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(datamart, this.generator.unbindDSLMetadataService, _typeRef_11, _function_11); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11); |
| } |
| |
| /** |
| * <p>build the class variables for each datamart definition.</p> |
| */ |
| public void toFields(final JvmDeclaredType type, final DatamartDefinition definition) { |
| final HashMap<String, LEntityAttribute> typesMap = CollectionLiterals.<String, LEntityAttribute>newHashMap(); |
| JvmField field = null; |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Logger.class); |
| final Procedure1<JvmField> _function = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("org.slf4j.LoggerFactory.getLogger(\"datamarts\")"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field = this._jvmTypesBuilder.toField(definition, "log", _typeRef, _function); |
| field = _field; |
| field.setStatic(true); |
| field.setVisibility(JvmVisibility.PRIVATE); |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(IDualData.class); |
| JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_2); |
| JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_1, _typeRef_3); |
| final Procedure1<JvmField> _function_1 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new HashMap<String,ArrayList<IDualData>>()"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(definition, "filterItems", _typeRef_4, _function_1); |
| field = _field_1; |
| field.setFinal(true); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field); |
| DatamartSource _source = definition.getSource(); |
| if ((_source instanceof DatamartCube)) { |
| JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("\""); |
| String _createMDXStatement = DatamartDSLJvmModelInferrer.this.createMDXStatement(definition); |
| _builder.append(_createMDXStatement, ""); |
| _builder.append("\""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_2 = this._jvmTypesBuilder.toField(definition, "statement", _typeRef_5, _function_2); |
| field = _field_2; |
| EList<JvmMember> _members_2 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field); |
| JvmTypeReference _typeRef_6 = this._typeReferenceBuilder.typeRef(RolapConnection.class); |
| final Procedure1<JvmField> _function_3 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("null"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_3 = this._jvmTypesBuilder.toField(definition, "connection", _typeRef_6, _function_3); |
| field = _field_3; |
| EList<JvmMember> _members_3 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_3, field); |
| JvmTypeReference _typeRef_7 = this._typeReferenceBuilder.typeRef(DatamartDtoMapper.class); |
| final Procedure1<JvmField> _function_4 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new DatamartDtoMapper()"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_4 = this._jvmTypesBuilder.toField(definition, "datamartDtoMapper", _typeRef_7, _function_4); |
| field = _field_4; |
| EList<JvmMember> _members_4 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_4, field); |
| } |
| DatamartSource _source_1 = definition.getSource(); |
| if ((_source_1 instanceof DatamartEntity)) { |
| JvmTypeReference _typeRef_8 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_9 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_10 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_8, _typeRef_9); |
| final Procedure1<JvmField> _function_5 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new HashMap<String,String>() "); |
| String _createSQLStatements = DatamartDSLJvmModelInferrer.this.createSQLStatements(definition, typesMap); |
| _builder.append(_createSQLStatements, ""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_5 = this._jvmTypesBuilder.toField(definition, "statements", _typeRef_10, _function_5); |
| field = _field_5; |
| EList<JvmMember> _members_5 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_5, field); |
| JvmTypeReference _typeRef_11 = this._typeReferenceBuilder.typeRef(DatamartDtoMapper.class); |
| final Procedure1<JvmField> _function_6 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(DatamartDSLJvmModelInferrer.this.datamartDtoMapper, ""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_6 = this._jvmTypesBuilder.toField(definition, "datamartDtoMapper", _typeRef_11, _function_6); |
| field = _field_6; |
| EList<JvmMember> _members_6 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_6, field); |
| JvmTypeReference _typeRef_12 = this._typeReferenceBuilder.typeRef(Connection.class); |
| final Procedure1<JvmField> _function_7 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("null"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_7 = this._jvmTypesBuilder.toField(definition, "connection", _typeRef_12, _function_7); |
| field = _field_7; |
| EList<JvmMember> _members_7 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_7, field); |
| JvmTypeReference _typeRef_13 = this._typeReferenceBuilder.typeRef(Integer.class); |
| JvmTypeReference _typeRef_14 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_15 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_14); |
| JvmTypeReference _typeRef_16 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_13, _typeRef_15); |
| final Procedure1<JvmField> _function_8 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new HashMap<Integer,ArrayList<String>>() "); |
| String _createAxisMap = DatamartDSLJvmModelInferrer.this.createAxisMap(definition); |
| _builder.append(_createAxisMap, ""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_8 = this._jvmTypesBuilder.toField(definition, "axisMap", _typeRef_16, _function_8); |
| field = _field_8; |
| EList<JvmMember> _members_8 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_8, field); |
| } |
| DatamartSource _source_2 = definition.getSource(); |
| if ((_source_2 instanceof DatamartTask)) { |
| JvmTypeReference _typeRef_17 = this._typeReferenceBuilder.typeRef(Integer.class); |
| JvmTypeReference _typeRef_18 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_19 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_18); |
| JvmTypeReference _typeRef_20 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_17, _typeRef_19); |
| final Procedure1<JvmField> _function_9 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new HashMap<Integer,ArrayList<String>>() "); |
| String _createAxisMap = DatamartDSLJvmModelInferrer.this.createAxisMap(definition); |
| _builder.append(_createAxisMap, ""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_9 = this._jvmTypesBuilder.toField(definition, "axisMap", _typeRef_20, _function_9); |
| field = _field_9; |
| EList<JvmMember> _members_9 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_9, field); |
| JvmTypeReference _typeRef_21 = this._typeReferenceBuilder.typeRef(DatamartDtoMapper.class); |
| final Procedure1<JvmField> _function_10 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new DatamartDtoMapper()"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_10 = this._jvmTypesBuilder.toField(definition, "datamartDtoMapper", _typeRef_21, _function_10); |
| field = _field_10; |
| EList<JvmMember> _members_10 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field); |
| } |
| JvmTypeReference _typeRef_22 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_23 = this._typeReferenceBuilder.typeRef(IDataMart.EType.class); |
| JvmTypeReference _typeRef_24 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_22, _typeRef_23); |
| final Procedure1<JvmField> _function_11 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new HashMap<String,EType>() "); |
| String _createIdMap = DatamartDSLJvmModelInferrer.this.createIdMap(definition); |
| _builder.append(_createIdMap, ""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_11 = this._jvmTypesBuilder.toField(definition, "idMap", _typeRef_24, _function_11); |
| field = _field_11; |
| EList<JvmMember> _members_11 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_11, field); |
| JvmTypeReference _typeRef_25 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_26 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_27 = this._typeReferenceBuilder.typeRef(IDataMart.EType.class); |
| JvmTypeReference _typeRef_28 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_26, _typeRef_27); |
| JvmTypeReference _typeRef_29 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_25, _typeRef_28); |
| final Procedure1<JvmField> _function_12 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new HashMap<String,HashMap<String,EType>>() "); |
| String _createTypesMaps = DatamartDSLJvmModelInferrer.this.createTypesMaps(definition, typesMap); |
| _builder.append(_createTypesMaps, ""); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_12 = this._jvmTypesBuilder.toField(definition, "typesMap", _typeRef_29, _function_12); |
| field = _field_12; |
| EList<JvmMember> _members_12 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field); |
| } |
| |
| /** |
| * <p>build the getters and setters from class variables of datamart definition.</p> |
| */ |
| public void toGetterSetter(final JvmDeclaredType type, final DatamartDefinition definition) { |
| JvmOperation operation = null; |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IDataMart.EType.class); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef, _typeRef_1); |
| JvmOperation _getter = this._jvmTypesBuilder.toGetter(definition, "idMap", _typeRef_2); |
| operation = _getter; |
| operation.setVisibility(JvmVisibility.PUBLIC); |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members, operation); |
| boolean _or = false; |
| DatamartSource _source = definition.getSource(); |
| if ((_source instanceof DatamartEntity)) { |
| _or = true; |
| } else { |
| DatamartSource _source_1 = definition.getSource(); |
| _or = (_source_1 instanceof DatamartTask); |
| } |
| if (_or) { |
| JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Integer.class); |
| JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_4); |
| JvmTypeReference _typeRef_6 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_3, _typeRef_5); |
| JvmOperation _getter_1 = this._jvmTypesBuilder.toGetter(definition, "axisMap", _typeRef_6); |
| operation = _getter_1; |
| operation.setVisibility(JvmVisibility.PUBLIC); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, operation); |
| } |
| } |
| |
| /** |
| * <p>build the methods separately for cube, entity and task or SQL and MDX respective.</p> |
| */ |
| public void toOperations(final JvmDeclaredType type, final DatamartDefinition definition) { |
| JvmOperation operation = null; |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef, _typeRef_1); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return new HashMap<String,String>() "); |
| String _createFilterMap = DatamartDSLJvmModelInferrer.this.createFilterMap(definition, null); |
| _builder.append(_createFilterMap, ""); |
| _builder.append(";"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(definition, "initializeFilterMap", _typeRef_2, _function); |
| operation = _method; |
| operation.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members, operation); |
| JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(int.class); |
| final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return "); |
| int _getNumAxes = DatamartDSLJvmModelInferrer.this.getGetNumAxes(definition); |
| _builder.append(_getNumAxes, ""); |
| _builder.append(";"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(definition, "getNumberOfAxes", _typeRef_3, _function_1); |
| operation = _method_1; |
| EList<JvmMember> _members_1 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, operation); |
| JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(IDataMart.EType.class); |
| JvmTypeReference _typeRef_6 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_4, _typeRef_5); |
| final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| EList<DatamartRole> _roles = definition.getRoles(); |
| int _size = _roles.size(); |
| boolean _greaterThan = (_size > 0); |
| if (_greaterThan) { |
| _builder.append("if (user == null || "); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("user.getUserName().equals(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, "\t"); |
| _builder.append("\") ||"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t"); |
| _builder.append(".getUserAccessService().getRoles() == null) "); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("{"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("return typesMap.get(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, "\t"); |
| _builder.append("\");"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("} else {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("// find the role with the most authorized items"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("String bestRole = null;"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("int bestSize = -1;"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("for(String role:"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t"); |
| _builder.append(".getUserAccessService().getRoles()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("if (typesMap.containsKey(role)) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("if (bestSize < typesMap.get(role).size()) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("bestSize = typesMap.get(role).size();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("bestRole = role;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("if (bestRole != null) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("return typesMap.get(bestRole);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("return null;"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| } else { |
| _builder.append("return typesMap.get(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, ""); |
| _builder.append("\");"); |
| _builder.newLineIfNotEmpty(); |
| } |
| } |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(definition, "getTypesMap", _typeRef_6, _function_2); |
| operation = _method_2; |
| 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 DatamartTask)) { |
| EList<JvmMember> _members_3 = type.getMembers(); |
| JvmTypeReference _typeRef_7 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_3 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return null;"); |
| _builder.newLine(); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(definition, "getPersistenceUnit", _typeRef_7, _function_3); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3); |
| EList<JvmMember> _members_4 = type.getMembers(); |
| JvmTypeReference _typeRef_8 = this._typeReferenceBuilder.typeRef(Connection.class); |
| final Procedure1<JvmOperation> _function_4 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return null;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(definition, "connect", _typeRef_8, _function_4); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4); |
| EList<JvmMember> _members_5 = type.getMembers(); |
| JvmTypeReference _typeRef_9 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_5 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(definition, "disconnect", _typeRef_9, _function_5); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5); |
| JvmTypeReference _typeRef_10 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_11 = this._typeReferenceBuilder.typeRef(IDualData.class); |
| JvmTypeReference _typeRef_12 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_11); |
| JvmTypeReference _typeRef_13 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_10, _typeRef_12); |
| final Procedure1<JvmOperation> _function_6 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("filterItems.clear();"); |
| _builder.newLine(); |
| _builder.append("for (String filterID : getFilterIds()) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("if (getFilter(filterID).equals(\"Groups\")) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("ArrayList<IDualData> dataArray = new ArrayList<IDualData>();"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("for(String grp : "); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getBpmEngine().getGroups().keySet()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t\t"); |
| _builder.append("IDualData data = new DatamartData();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("data.setSelectionValue(grp);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("data.setUnformattedValue(grp);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("dataArray.add(data);"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("filterItems.put(filterID, dataArray);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("if (getFilter(filterID).equals(\"Users\")) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("ArrayList<IDualData> dataArray = new ArrayList<IDualData>();"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("for(String grp : "); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getBpmEngine().getUsers().keySet()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t\t"); |
| _builder.append("IDualData data = new DatamartData();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("data.setSelectionValue(grp);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("data.setUnformattedValue(grp);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("dataArray.add(data);"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("filterItems.put(filterID, dataArray);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("return filterItems;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(definition, "getFilters", _typeRef_13, _function_6); |
| operation = _method_6; |
| EList<JvmMember> _members_6 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, operation); |
| EList<JvmMember> _members_7 = type.getMembers(); |
| JvmTypeReference _typeRef_14 = this._typeReferenceBuilder.typeRef(DerivedCellSet.class); |
| final Procedure1<JvmOperation> _function_7 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IBPMTaskClient.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "client", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter_1 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef_1); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| EList<JvmFormalParameter> _parameters_2 = it.getParameters(); |
| JvmTypeReference _typeRef_2 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_3 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_4 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Map.class, _typeRef_2, _typeRef_3); |
| JvmFormalParameter _parameter_2 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "filteredItems", _typeRef_4); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("if(user != null) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("List<TaskSummary> tasks = client.getUserTaskList(user, false);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("if (tasks == null || tasks.size() == 0) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("tasks = client.getUserTaskList(user, true);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("return (new DerivedCellSet(new SqlCellSet(tasks, getAxisMap()), null,"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getDSLMetadataService(),"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("user));"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("return null;"); |
| _builder.newLine(); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(definition, "getResults", _typeRef_14, _function_7); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7); |
| EList<JvmMember> _members_8 = type.getMembers(); |
| JvmTypeReference _typeRef_15 = this._typeReferenceBuilder.typeRef(DerivedCellSet.class); |
| final Procedure1<JvmOperation> _function_8 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IBPMTaskClient.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "client", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter_1 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef_1); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| EList<JvmFormalParameter> _parameters_2 = it.getParameters(); |
| JvmTypeReference _typeRef_2 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Long.class); |
| JvmFormalParameter _parameter_2 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "taskId", _typeRef_2); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("List<TaskSummary> myTasks = new ArrayList<TaskSummary>(); "); |
| _builder.newLine(); |
| _builder.append("myTasks.add(client.getUserTask(taskId, user));"); |
| _builder.newLine(); |
| _builder.append("return (new DerivedCellSet(new SqlCellSet(myTasks, getAxisMap()), null,"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t"); |
| _builder.append(".getDSLMetadataService(), user));"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(definition, "getResultsByTaskId", _typeRef_15, _function_8); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("Test"); |
| String _name = definition.getName(); |
| _builder.append(_name, ""); |
| JvmTypeReference _typeRef_16 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_9 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setStatic(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = definition.getName(); |
| _builder.append(_name, ""); |
| _builder.append("Datamart "); |
| String _name_1 = definition.getName(); |
| String _lowerCase = _name_1.toLowerCase(); |
| _builder.append(_lowerCase, ""); |
| _builder.append(" = new "); |
| String _name_2 = definition.getName(); |
| _builder.append(_name_2, ""); |
| _builder.append("Datamart();"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("HashMap<String,String> filteredItems = new HashMap<String,String>();"); |
| _builder.newLine(); |
| _builder.append("if ("); |
| String _name_3 = definition.getName(); |
| String _lowerCase_1 = _name_3.toLowerCase(); |
| _builder.append(_lowerCase_1, ""); |
| _builder.append(".getFiltersCount() > 0) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| String _name_4 = definition.getName(); |
| String _lowerCase_2 = _name_4.toLowerCase(); |
| _builder.append(_lowerCase_2, "\t"); |
| _builder.append(".getFilters(null);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("for (String filterID : "); |
| String _name_5 = definition.getName(); |
| String _lowerCase_3 = _name_5.toLowerCase(); |
| _builder.append(_lowerCase_3, "\t"); |
| _builder.append(".filterItems.keySet()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("filteredItems.put(filterID, \"\'\"+"); |
| String _name_6 = definition.getName(); |
| String _lowerCase_4 = _name_6.toLowerCase(); |
| _builder.append(_lowerCase_4, "\t\t"); |
| _builder.append(".filterItems.get(filterID).iterator().next().getSelectionValue()+\"\'\");"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("org.eclipse.osbp.vaaclipse.addons.softwarefactory.bpmImpl.BPMTaskClient client = new org.eclipse.osbp.vaaclipse.addons.softwarefactory.bpmImpl.BPMTaskClient();"); |
| _builder.newLine(); |
| _builder.append("DerivedCellSet cellset = "); |
| String _name_7 = definition.getName(); |
| String _lowerCase_5 = _name_7.toLowerCase(); |
| _builder.append(_lowerCase_5, ""); |
| _builder.append(".getResults(client, new User(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, ""); |
| _builder.append("\"), filteredItems);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("org.junit.Assert.assertNotNull(cellset);"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(definition, _builder.toString(), _typeRef_16, _function_9); |
| operation = _method_9; |
| JvmTypeReference _typeRef_17 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| operation.setReturnType(_typeRef_17); |
| JvmAnnotationReference annRef = this._annotationTypesBuilder.annotationRef(Test.class); |
| EList<JvmAnnotationReference> _annotations = operation.getAnnotations(); |
| _annotations.add(annRef); |
| EList<JvmMember> _members_9 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, operation); |
| } |
| DatamartSource _source_1 = definition.getSource(); |
| if ((_source_1 instanceof DatamartCube)) { |
| DatamartSource _source_2 = definition.getSource(); |
| CubeType _cubeRef = ((DatamartCube) _source_2).getCubeRef(); |
| CubeTypeEntity _cubeTypeEntity = _cubeRef.getCubeTypeEntity(); |
| boolean _notEquals = (!Objects.equal(_cubeTypeEntity, null)); |
| if (_notEquals) { |
| DatamartSource _source_3 = definition.getSource(); |
| CubeType _cubeRef_1 = ((DatamartCube) _source_3).getCubeRef(); |
| CubeTypeEntity _cubeTypeEntity_1 = _cubeRef_1.getCubeTypeEntity(); |
| CubeEntity _entityRef = _cubeTypeEntity_1.getEntityRef(); |
| final LEntity entity = _entityRef.getEntityValue(); |
| EList<JvmMember> _members_10 = type.getMembers(); |
| JvmTypeReference _typeRef_18 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_10 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return \""); |
| String _persistenceUnit = ((LEntity) entity).getPersistenceUnit(); |
| _builder.append(_persistenceUnit, ""); |
| _builder.append("\";"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(definition, "getPersistenceUnit", _typeRef_18, _function_10); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10); |
| EList<JvmMember> _members_11 = type.getMembers(); |
| JvmTypeReference _typeRef_19 = this._typeReferenceBuilder.typeRef(RolapConnection.class); |
| final Procedure1<JvmOperation> _function_11 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("if (connection == null) { \t\t\t"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("connection = "); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getPersistenceService().getMondrianConnection(getPersistenceUnit(), \""); |
| DatamartSource _source = definition.getSource(); |
| CubeType _cubeRef = ((DatamartCube) _source).getCubeRef(); |
| EObject _eContainer = _cubeRef.eContainer(); |
| QualifiedName _fullyQualifiedName = DatamartDSLJvmModelInferrer.this._iQualifiedNameProvider.getFullyQualifiedName(((CubePackage) _eContainer)); |
| _builder.append(_fullyQualifiedName, "\t\t"); |
| _builder.append("\");"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getPersistenceService().registerPersistenceUnit(getPersistenceUnit(), "); |
| QualifiedName _fullyQualifiedName_1 = DatamartDSLJvmModelInferrer.this._iQualifiedNameProvider.getFullyQualifiedName(((LEntity) entity)); |
| _builder.append(_fullyQualifiedName_1, "\t\t"); |
| _builder.append(".class);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("} catch (SQLException e) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("log.error(e.getLocalizedMessage());"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("return (connection);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("return (connection);"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(definition, "connect", _typeRef_19, _function_11); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11); |
| EList<JvmMember> _members_12 = type.getMembers(); |
| JvmTypeReference _typeRef_20 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_12 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("if (connection != null) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("connection.close();"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("connection = null;"); |
| _builder.newLine(); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_12 = this._jvmTypesBuilder.toMethod(definition, "disconnect", _typeRef_20, _function_12); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_12, _method_12); |
| JvmTypeReference _typeRef_21 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_22 = this._typeReferenceBuilder.typeRef(IDualData.class); |
| JvmTypeReference _typeRef_23 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_22); |
| JvmTypeReference _typeRef_24 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_21, _typeRef_23); |
| final Procedure1<JvmOperation> _function_13 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("filterItems.clear();"); |
| _builder.newLine(); |
| _builder.append("connect();"); |
| _builder.newLine(); |
| _builder.append("if (connection != null) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("for (String filterID : getFilterIds()) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("DerivedCellSet cellSet = new DerivedCellSet("); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getPersistenceService().sendQuery(connection,getFilter(filterID)),"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t\t"); |
| _builder.append(".getDSLMetadataService(),"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t\t"); |
| _builder.append("user);"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("List<DerivedAxis> axes = cellSet.getAxes();"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("DerivedAxis columnsAxis = axes.get(Axis.COLUMNS.ordinal());"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("ArrayList<IDualData> filterItemList = new ArrayList<IDualData>();"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("for (DerivedPosition position : columnsAxis.getPositions()) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("DerivedMember measure = position.getMembers().get(0);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("IDualData data = new DatamartData();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("data.setUnformattedValue(measure.getUniqueName());"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("filterItemList.add(data);"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("filterItems.put(filterID, filterItemList);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("disconnect();"); |
| _builder.newLine(); |
| _builder.append("return filterItems;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_13 = this._jvmTypesBuilder.toMethod(definition, "getFilters", _typeRef_24, _function_13); |
| operation = _method_13; |
| EList<JvmMember> _members_13 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_13, operation); |
| JvmTypeReference _typeRef_25 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_14 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_2 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Map.class, _typeRef, _typeRef_1); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "filteredItems", _typeRef_2); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("String filteredStatement = statement;"); |
| _builder.newLine(); |
| _builder.append("for (String filterID : filteredItems.keySet()) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("String filterValue = filteredItems.get(filterID).replace(\"\'\",\"\");"); |
| _builder.newLine(); |
| _builder.append("\t \t"); |
| _builder.append("filteredStatement = filteredStatement.replace(filterID, filterValue);"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("filteredStatement = filteredStatement.replace(\"<empty>,\",\"\").replace(\",<empty>\",\"\").replace(\"<empty>\",\"\");"); |
| _builder.newLine(); |
| _builder.append("log.debug(\""); |
| String _name = definition.getName(); |
| _builder.append(_name, ""); |
| _builder.append(":\"+filteredStatement);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("return filteredStatement;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_14 = this._jvmTypesBuilder.toMethod(definition, "setFilters", _typeRef_25, _function_14); |
| operation = _method_14; |
| EList<JvmMember> _members_14 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_14, operation); |
| EList<JvmMember> _members_15 = type.getMembers(); |
| JvmTypeReference _typeRef_26 = this._typeReferenceBuilder.typeRef(DerivedCellSet.class); |
| final Procedure1<JvmOperation> _function_15 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_2 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_3 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Map.class, _typeRef_1, _typeRef_2); |
| JvmFormalParameter _parameter_1 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "filteredItems", _typeRef_3); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| EList<JvmFormalParameter> _parameters_2 = it.getParameters(); |
| JvmTypeReference _typeRef_4 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Class.class); |
| JvmFormalParameter _parameter_2 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "operativeDtoClass", _typeRef_4); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2); |
| EList<JvmFormalParameter> _parameters_3 = it.getParameters(); |
| JvmTypeReference _typeRef_5 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IDto.class); |
| JvmTypeReference _typeRef_6 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(List.class, _typeRef_5); |
| JvmFormalParameter _parameter_3 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "operativeDtos", _typeRef_6); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_3, _parameter_3); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("DerivedCellSet derivedCellSet = null;"); |
| _builder.newLine(); |
| _builder.append("connect();"); |
| _builder.newLine(); |
| _builder.append("if (connection != null) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("derivedCellSet = new DerivedCellSet("); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t"); |
| _builder.append(".getPersistenceService().sendQuery(connection, setFilters(filteredItems)),"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t\t"); |
| _builder.append(".getDSLMetadataService(),"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t\t"); |
| _builder.append("user);"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("disconnect();"); |
| _builder.newLine(); |
| _builder.append("return derivedCellSet;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_15 = this._jvmTypesBuilder.toMethod(definition, "getResults", _typeRef_26, _function_15); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_15, _method_15); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("Test"); |
| String _name_1 = definition.getName(); |
| _builder_1.append(_name_1, ""); |
| JvmTypeReference _typeRef_27 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_16 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setStatic(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = definition.getName(); |
| _builder.append(_name, ""); |
| _builder.append("Datamart "); |
| String _name_1 = definition.getName(); |
| String _lowerCase = _name_1.toLowerCase(); |
| _builder.append(_lowerCase, ""); |
| _builder.append(" = new "); |
| String _name_2 = definition.getName(); |
| _builder.append(_name_2, ""); |
| _builder.append("Datamart();"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("HashMap<String,String> filteredItems = new HashMap<String,String>();"); |
| _builder.newLine(); |
| _builder.append("if ("); |
| String _name_3 = definition.getName(); |
| String _lowerCase_1 = _name_3.toLowerCase(); |
| _builder.append(_lowerCase_1, ""); |
| _builder.append(".getFiltersCount() > 0) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| String _name_4 = definition.getName(); |
| String _lowerCase_2 = _name_4.toLowerCase(); |
| _builder.append(_lowerCase_2, "\t"); |
| _builder.append(".getFilters(null);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("for (String filterID : "); |
| String _name_5 = definition.getName(); |
| String _lowerCase_3 = _name_5.toLowerCase(); |
| _builder.append(_lowerCase_3, "\t"); |
| _builder.append(".filterItems.keySet()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("filteredItems.put(filterID, "); |
| String _name_6 = definition.getName(); |
| String _lowerCase_4 = _name_6.toLowerCase(); |
| _builder.append(_lowerCase_4, "\t\t"); |
| _builder.append(".filterItems.get(filterID).iterator().next().getSelectionValue());"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("DerivedCellSet cellset = "); |
| String _name_7 = definition.getName(); |
| String _lowerCase_5 = _name_7.toLowerCase(); |
| _builder.append(_lowerCase_5, ""); |
| _builder.append(".getResults(new User(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, ""); |
| _builder.append("\"), filteredItems, null, null);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("org.junit.Assert.assertNotNull(cellset);"); |
| _builder.newLine(); |
| String _name_8 = definition.getName(); |
| String _lowerCase_6 = _name_8.toLowerCase(); |
| _builder.append(_lowerCase_6, ""); |
| _builder.append(".disconnect();"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_16 = this._jvmTypesBuilder.toMethod(definition, _builder_1.toString(), _typeRef_27, _function_16); |
| operation = _method_16; |
| JvmTypeReference _typeRef_28 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| operation.setReturnType(_typeRef_28); |
| JvmAnnotationReference annRef_1 = this._annotationTypesBuilder.annotationRef(Test.class); |
| EList<JvmAnnotationReference> _annotations_1 = operation.getAnnotations(); |
| _annotations_1.add(annRef_1); |
| EList<JvmMember> _members_16 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_16, operation); |
| } |
| } |
| DatamartSource _source_4 = definition.getSource(); |
| if ((_source_4 instanceof DatamartEntity)) { |
| EList<JvmMember> _members_17 = type.getMembers(); |
| JvmTypeReference _typeRef_29 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_17 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return \""); |
| DatamartSource _source = definition.getSource(); |
| LEntity _entityRef = null; |
| if (((DatamartEntity) _source)!=null) { |
| _entityRef=((DatamartEntity) _source).getEntityRef(); |
| } |
| String _persistenceUnit = null; |
| if (_entityRef!=null) { |
| _persistenceUnit=_entityRef.getPersistenceUnit(); |
| } |
| _builder.append(_persistenceUnit, ""); |
| _builder.append("\";"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_17 = this._jvmTypesBuilder.toMethod(definition, "getPersistenceUnit", _typeRef_29, _function_17); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_17, _method_17); |
| EList<JvmMember> _members_18 = type.getMembers(); |
| JvmTypeReference _typeRef_30 = this._typeReferenceBuilder.typeRef(Connection.class); |
| final Procedure1<JvmOperation> _function_18 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("if (connection == null) { \t\t\t"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("connection = "); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getPersistenceService().getPersistenceUnitConnection(getPersistenceUnit());"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getPersistenceService().registerPersistenceUnit(getPersistenceUnit(), "); |
| DatamartSource _source = definition.getSource(); |
| LEntity _entityRef = null; |
| if (((DatamartEntity) _source)!=null) { |
| _entityRef=((DatamartEntity) _source).getEntityRef(); |
| } |
| QualifiedName _fullyQualifiedName = null; |
| if (_entityRef!=null) { |
| _fullyQualifiedName=DatamartDSLJvmModelInferrer.this._iQualifiedNameProvider.getFullyQualifiedName(_entityRef); |
| } |
| _builder.append(_fullyQualifiedName, "\t\t"); |
| _builder.append(".class);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("} catch (SQLException e) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("log.error(e.getLocalizedMessage());"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("return (connection);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("return (connection);"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_18 = this._jvmTypesBuilder.toMethod(definition, "connect", _typeRef_30, _function_18); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_18, _method_18); |
| EList<JvmMember> _members_19 = type.getMembers(); |
| JvmTypeReference _typeRef_31 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_19 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("if (connection != null) { \t\t\t"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("connection.close();"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("connection = null;"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("} catch (SQLException e) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("log.error(e.getLocalizedMessage());"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_19 = this._jvmTypesBuilder.toMethod(definition, "disconnect", _typeRef_31, _function_19); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_19, _method_19); |
| JvmTypeReference _typeRef_32 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_33 = this._typeReferenceBuilder.typeRef(IDualData.class); |
| JvmTypeReference _typeRef_34 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_33); |
| JvmTypeReference _typeRef_35 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_32, _typeRef_34); |
| final Procedure1<JvmOperation> _function_20 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("filterItems.clear();"); |
| _builder.newLine(); |
| _builder.append("connect();"); |
| _builder.newLine(); |
| _builder.append("if (connection != null) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("for (String filterID : getFilterIds()) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("if (!getFilter(filterID).contains(\""); |
| _builder.append(IDataMart.filterIdPlaceholder, "\t\t\t"); |
| _builder.append("\")) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("ArrayList<IDualData> filterItemList = new ArrayList<IDualData>();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("ResultSet rs = connection.createStatement().executeQuery(getFilter(filterID));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("if (rs != null) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t"); |
| _builder.append("while (rs.next()) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t"); |
| _builder.append("int type = rs.getMetaData().getColumnType(1);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t"); |
| _builder.append("IDualData data = new DatamartData();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t"); |
| _builder.append("switch (type) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.DATE:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setSelectionValue(\"to_date(\'\"+rs.getDate(1).toString().replace(\".0\",\"\")+\"\',\'YYYY-MM-DD HH24:MI:SS\')\");"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("if (user == null) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setUnformattedValue(rs.getDate(1).toString());"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("} else {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t\t"); |
| _builder.append("data.setUnformattedValue(SimpleDateFormatter.getFormat(\"LONGDATE\", user.getLocale()).format(rs.getDate(1)));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("break;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.TIMESTAMP:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setSelectionValue(\"to_timestamp(\'\"+rs.getTimestamp(1).toString().replace(\".0\",\"\")+\"\',\'YYYY-MM-DD HH24:MI:SS\')\");"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("if (user == null) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setUnformattedValue(rs.getDate(1).toString());"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("} else {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setUnformattedValue(SimpleDateFormatter.getFormat(\"LONGDATE\", user.getLocale()).format(rs.getTimestamp(1)));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t \t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("break;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.DECIMAL:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setUnformattedValue(rs.getBigDecimal(1).toPlainString());"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setSelectionValue(rs.getBigDecimal(1).toPlainString());"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("break;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.NUMERIC:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.DOUBLE:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setUnformattedValue(Double.toString(rs.getDouble(1)));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setSelectionValue(Double.toString(rs.getDouble(1)));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("break;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.FLOAT:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setUnformattedValue(Float.toString(rs.getFloat(1)));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setSelectionValue(Float.toString(rs.getFloat(1)));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("break;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.CHAR:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.NCHAR:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.NVARCHAR:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t"); |
| _builder.append("case java.sql.Types.VARCHAR:"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setUnformattedValue(rs.getString(1));"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("data.setSelectionValue(\"\'\"+rs.getString(1)+\"\'\");"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t\t\t"); |
| _builder.append("break;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t \t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t\t"); |
| _builder.append("filterItemList.add(data);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t"); |
| _builder.append("rs.close();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t"); |
| _builder.append("filterItems.put(filterID, filterItemList);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("} catch (SQLException e) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("log.error(e.getLocalizedMessage());"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("disconnect();"); |
| _builder.newLine(); |
| _builder.append("return filterItems;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_20 = this._jvmTypesBuilder.toMethod(definition, "getFilters", _typeRef_35, _function_20); |
| operation = _method_20; |
| EList<JvmMember> _members_20 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_20, operation); |
| JvmTypeReference _typeRef_36 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_21 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_2 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_3 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Map.class, _typeRef_1, _typeRef_2); |
| JvmFormalParameter _parameter_1 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "filteredItems", _typeRef_3); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("String filteredStatement = \"\";"); |
| _builder.newLine(); |
| { |
| EList<DatamartRole> _roles = definition.getRoles(); |
| int _size = _roles.size(); |
| boolean _greaterThan = (_size > 0); |
| if (_greaterThan) { |
| _builder.append("if (user == null || "); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("user.getUserName().equals(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, "\t"); |
| _builder.append("\") ||"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t"); |
| _builder.append(".getUserAccessService().getRoles() == null) "); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("{"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("filteredStatement = statements.get(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, "\t"); |
| _builder.append("\");"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("else {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("// find the role with the biggest statement of authorized items"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("String bestRole = null;"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("int bestSize = -1;"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("for(String role:"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t"); |
| _builder.append(".getUserAccessService().getRoles()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("if (statements.containsKey(role)) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("if (bestSize < statements.get(role).length()) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("bestSize = statements.get(role).length();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("bestRole = role;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("if (bestRole != null) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("filteredStatement = statements.get(bestRole);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| } else { |
| _builder.append("filteredStatement = statements.get(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, ""); |
| _builder.append("\");"); |
| _builder.newLineIfNotEmpty(); |
| } |
| } |
| _builder.append("for (String filterID : filteredItems.keySet()) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("String filterValue = filteredItems.get(filterID);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("if (filterID.endsWith(\".id$\")) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("if\t(!filteredStatement.toLowerCase().contains(\" where \")) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("if\t((\" \"+filterValue).toLowerCase().contains(\"where \")) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("filteredStatement += \" \"+filterValue;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("else {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("filteredStatement += \" where \"+filterValue;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("else {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("if\t(filterValue.trim().toLowerCase().startsWith(\"and \") ||"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t "); |
| _builder.append("filterValue.trim().toLowerCase().startsWith(\"or \") ) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("filteredStatement += filterValue;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("else {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("filteredStatement += \" and \"+filterValue;"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("else {"); |
| _builder.newLine(); |
| _builder.append("\t \t"); |
| _builder.append("filteredStatement = filteredStatement.replace(filterID, filterValue);"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("log.debug(\""); |
| String _name = definition.getName(); |
| _builder.append(_name, ""); |
| _builder.append(":\"+filteredStatement);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("return filteredStatement;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_21 = this._jvmTypesBuilder.toMethod(definition, "setFilters", _typeRef_36, _function_21); |
| operation = _method_21; |
| EList<JvmMember> _members_21 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_21, operation); |
| EList<JvmMember> _members_22 = type.getMembers(); |
| JvmTypeReference _typeRef_37 = this._typeReferenceBuilder.typeRef(DerivedCellSet.class); |
| final Procedure1<JvmOperation> _function_22 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IUser.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "user", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_2 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_3 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Map.class, _typeRef_1, _typeRef_2); |
| JvmFormalParameter _parameter_1 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "filteredItems", _typeRef_3); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| EList<JvmFormalParameter> _parameters_2 = it.getParameters(); |
| JvmTypeReference _typeRef_4 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Class.class); |
| JvmFormalParameter _parameter_2 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "operativeDtoClass", _typeRef_4); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2); |
| EList<JvmFormalParameter> _parameters_3 = it.getParameters(); |
| JvmTypeReference _typeRef_5 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IDto.class); |
| JvmTypeReference _typeRef_6 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(List.class, _typeRef_5); |
| JvmFormalParameter _parameter_3 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "operativeDtos", _typeRef_6); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_3, _parameter_3); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("ResultSet rs = null;"); |
| _builder.newLine(); |
| _builder.append("SqlCellSet cellSet = null;"); |
| _builder.newLine(); |
| _builder.append("java.sql.ResultSetMetaData metaData = null;"); |
| _builder.newLine(); |
| _builder.append("// --- if filler text is enabled ---"); |
| _builder.newLine(); |
| _builder.append("if\t(fFillerTextEnabled) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("// --- try to generate filler text ---"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("rs = generateFillerTextResultSet();"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("// --- if no result set is generated by now ---"); |
| _builder.newLine(); |
| _builder.append("connect();"); |
| _builder.newLine(); |
| _builder.append("if (rs == null) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("if (connection != null) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("String query = setFilters(user, filteredItems);"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("if (query.length()>0) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("rs = connection.createStatement().executeQuery(query);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("} catch (SQLException e) {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("log.error(\"Query: \"+query);"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t"); |
| _builder.append("log.error(e.getLocalizedMessage());"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("if (rs != null) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("cellSet = new SqlCellSet(rs, getAxisMap(), getIdMap(), datamartDtoMapper, operativeDtoClass, operativeDtos);"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("metaData = rs.getMetaData();"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("catch (java.sql.SQLException e) {"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t\t\t"); |
| _builder.append("log.error(\"Statement: \"+rs.getStatement().toString());"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("} catch (SQLException e1) {}"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("log.error(e.getLocalizedMessage());"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("disconnect();"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("return (new DerivedCellSet(cellSet,"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append("metaData,"); |
| _builder.newLine(); |
| _builder.append("\t\t"); |
| _builder.append(DatamartDSLJvmModelInferrer.this.binderClassName, "\t\t"); |
| _builder.append(".getDSLMetadataService(), user));"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("disconnect();"); |
| _builder.newLine(); |
| _builder.append("return null;"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_22 = this._jvmTypesBuilder.toMethod(definition, "getResults", _typeRef_37, _function_22); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_22, _method_22); |
| EList<JvmMember> _members_23 = type.getMembers(); |
| DatamartSource _source_5 = definition.getSource(); |
| this.addFillerTextMethods(_members_23, definition, ((DatamartEntity) _source_5)); |
| EList<JvmMember> _members_24 = type.getMembers(); |
| JvmTypeReference _typeRef_38 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_23 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IEntityIdModificationListenerView.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "listeningView", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(DerivedCellSet.class); |
| JvmFormalParameter _parameter_1 = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "cellSet", _typeRef_1); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("super.addEntityIdsToModifyListener(listeningView, cellSet);"); |
| _builder.newLine(); |
| _builder.append("// @TODO: 1) check for listenenView != null"); |
| _builder.newLine(); |
| _builder.append("// @TODO: 2) extract all entity & id (= primary key)"); |
| _builder.newLine(); |
| _builder.append("// @TODO: 3) for each tuple call listenenView.addEntityIdToModifyListener(entityName, primaryKey);"); |
| _builder.newLine(); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_23 = this._jvmTypesBuilder.toMethod(definition, "addEntityIdsToModifyListener", _typeRef_38, _function_23); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_24, _method_23); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("Test"); |
| String _name_2 = definition.getName(); |
| _builder_2.append(_name_2, ""); |
| JvmTypeReference _typeRef_39 = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function_24 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setStatic(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = definition.getName(); |
| _builder.append(_name, ""); |
| _builder.append("Datamart "); |
| String _name_1 = definition.getName(); |
| String _lowerCase = _name_1.toLowerCase(); |
| _builder.append(_lowerCase, ""); |
| _builder.append(" = new "); |
| String _name_2 = definition.getName(); |
| _builder.append(_name_2, ""); |
| _builder.append("Datamart();"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("HashMap<String,String> filteredItems = new HashMap<String,String>();"); |
| _builder.newLine(); |
| _builder.append("if ("); |
| String _name_3 = definition.getName(); |
| String _lowerCase_1 = _name_3.toLowerCase(); |
| _builder.append(_lowerCase_1, ""); |
| _builder.append(".getFiltersCount() > 0) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| String _name_4 = definition.getName(); |
| String _lowerCase_2 = _name_4.toLowerCase(); |
| _builder.append(_lowerCase_2, "\t"); |
| _builder.append(".getFilters(null);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("for (String filterID : "); |
| String _name_5 = definition.getName(); |
| String _lowerCase_3 = _name_5.toLowerCase(); |
| _builder.append(_lowerCase_3, "\t"); |
| _builder.append(".filterItems.keySet()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("filteredItems.put(filterID, "); |
| String _name_6 = definition.getName(); |
| String _lowerCase_4 = _name_6.toLowerCase(); |
| _builder.append(_lowerCase_4, "\t\t"); |
| _builder.append(".filterItems.get(filterID).iterator().next().getSelectionValue());"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("DerivedCellSet cellset = "); |
| String _name_7 = definition.getName(); |
| String _lowerCase_5 = _name_7.toLowerCase(); |
| _builder.append(_lowerCase_5, ""); |
| _builder.append(".getResults(new User(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, ""); |
| _builder.append("\"), filteredItems, null, null);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("org.junit.Assert.assertNotNull(cellset);"); |
| _builder.newLine(); |
| String _name_8 = definition.getName(); |
| String _lowerCase_6 = _name_8.toLowerCase(); |
| _builder.append(_lowerCase_6, ""); |
| _builder.append(".disconnect();"); |
| it.append(_builder); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_24 = this._jvmTypesBuilder.toMethod(definition, _builder_2.toString(), _typeRef_39, _function_24); |
| operation = _method_24; |
| JvmTypeReference _typeRef_40 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| operation.setReturnType(_typeRef_40); |
| JvmAnnotationReference annRef_2 = this._annotationTypesBuilder.annotationRef(Test.class); |
| EList<JvmAnnotationReference> _annotations_2 = operation.getAnnotations(); |
| _annotations_2.add(annRef_2); |
| EList<JvmMember> _members_25 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_25, operation); |
| } |
| } |
| |
| public int getGetNumAxes(final DatamartDefinition definition) { |
| int numAxes = 0; |
| DatamartSource _source = definition.getSource(); |
| if ((_source instanceof DatamartCube)) { |
| DatamartSource _source_1 = definition.getSource(); |
| EList<DatamartCubeElement> _axisslicer = ((DatamartCube) _source_1).getAxisslicer(); |
| for (final DatamartCubeElement axisslicer : _axisslicer) { |
| if ((axisslicer instanceof DatamartAxis)) { |
| numAxes = (numAxes + 1); |
| } |
| } |
| } else { |
| DatamartSource _source_2 = definition.getSource(); |
| if ((_source_2 instanceof DatamartTask)) { |
| numAxes = 2; |
| } else { |
| DatamartSource _source_3 = definition.getSource(); |
| if ((_source_3 instanceof DatamartEntity)) { |
| DatamartSource _source_4 = definition.getSource(); |
| int _entityNumAxes = this.getEntityNumAxes(((DatamartEntity) _source_4), 0); |
| numAxes = _entityNumAxes; |
| } |
| } |
| } |
| return numAxes; |
| } |
| |
| public int getEntityNumAxes(final DatamartEntity entity, final int num) { |
| int numAxes = num; |
| EList<DatamartProperty> _properties = entity.getProperties(); |
| for (final DatamartProperty property : _properties) { |
| AxisEnum _axis = property.getAxis(); |
| int _value = _axis.getValue(); |
| int _plus = (_value + 1); |
| boolean _greaterThan = (_plus > num); |
| if (_greaterThan) { |
| AxisEnum _axis_1 = property.getAxis(); |
| int _value_1 = _axis_1.getValue(); |
| int _plus_1 = (_value_1 + 1); |
| numAxes = _plus_1; |
| } |
| } |
| EList<DatamartNavigation> _navigations = entity.getNavigations(); |
| for (final DatamartNavigation navigation : _navigations) { |
| DatamartEntity _datamartEntity = navigation.getDatamartEntity(); |
| int _entityNumAxes = this.getEntityNumAxes(_datamartEntity, numAxes); |
| numAxes = _entityNumAxes; |
| } |
| return numAxes; |
| } |
| |
| public boolean addFillerTextMethods(final EList<JvmMember> list, final DatamartDefinition definition, final DatamartEntity entity) { |
| boolean _xifexpression = false; |
| boolean _and = false; |
| boolean _and_1 = false; |
| int _fillerMinCountRows = entity.getFillerMinCountRows(); |
| boolean _greaterThan = (_fillerMinCountRows > 0); |
| if (!_greaterThan) { |
| _and_1 = false; |
| } else { |
| int _fillerMaxCountRows = entity.getFillerMaxCountRows(); |
| boolean _greaterThan_1 = (_fillerMaxCountRows > 0); |
| _and_1 = _greaterThan_1; |
| } |
| if (!_and_1) { |
| _and = false; |
| } else { |
| EList<PropertyFillerData> _fillerDatas = entity.getFillerDatas(); |
| boolean _isEmpty = _fillerDatas.isEmpty(); |
| boolean _not = (!_isEmpty); |
| _and = _not; |
| } |
| if (_and) { |
| boolean _xblockexpression = false; |
| { |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(FillerTextResultSet.class); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("FillerTextResultSet rs = new FillerTextResultSet(this, "); |
| int _fillerMinCountRows = entity.getFillerMinCountRows(); |
| _builder.append(_fillerMinCountRows, ""); |
| _builder.append(", "); |
| int _fillerMaxCountRows = entity.getFillerMaxCountRows(); |
| _builder.append(_fillerMaxCountRows, ""); |
| _builder.append(");"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| EList<PropertyFillerData> _fillerDatas = entity.getFillerDatas(); |
| for (final PropertyFillerData data : _fillerDatas) { |
| { |
| String className = "String.class"; |
| String typeName = "java.sql.Types.CHAR"; |
| PropertyFillerType type = data.getFillerType(); |
| boolean _matched = false; |
| if (!_matched) { |
| if (type instanceof PropertyFillerDateType) { |
| _matched=true; |
| className = "Timestamp.class"; |
| typeName = "java.sql.Types.TIMESTAMP"; |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerDoubleType) { |
| _matched=true; |
| className = "BigDecimal.class"; |
| typeName = "java.sql.Types.DECIMAL"; |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerIntegerType) { |
| _matched=true; |
| className = "BigDecimal.class"; |
| typeName = "java.sql.Types.DECIMAL"; |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerTextType) { |
| _matched=true; |
| } |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("rs.addColumn(\""); |
| LEntityAttribute _propertyRef = data.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| _builder_1.append(className, ""); |
| _builder_1.append(", null, "); |
| _builder_1.append(typeName, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return rs;"); |
| it.append(_builder_1); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(definition, "generateFillerTextResultSet", _typeRef, _function); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(list, _method); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(String.class); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(Object.class); |
| JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Map.class, _typeRef_1, _typeRef_2); |
| final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DatamartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(FillerTextProvider.class); |
| JvmFormalParameter _parameter = DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(definition, "provider", _typeRef); |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("Map<String,Object> rowData = new HashMap<>();"); |
| _builder.newLine(); |
| it.append(_builder); |
| EList<PropertyFillerData> _fillerDatas = entity.getFillerDatas(); |
| for (final PropertyFillerData data : _fillerDatas) { |
| { |
| String fillerTextMethod = "TO_BE_IMPLEMENTED"; |
| PropertyFillerType type = data.getFillerType(); |
| boolean _matched = false; |
| if (!_matched) { |
| if (type instanceof PropertyFillerDateFuture) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("new Timestamp(provider.date(0,"); |
| int _dateFutureYears = ((PropertyFillerDateFuture)type).getDateFutureYears(); |
| _builder_1.append(_dateFutureYears, ""); |
| _builder_1.append(").getTime())"); |
| fillerTextMethod = _builder_1.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerDatePast) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("new Timestamp(provider.date(-"); |
| int _datePastYears = ((PropertyFillerDatePast)type).getDatePastYears(); |
| _builder_1.append(_datePastYears, ""); |
| _builder_1.append(",0).getTime())"); |
| fillerTextMethod = _builder_1.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerDateRange) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("new Timestamp(provider.date("); |
| int _dateBeginYears = ((PropertyFillerDateRange)type).getDateBeginYears(); |
| _builder_1.append(_dateBeginYears, ""); |
| _builder_1.append(","); |
| int _dateEndYears = ((PropertyFillerDateRange)type).getDateEndYears(); |
| _builder_1.append(_dateEndYears, ""); |
| _builder_1.append(").getTime())"); |
| fillerTextMethod = _builder_1.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerSignedDoubleRange) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerSignedDoubleRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerSignedDoubleRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\")).doubleValue()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\")).doubleValue()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("new BigDecimal(provider.signeddouble("); |
| int _decimals = ((PropertyFillerSignedDoubleRange)type).getDecimals(); |
| _builder_5.append(_decimals, ""); |
| _builder_5.append(","); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(","); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(","); |
| double _rounded = ((PropertyFillerSignedDoubleRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append("))"); |
| fillerTextMethod = _builder_5.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerSignedDoubleRandom) { |
| _matched=true; |
| List<String> items = new ArrayList<String>(); |
| EList<Double> _items = ((PropertyFillerSignedDoubleRandom)type).getItems(); |
| for (final Double item : _items) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(item, ""); |
| items.add(_builder_1.toString()); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("double[] "); |
| LEntityAttribute _propertyRef = data.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder_2.append(_name, ""); |
| _builder_2.append("_items = {"); |
| String _join = StringUtils.join(items, ","); |
| _builder_2.append(_join, ""); |
| _builder_2.append("};"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("new BigDecimal("); |
| LEntityAttribute _propertyRef_1 = data.getPropertyRef(); |
| String _name_1 = _propertyRef_1.getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items[provider.unsignedinteger("); |
| EList<Double> _items_1 = ((PropertyFillerSignedDoubleRandom)type).getItems(); |
| int _size = _items_1.size(); |
| int _minus = (_size - 1); |
| _builder_3.append(_minus, ""); |
| _builder_3.append(")])"); |
| fillerTextMethod = _builder_3.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerSignedIntegerRange) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerSignedIntegerRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerSignedIntegerRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\")).intValue()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\")).intValue()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("new BigDecimal(provider.signedinteger("); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(","); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(","); |
| int _rounded = ((PropertyFillerSignedIntegerRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append("))"); |
| fillerTextMethod = _builder_5.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerSignedIntegerRandom) { |
| _matched=true; |
| List<String> items = new ArrayList<String>(); |
| EList<Integer> _items = ((PropertyFillerSignedIntegerRandom)type).getItems(); |
| for (final Integer item : _items) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(item, ""); |
| items.add(_builder_1.toString()); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("int[] "); |
| LEntityAttribute _propertyRef = data.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder_2.append(_name, ""); |
| _builder_2.append("_items = {"); |
| String _join = StringUtils.join(items, ","); |
| _builder_2.append(_join, ""); |
| _builder_2.append("};"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("new BigDecimal("); |
| LEntityAttribute _propertyRef_1 = data.getPropertyRef(); |
| String _name_1 = _propertyRef_1.getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items[provider.unsignedinteger("); |
| EList<Integer> _items_1 = ((PropertyFillerSignedIntegerRandom)type).getItems(); |
| int _size = _items_1.size(); |
| int _minus = (_size - 1); |
| _builder_3.append(_minus, ""); |
| _builder_3.append(")])"); |
| fillerTextMethod = _builder_3.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerTextRandom) { |
| _matched=true; |
| List<String> items = new ArrayList<String>(); |
| EList<String> _items = ((PropertyFillerTextRandom)type).getItems(); |
| for (final String item : _items) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("\""); |
| _builder_1.append(item, ""); |
| _builder_1.append("\""); |
| items.add(_builder_1.toString()); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("Object[] "); |
| LEntityAttribute _propertyRef = data.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder_2.append(_name, ""); |
| _builder_2.append("_items = {"); |
| String _join = StringUtils.join(items, ","); |
| _builder_2.append(_join, ""); |
| _builder_2.append("};"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| LEntityAttribute _propertyRef_1 = data.getPropertyRef(); |
| String _name_1 = _propertyRef_1.getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items[provider.unsignedinteger("); |
| EList<String> _items_1 = ((PropertyFillerTextRandom)type).getItems(); |
| int _size = _items_1.size(); |
| int _minus = (_size - 1); |
| _builder_3.append(_minus, ""); |
| _builder_3.append(")]"); |
| fillerTextMethod = _builder_3.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerTextParagraphs) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("provider.paragraphs("); |
| int _count = ((PropertyFillerTextParagraphs)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(")"); |
| fillerTextMethod = _builder_1.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerTextSentences) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("provider.sentences("); |
| int _count = ((PropertyFillerTextSentences)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(")"); |
| fillerTextMethod = _builder_1.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerTextWords) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("provider.words("); |
| int _count = ((PropertyFillerTextWords)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(")"); |
| fillerTextMethod = _builder_1.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerUnsignedDoubleRange) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerUnsignedDoubleRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerUnsignedDoubleRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\")).doubleValue()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\")).doubleValue()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("new BigDecimal(provider.unsigneddouble("); |
| int _decimals = ((PropertyFillerUnsignedDoubleRange)type).getDecimals(); |
| _builder_5.append(_decimals, ""); |
| _builder_5.append(","); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(","); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(","); |
| double _rounded = ((PropertyFillerUnsignedDoubleRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append("))"); |
| fillerTextMethod = _builder_5.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerUnsignedDoubleRandom) { |
| _matched=true; |
| List<String> items = new ArrayList<String>(); |
| EList<Double> _items = ((PropertyFillerUnsignedDoubleRandom)type).getItems(); |
| for (final Double item : _items) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(item, ""); |
| items.add(_builder_1.toString()); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("double[] "); |
| LEntityAttribute _propertyRef = data.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder_2.append(_name, ""); |
| _builder_2.append("_items = {"); |
| String _join = StringUtils.join(items, ","); |
| _builder_2.append(_join, ""); |
| _builder_2.append("};"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("new BigDecimal("); |
| LEntityAttribute _propertyRef_1 = data.getPropertyRef(); |
| String _name_1 = _propertyRef_1.getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items[provider.unsignedinteger("); |
| EList<Double> _items_1 = ((PropertyFillerUnsignedDoubleRandom)type).getItems(); |
| int _size = _items_1.size(); |
| int _minus = (_size - 1); |
| _builder_3.append(_minus, ""); |
| _builder_3.append(")])"); |
| fillerTextMethod = _builder_3.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerUnsignedIntegerRange) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerUnsignedIntegerRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerUnsignedIntegerRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\")).intValue()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("((BigDecimal)rowData.get(\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\")).intValue()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("new BigDecimal(provider.unsignedinteger("); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(","); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(","); |
| int _rounded = ((PropertyFillerUnsignedIntegerRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append("))"); |
| fillerTextMethod = _builder_5.toString(); |
| } |
| } |
| if (!_matched) { |
| if (type instanceof PropertyFillerUnsignedIntegerRandom) { |
| _matched=true; |
| List<String> items = new ArrayList<String>(); |
| EList<Integer> _items = ((PropertyFillerUnsignedIntegerRandom)type).getItems(); |
| for (final Integer item : _items) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(item, ""); |
| items.add(_builder_1.toString()); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("int[] "); |
| LEntityAttribute _propertyRef = data.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder_2.append(_name, ""); |
| _builder_2.append("_items = {"); |
| String _join = StringUtils.join(items, ","); |
| _builder_2.append(_join, ""); |
| _builder_2.append("};"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("new BigDecimal("); |
| LEntityAttribute _propertyRef_1 = data.getPropertyRef(); |
| String _name_1 = _propertyRef_1.getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items[provider.unsignedinteger("); |
| EList<Integer> _items_1 = ((PropertyFillerUnsignedIntegerRandom)type).getItems(); |
| int _size = _items_1.size(); |
| int _minus = (_size - 1); |
| _builder_3.append(_minus, ""); |
| _builder_3.append(")])"); |
| fillerTextMethod = _builder_3.toString(); |
| } |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("rowData.put(\""); |
| LEntityAttribute _propertyRef = data.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| _builder_1.append(fillerTextMethod, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return rowData;"); |
| it.append(_builder_1); |
| } |
| }; |
| DatamartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(definition, "generateFillerTextRow", _typeRef_3, _function_1); |
| _xblockexpression = this._jvmTypesBuilder.<JvmOperation>operator_add(list, _method_1); |
| } |
| _xifexpression = _xblockexpression; |
| } |
| return _xifexpression; |
| } |
| |
| /** |
| * <p>build the id map as lookup for primary key oriented applications.</p> |
| */ |
| public String createIdMap(final DatamartDefinition definition) { |
| String listTxt = ""; |
| Set<String> _keySet = this.idMap.keySet(); |
| for (final String idColumn : _keySet) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(listTxt, ""); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("put(\""); |
| _builder.append(idColumn, "\t\t"); |
| _builder.append("\", EType."); |
| LEntityAttribute _get = this.idMap.get(idColumn); |
| IDataMart.EType _basicType = this.dtType.getBasicType(_get); |
| _builder.append(_basicType, "\t\t"); |
| _builder.append(");"); |
| 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; |
| } |
| |
| /** |
| * <p>build the types map as lookup for datatypes.</p> |
| */ |
| public String createTypesMaps(final DatamartDefinition definition, final HashMap<String, LEntityAttribute> typesMap) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("put(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, ""); |
| _builder.append("\", new HashMap<String,EType>()"); |
| String _createTypesMap = this.createTypesMap(definition, null, typesMap); |
| _builder.append(_createTypesMap, ""); |
| _builder.append(");"); |
| String listTxt = _builder.toString(); |
| EList<DatamartRole> _roles = definition.getRoles(); |
| for (final DatamartRole role : _roles) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(listTxt, ""); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("put(\""); |
| Role _assignedRole = role.getAssignedRole(); |
| String _name = _assignedRole.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", new HashMap<String,EType>()"); |
| String _createTypesMap_1 = this.createTypesMap(definition, role, typesMap); |
| _builder_1.append(_createTypesMap_1, ""); |
| _builder_1.append(");"); |
| listTxt = _builder_1.toString(); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("{{"); |
| _builder_2.newLine(); |
| _builder_2.append("\t"); |
| _builder_2.append(listTxt, "\t"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("}}"); |
| listTxt = _builder_2.toString(); |
| return listTxt; |
| } |
| |
| /** |
| * <p>build the types map as lookup for datatypes according to authorization roles.</p> |
| */ |
| public String createTypesMap(final DatamartDefinition definition, final DatamartRole role, final HashMap<String, LEntityAttribute> typesMap) { |
| String listTxt = ""; |
| boolean _equals = Objects.equal(role, null); |
| if (_equals) { |
| Set<String> _keySet = typesMap.keySet(); |
| for (final String property : _keySet) { |
| { |
| LEntityAttribute _get = typesMap.get(property); |
| final IDataMart.EType type = this.dtType.getBasicType(_get); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(listTxt, ""); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("put(\""); |
| _builder.append(property, ""); |
| _builder.append("\", EType."); |
| String _string = type.toString(); |
| _builder.append(_string, ""); |
| _builder.append(");"); |
| listTxt = _builder.toString(); |
| } |
| } |
| } else { |
| Set<String> _keySet_1 = typesMap.keySet(); |
| for (final String property_1 : _keySet_1) { |
| boolean _isAuthorized = this.isAuthorized(role, property_1); |
| if (_isAuthorized) { |
| LEntityAttribute _get = typesMap.get(property_1); |
| final IDataMart.EType type = this.dtType.getBasicType(_get); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(listTxt, ""); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("put(\""); |
| _builder.append(property_1, ""); |
| _builder.append("\", EType."); |
| String _string = type.toString(); |
| _builder.append(_string, ""); |
| _builder.append(");"); |
| 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; |
| } |
| |
| /** |
| * <p>build the axis map.</p> |
| */ |
| public String createAxisMap(final DatamartDefinition definition) { |
| String text = ""; |
| HashMap<Integer, List<String>> map = CollectionLiterals.<Integer, List<String>>newHashMap(); |
| DatamartSource _source = definition.getSource(); |
| boolean _notEquals = (!Objects.equal(_source, null)); |
| if (_notEquals) { |
| DatamartSource _source_1 = definition.getSource(); |
| if ((_source_1 instanceof DatamartEntity)) { |
| DatamartSource _source_2 = definition.getSource(); |
| this.createAxisMap(((DatamartEntity) _source_2), map); |
| } |
| DatamartSource _source_3 = definition.getSource(); |
| if ((_source_3 instanceof DatamartTask)) { |
| DatamartSource _source_4 = definition.getSource(); |
| this.createAxisMap(((DatamartTask) _source_4), map); |
| } |
| } |
| Set<Integer> _keySet = map.keySet(); |
| for (final Integer axisNumber : _keySet) { |
| { |
| String listTxt = ""; |
| List<String> _get = map.get(axisNumber); |
| for (final String columnName : _get) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(listTxt, ""); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t\t"); |
| _builder.append("add(\""); |
| _builder.append(columnName, "\t\t"); |
| _builder.append("\");"); |
| listTxt = _builder.toString(); |
| } |
| boolean _and = false; |
| DatamartSource _source_5 = definition.getSource(); |
| if (!(_source_5 instanceof DatamartEntity)) { |
| _and = false; |
| } else { |
| _and = ((axisNumber).intValue() == AxisEnum.COLUMNS_VALUE); |
| } |
| if (_and) { |
| if ((!this.ignoreEntityGrouping)) { |
| Collection<LEntity> _values = this.entityGrouping.values(); |
| for (final LEntity entityRef : _values) { |
| { |
| String idColumn = DatamartDefinitionUtil.getEntityIdAliasName(entityRef); |
| boolean _notEquals_1 = (!Objects.equal(idColumn, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(listTxt, ""); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("\t\t"); |
| _builder_1.append("add(\""); |
| _builder_1.append(idColumn, "\t\t"); |
| _builder_1.append("\");"); |
| listTxt = _builder_1.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(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(text, ""); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("\t"); |
| _builder_2.append("put("); |
| _builder_2.append(axisNumber, "\t"); |
| _builder_2.append(",new ArrayList<String>() "); |
| _builder_2.append(listTxt, "\t"); |
| _builder_2.append(");"); |
| text = _builder_2.toString(); |
| } |
| } |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{{"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append(text, "\t"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("}}"); |
| text = _builder.toString(); |
| return text; |
| } |
| |
| /** |
| * <p>creates an axis map for tasks.</p> |
| */ |
| public void createAxisMap(final DatamartTask task, final HashMap<Integer, List<String>> map) { |
| EList<DatamartColumn> _columns = task.getColumns(); |
| for (final DatamartColumn column : _columns) { |
| { |
| int axisNumber = 0; |
| TaskQueryColumnEnum _columnRef = column.getColumnRef(); |
| String name = _columnRef.getLiteral(); |
| boolean found = false; |
| Set<Integer> _keySet = map.keySet(); |
| for (final Integer axNum : _keySet) { |
| if (((axNum).intValue() == axisNumber)) { |
| List<String> _get = map.get(axNum); |
| _get.add(name); |
| found = true; |
| } |
| } |
| if ((!found)) { |
| ArrayList<String> columns = CollectionLiterals.<String>newArrayList(); |
| columns.add(name); |
| map.put(Integer.valueOf(axisNumber), columns); |
| } |
| } |
| } |
| } |
| |
| public void recursAxisMap(final LScalarType type, final DatamartProperty property, final HashMap<Integer, List<String>> map, final int axisNumber) { |
| 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)) { |
| LScalarType _type_1 = attr.getType(); |
| this.recursAxisMap(_type_1, property, map, axisNumber); |
| } else { |
| String _name = attr.getName(); |
| this.addAxisProperty(_name, map, axisNumber); |
| } |
| } |
| } else { |
| LEntityAttribute _propertyRef = property.getPropertyRef(); |
| String _name_1 = _propertyRef.getName(); |
| this.addAxisProperty(_name_1, map, axisNumber); |
| } |
| } |
| |
| /** |
| * <p>recursively create an axis map for entities.</p> |
| */ |
| public void createAxisMap(final DatamartEntity entity, final HashMap<Integer, List<String>> map) { |
| EList<DatamartProperty> _properties = entity.getProperties(); |
| for (final DatamartProperty property : _properties) { |
| boolean _isPlaced = property.isPlaced(); |
| if (_isPlaced) { |
| int axisNumber = (-1); |
| AxisEnum _axis = property.getAxis(); |
| int _value = _axis.getValue(); |
| boolean _equals = (_value == (-1)); |
| if (_equals) { |
| axisNumber = 0; |
| } else { |
| AxisEnum _axis_1 = property.getAxis(); |
| int _value_1 = _axis_1.getValue(); |
| axisNumber = _value_1; |
| } |
| LEntityAttribute _propertyRef = property.getPropertyRef(); |
| LScalarType _type = _propertyRef.getType(); |
| LScalarType type = ((LScalarType) _type); |
| this.recursAxisMap(type, property, map, axisNumber); |
| } |
| } |
| EList<DatamartNavigation> _navigations = entity.getNavigations(); |
| for (final DatamartNavigation navigation : _navigations) { |
| DatamartEntity _datamartEntity = navigation.getDatamartEntity(); |
| this.createAxisMap(_datamartEntity, map); |
| } |
| } |
| |
| public List<String> addAxisProperty(final String name, final HashMap<Integer, List<String>> map, final int axisNumber) { |
| List<String> _xblockexpression = null; |
| { |
| boolean found = false; |
| Set<Integer> _keySet = map.keySet(); |
| for (final Integer axNum : _keySet) { |
| if (((axNum).intValue() == axisNumber)) { |
| List<String> _get = map.get(axNum); |
| String _string = name.toString(); |
| _get.add(_string); |
| found = true; |
| } |
| } |
| List<String> _xifexpression = null; |
| if ((!found)) { |
| List<String> _xblockexpression_1 = null; |
| { |
| ArrayList<String> columns = CollectionLiterals.<String>newArrayList(); |
| String _string_1 = name.toString(); |
| columns.add(_string_1); |
| _xblockexpression_1 = map.put(Integer.valueOf(axisNumber), columns); |
| } |
| _xifexpression = _xblockexpression_1; |
| } |
| _xblockexpression = _xifexpression; |
| } |
| return _xblockexpression; |
| } |
| |
| public String getPropertyName(final DatamartProperty prop) { |
| StringConcatenation _builder = new StringConcatenation(); |
| LEntityAttribute _propertyRef = prop.getPropertyRef(); |
| String _name = _propertyRef.getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| |
| public LScalarType getPropertyType(final DatamartProperty prop) { |
| LEntityAttribute _propertyRef = prop.getPropertyRef(); |
| return _propertyRef.getType(); |
| } |
| |
| /** |
| * <p>build a map for the filters contained in a datamart depending on a cube.</p> |
| */ |
| public String createFilterMap(final DatamartDefinition definition, final HashMap<String, String> filterIdMap) { |
| String text = ""; |
| DatamartSource _source = definition.getSource(); |
| boolean _notEquals = (!Objects.equal(_source, null)); |
| if (_notEquals) { |
| DatamartSource _source_1 = definition.getSource(); |
| if ((_source_1 instanceof DatamartCube)) { |
| DatamartSource _source_2 = definition.getSource(); |
| DatamartCube cube = ((DatamartCube) _source_2); |
| EList<DatamartCubeElement> _axisslicer = cube.getAxisslicer(); |
| for (final DatamartCubeElement axisslicer : _axisslicer) { |
| { |
| boolean _and = false; |
| if (!(axisslicer instanceof DatamartAxis)) { |
| _and = false; |
| } else { |
| EList<DatamartElement> _elements = ((DatamartAxis) axisslicer).getElements(); |
| boolean _notEquals_1 = (!Objects.equal(_elements, null)); |
| _and = _notEquals_1; |
| } |
| if (_and) { |
| EList<DatamartElement> _elements_1 = ((DatamartAxis) axisslicer).getElements(); |
| for (final DatamartElement element : _elements_1) { |
| if ((element instanceof DatamartHierarchy)) { |
| DatamartHierarchy hierarchy = ((DatamartHierarchy) element); |
| boolean _isFiltered = hierarchy.isFiltered(); |
| if (_isFiltered) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(text, ""); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("put(\""); |
| String _levelName = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate = IDataMart.decorate(IDataMart.singleSelectDecorator, _levelName); |
| _builder.append(_decorate, ""); |
| _builder.append("\",\""); |
| DatamartSource _source_3 = definition.getSource(); |
| String _createMDXFilter = this.createMDXFilter(((DatamartHierarchy) element), _source_3); |
| _builder.append(_createMDXFilter, ""); |
| _builder.append("\");"); |
| text = _builder.toString(); |
| boolean _notEquals_2 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_2) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| String _levelName_1 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_1 = IDataMart.decorate(IDataMart.singleSelectDecorator, _levelName_1); |
| _builder_1.append(_decorate_1, ""); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| EObject _eContainer = definition.eContainer(); |
| QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer)); |
| _builder_2.append(_fullyQualifiedName, ""); |
| _builder_2.append("."); |
| String _name = definition.getName(); |
| _builder_2.append(_name, ""); |
| _builder_2.append("."); |
| String _levelName_2 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false), |
| Boolean.valueOf(false)); |
| _builder_2.append(_levelName_2, ""); |
| String _string = _builder_2.toString(); |
| String _replace = _string.replace(".", "/"); |
| filterIdMap.put(_builder_1.toString(), _replace); |
| } |
| } |
| boolean _isSelected = hierarchy.isSelected(); |
| if (_isSelected) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(text, ""); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("put(\""); |
| String _levelName_3 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_2 = IDataMart.decorate(IDataMart.multiSelectDecorator, _levelName_3); |
| _builder_3.append(_decorate_2, ""); |
| _builder_3.append("\",\""); |
| DatamartSource _source_4 = definition.getSource(); |
| String _createMDXFilter_1 = this.createMDXFilter(((DatamartHierarchy) element), _source_4); |
| _builder_3.append(_createMDXFilter_1, ""); |
| _builder_3.append("\");"); |
| text = _builder_3.toString(); |
| boolean _notEquals_3 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_3) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| String _levelName_4 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_3 = IDataMart.decorate(IDataMart.multiSelectDecorator, _levelName_4); |
| _builder_4.append(_decorate_3, ""); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| EObject _eContainer_1 = definition.eContainer(); |
| QualifiedName _fullyQualifiedName_1 = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer_1)); |
| _builder_5.append(_fullyQualifiedName_1, ""); |
| _builder_5.append("."); |
| String _name_1 = definition.getName(); |
| _builder_5.append(_name_1, ""); |
| _builder_5.append("."); |
| String _levelName_5 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false), |
| Boolean.valueOf(false)); |
| _builder_5.append(_levelName_5, ""); |
| String _string_1 = _builder_5.toString(); |
| String _replace_1 = _string_1.replace(".", "/"); |
| filterIdMap.put(_builder_4.toString(), _replace_1); |
| } |
| } |
| boolean _isExcept = hierarchy.isExcept(); |
| if (_isExcept) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(text, ""); |
| _builder_6.newLineIfNotEmpty(); |
| _builder_6.append("put(\""); |
| String _dimensionName = this.getDimensionName(hierarchy, Boolean.valueOf(true)); |
| String _plus = (_dimensionName + ".["); |
| CubeLevel _exceptRef = hierarchy.getExceptRef(); |
| String _name_2 = _exceptRef.getName(); |
| String _plus_1 = (_plus + _name_2); |
| String _plus_2 = (_plus_1 + "]"); |
| String _decorate_4 = IDataMart.decorate(IDataMart.exceptDecorator, _plus_2); |
| _builder_6.append(_decorate_4, ""); |
| _builder_6.append("\",\""); |
| DatamartSource _source_5 = definition.getSource(); |
| String _createMDXFilter_2 = this.createMDXFilter(hierarchy, _source_5); |
| _builder_6.append(_createMDXFilter_2, ""); |
| _builder_6.append("\");"); |
| text = _builder_6.toString(); |
| boolean _notEquals_4 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_4) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| String _levelName_6 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_5 = IDataMart.decorate(IDataMart.exceptDecorator, _levelName_6); |
| _builder_7.append(_decorate_5, ""); |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| EObject _eContainer_2 = definition.eContainer(); |
| QualifiedName _fullyQualifiedName_2 = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer_2)); |
| _builder_8.append(_fullyQualifiedName_2, ""); |
| _builder_8.append("."); |
| String _name_3 = definition.getName(); |
| _builder_8.append(_name_3, ""); |
| _builder_8.append("."); |
| String _levelName_7 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false), |
| Boolean.valueOf(false)); |
| _builder_8.append(_levelName_7, ""); |
| String _string_2 = _builder_8.toString(); |
| String _replace_2 = _string_2.replace(".", "/"); |
| filterIdMap.put(_builder_7.toString(), _replace_2); |
| } |
| } |
| } |
| } |
| } |
| boolean _and_1 = false; |
| if (!(axisslicer instanceof DatamartSlicer)) { |
| _and_1 = false; |
| } else { |
| DatamartElement _element = ((DatamartSlicer) axisslicer).getElement(); |
| boolean _notEquals_5 = (!Objects.equal(_element, null)); |
| _and_1 = _notEquals_5; |
| } |
| if (_and_1) { |
| DatamartElement element_1 = ((DatamartSlicer) axisslicer).getElement(); |
| if ((element_1 instanceof DatamartHierarchy)) { |
| DatamartHierarchy hierarchy_1 = ((DatamartHierarchy) element_1); |
| boolean _isFiltered_1 = hierarchy_1.isFiltered(); |
| if (_isFiltered_1) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append(text, ""); |
| _builder_9.newLineIfNotEmpty(); |
| _builder_9.append("put(\""); |
| String _levelName_8 = this.getLevelName(((DatamartHierarchy) element_1), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_6 = IDataMart.decorate(IDataMart.slicerSingleSelectDecorator, _levelName_8); |
| _builder_9.append(_decorate_6, ""); |
| _builder_9.append("\",\""); |
| DatamartSource _source_6 = definition.getSource(); |
| String _createMDXFilter_3 = this.createMDXFilter(((DatamartHierarchy) element_1), _source_6); |
| _builder_9.append(_createMDXFilter_3, ""); |
| _builder_9.append("\");"); |
| text = _builder_9.toString(); |
| boolean _notEquals_6 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_6) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| String _levelName_9 = this.getLevelName(((DatamartHierarchy) element_1), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_7 = IDataMart.decorate(IDataMart.slicerSingleSelectDecorator, _levelName_9); |
| _builder_10.append(_decorate_7, ""); |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| EObject _eContainer_3 = definition.eContainer(); |
| QualifiedName _fullyQualifiedName_3 = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer_3)); |
| _builder_11.append(_fullyQualifiedName_3, ""); |
| _builder_11.append("."); |
| String _name_4 = definition.getName(); |
| _builder_11.append(_name_4, ""); |
| _builder_11.append("."); |
| String _levelName_10 = this.getLevelName(((DatamartHierarchy) element_1), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| _builder_11.append(_levelName_10, ""); |
| String _string_3 = _builder_11.toString(); |
| String _replace_3 = _string_3.replace(".", "/"); |
| filterIdMap.put(_builder_10.toString(), _replace_3); |
| } |
| } |
| boolean _isSelected_1 = hierarchy_1.isSelected(); |
| if (_isSelected_1) { |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append(text, ""); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append("put(\""); |
| String _levelName_11 = this.getLevelName(((DatamartHierarchy) element_1), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_8 = IDataMart.decorate(IDataMart.slicerMultiSelectDecorator, _levelName_11); |
| _builder_12.append(_decorate_8, ""); |
| _builder_12.append("\",\""); |
| DatamartSource _source_7 = definition.getSource(); |
| String _createMDXFilter_4 = this.createMDXFilter(((DatamartHierarchy) element_1), _source_7); |
| _builder_12.append(_createMDXFilter_4, ""); |
| _builder_12.append("\");"); |
| text = _builder_12.toString(); |
| boolean _notEquals_7 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_7) { |
| StringConcatenation _builder_13 = new StringConcatenation(); |
| String _levelName_12 = this.getLevelName(((DatamartHierarchy) element_1), Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| String _decorate_9 = IDataMart.decorate(IDataMart.slicerMultiSelectDecorator, _levelName_12); |
| _builder_13.append(_decorate_9, ""); |
| StringConcatenation _builder_14 = new StringConcatenation(); |
| EObject _eContainer_4 = definition.eContainer(); |
| QualifiedName _fullyQualifiedName_4 = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer_4)); |
| _builder_14.append(_fullyQualifiedName_4, ""); |
| _builder_14.append("."); |
| String _name_5 = definition.getName(); |
| _builder_14.append(_name_5, ""); |
| _builder_14.append("."); |
| String _levelName_13 = this.getLevelName(((DatamartHierarchy) element_1), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| _builder_14.append(_levelName_13, ""); |
| String _string_4 = _builder_14.toString(); |
| String _replace_4 = _string_4.replace(".", "/"); |
| filterIdMap.put(_builder_13.toString(), _replace_4); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| DatamartSource _source_3 = definition.getSource(); |
| if ((_source_3 instanceof DatamartEntity)) { |
| DatamartSource _source_4 = definition.getSource(); |
| DatamartEntity entity = ((DatamartEntity) _source_4); |
| String _createFiltermapCondition = this.createFiltermapCondition(entity, definition, filterIdMap); |
| text = _createFiltermapCondition; |
| } |
| DatamartSource _source_5 = definition.getSource(); |
| if ((_source_5 instanceof DatamartTask)) { |
| DatamartSource _source_6 = definition.getSource(); |
| DatamartTask task = ((DatamartTask) _source_6); |
| String _createFiltermapCondition_1 = this.createFiltermapCondition(task, definition, filterIdMap); |
| text = _createFiltermapCondition_1; |
| } |
| int _length = text.length(); |
| boolean _greaterThan = (_length > 0); |
| if (_greaterThan) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{{"); |
| _builder.newLine(); |
| _builder.append(text, ""); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("}}"); |
| text = _builder.toString(); |
| } |
| } |
| return text; |
| } |
| |
| /** |
| * <p>build a map for the filters contained in a datamart depending on a task.</p> |
| */ |
| public String createFiltermapCondition(final DatamartTask task, final DatamartDefinition definition, final HashMap<String, String> filterIdMap) { |
| String text = ""; |
| EList<DatamartCondition> _conditions = task.getConditions(); |
| for (final DatamartCondition condition : _conditions) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(text, ""); |
| _builder.newLineIfNotEmpty(); |
| String _createSQLFilter = this.createSQLFilter(condition, task, definition, filterIdMap); |
| _builder.append(_createSQLFilter, ""); |
| text = _builder.toString(); |
| } |
| return text; |
| } |
| |
| /** |
| * <p>build the sql filter condition depending on an entity.</p> |
| */ |
| public String createSQLFilter(final DatamartCondition condition, final DatamartTask task, final DatamartDefinition definition, final HashMap<String, String> filterIdMap) { |
| String text = ""; |
| Expression _condition = condition.getCondition(); |
| boolean _notEquals = (!Objects.equal(_condition, null)); |
| if (_notEquals) { |
| Expression _condition_1 = condition.getCondition(); |
| if ((_condition_1 instanceof ConditionalExpression)) { |
| Expression _condition_2 = condition.getCondition(); |
| Expression element = ((ConditionalExpression) _condition_2).getRight(); |
| Expression _condition_3 = condition.getCondition(); |
| Expression _left = ((ConditionalExpression) _condition_3).getLeft(); |
| if ((_left instanceof DatamartTaskFilter)) { |
| Expression _condition_4 = condition.getCondition(); |
| Expression _left_1 = ((ConditionalExpression) _condition_4).getLeft(); |
| DatamartTaskFilter taskFilter = ((DatamartTaskFilter) _left_1); |
| boolean _or = false; |
| boolean _isFiltered = element.isFiltered(); |
| if (_isFiltered) { |
| _or = true; |
| } else { |
| boolean _isSelected = element.isSelected(); |
| _or = _isSelected; |
| } |
| if (_or) { |
| boolean _notEquals_1 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| boolean _isFiltered_1 = element.isFiltered(); |
| if (_isFiltered_1) { |
| _builder.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_1 = element.isSelected(); |
| if (_isSelected_1) { |
| _builder.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| TaskFilterEnum _filterRef = taskFilter.getFilterRef(); |
| String _literal = _filterRef.getLiteral(); |
| _builder.append(_literal, ""); |
| { |
| boolean _isFiltered_2 = element.isFiltered(); |
| if (_isFiltered_2) { |
| _builder.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_2 = element.isSelected(); |
| if (_isSelected_2) { |
| _builder.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| EObject _eContainer = definition.eContainer(); |
| QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer)); |
| _builder_1.append(_fullyQualifiedName, ""); |
| _builder_1.append("."); |
| String _name = definition.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("."); |
| TaskFilterEnum _filterRef_1 = taskFilter.getFilterRef(); |
| String _literal_1 = _filterRef_1.getLiteral(); |
| _builder_1.append(_literal_1, ""); |
| String _string = _builder_1.toString(); |
| String _replace = _string.replace(".", "/"); |
| filterIdMap.put(_builder.toString(), _replace); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| TaskFilterEnum _filterRef_2 = taskFilter.getFilterRef(); |
| String _literal_2 = _filterRef_2.getLiteral(); |
| _builder_2.append(_literal_2, ""); |
| String filter = _builder_2.toString(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(text, ""); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("put(\""); |
| { |
| boolean _isFiltered_3 = element.isFiltered(); |
| if (_isFiltered_3) { |
| _builder_3.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_3 = element.isSelected(); |
| if (_isSelected_3) { |
| _builder_3.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| TaskFilterEnum _filterRef_3 = taskFilter.getFilterRef(); |
| String _literal_3 = _filterRef_3.getLiteral(); |
| _builder_3.append(_literal_3, ""); |
| { |
| boolean _isFiltered_4 = element.isFiltered(); |
| if (_isFiltered_4) { |
| _builder_3.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_4 = element.isSelected(); |
| if (_isSelected_4) { |
| _builder_3.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| _builder_3.append("\",\""); |
| _builder_3.append(filter, ""); |
| _builder_3.append("\");"); |
| text = _builder_3.toString(); |
| } |
| } else { |
| Expression _condition_5 = condition.getCondition(); |
| Expression _left_2 = ((ConditionalExpression) _condition_5).getLeft(); |
| if ((_left_2 instanceof DatamartColumn)) { |
| Expression _condition_6 = condition.getCondition(); |
| Expression _left_3 = ((ConditionalExpression) _condition_6).getLeft(); |
| DatamartColumn taskColumn = ((DatamartColumn) _left_3); |
| boolean _isFiltered_5 = element.isFiltered(); |
| if (_isFiltered_5) { |
| boolean _notEquals_2 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_2) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| { |
| boolean _isFiltered_6 = element.isFiltered(); |
| if (_isFiltered_6) { |
| _builder_4.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_5 = element.isSelected(); |
| if (_isSelected_5) { |
| _builder_4.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| TaskQueryColumnEnum _columnRef = taskColumn.getColumnRef(); |
| String _name_1 = _columnRef.name(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("."); |
| TaskQueryColumnEnum _columnRef_1 = taskColumn.getColumnRef(); |
| String _name_2 = _columnRef_1.name(); |
| _builder_4.append(_name_2, ""); |
| { |
| boolean _isFiltered_7 = element.isFiltered(); |
| if (_isFiltered_7) { |
| _builder_4.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_6 = element.isSelected(); |
| if (_isSelected_6) { |
| _builder_4.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| EObject _eContainer_1 = definition.eContainer(); |
| QualifiedName _fullyQualifiedName_1 = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer_1)); |
| _builder_5.append(_fullyQualifiedName_1, ""); |
| _builder_5.append("."); |
| String _name_3 = definition.getName(); |
| _builder_5.append(_name_3, ""); |
| _builder_5.append("."); |
| TaskQueryColumnEnum _columnRef_2 = taskColumn.getColumnRef(); |
| String _name_4 = _columnRef_2.name(); |
| _builder_5.append(_name_4, ""); |
| _builder_5.append("."); |
| TaskQueryColumnEnum _columnRef_3 = taskColumn.getColumnRef(); |
| String _name_5 = _columnRef_3.name(); |
| _builder_5.append(_name_5, ""); |
| String _string_1 = _builder_5.toString(); |
| String _replace_1 = _string_1.replace(".", "/"); |
| filterIdMap.put(_builder_4.toString(), _replace_1); |
| } |
| } |
| } |
| } |
| } |
| } |
| return text; |
| } |
| |
| /** |
| * <p>build a map for the filters contained in a datamart depending on an entity.</p> |
| */ |
| public String createFiltermapCondition(final DatamartEntity entity, final DatamartDefinition definition, final HashMap<String, String> filterIdMap) { |
| String text = ""; |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(text, ""); |
| _builder.newLineIfNotEmpty(); |
| String _createDefaultSQLFilter = this.createDefaultSQLFilter(entity, filterIdMap); |
| _builder.append(_createDefaultSQLFilter, ""); |
| text = _builder.toString(); |
| EList<DatamartCondition> _conditions = entity.getConditions(); |
| for (final DatamartCondition condition : _conditions) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(text, ""); |
| _builder_1.newLineIfNotEmpty(); |
| String _createSQLFilter = this.createSQLFilter(condition, entity, definition, filterIdMap); |
| _builder_1.append(_createSQLFilter, ""); |
| text = _builder_1.toString(); |
| } |
| EList<DatamartNavigation> _navigations = entity.getNavigations(); |
| for (final DatamartNavigation navigation : _navigations) { |
| { |
| if ((navigation instanceof DatamartMember)) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(text, ""); |
| _builder_2.newLineIfNotEmpty(); |
| DatamartEntity _datamartEntity = ((DatamartMember) navigation).getDatamartEntity(); |
| String _createFiltermapCondition = this.createFiltermapCondition(_datamartEntity, definition, filterIdMap); |
| _builder_2.append(_createFiltermapCondition, ""); |
| text = _builder_2.toString(); |
| } |
| if ((navigation instanceof DatamartOwner)) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(text, ""); |
| _builder_3.newLineIfNotEmpty(); |
| DatamartEntity _datamartEntity_1 = ((DatamartOwner) navigation).getDatamartEntity(); |
| String _createFiltermapCondition_1 = this.createFiltermapCondition(_datamartEntity_1, definition, filterIdMap); |
| _builder_3.append(_createFiltermapCondition_1, ""); |
| text = _builder_3.toString(); |
| } |
| } |
| } |
| return text; |
| } |
| |
| /** |
| * <p>build the default sql filter on id depending on an entity.</p> |
| */ |
| public String createDefaultSQLFilter(final DatamartEntity entity, final HashMap<String, String> filterIdMap) { |
| String text = ""; |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(IDataMart.filterIdPlaceholder, ""); |
| String filter = _builder.toString(); |
| boolean _notEquals = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(IDataMart.singleSelectDecorator, ""); |
| String _entityAlias = this.getEntityAlias(entity); |
| _builder_1.append(_entityAlias, ""); |
| _builder_1.append(".id"); |
| _builder_1.append(IDataMart.singleSelectDecorator, ""); |
| filterIdMap.put(_builder_1.toString(), |
| IDataMart.filterIdPlaceholder); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(text, ""); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("put(\""); |
| _builder_2.append(IDataMart.singleSelectDecorator, ""); |
| String _entityAlias_1 = this.getEntityAlias(entity); |
| _builder_2.append(_entityAlias_1, ""); |
| _builder_2.append(".id"); |
| _builder_2.append(IDataMart.singleSelectDecorator, ""); |
| _builder_2.append("\",\""); |
| _builder_2.append(filter, ""); |
| _builder_2.append("\");"); |
| text = _builder_2.toString(); |
| return text; |
| } |
| |
| /** |
| * <p>build the sql filter condition depending on an entity.</p> |
| */ |
| public String createSQLFilter(final DatamartCondition condition, final DatamartEntity entity, final DatamartDefinition definition, final HashMap<String, String> filterIdMap) { |
| String text = ""; |
| Expression _condition = condition.getCondition(); |
| boolean _notEquals = (!Objects.equal(_condition, null)); |
| if (_notEquals) { |
| Expression _condition_1 = condition.getCondition(); |
| if ((_condition_1 instanceof ConditionalExpression)) { |
| Expression _condition_2 = condition.getCondition(); |
| Expression element = ((ConditionalExpression) _condition_2).getRight(); |
| Expression _condition_3 = condition.getCondition(); |
| Expression _left = ((ConditionalExpression) _condition_3).getLeft(); |
| DatamartProperty property = ((DatamartProperty) _left); |
| boolean _or = false; |
| boolean _isFiltered = element.isFiltered(); |
| if (_isFiltered) { |
| _or = true; |
| } else { |
| boolean _isSelected = element.isSelected(); |
| _or = _isSelected; |
| } |
| if (_or) { |
| boolean _notEquals_1 = (!Objects.equal(filterIdMap, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| boolean _isFiltered_1 = element.isFiltered(); |
| if (_isFiltered_1) { |
| _builder.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_1 = element.isSelected(); |
| if (_isSelected_1) { |
| _builder.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| String _propertyName = this.getPropertyName(property, entity); |
| _builder.append(_propertyName, ""); |
| { |
| boolean _isFiltered_2 = element.isFiltered(); |
| if (_isFiltered_2) { |
| _builder.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_2 = element.isSelected(); |
| if (_isSelected_2) { |
| _builder.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| EObject _eContainer = definition.eContainer(); |
| QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer)); |
| _builder_1.append(_fullyQualifiedName, ""); |
| _builder_1.append("."); |
| String _name = definition.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("."); |
| String _propertyName_1 = this.getPropertyName(property, entity); |
| _builder_1.append(_propertyName_1, ""); |
| String _string = _builder_1.toString(); |
| String _replace = _string.replace(".", "/"); |
| filterIdMap.put(_builder.toString(), _replace); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| { |
| boolean _isOptional = element.isOptional(); |
| if (_isOptional) { |
| _builder_2.append("select "); |
| _builder_2.append(IDataMart.sqlFilterNothing, ""); |
| _builder_2.append(" from "); |
| _builder_2.append(EnumDatabaseVendor.ONE_ROW_ONE_COLUMN_TABLE, ""); |
| _builder_2.append(" union "); |
| } |
| } |
| _builder_2.append("select distinct "); |
| LEntityAttribute _propertyRef = property.getPropertyRef(); |
| String _columnName = this._namingExtensions.toColumnName(_propertyRef); |
| _builder_2.append(_columnName, ""); |
| _builder_2.append(" as \\\""); |
| LEntityAttribute _propertyRef_1 = property.getPropertyRef(); |
| String _name_1 = _propertyRef_1.getName(); |
| _builder_2.append(_name_1, ""); |
| _builder_2.append("\\\" from "); |
| LEntity _entityRef = entity.getEntityRef(); |
| LEntityPersistenceInfo _persistenceInfo = _entityRef.getPersistenceInfo(); |
| String _schemaName = _persistenceInfo.getSchemaName(); |
| CharSequence _provideSchemaName = this.getProvideSchemaName(_schemaName); |
| _builder_2.append(_provideSchemaName, ""); |
| LEntity _entityRef_1 = entity.getEntityRef(); |
| String _tableName = this._namingExtensions.toTableName(_entityRef_1); |
| _builder_2.append(_tableName, ""); |
| String filter = _builder_2.toString(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(text, ""); |
| _builder_3.append("put(\""); |
| { |
| boolean _isFiltered_3 = element.isFiltered(); |
| if (_isFiltered_3) { |
| _builder_3.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_3 = element.isSelected(); |
| if (_isSelected_3) { |
| _builder_3.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| String _propertyName_2 = this.getPropertyName(property, entity); |
| _builder_3.append(_propertyName_2, ""); |
| { |
| boolean _isFiltered_4 = element.isFiltered(); |
| if (_isFiltered_4) { |
| _builder_3.append(IDataMart.singleSelectDecorator, ""); |
| } else { |
| boolean _isSelected_4 = element.isSelected(); |
| if (_isSelected_4) { |
| _builder_3.append(IDataMart.multiSelectDecorator, ""); |
| } |
| } |
| } |
| _builder_3.append("\",\""); |
| _builder_3.append(filter, ""); |
| _builder_3.append("\");"); |
| text = _builder_3.toString(); |
| } |
| } |
| } |
| return text; |
| } |
| |
| /** |
| * <p>build the mdx filter slice depending on a cube.</p> |
| */ |
| public String createMDXFilter(final DatamartHierarchy level, final DatamartSource source) { |
| String filter = "select {} on columns,"; |
| CubeLevel _levelRef = level.getLevelRef(); |
| boolean _notEquals = (!Objects.equal(_levelRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(filter, ""); |
| String _levelName = this.getLevelName(level, Boolean.valueOf(true), Boolean.valueOf(false), Boolean.valueOf(false), Boolean.valueOf(false)); |
| _builder.append(_levelName, ""); |
| _builder.append(".members on rows"); |
| filter = _builder.toString(); |
| } |
| if ((source instanceof DatamartCube)) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(filter, ""); |
| _builder_1.append(" from "); |
| CubeType _cubeRef = ((DatamartCube) source).getCubeRef(); |
| String _name = _cubeRef.getName(); |
| _builder_1.append(_name, ""); |
| filter = _builder_1.toString(); |
| } |
| return filter; |
| } |
| |
| /** |
| * <p>helper to get a level name.</p> |
| */ |
| public String getFilterAlias(final DatamartHierarchy level) { |
| String text = ""; |
| CubeLevel _levelRef = level.getLevelRef(); |
| boolean _notEquals = (!Objects.equal(_levelRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _dimensionName = this.getDimensionName(level, Boolean.valueOf(false)); |
| _builder.append(_dimensionName, ""); |
| CubeLevel _levelRef_1 = level.getLevelRef(); |
| String _name = _levelRef_1.getName(); |
| String _firstUpper = StringExtensions.toFirstUpper(_name); |
| _builder.append(_firstUpper, ""); |
| text = _builder.toString(); |
| } |
| return text; |
| } |
| |
| /** |
| * <p>mdx syntax part for aggregations on sets.</p> |
| */ |
| public String createSetAggregation(final List<DatamartSetAggregation> usedSetAggregation, final Boolean nonEmpty) { |
| String set = ""; |
| boolean firstTuple = true; |
| for (final DatamartSetAggregation element : usedSetAggregation) { |
| { |
| if (firstTuple) { |
| firstTuple = false; |
| } else { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(set, ""); |
| _builder.append(","); |
| set = _builder.toString(); |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(set, ""); |
| String _evaluateExpression = this.evaluateExpression(element, null); |
| _builder_1.append(_evaluateExpression, ""); |
| set = _builder_1.toString(); |
| } |
| } |
| int _size = usedSetAggregation.size(); |
| boolean _greaterThan = (_size > 1); |
| if (_greaterThan) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| if ((nonEmpty).booleanValue()) { |
| _builder.append("Non Empty"); |
| } |
| } |
| _builder.append("{"); |
| _builder.append(set, ""); |
| _builder.append("}"); |
| set = _builder.toString(); |
| } else { |
| int _size_1 = usedSetAggregation.size(); |
| boolean _greaterThan_1 = (_size_1 > 0); |
| if (_greaterThan_1) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| { |
| if ((nonEmpty).booleanValue()) { |
| _builder_1.append("Non Empty "); |
| } |
| } |
| _builder_1.append(set, ""); |
| set = _builder_1.toString(); |
| } |
| } |
| return set; |
| } |
| |
| /** |
| * <p>mdx syntax part for hierarchies.</p> |
| */ |
| public String createHierarchies(final List<DatamartHierarchy> usedHierarchies, final Boolean nonEmpty) { |
| String set = ""; |
| boolean firstTuple = true; |
| for (final DatamartHierarchy element : usedHierarchies) { |
| { |
| if (firstTuple) { |
| firstTuple = false; |
| } else { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(set, ""); |
| _builder.append(","); |
| set = _builder.toString(); |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(set, ""); |
| String _levelName = this.getLevelName(element, Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_1.append(_levelName, ""); |
| set = _builder_1.toString(); |
| } |
| } |
| int _size = usedHierarchies.size(); |
| boolean _greaterThan = (_size > 1); |
| if (_greaterThan) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| if ((nonEmpty).booleanValue()) { |
| _builder.append("Non Empty"); |
| } |
| } |
| _builder.append("{"); |
| _builder.append(set, ""); |
| _builder.append("}"); |
| set = _builder.toString(); |
| } else { |
| int _size_1 = usedHierarchies.size(); |
| boolean _greaterThan_1 = (_size_1 > 0); |
| if (_greaterThan_1) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| { |
| if ((nonEmpty).booleanValue()) { |
| _builder_1.append("Non Empty "); |
| } |
| } |
| _builder_1.append(set, ""); |
| set = _builder_1.toString(); |
| } |
| } |
| return set; |
| } |
| |
| /** |
| * <p>mdx syntax part for measures.</p> |
| */ |
| public String createMeasures(final List<DatamartMeasure> usedMeasures, final List<DatamartDerivedMeasure> usedDerived, final Boolean nonEmpty) { |
| String set = ""; |
| boolean firstTuple = true; |
| for (final DatamartMeasure element : usedMeasures) { |
| { |
| if (firstTuple) { |
| firstTuple = false; |
| } else { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(set, ""); |
| _builder.append(","); |
| set = _builder.toString(); |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(set, ""); |
| String _measureName = this.getMeasureName(element); |
| _builder_1.append(_measureName, ""); |
| set = _builder_1.toString(); |
| } |
| } |
| for (final DatamartDerivedMeasure element_1 : usedDerived) { |
| { |
| if (firstTuple) { |
| firstTuple = false; |
| } else { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(set, ""); |
| _builder.append(","); |
| set = _builder.toString(); |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(set, ""); |
| String _derivedMeasureName = this.getDerivedMeasureName(element_1); |
| _builder_1.append(_derivedMeasureName, ""); |
| set = _builder_1.toString(); |
| } |
| } |
| int _size = usedMeasures.size(); |
| int _size_1 = usedDerived.size(); |
| int _plus = (_size + _size_1); |
| boolean _greaterThan = (_plus > 1); |
| if (_greaterThan) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| if ((nonEmpty).booleanValue()) { |
| _builder.append("Non Empty"); |
| } |
| } |
| _builder.append("{"); |
| _builder.append(set, ""); |
| _builder.append("}"); |
| set = _builder.toString(); |
| } else { |
| int _size_2 = usedMeasures.size(); |
| int _size_3 = usedDerived.size(); |
| int _plus_1 = (_size_2 + _size_3); |
| boolean _greaterThan_1 = (_plus_1 > 0); |
| if (_greaterThan_1) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| { |
| if ((nonEmpty).booleanValue()) { |
| _builder_1.append("Non Empty "); |
| } |
| } |
| _builder_1.append(set, ""); |
| set = _builder_1.toString(); |
| } |
| } |
| return set; |
| } |
| |
| /** |
| * <p>the main function to build a mdx statement.</p> |
| */ |
| public String createMDXStatement(final DatamartDefinition definition) { |
| DatamartSource _source = definition.getSource(); |
| DatamartCube cube = ((DatamartCube) _source); |
| String body = ""; |
| String slice = ""; |
| String derived = ""; |
| boolean firstAxis = true; |
| boolean firstSlice = true; |
| boolean firstderived = true; |
| EList<DatamartCubeElement> _axisslicer = cube.getAxisslicer(); |
| for (final DatamartCubeElement axisslicer : _axisslicer) { |
| { |
| if ((axisslicer instanceof DatamartAxis)) { |
| boolean crossJoinMeasure = false; |
| boolean crossJoinHierarchy = false; |
| boolean crossJoinSetAggregation = false; |
| DatamartAxis axis = ((DatamartAxis) axisslicer); |
| if (firstAxis) { |
| firstAxis = false; |
| } else { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(body, ""); |
| _builder.append(","); |
| body = _builder.toString(); |
| } |
| EList<DatamartElement> _elements = axis.getElements(); |
| boolean _notEquals = (!Objects.equal(_elements, null)); |
| if (_notEquals) { |
| String set = ""; |
| final ArrayList<DatamartHierarchy> usedHierarchies = CollectionLiterals.<DatamartHierarchy>newArrayList(); |
| final ArrayList<DatamartMeasure> usedMeasures = CollectionLiterals.<DatamartMeasure>newArrayList(); |
| final ArrayList<DatamartDerivedMeasure> usedDerivedMeasure = CollectionLiterals.<DatamartDerivedMeasure>newArrayList(); |
| final ArrayList<DatamartSetAggregation> usedSetAggregation = CollectionLiterals.<DatamartSetAggregation>newArrayList(); |
| EList<DatamartElement> _elements_1 = axis.getElements(); |
| for (final DatamartElement element : _elements_1) { |
| { |
| if ((element instanceof DatamartSetAggregation)) { |
| boolean _or = false; |
| int _size = usedMeasures.size(); |
| boolean _greaterThan = (_size > 0); |
| if (_greaterThan) { |
| _or = true; |
| } else { |
| int _size_1 = usedDerivedMeasure.size(); |
| boolean _greaterThan_1 = (_size_1 > 0); |
| _or = _greaterThan_1; |
| } |
| if (_or) { |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(set, ""); |
| _builder_1.append(","); |
| set = _builder_1.toString(); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty = cube.isNonEmpty(); |
| if (_isNonEmpty) { |
| _builder_2.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_2.append("CrossJoin"); |
| } |
| } |
| _builder_2.append("("); |
| _builder_2.append(set, ""); |
| String _createMeasures = this.createMeasures(usedMeasures, usedDerivedMeasure, Boolean.valueOf(false)); |
| _builder_2.append(_createMeasures, ""); |
| set = _builder_2.toString(); |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(set, ""); |
| _builder_3.append(")"); |
| set = _builder_3.toString(); |
| } |
| usedMeasures.clear(); |
| usedDerivedMeasure.clear(); |
| crossJoinSetAggregation = true; |
| } |
| int _size_2 = usedHierarchies.size(); |
| boolean _greaterThan_2 = (_size_2 > 0); |
| if (_greaterThan_2) { |
| if (crossJoinHierarchy) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append(set, ""); |
| _builder_4.append(","); |
| set = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_1 = cube.isNonEmpty(); |
| if (_isNonEmpty_1) { |
| _builder_5.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_5.append("CrossJoin"); |
| } |
| } |
| _builder_5.append("("); |
| _builder_5.append(set, ""); |
| String _createHierarchies = this.createHierarchies(usedHierarchies, Boolean.valueOf(false)); |
| _builder_5.append(_createHierarchies, ""); |
| set = _builder_5.toString(); |
| if (crossJoinHierarchy) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(set, ""); |
| _builder_6.append(")"); |
| set = _builder_6.toString(); |
| } |
| usedHierarchies.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartSetAggregation setAggregation = ((DatamartSetAggregation) element); |
| usedSetAggregation.add(setAggregation); |
| } |
| if ((element instanceof DatamartHierarchy)) { |
| boolean _or_1 = false; |
| int _size_3 = usedMeasures.size(); |
| boolean _greaterThan_3 = (_size_3 > 0); |
| if (_greaterThan_3) { |
| _or_1 = true; |
| } else { |
| int _size_4 = usedDerivedMeasure.size(); |
| boolean _greaterThan_4 = (_size_4 > 0); |
| _or_1 = _greaterThan_4; |
| } |
| if (_or_1) { |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append(set, ""); |
| _builder_7.append(","); |
| set = _builder_7.toString(); |
| } |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_2 = cube.isNonEmpty(); |
| if (_isNonEmpty_2) { |
| _builder_8.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_8.append("CrossJoin"); |
| } |
| } |
| _builder_8.append("("); |
| _builder_8.append(set, ""); |
| String _createMeasures_1 = this.createMeasures(usedMeasures, usedDerivedMeasure, Boolean.valueOf(false)); |
| _builder_8.append(_createMeasures_1, ""); |
| set = _builder_8.toString(); |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append(set, ""); |
| _builder_9.append(")"); |
| set = _builder_9.toString(); |
| } |
| usedMeasures.clear(); |
| usedDerivedMeasure.clear(); |
| crossJoinMeasure = true; |
| } |
| int _size_5 = usedSetAggregation.size(); |
| boolean _greaterThan_5 = (_size_5 > 0); |
| if (_greaterThan_5) { |
| if (crossJoinSetAggregation) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append(set, ""); |
| _builder_10.append(","); |
| set = _builder_10.toString(); |
| } |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_3 = cube.isNonEmpty(); |
| if (_isNonEmpty_3) { |
| _builder_11.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_11.append("CrossJoin"); |
| } |
| } |
| _builder_11.append("("); |
| _builder_11.append(set, ""); |
| String _createSetAggregation = this.createSetAggregation(usedSetAggregation, Boolean.valueOf(false)); |
| _builder_11.append(_createSetAggregation, ""); |
| set = _builder_11.toString(); |
| if (crossJoinSetAggregation) { |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append(set, ""); |
| _builder_12.append(")"); |
| set = _builder_12.toString(); |
| } |
| usedSetAggregation.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartHierarchy hierarchyLevel = ((DatamartHierarchy) element); |
| DatamartHierarchy lastHierarchy = IterableExtensions.<DatamartHierarchy>last(usedHierarchies); |
| boolean _and = false; |
| if (!(!crossJoinHierarchy)) { |
| _and = false; |
| } else { |
| boolean _or_2 = false; |
| boolean _equals = Objects.equal(lastHierarchy, null); |
| if (_equals) { |
| _or_2 = true; |
| } else { |
| String _hierarchyName = this.getHierarchyName(hierarchyLevel); |
| String _hierarchyName_1 = this.getHierarchyName(lastHierarchy); |
| boolean _equals_1 = _hierarchyName.equals(_hierarchyName_1); |
| _or_2 = _equals_1; |
| } |
| _and = _or_2; |
| } |
| if (_and) { |
| usedHierarchies.add(hierarchyLevel); |
| } else { |
| if (crossJoinHierarchy) { |
| StringConcatenation _builder_13 = new StringConcatenation(); |
| _builder_13.append(set, ""); |
| _builder_13.append(","); |
| set = _builder_13.toString(); |
| } |
| StringConcatenation _builder_14 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_4 = cube.isNonEmpty(); |
| if (_isNonEmpty_4) { |
| _builder_14.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_14.append("CrossJoin"); |
| } |
| } |
| _builder_14.append("("); |
| _builder_14.append(set, ""); |
| String _createHierarchies_1 = this.createHierarchies(usedHierarchies, Boolean.valueOf(false)); |
| _builder_14.append(_createHierarchies_1, ""); |
| set = _builder_14.toString(); |
| if (crossJoinHierarchy) { |
| StringConcatenation _builder_15 = new StringConcatenation(); |
| _builder_15.append(set, ""); |
| _builder_15.append(")"); |
| set = _builder_15.toString(); |
| } |
| usedHierarchies.clear(); |
| usedHierarchies.add(hierarchyLevel); |
| crossJoinHierarchy = true; |
| } |
| } |
| if ((element instanceof DatamartMeasure)) { |
| int _size_6 = usedHierarchies.size(); |
| boolean _greaterThan_6 = (_size_6 > 0); |
| if (_greaterThan_6) { |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_16 = new StringConcatenation(); |
| _builder_16.append(set, ""); |
| _builder_16.append(","); |
| set = _builder_16.toString(); |
| } |
| StringConcatenation _builder_17 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_5 = cube.isNonEmpty(); |
| if (_isNonEmpty_5) { |
| _builder_17.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_17.append("CrossJoin"); |
| } |
| } |
| _builder_17.append("("); |
| _builder_17.append(set, ""); |
| String _createHierarchies_2 = this.createHierarchies(usedHierarchies, Boolean.valueOf(false)); |
| _builder_17.append(_createHierarchies_2, ""); |
| set = _builder_17.toString(); |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_18 = new StringConcatenation(); |
| _builder_18.append(set, ""); |
| _builder_18.append(")"); |
| set = _builder_18.toString(); |
| } |
| usedHierarchies.clear(); |
| crossJoinMeasure = true; |
| } |
| int _size_7 = usedSetAggregation.size(); |
| boolean _greaterThan_7 = (_size_7 > 0); |
| if (_greaterThan_7) { |
| if (crossJoinSetAggregation) { |
| StringConcatenation _builder_19 = new StringConcatenation(); |
| _builder_19.append(set, ""); |
| _builder_19.append(","); |
| set = _builder_19.toString(); |
| } |
| StringConcatenation _builder_20 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_6 = cube.isNonEmpty(); |
| if (_isNonEmpty_6) { |
| _builder_20.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_20.append("CrossJoin"); |
| } |
| } |
| _builder_20.append("("); |
| _builder_20.append(set, ""); |
| String _createSetAggregation_1 = this.createSetAggregation(usedSetAggregation, Boolean.valueOf(false)); |
| _builder_20.append(_createSetAggregation_1, ""); |
| set = _builder_20.toString(); |
| if (crossJoinSetAggregation) { |
| StringConcatenation _builder_21 = new StringConcatenation(); |
| _builder_21.append(set, ""); |
| _builder_21.append(")"); |
| set = _builder_21.toString(); |
| } |
| usedSetAggregation.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartMeasure measure = ((DatamartMeasure) element); |
| usedMeasures.add(measure); |
| } |
| if ((element instanceof DatamartDerivedMeasure)) { |
| int _size_8 = usedHierarchies.size(); |
| boolean _greaterThan_8 = (_size_8 > 0); |
| if (_greaterThan_8) { |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_22 = new StringConcatenation(); |
| _builder_22.append(set, ""); |
| _builder_22.append(","); |
| set = _builder_22.toString(); |
| } |
| StringConcatenation _builder_23 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_7 = cube.isNonEmpty(); |
| if (_isNonEmpty_7) { |
| _builder_23.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_23.append("CrossJoin"); |
| } |
| } |
| _builder_23.append("("); |
| _builder_23.append(set, ""); |
| String _createHierarchies_3 = this.createHierarchies(usedHierarchies, Boolean.valueOf(false)); |
| _builder_23.append(_createHierarchies_3, ""); |
| set = _builder_23.toString(); |
| if (crossJoinMeasure) { |
| StringConcatenation _builder_24 = new StringConcatenation(); |
| _builder_24.append(set, ""); |
| _builder_24.append(")"); |
| set = _builder_24.toString(); |
| } |
| usedHierarchies.clear(); |
| crossJoinMeasure = true; |
| } |
| int _size_9 = usedSetAggregation.size(); |
| boolean _greaterThan_9 = (_size_9 > 0); |
| if (_greaterThan_9) { |
| if (crossJoinSetAggregation) { |
| StringConcatenation _builder_25 = new StringConcatenation(); |
| _builder_25.append(set, ""); |
| _builder_25.append(","); |
| set = _builder_25.toString(); |
| } |
| StringConcatenation _builder_26 = new StringConcatenation(); |
| { |
| boolean _isNonEmpty_8 = cube.isNonEmpty(); |
| if (_isNonEmpty_8) { |
| _builder_26.append("NonEmptyCrossjoin"); |
| } else { |
| _builder_26.append("CrossJoin"); |
| } |
| } |
| _builder_26.append("("); |
| _builder_26.append(set, ""); |
| String _createSetAggregation_2 = this.createSetAggregation(usedSetAggregation, Boolean.valueOf(false)); |
| _builder_26.append(_createSetAggregation_2, ""); |
| set = _builder_26.toString(); |
| if (crossJoinSetAggregation) { |
| StringConcatenation _builder_27 = new StringConcatenation(); |
| _builder_27.append(set, ""); |
| _builder_27.append(")"); |
| set = _builder_27.toString(); |
| } |
| usedSetAggregation.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartDerivedMeasure measure_1 = ((DatamartDerivedMeasure) element); |
| usedDerivedMeasure.add(measure_1); |
| } |
| } |
| } |
| if (((crossJoinMeasure || crossJoinHierarchy) || crossJoinSetAggregation)) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(set, ""); |
| _builder_1.append(","); |
| set = _builder_1.toString(); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(set, ""); |
| boolean _and = false; |
| boolean _isNonEmpty = cube.isNonEmpty(); |
| if (!_isNonEmpty) { |
| _and = false; |
| } else { |
| _and = (!((crossJoinMeasure || crossJoinHierarchy) || crossJoinSetAggregation)); |
| } |
| String _createHierarchies = this.createHierarchies(usedHierarchies, Boolean.valueOf(_and)); |
| _builder_2.append(_createHierarchies, ""); |
| set = _builder_2.toString(); |
| usedHierarchies.clear(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(set, ""); |
| boolean _and_1 = false; |
| boolean _isNonEmpty_1 = cube.isNonEmpty(); |
| if (!_isNonEmpty_1) { |
| _and_1 = false; |
| } else { |
| _and_1 = (!((crossJoinMeasure || crossJoinHierarchy) || crossJoinSetAggregation)); |
| } |
| String _createMeasures = this.createMeasures(usedMeasures, usedDerivedMeasure, Boolean.valueOf(_and_1)); |
| _builder_3.append(_createMeasures, ""); |
| set = _builder_3.toString(); |
| usedMeasures.clear(); |
| usedDerivedMeasure.clear(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append(set, ""); |
| boolean _and_2 = false; |
| boolean _isNonEmpty_2 = cube.isNonEmpty(); |
| if (!_isNonEmpty_2) { |
| _and_2 = false; |
| } else { |
| _and_2 = (!((crossJoinMeasure || crossJoinHierarchy) || crossJoinSetAggregation)); |
| } |
| String _createSetAggregation = this.createSetAggregation(usedSetAggregation, Boolean.valueOf(_and_2)); |
| _builder_4.append(_createSetAggregation, ""); |
| set = _builder_4.toString(); |
| usedMeasures.clear(); |
| if (((crossJoinMeasure || crossJoinHierarchy) || crossJoinSetAggregation)) { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append(set, ""); |
| _builder_5.append(")"); |
| set = _builder_5.toString(); |
| } |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(body, ""); |
| _builder_6.append(set, ""); |
| _builder_6.append(" on "); |
| AxisEnum _name = axis.getName(); |
| _builder_6.append(_name, ""); |
| body = _builder_6.toString(); |
| } |
| } |
| if ((axisslicer instanceof DatamartSlicer)) { |
| if (firstSlice) { |
| firstSlice = false; |
| } else { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append(slice, ""); |
| _builder_7.append(","); |
| slice = _builder_7.toString(); |
| } |
| DatamartElement element_1 = ((DatamartSlicer) axisslicer).getElement(); |
| if ((element_1 instanceof DatamartHierarchy)) { |
| DatamartHierarchy hierarchyLevel = ((DatamartHierarchy) element_1); |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append(slice, ""); |
| String _levelName = this.getLevelName(hierarchyLevel, Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true)); |
| _builder_8.append(_levelName, ""); |
| slice = _builder_8.toString(); |
| } |
| if ((element_1 instanceof DatamartMeasure)) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append(slice, ""); |
| String _measureName = this.getMeasureName(((DatamartMeasure) element_1)); |
| _builder_9.append(_measureName, ""); |
| slice = _builder_9.toString(); |
| } |
| } |
| if ((axisslicer instanceof DatamartDefineDerivedMeasure)) { |
| if (firstderived) { |
| firstderived = false; |
| } |
| DatamartDefineDerivedMeasure derivedMeasure = ((DatamartDefineDerivedMeasure) axisslicer); |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append(derived, ""); |
| _builder_10.append(" member [Measures].["); |
| String _name_1 = derivedMeasure.getName(); |
| _builder_10.append(_name_1, ""); |
| _builder_10.append("] as "); |
| String _buildDerivedFormula = this.buildDerivedFormula(derivedMeasure); |
| _builder_10.append(_buildDerivedFormula, ""); |
| derived = _builder_10.toString(); |
| } |
| } |
| } |
| if ((!firstSlice)) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(" "); |
| _builder.append("where ("); |
| _builder.append(slice, " "); |
| _builder.append(")"); |
| slice = _builder.toString(); |
| } |
| if ((!firstderived)) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("with"); |
| _builder_1.append(derived, ""); |
| _builder_1.append(" "); |
| derived = _builder_1.toString(); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(derived, ""); |
| _builder_2.append("select "); |
| _builder_2.append(body, ""); |
| _builder_2.append(" from "); |
| CubeType _cubeRef = cube.getCubeRef(); |
| String _name = _cubeRef.getName(); |
| _builder_2.append(_name, ""); |
| _builder_2.append(slice, ""); |
| return _builder_2.toString(); |
| } |
| |
| public boolean isCrossJoined(final DatamartDefinition definition) { |
| DatamartSource _source = definition.getSource(); |
| if ((!(_source instanceof DatamartCube))) { |
| return false; |
| } |
| DatamartSource _source_1 = definition.getSource(); |
| DatamartCube cube = ((DatamartCube) _source_1); |
| boolean firstAxis = true; |
| EList<DatamartCubeElement> _axisslicer = cube.getAxisslicer(); |
| for (final DatamartCubeElement axisslicer : _axisslicer) { |
| if ((axisslicer instanceof DatamartAxis)) { |
| boolean crossJoinMeasure = false; |
| boolean crossJoinHierarchy = false; |
| boolean crossJoinSetAggregation = false; |
| DatamartAxis axis = ((DatamartAxis) axisslicer); |
| if (firstAxis) { |
| firstAxis = false; |
| } |
| EList<DatamartElement> _elements = axis.getElements(); |
| boolean _notEquals = (!Objects.equal(_elements, null)); |
| if (_notEquals) { |
| final ArrayList<DatamartHierarchy> usedHierarchies = CollectionLiterals.<DatamartHierarchy>newArrayList(); |
| final ArrayList<DatamartMeasure> usedMeasures = CollectionLiterals.<DatamartMeasure>newArrayList(); |
| final ArrayList<DatamartDerivedMeasure> usedDerivedMeasure = CollectionLiterals.<DatamartDerivedMeasure>newArrayList(); |
| final ArrayList<DatamartSetAggregation> usedSetAggregation = CollectionLiterals.<DatamartSetAggregation>newArrayList(); |
| EList<DatamartElement> _elements_1 = axis.getElements(); |
| for (final DatamartElement element : _elements_1) { |
| { |
| if ((element instanceof DatamartSetAggregation)) { |
| boolean _or = false; |
| int _size = usedMeasures.size(); |
| boolean _greaterThan = (_size > 0); |
| if (_greaterThan) { |
| _or = true; |
| } else { |
| int _size_1 = usedDerivedMeasure.size(); |
| boolean _greaterThan_1 = (_size_1 > 0); |
| _or = _greaterThan_1; |
| } |
| if (_or) { |
| usedMeasures.clear(); |
| usedDerivedMeasure.clear(); |
| crossJoinSetAggregation = true; |
| } |
| int _size_2 = usedHierarchies.size(); |
| boolean _greaterThan_2 = (_size_2 > 0); |
| if (_greaterThan_2) { |
| usedHierarchies.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartSetAggregation setAggregation = ((DatamartSetAggregation) element); |
| usedSetAggregation.add(setAggregation); |
| } |
| if ((element instanceof DatamartHierarchy)) { |
| boolean _or_1 = false; |
| int _size_3 = usedMeasures.size(); |
| boolean _greaterThan_3 = (_size_3 > 0); |
| if (_greaterThan_3) { |
| _or_1 = true; |
| } else { |
| int _size_4 = usedDerivedMeasure.size(); |
| boolean _greaterThan_4 = (_size_4 > 0); |
| _or_1 = _greaterThan_4; |
| } |
| if (_or_1) { |
| usedMeasures.clear(); |
| usedDerivedMeasure.clear(); |
| crossJoinMeasure = true; |
| } |
| int _size_5 = usedSetAggregation.size(); |
| boolean _greaterThan_5 = (_size_5 > 0); |
| if (_greaterThan_5) { |
| usedSetAggregation.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartHierarchy hierarchyLevel = ((DatamartHierarchy) element); |
| DatamartHierarchy lastHierarchy = IterableExtensions.<DatamartHierarchy>last(usedHierarchies); |
| boolean _and = false; |
| if (!(!crossJoinHierarchy)) { |
| _and = false; |
| } else { |
| boolean _or_2 = false; |
| boolean _equals = Objects.equal(lastHierarchy, null); |
| if (_equals) { |
| _or_2 = true; |
| } else { |
| String _hierarchyName = this.getHierarchyName(hierarchyLevel); |
| String _hierarchyName_1 = this.getHierarchyName(lastHierarchy); |
| boolean _equals_1 = _hierarchyName.equals(_hierarchyName_1); |
| _or_2 = _equals_1; |
| } |
| _and = _or_2; |
| } |
| if (_and) { |
| usedHierarchies.add(hierarchyLevel); |
| } else { |
| usedHierarchies.clear(); |
| usedHierarchies.add(hierarchyLevel); |
| crossJoinHierarchy = true; |
| } |
| } |
| if ((element instanceof DatamartMeasure)) { |
| int _size_6 = usedHierarchies.size(); |
| boolean _greaterThan_6 = (_size_6 > 0); |
| if (_greaterThan_6) { |
| usedHierarchies.clear(); |
| crossJoinMeasure = true; |
| } |
| int _size_7 = usedSetAggregation.size(); |
| boolean _greaterThan_7 = (_size_7 > 0); |
| if (_greaterThan_7) { |
| usedSetAggregation.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartMeasure measure = ((DatamartMeasure) element); |
| usedMeasures.add(measure); |
| } |
| if ((element instanceof DatamartDerivedMeasure)) { |
| int _size_8 = usedHierarchies.size(); |
| boolean _greaterThan_8 = (_size_8 > 0); |
| if (_greaterThan_8) { |
| usedHierarchies.clear(); |
| crossJoinMeasure = true; |
| } |
| int _size_9 = usedSetAggregation.size(); |
| boolean _greaterThan_9 = (_size_9 > 0); |
| if (_greaterThan_9) { |
| usedSetAggregation.clear(); |
| crossJoinSetAggregation = true; |
| } |
| DatamartDerivedMeasure measure_1 = ((DatamartDerivedMeasure) element); |
| usedDerivedMeasure.add(measure_1); |
| } |
| } |
| } |
| usedMeasures.clear(); |
| usedDerivedMeasure.clear(); |
| usedMeasures.clear(); |
| } |
| return ((crossJoinMeasure || crossJoinHierarchy) || crossJoinSetAggregation); |
| } |
| } |
| return false; |
| } |
| |
| /** |
| * <p>mdx syntax part for hierarchy names. If a hierarchy itself has no name in the cube definition, the dimension name is used instead</p> |
| */ |
| public String getHierarchyName(final DatamartHierarchy hierarchy) { |
| String _xifexpression = null; |
| CubeHierarchy _hierarchyRef = hierarchy.getHierarchyRef(); |
| String _name = _hierarchyRef.getName(); |
| boolean _equals = Objects.equal(_name, null); |
| if (_equals) { |
| CubeHierarchy _hierarchyRef_1 = hierarchy.getHierarchyRef(); |
| EObject _eContainer = _hierarchyRef_1.eContainer(); |
| return ((CubeDimension) _eContainer).getName(); |
| } else { |
| CubeHierarchy _hierarchyRef_2 = hierarchy.getHierarchyRef(); |
| _xifexpression = _hierarchyRef_2.getName(); |
| } |
| return _xifexpression; |
| } |
| |
| /** |
| * <p>mdx syntax part for derived measure expressions.</p> |
| */ |
| public String buildDerivedFormula(final DatamartDefineDerivedMeasure derivedMeasure) { |
| String formula = ""; |
| EList<Expression> _derivedElement = derivedMeasure.getDerivedElement(); |
| for (final Expression element : _derivedElement) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(formula, ""); |
| String _evaluateExpression = this.evaluateExpression(element, null); |
| _builder.append(_evaluateExpression, ""); |
| formula = _builder.toString(); |
| } |
| String _concat = "\'".concat(formula); |
| return _concat.concat("\'"); |
| } |
| |
| /** |
| * <p>as the grammar makes use of expressions along an abstract syntax tree, we need this recursive dispatcher to synthesize resulting code.</p> |
| */ |
| public String evaluateExpression(final Expression element, final DatamartEntity entity) { |
| String evaluation = ""; |
| String _value = element.getValue(); |
| boolean _notEquals = (!Objects.equal(_value, null)); |
| if (_notEquals) { |
| String _value_1 = element.getValue(); |
| evaluation = _value_1; |
| } |
| String _numberValue = element.getNumberValue(); |
| boolean _notEquals_1 = (!Objects.equal(_numberValue, null)); |
| if (_notEquals_1) { |
| String _numberValue_1 = element.getNumberValue(); |
| evaluation = _numberValue_1; |
| } |
| String _stringValue = element.getStringValue(); |
| boolean _notEquals_2 = (!Objects.equal(_stringValue, null)); |
| if (_notEquals_2) { |
| String _stringValue_1 = element.getStringValue(); |
| String _concat = "\'".concat(_stringValue_1); |
| String _concat_1 = _concat.concat("\'"); |
| evaluation = _concat_1; |
| } |
| boolean _isFiltered = element.isFiltered(); |
| if (_isFiltered) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(IDataMart.singleSelectDecorator, ""); |
| EObject _eContainer = element.eContainer(); |
| Expression _left = ((ConditionalExpression) _eContainer).getLeft(); |
| String _propertyName = this.getPropertyName(((DatamartProperty) _left), entity); |
| _builder.append(_propertyName, ""); |
| _builder.append(IDataMart.singleSelectDecorator, ""); |
| evaluation = _builder.toString(); |
| } |
| boolean _isSelected = element.isSelected(); |
| if (_isSelected) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(IDataMart.multiSelectDecorator, ""); |
| EObject _eContainer_1 = element.eContainer(); |
| Expression _left_1 = ((ConditionalExpression) _eContainer_1).getLeft(); |
| String _propertyName_1 = this.getPropertyName(((DatamartProperty) _left_1), entity); |
| _builder_1.append(_propertyName_1, ""); |
| _builder_1.append(IDataMart.multiSelectDecorator, ""); |
| evaluation = _builder_1.toString(); |
| } |
| DatamartFunctionInterface _function = element.getFunction(); |
| boolean _notEquals_3 = (!Objects.equal(_function, null)); |
| if (_notEquals_3) { |
| DatamartFunctionInterface _function_1 = element.getFunction(); |
| if ((_function_1 instanceof DatamartFunction)) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(evaluation, ""); |
| DatamartHierarchy _hierarchy = element.getHierarchy(); |
| String _levelName = this.getLevelName(_hierarchy, Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_2.append(_levelName, ""); |
| _builder_2.append("."); |
| DatamartFunctionInterface _function_2 = element.getFunction(); |
| FunctionEnum _function_3 = ((DatamartFunction) _function_2).getFunction(); |
| String _name = _function_3.name(); |
| _builder_2.append(_name, ""); |
| evaluation = _builder_2.toString(); |
| } |
| DatamartFunctionInterface _function_4 = element.getFunction(); |
| if ((_function_4 instanceof DatamartParameterFunction)) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(evaluation, ""); |
| DatamartHierarchy _hierarchy_1 = element.getHierarchy(); |
| String _levelName_1 = this.getLevelName(_hierarchy_1, Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_3.append(_levelName_1, ""); |
| _builder_3.append("."); |
| DatamartFunctionInterface _function_5 = element.getFunction(); |
| ParameterFunctionEnum _function_6 = ((DatamartParameterFunction) _function_5).getFunction(); |
| String _name_1 = _function_6.name(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("("); |
| DatamartFunctionInterface _function_7 = element.getFunction(); |
| DatamartFunctionIntParameter _parameter = ((DatamartParameterFunction) _function_7).getParameter(); |
| int _value_2 = _parameter.getValue(); |
| _builder_3.append(_value_2, ""); |
| _builder_3.append(")"); |
| evaluation = _builder_3.toString(); |
| } |
| } |
| boolean _and = false; |
| DatamartHierarchy _hierarchy_2 = element.getHierarchy(); |
| boolean _notEquals_4 = (!Objects.equal(_hierarchy_2, null)); |
| if (!_notEquals_4) { |
| _and = false; |
| } else { |
| DatamartFunctionInterface _function_8 = element.getFunction(); |
| boolean _equals = Objects.equal(_function_8, null); |
| _and = _equals; |
| } |
| if (_and) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append(evaluation, ""); |
| DatamartHierarchy _hierarchy_3 = element.getHierarchy(); |
| String _levelName_2 = this.getLevelName(_hierarchy_3, Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_4.append(_levelName_2, ""); |
| evaluation = _builder_4.toString(); |
| } |
| if ((element instanceof DatamartSetTuple)) { |
| Expression _left_2 = ((DatamartSetTuple) element).getLeft(); |
| DatamartSetFunctionInterface _setFunction = _left_2.getSetFunction(); |
| boolean _notEquals_5 = (!Objects.equal(_setFunction, null)); |
| if (_notEquals_5) { |
| Expression _left_3 = ((DatamartSetTuple) element).getLeft(); |
| DatamartSetFunctionInterface _setFunction_1 = _left_3.getSetFunction(); |
| if ((_setFunction_1 instanceof DatamartSetFunction)) { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append(evaluation, ""); |
| Expression _left_4 = ((DatamartSetTuple) element).getLeft(); |
| DatamartSetFunctionInterface _setFunction_2 = _left_4.getSetFunction(); |
| SetFunctionEnum _setFunction_3 = ((DatamartSetFunction) _setFunction_2).getSetFunction(); |
| String _name_2 = _setFunction_3.name(); |
| _builder_5.append(_name_2, ""); |
| _builder_5.append("("); |
| DatamartHierarchy _right = ((DatamartSetTuple) element).getRight(); |
| String _levelName_3 = this.getLevelName(_right, Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_5.append(_levelName_3, ""); |
| _builder_5.append(")"); |
| evaluation = _builder_5.toString(); |
| } |
| Expression _left_5 = ((DatamartSetTuple) element).getLeft(); |
| DatamartSetFunctionInterface _setFunction_4 = _left_5.getSetFunction(); |
| if ((_setFunction_4 instanceof DatamartSetParameterFunction)) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(evaluation, ""); |
| Expression _left_6 = ((DatamartSetTuple) element).getLeft(); |
| DatamartSetFunctionInterface _setFunction_5 = _left_6.getSetFunction(); |
| SetParameterFunctionEnum _setFunction_6 = ((DatamartSetParameterFunction) _setFunction_5).getSetFunction(); |
| String _name_3 = _setFunction_6.name(); |
| _builder_6.append(_name_3, ""); |
| _builder_6.append("("); |
| DatamartHierarchy _right_1 = ((DatamartSetTuple) element).getRight(); |
| String _levelName_4 = this.getLevelName(_right_1, Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_6.append(_levelName_4, ""); |
| _builder_6.append(","); |
| Expression _left_7 = ((DatamartSetTuple) element).getLeft(); |
| DatamartSetFunctionInterface _setFunction_7 = _left_7.getSetFunction(); |
| DatamartFunctionIntParameter _parameter_1 = ((DatamartSetParameterFunction) _setFunction_7).getParameter(); |
| int _value_3 = ((DatamartFunctionIntParameter) _parameter_1).getValue(); |
| _builder_6.append(_value_3, ""); |
| _builder_6.append(")"); |
| evaluation = _builder_6.toString(); |
| } |
| } |
| } |
| if ((element instanceof DatamartMeasure)) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| String _measureName = this.getMeasureName(((DatamartMeasure) element)); |
| _builder_7.append(_measureName, ""); |
| evaluation = _builder_7.toString(); |
| } |
| if ((element instanceof DatamartDerivedMeasure)) { |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| String _derivedMeasureName = this.getDerivedMeasureName(((DatamartDerivedMeasure) element)); |
| _builder_8.append(_derivedMeasureName, ""); |
| evaluation = _builder_8.toString(); |
| } |
| if ((element instanceof DatamartHierarchy)) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| String _levelName_5 = this.getLevelName(((DatamartHierarchy) element), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_9.append(_levelName_5, ""); |
| evaluation = _builder_9.toString(); |
| } |
| if ((element instanceof DatamartProperty)) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| String _propertyName_2 = this.getPropertyName(((DatamartProperty) element), entity); |
| _builder_10.append(_propertyName_2, ""); |
| evaluation = _builder_10.toString(); |
| LEntityAttribute _propertyRef = ((DatamartProperty) element).getPropertyRef(); |
| LScalarType type = _propertyRef.getType(); |
| String typeName = ""; |
| boolean _and_1 = false; |
| boolean _and_2 = false; |
| boolean _notEquals_6 = (!Objects.equal(type, null)); |
| if (!_notEquals_6) { |
| _and_2 = false; |
| } else { |
| _and_2 = (type instanceof LDataType); |
| } |
| if (!_and_2) { |
| _and_1 = false; |
| } else { |
| JvmTypeReference _jvmTypeReference = ((LDataType) type).getJvmTypeReference(); |
| boolean _notEquals_7 = (!Objects.equal(_jvmTypeReference, null)); |
| _and_1 = _notEquals_7; |
| } |
| if (_and_1) { |
| JvmTypeReference _jvmTypeReference_1 = ((LDataType) type).getJvmTypeReference(); |
| String _simpleName = _jvmTypeReference_1.getSimpleName(); |
| typeName = _simpleName; |
| } else { |
| String _name_4 = type.getName(); |
| typeName = _name_4; |
| } |
| } |
| if ((element instanceof Multiplication)) { |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| Expression _left_8 = ((Multiplication) element).getLeft(); |
| String _evaluateExpression = this.evaluateExpression(_left_8, entity); |
| _builder_11.append(_evaluateExpression, ""); |
| evaluation = _builder_11.toString(); |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append(evaluation, ""); |
| _builder_12.append("*"); |
| evaluation = _builder_12.toString(); |
| StringConcatenation _builder_13 = new StringConcatenation(); |
| _builder_13.append(evaluation, ""); |
| Expression _right_2 = ((Multiplication) element).getRight(); |
| String _evaluateExpression_1 = this.evaluateExpression(_right_2, entity); |
| _builder_13.append(_evaluateExpression_1, ""); |
| evaluation = _builder_13.toString(); |
| } |
| if ((element instanceof Division)) { |
| StringConcatenation _builder_14 = new StringConcatenation(); |
| Expression _left_9 = ((Division) element).getLeft(); |
| String _evaluateExpression_2 = this.evaluateExpression(_left_9, entity); |
| _builder_14.append(_evaluateExpression_2, ""); |
| evaluation = _builder_14.toString(); |
| StringConcatenation _builder_15 = new StringConcatenation(); |
| _builder_15.append(evaluation, ""); |
| _builder_15.append("/"); |
| evaluation = _builder_15.toString(); |
| StringConcatenation _builder_16 = new StringConcatenation(); |
| _builder_16.append(evaluation, ""); |
| Expression _right_3 = ((Division) element).getRight(); |
| String _evaluateExpression_3 = this.evaluateExpression(_right_3, entity); |
| _builder_16.append(_evaluateExpression_3, ""); |
| evaluation = _builder_16.toString(); |
| } |
| if ((element instanceof Addition)) { |
| StringConcatenation _builder_17 = new StringConcatenation(); |
| _builder_17.append("("); |
| Expression _left_10 = ((Addition) element).getLeft(); |
| String _evaluateExpression_4 = this.evaluateExpression(_left_10, entity); |
| _builder_17.append(_evaluateExpression_4, ""); |
| evaluation = _builder_17.toString(); |
| StringConcatenation _builder_18 = new StringConcatenation(); |
| _builder_18.append(evaluation, ""); |
| _builder_18.append("+"); |
| evaluation = _builder_18.toString(); |
| StringConcatenation _builder_19 = new StringConcatenation(); |
| _builder_19.append(evaluation, ""); |
| Expression _right_4 = ((Addition) element).getRight(); |
| String _evaluateExpression_5 = this.evaluateExpression(_right_4, entity); |
| _builder_19.append(_evaluateExpression_5, ""); |
| _builder_19.append(")"); |
| evaluation = _builder_19.toString(); |
| } |
| if ((element instanceof Subtraction)) { |
| StringConcatenation _builder_20 = new StringConcatenation(); |
| _builder_20.append("("); |
| Expression _left_11 = ((Subtraction) element).getLeft(); |
| String _evaluateExpression_6 = this.evaluateExpression(_left_11, entity); |
| _builder_20.append(_evaluateExpression_6, ""); |
| evaluation = _builder_20.toString(); |
| StringConcatenation _builder_21 = new StringConcatenation(); |
| _builder_21.append(evaluation, ""); |
| _builder_21.append("-"); |
| evaluation = _builder_21.toString(); |
| StringConcatenation _builder_22 = new StringConcatenation(); |
| _builder_22.append(evaluation, ""); |
| Expression _right_5 = ((Subtraction) element).getRight(); |
| String _evaluateExpression_7 = this.evaluateExpression(_right_5, entity); |
| _builder_22.append(_evaluateExpression_7, ""); |
| _builder_22.append(")"); |
| evaluation = _builder_22.toString(); |
| } |
| if ((element instanceof Conjunction)) { |
| StringConcatenation _builder_23 = new StringConcatenation(); |
| Expression _left_12 = ((Conjunction) element).getLeft(); |
| String _evaluateExpression_8 = this.evaluateExpression(_left_12, entity); |
| _builder_23.append(_evaluateExpression_8, ""); |
| evaluation = _builder_23.toString(); |
| StringConcatenation _builder_24 = new StringConcatenation(); |
| _builder_24.append(evaluation, ""); |
| _builder_24.append(" and "); |
| evaluation = _builder_24.toString(); |
| StringConcatenation _builder_25 = new StringConcatenation(); |
| _builder_25.append(evaluation, ""); |
| Expression _right_6 = ((Conjunction) element).getRight(); |
| String _evaluateExpression_9 = this.evaluateExpression(_right_6, entity); |
| _builder_25.append(_evaluateExpression_9, ""); |
| evaluation = _builder_25.toString(); |
| } |
| if ((element instanceof Disjunction)) { |
| StringConcatenation _builder_26 = new StringConcatenation(); |
| _builder_26.append("("); |
| Expression _left_13 = ((Disjunction) element).getLeft(); |
| String _evaluateExpression_10 = this.evaluateExpression(_left_13, entity); |
| _builder_26.append(_evaluateExpression_10, ""); |
| evaluation = _builder_26.toString(); |
| StringConcatenation _builder_27 = new StringConcatenation(); |
| _builder_27.append(evaluation, ""); |
| _builder_27.append(" or "); |
| evaluation = _builder_27.toString(); |
| StringConcatenation _builder_28 = new StringConcatenation(); |
| _builder_28.append(evaluation, ""); |
| Expression _right_7 = ((Disjunction) element).getRight(); |
| String _evaluateExpression_11 = this.evaluateExpression(_right_7, entity); |
| _builder_28.append(_evaluateExpression_11, ""); |
| _builder_28.append(")"); |
| evaluation = _builder_28.toString(); |
| } |
| if ((element instanceof ConditionalExpression)) { |
| StringConcatenation _builder_29 = new StringConcatenation(); |
| Expression _left_14 = ((ConditionalExpression) element).getLeft(); |
| String _evaluateExpression_12 = this.evaluateExpression(_left_14, entity); |
| _builder_29.append(_evaluateExpression_12, ""); |
| evaluation = _builder_29.toString(); |
| Expression _right_8 = ((ConditionalExpression) element).getRight(); |
| boolean _isSelected_1 = _right_8.isSelected(); |
| if (_isSelected_1) { |
| StringConcatenation _builder_30 = new StringConcatenation(); |
| _builder_30.append(evaluation, ""); |
| _builder_30.append(" in "); |
| evaluation = _builder_30.toString(); |
| StringConcatenation _builder_31 = new StringConcatenation(); |
| _builder_31.append(evaluation, ""); |
| _builder_31.append("("); |
| Expression _right_9 = ((ConditionalExpression) element).getRight(); |
| String _evaluateExpression_13 = this.evaluateExpression(_right_9, entity); |
| _builder_31.append(_evaluateExpression_13, ""); |
| _builder_31.append(")"); |
| evaluation = _builder_31.toString(); |
| } else { |
| StringConcatenation _builder_32 = new StringConcatenation(); |
| _builder_32.append(evaluation, ""); |
| _builder_32.append(" "); |
| OperatorEnum _operator = ((ConditionalExpression) element).getOperator(); |
| String _literal = _operator.getLiteral(); |
| _builder_32.append(_literal, ""); |
| _builder_32.append(" "); |
| evaluation = _builder_32.toString(); |
| StringConcatenation _builder_33 = new StringConcatenation(); |
| _builder_33.append(evaluation, ""); |
| Expression _right_10 = ((ConditionalExpression) element).getRight(); |
| String _evaluateExpression_14 = this.evaluateExpression(_right_10, entity); |
| _builder_33.append(_evaluateExpression_14, ""); |
| evaluation = _builder_33.toString(); |
| } |
| Expression _right_11 = ((ConditionalExpression) element).getRight(); |
| boolean _isOptional = _right_11.isOptional(); |
| if (_isOptional) { |
| StringConcatenation _builder_34 = new StringConcatenation(); |
| _builder_34.append("("); |
| Expression _right_12 = ((ConditionalExpression) element).getRight(); |
| String _evaluateExpression_15 = this.evaluateExpression(_right_12, entity); |
| _builder_34.append(_evaluateExpression_15, ""); |
| _builder_34.append("="); |
| _builder_34.append(IDataMart.sqlFilterNothing, ""); |
| _builder_34.append(" or "); |
| _builder_34.append(evaluation, ""); |
| _builder_34.append(")"); |
| evaluation = _builder_34.toString(); |
| } |
| } |
| if ((element instanceof DatamartMemberTuple)) { |
| StringConcatenation _builder_35 = new StringConcatenation(); |
| _builder_35.append("("); |
| DatamartMeasure _right_13 = ((DatamartMemberTuple) element).getRight(); |
| String _evaluateExpression_16 = this.evaluateExpression(_right_13, entity); |
| _builder_35.append(_evaluateExpression_16, ""); |
| evaluation = _builder_35.toString(); |
| StringConcatenation _builder_36 = new StringConcatenation(); |
| _builder_36.append(evaluation, ""); |
| _builder_36.append(","); |
| evaluation = _builder_36.toString(); |
| StringConcatenation _builder_37 = new StringConcatenation(); |
| _builder_37.append(evaluation, ""); |
| Expression _left_15 = ((DatamartMemberTuple) element).getLeft(); |
| String _evaluateExpression_17 = this.evaluateExpression(_left_15, entity); |
| _builder_37.append(_evaluateExpression_17, ""); |
| _builder_37.append(")"); |
| evaluation = _builder_37.toString(); |
| } |
| if ((element instanceof DatamartAggregation)) { |
| Expression _left_16 = ((DatamartAggregation) element).getLeft(); |
| DatamartAggregationFunctionInterface _aggregation = _left_16.getAggregation(); |
| boolean _notEquals_8 = (!Objects.equal(_aggregation, null)); |
| if (_notEquals_8) { |
| Expression _left_17 = ((DatamartAggregation) element).getLeft(); |
| DatamartAggregationFunctionInterface _aggregation_1 = _left_17.getAggregation(); |
| if ((_aggregation_1 instanceof DatamartAggregationFunction)) { |
| StringConcatenation _builder_38 = new StringConcatenation(); |
| Expression _left_18 = ((DatamartAggregation) element).getLeft(); |
| DatamartAggregationFunctionInterface _aggregation_2 = _left_18.getAggregation(); |
| AggregationEnum _aggregation_3 = ((DatamartAggregationFunction) _aggregation_2).getAggregation(); |
| String _name_5 = _aggregation_3.name(); |
| _builder_38.append(_name_5, ""); |
| _builder_38.append("("); |
| evaluation = _builder_38.toString(); |
| Expression _left_19 = ((DatamartAggregation) element).getLeft(); |
| Expression _set = _left_19.getSet(); |
| if ((_set instanceof DatamartHierarchy)) { |
| StringConcatenation _builder_39 = new StringConcatenation(); |
| _builder_39.append(evaluation, ""); |
| Expression _left_20 = ((DatamartAggregation) element).getLeft(); |
| Expression _set_1 = _left_20.getSet(); |
| String _levelName_6 = this.getLevelName(((DatamartHierarchy) _set_1), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_39.append(_levelName_6, ""); |
| evaluation = _builder_39.toString(); |
| } |
| Expression _left_21 = ((DatamartAggregation) element).getLeft(); |
| Expression _set_2 = _left_21.getSet(); |
| if ((_set_2 instanceof DatamartSetTuple)) { |
| StringConcatenation _builder_40 = new StringConcatenation(); |
| _builder_40.append(evaluation, ""); |
| Expression _left_22 = ((DatamartAggregation) element).getLeft(); |
| Expression _set_3 = _left_22.getSet(); |
| String _evaluateExpression_18 = this.evaluateExpression(((DatamartSetTuple) _set_3), entity); |
| _builder_40.append(_evaluateExpression_18, ""); |
| evaluation = _builder_40.toString(); |
| } |
| } |
| } |
| StringConcatenation _builder_41 = new StringConcatenation(); |
| _builder_41.append(evaluation, ""); |
| _builder_41.append(","); |
| evaluation = _builder_41.toString(); |
| StringConcatenation _builder_42 = new StringConcatenation(); |
| _builder_42.append(evaluation, ""); |
| DatamartMeasure _right_14 = ((DatamartAggregation) element).getRight(); |
| String _evaluateExpression_19 = this.evaluateExpression(_right_14, entity); |
| _builder_42.append(_evaluateExpression_19, ""); |
| _builder_42.append(")"); |
| evaluation = _builder_42.toString(); |
| } |
| if ((element instanceof DatamartSetAggregation)) { |
| Expression _left_23 = ((DatamartSetAggregation) element).getLeft(); |
| DatamartAggregationFunctionInterface _aggregation_4 = _left_23.getAggregation(); |
| boolean _notEquals_9 = (!Objects.equal(_aggregation_4, null)); |
| if (_notEquals_9) { |
| Expression _left_24 = ((DatamartSetAggregation) element).getLeft(); |
| DatamartAggregationFunctionInterface _aggregation_5 = _left_24.getAggregation(); |
| if ((_aggregation_5 instanceof DatamartSetAggregationFunction)) { |
| StringConcatenation _builder_43 = new StringConcatenation(); |
| Expression _left_25 = ((DatamartSetAggregation) element).getLeft(); |
| DatamartAggregationFunctionInterface _aggregation_6 = _left_25.getAggregation(); |
| SetAggregationEnum _aggregation_7 = ((DatamartSetAggregationFunction) _aggregation_6).getAggregation(); |
| String _name_6 = _aggregation_7.name(); |
| _builder_43.append(_name_6, ""); |
| _builder_43.append("("); |
| evaluation = _builder_43.toString(); |
| Expression _left_26 = ((DatamartSetAggregation) element).getLeft(); |
| Expression _set_4 = _left_26.getSet(); |
| if ((_set_4 instanceof DatamartHierarchy)) { |
| StringConcatenation _builder_44 = new StringConcatenation(); |
| _builder_44.append(evaluation, ""); |
| Expression _left_27 = ((DatamartSetAggregation) element).getLeft(); |
| Expression _set_5 = _left_27.getSet(); |
| String _levelName_7 = this.getLevelName(((DatamartHierarchy) _set_5), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(true), Boolean.valueOf(false)); |
| _builder_44.append(_levelName_7, ""); |
| evaluation = _builder_44.toString(); |
| } |
| Expression _left_28 = ((DatamartSetAggregation) element).getLeft(); |
| Expression _set_6 = _left_28.getSet(); |
| if ((_set_6 instanceof DatamartSetTuple)) { |
| StringConcatenation _builder_45 = new StringConcatenation(); |
| _builder_45.append(evaluation, ""); |
| Expression _left_29 = ((DatamartSetAggregation) element).getLeft(); |
| Expression _set_7 = _left_29.getSet(); |
| String _evaluateExpression_20 = this.evaluateExpression(((DatamartSetTuple) _set_7), entity); |
| _builder_45.append(_evaluateExpression_20, ""); |
| evaluation = _builder_45.toString(); |
| } |
| } |
| } |
| StringConcatenation _builder_46 = new StringConcatenation(); |
| _builder_46.append(evaluation, ""); |
| _builder_46.append(","); |
| Expression _left_30 = ((DatamartSetAggregation) element).getLeft(); |
| DatamartAggregationFunctionInterface _aggregation_8 = _left_30.getAggregation(); |
| DatamartFunctionIntParameter _parameter_2 = ((DatamartSetAggregationFunction) _aggregation_8).getParameter(); |
| int _value_4 = ((DatamartFunctionIntParameter) _parameter_2).getValue(); |
| _builder_46.append(_value_4, ""); |
| _builder_46.append(","); |
| evaluation = _builder_46.toString(); |
| StringConcatenation _builder_47 = new StringConcatenation(); |
| _builder_47.append(evaluation, ""); |
| DatamartMeasure _right_15 = ((DatamartSetAggregation) element).getRight(); |
| String _evaluateExpression_21 = this.evaluateExpression(_right_15, entity); |
| _builder_47.append(_evaluateExpression_21, ""); |
| _builder_47.append(")"); |
| evaluation = _builder_47.toString(); |
| } |
| return evaluation; |
| } |
| |
| /** |
| * <p>mdx syntax part for property names, full qualified and aliased> |
| */ |
| public String getPropertyName(final DatamartProperty property, final DatamartEntity entity) { |
| boolean _notEquals = (!Objects.equal(entity, null)); |
| if (_notEquals) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityAlias = this.getEntityAlias(entity); |
| _builder.append(_entityAlias, ""); |
| _builder.append("."); |
| LEntityAttribute _propertyRef = property.getPropertyRef(); |
| String _columnName = this._namingExtensions.toColumnName(_propertyRef); |
| _builder.append(_columnName, ""); |
| return _builder.toString(); |
| } else { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| LEntityAttribute _propertyRef_1 = property.getPropertyRef(); |
| EObject _eContainer = _propertyRef_1.eContainer(); |
| String _name = ((LEntity) _eContainer).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("."); |
| LEntityAttribute _propertyRef_2 = property.getPropertyRef(); |
| String _columnName_1 = this._namingExtensions.toColumnName(_propertyRef_2); |
| _builder_1.append(_columnName_1, ""); |
| return _builder_1.toString(); |
| } |
| } |
| |
| /** |
| * <p>mdx syntax part for measure names.</p> |
| */ |
| public String getMeasureName(final DatamartMeasure measure) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("[Measures].["); |
| CubeMeasure _measureRef = measure.getMeasureRef(); |
| String _name = _measureRef.getName(); |
| _builder.append(_name, ""); |
| _builder.append("]"); |
| return _builder.toString(); |
| } |
| |
| /** |
| * <p>mdx syntax part for derived measure names.</p> |
| */ |
| public String getDerivedMeasureName(final DatamartDerivedMeasure measure) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("[Measures].["); |
| DatamartDefineDerivedMeasure _derivedRef = measure.getDerivedRef(); |
| String _name = _derivedRef.getName(); |
| _builder.append(_name, ""); |
| _builder.append("]"); |
| return _builder.toString(); |
| } |
| |
| /** |
| * <p>mdx syntax part for dimension names.</p> |
| */ |
| public String getDimensionName(final DatamartHierarchy hierarchy, final Boolean withBrackets) { |
| String dim = ""; |
| CubeHierarchy _hierarchyRef = hierarchy.getHierarchyRef(); |
| EObject _eContainer = _hierarchyRef.eContainer(); |
| boolean _notEquals = (!Objects.equal(_eContainer, null)); |
| if (_notEquals) { |
| CubeHierarchy _hierarchyRef_1 = hierarchy.getHierarchyRef(); |
| String _name = _hierarchyRef_1.getName(); |
| boolean _equals = Objects.equal(_name, null); |
| if (_equals) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| if ((withBrackets).booleanValue()) { |
| _builder.append("["); |
| } |
| } |
| CubeHierarchy _hierarchyRef_2 = hierarchy.getHierarchyRef(); |
| EObject _eContainer_1 = _hierarchyRef_2.eContainer(); |
| String _name_1 = ((CubeDimension) _eContainer_1).getName(); |
| _builder.append(_name_1, ""); |
| { |
| if ((withBrackets).booleanValue()) { |
| _builder.append("]"); |
| } |
| } |
| dim = _builder.toString(); |
| } else { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| { |
| if ((withBrackets).booleanValue()) { |
| _builder_1.append("["); |
| } |
| } |
| CubeHierarchy _hierarchyRef_3 = hierarchy.getHierarchyRef(); |
| String _name_2 = _hierarchyRef_3.getName(); |
| _builder_1.append(_name_2, ""); |
| { |
| if ((withBrackets).booleanValue()) { |
| _builder_1.append("]"); |
| } |
| } |
| dim = _builder_1.toString(); |
| } |
| } |
| return dim; |
| } |
| |
| /** |
| * <p>mdx syntax part for level names.</p> |
| */ |
| public String getLevelName(final DatamartHierarchy hierarchy, final Boolean withBrackets, final Boolean withFiltermask, final Boolean withFunctions, final Boolean isSlicer) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _dimensionName = this.getDimensionName(hierarchy, withBrackets); |
| _builder.append(_dimensionName, ""); |
| String text = _builder.toString(); |
| CubeLevel _levelRef = hierarchy.getLevelRef(); |
| boolean _notEquals = (!Objects.equal(_levelRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(text, ""); |
| _builder_1.append("."); |
| text = _builder_1.toString(); |
| boolean _and = false; |
| boolean _isFiltered = hierarchy.isFiltered(); |
| if (!_isFiltered) { |
| _and = false; |
| } else { |
| _and = (withFiltermask).booleanValue(); |
| } |
| if (_and) { |
| if ((isSlicer).booleanValue()) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(IDataMart.slicerSingleSelectDecorator, ""); |
| _builder_2.append(text, ""); |
| text = _builder_2.toString(); |
| } else { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(IDataMart.singleSelectDecorator, ""); |
| _builder_3.append(text, ""); |
| text = _builder_3.toString(); |
| } |
| } |
| boolean _and_1 = false; |
| boolean _isSelected = hierarchy.isSelected(); |
| if (!_isSelected) { |
| _and_1 = false; |
| } else { |
| _and_1 = (withFiltermask).booleanValue(); |
| } |
| if (_and_1) { |
| if ((isSlicer).booleanValue()) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append(IDataMart.slicerMultiSelectDecorator, ""); |
| _builder_4.append(text, ""); |
| text = _builder_4.toString(); |
| } else { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append(IDataMart.multiSelectDecorator, ""); |
| _builder_5.append(text, ""); |
| text = _builder_5.toString(); |
| } |
| } |
| if ((withBrackets).booleanValue()) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(text, ""); |
| _builder_6.append("["); |
| text = _builder_6.toString(); |
| } |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append(text, ""); |
| CubeLevel _levelRef_1 = hierarchy.getLevelRef(); |
| String _name = _levelRef_1.getName(); |
| _builder_7.append(_name, ""); |
| text = _builder_7.toString(); |
| if ((withBrackets).booleanValue()) { |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append(text, ""); |
| _builder_8.append("]"); |
| text = _builder_8.toString(); |
| } |
| boolean _and_2 = false; |
| boolean _isFiltered_1 = hierarchy.isFiltered(); |
| if (!_isFiltered_1) { |
| _and_2 = false; |
| } else { |
| _and_2 = (withFiltermask).booleanValue(); |
| } |
| if (_and_2) { |
| if ((isSlicer).booleanValue()) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append(text, ""); |
| _builder_9.append(IDataMart.slicerSingleSelectDecorator, ""); |
| text = _builder_9.toString(); |
| } else { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append(text, ""); |
| _builder_10.append(IDataMart.singleSelectDecorator, ""); |
| text = _builder_10.toString(); |
| } |
| } |
| boolean _and_3 = false; |
| boolean _isSelected_1 = hierarchy.isSelected(); |
| if (!_isSelected_1) { |
| _and_3 = false; |
| } else { |
| _and_3 = (withFiltermask).booleanValue(); |
| } |
| if (_and_3) { |
| if ((isSlicer).booleanValue()) { |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append(text, ""); |
| _builder_11.append(IDataMart.slicerMultiSelectDecorator, ""); |
| text = _builder_11.toString(); |
| } else { |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append(text, ""); |
| _builder_12.append(IDataMart.multiSelectDecorator, ""); |
| text = _builder_12.toString(); |
| } |
| } |
| boolean _or = false; |
| boolean _isFiltered_2 = hierarchy.isFiltered(); |
| if (_isFiltered_2) { |
| _or = true; |
| } else { |
| boolean _isSelected_2 = hierarchy.isSelected(); |
| _or = _isSelected_2; |
| } |
| if (_or) { |
| boolean _and_4 = false; |
| boolean _isAll = hierarchy.isAll(); |
| if (!_isAll) { |
| _and_4 = false; |
| } else { |
| _and_4 = (withFunctions).booleanValue(); |
| } |
| if (_and_4) { |
| StringConcatenation _builder_13 = new StringConcatenation(); |
| _builder_13.append(text, ""); |
| _builder_13.append(".Children"); |
| text = _builder_13.toString(); |
| } |
| } else { |
| if ((withFunctions).booleanValue()) { |
| StringConcatenation _builder_14 = new StringConcatenation(); |
| _builder_14.append(text, ""); |
| _builder_14.append(".Members"); |
| text = _builder_14.toString(); |
| } |
| } |
| boolean _and_5 = false; |
| boolean _isExcept = hierarchy.isExcept(); |
| if (!_isExcept) { |
| _and_5 = false; |
| } else { |
| _and_5 = (withFunctions).booleanValue(); |
| } |
| if (_and_5) { |
| StringConcatenation _builder_15 = new StringConcatenation(); |
| _builder_15.append("Except("); |
| _builder_15.append(text, ""); |
| _builder_15.append(",{"); |
| _builder_15.append(IDataMart.exceptDecorator, ""); |
| String _dimensionName_1 = this.getDimensionName(hierarchy, Boolean.valueOf(true)); |
| _builder_15.append(_dimensionName_1, ""); |
| _builder_15.append("."); |
| { |
| if ((withBrackets).booleanValue()) { |
| _builder_15.append("["); |
| } |
| } |
| CubeLevel _exceptRef = hierarchy.getExceptRef(); |
| String _name_1 = _exceptRef.getName(); |
| _builder_15.append(_name_1, ""); |
| { |
| if ((withBrackets).booleanValue()) { |
| _builder_15.append("]"); |
| } |
| } |
| _builder_15.append(IDataMart.exceptDecorator, ""); |
| _builder_15.append("})"); |
| text = _builder_15.toString(); |
| } |
| boolean _and_6 = false; |
| boolean _isOrdered = hierarchy.isOrdered(); |
| if (!_isOrdered) { |
| _and_6 = false; |
| } else { |
| _and_6 = (withFunctions).booleanValue(); |
| } |
| if (_and_6) { |
| DatamartElement _orderRef = hierarchy.getOrderRef(); |
| if ((_orderRef instanceof DatamartMeasure)) { |
| StringConcatenation _builder_16 = new StringConcatenation(); |
| _builder_16.append("Order("); |
| _builder_16.append(text, ""); |
| _builder_16.append(","); |
| DatamartElement _orderRef_1 = hierarchy.getOrderRef(); |
| String _measureName = this.getMeasureName(((DatamartMeasure) _orderRef_1)); |
| _builder_16.append(_measureName, ""); |
| _builder_16.append(","); |
| { |
| boolean _isDescending = hierarchy.isDescending(); |
| if (_isDescending) { |
| _builder_16.append("Desc"); |
| } else { |
| _builder_16.append("Asc"); |
| } |
| } |
| _builder_16.append(")"); |
| text = _builder_16.toString(); |
| } else { |
| StringConcatenation _builder_17 = new StringConcatenation(); |
| _builder_17.append("Order("); |
| _builder_17.append(text, ""); |
| _builder_17.append(","); |
| DatamartElement _orderRef_2 = hierarchy.getOrderRef(); |
| String _derivedMeasureName = this.getDerivedMeasureName(((DatamartDerivedMeasure) _orderRef_2)); |
| _builder_17.append(_derivedMeasureName, ""); |
| _builder_17.append(","); |
| { |
| boolean _isDescending_1 = hierarchy.isDescending(); |
| if (_isDescending_1) { |
| _builder_17.append("Desc"); |
| } else { |
| _builder_17.append("Asc"); |
| } |
| } |
| _builder_17.append(")"); |
| text = _builder_17.toString(); |
| } |
| } |
| } |
| boolean _and_7 = false; |
| boolean _and_8 = false; |
| CubeLevel _levelRef_2 = hierarchy.getLevelRef(); |
| boolean _equals = Objects.equal(_levelRef_2, null); |
| if (!_equals) { |
| _and_8 = false; |
| } else { |
| CubeLevel _exceptRef_1 = hierarchy.getExceptRef(); |
| boolean _equals_1 = Objects.equal(_exceptRef_1, null); |
| _and_8 = _equals_1; |
| } |
| if (!_and_8) { |
| _and_7 = false; |
| } else { |
| _and_7 = (withFunctions).booleanValue(); |
| } |
| if (_and_7) { |
| boolean _and_9 = false; |
| CubeHierarchy _hierarchyRef = hierarchy.getHierarchyRef(); |
| EObject _eContainer = _hierarchyRef.eContainer(); |
| boolean _notEquals_1 = (!Objects.equal(_eContainer, null)); |
| if (!_notEquals_1) { |
| _and_9 = false; |
| } else { |
| CubeHierarchy _hierarchyRef_1 = hierarchy.getHierarchyRef(); |
| EObject _eContainer_1 = _hierarchyRef_1.eContainer(); |
| boolean _isTypeTime = ((CubeDimension) _eContainer_1).isTypeTime(); |
| boolean _not = (!_isTypeTime); |
| _and_9 = _not; |
| } |
| if (_and_9) { |
| boolean _isAll_1 = hierarchy.isAll(); |
| if (_isAll_1) { |
| StringConcatenation _builder_18 = new StringConcatenation(); |
| _builder_18.append(text, ""); |
| _builder_18.append(".Members"); |
| text = _builder_18.toString(); |
| } else { |
| boolean _and_10 = false; |
| boolean _isAllMember = hierarchy.isAllMember(); |
| if (!_isAllMember) { |
| _and_10 = false; |
| } else { |
| CubeHierarchy _hierarchyRef_2 = hierarchy.getHierarchyRef(); |
| boolean _isAllMemberName = _hierarchyRef_2.isAllMemberName(); |
| _and_10 = _isAllMemberName; |
| } |
| if (_and_10) { |
| StringConcatenation _builder_19 = new StringConcatenation(); |
| _builder_19.append(text, ""); |
| _builder_19.append(".["); |
| CubeHierarchy _hierarchyRef_3 = hierarchy.getHierarchyRef(); |
| String _allMemberNameValue = _hierarchyRef_3.getAllMemberNameValue(); |
| String _replaceAll = _allMemberNameValue.replaceAll("\"", ""); |
| _builder_19.append(_replaceAll, ""); |
| _builder_19.append("]"); |
| text = _builder_19.toString(); |
| } else { |
| boolean _isAllLevels = hierarchy.isAllLevels(); |
| if (_isAllLevels) { |
| StringConcatenation _builder_20 = new StringConcatenation(); |
| _builder_20.append(text, ""); |
| _builder_20.append(".AllMembers"); |
| text = _builder_20.toString(); |
| } else { |
| boolean _and_11 = false; |
| boolean _isDefaultMember = hierarchy.isDefaultMember(); |
| if (!_isDefaultMember) { |
| _and_11 = false; |
| } else { |
| CubeHierarchy _hierarchyRef_4 = hierarchy.getHierarchyRef(); |
| boolean _isDefaultMember_1 = _hierarchyRef_4.isDefaultMember(); |
| _and_11 = _isDefaultMember_1; |
| } |
| if (_and_11) { |
| StringConcatenation _builder_21 = new StringConcatenation(); |
| _builder_21.append(text, ""); |
| _builder_21.append(".Defaultmember"); |
| text = _builder_21.toString(); |
| } else { |
| CubeHierarchy _hierarchyRef_5 = hierarchy.getHierarchyRef(); |
| boolean _isDefaultMember_2 = _hierarchyRef_5.isDefaultMember(); |
| if (_isDefaultMember_2) { |
| StringConcatenation _builder_22 = new StringConcatenation(); |
| _builder_22.append(text, ""); |
| _builder_22.append(".Defaultmember"); |
| text = _builder_22.toString(); |
| } else { |
| StringConcatenation _builder_23 = new StringConcatenation(); |
| _builder_23.append(text, ""); |
| _builder_23.append(".Members"); |
| text = _builder_23.toString(); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| StringConcatenation _builder_24 = new StringConcatenation(); |
| _builder_24.append(text, ""); |
| return _builder_24.toString(); |
| } |
| |
| /** |
| * <p>helper for camel case splitting.</p> |
| */ |
| public String splitCamelCase(final String s) { |
| String[] words = s.split("(?<!^)(?=[A-Z])"); |
| final String[] _converted_words = (String[])words; |
| return IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(_converted_words)), " "); |
| } |
| |
| /** |
| * <p>helper for entity names.</p> |
| */ |
| public String getEntityAlias(final DatamartEntity entity) { |
| LEntity _entityRef = entity.getEntityRef(); |
| return this.getEntityAlias(_entityRef); |
| } |
| |
| /** |
| * <p>helper for entity names including aliases when used in recursive join relations.</p> |
| */ |
| public String getEntityAlias(final LEntity entityRef) { |
| String alias = entityRef.getName(); |
| String _name = entityRef.getName(); |
| boolean _containsKey = this.sqlAliasCounter.containsKey(_name); |
| if (_containsKey) { |
| String _name_1 = entityRef.getName(); |
| Integer newId = this.sqlAliasCounter.get(_name_1); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(alias, ""); |
| { |
| if (((newId).intValue() > 0)) { |
| _builder.append(newId, ""); |
| } |
| } |
| alias = _builder.toString(); |
| } |
| return alias; |
| } |
| |
| /** |
| * <p>helper for entity names including aliases when used in recursive join relations.</p> |
| */ |
| public String entityAlias2(final DatamartEntity entity) { |
| LEntity _entityRef = entity.getEntityRef(); |
| String alias = _entityRef.getName(); |
| LEntity _entityRef_1 = entity.getEntityRef(); |
| String _name = _entityRef_1.getName(); |
| boolean _containsKey = this.sqlAliasCounter.containsKey(_name); |
| if (_containsKey) { |
| LEntity _entityRef_2 = entity.getEntityRef(); |
| String _name_1 = _entityRef_2.getName(); |
| Integer newId = this.sqlAliasCounter.get(_name_1); |
| LEntity _entityRef_3 = entity.getEntityRef(); |
| String _name_2 = _entityRef_3.getName(); |
| this.sqlAliasCounter.put(_name_2, Integer.valueOf(((newId).intValue() + 1))); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(alias, ""); |
| _builder.append(((newId).intValue() + 1), ""); |
| alias = _builder.toString(); |
| } else { |
| LEntity _entityRef_4 = entity.getEntityRef(); |
| String _name_3 = _entityRef_4.getName(); |
| this.sqlAliasCounter.put(_name_3, Integer.valueOf(0)); |
| } |
| return alias; |
| } |
| |
| /** |
| * <p>main method to build sql statements bases on entities and roles.</p> |
| */ |
| public String createSQLStatements(final DatamartDefinition definition, final HashMap<String, LEntityAttribute> typesMap) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("put(\""); |
| _builder.append(IUserAccessService.ADMINISTRATOR, ""); |
| _builder.append("\", \""); |
| String _createSQLStatement = this.createSQLStatement(definition, null, typesMap); |
| _builder.append(_createSQLStatement, ""); |
| _builder.append("\");"); |
| String listTxt = _builder.toString(); |
| EList<DatamartRole> _roles = definition.getRoles(); |
| for (final DatamartRole role : _roles) { |
| { |
| String stmt = this.createSQLStatement(definition, role, typesMap); |
| boolean _isEmpty = stmt.isEmpty(); |
| boolean _not = (!_isEmpty); |
| if (_not) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(listTxt, ""); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("put(\""); |
| Role _assignedRole = role.getAssignedRole(); |
| String _name = _assignedRole.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", \""); |
| _builder_1.append(stmt, ""); |
| _builder_1.append("\");"); |
| listTxt = _builder_1.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; |
| } |
| |
| /** |
| * <p>main method to build sql statements bases on entities and a role.</p> |
| */ |
| public String createSQLStatement(final DatamartDefinition definition, final DatamartRole role, final HashMap<String, LEntityAttribute> typesMap) { |
| this.sqlAliasCounter.clear(); |
| this.sqlFilterMap.clear(); |
| this.sqlGrouping.clear(); |
| this.entityGrouping.clear(); |
| this.ignoreEntityGrouping = false; |
| this.sqlHasAggregate = false; |
| this.sqlHasOrder = false; |
| this.idMap.clear(); |
| HashMap<String, String> properties = CollectionLiterals.<String, String>newHashMap(); |
| ArrayList<String> conditions = CollectionLiterals.<String>newArrayList(); |
| ArrayList<String> orderings = CollectionLiterals.<String>newArrayList(); |
| DatamartSource _source = definition.getSource(); |
| DatamartEntity entity = ((DatamartEntity) _source); |
| String used = this.createEntity(entity, null, null, properties, conditions, orderings, role, typesMap); |
| String select = this.createSelect(properties, definition); |
| String condition = this.createCondition(conditions); |
| String ordering = this.createOrdering(orderings); |
| String grouping = this.createGrouping(this.sqlGrouping); |
| boolean _isEmpty = select.isEmpty(); |
| if (_isEmpty) { |
| return ""; |
| } |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("select "); |
| _builder.append(select, ""); |
| _builder.append(" from "); |
| _builder.append(used, ""); |
| { |
| int _size = conditions.size(); |
| boolean _greaterThan = (_size > 0); |
| if (_greaterThan) { |
| _builder.append(" where "); |
| _builder.append(condition, ""); |
| } |
| } |
| { |
| if (this.sqlHasAggregate) { |
| _builder.append(" group by "); |
| _builder.append(grouping, ""); |
| } |
| } |
| { |
| if (this.sqlHasOrder) { |
| _builder.append(" order by "); |
| _builder.append(ordering, ""); |
| } |
| } |
| return _builder.toString(); |
| } |
| |
| /** |
| * <p>sql syntax part for group by.</p> |
| */ |
| public String createGrouping(final ArrayList<String> grouping) { |
| String groupingString = ""; |
| for (final String groupBy : grouping) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| boolean _isEmpty = groupingString.isEmpty(); |
| boolean _not = (!_isEmpty); |
| if (_not) { |
| _builder.append(groupingString, ""); |
| _builder.append(","); |
| } |
| } |
| _builder.append(groupBy, ""); |
| groupingString = _builder.toString(); |
| } |
| return groupingString; |
| } |
| |
| /** |
| * <p>sql syntax part for where.</p> |
| */ |
| public String createCondition(final ArrayList<String> conditions) { |
| String conditionString = ""; |
| for (final String condition : conditions) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| boolean _isEmpty = conditionString.isEmpty(); |
| boolean _not = (!_isEmpty); |
| if (_not) { |
| _builder.append(conditionString, ""); |
| _builder.append(" and "); |
| } |
| } |
| _builder.append("("); |
| _builder.append(condition, ""); |
| _builder.append(")"); |
| conditionString = _builder.toString(); |
| } |
| return conditionString; |
| } |
| |
| /** |
| * <p>sql syntax part for order.</p> |
| */ |
| public String createOrdering(final ArrayList<String> orderings) { |
| String orderingString = ""; |
| for (final String order : orderings) { |
| { |
| this.sqlHasOrder = true; |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| boolean _isEmpty = orderingString.isEmpty(); |
| boolean _not = (!_isEmpty); |
| if (_not) { |
| _builder.append(orderingString, ""); |
| _builder.append(","); |
| } |
| } |
| _builder.append(order, ""); |
| orderingString = _builder.toString(); |
| } |
| } |
| return orderingString; |
| } |
| |
| /** |
| * <p>sql syntax part for select.</p> |
| */ |
| public String createSelect(final Map<String, String> properties, final DatamartDefinition definition) { |
| String selectString = ""; |
| this.datamartDtoMapper = "new DatamartDtoMapper()"; |
| Set<String> _keySet = properties.keySet(); |
| for (final String property : _keySet) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| boolean _isEmpty = selectString.isEmpty(); |
| boolean _not = (!_isEmpty); |
| if (_not) { |
| _builder.append(selectString, ""); |
| _builder.append(","); |
| } |
| } |
| _builder.append(property, ""); |
| { |
| String _get = properties.get(property); |
| int _length = _get.length(); |
| boolean _greaterThan = (_length > 0); |
| if (_greaterThan) { |
| _builder.append(" as \\\""); |
| String _get_1 = properties.get(property); |
| _builder.append(_get_1, ""); |
| _builder.append("\\\""); |
| } |
| } |
| selectString = _builder.toString(); |
| } |
| boolean _notEquals = (!Objects.equal(definition, null)); |
| if (_notEquals) { |
| if ((!this.ignoreEntityGrouping)) { |
| Collection<LEntity> _values = this.entityGrouping.values(); |
| for (final LEntity entityRef : _values) { |
| { |
| String entityName = entityRef.getName(); |
| String dtoFqn = EntityUtils.getDtoFQNForLEntity(entityRef); |
| LEntityAttribute idAttribute = DatamartDefinitionUtil.getEntityIdAttribute(entityRef); |
| String _entityIdDatatype = DatamartDefinitionUtil.getEntityIdDatatype(entityRef); |
| IDataMart.EType _basicType = this.dtType.getBasicType(_entityIdDatatype); |
| String idDataType = _basicType.toString(); |
| String idColumn = DatamartDefinitionUtil.getEntityIdAliasName(entityRef); |
| boolean _notEquals_1 = (!Objects.equal(idAttribute, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(selectString, ""); |
| _builder_1.append(","); |
| _builder_1.append(entityName, ""); |
| _builder_1.append("."); |
| String _name = idAttribute.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append(" as \\\""); |
| _builder_1.append(idColumn, ""); |
| _builder_1.append("\\\""); |
| selectString = _builder_1.toString(); |
| this.idMap.put(idColumn, idAttribute); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(this.datamartDtoMapper, ""); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append(".add(\""); |
| _builder_2.append(dtoFqn, ""); |
| _builder_2.append("\", \""); |
| String _name_1 = idAttribute.getName(); |
| _builder_2.append(_name_1, ""); |
| _builder_2.append("\", EType."); |
| _builder_2.append(idDataType, ""); |
| _builder_2.append(", \""); |
| _builder_2.append(idColumn, ""); |
| _builder_2.append("\")"); |
| this.datamartDtoMapper = _builder_2.toString(); |
| } |
| } |
| } |
| } |
| } |
| return selectString; |
| } |
| |
| /** |
| * <p>recursive entity relation builder.</p> |
| */ |
| public String createEntity(final DatamartEntity entity, final DatamartEntity parent, final DatamartNavigation parentNavigation, final Map<String, String> properties, final List<String> conditions, final List<String> orderings, final DatamartRole role, final HashMap<String, LEntityAttribute> typesMap) { |
| String body = ""; |
| boolean _isAuthorized = this.isAuthorized(role, entity); |
| if (_isAuthorized) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(body, ""); |
| LEntity _entityRef = entity.getEntityRef(); |
| LEntityPersistenceInfo _persistenceInfo = _entityRef.getPersistenceInfo(); |
| String _schemaName = _persistenceInfo.getSchemaName(); |
| CharSequence _provideSchemaName = this.getProvideSchemaName(_schemaName); |
| _builder.append(_provideSchemaName, ""); |
| LEntity _entityRef_1 = entity.getEntityRef(); |
| String _tableName = this._namingExtensions.toTableName(_entityRef_1); |
| _builder.append(_tableName, ""); |
| _builder.append(" "); |
| String _entityAlias2 = this.entityAlias2(entity); |
| _builder.append(_entityAlias2, ""); |
| body = _builder.toString(); |
| boolean _and = false; |
| boolean _notEquals = (!Objects.equal(parent, null)); |
| if (!_notEquals) { |
| _and = false; |
| } else { |
| boolean _notEquals_1 = (!Objects.equal(parentNavigation, null)); |
| _and = _notEquals_1; |
| } |
| if (_and) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(" "); |
| _builder_1.append("left join "); |
| _builder_1.append(body, " "); |
| String _createJoin = this.createJoin(entity, parent, parentNavigation); |
| _builder_1.append(_createJoin, " "); |
| body = _builder_1.toString(); |
| } |
| EList<DatamartNavigation> _navigations = entity.getNavigations(); |
| for (final DatamartNavigation navigation : _navigations) { |
| { |
| if ((navigation instanceof DatamartMember)) { |
| DatamartEntity _datamartEntity = ((DatamartMember) navigation).getDatamartEntity(); |
| DatamartReference _joinRef = ((DatamartMember) navigation).getJoinRef(); |
| boolean _isAuthorized_1 = this.isAuthorized(role, _datamartEntity, ((DatamartReference) _joinRef)); |
| if (_isAuthorized_1) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(body, ""); |
| DatamartEntity _datamartEntity_1 = ((DatamartMember) navigation).getDatamartEntity(); |
| String _createEntity = this.createEntity(_datamartEntity_1, entity, navigation, properties, conditions, orderings, role, typesMap); |
| _builder_2.append(_createEntity, ""); |
| body = _builder_2.toString(); |
| } |
| } |
| if ((navigation instanceof DatamartOwner)) { |
| DatamartEntity _datamartEntity_2 = ((DatamartOwner) navigation).getDatamartEntity(); |
| DatamartReference _joinRef_1 = ((DatamartOwner) navigation).getJoinRef(); |
| boolean _isAuthorized_2 = this.isAuthorized(role, _datamartEntity_2, ((DatamartReference) _joinRef_1)); |
| if (_isAuthorized_2) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(body, ""); |
| DatamartEntity _datamartEntity_3 = ((DatamartOwner) navigation).getDatamartEntity(); |
| String _createEntity_1 = this.createEntity(_datamartEntity_3, entity, navigation, properties, conditions, orderings, role, typesMap); |
| _builder_3.append(_createEntity_1, ""); |
| body = _builder_3.toString(); |
| } |
| } |
| } |
| } |
| EList<DatamartProperty> _properties = entity.getProperties(); |
| boolean _isEmpty = _properties.isEmpty(); |
| if (_isEmpty) { |
| LEntity _entityRef_2 = entity.getEntityRef(); |
| List<LEntityAttribute> _allAttributes = _entityRef_2.getAllAttributes(); |
| for (final LEntityAttribute attr : _allAttributes) { |
| boolean _and_1 = false; |
| boolean _isId = attr.isId(); |
| boolean _not = (!_isId); |
| if (!_not) { |
| _and_1 = false; |
| } else { |
| boolean _isUuid = attr.isUuid(); |
| boolean _not_1 = (!_isUuid); |
| _and_1 = _not_1; |
| } |
| if (_and_1) { |
| LEntity _entityRef_3 = entity.getEntityRef(); |
| this.recurProperty(_entityRef_3, attr, false, "", properties, role, typesMap); |
| } |
| } |
| } else { |
| EList<DatamartProperty> _properties_1 = entity.getProperties(); |
| for (final DatamartProperty property : _properties_1) { |
| LEntity _entityRef_4 = entity.getEntityRef(); |
| LEntityAttribute _propertyRef = property.getPropertyRef(); |
| boolean _isAggregated = property.isAggregated(); |
| SqlAggregationEnum _aggregate = property.getAggregate(); |
| String _name = _aggregate.getName(); |
| this.recurProperty(_entityRef_4, _propertyRef, _isAggregated, _name, properties, role, typesMap); |
| } |
| } |
| EList<DatamartCondition> _conditions = entity.getConditions(); |
| for (final DatamartCondition condition : _conditions) { |
| Expression _condition = condition.getCondition(); |
| String _evaluateExpression = this.evaluateExpression(_condition, entity); |
| conditions.add(_evaluateExpression); |
| } |
| EList<DatamartOrder> _ordering = entity.getOrdering(); |
| for (final DatamartOrder order : _ordering) { |
| String _entityAlias = this.getEntityAlias(entity); |
| String _plus = (_entityAlias + "."); |
| LEntityAttribute _orderBy = order.getOrderBy(); |
| String _columnName = this._namingExtensions.toColumnName(_orderBy); |
| String _plus_1 = (_plus + _columnName); |
| String _plus_2 = (_plus_1 + " "); |
| OrderEnum _orderHow = order.getOrderHow(); |
| String _name_1 = _orderHow.getName(); |
| String _plus_3 = (_plus_2 + _name_1); |
| orderings.add(_plus_3); |
| } |
| } |
| return body; |
| } |
| |
| public void recurProperty(final LEntity entity, final LAttribute attr, final boolean aggregated, final String aggregateName, final Map<String, String> properties, final DatamartRole role, final HashMap<String, LEntityAttribute> typesMap) { |
| LScalarType type = attr.getType(); |
| if ((type instanceof LBean)) { |
| LBean bean = ((LBean) type); |
| List<LBeanAttribute> _allAttributes = bean.getAllAttributes(); |
| for (final LBeanAttribute battr : _allAttributes) { |
| LScalarType _type = battr.getType(); |
| if ((_type instanceof LBean)) { |
| this.recurProperty(entity, battr, aggregated, aggregateName, properties, role, typesMap); |
| } else { |
| this.addProperty(entity, attr, aggregated, aggregateName, properties, role, typesMap); |
| } |
| } |
| } else { |
| this.addProperty(entity, attr, aggregated, aggregateName, properties, role, typesMap); |
| } |
| } |
| |
| public void addProperty(final LEntity entity, final LAttribute attr, final boolean aggregated, final String aggregateName, final Map<String, String> properties, final DatamartRole role, final HashMap<String, LEntityAttribute> typesMap) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityAlias = this.getEntityAlias(entity); |
| _builder.append(_entityAlias, ""); |
| _builder.append("."); |
| String _columnName = this._namingExtensions.toColumnName(attr); |
| _builder.append(_columnName, ""); |
| String key = _builder.toString(); |
| String _name = entity.getName(); |
| String _plus = (_name + "."); |
| String _columnName_1 = this._namingExtensions.toColumnName(attr); |
| String _lowerCase = _columnName_1.toLowerCase(); |
| String _plus_1 = (_plus + _lowerCase); |
| typesMap.put(_plus_1, ((LEntityAttribute) attr)); |
| String _name_1 = attr.getName(); |
| boolean _isAuthorized = this.isAuthorized(role, entity, _name_1); |
| if (_isAuthorized) { |
| if (aggregated) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(aggregateName, ""); |
| _builder_1.append("("); |
| _builder_1.append(key, ""); |
| _builder_1.append(")"); |
| key = _builder_1.toString(); |
| this.sqlHasAggregate = true; |
| String _string = key.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_2 = attr.getName(); |
| _builder_2.append(_name_2, ""); |
| properties.put(_string, _builder_2.toString()); |
| this.ignoreEntityGrouping = true; |
| } else { |
| String _entityAlias_1 = this.getEntityAlias(entity); |
| this.entityGrouping.put(_entityAlias_1, entity); |
| String _string_1 = key.toString(); |
| this.sqlGrouping.add(_string_1); |
| String _string_2 = key.toString(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_3 = attr.getName(); |
| _builder_3.append(_name_3, ""); |
| properties.put(_string_2, _builder_3.toString()); |
| } |
| } |
| } |
| |
| public boolean isAuthorized(final DatamartRole role, final DatamartEntity entity) { |
| boolean _equals = Objects.equal(role, null); |
| if (_equals) { |
| return true; |
| } |
| Role _assignedRole = role.getAssignedRole(); |
| EList<RoleElement> _roleElements = _assignedRole.getRoleElements(); |
| for (final RoleElement roleElement : _roleElements) { |
| if ((roleElement instanceof RoleEntity)) { |
| LEntity _entityRef = entity.getEntityRef(); |
| String _name = _entityRef.getName(); |
| LEntity _entityRef_1 = ((RoleEntity) roleElement).getEntityRef(); |
| String _name_1 = ((LEntity) _entityRef_1).getName(); |
| boolean _equals_1 = _name.equals(_name_1); |
| if (_equals_1) { |
| return true; |
| } |
| } |
| } |
| return false; |
| } |
| |
| public boolean isAuthorized(final DatamartRole role, final LEntity entity, final String propertyName) { |
| boolean _equals = Objects.equal(role, null); |
| if (_equals) { |
| return true; |
| } |
| Role _assignedRole = role.getAssignedRole(); |
| EList<RoleElement> _roleElements = _assignedRole.getRoleElements(); |
| for (final RoleElement roleElement : _roleElements) { |
| if ((roleElement instanceof RoleEntity)) { |
| String _name = entity.getName(); |
| LEntity _entityRef = ((RoleEntity) roleElement).getEntityRef(); |
| String _name_1 = ((LEntity) _entityRef).getName(); |
| boolean _equals_1 = _name.equals(_name_1); |
| if (_equals_1) { |
| EList<RoleEntityFeature> _entityFeatures = ((RoleEntity) roleElement).getEntityFeatures(); |
| for (final RoleEntityFeature feature : _entityFeatures) { |
| LEntityFeature _entityAttriCol = feature.getEntityAttriCol(); |
| String _name_2 = ((LEntityFeature) _entityAttriCol).getName(); |
| boolean _equals_2 = propertyName.equals(_name_2); |
| if (_equals_2) { |
| if ((feature instanceof RoleEntityAttribute)) { |
| RolePropertyEnum _entityAttriUnauthorized = ((RoleEntityAttribute)feature).getEntityAttriUnauthorized(); |
| String _literal = _entityAttriUnauthorized.getLiteral(); |
| boolean _equals_3 = "invisible".equals(_literal); |
| if (_equals_3) { |
| return false; |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| return true; |
| } |
| |
| public boolean isAuthorized(final DatamartRole role, final String entityAttribute) { |
| boolean _equals = Objects.equal(role, null); |
| if (_equals) { |
| return true; |
| } |
| Role _assignedRole = role.getAssignedRole(); |
| EList<RoleElement> _roleElements = _assignedRole.getRoleElements(); |
| for (final RoleElement roleElement : _roleElements) { |
| if ((roleElement instanceof RoleEntity)) { |
| String[] parts = entityAttribute.split("\\."); |
| String _get = parts[0]; |
| LEntity _entityRef = ((RoleEntity) roleElement).getEntityRef(); |
| String _name = ((LEntity) _entityRef).getName(); |
| boolean _equals_1 = _get.equals(_name); |
| if (_equals_1) { |
| EList<RoleEntityFeature> _entityFeatures = ((RoleEntity) roleElement).getEntityFeatures(); |
| for (final RoleEntityFeature feature : _entityFeatures) { |
| String _get_1 = parts[1]; |
| LEntityFeature _entityAttriCol = feature.getEntityAttriCol(); |
| String _name_1 = ((LEntityFeature) _entityAttriCol).getName(); |
| boolean _equals_2 = _get_1.equals(_name_1); |
| if (_equals_2) { |
| if ((feature instanceof RoleEntityAttribute)) { |
| RolePropertyEnum _entityAttriUnauthorized = ((RoleEntityAttribute)feature).getEntityAttriUnauthorized(); |
| String _literal = _entityAttriUnauthorized.getLiteral(); |
| boolean _equals_3 = "invisible".equals(_literal); |
| if (_equals_3) { |
| return false; |
| } |
| } |
| } |
| } |
| return true; |
| } |
| } |
| } |
| return false; |
| } |
| |
| public boolean isAuthorized(final DatamartRole role, final DatamartEntity entity, final DatamartReference link) { |
| boolean _equals = Objects.equal(role, null); |
| if (_equals) { |
| return true; |
| } |
| Role _assignedRole = role.getAssignedRole(); |
| EList<RoleElement> _roleElements = _assignedRole.getRoleElements(); |
| for (final RoleElement roleElement : _roleElements) { |
| if ((roleElement instanceof RoleEntity)) { |
| LEntity _entityRef = entity.getEntityRef(); |
| String _name = _entityRef.getName(); |
| LEntity _entityRef_1 = ((RoleEntity) roleElement).getEntityRef(); |
| String _name_1 = ((LEntity) _entityRef_1).getName(); |
| boolean _equals_1 = _name.equals(_name_1); |
| if (_equals_1) { |
| EList<RoleEntityFeature> _entityFeatures = ((RoleEntity) roleElement).getEntityFeatures(); |
| for (final RoleEntityFeature feature : _entityFeatures) { |
| if ((feature instanceof RoleEntityReference)) { |
| LEntityReference _ref = link.getRef(); |
| String _name_2 = _ref.getName(); |
| String _lowerCase = _name_2.toLowerCase(); |
| LEntityFeature _entityAttriCol = ((RoleEntityReference)feature).getEntityAttriCol(); |
| String _name_3 = ((LEntityFeature) _entityAttriCol).getName(); |
| boolean _equals_2 = _lowerCase.equals(_name_3); |
| if (_equals_2) { |
| String _literal = RolePropertyEnum.INVISIBLE.getLiteral(); |
| RolePropertyEnum _entityAttriUnauthorized = ((RoleEntityReference)feature).getEntityAttriUnauthorized(); |
| String _literal_1 = _entityAttriUnauthorized.getLiteral(); |
| boolean _equals_3 = _literal.equals(_literal_1); |
| if (_equals_3) { |
| return false; |
| } |
| } |
| } |
| } |
| return true; |
| } |
| } |
| } |
| return false; |
| } |
| |
| public CharSequence getProvideSchemaName(final String schemaName) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| boolean _and = false; |
| boolean _notEquals = (!Objects.equal(schemaName, null)); |
| if (!_notEquals) { |
| _and = false; |
| } else { |
| int _length = schemaName.length(); |
| boolean _greaterThan = (_length > 0); |
| _and = _greaterThan; |
| } |
| if (_and) { |
| _builder.append(schemaName, ""); |
| _builder.append("."); |
| } |
| } |
| return _builder; |
| } |
| |
| /** |
| * <p>sql syntax part for joined relations.</p> |
| */ |
| public String createJoin(final DatamartEntity entity, final DatamartEntity parent, final DatamartNavigation navigation) { |
| String _xblockexpression = null; |
| { |
| String join = ""; |
| DatamartReference joinRef = navigation.getJoinRef(); |
| String _xifexpression = null; |
| if ((joinRef instanceof DatamartReference)) { |
| String _xblockexpression_1 = null; |
| { |
| LEntityReference _ref = joinRef.getRef(); |
| String name = _ref.getName(); |
| if ((navigation instanceof DatamartMember)) { |
| DatamartEntity _datamartEntity = ((DatamartMember)navigation).getDatamartEntity(); |
| LEntity _entityRef = _datamartEntity.getEntityRef(); |
| List<LEntityReference> refs = _entityRef.getAllReferences(); |
| for (final LEntityReference ref : refs) { |
| boolean _and = false; |
| LEntity _type = ref.getType(); |
| boolean _notEquals = (!Objects.equal(_type, null)); |
| if (!_notEquals) { |
| _and = false; |
| } else { |
| LEntity _type_1 = ref.getType(); |
| LEntity _entityRef_1 = parent.getEntityRef(); |
| boolean _equals = _type_1.equals(_entityRef_1); |
| _and = _equals; |
| } |
| if (_and) { |
| String _name = ref.getName(); |
| name = _name; |
| } |
| } |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityAlias = this.getEntityAlias(entity); |
| _builder.append(_entityAlias, ""); |
| _builder.append("."); |
| _builder.append(name, ""); |
| _builder.append("_id="); |
| String _entityAlias_1 = this.getEntityAlias(parent); |
| _builder.append(_entityAlias_1, ""); |
| _builder.append(".id"); |
| join = _builder.toString(); |
| } else { |
| if ((navigation instanceof DatamartOwner)) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| String _entityAlias_2 = this.getEntityAlias(entity); |
| _builder_1.append(_entityAlias_2, ""); |
| _builder_1.append(".id="); |
| String _entityAlias_3 = this.getEntityAlias(parent); |
| _builder_1.append(_entityAlias_3, ""); |
| _builder_1.append("."); |
| _builder_1.append(name, ""); |
| _builder_1.append("_id"); |
| join = _builder_1.toString(); |
| } |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(" "); |
| _builder_2.append("on("); |
| _builder_2.append(join, " "); |
| _builder_2.append(")"); |
| _xblockexpression_1 = join = _builder_2.toString(); |
| } |
| _xifexpression = _xblockexpression_1; |
| } |
| _xblockexpression = _xifexpression; |
| } |
| return _xblockexpression; |
| } |
| |
| /** |
| * get a set of entities used by the datamart |
| */ |
| public Set<LEntity> findAllEntities(final DatamartDefinition datamart) { |
| HashSet<LEntity> entities = new HashSet<LEntity>(); |
| DatamartSource _source = datamart.getSource(); |
| boolean _matched = false; |
| if (!_matched) { |
| if (_source instanceof DatamartEntity) { |
| _matched=true; |
| DatamartSource _source_1 = datamart.getSource(); |
| this.findAllEntites(((DatamartEntity) _source_1), entities); |
| } |
| } |
| return entities; |
| } |
| |
| /** |
| * add all entities used by the datamart entity into the given set of entities |
| */ |
| public void findAllEntites(final DatamartEntity datamartEntity, final Set<LEntity> entities) { |
| LEntity _entityRef = datamartEntity.getEntityRef(); |
| entities.add(_entityRef); |
| EList<DatamartNavigation> _navigations = datamartEntity.getNavigations(); |
| for (final DatamartNavigation navigation : _navigations) { |
| DatamartEntity _datamartEntity = navigation.getDatamartEntity(); |
| this.findAllEntites(_datamartEntity, entities); |
| } |
| } |
| |
| public void infer(final EObject datamart, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| if (datamart instanceof DatamartPackage) { |
| _infer((DatamartPackage)datamart, acceptor, isPreIndexingPhase); |
| return; |
| } else if (datamart != null) { |
| _infer(datamart, acceptor, isPreIndexingPhase); |
| return; |
| } else { |
| throw new IllegalArgumentException("Unhandled parameter types: " + |
| Arrays.<Object>asList(datamart, acceptor, isPreIndexingPhase).toString()); |
| } |
| } |
| } |