| /** |
| * |
| * 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.table.jvmmodel |
| |
| import com.github.wolfie.refresher.Refresher |
| import com.vaadin.data.Property.ValueChangeListener |
| import com.vaadin.ui.Button |
| import com.vaadin.ui.Component |
| import com.vaadin.ui.VerticalLayout |
| import java.util.ArrayList |
| import java.util.Comparator |
| import java.util.Date |
| import java.util.HashMap |
| import java.util.HashSet |
| import java.util.Locale |
| import java.util.Map |
| import java.util.Set |
| import javax.annotation.PreDestroy |
| import javax.inject.Inject |
| import javax.inject.Named |
| import org.drools.event.process.ProcessCompletedEvent |
| import org.eclipse.e4.core.contexts.IContextFunction |
| 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.ecore.EObject |
| import org.eclipse.osbp.bpm.api.IBPMTaskClient |
| import org.eclipse.osbp.bpm.api.IBPMTaskEventNotification |
| import org.eclipse.osbp.bpm.api.IBlipBPMWorkloadModifiableItem |
| import org.eclipse.osbp.dsl.common.datatypes.IDto |
| import org.eclipse.osbp.dsl.entity.xtext.extensions.ModelExtensions |
| import org.eclipse.osbp.dsl.semantic.common.types.LDataType |
| import org.eclipse.osbp.dsl.semantic.common.types.LReference |
| import org.eclipse.osbp.dsl.semantic.common.types.LTypedPackage |
| import org.eclipse.osbp.dsl.semantic.entity.LEntity |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute |
| import org.eclipse.osbp.ecview.^extension.strategy.AbstractLayoutingStrategy |
| import org.eclipse.osbp.infogrid.api.IGridSourceFacade |
| import org.eclipse.osbp.osgi.hybrid.api.AbstractHybridVaaclipseView |
| import org.eclipse.osbp.runtime.common.types.ITypeProviderService |
| import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider |
| import org.eclipse.osbp.ui.api.datamart.DerivedOlapException |
| import org.eclipse.osbp.ui.api.datamart.IDatamartFilterGenerator |
| import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService |
| import org.eclipse.osbp.ui.api.themes.IThemeResourceService |
| import org.eclipse.osbp.ui.api.user.IUser |
| import org.eclipse.osbp.utils.annotation.CommonUtils |
| import org.eclipse.osbp.utils.common.EntityUtils |
| import org.eclipse.osbp.utils.constants.GeneratorConstants |
| import org.eclipse.osbp.utils.vaadin.PropertyLookup |
| import org.eclipse.osbp.vaaclipse.common.ecview.api.IECViewSessionHelper |
| import org.eclipse.osbp.xtext.action.ActionPackage |
| import org.eclipse.osbp.xtext.action.ChartActionEnum |
| import org.eclipse.osbp.xtext.action.ReportActionEnum |
| import org.eclipse.osbp.xtext.action.SelectWorkloadActionEnum |
| import org.eclipse.osbp.xtext.action.WorkflowActionEnum |
| import org.eclipse.osbp.xtext.cubedsl.CubeLevel |
| import org.eclipse.osbp.xtext.datamart.common.DatamartDefinitionUtil |
| import org.eclipse.osbp.xtext.datamart.common.olap.DerivedCellSet |
| import org.eclipse.osbp.xtext.datamart.common.sql.OperativeDtoContainer |
| import org.eclipse.osbp.xtext.datamartdsl.AxisEnum |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartCube |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartDefinition |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartPackage |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartProperty |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartTask |
| import org.eclipse.osbp.xtext.datamartdsl.jvmmodel.DatamartDSLJvmModelInferrer |
| import org.eclipse.osbp.xtext.table.Table |
| import org.eclipse.osbp.xtext.table.TableAggregation |
| import org.eclipse.osbp.xtext.table.TableAllColumns |
| import org.eclipse.osbp.xtext.table.TableAxis |
| import org.eclipse.osbp.xtext.table.TableBrokerDatamart |
| import org.eclipse.osbp.xtext.table.TableCellColor |
| import org.eclipse.osbp.xtext.table.TableColumn |
| import org.eclipse.osbp.xtext.table.TableDSLFactory |
| import org.eclipse.osbp.xtext.table.TableDatamart |
| import org.eclipse.osbp.xtext.table.TableDateDayInterval |
| import org.eclipse.osbp.xtext.table.TableDateDayLookup |
| import org.eclipse.osbp.xtext.table.TableDerived |
| import org.eclipse.osbp.xtext.table.TableDtoDatasource |
| import org.eclipse.osbp.xtext.table.TableGrid |
| import org.eclipse.osbp.xtext.table.TableHierarchy |
| import org.eclipse.osbp.xtext.table.TableIcon |
| import org.eclipse.osbp.xtext.table.TableMeasure |
| import org.eclipse.osbp.xtext.table.TableNumberInterval |
| import org.eclipse.osbp.xtext.table.TableNumberLookup |
| import org.eclipse.osbp.xtext.table.TableOption |
| import org.eclipse.osbp.xtext.table.TableOrdinal |
| import org.eclipse.osbp.xtext.table.TablePackage |
| import org.eclipse.osbp.xtext.table.TablePreorder |
| import org.eclipse.osbp.xtext.table.TableProperty |
| import org.eclipse.osbp.xtext.table.TableSelection |
| import org.eclipse.osbp.xtext.table.TableStringLookup |
| import org.eclipse.osbp.xtext.table.TableTable |
| import org.eclipse.osbp.xtext.table.TableTask |
| import org.eclipse.osbp.xtext.table.TableTextColor |
| import org.eclipse.osbp.xtext.table.TableTooltip |
| import org.eclipse.osbp.xtext.table.TableTrend |
| import org.eclipse.osbp.xtext.table.common.CellSetFilterTable |
| import org.eclipse.osbp.xtext.table.common.CellSetIndexedContainer |
| import org.eclipse.osbp.xtext.table.common.CheckboxSelectionCellSetFilterTable |
| import org.eclipse.osbp.xtext.table.common.TableFilterDecorator |
| import org.eclipse.xtext.Constants |
| import org.eclipse.xtext.EcoreUtil2 |
| import org.eclipse.xtext.common.types.JvmDeclaredType |
| import org.eclipse.xtext.common.types.JvmField |
| import org.eclipse.xtext.common.types.JvmGenericType |
| 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.xbase.jvmmodel.AbstractModelInferrer |
| import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor |
| import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder |
| import org.jbpm.task.event.entity.TaskEventType |
| import org.jbpm.task.event.entity.TaskUserEvent |
| import org.osgi.service.event.EventHandler |
| import org.slf4j.Logger |
| import org.eclipse.osbp.ui.api.layout.IViewLayoutManager |
| import org.eclipse.osbp.ui.api.datamart.IDataMart |
| |
| /** |
| * <p> |
| * This inferrer infers models of extension .table and generates code to be used by a e4 application as view. Underlying components |
| * are from the vaadin component repository |
| * </p> |
| * |
| * @author Joerg Riegel |
| */ |
| /** |
| * <p>Helper class for a Treemap in order to make double values comparable.</p> |
| * |
| */ |
| class DoubleComparator implements Comparator<Double> { |
| override compare(Double arg0, Double arg1) { |
| if (arg0 < arg1) { |
| return -1 |
| } else if (arg0 > arg1) { |
| return 1 |
| } else { |
| return 0 |
| } |
| } |
| } |
| |
| class DateComparator implements Comparator<Date> { |
| override compare(Date o1, Date o2) { |
| return o1.compareTo(o2); |
| } |
| } |
| |
| /** |
| * <p>Container class for a Hashmap value. It carries look and feel information for table cells.</p> |
| * |
| */ |
| class FormatProperty { |
| public String formatter = null |
| public String tooltipPattern = null |
| public boolean hideLabelLookup = false |
| public boolean hideLabelInterval = false |
| public boolean hideImageLabel = false |
| public boolean collapsed = false; |
| public boolean hasImage = false |
| public boolean hasImageParameter = false |
| public String imagePathParameter = null |
| public String imagePath = null |
| public boolean hasImageResize = false; |
| public String imageResizeString = null |
| public String iconName = null; |
| } |
| |
| class IdProperty { |
| public boolean collapsed = false; |
| } |
| |
| /** |
| * <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> |
| */ |
| class TableDSLJvmModelInferrer extends AbstractModelInferrer { |
| |
| @Inject extension JvmTypesBuilder |
| @Inject extension IQualifiedNameProvider |
| @Inject extension DatamartDSLJvmModelInferrer datamartInferrer |
| @Inject extension ModelExtensions |
| @Inject extension CommonUtils |
| @Inject |
| @Named(Constants.FILE_EXTENSIONS) String fileExtension |
| |
| var customformatCounter = 0 |
| |
| val CONVERT_METHOD_PREFIX = "getStringTo" |
| |
| def String getFileExtension() { |
| } |
| |
| /** |
| * <p>infer method dispatches the necessary routines to build fields, setter, getter, constructors and methods of the generated code.</p> |
| * |
| */ |
| def dispatch void infer(TablePackage pkg, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) { |
| // create table classes |
| for (table : pkg.tables) { |
| val tableoption = table.tabletype |
| var clsName = "" |
| if (tableoption.embedded) { |
| clsName = pkg.name.toString.concat(".").concat(table.name).concat(fileExtension.toFirstUpper). |
| concat("Embedded") |
| } |
| else if (table.tabletype instanceof TableGrid) { |
| clsName = pkg.name.toString.concat(".").concat(table.name).concat("Grid") |
| } |
| else if (table.tabletype instanceof TableSelection) { |
| clsName = pkg.name.toString.concat(".").concat(table.name).concat("Select") |
| } |
| else { |
| clsName = pkg.name.toString.concat(".").concat(table.name).concat(fileExtension.toFirstUpper) |
| } |
| val cls = table.toClass(clsName) |
| if (tableoption.embedded) { |
| cls.getSuperTypes().add(_typeReferenceBuilder.typeRef(IViewEmbeddedProvider)) |
| } else { |
| cls.getSuperTypes().add(_typeReferenceBuilder.typeRef(AbstractHybridVaaclipseView)) |
| } |
| cls.superTypes.add(_typeReferenceBuilder.typeRef(IUser.UserLocaleListener)) |
| if (table.task) { |
| cls.getSuperTypes().add(_typeReferenceBuilder.typeRef(IBPMTaskEventNotification)) |
| } |
| acceptor.accept(cls, |
| [ |
| documentation = GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION |
| it.toFields(table) |
| it.toConstructor(table) |
| it.toGetterSetter(table) |
| it.toOperations(pkg, table) |
| it.toStringToNumberConverter(table) |
| ]) |
| if (tableoption.embedded) { |
| |
| // the context function class |
| var contextClassName = table.name.concat(fileExtension.toFirstUpper).concat("Embedded") + |
| "ContextFunction" |
| val contextCls = pkg.toClass(contextClassName) |
| val tableClsName = clsName |
| contextCls.getSuperTypes().add(_typeReferenceBuilder.typeRef(IContextFunction)) |
| contextCls.simpleName = contextCls.simpleName.toFirstUpper |
| acceptor.accept(contextCls, |
| [ |
| var annotationRef = _annotationTypesBuilder.annotationRef( |
| typeof(org.osgi.service.component.annotations.Component)) |
| annotationRef.addAnnAttr(table, "service", |
| _typeReferenceBuilder.typeRef(IContextFunction) as JvmTypeReference) |
| var propContent = '''«IContextFunction.SERVICE_CONTEXT_KEY»=«table.name.toFirstUpper»''' |
| annotationRef.addAnnAttr(table, "property", propContent) |
| annotations += annotationRef |
| packageName = pkg.fullyQualifiedName.toString |
| documentation = GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION |
| it.toContextOperations(table, tableClsName) |
| ]) |
| } |
| } |
| } |
| |
| /** |
| * <p>create an injectable context function to be used by an e4 application.</p> |
| * |
| */ |
| def void toContextOperations(JvmGenericType type, Table table, String clsName) { |
| var JvmOperation operation |
| |
| // compute override |
| type.members += table.toMethod("compute", _typeReferenceBuilder.typeRef(Object), |
| [ |
| annotations += _annotationTypesBuilder.annotationRef(Override) |
| visibility = JvmVisibility.PUBLIC |
| parameters += table.toParameter("context", _typeReferenceBuilder.typeRef(IEclipseContext)) |
| parameters += table.toParameter("contextKey", _typeReferenceBuilder.typeRef(String)) |
| body = [ |
| append( |
| ''' |
| MApplication application = context.get(MApplication.class); |
| IEclipseContext appCtx = application.getContext(); |
| IViewEmbeddedProvider provider = ContextInjectionFactory.make(«clsName».class, appCtx); |
| appCtx.set(IViewEmbeddedProvider.class, provider); |
| return provider;''')] |
| ]) |
| } |
| |
| /** |
| * <p>build the constructors to be used by an e4 application.</p> |
| * |
| */ |
| def void toConstructor(JvmDeclaredType type, Table table) { |
| if (!table.tabletype.embedded) { |
| type.members += table.toConstructor( |
| [ |
| annotations += _annotationTypesBuilder.annotationRef(Inject) |
| parameters += table.toParameter("parent", _typeReferenceBuilder.typeRef(VerticalLayout)) |
| parameters += table.toParameter("context", _typeReferenceBuilder.typeRef(IEclipseContext)) |
| parameters += table.toParameter("app", _typeReferenceBuilder.typeRef(MApplication)) |
| body = [ |
| append( |
| ''' |
| super(parent,context,app);''')] |
| ]) |
| } |
| } |
| |
| def TableDatamart getDataMartTable(Table table) { |
| return table.tabletype.dataMartTable |
| } |
| |
| def TableDatamart getDataMartTable(TableOption option) { |
| switch option { |
| TableTable: return option.source |
| } |
| return null |
| } |
| |
| def TableDtoDatasource getDtoGridTable(Table table) { |
| return table.tabletype.dtoGridTable |
| } |
| |
| def TableDtoDatasource getDtoGridTable(TableOption option) { |
| switch option { |
| TableGrid: return option.source as TableDtoDatasource |
| } |
| return null |
| } |
| |
| def String getSourceDataMartRefName(Table table) { |
| if (table.dataMartTable != null && table.dataMartTable.datamartRef != null && |
| table.dataMartTable.datamartRef.name != null) { |
| return table.dataMartTable.datamartRef.name.toString |
| } else { |
| return null; |
| } |
| } |
| |
| /** |
| * <p>build the class variables.</p> |
| * |
| */ |
| def void toFields(JvmDeclaredType type, Table table) { |
| var JvmField field = null |
| |
| // create logger |
| field = table.toField("log", _typeReferenceBuilder.typeRef(Logger))[ |
| setInitializer([append('''org.slf4j.LoggerFactory.getLogger("tables")''')])] |
| field.static = true |
| field.visibility = JvmVisibility::PRIVATE |
| type.members += field |
| field = table.toField("context", _typeReferenceBuilder.typeRef(IEclipseContext))[annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("user", _typeReferenceBuilder.typeRef(IUser))[annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("coordinateSystem", _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Integer))) |
| type.members += field |
| field = table.toField("filterGenerator", _typeReferenceBuilder.typeRef(IDatamartFilterGenerator)) |
| type.members += field |
| field = table.toField("layoutManager", _typeReferenceBuilder.typeRef(IViewLayoutManager)) |
| type.members += field |
| field = table.toField("dslMetadataService", _typeReferenceBuilder.typeRef(IDSLMetadataService)) [annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("locale", _typeReferenceBuilder.typeRef(Locale)) |
| type.members += field |
| // the package name of the referenced datamart |
| if (getSourceDataMartRefName(table) != null) { |
| var packageName = (table.dataMartTable.datamartRef.eContainer as DatamartPackage).fullyQualifiedName. |
| toString |
| field = table.toField("datamartClass", |
| _typeReferenceBuilder.typeRef('''«packageName».«getSourceDataMartRefName(table)»Datamart''')) |
| type.members += field |
| } |
| if(table.tabletype instanceof TableGrid) { |
| field = table.toField("gridSourceService", _typeReferenceBuilder.typeRef(IGridSourceFacade))[annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("ecviewPropsProvider", _typeReferenceBuilder.typeRef(IECViewSessionHelper))[annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("bundleSpaceTypeProvider", _typeReferenceBuilder.typeRef(ITypeProviderService))[annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("grid", _typeReferenceBuilder.typeRef("org.eclipse.osbp.infogrid.vaaclipse.SingleInfoGridComponent")) |
| type.members += field |
| } |
| field = table.toField("filterChangeListener", _typeReferenceBuilder.typeRef(ValueChangeListener)) |
| type.members += field |
| field = table.toField("tableSelectDelay", _typeReferenceBuilder.typeRef(Refresher)) |
| type.members += field |
| field = table.toField("tableRefresher", _typeReferenceBuilder.typeRef(Refresher)) |
| type.members += field |
| field = table.toField("dataComponent", _typeReferenceBuilder.typeRef(Component)) |
| type.members += field |
| field = table.toField("propertyLookupMap", |
| _typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String), _typeReferenceBuilder.typeRef(PropertyLookup))) |
| type.members += field |
| field = table.toField("dataSourceContainer", _typeReferenceBuilder.typeRef(CellSetIndexedContainer)) |
| type.members += field |
| field = table.toField("operativeDtoContainer", _typeReferenceBuilder.typeRef(OperativeDtoContainer)) |
| type.members += field |
| field = table.toField("tables", |
| _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(CellSetFilterTable))) |
| type.members += field |
| field = table.toField("eventBroker", _typeReferenceBuilder.typeRef(IEventBroker))[ |
| annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("renderingEngine", _typeReferenceBuilder.typeRef(IPresentationEngine))[ |
| annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("themeResourceService", _typeReferenceBuilder.typeRef(IThemeResourceService))[ |
| annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("refreshView", _typeReferenceBuilder.typeRef(EventHandler)) |
| type.members += field |
| field = table.toField("delegatedTask", _typeReferenceBuilder.typeRef(EventHandler)) |
| type.members += field |
| if (!table.tabletype.embedded) { |
| field = table.toField("dispatchAction", _typeReferenceBuilder.typeRef(EventHandler)) |
| type.members += field |
| } |
| field = table.toField("tableFilterDecorator", _typeReferenceBuilder.typeRef(TableFilterDecorator)) |
| type.members += field |
| if (table.task) { |
| field = table.toField("taskClient", _typeReferenceBuilder.typeRef(IBPMTaskClient))[ |
| annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("currentTaskId", _typeReferenceBuilder.typeRef(Long)) |
| type.members += field |
| field = table.toField("taskButtons", |
| _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Button))) |
| type.members += field |
| } |
| if (table.tabletype instanceof TableSelection) { |
| field = table.toField("taskClient", _typeReferenceBuilder.typeRef(IBPMTaskClient))[ |
| annotations += _annotationTypesBuilder.annotationRef(Inject)] |
| type.members += field |
| field = table.toField("selectTable", _typeReferenceBuilder.typeRef(CheckboxSelectionCellSetFilterTable)) |
| type.members += field |
| } |
| if (!table.tabletype.embedded && table.tabletype.toolbar != null && table.tabletype.toolbar.eContainer != null) { |
| var packageName = (table.tabletype.toolbar.eContainer as ActionPackage).fullyQualifiedName.toString |
| field = table.toField("toolbarClass", |
| _typeReferenceBuilder.typeRef('''«packageName».«table.tabletype.toolbar.name.toString.toFirstUpper»Action''')) |
| type.members += field |
| } |
| } |
| |
| /** |
| * <p>build the getters and setters from class variables.</p> |
| * |
| */ |
| def void toGetterSetter(JvmDeclaredType type, Table table) { |
| var JvmOperation operation = null |
| operation = table.toGetter("coordinateSystem", |
| _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Integer))) |
| operation.visibility = JvmVisibility::PUBLIC |
| type.members += operation |
| } |
| |
| /** |
| * <p>build the methods.</p> |
| * |
| */ |
| def void toOperations(JvmDeclaredType type, TablePackage pkg, Table table) { |
| |
| // create view |
| type.members += table.toMethod("getCellSet", _typeReferenceBuilder.typeRef(DerivedCellSet), |
| [ |
| body = [append( |
| ''' |
| operativeDtoContainer = null; |
| «IF (table.dataMartTable != null)» |
| DerivedCellSet cellSet = datamartClass.getResults( |
| «IF table.task»taskClient, «ENDIF»user, |
| filterGenerator.getFilter(«(table.dataMartTable.datamartRef.source instanceof DatamartCube).booleanValue.toString») |
| «IF !table.task»«IF ((table.tabletype instanceof TableSelection) || table.tabletype.embedded)», null, null«ELSE», getTaskOperativeDtoClass(), getTaskInitialOperativeDtos()«ENDIF»«ENDIF» |
| ); |
| «ELSE» |
| DerivedCellSet cellSet = null; |
| «ENDIF» |
| if (cellSet != null) { |
| operativeDtoContainer = cellSet.getOperativeDtoContainer(); |
| } |
| return cellSet; |
| ''')] |
| ]) |
| |
| // create view |
| type.members += table.toMethod("createView", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| parameters += table.toParameter("parent", _typeReferenceBuilder.typeRef(VerticalLayout)) |
| if (table.tabletype.embedded) { |
| annotations += _annotationTypesBuilder.annotationRef(Override) |
| } |
| body = [append('''«table.createView(pkg)»''')] |
| ]) |
| |
| // create components |
| type.members += table.toMethod("createComponents", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| body = [append('''«table.createComponents»''')] |
| ]) |
| |
| switch (table.tabletype) { |
| TableTable: { |
| // create tab |
| type.members += table.toMethod("createTabSheet", _typeReferenceBuilder.typeRef(Component), |
| [ |
| exceptions += _typeReferenceBuilder.typeRef(DerivedOlapException) |
| parameters += table.toParameter("cellSet", _typeReferenceBuilder.typeRef(DerivedCellSet)) |
| parameters += table.toParameter("axisNo", _typeReferenceBuilder.typeRef(Integer)) |
| body = [append('''«table.createTabSheet»''')] |
| ]) |
| |
| // create table |
| type.members += table.toMethod("createTable", _typeReferenceBuilder.typeRef(Component), |
| [ |
| exceptions += _typeReferenceBuilder.typeRef(DerivedOlapException) |
| parameters += table.toParameter("cellSet", _typeReferenceBuilder.typeRef(DerivedCellSet)) |
| body = [append('''«table.createTable»''')] |
| ]) |
| |
| // create table |
| type.members += table.toMethod("dataRefresh", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| body = [append('''«table.dataRefresh»''')] |
| ]) |
| } |
| TableGrid: { |
| // create tab |
| type.members += table.toMethod("createDtoGrid", _typeReferenceBuilder.typeRef(Component), |
| [ |
| exceptions += _typeReferenceBuilder.typeRef(DerivedOlapException) |
| val gridDtoFqn = (table.tabletype as TableGrid).source.dtoSource.fullyQualifiedName?.toString |
| body = [append(''' |
| IEclipseContext childContext = context.createChild(); |
| childContext.set(Locale.class, user.getLocale()); |
| childContext.set("gridSourceId", "«pkg.name.toString.concat(".").concat(table.name).concat("Grid")»"); |
| if ("«gridDtoFqn»".equals(getTaskOperativeDtoFqn())) { |
| childContext.set("inputdata", getTaskInitialOperativeDtos()); |
| } |
| grid = ContextInjectionFactory.make(SingleInfoGridComponent.class, childContext); |
| return grid;''')] |
| ]) |
| } |
| } |
| |
| // setup-Method |
| type.members += table.toMethod("setup", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PROTECTED |
| body = [append('''«table.setup»''')] |
| ]) |
| |
| // subscribe to eventBroker |
| type.members += table.toMethod("subscribe", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PROTECTED |
| body = [append('''«table.subscribe»''')] |
| ]) |
| |
| // unsubscribe from eventBroker |
| type.members += table.toMethod("unsubscribe", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PROTECTED |
| annotations += _annotationTypesBuilder.annotationRef(PreDestroy) |
| body = [append('''«table.unsubscribe»''')] |
| ]) |
| // locale notification |
| type.members += table.toMethod("localeChanged", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PUBLIC |
| annotations += _annotationTypesBuilder.annotationRef(Override) |
| parameters += table.toParameter("locale", _typeReferenceBuilder.typeRef(Locale)) |
| body = [append('''«table.localeChanged»''')] |
| ]) |
| |
| if (table.task) { |
| |
| // unsubscribe from eventBroker |
| type.members += table.toMethod("notifyTaskEvent", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PUBLIC |
| parameters += table.toParameter("type", _typeReferenceBuilder.typeRef(TaskEventType)) |
| parameters += table.toParameter("event", _typeReferenceBuilder.typeRef(TaskUserEvent)) |
| annotations += _annotationTypesBuilder.annotationRef(Override) |
| body = [append('''«table.notifyTaskEvent»''')] |
| ]) |
| |
| // unsubscribe from eventBroker |
| type.members += table.toMethod("notifyProcessCompletedEvent", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PUBLIC |
| parameters += table.toParameter("event", _typeReferenceBuilder.typeRef(ProcessCompletedEvent)) |
| annotations += _annotationTypesBuilder.annotationRef(Override) |
| body = [append('''«table.notifyTaskEvent»''')] |
| ]) |
| } |
| if (!table.tabletype.embedded) { |
| |
| // react on refresh due to modified entities |
| // unsubscribe from eventBroker |
| type.members += table.toMethod("refreshViewDueToModifiedEntityId", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| parameters += table.toParameter("entity", _typeReferenceBuilder.typeRef(String)) |
| parameters += table.toParameter("id", _typeReferenceBuilder.typeRef(Object)) |
| visibility = JvmVisibility.PUBLIC |
| body = [ |
| append( |
| ''' |
| super.refreshViewDueToModifiedEntityId(entity, id); |
| «table.callDataRefreshMethod» |
| ''')] |
| ]) |
| } |
| |
| // any select table modifying workload dto methods |
| if (table.tabletype instanceof TableSelection) { |
| type.members += table.toMethod("selectItemsFromWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PUBLIC |
| body = [append('''«table.selectItemsFromWorkloadDto»''')] |
| ]) |
| type.members += table.toMethod("addAllItemsToWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PUBLIC |
| body = [append('''«table.addAllItemsToWorkloadDto»''')] |
| ]) |
| type.members += table.toMethod("addOrRemoveItemToWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PROTECTED |
| parameters += table.toParameter("task", _typeReferenceBuilder.typeRef(IBlipBPMWorkloadModifiableItem)) |
| parameters += table.toParameter("workloadDto", _typeReferenceBuilder.typeRef(IDto)) |
| parameters += table.toParameter("selection", _typeReferenceBuilder.typeRef(Integer)) |
| parameters += table.toParameter("selected", _typeReferenceBuilder.typeRef(boolean)) |
| body = [append('''«table.addOrRemoveItemToWorkloadDto»''')] |
| ]) |
| type.members += table.toMethod("removeAllItemsFromWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE), |
| [ |
| visibility = JvmVisibility.PUBLIC |
| body = [append('''«table.removeAllItemsFromWorkloadDto»''')] |
| ]) |
| } |
| } |
| |
| def getCallDataRefreshMethod(Table table) { |
| switch (table.tabletype) { |
| TableTable: { |
| "dataRefresh();" |
| } |
| TableGrid: { |
| "" |
| } |
| } |
| } |
| |
| def notifyTaskEvent(Table table) { |
| ''' |
| «table.callDataRefreshMethod»''' |
| } |
| |
| /** |
| * <p>build the methods.</p> |
| * |
| */ |
| def void toStringToNumberConverter(JvmDeclaredType type, Table table) { |
| |
| // create getStringToInt |
| type.members += table.toMethod('''«CONVERT_METHOD_PREFIX»Int''', _typeReferenceBuilder.typeRef(int), |
| [ |
| parameters += table.toParameter("value", _typeReferenceBuilder.typeRef(String)) |
| body = [append('''return Double.valueOf(value).intValue();''')] |
| ]) |
| |
| // create getStringToDouble |
| type.members += table.toMethod('''«CONVERT_METHOD_PREFIX»Double''', _typeReferenceBuilder.typeRef(double), |
| [ |
| parameters += table.toParameter("value", _typeReferenceBuilder.typeRef(String)) |
| body = [append('''return Double.valueOf(value);''')] |
| ]) |
| } |
| |
| /** |
| * <p>build the main method to be called from e4.</p> |
| * |
| tablePageLabel = new Label(); |
| tablePageLabel.setContentMode(ContentMode.HTML); |
| tablePageLabel.addStyleName("pagelabel"); |
| tablePageLabel.setId("tablePageLabel"); |
| |
| «"Page".bindComponent("tablePageLabel", "Value")» |
| tableItemsLabel = new Label(); |
| tableItemsLabel.setContentMode(ContentMode.HTML); |
| tableItemsLabel.addStyleName("pagelabel"); |
| tableItemsLabel.setId("tableItemsLabel"); |
| «"Items per page".bindComponent("tableItemsLabel", "Value")» |
| */ |
| def String createView(Table table, TablePackage pkg) { |
| |
| var body = ''' |
| «IF table.task» |
| taskClient.subscribeTaskEventNotification(this); |
| taskClient.subscribeProcessCompletedEventNotification(this); |
| currentTaskId = -1L; |
| «ENDIF» |
| tables = new ArrayList<CellSetFilterTable>(); |
| tableFilterDecorator = new TableFilterDecorator(dslMetadataService); |
| // the timeout to begin the filter process after the last key pressed |
| tableFilterDecorator.setTextChangeTimeout(500); |
| ''' |
| if(table.tabletype instanceof TableGrid) { |
| val gridDtoFqn = (table.tabletype as TableGrid).source.dtoSource.fullyQualifiedName.toString |
| val entity = EntityUtils.getEntityFromDto((table.tabletype as TableGrid).source.dtoSource) |
| body = ''' |
| «body» |
| persistenceService.registerPersistenceUnit("«entity?.persistenceUnit»", |
| «entity?.fullyQualifiedName».class); |
| log.debug("PersistenceService registered"); |
| IEclipseContext childContext = context.createChild(); |
| childContext.set(Locale.class, user.getLocale()); |
| childContext.set("gridSourceId", "«pkg.name.toString.concat(".").concat(table.name).concat("Grid")»"); |
| if ("«gridDtoFqn»".equals(getTaskOperativeDtoFqn())) { |
| childContext.set("inputdata", getTaskInitialOperativeDtos()); |
| } |
| grid = ContextInjectionFactory.make(SingleInfoGridComponent.class, childContext);''' |
| } |
| body = ''' |
| «body» |
| coordinateSystem = new ArrayList<Integer>(); |
| filterGenerator = new DatamartFilterGenerator(); |
| filterGenerator.setDslMetadataService(dslMetadataService); |
| layoutManager = new ViewLayoutManager(); |
| tableSelectDelay = new Refresher(); |
| tableRefresher = new Refresher(); |
| propertyLookupMap = new HashMap<String,PropertyLookup>(); |
| ''' |
| |
| // the package name of the referenced datamart |
| if (getSourceDataMartRefName(table) != null) { |
| body = ''' |
| «body» |
| datamartClass = new «getSourceDataMartRefName(table)»Datamart();''' |
| } |
| if (!table.tabletype.embedded && table.tabletype.toolbar != null) { |
| body = ''' |
| «body» |
| toolbarClass = new «table.tabletype.toolbar.name.toString.toFirstUpper»Action(UUID.randomUUID().toString()); |
| toolbarClass.createToolbar(getContext(), renderingEngine, themeResourceService);''' |
| } |
| body = ''' |
| «body» |
| parent.setPrimaryStyleName("osbp"); |
| parent.setId("parent"); |
| parent.setSizeFull(); |
| layoutManager.init(parent); |
| refreshView = «table.refreshView» |
| «IF !table.tabletype.embedded && table.tabletype.toolbar != null»dispatchAction = «table.dispatchAction»«ENDIF» |
| ''' |
| |
| if (table.tabletype.polling) { |
| body = ''' |
| «body» |
| tableRefresher.setRefreshInterval(«table.tabletype.pollingTime»*1000); |
| tableRefresher.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() { |
| @Override |
| public void refresh(final Refresher source) { |
| «table.callDataRefreshMethod» |
| } |
| }); |
| layoutManager.addExtension(tableRefresher); |
| ''' |
| } |
| |
| if (table.dataMartTable instanceof TableDatamart && table.dataMartTable != null && ( |
| (table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartEntity || |
| (table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartCube |
| )) { |
| body = ''' |
| «body» |
| filterChangeListener = new ValueChangeListener() { |
| @Override |
| public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { |
| «table.callDataRefreshMethod» |
| } |
| }; |
| filterGenerator.createFilter(datamartClass, user, filterChangeListener, layoutManager); |
| ''' |
| } |
| |
| body = ''' |
| «body»setup(); |
| user.addUserLocaleListener(this); |
| ''' |
| return body |
| } |
| |
| def boolean isTask(Table table) { |
| return table.dataMartTable instanceof TableDatamart && |
| (table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartTask; |
| } |
| |
| def dataRefresh(Table table) { |
| ''' |
| try { |
| // if no current ui found |
| if (UI.getCurrent() == null) { |
| for(CellSetFilterTable table:tables) { |
| UI.setCurrent(table.getUI()); |
| break; |
| } |
| } |
| if(dataSourceContainer== null || !dataSourceContainer.updateContainer(getCellSet())) { |
| log.debug("cannot update container - full refresh"); |
| «IF table.tabletype.embedded» |
| createComponents(); |
| «ELSE» |
| renderData(); |
| «ENDIF» |
| } |
| for(CellSetFilterTable table:tables) { |
| table.sanitizeSelection(); |
| «table.notifyBPMNChart» |
| } |
| } |
| catch (Exception e) { |
| log.error("dataRefresh", e); |
| }''' |
| } |
| |
| /** |
| * <p>create a handler for external triggered refresh requests.</p> |
| * |
| */ |
| def String refreshView(Table table) { |
| var body = "" |
| var updateFiler = "" |
| switch (table.tabletype) { |
| TableTable: { |
| updateFiler = "filterGenerator.updateFilter(datamartClass, user, filterChangeListener);" |
| } |
| TableGrid: { |
| } |
| } |
| body = ''' |
| «body» |
| new EventHandler() { |
| @Override |
| public void handleEvent(Event event) { |
| // data could be changed externally - update filters |
| «updateFiler» |
| «table.callDataRefreshMethod» |
| } |
| }; |
| ''' |
| return body |
| } |
| |
| /** |
| * <p>create a handler for external triggered task actions.</p> |
| * |
| */ |
| def String dispatchAction(Table table) { |
| var body = "" |
| body = ''' |
| «body» |
| new EventHandler() { |
| @Override |
| public void handleEvent(Event event) { |
| EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(EventUtils.DATA); |
| log.debug("dispatch action received in «table.name» for "+msg.getName()); |
| «IF table.isTask» |
| currentTaskId = msg.getLong(); |
| taskClient.operations(msg.getLong(), user, null, Operation.valueOf(msg.getName())); |
| «ELSEIF (table.tabletype instanceof TableSelection)» |
| switch(msg.getName()) { |
| case "«SelectWorkloadActionEnum.WORKLOAD_SELECT_ACTION_ADD_ALL.literal»": |
| addAllItemsToWorkloadDto(); |
| break; |
| case "«SelectWorkloadActionEnum.WORKLOAD_SELECT_ACTION_REMOVE_ALL.literal»": |
| removeAllItemsFromWorkloadDto(); |
| break; |
| } |
| «ELSE» |
| switch(msg.getName()) { |
| case "«ReportActionEnum.REPORT_ACTION_PRINT_ON_SERVER_PDF.literal»": |
| break; |
| case "«ReportActionEnum.REPORT_ACTION_DOWNLOAD_PDF.literal»": |
| break; |
| case "«ChartActionEnum.CHART_ACTION_DOWNLOAD.literal»": |
| break; |
| case "«WorkflowActionEnum.WORKFLOW_ACTION_START.literal»": |
| break; |
| } |
| «ENDIF» |
| } |
| }; |
| ''' |
| return body |
| } |
| |
| /** |
| * <p>create a handler for user changed.</p> |
| * |
| */ |
| def String delegatedTask(Table table) { |
| var body = "" |
| body = ''' |
| «body» |
| new EventHandler() { |
| @Override |
| public void handleEvent(Event event) { |
| EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(EventUtils.DATA); |
| datamartClass.operations(msg.getLong(), user, msg.getName(), Operation.Delegate); |
| } |
| }; |
| ''' |
| return body |
| } |
| |
| /** |
| * <p>build the data components.</p> |
| * |
| */ |
| def String createComponents(Table table) { |
| var body = "resetListeningForEntityIdsModifications();" |
| if (table.dataMartTable != null) { |
| var generateModifyLister = '''''' |
| if (table.dataMartTable != null && table.dataMartTable.datamartRef != null && |
| (table.dataMartTable.datamartRef.source instanceof DatamartEntity)) { |
| generateModifyLister = '''datamartClass.addEntityIdsToModifyListener(this, cellSet);''' |
| } |
| body = ''' |
| try { |
| // get the results |
| final DerivedCellSet cellSet = getCellSet(); |
| if (cellSet == null) { |
| «IF !table.tabletype.embedded»promptSecurityMessage(dslMetadataService.translate(locale.toLanguageTag(), "securityMessage"), layoutManager.getDataArea());«ENDIF» |
| return; |
| } else { |
| layoutManager.getDataArea().removeAllComponents(); |
| } |
| «IF !table.tabletype.embedded» |
| resetListeningForEntityIdsModifications(); |
| «generateModifyLister» |
| «ENDIF» |
| getCoordinateSystem().clear(); |
| // generate a new result component |
| if (cellSet != null) { |
| // create a multidimensional coordinate system against the cellSet |
| for (int axis = 0; axis < cellSet.getAxes().size(); axis++) { |
| getCoordinateSystem().add(0); |
| } |
| // remove any previous component |
| if (dataComponent != null) { |
| layoutManager.getDataArea().removeComponent(dataComponent); |
| dataComponent = null; |
| } |
| if (cellSet.getAxes().size() < 2) { |
| log.error("at least 2 axes from referenced datamart «table.dataMartTable.datamartRef.name» are needed to render «table. |
| name»"); |
| } |
| dataComponent = createTabSheet(cellSet, cellSet.getAxes().size()); |
| if (dataComponent != null) { |
| dataComponent.setSizeFull(); |
| dataComponent.setId("dataComponent"); |
| layoutManager.getDataArea().addComponent(dataComponent); |
| «IF (table.tabletype instanceof TableSelection)» |
| selectItemsFromWorkloadDto(); |
| «ENDIF» |
| layoutManager.getDataArea().setExpandRatio(dataComponent, 1); |
| «table.selectAlways» |
| } |
| } |
| else { |
| log.error("referenced datamart «table.dataMartTable.datamartRef.name» generates no results"); |
| } |
| } catch (DerivedOlapException e) { |
| log.error("createComponents", e); |
| } |
| ''' |
| } else { |
| body = ''' |
| «body» |
| // generate a new result component |
| try { |
| // remove any previous component |
| if (dataComponent != null) { |
| layoutManager.getDataArea().removeComponent(dataComponent); |
| dataComponent = null; |
| } |
| dataComponent = createDtoGrid(); |
| dataComponent.setSizeFull(); |
| dataComponent.setId("dataComponent"); |
| layoutManager.getDataArea().addComponent(dataComponent); |
| layoutManager.getDataArea().setExpandRatio(dataComponent, 1); |
| «table.selectAlways» |
| } catch (DerivedOlapException e) { |
| log.error("createComponents", e); |
| } |
| ''' |
| } |
| return body |
| } |
| |
| def String getSelectAlways(Table table) { |
| var body = "" |
| if (table.tabletype instanceof TableTable && (table.tabletype as TableTable).selectalways) { |
| body = ''' |
| «body» |
| tableSelectDelay.setRefreshInterval(1000); |
| if (tableSelectDelay.getListeners(null).size()==0) { |
| tableSelectDelay.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() { |
| @Override |
| public void refresh(final Refresher source) { |
| // refresh only once |
| source.setRefreshInterval(0); |
| for(CellSetFilterTable table:tables) { |
| if (table.getItemIds().size()>0) { |
| table.select(table.getItemIds().iterator().next()); |
| } |
| } |
| } |
| }); |
| layoutManager.addExtension(tableSelectDelay); |
| }''' |
| } |
| return body |
| } |
| |
| /** |
| * <p>if more than 2 axes (dimensions) are found in the cellSet, build recursive tabsheets as long as the remaining axes are more than 2.</p> |
| * |
| */ |
| def String createTabSheet(Table table) { |
| var body = "" |
| body = ''' |
| «body» |
| tables.clear(); |
| // either create a recursive tabsheet or a table |
| Component component = null; |
| if (axisNo == 2) { |
| component = createTable(cellSet); |
| } |
| else { |
| Integer axis = axisNo-1; |
| TabSheet tabsheet = new TabSheet(); |
| tabsheet.setSizeFull(); |
| DerivedAxis tabAxis = cellSet.getAxes().get(axis); |
| // create a tab page for all tab axis members |
| int tabNo = 0; |
| for (DerivedPosition column : tabAxis.getPositions()) { |
| // create the title for the axis |
| String title = null; |
| for (DerivedMember member : column.getMembers()) { |
| if (title == null) { |
| title = dslMetadataService.translate(locale.toLanguageTag(), member.getCaption()); |
| } |
| else { |
| title += " / "+dslMetadataService.translate(locale.toLanguageTag(), member.getCaption()); |
| } |
| } |
| // position the data to this coordinate |
| getCoordinateSystem().set(axis, tabNo); |
| component = createTabSheet(cellSet, axis); |
| // set the caption |
| if (component != null) { |
| component.setCaption(title); |
| tabsheet.addComponent(component); |
| if (component instanceof CellSetFilterTable) { |
| tabsheet.addComponent(((CellSetFilterTable)component)); |
| } |
| } |
| tabNo++; |
| } |
| component = tabsheet; |
| } |
| return component;''' |
| return body |
| } |
| |
| /** |
| * <p>build the table component.</p> |
| * |
| */ |
| def String createTable(Table table) { |
| var body = "" |
| var TableAxis category_axis = null |
| var TableAxis data_axis = null |
| var idMap = <String, IdProperty>newHashMap |
| var formatMap = <String, FormatProperty>newHashMap |
| var intervalStyleMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var intervalIconMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var intervalTooltipMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var numberLookupStyleMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var numberLookupIconMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var numberLookupTooltipMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var stringLookupStyleMap = <String, Map<String, Map<String, String>>>newHashMap |
| var stringLookupIconMap = <String, Map<String, Map<String, String>>>newHashMap |
| var stringLookupTooltipMap = <String, Map<String, Map<String, String>>>newHashMap |
| var dateLookupStyleMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var dateLookupIconMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var dateLookupTooltipMap = <String, Map<Double, Map<String, String>>>newHashMap |
| var blobLookupMap = <String, String>newHashMap() |
| |
| var rowStyle = "" |
| |
| for (element : table.dataMartTable.elements) { |
| if (element instanceof TableAxis) { |
| var axis = element as TableAxis |
| if (axis.axis.getName.equals('COLUMNS')) { |
| data_axis = axis |
| } |
| if (axis.axis.getName.equals('ROWS')) { |
| category_axis = axis |
| } |
| } |
| } |
| |
| if (category_axis == null) { |
| category_axis = TableDSLFactory.eINSTANCE.createTableAxis(); |
| category_axis.axis = AxisEnum.ROWS; |
| table.dataMartTable.elements.add(category_axis); |
| } |
| if (data_axis == null) { |
| data_axis = TableDSLFactory.eINSTANCE.createTableAxis(); |
| data_axis.axis = AxisEnum.COLUMNS; |
| table.dataMartTable.elements.add(data_axis); |
| } |
| var constructTable = "final CellSetFilterTable table = new CellSetFilterTable();" |
| var multiSelect = false; |
| if (table.tabletype instanceof TableSelection) { |
| constructTable = ''' |
| final CheckboxSelectionCellSetFilterTable table = new CheckboxSelectionCellSetFilterTable(); |
| selectTable = table; |
| ''' |
| multiSelect = (table.tabletype as TableSelection).multiSelection |
| } |
| body = ''' |
| «body»«constructTable» |
| VerticalLayout tableLayout = new VerticalLayout(); |
| «IF table.tabletype.embedded && table.isTask» |
| taskButtons = new ArrayList<Button>(); |
| HorizontalLayout tools = new HorizontalLayout(); |
| tools.addStyleName("os-embedded-toolbar"); |
| tools.setSpacing(false); |
| |
| Button b = new Button(null, new Button.ClickListener() { |
| public void buttonClick(ClickEvent event) { |
| taskClient.operations(dataSourceContainer.getTaskId((int)table.getValue()), user, null, Operation.Start); |
| eventBroker.send(EventBrokerMsg.MENU_CLOSE, null); |
| } |
| }); |
| b.setIcon(themeResourceService.getThemeResource("task_action_start", ThemeResourceType.ICON)); |
| b.setDescription(null); |
| b.setEnabled(false); |
| b.addStyleName("v-button-small"); |
| tools.addComponent(b); |
| taskButtons.add(b); |
| tableLayout.addComponent(tools); |
| «ENDIF» |
| table.setImmediate(true); |
| table.setMultiSelect(«multiSelect»); |
| table.setColumnCollapsingAllowed(true); |
| table.setColumnReorderingAllowed(true); |
| table.setId("table"); |
| table.setRowHeaderMode(RowHeaderMode.«IF (table.tabletype as TableTable).headerMode != null»«(table.tabletype as TableTable). |
| headerMode.name()»«ELSE»HIDDEN«ENDIF»); |
| table.setFilterDecorator(tableFilterDecorator); |
| table.setFilterBarVisible(«table.tabletype.filtering.booleanValue»); |
| table.setSelectable(true); |
| table.setSizeFull(); |
| tableLayout.addComponent(table); |
| tables.add(table); |
| ''' |
| |
| // Initialization of the BlobLookupMap |
| table.initBlobLookup(blobLookupMap) |
| table.initIdMap(idMap) |
| if (category_axis.hasDetails) { |
| category_axis.initPropertyLookups(formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap, |
| numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, stringLookupStyleMap, |
| stringLookupIconMap, stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap) |
| } |
| if (data_axis.hasDetails) { |
| data_axis.initPropertyLookups(formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap, |
| numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, stringLookupStyleMap, |
| stringLookupIconMap, stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap) |
| } |
| if (intervalStyleMap.keySet.size + numberLookupStyleMap.keySet.size + stringLookupStyleMap.keySet.size + |
| dateLookupStyleMap.keySet.size > 0 || category_axis.hasRowHeight) { |
| body = ''' |
| «body»// add styles to page for the axis's custom styles |
| Styles styles = Page.getCurrent().getStyles(); |
| ''' |
| } |
| if (category_axis.hasRowHeight) { |
| customformatCounter = customformatCounter + 1 |
| rowStyle = '''rowcustomformat«customformatCounter»''' |
| body = '''«body»styles.add(".v-table-row-«rowStyle» {height: «category_axis.rowHeight»px;}"); |
| ''' |
| } |
| body = '''«body»«createStyles(intervalStyleMap, numberLookupStyleMap, stringLookupStyleMap, dateLookupStyleMap)» ''' |
| |
| // all detail value information if present is mapped to methods of TableCellGenerator |
| body = '''«body»«generatePropertyLookups(idMap, formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap, |
| numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, stringLookupStyleMap, stringLookupIconMap, |
| stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap, blobLookupMap)»''' |
| body = ''' |
| «body»dataSourceContainer = new CellSetIndexedContainer(dslMetadataService, locale, themeResourceService, propertyLookupMap, cellSet, coordinateSystem, «table.isDatamartCrossJoined»); |
| table.setContainerDataSource(dataSourceContainer); |
| dataSourceContainer.addExtras(table); |
| ''' |
| if (category_axis.hasRowHeight) { |
| body = ''' |
| «body»dataSourceContainer.setRowStyle("«rowStyle»"); |
| ''' |
| } |
| if (table.tabletype instanceof TableTable) { |
| if (table.dataMartTable instanceof TableDatamart) { |
| for (element : (table.dataMartTable as TableDatamart).elements) { |
| if (element instanceof TableAxis) { |
| if ((element as TableAxis).preOrder != null) { |
| |
| // create a ordering refresh event if applicable |
| body = '''«body»«(element as TableAxis).preOrder.preOrder(element as TableAxis)»''' |
| } |
| } |
| } |
| |
| } |
| } |
| |
| // if (!(table.tabletype as TableTable).pageable) { |
| // body = ''' |
| // «body»if (cellSet.getAxes().get(«category_axis.axis.name.ordinal»).getPositions().size() > 15) { |
| // table.setPageLength(15); |
| // } |
| // else |
| // { |
| // table.setPageLength(0); |
| // } |
| // ''' |
| // } |
| // send a selection event if modeled |
| body = '''«body»«table.sendEvent» |
| ''' |
| if (table.tabletype instanceof TableSelection) { |
| body = '''«body» |
| selectItemsFromWorkloadDto(); |
| ''' |
| } |
| body = '''«body»return tableLayout;''' |
| return body |
| } |
| |
| def boolean isDatamartCrossJoined(Table table) { |
| return (table.dataMartTable as TableDatamart).datamartRef.isCrossJoined(); |
| } |
| |
| def String modifyOddStyle(String style) { |
| var start = style.indexOf("background-color:"); |
| var end = 0; |
| if (start >= 0) { |
| var pos = style.indexOf("(", start); |
| if (pos >= 0) { |
| var newrgb = ""; |
| end = style.indexOf(")", pos); |
| var rgb = style.substring(pos + 1, end); |
| var colors = rgb.split(",") |
| for (color : colors) { |
| var colorValue = Integer.parseInt(color) |
| var diff = 15 |
| if (diff > colorValue) { |
| diff = colorValue |
| } |
| colorValue = colorValue - diff |
| newrgb = '''«newrgb»«IF newrgb.length > 0»,«ENDIF»«colorValue.toString»''' |
| } |
| return '''«style.substring(0, start)»background-color: rgb(«newrgb»)«style.substring(end + 1)»''' |
| } |
| } |
| return style |
| } |
| |
| /** |
| * <p>collected styles from the model are applied to code. Styles aside from the CSS are created at runtime.</p> |
| * |
| */ |
| def String createStyles( |
| HashMap<String, Map<Double, Map<String, String>>> intervalStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> numberLookupStyleMap, |
| HashMap<String, Map<String, Map<String, String>>> stringLookupStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> dateLookupStyleMap |
| ) { |
| var stylePrefix = ".v-table-cell-content-" |
| var body = "" |
| for (format : intervalStyleMap.keySet) { |
| for (interval : intervalStyleMap.get(format).keySet) { |
| for (style : intervalStyleMap.get(format).get(interval).keySet) { |
| body = '''«body»styles.add("«stylePrefix»«style» {«intervalStyleMap.get(format).get(interval).get( |
| style)»}"); |
| ''' |
| body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle( |
| intervalStyleMap.get(format).get(interval).get(style))»}"); |
| ''' |
| } |
| } |
| } |
| for (format : numberLookupStyleMap.keySet) { |
| for (interval : numberLookupStyleMap.get(format).keySet) { |
| for (style : numberLookupStyleMap.get(format).get(interval).keySet) { |
| body = '''«body»styles.add("«stylePrefix»«style» {«numberLookupStyleMap.get(format).get(interval). |
| get(style)»}"); |
| ''' |
| body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle( |
| numberLookupStyleMap.get(format).get(interval).get(style))»}"); |
| ''' |
| } |
| } |
| } |
| for (format : stringLookupStyleMap.keySet) { |
| for (interval : stringLookupStyleMap.get(format).keySet) { |
| for (style : stringLookupStyleMap.get(format).get(interval).keySet) { |
| body = '''«body»styles.add("«stylePrefix»«style» {«stringLookupStyleMap.get(format).get(interval). |
| get(style)»}"); |
| ''' |
| body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle( |
| stringLookupStyleMap.get(format).get(interval).get(style))»}"); |
| ''' |
| } |
| } |
| } |
| for (format : dateLookupStyleMap.keySet) { |
| for (interval : dateLookupStyleMap.get(format).keySet) { |
| for (style : dateLookupStyleMap.get(format).get(interval).keySet) { |
| body = '''«body»styles.add("«stylePrefix»«style» {«dateLookupStyleMap.get(format).get(interval). |
| get(style)»}"); |
| ''' |
| body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle( |
| dateLookupStyleMap.get(format).get(interval).get(style))»}"); |
| ''' |
| } |
| } |
| } |
| return body |
| } |
| |
| /** |
| * <p>In order to customize the cellGenerator, methods must be called inferred from the model.</p> |
| * |
| */ |
| def String generatePropertyLookups( |
| HashMap<String, IdProperty> idMap, |
| HashMap<String, FormatProperty> formatMap, |
| HashMap<String, Map<Double, Map<String, String>>> intervalStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> intervalIconMap, |
| HashMap<String, Map<Double, Map<String, String>>> intervalTooltipMap, |
| HashMap<String, Map<Double, Map<String, String>>> numberLookupStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> numberLookupIconMap, |
| HashMap<String, Map<Double, Map<String, String>>> numberLookupTooltipMap, |
| HashMap<String, Map<String, Map<String, String>>> stringLookupStyleMap, |
| HashMap<String, Map<String, Map<String, String>>> stringLookupIconMap, |
| HashMap<String, Map<String, Map<String, String>>> stringLookupTooltipMap, |
| HashMap<String, Map<Double, Map<String, String>>> dateLookupStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> dateLookupIconMap, |
| HashMap<String, Map<Double, Map<String, String>>> dateLookupTooltipMap, |
| HashMap<String, String> blobLookupMap |
| ) { |
| var properties = <String>newHashSet |
| properties.addAll(formatMap.keySet) |
| properties.addAll(intervalStyleMap.keySet) |
| properties.addAll(intervalIconMap.keySet) |
| properties.addAll(intervalTooltipMap.keySet) |
| properties.addAll(numberLookupStyleMap.keySet) |
| properties.addAll(numberLookupIconMap.keySet) |
| properties.addAll(numberLookupTooltipMap.keySet) |
| properties.addAll(stringLookupStyleMap.keySet) |
| properties.addAll(stringLookupIconMap.keySet) |
| properties.addAll(stringLookupTooltipMap.keySet) |
| properties.addAll(dateLookupStyleMap.keySet) |
| properties.addAll(dateLookupIconMap.keySet) |
| properties.addAll(dateLookupTooltipMap.keySet) |
| properties.addAll(blobLookupMap.keySet) |
| properties.addAll(idMap.keySet) |
| var body = "" |
| |
| if (properties.size > 0) { |
| body = '''«body»// add propertyLookups for column and row property supplements |
| ''' |
| } |
| |
| // all detail value information if present is mapped to methods of PropertyLookup |
| // styles and icons can be mapped to value ranges |
| for (property : properties) { |
| var hadProperty = false |
| if(property != null) { |
| hadProperty = true |
| body = '''«body»propertyLookupMap.put("«property.toString.toUpperCase»", new PropertyLookup(themeResourceService, dslMetadataService, locale)''' |
| |
| // apply all collapsed id columns |
| if (idMap.containsKey(property)) { |
| body = ''' |
| «body» |
| .setCollapseColumn(«idMap.get(property).collapsed.booleanValue.toString») |
| ''' |
| } |
| |
| // apply all found formatter information |
| if (formatMap.containsKey(property)) { |
| if (formatMap.get(property).formatter != null) { |
| body = ''' |
| «body» |
| .setFormat("«formatMap.get(property).formatter»") |
| ''' |
| } |
| if (formatMap.get(property).tooltipPattern != null) { |
| body = ''' |
| «body» |
| .setTooltipPattern("«formatMap.get(property).tooltipPattern»") |
| ''' |
| } |
| if (intervalIconMap.size > 0) { |
| body = ''' |
| «body» |
| .setHideLabel(«formatMap.get(property).hideLabelInterval.booleanValue.toString») |
| ''' |
| } else if (numberLookupIconMap.size + stringLookupIconMap.size + dateLookupIconMap.size > 0) { |
| body = ''' |
| «body» |
| .setHideLabel(«formatMap.get(property).hideLabelLookup.booleanValue.toString») |
| ''' |
| } else { |
| body = ''' |
| «body» |
| .setHideLabel(«formatMap.get(property).hideImageLabel.booleanValue.toString») |
| ''' |
| } |
| body = ''' |
| «body» |
| .setCollapseColumn(«formatMap.get(property).collapsed.booleanValue.toString») |
| ''' |
| if (formatMap.get(property).hasImage) { |
| body = ''' |
| «body» |
| .setImageService("«formatMap.get(property).imagePath»", «formatMap.get(property).hasImageParameter.booleanValue. |
| toString») |
| ''' |
| if (formatMap.get(property).hasImageResize) { |
| body = ''' |
| «body» |
| .setResizeString("«formatMap.get(property).imageResizeString»")''' |
| } |
| } |
| if (formatMap.get(property).iconName != null) { |
| body = ''' |
| «body» |
| .setColumnIcon("«formatMap.get(property).iconName»") |
| ''' |
| } |
| } |
| |
| // apply all interval styles information |
| if (intervalStyleMap.containsKey(property)) { |
| for (interval : intervalStyleMap.get(property).keySet) { |
| for (style : intervalStyleMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addStyleInterval(«IF style.startsWith("date")»ExtendedDate.add(new Date(), (long)«interval * -1», TimeUnit.DAYS)«ELSE»«interval»«ENDIF», "«style»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all interval icons information |
| if (intervalIconMap.containsKey(property)) { |
| for (interval : intervalIconMap.get(property).keySet) { |
| for (style : intervalIconMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addResourceInterval(«IF style.startsWith("date")»ExtendedDate.add(new Date(), (long)«interval * -1», TimeUnit.DAYS)«ELSE»«interval»«ENDIF», "«intervalIconMap. |
| get(property).get(interval).get(style)»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all interval tooltip information |
| if (intervalTooltipMap.containsKey(property)) { |
| for (interval : intervalTooltipMap.get(property).keySet) { |
| for (style : intervalTooltipMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addTooltipInterval(«IF style.startsWith("date")»ExtendedDate.add(new Date(), (long)«interval * -1», TimeUnit.DAYS)«ELSE»«interval»«ENDIF», dslMetadataService.translate(locale.toLanguageTag(), "«intervalTooltipMap. |
| get(property).get(interval).get(style)»")) |
| ''' |
| } |
| } |
| } |
| |
| // styles and icons can be mapped to discrete double values (lookups) |
| // apply all lookup styles information |
| if (numberLookupStyleMap.containsKey(property)) { |
| for (interval : numberLookupStyleMap.get(property).keySet) { |
| for (style : numberLookupStyleMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addStyleLookup(«interval», "«style»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all lookup icons information |
| if (numberLookupIconMap.containsKey(property)) { |
| for (interval : numberLookupIconMap.get(property).keySet) { |
| for (style : numberLookupIconMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addResourceLookup(«interval», "«numberLookupIconMap.get(property).get(interval).get(style)»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all lookup tooltip information |
| if (numberLookupTooltipMap.containsKey(property)) { |
| for (interval : numberLookupTooltipMap.get(property).keySet) { |
| for (style : numberLookupTooltipMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addTooltipLookup(«interval», dslMetadataService.translate(locale.toLanguageTag(), "«numberLookupTooltipMap.get(property). |
| get(interval).get(style)»")) |
| ''' |
| } |
| } |
| } |
| |
| // styles and icons can be mapped to discrete string values (lookups) |
| // apply all lookup styles information |
| if (stringLookupStyleMap.containsKey(property)) { |
| for (interval : stringLookupStyleMap.get(property).keySet) { |
| for (style : stringLookupStyleMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addStyleLookup("«interval»", "«style»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all lookup icons information |
| if (stringLookupIconMap.containsKey(property)) { |
| for (interval : stringLookupIconMap.get(property).keySet) { |
| for (style : stringLookupIconMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addResourceLookup("«interval»", "«stringLookupIconMap.get(property).get(interval).get(style)»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all lookup tooltip information |
| if (stringLookupTooltipMap.containsKey(property)) { |
| for (interval : stringLookupTooltipMap.get(property).keySet) { |
| for (style : stringLookupTooltipMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addTooltipLookup("«interval»", dslMetadataService.translate(locale.toLanguageTag(), "«stringLookupTooltipMap.get(property). |
| get(interval).get(style)»")) |
| ''' |
| } |
| } |
| } |
| |
| // styles and icons can be mapped to discrete date values (lookups) |
| // apply all lookup styles information |
| if (dateLookupStyleMap.containsKey(property)) { |
| for (interval : dateLookupStyleMap.get(property).keySet) { |
| for (style : dateLookupStyleMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addStyleLookup(ExtendedDate.add(new Date(),«interval * -1»,TimeUnit.DAYS), "«style»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all lookup icons information |
| if (dateLookupIconMap.containsKey(property)) { |
| for (interval : dateLookupIconMap.get(property).keySet) { |
| for (style : dateLookupIconMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addResourceLookup(ExtendedDate.add(new Date(),«interval * -1»,TimeUnit.DAYS), "«dateLookupIconMap.get(property). |
| get(interval).get(style)»") |
| ''' |
| } |
| } |
| } |
| |
| // apply all lookup tooltip information |
| if (dateLookupTooltipMap.containsKey(property)) { |
| for (interval : dateLookupTooltipMap.get(property).keySet) { |
| for (style : dateLookupTooltipMap.get(property).get(interval).keySet) { |
| body = ''' |
| «body» |
| .addTooltipLookup(ExtendedDate.add(new Date(),«interval * -1»,TimeUnit.DAYS), dslMetadataService.translate(locale.toLanguageTag(), "«dateLookupTooltipMap. |
| get(property).get(interval).get(style)»")) |
| ''' |
| } |
| } |
| } |
| |
| // apply all lookup blob information |
| if (blobLookupMap.containsKey(property)) { |
| body = ''' |
| «body» |
| .setBlob(true, «blobLookupMap.get(property)») |
| ''' |
| } |
| } |
| if(hadProperty) { |
| body = '''«body»); |
| ''' |
| } |
| } |
| return body |
| } |
| |
| /** |
| * <p>infer the model's setting for cell configuration including blobs.</p> |
| * |
| */ |
| def initBlobLookup(Table table, Map<String, String> blobMap) { |
| var datamartSource = table.dataMartTable.datamartRef.source |
| if (datamartSource instanceof DatamartEntity) { |
| for (property : (datamartSource as DatamartEntity).properties) { |
| if(property.propertyRef.properties.exists[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)]) { // try entity properties |
| var resolution = property.propertyRef.properties.findFirst[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)] |
| blobMap.put(property.getPropertyName(), resolution?.value) |
| } else if (property.propertyRef.type instanceof LDataType){ // try data type properties |
| if((property.propertyRef.type as LDataType).properties.exists[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)]) { |
| var resolution = (property.propertyRef.type as LDataType).properties.findFirst[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)] |
| blobMap.put(property.getPropertyName(), resolution?.value) |
| } |
| } |
| } |
| } |
| } |
| |
| /** |
| * <p>infer the model's setting for cell configuration including styles and images.</p> |
| * |
| */ |
| def initPropertyLookups( |
| TableAxis axis, |
| HashMap<String, FormatProperty> formatMap, |
| HashMap<String, Map<Double, Map<String, String>>> intervalStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> intervalIconMap, |
| HashMap<String, Map<Double, Map<String, String>>> intervalTooltipMap, |
| HashMap<String, Map<Double, Map<String, String>>> numberLookupStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> numberLookupIconMap, |
| HashMap<String, Map<Double, Map<String, String>>> numberLookupTooltipMap, |
| HashMap<String, Map<String, Map<String, String>>> stringLookupStyleMap, |
| HashMap<String, Map<String, Map<String, String>>> stringLookupIconMap, |
| HashMap<String, Map<String, Map<String, String>>> stringLookupTooltipMap, |
| HashMap<String, Map<Double, Map<String, String>>> dateLookupStyleMap, |
| HashMap<String, Map<Double, Map<String, String>>> dateLookupIconMap, |
| HashMap<String, Map<Double, Map<String, String>>> dateLookupTooltipMap |
| ) { |
| for (value : axis.values) { |
| |
| // create formatter map |
| var prop = new FormatProperty |
| if (value.formatter != null) { |
| prop.formatter = value.formatter.format |
| } |
| if (value.tooltipPattern != null) { |
| prop.tooltipPattern = value.tooltipPattern.tooltipPattern |
| } |
| prop.hideLabelLookup = value.hideLabelLookup |
| prop.collapsed = value.collapsed |
| prop.hasImage = value.hasImage |
| prop.iconName = value.iconName |
| if (value.hasImage && value.image != null) { |
| prop.hasImageParameter = value.image.hasParameter |
| prop.imagePath = value.image.imagePathPattern |
| prop.hideImageLabel = value.image.hideImageLabel |
| prop.hasImageResize = value.image.resize |
| prop.imageResizeString = value.image.resizeString |
| if (value.image.hasParameter) { |
| switch (value.image.imagePathParameter) { |
| TableColumn: |
| prop.imagePathParameter = (value.image.imagePathParameter as TableColumn).valueRef. |
| columnRef.literal |
| TableMeasure: |
| prop.imagePathParameter = (value.image.imagePathParameter as TableMeasure).valueRef. |
| measureRef.name |
| TableDerived: |
| prop.imagePathParameter = (value.image.imagePathParameter as TableDerived).valueRef. |
| derivedRef.name |
| TableHierarchy: |
| prop.imagePathParameter = (value.image.imagePathParameter as TableHierarchy).valueRef. |
| levelName |
| TableProperty: |
| prop.imagePathParameter = (value.image.imagePathParameter as TableProperty).valueRef. |
| getPropertyName() |
| TableAggregation: |
| prop.imagePathParameter = (value.image.imagePathParameter as TableAggregation).valueRef. |
| aggregation.name() |
| } |
| } |
| } |
| switch value.column { |
| TableOrdinal: formatMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', prop) |
| TableAllColumns: formatMap.put('''?«axis.axis.literal»''', prop) |
| TableMeasure: formatMap.put('''«(value.column as TableMeasure).valueRef.measureRef.name»''', prop) |
| TableDerived: formatMap.put('''«(value.column as TableDerived).valueRef.derivedRef.name»''', prop) |
| TableHierarchy: formatMap.put('''«(value.column as TableHierarchy).valueRef.levelName»''', prop) |
| TableProperty: formatMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', prop) |
| TableAggregation: formatMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', prop) |
| TableColumn: formatMap.put('''«(value.column as TableColumn).valueRef.columnRef.literal»''', prop) |
| } |
| |
| // create styles interval map |
| var valueMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| for (interval : value.intervals) { |
| switch interval { |
| TableNumberInterval: |
| if ((interval as TableNumberInterval).numberRange instanceof TableTextColor || |
| (interval as TableNumberInterval).numberRange instanceof TableCellColor) { |
| var key = new Double((interval as TableNumberInterval).numberIntervalValue) |
| var styleAspect = "" |
| var Map<String, String> styleMap = null |
| if (valueMap.containsKey(key)) { |
| styleMap = valueMap.get(key) |
| styleAspect = styleMap.get(styleMap.keySet.get(0)) |
| } else { |
| styleMap = <String, String>newHashMap |
| styleAspect = "" |
| customformatCounter = customformatCounter + 1 |
| } |
| switch (interval as TableNumberInterval).numberRange { |
| TableTextColor: styleAspect = '''«styleAspect»color: «((interval as TableNumberInterval). |
| numberRange as TableTextColor).rgb.toRGB»;''' |
| TableCellColor: styleAspect = '''«styleAspect»background-color: «((interval as TableNumberInterval). |
| numberRange as TableCellColor).rgb.toRGB»;''' |
| } |
| if (styleAspect.length > 0) { |
| styleMap.put('''numbercustomformat«customformatCounter»''', styleAspect) |
| valueMap.put(key, styleMap) |
| } |
| } |
| TableDateDayInterval: |
| if ((interval as TableDateDayInterval).dateRange instanceof TableTextColor || |
| (interval as TableDateDayInterval).dateRange instanceof TableCellColor) { |
| var key = new Double((interval as TableDateDayInterval).dateIntervalValue) |
| var styleAspect = "" |
| var Map<String, String> styleMap = null |
| if (valueMap.containsKey(key)) { |
| styleMap = valueMap.get(key) |
| styleAspect = styleMap.get(styleMap.keySet.get(0)) |
| } else { |
| styleMap = <String, String>newHashMap |
| styleAspect = "" |
| customformatCounter = customformatCounter + 1 |
| } |
| switch (interval as TableDateDayInterval).dateRange { |
| TableTextColor: styleAspect = '''«styleAspect»color: «((interval as TableDateDayInterval). |
| dateRange as TableTextColor).rgb.toRGB»;''' |
| TableCellColor: styleAspect = '''«styleAspect»background-color: «((interval as TableDateDayInterval). |
| dateRange as TableCellColor).rgb.toRGB»;''' |
| } |
| if (styleAspect.length > 0) { |
| styleMap.put('''datecustomformat«customformatCounter»''', styleAspect) |
| valueMap.put(key, styleMap) |
| } |
| } |
| } |
| } |
| if (valueMap.size > 0) { |
| switch value.column { |
| TableOrdinal: intervalStyleMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', valueMap) |
| TableAllColumns: intervalStyleMap.put('''?«axis.axis.literal»''', valueMap) |
| TableMeasure: intervalStyleMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', valueMap) |
| TableDerived: intervalStyleMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', valueMap) |
| TableHierarchy: intervalStyleMap.put('''«(value.column as TableHierarchy).valueRef.levelName»''', |
| valueMap) |
| TableProperty: intervalStyleMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', valueMap) |
| TableAggregation: intervalStyleMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', valueMap) |
| TableColumn: intervalStyleMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', valueMap) |
| } |
| } |
| |
| // create icon interval map |
| var valueIconMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| for (interval : value.intervals) { |
| switch interval { |
| TableNumberInterval: { |
| var key = new Double((interval as TableNumberInterval).numberIntervalValue) |
| var iconAspect = "" |
| var Map<String, String> iMap = <String, String>newHashMap |
| switch (interval as TableNumberInterval).numberRange { |
| TableIcon: iconAspect = '''«((interval as TableNumberInterval).numberRange as TableIcon). |
| icon»''' |
| TableTrend: iconAspect = '''trend_«((interval as TableNumberInterval).numberRange as TableTrend). |
| icon.literal»''' |
| } |
| if (iconAspect.length > 0) { |
| iMap.put("numbericon", iconAspect) |
| valueIconMap.put(key, iMap) |
| } |
| |
| } |
| TableDateDayInterval: { |
| var key = new Double((interval as TableDateDayInterval).dateIntervalValue) |
| var iconAspect = "" |
| var Map<String, String> iMap = <String, String>newHashMap |
| switch (interval as TableDateDayInterval).dateRange { |
| TableIcon: iconAspect = '''«((interval as TableDateDayInterval).dateRange as TableIcon). |
| icon»''' |
| TableTrend: iconAspect = '''trend_«((interval as TableDateDayInterval).dateRange as TableTrend). |
| icon.literal»''' |
| } |
| if (iconAspect.length > 0) { |
| iMap.put("dateicon", iconAspect) |
| valueIconMap.put(key, iMap) |
| } |
| |
| } |
| } |
| } |
| if (valueIconMap.size > 0) { |
| switch value.column { |
| TableOrdinal: intervalIconMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', valueIconMap) |
| TableAllColumns: intervalIconMap.put('''?«axis.axis.literal»''', valueIconMap) |
| TableMeasure: intervalIconMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', valueIconMap) |
| TableDerived: intervalIconMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', valueIconMap) |
| TableHierarchy: intervalIconMap.put('''«(value.column as TableHierarchy).valueRef.levelName»''', |
| valueIconMap) |
| TableProperty: intervalIconMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', valueIconMap) |
| TableAggregation: intervalIconMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', valueIconMap) |
| TableColumn: intervalIconMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', valueIconMap) |
| } |
| } |
| |
| // create tooltip interval map |
| var valueTooltipMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| for (interval : value.intervals) { |
| switch interval { |
| TableNumberInterval: { |
| var key = new Double((interval as TableNumberInterval).numberIntervalValue) |
| var tooltipAspect = "" |
| var Map<String, String> tMap = <String, String>newHashMap |
| switch (interval as TableNumberInterval).numberRange { |
| TableTooltip: tooltipAspect = '''«((interval as TableNumberInterval).numberRange as TableTooltip). |
| tooltip»''' |
| } |
| if (tooltipAspect.length > 0) { |
| tMap.put("numbertooltip", tooltipAspect) |
| valueTooltipMap.put(key, tMap) |
| } |
| } |
| TableDateDayInterval: { |
| var key = new Double((interval as TableDateDayInterval).dateIntervalValue) |
| var tooltipAspect = "" |
| var Map<String, String> tMap = <String, String>newHashMap |
| switch (interval as TableDateDayInterval).dateRange { |
| TableTooltip: tooltipAspect = '''«((interval as TableDateDayInterval).dateRange as TableTooltip). |
| tooltip»''' |
| } |
| if (tooltipAspect.length > 0) { |
| tMap.put("datetooltip", tooltipAspect) |
| valueTooltipMap.put(key, tMap) |
| } |
| } |
| } |
| } |
| if (valueTooltipMap.size > 0) { |
| switch value.column { |
| TableOrdinal: intervalTooltipMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| valueTooltipMap) |
| TableAllColumns: intervalTooltipMap.put('''?«axis.axis.literal»''', valueTooltipMap) |
| TableMeasure: intervalTooltipMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', valueTooltipMap) |
| TableDerived: intervalTooltipMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', valueTooltipMap) |
| TableHierarchy: intervalTooltipMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', valueTooltipMap) |
| TableProperty: intervalTooltipMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', valueTooltipMap) |
| TableAggregation: intervalTooltipMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', valueTooltipMap) |
| TableColumn: intervalTooltipMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', valueTooltipMap) |
| } |
| } |
| |
| // create styles lookup map |
| var numberValueLookupStyleMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| var stringValueLookupStyleMap = <String, Map<String, String>>newHashMap() |
| var dateValueLookupStyleMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| for (lookup : value.lookups) { |
| if (lookup instanceof TableNumberLookup && |
| ((lookup as TableNumberLookup).discrete instanceof TableTextColor || |
| (lookup as TableNumberLookup).discrete instanceof TableCellColor)) { |
| var key = new Double((lookup as TableNumberLookup).lookupValue) |
| var styleAspect = "" |
| var Map<String, String> styleMap = null |
| if (numberValueLookupStyleMap.containsKey(key)) { |
| styleMap = numberValueLookupStyleMap.get(key) |
| styleAspect = styleMap.get(styleMap.keySet.get(0)) |
| } else { |
| styleMap = <String, String>newHashMap |
| styleAspect = "" |
| customformatCounter = customformatCounter + 1 |
| } |
| switch (lookup as TableNumberLookup).discrete { |
| TableTextColor: styleAspect = '''«styleAspect»color: «((lookup as TableNumberLookup). |
| discrete as TableTextColor).rgb.toRGB»;''' |
| TableCellColor: styleAspect = '''«styleAspect»background-color: «((lookup as TableNumberLookup). |
| discrete as TableCellColor).rgb.toRGB»;''' |
| } |
| if (styleAspect.length > 0) { |
| styleMap.put('''customformat«customformatCounter»''', styleAspect) |
| numberValueLookupStyleMap.put(key, styleMap) |
| } |
| } |
| if (lookup instanceof TableStringLookup) { |
| var key = new String((lookup as TableStringLookup).lookupValue) |
| var styleAspect = "" |
| var Map<String, String> styleMap = null |
| if (stringValueLookupStyleMap.containsKey(key)) { |
| styleMap = stringValueLookupStyleMap.get(key) |
| styleAspect = styleMap.get(styleMap.keySet.get(0)) |
| } else { |
| styleMap = <String, String>newHashMap |
| styleAspect = "" |
| customformatCounter = customformatCounter + 1 |
| } |
| switch lookup.discrete { |
| TableTextColor: styleAspect = '''«styleAspect»color: «(lookup.discrete as TableTextColor). |
| rgb.toRGB»;''' |
| TableCellColor: styleAspect = '''«styleAspect»background-color: «(lookup.discrete as TableCellColor). |
| rgb.toRGB»;''' |
| } |
| if (styleAspect.length > 0) { |
| styleMap.put('''customformat«customformatCounter»''', styleAspect) |
| stringValueLookupStyleMap.put(key, styleMap) |
| } |
| } |
| if (lookup instanceof TableDateDayLookup && |
| ((lookup as TableDateDayLookup).discrete instanceof TableTextColor || |
| (lookup as TableDateDayLookup).discrete instanceof TableCellColor)) { |
| var key = new Double((lookup as TableDateDayLookup).lookupValue) |
| var styleAspect = "" |
| var Map<String, String> styleMap = null |
| if (dateValueLookupStyleMap.containsKey(key)) { |
| styleMap = dateValueLookupStyleMap.get(key) |
| styleAspect = styleMap.get(styleMap.keySet.get(0)) |
| } else { |
| styleMap = <String, String>newHashMap |
| styleAspect = "" |
| customformatCounter = customformatCounter + 1 |
| } |
| switch (lookup as TableDateDayLookup).discrete { |
| TableTextColor: styleAspect = '''«styleAspect»color: «((lookup as TableDateDayLookup). |
| discrete as TableTextColor).rgb.toRGB»;''' |
| TableCellColor: styleAspect = '''«styleAspect»background-color: «((lookup as TableDateDayLookup). |
| discrete as TableCellColor).rgb.toRGB»;''' |
| } |
| if (styleAspect.length > 0) { |
| styleMap.put('''customformat«customformatCounter»''', styleAspect) |
| dateValueLookupStyleMap.put(key, styleMap) |
| } |
| } |
| } |
| if (numberValueLookupStyleMap.size > 0) { |
| switch value.column { |
| TableOrdinal: numberLookupStyleMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| numberValueLookupStyleMap) |
| TableAllColumns: numberLookupStyleMap.put('''?«axis.axis.literal»''', |
| numberValueLookupStyleMap) |
| TableMeasure: numberLookupStyleMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', numberValueLookupStyleMap) |
| TableDerived: numberLookupStyleMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', numberValueLookupStyleMap) |
| TableHierarchy: numberLookupStyleMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', numberValueLookupStyleMap) |
| TableProperty: numberLookupStyleMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', numberValueLookupStyleMap) |
| TableAggregation: numberLookupStyleMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', |
| numberValueLookupStyleMap) |
| TableColumn: numberLookupStyleMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', numberValueLookupStyleMap) |
| } |
| } |
| if (stringValueLookupStyleMap.size > 0) { |
| switch value.column { |
| TableOrdinal: stringLookupStyleMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| stringValueLookupStyleMap) |
| TableAllColumns: stringLookupStyleMap.put('''?«axis.axis.literal»''', |
| stringValueLookupStyleMap) |
| TableMeasure: stringLookupStyleMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', stringValueLookupStyleMap) |
| TableDerived: stringLookupStyleMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', stringValueLookupStyleMap) |
| TableHierarchy: stringLookupStyleMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', stringValueLookupStyleMap) |
| TableProperty: stringLookupStyleMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', stringValueLookupStyleMap) |
| TableAggregation: stringLookupStyleMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', |
| stringValueLookupStyleMap) |
| TableColumn: stringLookupStyleMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', stringValueLookupStyleMap) |
| } |
| } |
| if (dateValueLookupStyleMap.size > 0) { |
| switch value.column { |
| TableOrdinal: dateLookupStyleMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| dateValueLookupStyleMap) |
| TableAllColumns: dateLookupStyleMap.put('''?«axis.axis.literal»''', dateValueLookupStyleMap) |
| TableMeasure: dateLookupStyleMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', dateValueLookupStyleMap) |
| TableDerived: dateLookupStyleMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', dateValueLookupStyleMap) |
| TableHierarchy: dateLookupStyleMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', dateValueLookupStyleMap) |
| TableProperty: dateLookupStyleMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', dateValueLookupStyleMap) |
| TableAggregation: dateLookupStyleMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', dateValueLookupStyleMap) |
| TableColumn: dateLookupStyleMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', dateValueLookupStyleMap) |
| } |
| } |
| |
| // create icon lookup map |
| var numberValueLookupIconMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| var stringValueLookupIconMap = <String, Map<String, String>>newHashMap() |
| var dateValueLookupIconMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| for (lookup : value.lookups) { |
| if (lookup instanceof TableNumberLookup/* && (lookup.discrete instanceof TableTextColor || lookup.discrete instanceof TableCellColor || lookup.discrete instanceof TableIcon)*/) { |
| var key = new Double((lookup as TableNumberLookup).lookupValue) |
| var iconAspect = "" |
| var Map<String, String> iMap = <String, String>newHashMap |
| switch lookup.discrete { |
| TableIcon: iconAspect = '''«(lookup.discrete as TableIcon).icon»''' |
| TableTrend: iconAspect = '''trend_«(lookup.discrete as TableTrend).icon.literal»''' |
| } |
| if (iconAspect.length > 0) { |
| iMap.put("icon", iconAspect) |
| numberValueLookupIconMap.put(key, iMap) |
| } |
| } |
| if (lookup instanceof TableStringLookup) { |
| var key = (lookup as TableStringLookup).lookupValue |
| var iconAspect = "" |
| var Map<String, String> iMap = <String, String>newHashMap |
| switch lookup.discrete { |
| TableIcon: iconAspect = '''«(lookup.discrete as TableIcon).icon»''' |
| } |
| if (iconAspect.length > 0) { |
| iMap.put("icon", iconAspect) |
| stringValueLookupIconMap.put(key, iMap) |
| } |
| } |
| if (lookup instanceof TableDateDayLookup) { |
| var key = new Double((lookup as TableDateDayLookup).lookupValue) |
| var iconAspect = "" |
| var Map<String, String> iMap = <String, String>newHashMap |
| switch lookup.discrete { |
| TableIcon: iconAspect = '''«(lookup.discrete as TableIcon).icon»''' |
| TableTrend: iconAspect = '''trend_«(lookup.discrete as TableTrend).icon.literal»''' |
| } |
| if (iconAspect.length > 0) { |
| iMap.put("icon", iconAspect) |
| dateValueLookupIconMap.put(key, iMap) |
| } |
| } |
| } |
| if (numberValueLookupIconMap.size > 0) { |
| switch value.column { |
| TableOrdinal: numberLookupIconMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| numberValueLookupIconMap) |
| TableAllColumns: numberLookupIconMap.put('''?«axis.axis.literal»''', numberValueLookupIconMap) |
| TableMeasure: numberLookupIconMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', numberValueLookupIconMap) |
| TableDerived: numberLookupIconMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', numberValueLookupIconMap) |
| TableHierarchy: numberLookupIconMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', numberValueLookupIconMap) |
| TableProperty: numberLookupIconMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', numberValueLookupIconMap) |
| TableAggregation: numberLookupIconMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', |
| numberValueLookupIconMap) |
| TableColumn: numberLookupIconMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', numberValueLookupIconMap) |
| } |
| } |
| if (stringValueLookupIconMap.size > 0) { |
| switch value.column { |
| TableOrdinal: stringLookupIconMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| stringValueLookupIconMap) |
| TableAllColumns: stringLookupIconMap.put('''?«axis.axis.literal»''', stringValueLookupIconMap) |
| TableMeasure: stringLookupIconMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', stringValueLookupIconMap) |
| TableDerived: stringLookupIconMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', stringValueLookupIconMap) |
| TableHierarchy: stringLookupIconMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', stringValueLookupIconMap) |
| TableProperty: stringLookupIconMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', stringValueLookupIconMap) |
| TableAggregation: stringLookupIconMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', |
| stringValueLookupIconMap) |
| TableColumn: stringLookupIconMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', stringValueLookupIconMap) |
| } |
| } |
| if (dateValueLookupIconMap.size > 0) { |
| switch value.column { |
| TableOrdinal: dateLookupIconMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| dateValueLookupIconMap) |
| TableAllColumns: dateLookupIconMap.put('''?«axis.axis.literal»''', dateValueLookupIconMap) |
| TableMeasure: dateLookupIconMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', dateValueLookupIconMap) |
| TableDerived: dateLookupIconMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', dateValueLookupIconMap) |
| TableHierarchy: dateLookupIconMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', dateValueLookupIconMap) |
| TableProperty: dateLookupIconMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', dateValueLookupIconMap) |
| TableAggregation: dateLookupIconMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', dateValueLookupIconMap) |
| TableColumn: dateLookupIconMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', dateValueLookupIconMap) |
| } |
| } |
| |
| // create tooltip lookup map |
| var numberValueLookupTooltipMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| var stringValueLookupTooltipMap = <String, Map<String, String>>newHashMap() |
| var dateValueLookupTooltipMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator()) |
| for (lookup : value.lookups) { |
| if (lookup instanceof TableNumberLookup/* && (lookup.discrete instanceof TableTextColor || lookup.discrete instanceof TableCellColor || lookup.discrete instanceof TableIcon)*/) { |
| var key = new Double((lookup as TableNumberLookup).lookupValue) |
| var tooltipAspect = "" |
| var Map<String, String> tMap = <String, String>newHashMap |
| switch lookup.discrete { |
| TableTooltip: tooltipAspect = '''«(lookup.discrete as TableTooltip).tooltip»''' |
| } |
| if (tooltipAspect.length > 0) { |
| tMap.put("tooltip", tooltipAspect) |
| numberValueLookupTooltipMap.put(key, tMap) |
| } |
| } |
| if (lookup instanceof TableStringLookup) { |
| var key = (lookup as TableStringLookup).lookupValue |
| var tooltipAspect = "" |
| var Map<String, String> tMap = <String, String>newHashMap |
| switch lookup.discrete { |
| TableTooltip: tooltipAspect = '''«(lookup.discrete as TableTooltip).tooltip»''' |
| } |
| if (tooltipAspect.length > 0) { |
| tMap.put("tooltip", tooltipAspect) |
| stringValueLookupTooltipMap.put(key, tMap) |
| } |
| } |
| if (lookup instanceof TableDateDayLookup) { |
| var key = new Double((lookup as TableDateDayLookup).lookupValue) |
| var tooltipAspect = "" |
| var Map<String, String> tMap = <String, String>newHashMap |
| switch lookup.discrete { |
| TableTooltip: tooltipAspect = '''«(lookup.discrete as TableTooltip).tooltip»''' |
| } |
| if (tooltipAspect.length > 0) { |
| tMap.put("tooltip", tooltipAspect) |
| dateValueLookupTooltipMap.put(key, tMap) |
| } |
| } |
| } |
| if (numberValueLookupTooltipMap.size > 0) { |
| switch value.column { |
| TableOrdinal: numberLookupTooltipMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| numberValueLookupTooltipMap) |
| TableAllColumns: numberLookupTooltipMap.put('''?«axis.axis.literal»''', |
| numberValueLookupTooltipMap) |
| TableMeasure: numberLookupTooltipMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', numberValueLookupTooltipMap) |
| TableDerived: numberLookupTooltipMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', numberValueLookupTooltipMap) |
| TableHierarchy: numberLookupTooltipMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', numberValueLookupTooltipMap) |
| TableProperty: numberLookupTooltipMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', |
| numberValueLookupTooltipMap) |
| TableAggregation: numberLookupTooltipMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', |
| numberValueLookupTooltipMap) |
| TableColumn: numberLookupTooltipMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', numberValueLookupTooltipMap) |
| } |
| } |
| if (stringValueLookupTooltipMap.size > 0) { |
| switch value.column { |
| TableOrdinal: stringLookupTooltipMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| stringValueLookupTooltipMap) |
| TableAllColumns: stringLookupTooltipMap.put('''?«axis.axis.literal»''', |
| stringValueLookupTooltipMap) |
| TableMeasure: stringLookupTooltipMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', stringValueLookupTooltipMap) |
| TableDerived: stringLookupTooltipMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', stringValueLookupTooltipMap) |
| TableHierarchy: stringLookupTooltipMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', stringValueLookupTooltipMap) |
| TableProperty: stringLookupTooltipMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', |
| stringValueLookupTooltipMap) |
| TableAggregation: stringLookupTooltipMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', |
| stringValueLookupTooltipMap) |
| TableColumn: stringLookupTooltipMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', stringValueLookupTooltipMap) |
| } |
| } |
| if (dateValueLookupTooltipMap.size > 0) { |
| switch value.column { |
| TableOrdinal: dateLookupTooltipMap.put( |
| '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', |
| dateValueLookupTooltipMap) |
| TableAllColumns: dateLookupTooltipMap.put('''?«axis.axis.literal»''', |
| dateValueLookupTooltipMap) |
| TableMeasure: dateLookupTooltipMap.put( |
| '''«(value.column as TableMeasure).valueRef.measureRef.name»''', dateValueLookupTooltipMap) |
| TableDerived: dateLookupTooltipMap.put( |
| '''«(value.column as TableDerived).valueRef.derivedRef.name»''', dateValueLookupTooltipMap) |
| TableHierarchy: dateLookupTooltipMap.put( |
| '''«(value.column as TableHierarchy).valueRef.levelName»''', dateValueLookupTooltipMap) |
| TableProperty: dateLookupTooltipMap.put( |
| '''«(value.column as TableProperty).valueRef.getPropertyName()»''', dateValueLookupTooltipMap) |
| TableAggregation: dateLookupTooltipMap.put( |
| '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', |
| dateValueLookupTooltipMap) |
| TableColumn: dateLookupTooltipMap.put( |
| '''«(value.column as TableColumn).valueRef.columnRef.literal»''', dateValueLookupTooltipMap) |
| } |
| } |
| } |
| } |
| |
| /** |
| * <p>helper method to get a property name or its alias if present of a entity's property object.</p> |
| * |
| */ |
| def String propertyName(DatamartProperty property) { |
| return property.getPropertyName(null); |
| } |
| |
| /** |
| * <p>helper method to get a level name of a hierarchy's level object.</p> |
| * |
| */ |
| def String getLevelName(CubeLevel level) { |
| return level.name |
| } |
| |
| /** |
| * <p>generate code for the pre-ordering refresh event.</p> |
| * |
| */ |
| def String preOrder(TablePreorder preorder, TableAxis axis) { |
| var name = "" |
| switch (preorder.column) { |
| TableOrdinal: name = '''#«axis.axis.literal»«(preorder.column as TableOrdinal).valueRef.toString»''' |
| TableAllColumns: name = '''?«axis.axis.literal»''' |
| TableMeasure: name = '''«(preorder.column as TableMeasure).valueRef.measureRef.name»''' |
| TableDerived: name = '''«(preorder.column as TableDerived).valueRef.derivedRef.name»''' |
| TableHierarchy: name = '''«(preorder.column as TableHierarchy).valueRef.levelName»''' |
| TableProperty: name = '''«(preorder.column as TableProperty).valueRef.getPropertyName()»''' |
| TableAggregation: name = '''«(preorder.column as TableAggregation).valueRef.aggregation.name()»''' |
| TableColumn: name = '''«(preorder.column as TableColumn).valueRef.columnRef.literal»''' |
| } |
| var body = '''dataSourceContainer.setSort(table, "«name»", «preorder.ascending.booleanValue.toString»); |
| ''' |
| return body |
| } |
| |
| def String setup(Table table) { |
| var body = "" |
| body = ''' |
| «body» |
| subscribe(); |
| ''' |
| var filterIdMap = <String, String>newHashMap |
| if (table.dataMartTable != null && table.dataMartTable.datamartRef != null && |
| table.dataMartTable.datamartRef.name != null) { |
| datamartInferrer.createFilterMap(table.dataMartTable.datamartRef, filterIdMap) |
| } |
| for (filter : filterIdMap.keySet) { |
| |
| // synchronize by id |
| if (filterIdMap.get(filter).contains(IDataMart.filterIdPlaceholder)) { |
| if (table.dataMartTable.datamartRef.source instanceof DatamartEntity) { |
| var entity = (table.dataMartTable.datamartRef.source as DatamartEntity).entityRef |
| for (f : entity.features) { |
| if (f instanceof LReference && !(f as LReference).toMany) { |
| body = |
| ''' |
| «body»«table.setupIdEvent( |
| table.dataMartTable.datamartRef.buildTopic((f as LReference).name), filter, |
| datamartInferrer.getEntityAlias(entity), (f as LReference).name)»''' |
| } |
| } |
| } |
| } |
| // synchronize by filter |
| else { |
| body = '''«body»«table.setupEvent(filterIdMap.get(filter), filter)»''' |
| } |
| } |
| return body |
| } |
| |
| // subscribe to view refresh |
| def subscribe(Table table) { |
| var subscribers = ''' |
| eventBroker.subscribe(EventBrokerMsg.REFRESH_VIEW+"«table.name»Table", refreshView); |
| «IF table.dataMartTable instanceof TableDatamart && !table.tabletype.embedded && table.tabletype.toolbar != null» |
| eventBroker.subscribe(EventBrokerMsg.ACTION_BUTTON_EXECUTE_PREFIX+"«table.tabletype.toolbar.name»Action"+(String)getContext().get("«table.tabletype.toolbar.name»_TOOLBAR_ID"), dispatchAction); |
| «ENDIF» |
| ''' |
| if (!table.tabletype.embedded) { |
| |
| // get all entities requested in this report |
| var entites = findRequestedEntities(table) |
| for (LEntity entity : entites) { |
| subscribers = subscribers.concat( |
| ''' |
| eventBroker.subscribe(EventBrokerMsg.REFRESH_VIEW+"«(entity.eContainer as LTypedPackage).name.replace('.', '/')»/«entity. |
| name»Entity", fModifiedEntityIdsListener); |
| ''') |
| } |
| } |
| return subscribers |
| } |
| |
| def Set<LEntity> findRequestedEntities(Table table) { |
| var entities = new HashSet<LEntity>() |
| switch (table.tabletype) { |
| TableTable: { |
| entities.addAll(table.dataMartTable.datamartRef.findAllEntities()) |
| } |
| TableGrid: { |
| // TODO gridsource roottype -> dto -> entity |
| // entities.add(table.dtoGridTable.) |
| } |
| } |
| return entities |
| } |
| |
| def unsubscribe(Table table) { |
| var unsubscribers = ''' |
| eventBroker.unsubscribe(refreshView); |
| «IF table.dataMartTable instanceof TableDatamart && !table.tabletype.embedded && table.tabletype.toolbar != null» |
| eventBroker.unsubscribe(dispatchAction); |
| «ENDIF» |
| «IF !table.tabletype.embedded» |
| eventBroker.unsubscribe(fModifiedEntityIdsListener); |
| «ENDIF» |
| «IF table.task» |
| taskClient.unsubscribeTaskEventNotification(this); |
| «ENDIF» |
| ''' |
| return unsubscribers |
| } |
| |
| // subscribe to id changes |
| def String setupIdEvent(Table table, String eventId, String filter, String entityName, String referenceName) { |
| var body = "" |
| body = ''' |
| «body» |
| eventBroker.subscribe("«eventId»", |
| new org.osgi.service.event.EventHandler() { |
| @Override |
| public void handleEvent(org.osgi.service.event.Event event) { |
| final EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(org.eclipse.e4.core.di.extensions.EventUtils.DATA); |
| filterGenerator.setId("«filter»", " where «entityName».«referenceName»='"+msg.getName()+"'"); |
| «table.callDataRefreshMethod» |
| } |
| }); |
| ''' |
| return body |
| } |
| |
| def notifyBPMNChart(Table table) { |
| ''' |
| // sync bpmn view |
| if(table.getValue() == null) { |
| eventBroker.send(EventBrokerMsg.BPMNCHART_EVENT, new EventBrokerMsg(null, null)); |
| } |
| else { |
| eventBroker.send(EventBrokerMsg.BPMNCHART_EVENT, new EventBrokerMsg(dataSourceContainer.getProcessId((int) table.getValue()), dataSourceContainer.getTaskName((int) table.getValue()))); |
| } |
| ''' |
| } |
| |
| // subscribe to filter changes |
| def String setupEvent(Table table, String eventId, String filter) { |
| var body = "" |
| body = ''' |
| «body» |
| eventBroker.subscribe("«eventId»", |
| new org.osgi.service.event.EventHandler() { |
| @Override |
| public void handleEvent(org.osgi.service.event.Event event) { |
| final EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(org.eclipse.e4.core.di.extensions.EventUtils.DATA); |
| «IF table.task» |
| dataSourceContainer.updateContainer(datamartClass.getResultsByTaskId(taskClient, user, msg.getLong())); |
| «ELSE» |
| filterGenerator.selectItem("«filter»", msg.getName()); |
| «ENDIF» |
| } |
| }); |
| eventBroker.subscribe("«eventId»/clear", |
| new org.osgi.service.event.EventHandler() { |
| @Override |
| public void handleEvent(org.osgi.service.event.Event event) { |
| «IF table.task» |
| dataSourceContainer.clearContainer(); |
| «ELSE» |
| filterGenerator.resetItem("«filter»"); |
| «ENDIF» |
| } |
| }); |
| ''' |
| return body |
| } |
| |
| def String sendEvent(Table table) { |
| var body = ""; |
| body = ''' |
| «body» |
| table.addValueChangeListener(new ValueChangeListener() { |
| @Override |
| public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { |
| try { |
| Object msg = null; |
| Object id = null; |
| String target = null; |
| Object value = table.getValue(); |
| int selection = -1; |
| if (value instanceof Integer) { |
| selection = (Integer)value; |
| } |
| else { |
| if ((value instanceof Collection<?>) && (((Collection<?>)value).size() == 1)) { |
| value = ((Collection<?>)value).iterator().next(); |
| if (value instanceof Integer) { |
| selection = (Integer)value; |
| } |
| } |
| } |
| «IF table.tabletype.embedded && table.isTask» |
| for(Button b:taskButtons) { |
| b.setEnabled(table.getValue() != null); |
| } |
| «ENDIF» |
| ''' |
| if (table.tabletype instanceof TableTable) { |
| if (table.dataMartTable instanceof TableDatamart) { |
| body = ''' |
| «body» |
| «IF !table.tabletype.embedded» |
| dataSourceContainer.registerSelection(getPart().getTransientData(), selection); |
| «ENDIF» |
| ''' |
| switch ((table.dataMartTable as TableDatamart).datamartRef.source) { |
| DatamartTask: |
| body = ''' |
| «body» |
| «IF !table.tabletype.embedded» |
| if (table.getValue() != null) { |
| getPart().getTransientData().put("taskSummary", taskClient.getUserTask(dataSourceContainer.getTaskId(selection), user)); |
| } |
| else { |
| getPart().getTransientData().put("taskSummary", null); |
| } |
| «ENDIF» |
| «table.notifyBPMNChart» |
| ''' |
| DatamartEntity: { |
| var datamartEntity = ((table.dataMartTable as TableDatamart).datamartRef.source) as DatamartEntity |
| var entity = EcoreUtil2.resolve(datamartEntity.entityRef, table.eResource) as LEntity |
| var alias = DatamartDefinitionUtil.getEntityIdAliasName(entity) |
| if(alias != null) { |
| body = ''' |
| «body» |
| if (selection >= 0) { |
| id = dataSourceContainer.getStringValueByProperty(selection, "«alias.toLowerCase»"); |
| } |
| if ((id != null) && (operativeDtoContainer != null) && (operativeDtoContainer.getOperativeDtoIdColumn() != null)) { |
| msg = operativeDtoContainer.getOperativeDtoForId(id); |
| } |
| if (msg == null) { |
| msg = new EventBrokerMsg((String) id, "«(((table.dataMartTable.datamartRef.source) as DatamartEntity).entityRef as EObject).fullyQualifiedName»"); |
| } |
| target = EventBrokerMsg.AUTOWIRED_ENTITY_PREFIX+"«(((table.dataMartTable as TableDatamart).datamartRef. |
| source) as DatamartEntity).entityRef.name»"; |
| eventBroker.send(target, msg);''' |
| } |
| } |
| } |
| } |
| } |
| for (element : table.dataMartTable.elements) { |
| if (element instanceof TableAxis) { |
| var axis = element as TableAxis |
| for (event : axis.events) { |
| for (datamart : event.brokerDatamarts) { |
| if (datamart.filter != null) { |
| body = ''' |
| «body» |
| if(selection<0) { |
| target = "«datamart.filter»/clear"; |
| msg = new EventBrokerMsg(null, "*"); |
| eventBroker.send(target, msg); |
| } |
| else { |
| ''' |
| } else if (datamart.reference != null) { |
| body = ''' |
| «body» |
| if(selection<0) { |
| target = "«datamart.datamartDef.buildTopic(datamart.reference.name)»/clear"; |
| msg = new EventBrokerMsg(null, "*"); |
| eventBroker.send(target, msg); |
| } |
| else { |
| ''' |
| } |
| if (event.source instanceof TableOrdinal) { |
| body = ''' |
| «body» |
| target = "«datamart.filter»"; |
| msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByOrdinal(selection, «(event. |
| source as TableOrdinal).valueRef»)); |
| eventBroker.send(target, msg); |
| } |
| ''' |
| } |
| else if (event.source instanceof TableAggregation) { |
| body = ''' |
| «body» |
| target = "«datamart.filter»"; |
| msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByAggregate(selection)); |
| eventBroker.send(target, msg); |
| } |
| ''' |
| } else if (event.source instanceof TableProperty) { |
| if (datamart.filter != null) { |
| body = ''' |
| «body» |
| target = "«datamart.filter»"; |
| msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByProperty(selection, "«(event. |
| source as TableProperty).valueRef.propertyRef.name»")); |
| eventBroker.send(target, msg); |
| } |
| ''' |
| } else if (datamart.reference != null) { |
| body = ''' |
| «body» |
| target = "«datamart.datamartDef.buildTopic(datamart.reference.name)»"; |
| msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByProperty(selection, "«(event. |
| source as TableProperty).valueRef.propertyRef.name»")); |
| eventBroker.send(target, msg); |
| } |
| ''' |
| } |
| } else if (event.source instanceof TableTask) { |
| body = ''' |
| «body» |
| target = "«datamart.filter»"; |
| msg = new EventBrokerMsg(null, null, dataSourceContainer.getTaskId(selection)); |
| eventBroker.send(target, msg); |
| } |
| ''' |
| } |
| |
| } |
| |
| } |
| } |
| } |
| body = ''' |
| «body» |
| } catch (Exception e) { |
| Notification.show("sendEvent() caused "+e.getLocalizedMessage()+"!", |
| Type.ERROR_MESSAGE); |
| } |
| } |
| }); |
| ''' |
| return body |
| } |
| |
| def getMsgValue(LEntityAttribute attribute, String string) '''«CONVERT_METHOD_PREFIX»«attribute.typeName. |
| toFirstUpper»(«string»)''' |
| |
| def String buildTopic(DatamartDefinition datamart, String referenceName) { |
| var topic = "" |
| if (datamart.source instanceof DatamartEntity) { |
| var entity = (datamart.source as DatamartEntity).entityRef |
| var eObj = datamart.eContainer |
| while (!(eObj instanceof DatamartPackage)) { |
| eObj = eObj.eContainer |
| } |
| if (eObj != null) { |
| var pckName = (eObj as DatamartPackage).fullyQualifiedName.toString.replace(".", "/") |
| topic = pckName.concat("/").concat(datamart.name).concat("/").concat(entity.name).concat("/"). |
| concat(referenceName) |
| } |
| } |
| return topic |
| } |
| |
| /** |
| * <p>helper method to convert a rgb string to a hex string.</p> |
| * |
| */ |
| def StringtoHex(String rgb) { |
| var colorHex = "#" |
| for (color : rgb.split(",")) { |
| var i = new Integer(color); |
| colorHex = '''«colorHex»«String.format("%02x", i)»''' |
| } |
| return colorHex |
| } |
| |
| /** |
| * <p>helper method to convert a rgb string to a rgb syntax.</p> |
| * |
| */ |
| def String toRGB(String rgb) { |
| return '''rgb(«rgb»)''' |
| } |
| |
| def void initIdMap(Table table, HashMap<String, IdProperty> map) { |
| map.clear |
| if (table.dataMartTable instanceof TableDatamart) { |
| var datamart = (table.dataMartTable as TableDatamart).datamartRef |
| if (datamart.source instanceof DatamartEntity) { |
| var entity = datamart.source as DatamartEntity |
| entity.iterateIdMap(map) |
| } |
| } |
| } |
| |
| def void iterateIdMap(DatamartEntity entity, HashMap<String, IdProperty> map) { |
| var prop = new IdProperty() |
| prop.collapsed = true |
| map.put(DatamartDefinitionUtil.getEntityIdAliasName(entity.entityRef), prop) |
| for (navigation : entity.navigations) { |
| navigation.datamartEntity.iterateIdMap(map) |
| } |
| } |
| |
| def getEntity(TableBrokerDatamart datamart) { |
| if (datamart.datamartDef.source instanceof DatamartEntity) { |
| return (datamart.datamartDef.source as DatamartEntity).entityRef |
| } |
| return null |
| } |
| |
| def localeChanged(Table table) |
| ''' |
| this.locale = locale; |
| if(tableFilterDecorator != null) { |
| tableFilterDecorator.setLocale(locale); |
| } |
| for(CellSetFilterTable table:tables) { |
| table.setLocale(locale); |
| «IF table.tabletype instanceof TableTable && |
| (table.dataMartTable as TableDatamart).datamartRef.description && |
| (table.dataMartTable as TableDatamart).datamartRef.descriptionValue != null» |
| table.setDescription(dslMetadataService.translate(locale.toLanguageTag(), "«(table.dataMartTable as TableDatamart).datamartRef.descriptionValue»")); |
| «ENDIF» |
| } |
| if(filterGenerator != null) { |
| filterGenerator.setLocale(locale); |
| } |
| if(dataSourceContainer != null) { |
| dataSourceContainer.setLocale(locale); |
| } |
| if(layoutManager != null) { |
| layoutManager.setLabelValue(dslMetadataService.translate(locale.toLanguageTag(), "«table.name»")); |
| } |
| ''' |
| |
| def selectItemsFromWorkloadDto(Table table) { |
| var datamartEntity = null as DatamartEntity |
| var entity = null as LEntity |
| var alias = null as String |
| var dtoFqn = null as String |
| if (table.dataMartTable instanceof TableDatamart) { |
| switch ((table.dataMartTable as TableDatamart).datamartRef.source) { |
| DatamartEntity: { |
| datamartEntity = ((table.dataMartTable as TableDatamart).datamartRef.source) as DatamartEntity |
| entity = EcoreUtil2.resolve(datamartEntity.entityRef, table.eResource) as LEntity |
| alias = DatamartDefinitionUtil.getEntityIdAliasName(entity).toLowerCase |
| dtoFqn = EntityUtils.getDtoFQNForLEntity(entity) |
| } |
| } |
| } |
| ''' |
| IBlipBPMWorkloadModifiableItem task = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO); |
| TaskSummary taskSummary = (TaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY); |
| IDto workloadDto = taskClient.getWorkloadDto(taskSummary); |
| List<IDto> operativeDtos = task.getOperativeDtos(workloadDto); |
| if (operativeDtos != null) { |
| Set<String> ids = new TreeSet<String>(); |
| for (IDto operativeDto : operativeDtos) { |
| ids.add(String.valueOf(((«dtoFqn»)operativeDto).getId())); |
| } |
| for (Object selection : dataSourceContainer.getAllItemIds()) { |
| String idValue = dataSourceContainer.getStringValueByProperty((Integer)selection,"«alias»"); |
| if (idValue.endsWith(".0")) { |
| idValue = idValue.substring(0, idValue.length()-2); |
| } |
| if (ids.contains(idValue)) { |
| selectTable.setCheckBox(selection, true); |
| } |
| } |
| } |
| ''' |
| } |
| |
| def addAllItemsToWorkloadDto(Table table) { |
| ''' |
| IBlipBPMWorkloadModifiableItem task = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO); |
| TaskSummary taskSummary = (TaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY); |
| IDto workloadDto = taskClient.getWorkloadDto(taskSummary); |
| if ((taskClient != null) && (task != null) && (workloadDto != null)) { |
| Object values = selectTable.getValue(); |
| for (Object selection : dataSourceContainer.getAllItemIds()) { |
| boolean selected = false; |
| if (values instanceof Integer) { |
| selected = (values == selection); |
| } |
| else { |
| if ((values instanceof Collection<?>) && !((Collection<?>)values).isEmpty()) { |
| selected = ((Collection<?>)values).contains(selection); |
| } |
| } |
| addOrRemoveItemToWorkloadDto(task, workloadDto, (Integer)selection, selected); |
| } |
| taskClient.setWorkloadDto(taskSummary, workloadDto); |
| } |
| ''' |
| } |
| |
| def addOrRemoveItemToWorkloadDto(Table table) { |
| var datamartEntity = null as DatamartEntity |
| var entity = null as LEntity |
| var alias = null as String |
| var dtoFqn = null as String |
| if (table.dataMartTable instanceof TableDatamart) { |
| switch ((table.dataMartTable as TableDatamart).datamartRef.source) { |
| DatamartEntity: { |
| datamartEntity = ((table.dataMartTable as TableDatamart).datamartRef.source) as DatamartEntity |
| entity = EcoreUtil2.resolve(datamartEntity.entityRef, table.eResource) as LEntity |
| alias = DatamartDefinitionUtil.getEntityIdAliasName(entity).toLowerCase |
| dtoFqn = EntityUtils.getDtoFQNForLEntity(entity) |
| } |
| } |
| } |
| ''' |
| IDto operativeDto = null; |
| String idValue = null; |
| try { |
| idValue = dataSourceContainer.getStringValueByProperty(selection,"«alias»"); |
| IDTOServiceWithMutablePersistence<«dtoFqn»> dtoService = (IDTOServiceWithMutablePersistence<«dtoFqn»>) DtoServiceAccess |
| .getService(«dtoFqn».class); |
| operativeDto = dtoService.get((int) Double.parseDouble(idValue)); |
| } |
| catch (Exception e) { |
| log.error("try to retrive the dto", e); |
| } |
| if (operativeDto == null) { |
| log.warn("«dtoFqn» for selection="+selection+" «alias»='"+idValue+"' could not be found!"); |
| } |
| else { |
| try { |
| if (selected) { |
| task.addOperativeDto(workloadDto, operativeDto); |
| } |
| else { |
| task.removeOperativeDto(workloadDto, operativeDto); |
| } |
| } |
| catch (Exception e) { |
| log.error("try to add/remove operative dto", e); |
| } |
| } |
| ''' |
| } |
| |
| def removeAllItemsFromWorkloadDto(Table table) { |
| ''' |
| IBlipBPMWorkloadModifiableItem task = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO); |
| TaskSummary taskSummary = (TaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY); |
| IDto workloadDto = taskClient.getWorkloadDto(taskSummary); |
| if ((taskClient != null) && (task != null) && (workloadDto != null)) { |
| task.removeAllOperativeDtos(workloadDto); |
| } |
| ''' |
| } |
| } |