| /** |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 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 |
| * |
| * |
| * This copyright notice shows up in the generated Java code |
| */ |
| package org.eclipse.osbp.xtext.reportdsl.jvmmodel; |
| |
| import com.vaadin.data.Container; |
| import com.vaadin.ui.VerticalLayout; |
| import java.util.ArrayList; |
| import java.util.Arrays; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.Set; |
| import java.util.function.Consumer; |
| import javax.inject.Inject; |
| import org.eclipse.e4.core.contexts.IEclipseContext; |
| import org.eclipse.e4.core.services.events.IEventBroker; |
| import org.eclipse.e4.ui.model.application.MApplication; |
| import org.eclipse.e4.ui.workbench.IPresentationEngine; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntity; |
| import org.eclipse.osbp.ui.api.datamart.IDataMart; |
| import org.eclipse.osbp.ui.api.e4.IE4Focusable; |
| import org.eclipse.osbp.ui.api.report.IReportProvider; |
| import org.eclipse.osbp.ui.api.themes.IThemeResourceService; |
| import org.eclipse.osbp.ui.api.user.IUser; |
| import org.eclipse.osbp.xtext.action.ActionPackage; |
| import org.eclipse.osbp.xtext.action.ActionToolbar; |
| import org.eclipse.osbp.xtext.datamartdsl.jvmmodel.DatamartDSLJvmModelInferrer; |
| import org.eclipse.osbp.xtext.reportdsl.DatamartTableAttribute; |
| import org.eclipse.osbp.xtext.reportdsl.Element; |
| import org.eclipse.osbp.xtext.reportdsl.Grid; |
| import org.eclipse.osbp.xtext.reportdsl.GridCell; |
| import org.eclipse.osbp.xtext.reportdsl.GridRow; |
| import org.eclipse.osbp.xtext.reportdsl.PageHeader; |
| import org.eclipse.osbp.xtext.reportdsl.RenderingEnum; |
| import org.eclipse.osbp.xtext.reportdsl.Report; |
| import org.eclipse.osbp.xtext.reportdsl.ReportDesign; |
| import org.eclipse.osbp.xtext.reportdsl.ReportDesignFile; |
| import org.eclipse.osbp.xtext.reportdsl.ReportDesignTemplate; |
| import org.eclipse.osbp.xtext.reportdsl.ReportPackage; |
| import org.eclipse.osbp.xtext.reportdsl.TableAttribute; |
| import org.eclipse.osbp.xtext.reportdsl.TableValueElement; |
| import org.eclipse.osbp.xtext.reportdsl.common.AbstractReportBean; |
| import org.eclipse.osbp.xtext.reportdsl.common.BaseReport; |
| import org.eclipse.xtend2.lib.StringConcatenation; |
| import org.eclipse.xtext.common.types.JvmAnnotationReference; |
| import org.eclipse.xtext.common.types.JvmConstructor; |
| 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.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.Extension; |
| import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; |
| import org.eclipse.xtext.xbase.lib.StringExtensions; |
| |
| /** |
| * <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 ReportDSLJvmModelInferrer 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 DatamartDSLJvmModelInferrer _datamartDSLJvmModelInferrer; |
| |
| protected void _infer(final ReportPackage pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| final Consumer<Report> _function = (Report report) -> { |
| QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(report); |
| String _plus = (_fullyQualifiedName + "Report"); |
| JvmGenericType cls = this._jvmTypesBuilder.toClass(report, _plus); |
| final Procedure1<JvmGenericType> _function_1 = (JvmGenericType it) -> { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(BaseReport.class); |
| this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| EList<JvmTypeReference> _superTypes_1 = it.getSuperTypes(); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IE4Focusable.class); |
| this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_1, _typeRef_1); |
| this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(pckg)); |
| this.toConstructor(it, report); |
| this.toOperations(it, pckg, report); |
| }; |
| acceptor.<JvmGenericType>accept(cls, _function_1); |
| this.addReportBean(cls, pckg, report, acceptor); |
| }; |
| pckg.getReports().forEach(_function); |
| } |
| |
| public void addReportBean(final JvmDeclaredType type, final ReportPackage pckg, final Report report, final IJvmDeclaredTypeAcceptor acceptor) { |
| JvmGenericType beanCls = this._jvmTypesBuilder.toClass(report, "Bean"); |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmGenericType>operator_add(_members, beanCls); |
| final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { |
| it.getSuperTypes().add(this._typeReferenceBuilder.typeRef(AbstractReportBean.class)); |
| it.setStatic(true); |
| EList<JvmMember> _members_1 = it.getMembers(); |
| final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it_1.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return new "); |
| QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(report); |
| _builder.append(_fullyQualifiedName); |
| _builder.append("Report(null,null,null);"); |
| it_2.append(_builder); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_2); |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(report, "createReport", this._typeReferenceBuilder.typeRef(BaseReport.class), _function_1); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method); |
| }; |
| acceptor.<JvmGenericType>accept(beanCls, _function); |
| } |
| |
| public void toConstructor(final JvmDeclaredType type, final Report report) { |
| EList<JvmMember> _members = type.getMembers(); |
| final Procedure1<JvmConstructor> _function = (JvmConstructor it) -> { |
| this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(report)); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(report, "parent", this._typeReferenceBuilder.typeRef(VerticalLayout.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(report, "context", this._typeReferenceBuilder.typeRef(IEclipseContext.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| EList<JvmFormalParameter> _parameters_2 = it.getParameters(); |
| JvmFormalParameter _parameter_2 = this._jvmTypesBuilder.toParameter(report, "app", this._typeReferenceBuilder.typeRef(MApplication.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2); |
| final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("super(parent,context,app);"); |
| it_1.append(_builder); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_1); |
| }; |
| JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(report, _function); |
| this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor); |
| } |
| |
| public void toOperations(final JvmDeclaredType type, final ReportPackage pckg, final Report report) { |
| EList<JvmMember> _members = type.getMembers(); |
| final Procedure1<JvmField> _function = (JvmField it) -> { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| }; |
| JvmField _field = this._jvmTypesBuilder.toField(report, "eventBroker", this._typeReferenceBuilder.typeRef(IEventBroker.class), _function); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members, _field); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| final Procedure1<JvmField> _function_1 = (JvmField it) -> { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(report, "renderingEngine", this._typeReferenceBuilder.typeRef(IPresentationEngine.class), _function_1); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_1, _field_1); |
| EList<JvmMember> _members_2 = type.getMembers(); |
| final Procedure1<JvmField> _function_2 = (JvmField it) -> { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| }; |
| JvmField _field_2 = this._jvmTypesBuilder.toField(report, "themeResourceService", this._typeReferenceBuilder.typeRef(IThemeResourceService.class), _function_2); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| EList<JvmMember> _members_3 = type.getMembers(); |
| final Procedure1<JvmField> _function_3 = (JvmField it) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new ArrayList() {{"); |
| _builder.newLine(); |
| String _addStaticData = this.addStaticData(report); |
| _builder.append(_addStaticData); |
| _builder.append("}}"); |
| it_1.append(_builder); |
| }; |
| this._jvmTypesBuilder.setInitializer(it, _function_4); |
| }; |
| JvmField _field_3 = this._jvmTypesBuilder.toField(report, "staticData", this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(String.class)), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_3, _field_3); |
| EList<JvmMember> _members_4 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return staticData;"); |
| it_1.append(_builder); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_5); |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(report, "getStaticData", this._typeReferenceBuilder.typeRef(List.class, this._typeReferenceBuilder.typeRef(String.class)), _function_4); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method); |
| ActionToolbar _toolbar = report.getToolbar(); |
| boolean _tripleNotEquals = (_toolbar != null); |
| if (_tripleNotEquals) { |
| EObject _eContainer = report.getToolbar().eContainer(); |
| String packageName = this._iQualifiedNameProvider.getFullyQualifiedName(((ActionPackage) _eContainer)).toString(); |
| EList<JvmMember> _members_5 = type.getMembers(); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(packageName); |
| _builder.append("."); |
| String _firstUpper = StringExtensions.toFirstUpper(report.getToolbar().getName().toString()); |
| _builder.append(_firstUpper); |
| _builder.append("Toolbar"); |
| JvmField _field_4 = this._jvmTypesBuilder.toField(report, "toolbarClass", this._typeReferenceBuilder.typeRef(_builder.toString())); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_5, _field_4); |
| } |
| EList<JvmMember> _members_6 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_5 = (JvmOperation it) -> { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(report, "parent", this._typeReferenceBuilder.typeRef(VerticalLayout.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| CharSequence _createView = this.createView(report); |
| _builder_1.append(_createView); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_6); |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(report, "createView", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_5); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_1); |
| EList<JvmMember> _members_7 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_6 = (JvmOperation it) -> { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_1) -> { |
| RenderingEnum _rendering = report.getRendering(); |
| if (_rendering != null) { |
| switch (_rendering) { |
| case HTML: |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return Rendering.HTML_STREAM;"); |
| it_1.append(_builder_1); |
| break; |
| case PDF: |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("return Rendering.PDF_STREAM;"); |
| it_1.append(_builder_2); |
| break; |
| default: |
| break; |
| } |
| } |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_7); |
| }; |
| JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(report, "getRenderingAs", this._typeReferenceBuilder.typeRef(IReportProvider.Rendering.class), _function_6); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_2); |
| EList<JvmMember> _members_8 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return \""); |
| String _name = report.getName(); |
| _builder_1.append(_name); |
| _builder_1.append("\";"); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_8); |
| }; |
| JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(report, "getReportName", this._typeReferenceBuilder.typeRef(String.class), _function_7); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_3); |
| if (((pckg.getExternalCssURIBundle() != null) || (report.getExternalCssURIBundle() != null))) { |
| EList<JvmMember> _members_9 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_8 = (JvmOperation it) -> { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> { |
| String _externalCssURIBundle = report.getExternalCssURIBundle(); |
| boolean _tripleNotEquals_1 = (_externalCssURIBundle != null); |
| if (_tripleNotEquals_1) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return \""); |
| String _externalCssURIBundle_1 = report.getExternalCssURIBundle(); |
| _builder_1.append(_externalCssURIBundle_1); |
| _builder_1.append("\";"); |
| it_1.append(_builder_1); |
| } else { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("return \""); |
| String _externalCssURIBundle_2 = pckg.getExternalCssURIBundle(); |
| _builder_2.append(_externalCssURIBundle_2); |
| _builder_2.append("\";"); |
| it_1.append(_builder_2); |
| } |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_9); |
| }; |
| JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(report, "getExternalCssURIBundle", this._typeReferenceBuilder.typeRef(String.class), _function_8); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_4); |
| } |
| if (((pckg.getExternalCssURI() != null) || (report.getExternalCssURI() != null))) { |
| EList<JvmMember> _members_10 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> { |
| String _externalCssURI = report.getExternalCssURI(); |
| boolean _tripleNotEquals_1 = (_externalCssURI != null); |
| if (_tripleNotEquals_1) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return \""); |
| String _externalCssURI_1 = report.getExternalCssURI(); |
| _builder_1.append(_externalCssURI_1); |
| _builder_1.append("\";"); |
| it_1.append(_builder_1); |
| } else { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("return \""); |
| String _externalCssURI_2 = pckg.getExternalCssURI(); |
| _builder_2.append(_externalCssURI_2); |
| _builder_2.append("\";"); |
| it_1.append(_builder_2); |
| } |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_10); |
| }; |
| JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(report, "getExternalCssURI", this._typeReferenceBuilder.typeRef(String.class), _function_9); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_5); |
| } |
| EList<JvmMember> _members_11 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> { |
| this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(report.getDatamartRef())); |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(report, "user", this._typeReferenceBuilder.typeRef(IUser.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(report.getDatamartRef()); |
| _builder_1.append(_fullyQualifiedName); |
| _builder_1.append("Datamart "); |
| String _firstLower = StringExtensions.toFirstLower(report.getDatamartRef().getName()); |
| _builder_1.append(_firstLower); |
| _builder_1.append("Datamart = new "); |
| QualifiedName _fullyQualifiedName_1 = this._iQualifiedNameProvider.getFullyQualifiedName(report.getDatamartRef()); |
| _builder_1.append(_fullyQualifiedName_1); |
| _builder_1.append("Datamart();"); |
| _builder_1.newLineIfNotEmpty(); |
| String _firstLower_1 = StringExtensions.toFirstLower(report.getDatamartRef().getName()); |
| _builder_1.append(_firstLower_1); |
| _builder_1.append("Datamart.setUser(user);"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("return "); |
| String _firstLower_2 = StringExtensions.toFirstLower(report.getDatamartRef().getName()); |
| _builder_1.append(_firstLower_2); |
| _builder_1.append("Datamart;"); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_11); |
| }; |
| JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(report, "getDatamartInstance", this._typeReferenceBuilder.typeRef(IDataMart.class), _function_10); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_6); |
| EList<JvmMember> _members_12 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_11 = (JvmOperation it) -> { |
| this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(report.getDatamartRef())); |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return "); |
| boolean _booleanValue = Boolean.valueOf(report.isSelectById()).booleanValue(); |
| _builder_1.append(_booleanValue); |
| _builder_1.append(";"); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_12); |
| }; |
| JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(report, "getSelectById", this._typeReferenceBuilder.typeRef(boolean.class), _function_11); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_12, _method_7); |
| ReportDesign _design = report.getDesign(); |
| if ((_design instanceof ReportDesignFile)) { |
| EList<JvmMember> _members_13 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_12 = (JvmOperation it) -> { |
| this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(report.getDesign())); |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_13 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return \""); |
| ReportDesign _design_1 = report.getDesign(); |
| String _name = ((ReportDesignFile) _design_1).getName(); |
| _builder_1.append(_name); |
| _builder_1.append("\";"); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_13); |
| }; |
| JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(report, "getReportDesignFilename", this._typeReferenceBuilder.typeRef(String.class), _function_12); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_13, _method_8); |
| } else { |
| ReportDesign _design_1 = report.getDesign(); |
| if ((_design_1 instanceof ReportDesignTemplate)) { |
| EList<JvmMember> _members_14 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_13 = (JvmOperation it) -> { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_14 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return null;"); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_14); |
| }; |
| JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(report, "getReportDesignFilename", this._typeReferenceBuilder.typeRef(String.class), _function_13); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_14, _method_9); |
| } |
| } |
| EList<JvmMember> _members_15 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_14 = (JvmOperation it) -> { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(report, "filter", this._typeReferenceBuilder.typeRef(Container.Filter.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function_15 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("// !!! no datamart, entity and DTO found for the report --> nothing can be done in here !!!"); |
| _builder_1.newLine(); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_15); |
| }; |
| JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(report, "applyBeanFilter", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_14); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_15, _method_10); |
| EList<JvmMember> _members_16 = type.getMembers(); |
| final Procedure1<JvmOperation> _function_15 = (JvmOperation it) -> { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(report, "dto", this._typeReferenceBuilder.typeRef(Object.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function_16 = (ITreeAppendable it_1) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("// !!! no datamart, entity and DTO found for the report --> nothing can be done in here !!!"); |
| _builder_1.newLine(); |
| it_1.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it, _function_16); |
| }; |
| JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(report, "applyBeanDto", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_15); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_16, _method_11); |
| } |
| |
| public String addStaticData(final Report report) { |
| ReportDesign _design = report.getDesign(); |
| if ((_design instanceof ReportDesignTemplate)) { |
| ReportDesign _design_1 = report.getDesign(); |
| PageHeader _header = ((ReportDesignTemplate) _design_1).getHeader(); |
| boolean _tripleNotEquals = (_header != null); |
| if (_tripleNotEquals) { |
| ReportDesign _design_2 = report.getDesign(); |
| return this.decodeContainer(((ReportDesignTemplate) _design_2).getHeader()); |
| } |
| } |
| return null; |
| } |
| |
| public String decodeContainer(final org.eclipse.osbp.xtext.reportdsl.Container container) { |
| String body = ""; |
| EList<Element> _elements = container.getElements(); |
| for (final Element element : _elements) { |
| boolean _matched = false; |
| if (element instanceof Grid) { |
| _matched=true; |
| EList<GridRow> _rows = ((Grid)element).getRows(); |
| for (final GridRow row : _rows) { |
| boolean _matched_1 = false; |
| if (row instanceof GridRow) { |
| _matched_1=true; |
| EList<GridCell> _cells = ((GridRow) row).getCells(); |
| for (final GridCell cell : _cells) { |
| String _decodeContainer = this.decodeContainer(cell); |
| String _plus = (body + _decodeContainer); |
| body = _plus; |
| } |
| } |
| if (!_matched_1) { |
| if (row instanceof GridCell) { |
| _matched_1=true; |
| String _decodeContainer = this.decodeContainer(((GridCell) row)); |
| String _plus = (body + _decodeContainer); |
| body = _plus; |
| } |
| } |
| } |
| } |
| if (!_matched) { |
| if (element instanceof DatamartTableAttribute) { |
| _matched=true; |
| TableValueElement _column = ((DatamartTableAttribute) element).getColumn(); |
| if ((_column instanceof TableAttribute)) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append(body); |
| _builder.append("add(\""); |
| TableValueElement _column_1 = ((DatamartTableAttribute) element).getColumn(); |
| String _name = ((TableAttribute) _column_1).getValueRef().getAttributeRef().getName(); |
| _builder.append(_name); |
| _builder.append("\");"); |
| _builder.newLineIfNotEmpty(); |
| body = _builder.toString(); |
| } |
| } |
| } |
| } |
| return body; |
| } |
| |
| /** |
| * get a set of all entities used in the given report |
| */ |
| public Set<LEntity> findRequestedEntities(final Report report) { |
| HashSet<LEntity> entities = new HashSet<LEntity>(); |
| entities.addAll(this._datamartDSLJvmModelInferrer.findAllEntities(report.getDatamartRef())); |
| return entities; |
| } |
| |
| public CharSequence createView(final Report report) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("super.createView(parent);"); |
| _builder.newLine(); |
| _builder.append("getContext().set(IE4Focusable.class, this);"); |
| _builder.newLine(); |
| _builder.append("workset = new ReportGeneratorWorkSet();"); |
| _builder.newLine(); |
| { |
| ActionToolbar _toolbar = report.getToolbar(); |
| boolean _tripleNotEquals = (_toolbar != null); |
| if (_tripleNotEquals) { |
| _builder.append("toolbarClass = new "); |
| String _firstUpper = StringExtensions.toFirstUpper(report.getToolbar().getName().toString()); |
| _builder.append(_firstUpper); |
| _builder.append("Toolbar(UUID.randomUUID().toString());"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("toolbarClass.createToolbar(getContext(), renderingEngine, themeResourceService);"); |
| _builder.newLine(); |
| _builder.append("addPDFDownload(toolbarClass);"); |
| _builder.newLine(); |
| } |
| } |
| _builder.append("createFilter();"); |
| _builder.newLine(); |
| return _builder; |
| } |
| |
| public void infer(final EObject pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| if (pckg instanceof ReportPackage) { |
| _infer((ReportPackage)pckg, acceptor, isPreIndexingPhase); |
| return; |
| } else if (pckg != null) { |
| _infer(pckg, acceptor, isPreIndexingPhase); |
| return; |
| } else { |
| throw new IllegalArgumentException("Unhandled parameter types: " + |
| Arrays.<Object>asList(pckg, acceptor, isPreIndexingPhase).toString()); |
| } |
| } |
| } |