blob: b918ae423129103e5c652dcf2581bb75b8716e8d [file] [log] [blame]
/**
* 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.chart.jvmmodel;
import com.github.wolfie.refresher.Refresher;
import com.google.common.base.Objects;
import com.vaadin.data.Property;
import com.vaadin.ui.Component;
import com.vaadin.ui.VerticalLayout;
import elemental.json.JsonException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import org.dussan.vaadin.dcharts.DCharts;
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.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.dsl.semantic.common.types.LAttribute;
import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute;
import org.eclipse.osbp.osgi.hybrid.api.AbstractHybridVaaclipseView;
import org.eclipse.osbp.ui.api.datamart.DerivedOlapException;
import org.eclipse.osbp.ui.api.datamart.IDatamartFilterGenerator;
import org.eclipse.osbp.ui.api.layout.IViewLayoutManager;
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
import org.eclipse.osbp.ui.api.user.IUser;
import org.eclipse.osbp.utils.constants.GeneratorConstants;
import org.eclipse.osbp.utils.theme.EnumCssClass;
import org.eclipse.osbp.utils.vaadin.PropertyLookup;
import org.eclipse.osbp.xtext.chart.Chart;
import org.eclipse.osbp.xtext.chart.ChartAxis;
import org.eclipse.osbp.xtext.chart.ChartBar;
import org.eclipse.osbp.xtext.chart.ChartBubble;
import org.eclipse.osbp.xtext.chart.ChartDatamart;
import org.eclipse.osbp.xtext.chart.ChartDonut;
import org.eclipse.osbp.xtext.chart.ChartElement;
import org.eclipse.osbp.xtext.chart.ChartGauge;
import org.eclipse.osbp.xtext.chart.ChartHighlighter;
import org.eclipse.osbp.xtext.chart.ChartInterval;
import org.eclipse.osbp.xtext.chart.ChartLegend;
import org.eclipse.osbp.xtext.chart.ChartLine;
import org.eclipse.osbp.xtext.chart.ChartNumberInterval;
import org.eclipse.osbp.xtext.chart.ChartOption;
import org.eclipse.osbp.xtext.chart.ChartPackage;
import org.eclipse.osbp.xtext.chart.ChartPie;
import org.eclipse.osbp.xtext.chart.ChartRangeElement;
import org.eclipse.osbp.xtext.chart.ChartSegmentColor;
import org.eclipse.osbp.xtext.chart.ChartTree;
import org.eclipse.osbp.xtext.chart.LegendPlacementEnum;
import org.eclipse.osbp.xtext.chart.RenderTypeEnum;
import org.eclipse.osbp.xtext.chart.ToggleTypeEnum;
import org.eclipse.osbp.xtext.chart.TooltipLocationEnum;
import org.eclipse.osbp.xtext.chart.jvmmodel.ChartDSLD3JavaComponentsCreator;
import org.eclipse.osbp.xtext.cubedsl.CubeLevel;
import org.eclipse.osbp.xtext.datamart.common.olap.DerivedCellSet;
import org.eclipse.osbp.xtext.datamartdsl.AxisEnum;
import org.eclipse.osbp.xtext.datamartdsl.DatamartAxis;
import org.eclipse.osbp.xtext.datamartdsl.DatamartCube;
import org.eclipse.osbp.xtext.datamartdsl.DatamartCubeElement;
import org.eclipse.osbp.xtext.datamartdsl.DatamartDefinition;
import org.eclipse.osbp.xtext.datamartdsl.DatamartDerivedMeasure;
import org.eclipse.osbp.xtext.datamartdsl.DatamartElement;
import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity;
import org.eclipse.osbp.xtext.datamartdsl.DatamartMeasure;
import org.eclipse.osbp.xtext.datamartdsl.DatamartMember;
import org.eclipse.osbp.xtext.datamartdsl.DatamartNavigation;
import org.eclipse.osbp.xtext.datamartdsl.DatamartOwner;
import org.eclipse.osbp.xtext.datamartdsl.DatamartPackage;
import org.eclipse.osbp.xtext.datamartdsl.DatamartProperty;
import org.eclipse.osbp.xtext.datamartdsl.DatamartSource;
import org.eclipse.osbp.xtext.datamartdsl.ValueScaleEnum;
import org.eclipse.osbp.xtext.datamartdsl.jvmmodel.DatamartDSLJvmModelInferrer;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.common.types.JvmAnnotationReference;
import org.eclipse.xtext.common.types.JvmConstructor;
import org.eclipse.xtext.common.types.JvmDeclaredType;
import org.eclipse.xtext.common.types.JvmField;
import org.eclipse.xtext.common.types.JvmFormalParameter;
import org.eclipse.xtext.common.types.JvmGenericType;
import org.eclipse.xtext.common.types.JvmMember;
import org.eclipse.xtext.common.types.JvmOperation;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.common.types.JvmVisibility;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.xbase.compiler.output.ITreeAppendable;
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer;
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor;
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
/**
* <p>Infers a JVM model from the source model.</p>
*
* <p>The JVM model should contain all elements that would appear in the Java code
* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
*/
@SuppressWarnings("all")
public class ChartDSLJvmModelInferrer extends AbstractModelInferrer {
@Inject
@Extension
private JvmTypesBuilder _jvmTypesBuilder;
@Inject
@Extension
private IQualifiedNameProvider _iQualifiedNameProvider;
@Inject
@Extension
private DatamartDSLJvmModelInferrer datamartInferrer;
@Inject
@Extension
private ChartDSLD3JavaComponentsCreator _chartDSLD3JavaComponentsCreator;
/**
* <p>infer method dispatches the necessary routines to build fields, setter, getter, constructors and methods of the generated code.</p>
*/
protected void _infer(final ChartPackage pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
EList<Chart> _charts = pckg.getCharts();
for (final Chart chart : _charts) {
{
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(pckg);
String _plus = (_fullyQualifiedName + ".");
String _name = chart.getName();
String _plus_1 = (_plus + _name);
String _plus_2 = (_plus_1 + "Chart");
JvmGenericType cls = this._jvmTypesBuilder.toClass(chart, _plus_2);
EList<JvmTypeReference> _superTypes = cls.getSuperTypes();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(AbstractHybridVaaclipseView.class);
_superTypes.add(_typeRef);
EList<JvmTypeReference> _superTypes_1 = cls.getSuperTypes();
JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IUser.UserLocaleListener.class);
_superTypes_1.add(_typeRef_1);
final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() {
public void apply(final JvmGenericType it) {
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION);
ChartDSLJvmModelInferrer.this.toFields(it, chart);
ChartDSLJvmModelInferrer.this.toConstructor(it, chart);
ChartDSLJvmModelInferrer.this.toGetterSetter(it, chart);
ChartDSLJvmModelInferrer.this.toOperations(it, chart);
}
};
acceptor.<JvmGenericType>accept(cls, _function);
ChartOption _charttype = chart.getCharttype();
if ((_charttype instanceof ChartTree)) {
this._chartDSLD3JavaComponentsCreator.createJsJavaComponent(chart, acceptor);
}
}
}
}
/**
* <p>build the constructors to be used by an e4 application.</p>
*/
public void toConstructor(final JvmDeclaredType type, final Chart chart) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmConstructor> _function = new Procedure1<JvmConstructor>() {
public void apply(final JvmConstructor it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Inject.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(VerticalLayout.class);
JvmFormalParameter _parameter = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "parent", _typeRef);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmTypeReference _typeRef_1 = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IEclipseContext.class);
JvmFormalParameter _parameter_1 = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "context", _typeRef_1);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
EList<JvmFormalParameter> _parameters_2 = it.getParameters();
JvmTypeReference _typeRef_2 = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(MApplication.class);
JvmFormalParameter _parameter_2 = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "app", _typeRef_2);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super(parent,context,app);");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(chart, _function);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
}
/**
* <p>build the class variables.</p>
*/
public void toFields(final JvmDeclaredType type, final Chart chart) {
JvmField field = null;
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Logger.class);
final Procedure1<JvmField> _function = new Procedure1<JvmField>() {
public void apply(final JvmField it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("org.slf4j.LoggerFactory.getLogger(\"charts\")");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function);
}
};
JvmField _field = this._jvmTypesBuilder.toField(chart, "log", _typeRef, _function);
field = _field;
field.setStatic(true);
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IUser.class);
final Procedure1<JvmField> _function_1 = new Procedure1<JvmField>() {
public void apply(final JvmField it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Inject.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
}
};
JvmField _field_1 = this._jvmTypesBuilder.toField(chart, "user", _typeRef_1, _function_1);
field = _field_1;
EList<JvmMember> _members_1 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field);
JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(IEclipseContext.class);
final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() {
public void apply(final JvmField it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Inject.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
}
};
JvmField _field_2 = this._jvmTypesBuilder.toField(chart, "eclipseContext", _typeRef_2, _function_2);
field = _field_2;
EList<JvmMember> _members_2 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field);
JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Integer.class);
JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_3);
JvmField _field_3 = this._jvmTypesBuilder.toField(chart, "coordinateSystem", _typeRef_4);
field = _field_3;
EList<JvmMember> _members_3 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_3, field);
JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(IDatamartFilterGenerator.class);
JvmField _field_4 = this._jvmTypesBuilder.toField(chart, "filterGenerator", _typeRef_5);
field = _field_4;
EList<JvmMember> _members_4 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_4, field);
JvmTypeReference _typeRef_6 = this._typeReferenceBuilder.typeRef(IViewLayoutManager.class);
JvmField _field_5 = this._jvmTypesBuilder.toField(chart, "layoutManager", _typeRef_6);
field = _field_5;
EList<JvmMember> _members_5 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_5, field);
String _sourceDataMartRefName = this.getSourceDataMartRefName(chart);
boolean _notEquals = (!Objects.equal(_sourceDataMartRefName, null));
if (_notEquals) {
ChartDatamart _source = chart.getSource();
DatamartDefinition _datamartRef = _source.getDatamartRef();
EObject _eContainer = _datamartRef.eContainer();
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer));
String packageName = _fullyQualifiedName.toString();
StringConcatenation _builder = new StringConcatenation();
_builder.append(packageName, "");
_builder.append(".");
ChartDatamart _source_1 = chart.getSource();
DatamartDefinition _datamartRef_1 = _source_1.getDatamartRef();
String _name = _datamartRef_1.getName();
String _string = _name.toString();
_builder.append(_string, "");
_builder.append("Datamart");
JvmTypeReference _typeRef_7 = this._typeReferenceBuilder.typeRef(_builder.toString());
JvmField _field_6 = this._jvmTypesBuilder.toField(chart, "datamartClass", _typeRef_7);
field = _field_6;
EList<JvmMember> _members_6 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_6, field);
}
JvmTypeReference _typeRef_8 = this._typeReferenceBuilder.typeRef(Property.ValueChangeListener.class);
JvmField _field_7 = this._jvmTypesBuilder.toField(chart, "filterChangeListener", _typeRef_8);
field = _field_7;
EList<JvmMember> _members_7 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_7, field);
JvmTypeReference _typeRef_9 = this._typeReferenceBuilder.typeRef(Refresher.class);
JvmField _field_8 = this._jvmTypesBuilder.toField(chart, "chartRefresher", _typeRef_9);
field = _field_8;
EList<JvmMember> _members_8 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_8, field);
JvmTypeReference _typeRef_10 = this._typeReferenceBuilder.typeRef(boolean.class);
JvmField _field_9 = this._jvmTypesBuilder.toField(chart, "chartRefresherDone", _typeRef_10);
field = _field_9;
EList<JvmMember> _members_9 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_9, field);
JvmTypeReference _typeRef_11 = this._typeReferenceBuilder.typeRef(Refresher.class);
JvmField _field_10 = this._jvmTypesBuilder.toField(chart, "chartRenderDelay", _typeRef_11);
field = _field_10;
EList<JvmMember> _members_10 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field);
JvmTypeReference _typeRef_12 = this._typeReferenceBuilder.typeRef(Component.class);
JvmField _field_11 = this._jvmTypesBuilder.toField(chart, "dataComponent", _typeRef_12);
field = _field_11;
EList<JvmMember> _members_11 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_11, field);
JvmTypeReference _typeRef_13 = this._typeReferenceBuilder.typeRef(String.class);
JvmTypeReference _typeRef_14 = this._typeReferenceBuilder.typeRef(PropertyLookup.class);
JvmTypeReference _typeRef_15 = this._typeReferenceBuilder.typeRef(HashMap.class, _typeRef_13, _typeRef_14);
JvmField _field_12 = this._jvmTypesBuilder.toField(chart, "propertyLookupMap", _typeRef_15);
field = _field_12;
EList<JvmMember> _members_12 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field);
JvmTypeReference _typeRef_16 = this._typeReferenceBuilder.typeRef(DCharts.class);
JvmTypeReference _typeRef_17 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef_16);
JvmField _field_13 = this._jvmTypesBuilder.toField(chart, "charts", _typeRef_17);
field = _field_13;
EList<JvmMember> _members_13 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_13, field);
JvmTypeReference _typeRef_18 = this._typeReferenceBuilder.typeRef(IEventBroker.class);
final Procedure1<JvmField> _function_3 = new Procedure1<JvmField>() {
public void apply(final JvmField it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Inject.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
}
};
JvmField _field_14 = this._jvmTypesBuilder.toField(chart, "eventBroker", _typeRef_18, _function_3);
field = _field_14;
EList<JvmMember> _members_14 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_14, field);
JvmTypeReference _typeRef_19 = this._typeReferenceBuilder.typeRef(EventHandler.class);
JvmField _field_15 = this._jvmTypesBuilder.toField(chart, "refreshView", _typeRef_19);
field = _field_15;
EList<JvmMember> _members_15 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_15, field);
JvmTypeReference _typeRef_20 = this._typeReferenceBuilder.typeRef(IDSLMetadataService.class);
final Procedure1<JvmField> _function_4 = new Procedure1<JvmField>() {
public void apply(final JvmField it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Inject.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
}
};
JvmField _field_16 = this._jvmTypesBuilder.toField(chart, "dslMetadataService", _typeRef_20, _function_4);
field = _field_16;
EList<JvmMember> _members_16 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_16, field);
JvmTypeReference _typeRef_21 = this._typeReferenceBuilder.typeRef(Locale.class);
JvmField _field_17 = this._jvmTypesBuilder.toField(chart, "locale", _typeRef_21);
field = _field_17;
EList<JvmMember> _members_17 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_17, field);
}
/**
* <p>build the getters and setters from class variables.</p>
*/
public void toGetterSetter(final JvmDeclaredType type, final Chart chart) {
JvmOperation operation = null;
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Integer.class);
JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(ArrayList.class, _typeRef);
JvmOperation _getter = this._jvmTypesBuilder.toGetter(chart, "coordinateSystem", _typeRef_1);
operation = _getter;
operation.setVisibility(JvmVisibility.PUBLIC);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, operation);
}
/**
* <p>build the methods.</p>
*/
public void toOperations(final JvmDeclaredType type, final Chart chart) {
EList<JvmMember> _members = type.getMembers();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(VerticalLayout.class);
JvmFormalParameter _parameter = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "parent", _typeRef);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
String _createView = ChartDSLJvmModelInferrer.this.createView(chart);
_builder.append(_createView, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(chart, "createView", _typeRef, _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
EList<JvmMember> _members_1 = type.getMembers();
JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
String _createComponents = ChartDSLJvmModelInferrer.this.createComponents(chart);
_builder.append(_createComponents, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(chart, "createComponents", _typeRef_1, _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
EList<JvmMember> _members_2 = type.getMembers();
JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(Component.class);
final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(DerivedOlapException.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef_1 = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(DerivedCellSet.class);
JvmFormalParameter _parameter = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "cellSet", _typeRef_1);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmTypeReference _typeRef_2 = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Integer.class);
JvmFormalParameter _parameter_1 = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "axisNo", _typeRef_2);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
String _createTabSheet = ChartDSLJvmModelInferrer.this.createTabSheet(chart);
_builder.append(_createTabSheet, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(chart, "createTabSheet", _typeRef_2, _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
ChartOption _charttype = chart.getCharttype();
if ((!(_charttype instanceof ChartTree))) {
EList<JvmMember> _members_3 = type.getMembers();
JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Component.class);
final Procedure1<JvmOperation> _function_3 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(DerivedOlapException.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef_1 = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(DerivedCellSet.class);
JvmFormalParameter _parameter = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "cellSet", _typeRef_1);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
String _createChart = ChartDSLJvmModelInferrer.this.createChart(chart);
_builder.append(_createChart, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(chart, "createChart", _typeRef_3, _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
}
ChartOption _charttype_1 = chart.getCharttype();
if ((_charttype_1 instanceof ChartTree)) {
EList<JvmMember> _members_4 = type.getMembers();
JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(Component.class);
final Procedure1<JvmOperation> _function_4 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(DerivedOlapException.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
EList<JvmTypeReference> _exceptions_1 = it.getExceptions();
JvmTypeReference _typeRef_1 = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(JsonException.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions_1, _typeRef_1);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef_2 = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(DerivedCellSet.class);
JvmFormalParameter _parameter = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "cxCellSet", _typeRef_2);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
CharSequence _createD3Chart = ChartDSLJvmModelInferrer.this._chartDSLD3JavaComponentsCreator.createD3Chart(chart);
_builder.append(_createD3Chart, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(chart, "createD3Chart", _typeRef_4, _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
}
EList<JvmMember> _members_5 = type.getMembers();
JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_5 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
it.setVisibility(JvmVisibility.PROTECTED);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(PostConstruct.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
String _setup = ChartDSLJvmModelInferrer.this.setup(chart);
_builder.append(_setup, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(chart, "setup", _typeRef_5, _function_5);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5);
EList<JvmMember> _members_6 = type.getMembers();
JvmTypeReference _typeRef_6 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_6 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
it.setVisibility(JvmVisibility.PROTECTED);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
CharSequence _subscribe = ChartDSLJvmModelInferrer.this.subscribe(chart);
_builder.append(_subscribe, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(chart, "subscribe", _typeRef_6, _function_6);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
EList<JvmMember> _members_7 = type.getMembers();
JvmTypeReference _typeRef_7 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_7 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
it.setVisibility(JvmVisibility.PROTECTED);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(PreDestroy.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
CharSequence _unsubscribe = ChartDSLJvmModelInferrer.this.unsubscribe(chart);
_builder.append(_unsubscribe, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(chart, "unsubscribe", _typeRef_7, _function_7);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
EList<JvmMember> _members_8 = type.getMembers();
JvmTypeReference _typeRef_8 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_8 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = ChartDSLJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Override.class);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = ChartDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Locale.class);
JvmFormalParameter _parameter = ChartDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(chart, "locale", _typeRef);
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
CharSequence _localeChanged = ChartDSLJvmModelInferrer.this.localeChanged(chart);
_builder.append(_localeChanged, "");
it.append(_builder);
}
};
ChartDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(chart, "localeChanged", _typeRef_8, _function_8);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
}
public CharSequence subscribe(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("eventBroker.subscribe(EventBrokerMsg.REFRESH_VIEW+\"");
String _name = chart.getName();
_builder.append(_name, "");
_builder.append("Chart\", refreshView);");
return _builder;
}
public CharSequence unsubscribe(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("eventBroker.unsubscribe(refreshView);");
return _builder;
}
public String getSourceDataMartRefName(final Chart chart) {
boolean _and = false;
boolean _and_1 = false;
ChartDatamart _source = chart.getSource();
boolean _notEquals = (!Objects.equal(_source, null));
if (!_notEquals) {
_and_1 = false;
} else {
ChartDatamart _source_1 = chart.getSource();
DatamartDefinition _datamartRef = _source_1.getDatamartRef();
boolean _notEquals_1 = (!Objects.equal(_datamartRef, null));
_and_1 = _notEquals_1;
}
if (!_and_1) {
_and = false;
} else {
ChartDatamart _source_2 = chart.getSource();
DatamartDefinition _datamartRef_1 = _source_2.getDatamartRef();
String _name = _datamartRef_1.getName();
boolean _notEquals_2 = (!Objects.equal(_name, null));
_and = _notEquals_2;
}
if (_and) {
ChartDatamart _source_3 = chart.getSource();
DatamartDefinition _datamartRef_2 = _source_3.getDatamartRef();
String _name_1 = _datamartRef_2.getName();
return _name_1.toString();
} else {
return null;
}
}
/**
* <p>build the main method to be called from e4.</p>
*/
public String createView(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("chartRefresherDone = false;");
_builder.newLine();
_builder.append("charts = new ArrayList<DCharts>();");
_builder.newLine();
_builder.append("coordinateSystem = new ArrayList<Integer>();");
_builder.newLine();
_builder.append("filterGenerator = new DatamartFilterGenerator();");
_builder.newLine();
_builder.append("filterGenerator.setDslMetadataService(dslMetadataService);");
_builder.newLine();
_builder.append("layoutManager = new ViewLayoutManager();");
_builder.newLine();
_builder.append("chartRefresher = new Refresher();");
_builder.newLine();
_builder.append("chartRenderDelay = new Refresher();");
_builder.newLine();
_builder.append("propertyLookupMap = new HashMap<String,PropertyLookup>();");
_builder.newLine();
String body = _builder.toString();
String _sourceDataMartRefName = this.getSourceDataMartRefName(chart);
boolean _notEquals = (!Objects.equal(_sourceDataMartRefName, null));
if (_notEquals) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.newLineIfNotEmpty();
_builder_1.append("datamartClass = new ");
String _sourceDataMartRefName_1 = this.getSourceDataMartRefName(chart);
_builder_1.append(_sourceDataMartRefName_1, "");
_builder_1.append("Datamart();");
body = _builder_1.toString();
}
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body, "");
_builder_2.newLineIfNotEmpty();
_builder_2.append("parent.setPrimaryStyleName(\"osbp\"); // <== is THIS necessary any more???");
_builder_2.newLine();
_builder_2.append("parent.addStyleName(\"");
String _styleName = EnumCssClass.VIEW.styleName();
_builder_2.append(_styleName, "");
_builder_2.append("\");");
_builder_2.newLineIfNotEmpty();
_builder_2.append("parent.addStyleName(\"");
String _styleName_1 = EnumCssClass.CHART_VIEW.styleName();
_builder_2.append(_styleName_1, "");
_builder_2.append("\");");
_builder_2.newLineIfNotEmpty();
_builder_2.append("parent.setSizeFull();");
_builder_2.newLine();
_builder_2.append("layoutManager.init(parent);");
_builder_2.newLine();
_builder_2.append("refreshView = ");
String _refreshView = this.refreshView(chart);
_builder_2.append(_refreshView, "");
_builder_2.newLineIfNotEmpty();
body = _builder_2.toString();
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body, "");
_builder_3.newLineIfNotEmpty();
_builder_3.append("chartRenderDelay.setRefreshInterval(100);");
_builder_3.newLine();
_builder_3.append("chartRenderDelay.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() {");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("@Override");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("public void refresh(final Refresher source) {");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("// refresh only once");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("layoutManager.removeExtension(source);");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("log.debug(\"initial - show delayed\");");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("for(DCharts chart : charts) {");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("chart.show();");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("chartRefresherDone = true;");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("});");
_builder_3.newLine();
_builder_3.append("layoutManager.addExtension(chartRenderDelay);");
_builder_3.newLine();
_builder_3.append("user.addUserLocaleListener(this);");
_builder_3.newLine();
body = _builder_3.toString();
boolean _isPolling = chart.isPolling();
if (_isPolling) {
StringConcatenation _builder_4 = new StringConcatenation();
_builder_4.append(body, "");
_builder_4.newLineIfNotEmpty();
_builder_4.append("chartRefresher.setRefreshInterval(");
int _pollingTime = chart.getPollingTime();
_builder_4.append(_pollingTime, "");
_builder_4.append("*1000);");
_builder_4.newLineIfNotEmpty();
_builder_4.append("chartRefresher.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() {");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("@Override");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("public void refresh(final Refresher source) {");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("renderData();");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("});");
_builder_4.newLine();
_builder_4.append("layoutManager.addExtension(chartRefresher);");
_builder_4.newLine();
body = _builder_4.toString();
}
ChartDatamart _source = chart.getSource();
boolean _notEquals_1 = (!Objects.equal(_source, null));
if (_notEquals_1) {
StringConcatenation _builder_5 = new StringConcatenation();
_builder_5.append(body, "");
_builder_5.newLineIfNotEmpty();
_builder_5.append("filterChangeListener = new ValueChangeListener() {");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("@Override");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {");
_builder_5.newLine();
_builder_5.append("\t\t");
_builder_5.append("renderData();");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("}");
_builder_5.newLine();
_builder_5.append("};");
_builder_5.newLine();
_builder_5.append("filterGenerator.createFilter(datamartClass, user, filterChangeListener, layoutManager);");
_builder_5.newLine();
body = _builder_5.toString();
}
StringConcatenation _builder_6 = new StringConcatenation();
_builder_6.append(body, "");
_builder_6.append("// to resize the chart according to browser");
_builder_6.newLineIfNotEmpty();
_builder_6.append("Page.getCurrent().addBrowserWindowResizeListener(new BrowserWindowResizeListener() {");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("@Override");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("public void browserWindowResized(BrowserWindowResizeEvent event) {");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("log.debug(\"browserWindowResized - mark dirty\");");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("getParent().markAsDirtyRecursive();");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("}");
_builder_6.newLine();
_builder_6.append("});");
_builder_6.newLine();
_builder_6.append("// to resize the chart according to split positions of partsashcontainer - setContainerData is tracked");
_builder_6.newLine();
_builder_6.append("EObject container = ((EObject)eclipseContext.get(MUIElement.class)).eContainer();");
_builder_6.newLine();
_builder_6.append("if(!(container instanceof MPartStack)) {");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("container = (EObject)eclipseContext.get(MUIElement.class);");
_builder_6.newLine();
_builder_6.append("}");
_builder_6.newLine();
_builder_6.append("container.eAdapters().add(new AdapterImpl() {");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("public void notifyChanged(Notification notification) {");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("if (notification.getEventType()==Notification.SET && ");
_builder_6.newLine();
_builder_6.append("\t\t\t\t");
_builder_6.append("notification.getFeatureID(UIElementImpl.class) == UiPackageImpl.UI_ELEMENT__CONTAINER_DATA)");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("{");
_builder_6.newLine();
_builder_6.append("\t\t\t");
_builder_6.append("log.debug(\"split position changed - mark dirty\");");
_builder_6.newLine();
_builder_6.append("\t\t\t");
_builder_6.append("getParent().markAsDirtyRecursive();");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("}");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("}");
_builder_6.newLine();
_builder_6.append("});");
_builder_6.newLine();
body = _builder_6.toString();
return body;
}
/**
* <p>create a handler for external triggered refresh requests.</p>
*/
public String refreshView(final Chart chart) {
String body = "";
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
_builder.newLineIfNotEmpty();
_builder.append("new EventHandler() {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void handleEvent(Event event) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("renderData();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("};");
_builder.newLine();
body = _builder.toString();
return body;
}
/**
* <p>build the data components.</p>
*/
public String createComponents(final Chart chart) {
String body = "";
ChartDatamart _source = chart.getSource();
boolean _notEquals = (!Objects.equal(_source, null));
if (_notEquals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
_builder.append("// get the results");
_builder.newLineIfNotEmpty();
_builder.append("try {");
_builder.newLine();
_builder.append("\t");
_builder.append("final DerivedCellSet cellSet = datamartClass.getResults(user, filterGenerator.getFilter(");
ChartDatamart _source_1 = chart.getSource();
DatamartDefinition _datamartRef = _source_1.getDatamartRef();
DatamartSource _source_2 = _datamartRef.getSource();
boolean _booleanValue = Boolean.valueOf((_source_2 instanceof DatamartCube)).booleanValue();
String _string = Boolean.valueOf(_booleanValue).toString();
_builder.append(_string, "\t");
_builder.append("), getTaskOperativeDtoClass(), getTaskInitialOperativeDtos());");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("getCoordinateSystem().clear();");
_builder.newLine();
_builder.append("\t");
_builder.append("if (cellSet == null) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("promptSecurityMessage(dslMetadataService.translate(locale.toLanguageTag(), \"securityMessage\"), layoutManager.getDataArea());");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return;");
_builder.newLine();
_builder.append("\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("layoutManager.getDataArea().removeAllComponents();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("// generate a new result component");
_builder.newLine();
_builder.append("\t");
_builder.append("if (cellSet != null) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("// create a multidimensional coordinate system against the cellSet");
_builder.newLine();
_builder.append("\t\t");
_builder.append("for\t(int axis = 0; axis < cellSet.getAxes().size(); axis++) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("getCoordinateSystem().add(0);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("// remove any previous component");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if\t(dataComponent != null) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("layoutManager.getDataArea().removeComponent(dataComponent);");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("dataComponent = null;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (cellSet.getAxes().size() < 2) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("log.error(\"at least 2 axes from referenced datamart ");
ChartDatamart _source_3 = chart.getSource();
DatamartDefinition _datamartRef_1 = _source_3.getDatamartRef();
String _name = _datamartRef_1.getName();
_builder.append(_name, "\t\t\t");
_builder.append(" are needed to render ");
String _name_1 = chart.getName();
_builder.append(_name_1, "\t\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("dataComponent = createTabSheet(cellSet, cellSet.getAxes().size());");
_builder.newLine();
_builder.append("\t\t");
_builder.append("dataComponent.setSizeFull();");
_builder.newLine();
_builder.append("\t\t");
_builder.append("dataComponent.setId(\"dataComponent\");");
_builder.newLine();
_builder.append("\t\t");
_builder.append("dataComponent.addStyleName(\"");
String _styleName = EnumCssClass.DATA_COMPONENT.styleName();
_builder.append(_styleName, "\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("layoutManager.getDataArea().addComponent(dataComponent);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("layoutManager.getDataArea().setExpandRatio(dataComponent, 1);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("else {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("log.error(\"referenced datamart ");
ChartDatamart _source_4 = chart.getSource();
DatamartDefinition _datamartRef_2 = _source_4.getDatamartRef();
String _name_2 = _datamartRef_2.getName();
_builder.append(_name_2, "\t\t");
_builder.append(" generates no results\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("} catch (DerivedOlapException e) {");
_builder.newLine();
_builder.append("\t");
_builder.append("log.error(e.getLocalizedMessage());");
_builder.newLine();
_builder.append("}");
_builder.newLine();
body = _builder.toString();
} else {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.newLineIfNotEmpty();
_builder_1.append("// generate a new result component");
_builder_1.newLine();
_builder_1.append("try {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("// remove any previous component");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("if\t(dataComponent != null) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("layoutManager.getDataArea().removeComponent(dataComponent);");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("dataComponent = null;");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}\t\t\t\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent = createTabSheet(null, 2);");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent.setSizeFull();");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent.setId(\"dataComponent\");");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent.addStyleName(\"");
String _styleName_1 = EnumCssClass.DATA_COMPONENT.styleName();
_builder_1.append(_styleName_1, "\t");
_builder_1.append("\");");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("layoutManager.getDataArea().addComponent(dataComponent);");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("layoutManager.getDataArea().setExpandRatio(dataComponent, 1);");
_builder_1.newLine();
_builder_1.append("} catch (DerivedOlapException e) {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("log.error(e.getLocalizedMessage());");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
body = _builder_1.toString();
}
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>
*/
public String createTabSheet(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("charts.clear();");
_builder.newLine();
_builder.append("// either create a recursive tabsheet or a chart");
_builder.newLine();
_builder.append("Component component = null;");
_builder.newLine();
_builder.append("if\t(axisNo == 2) {");
_builder.newLine();
String body = _builder.toString();
ChartOption _charttype = chart.getCharttype();
if ((_charttype instanceof ChartTree)) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("try {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("component = createD3Chart(cellSet);");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("} catch (JsonException e) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("log.error(e.getLocalizedMessage());");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
body = _builder_1.toString();
} else {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body, "");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t");
_builder_2.append("component = createChart(cellSet);");
_builder_2.newLine();
body = _builder_2.toString();
}
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body, "");
_builder_3.newLineIfNotEmpty();
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("else {\t\t");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("Integer axis = axisNo-1;");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("TabSheet tabsheet = new TabSheet();");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("tabsheet.setSizeFull();");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("DerivedAxis tabAxis = cellSet.getAxes().get(axis);");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("// create a tab page for all tab axis members");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("int tabNo = 0;");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("for\t(DerivedPosition column : tabAxis.getPositions()) {");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("// create the title for the axis");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("String title = null;");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("for (DerivedMember member : column.getMembers()) {");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("if\t(title == null) {");
_builder_3.newLine();
_builder_3.append("\t\t\t\t");
_builder_3.append("title = dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("else {");
_builder_3.newLine();
_builder_3.append("\t\t\t\t");
_builder_3.append("title += \" / \"+dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("// position the data to this coordinate");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("getCoordinateSystem().set(axis, tabNo);");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("component = createTabSheet(cellSet, axis);");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("// set the caption");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("if (component != null) {");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("component.setCaption(title);");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("// add the component as a tab page");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("tabsheet.addComponent(component);");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("tabNo++;");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("component = tabsheet;");
_builder_3.newLine();
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("return component;");
body = _builder_3.toString();
return body;
}
/**
* <p>build the chart components.</p>
*/
public String createChart(final Chart chart) {
String body = "";
String postfix = "";
String chartType = "";
boolean hasAxis = true;
HashMap<String, String> multipleAxes = CollectionLiterals.<String, String>newHashMap();
ChartAxis category_axis = null;
ChartAxis data_axis = null;
ChartAxis inner_axis = null;
ChartAxis outer_axis = null;
boolean axisSwitch = false;
String axisPrefix = "XY";
ChartOption _charttype = chart.getCharttype();
if ((_charttype instanceof ChartBar)) {
ChartOption _charttype_1 = chart.getCharttype();
boolean _isSwapped = ((ChartBar) _charttype_1).isSwapped();
if (_isSwapped) {
axisPrefix = "YX";
axisSwitch = true;
}
}
ChartDatamart _source = chart.getSource();
EList<ChartElement> _elements = _source.getElements();
for (final ChartElement element : _elements) {
if ((element instanceof ChartAxis)) {
ChartAxis axis = ((ChartAxis) element);
boolean _or = false;
DatamartAxis _axis = axis.getAxis();
AxisEnum _name = _axis.getName();
String _name_1 = _name.getName();
boolean _equals = _name_1.equals("COLUMNS");
if (_equals) {
_or = true;
} else {
DatamartAxis _axis_1 = axis.getAxis();
AxisEnum _name_2 = _axis_1.getName();
String _name_3 = _name_2.getName();
boolean _equals_1 = _name_3.equals("ROWS");
_or = _equals_1;
}
if (_or) {
boolean _or_1 = false;
boolean _or_2 = false;
RenderTypeEnum _renderType = axis.getRenderType();
String _name_4 = _renderType.getName();
boolean _equals_2 = _name_4.equals("LOG");
if (_equals_2) {
_or_2 = true;
} else {
RenderTypeEnum _renderType_1 = axis.getRenderType();
String _name_5 = _renderType_1.getName();
boolean _equals_3 = _name_5.equals("LINEAR");
_or_2 = _equals_3;
}
if (_or_2) {
_or_1 = true;
} else {
RenderTypeEnum _renderType_2 = axis.getRenderType();
String _name_6 = _renderType_2.getName();
boolean _equals_4 = _name_6.equals("PYRAMID");
_or_1 = _equals_4;
}
if (_or_1) {
data_axis = axis;
}
boolean _or_3 = false;
RenderTypeEnum _renderType_3 = axis.getRenderType();
String _name_7 = _renderType_3.getName();
boolean _equals_5 = _name_7.equals("CATEGORY");
if (_equals_5) {
_or_3 = true;
} else {
RenderTypeEnum _renderType_4 = axis.getRenderType();
String _name_8 = _renderType_4.getName();
boolean _equals_6 = _name_8.equals("DATE");
_or_3 = _equals_6;
}
if (_or_3) {
category_axis = axis;
}
}
}
}
ChartOption _charttype_2 = chart.getCharttype();
if ((_charttype_2 instanceof ChartBar)) {
chartType = "BAR";
StringConcatenation _builder = new StringConcatenation();
_builder.append("_");
_builder.append(chartType, "");
postfix = _builder.toString();
inner_axis = category_axis;
outer_axis = data_axis;
} else {
ChartOption _charttype_3 = chart.getCharttype();
if ((_charttype_3 instanceof ChartBubble)) {
chartType = "BUBBLE";
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("_");
_builder_1.append(chartType, "");
postfix = _builder_1.toString();
hasAxis = true;
inner_axis = data_axis;
outer_axis = category_axis;
} else {
ChartOption _charttype_4 = chart.getCharttype();
if ((_charttype_4 instanceof ChartDonut)) {
chartType = "DONUT";
hasAxis = false;
inner_axis = category_axis;
outer_axis = data_axis;
} else {
ChartOption _charttype_5 = chart.getCharttype();
if ((_charttype_5 instanceof ChartLine)) {
chartType = "LINE";
inner_axis = category_axis;
outer_axis = data_axis;
} else {
ChartOption _charttype_6 = chart.getCharttype();
if ((_charttype_6 instanceof ChartPie)) {
chartType = "PIE";
hasAxis = false;
inner_axis = data_axis;
outer_axis = category_axis;
} else {
ChartOption _charttype_7 = chart.getCharttype();
if ((_charttype_7 instanceof ChartGauge)) {
chartType = "METER_GAUGE";
hasAxis = false;
inner_axis = data_axis;
outer_axis = category_axis;
}
}
}
}
}
}
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("List<Integer> coordinate = new ArrayList<Integer>(getCoordinateSystem());");
_builder_2.newLine();
body = _builder_2.toString();
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body, "");
_builder_3.append("// create a label series");
_builder_3.newLineIfNotEmpty();
_builder_3.append("List<String> ");
DatamartAxis _axis_2 = data_axis.getAxis();
AxisEnum _name_9 = _axis_2.getName();
String _literal = _name_9.getLiteral();
_builder_3.append(_literal, "");
_builder_3.append("TitlesArray = new ArrayList<String>();");
_builder_3.newLineIfNotEmpty();
_builder_3.append("for\t(DerivedPosition pos : cellSet.getAxes().get(");
DatamartAxis _axis_3 = data_axis.getAxis();
AxisEnum _name_10 = _axis_3.getName();
int _value = _name_10.getValue();
_builder_3.append(_value, "");
_builder_3.append(").getPositions()) {");
_builder_3.newLineIfNotEmpty();
body = _builder_3.toString();
StringConcatenation _builder_4 = new StringConcatenation();
_builder_4.append(body, "");
_builder_4.newLineIfNotEmpty();
_builder_4.append("\t");
_builder_4.append("String title = null;");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("Boolean valueUsed = false;");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("for (DerivedMember member : pos.getMembers()) {");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("if\t(title == null) {");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("title = dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("else {");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("title += \" \"+dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t");
DatamartAxis _axis_4 = data_axis.getAxis();
AxisEnum _name_11 = _axis_4.getName();
String _literal_1 = _name_11.getLiteral();
_builder_4.append(_literal_1, "\t");
_builder_4.append("TitlesArray.add(title);");
_builder_4.newLineIfNotEmpty();
_builder_4.append("}");
_builder_4.newLine();
body = _builder_4.toString();
if (hasAxis) {
StringConcatenation _builder_5 = new StringConcatenation();
_builder_5.append(body, "");
_builder_5.append("Series ");
DatamartAxis _axis_5 = data_axis.getAxis();
AxisEnum _name_12 = _axis_5.getName();
String _literal_2 = _name_12.getLiteral();
_builder_5.append(_literal_2, "");
_builder_5.append("Series = new Series();");
_builder_5.newLineIfNotEmpty();
body = _builder_5.toString();
StringConcatenation _builder_6 = new StringConcatenation();
_builder_6.append(body, "");
_builder_6.append("if (");
DatamartAxis _axis_6 = data_axis.getAxis();
AxisEnum _name_13 = _axis_6.getName();
String _literal_3 = _name_13.getLiteral();
_builder_6.append(_literal_3, "");
_builder_6.append("TitlesArray.size() > 0) {");
_builder_6.newLineIfNotEmpty();
body = _builder_6.toString();
boolean showMarker = false;
ChartOption _charttype_8 = chart.getCharttype();
if ((_charttype_8 instanceof ChartLine)) {
ChartOption _charttype_9 = chart.getCharttype();
boolean _isShowMarker = ((ChartLine) _charttype_9).isShowMarker();
showMarker = _isShowMarker;
}
StringConcatenation _builder_7 = new StringConcatenation();
_builder_7.append(body, "");
String _createLabelSeries = this.createLabelSeries(chart, data_axis, multipleAxes, axisPrefix, showMarker);
_builder_7.append(_createLabelSeries, "");
body = _builder_7.toString();
StringConcatenation _builder_8 = new StringConcatenation();
_builder_8.append(body, "");
_builder_8.append("}");
_builder_8.newLineIfNotEmpty();
body = _builder_8.toString();
}
StringConcatenation _builder_9 = new StringConcatenation();
_builder_9.append(body, "");
_builder_9.append("// create the data series ticks");
_builder_9.newLineIfNotEmpty();
_builder_9.append("String ");
DatamartAxis _axis_7 = category_axis.getAxis();
AxisEnum _name_14 = _axis_7.getName();
String _literal_4 = _name_14.getLiteral();
_builder_9.append(_literal_4, "");
_builder_9.append("AxisLabel = \"\";");
_builder_9.newLineIfNotEmpty();
_builder_9.append("Boolean ");
DatamartAxis _axis_8 = category_axis.getAxis();
AxisEnum _name_15 = _axis_8.getName();
String _literal_5 = _name_15.getLiteral();
_builder_9.append(_literal_5, "");
_builder_9.append("AxisLabelSet = false;");
_builder_9.newLineIfNotEmpty();
_builder_9.append("List<String> ");
DatamartAxis _axis_9 = category_axis.getAxis();
AxisEnum _name_16 = _axis_9.getName();
String _literal_6 = _name_16.getLiteral();
_builder_9.append(_literal_6, "");
_builder_9.append("TitlesArray = new ArrayList<String>();");
_builder_9.newLineIfNotEmpty();
_builder_9.append("for\t(DerivedPosition pos : cellSet.getAxes().get(");
DatamartAxis _axis_10 = category_axis.getAxis();
AxisEnum _name_17 = _axis_10.getName();
int _value_1 = _name_17.getValue();
_builder_9.append(_value_1, "");
_builder_9.append(").getPositions()) {");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t");
_builder_9.append("String title = \"\";");
_builder_9.newLine();
_builder_9.append("\t");
_builder_9.append("for (DerivedMember member : pos.getMembers()) {");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("String[] tokens = member.getUniqueName().split(\"\\\\]\\\\.\\\\[\");");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("if (!");
DatamartAxis _axis_11 = category_axis.getAxis();
AxisEnum _name_18 = _axis_11.getName();
String _literal_7 = _name_18.getLiteral();
_builder_9.append(_literal_7, " \t");
_builder_9.append("AxisLabelSet) {");
_builder_9.newLineIfNotEmpty();
_builder_9.append(" \t\t");
_builder_9.append("if (");
DatamartAxis _axis_12 = category_axis.getAxis();
AxisEnum _name_19 = _axis_12.getName();
String _literal_8 = _name_19.getLiteral();
_builder_9.append(_literal_8, " \t\t");
_builder_9.append("AxisLabel.length() > 0) {");
_builder_9.newLineIfNotEmpty();
_builder_9.append(" \t\t\t");
DatamartAxis _axis_13 = category_axis.getAxis();
AxisEnum _name_20 = _axis_13.getName();
String _literal_9 = _name_20.getLiteral();
_builder_9.append(_literal_9, " \t\t\t");
_builder_9.append("AxisLabel += \" / \";");
_builder_9.newLineIfNotEmpty();
_builder_9.append(" \t\t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append(" \t\t");
DatamartAxis _axis_14 = category_axis.getAxis();
AxisEnum _name_21 = _axis_14.getName();
String _literal_10 = _name_21.getLiteral();
_builder_9.append(_literal_10, " \t\t");
_builder_9.append("AxisLabel += dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getLevel().getName());");
_builder_9.newLineIfNotEmpty();
_builder_9.append(" \t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("int start = 1;");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("// if shortlabel is configured, use only last level name");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("if (");
boolean _isShortLabel = category_axis.isShortLabel();
boolean _booleanValue = Boolean.valueOf(_isShortLabel).booleanValue();
_builder_9.append(_booleanValue, " \t");
_builder_9.append(") {");
_builder_9.newLineIfNotEmpty();
_builder_9.append(" \t\t");
_builder_9.append("start = tokens.length-1;");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("for\t(int token = start; token < tokens.length; token++) {");
_builder_9.newLine();
_builder_9.append(" \t\t");
_builder_9.append("title += dslMetadataService.translate(user.getLocale().toLanguageTag(), tokens[token])+\" \";");
_builder_9.newLine();
_builder_9.append(" \t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t");
DatamartAxis _axis_15 = category_axis.getAxis();
AxisEnum _name_22 = _axis_15.getName();
String _literal_11 = _name_22.getLiteral();
_builder_9.append(_literal_11, "\t");
_builder_9.append("AxisLabelSet = true;");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t");
DatamartAxis _axis_16 = category_axis.getAxis();
AxisEnum _name_23 = _axis_16.getName();
String _literal_12 = _name_23.getLiteral();
_builder_9.append(_literal_12, "\t");
_builder_9.append("TitlesArray.add(title.trim().replace(\"[\", \"\").replace(\"]\", \"\"));");
_builder_9.newLineIfNotEmpty();
_builder_9.append("}");
_builder_9.newLine();
body = _builder_9.toString();
if (hasAxis) {
StringConcatenation _builder_10 = new StringConcatenation();
_builder_10.append(body, "");
_builder_10.append("Ticks ");
DatamartAxis _axis_17 = category_axis.getAxis();
AxisEnum _name_24 = _axis_17.getName();
String _literal_13 = _name_24.getLiteral();
_builder_10.append(_literal_13, "");
_builder_10.append("Ticks = new Ticks();");
_builder_10.newLineIfNotEmpty();
DatamartAxis _axis_18 = category_axis.getAxis();
AxisEnum _name_25 = _axis_18.getName();
String _literal_14 = _name_25.getLiteral();
_builder_10.append(_literal_14, "");
_builder_10.append("Ticks.add(");
DatamartAxis _axis_19 = category_axis.getAxis();
AxisEnum _name_26 = _axis_19.getName();
String _literal_15 = _name_26.getLiteral();
_builder_10.append(_literal_15, "");
_builder_10.append("TitlesArray.toArray());");
_builder_10.newLineIfNotEmpty();
body = _builder_10.toString();
}
StringConcatenation _builder_11 = new StringConcatenation();
_builder_11.append(body, "");
_builder_11.append("// copy cellset data to data series");
_builder_11.newLineIfNotEmpty();
_builder_11.append("DataSeries dataSeries = new DataSeries();");
_builder_11.newLine();
body = _builder_11.toString();
ChartOption _charttype_10 = chart.getCharttype();
if ((_charttype_10 instanceof ChartBubble)) {
StringConcatenation _builder_12 = new StringConcatenation();
_builder_12.append(body, "");
_builder_12.append("dataSeries.newSeries();");
_builder_12.newLineIfNotEmpty();
body = _builder_12.toString();
}
StringConcatenation _builder_13 = new StringConcatenation();
_builder_13.append(body, "");
_builder_13.append("int ");
DatamartAxis _axis_20 = outer_axis.getAxis();
AxisEnum _name_27 = _axis_20.getName();
String _literal_16 = _name_27.getLiteral();
_builder_13.append(_literal_16, "");
_builder_13.append("No = 0;");
_builder_13.newLineIfNotEmpty();
body = _builder_13.toString();
StringConcatenation _builder_14 = new StringConcatenation();
_builder_14.append(body, "");
_builder_14.append("for\t(DerivedPosition ");
DatamartAxis _axis_21 = outer_axis.getAxis();
AxisEnum _name_28 = _axis_21.getName();
String _literal_17 = _name_28.getLiteral();
_builder_14.append(_literal_17, "");
_builder_14.append("Pos : cellSet.getAxes().get(");
DatamartAxis _axis_22 = outer_axis.getAxis();
AxisEnum _name_29 = _axis_22.getName();
int _value_2 = _name_29.getValue();
_builder_14.append(_value_2, "");
_builder_14.append(").getPositions()) {");
_builder_14.newLineIfNotEmpty();
body = _builder_14.toString();
StringConcatenation _builder_15 = new StringConcatenation();
_builder_15.append(body, "");
_builder_15.append("\tcoordinate.set(");
DatamartAxis _axis_23 = outer_axis.getAxis();
AxisEnum _name_30 = _axis_23.getName();
int _value_3 = _name_30.getValue();
_builder_15.append(_value_3, "");
_builder_15.append(", ");
DatamartAxis _axis_24 = outer_axis.getAxis();
AxisEnum _name_31 = _axis_24.getName();
String _literal_18 = _name_31.getLiteral();
_builder_15.append(_literal_18, "");
_builder_15.append("No);");
_builder_15.newLineIfNotEmpty();
body = _builder_15.toString();
ChartOption _charttype_11 = chart.getCharttype();
if ((_charttype_11 instanceof ChartDonut)) {
StringConcatenation _builder_16 = new StringConcatenation();
_builder_16.append(body, "");
_builder_16.append("\tdataSeries.newSeries();");
_builder_16.newLineIfNotEmpty();
body = _builder_16.toString();
}
if (((!(chart.getCharttype() instanceof ChartPie)) && (!(chart.getCharttype() instanceof ChartDonut)))) {
StringConcatenation _builder_17 = new StringConcatenation();
_builder_17.append(body, "");
_builder_17.append("\tArrayList<Object> ");
DatamartAxis _axis_25 = inner_axis.getAxis();
AxisEnum _name_32 = _axis_25.getName();
String _literal_19 = _name_32.getLiteral();
_builder_17.append(_literal_19, "");
_builder_17.append("DataSeries = new ArrayList<Object>();");
_builder_17.newLineIfNotEmpty();
body = _builder_17.toString();
}
StringConcatenation _builder_18 = new StringConcatenation();
_builder_18.append(body, "");
_builder_18.append("\tint ");
DatamartAxis _axis_26 = inner_axis.getAxis();
AxisEnum _name_33 = _axis_26.getName();
String _literal_20 = _name_33.getLiteral();
_builder_18.append(_literal_20, "");
_builder_18.append("No = 0;");
_builder_18.newLineIfNotEmpty();
body = _builder_18.toString();
StringConcatenation _builder_19 = new StringConcatenation();
_builder_19.append(body, "");
_builder_19.append("\tfor\t(DerivedPosition ");
DatamartAxis _axis_27 = inner_axis.getAxis();
AxisEnum _name_34 = _axis_27.getName();
String _literal_21 = _name_34.getLiteral();
_builder_19.append(_literal_21, "");
_builder_19.append("Pos : cellSet.getAxes().get(");
DatamartAxis _axis_28 = inner_axis.getAxis();
AxisEnum _name_35 = _axis_28.getName();
int _value_4 = _name_35.getValue();
_builder_19.append(_value_4, "");
_builder_19.append(").getPositions()) {");
_builder_19.newLineIfNotEmpty();
body = _builder_19.toString();
ChartOption _charttype_12 = chart.getCharttype();
if ((_charttype_12 instanceof ChartPie)) {
StringConcatenation _builder_20 = new StringConcatenation();
_builder_20.append(body, "");
_builder_20.append("\t\tdataSeries.newSeries();");
_builder_20.newLineIfNotEmpty();
body = _builder_20.toString();
}
StringConcatenation _builder_21 = new StringConcatenation();
_builder_21.append(body, "");
_builder_21.append("\t\tcoordinate.set(");
DatamartAxis _axis_29 = inner_axis.getAxis();
AxisEnum _name_36 = _axis_29.getName();
int _value_5 = _name_36.getValue();
_builder_21.append(_value_5, "");
_builder_21.append(", ");
DatamartAxis _axis_30 = inner_axis.getAxis();
AxisEnum _name_37 = _axis_30.getName();
String _literal_22 = _name_37.getLiteral();
_builder_21.append(_literal_22, "");
_builder_21.append("No);");
_builder_21.newLineIfNotEmpty();
body = _builder_21.toString();
StringConcatenation _builder_22 = new StringConcatenation();
_builder_22.append(body, "");
_builder_22.newLineIfNotEmpty();
_builder_22.append("\t\t");
_builder_22.append("Object value = null;");
_builder_22.newLine();
_builder_22.append("\t\t");
_builder_22.append("DerivedCell cell = cellSet.getCell(coordinate);");
_builder_22.newLine();
_builder_22.append("\t\t");
_builder_22.append("if (cell != null) {");
_builder_22.newLine();
_builder_22.append("\t\t\t");
_builder_22.append("value = cell.getValue();");
_builder_22.newLine();
_builder_22.append("\t\t");
_builder_22.append("}");
_builder_22.newLine();
body = _builder_22.toString();
boolean _or_4 = false;
ChartOption _charttype_13 = chart.getCharttype();
if ((_charttype_13 instanceof ChartPie)) {
_or_4 = true;
} else {
ChartOption _charttype_14 = chart.getCharttype();
_or_4 = (_charttype_14 instanceof ChartDonut);
}
if (_or_4) {
StringConcatenation _builder_23 = new StringConcatenation();
_builder_23.append(body, "");
_builder_23.append("\t\tdataSeries.add(");
DatamartAxis _axis_31 = outer_axis.getAxis();
AxisEnum _name_38 = _axis_31.getName();
String _literal_23 = _name_38.getLiteral();
_builder_23.append(_literal_23, "");
_builder_23.append("TitlesArray.get(");
DatamartAxis _axis_32 = outer_axis.getAxis();
AxisEnum _name_39 = _axis_32.getName();
String _literal_24 = _name_39.getLiteral();
_builder_23.append(_literal_24, "");
_builder_23.append("No)+\" \"+");
DatamartAxis _axis_33 = inner_axis.getAxis();
AxisEnum _name_40 = _axis_33.getName();
String _literal_25 = _name_40.getLiteral();
_builder_23.append(_literal_25, "");
_builder_23.append("TitlesArray.get(");
DatamartAxis _axis_34 = inner_axis.getAxis();
AxisEnum _name_41 = _axis_34.getName();
String _literal_26 = _name_41.getLiteral();
_builder_23.append(_literal_26, "");
_builder_23.append("No),(value == null ? 0.0 : value));");
_builder_23.newLineIfNotEmpty();
body = _builder_23.toString();
} else {
StringConcatenation _builder_24 = new StringConcatenation();
_builder_24.append(body, "");
_builder_24.append("\t\t");
DatamartAxis _axis_35 = inner_axis.getAxis();
AxisEnum _name_42 = _axis_35.getName();
String _literal_27 = _name_42.getLiteral();
_builder_24.append(_literal_27, "");
_builder_24.append("DataSeries.add(value == null ? 0.0 : value);");
_builder_24.newLineIfNotEmpty();
body = _builder_24.toString();
}
StringConcatenation _builder_25 = new StringConcatenation();
_builder_25.append(body, "");
_builder_25.append("\t\t");
DatamartAxis _axis_36 = inner_axis.getAxis();
AxisEnum _name_43 = _axis_36.getName();
String _literal_28 = _name_43.getLiteral();
_builder_25.append(_literal_28, "");
_builder_25.append("No ++;");
_builder_25.newLineIfNotEmpty();
_builder_25.append("\t");
_builder_25.append("}");
_builder_25.newLine();
body = _builder_25.toString();
if (((!(chart.getCharttype() instanceof ChartPie)) && (!(chart.getCharttype() instanceof ChartDonut)))) {
ChartOption _charttype_15 = chart.getCharttype();
if ((_charttype_15 instanceof ChartBubble)) {
StringConcatenation _builder_26 = new StringConcatenation();
_builder_26.append(body, "");
_builder_26.append("\t");
DatamartAxis _axis_37 = inner_axis.getAxis();
AxisEnum _name_44 = _axis_37.getName();
String _literal_29 = _name_44.getLiteral();
_builder_26.append(_literal_29, "");
_builder_26.append("DataSeries.add(");
DatamartAxis _axis_38 = outer_axis.getAxis();
AxisEnum _name_45 = _axis_38.getName();
String _literal_30 = _name_45.getLiteral();
_builder_26.append(_literal_30, "");
_builder_26.append("TitlesArray.get(");
DatamartAxis _axis_39 = outer_axis.getAxis();
AxisEnum _name_46 = _axis_39.getName();
String _literal_31 = _name_46.getLiteral();
_builder_26.append(_literal_31, "");
_builder_26.append("No));");
_builder_26.newLineIfNotEmpty();
body = _builder_26.toString();
}
StringConcatenation _builder_27 = new StringConcatenation();
_builder_27.append(body, "");
_builder_27.append("\tdataSeries.add(");
DatamartAxis _axis_40 = inner_axis.getAxis();
AxisEnum _name_47 = _axis_40.getName();
String _literal_32 = _name_47.getLiteral();
_builder_27.append(_literal_32, "");
_builder_27.append("DataSeries.toArray());");
_builder_27.newLineIfNotEmpty();
body = _builder_27.toString();
}
StringConcatenation _builder_28 = new StringConcatenation();
_builder_28.append(body, "");
_builder_28.append("\t");
DatamartAxis _axis_41 = outer_axis.getAxis();
AxisEnum _name_48 = _axis_41.getName();
String _literal_33 = _name_48.getLiteral();
_builder_28.append(_literal_33, "");
_builder_28.append("No ++;");
_builder_28.newLineIfNotEmpty();
_builder_28.append("}");
_builder_28.newLine();
body = _builder_28.toString();
StringConcatenation _builder_29 = new StringConcatenation();
_builder_29.append(body, "");
_builder_29.append("SeriesDefaults seriesDefaults = new SeriesDefaults()");
_builder_29.newLineIfNotEmpty();
_builder_29.append("\t");
_builder_29.append(".setRenderer(SeriesRenderers.");
_builder_29.append(chartType, "\t");
_builder_29.append(");");
_builder_29.newLineIfNotEmpty();
body = _builder_29.toString();
ChartOption _charttype_16 = chart.getCharttype();
if ((_charttype_16 instanceof ChartLine)) {
StringConcatenation _builder_30 = new StringConcatenation();
_builder_30.append(body, "");
_builder_30.append("seriesDefaults.setFillToZero(");
ChartOption _charttype_17 = chart.getCharttype();
boolean _isFillToZero = ((ChartLine) _charttype_17).isFillToZero();
boolean _booleanValue_1 = Boolean.valueOf(_isFillToZero).booleanValue();
String _string = Boolean.valueOf(_booleanValue_1).toString();
_builder_30.append(_string, "");
_builder_30.append(").setFill(");
ChartOption _charttype_18 = chart.getCharttype();
boolean _isFillArea = ((ChartLine) _charttype_18).isFillArea();
String _string_1 = Boolean.valueOf(_isFillArea).toString();
_builder_30.append(_string_1, "");
_builder_30.append(");");
_builder_30.newLineIfNotEmpty();
body = _builder_30.toString();
ChartOption _charttype_19 = chart.getCharttype();
boolean _isTrendLine = ((ChartLine) _charttype_19).isTrendLine();
if (_isTrendLine) {
StringConcatenation _builder_31 = new StringConcatenation();
_builder_31.append(body, "");
_builder_31.append("seriesDefaults.setTrendline(");
_builder_31.newLineIfNotEmpty();
_builder_31.append("\t");
_builder_31.append("new Trendline().setShow(true).setLineWidth(1));");
_builder_31.newLine();
body = _builder_31.toString();
}
}
StringConcatenation _builder_32 = new StringConcatenation();
_builder_32.append(body, "");
_builder_32.append("Options options = new Options()");
_builder_32.newLineIfNotEmpty();
_builder_32.append("\t");
_builder_32.append(".setSeriesDefaults(seriesDefaults);");
_builder_32.newLine();
body = _builder_32.toString();
ChartOption _charttype_20 = chart.getCharttype();
if ((_charttype_20 instanceof ChartPie)) {
StringConcatenation _builder_33 = new StringConcatenation();
_builder_33.append(body, "");
_builder_33.append("seriesDefaults.setRendererOptions(new PieRenderer()");
_builder_33.newLineIfNotEmpty();
_builder_33.append("\t");
_builder_33.append(".setShowDataLabels(true).setFill(");
ChartOption _charttype_21 = chart.getCharttype();
boolean _isEmpty = ((ChartPie) _charttype_21).isEmpty();
boolean _not = (!_isEmpty);
String _string_2 = Boolean.valueOf(_not).toString();
_builder_33.append(_string_2, "\t");
_builder_33.append("));");
_builder_33.newLineIfNotEmpty();
body = _builder_33.toString();
} else {
ChartOption _charttype_22 = chart.getCharttype();
if ((_charttype_22 instanceof ChartDonut)) {
StringConcatenation _builder_34 = new StringConcatenation();
_builder_34.append(body, "");
_builder_34.append("seriesDefaults.setRendererOptions(new DonutRenderer()");
_builder_34.newLineIfNotEmpty();
_builder_34.append("\t");
_builder_34.append(".setShowDataLabels(true)");
_builder_34.newLine();
_builder_34.append("\t");
_builder_34.append(".setStartAngle(-90)");
_builder_34.newLine();
_builder_34.append("\t");
_builder_34.append(".setSliceMargin(3));");
_builder_34.newLine();
body = _builder_34.toString();
} else {
ChartOption _charttype_23 = chart.getCharttype();
if ((_charttype_23 instanceof ChartBubble)) {
StringConcatenation _builder_35 = new StringConcatenation();
_builder_35.append(body, "");
_builder_35.append("seriesDefaults.setRendererOptions(new BubbleRenderer()");
_builder_35.newLineIfNotEmpty();
_builder_35.append("\t");
_builder_35.append(".setVaryBubbleColors(true)");
_builder_35.newLine();
_builder_35.append("\t");
{
ChartOption _charttype_24 = chart.getCharttype();
boolean _isMultiplier = ((ChartBubble) _charttype_24).isMultiplier();
if (_isMultiplier) {
_builder_35.append(".setAutoscaleMultiplier(");
ChartOption _charttype_25 = chart.getCharttype();
String _multiplierValue = ((ChartBubble) _charttype_25).getMultiplierValue();
_builder_35.append(_multiplierValue, "\t");
_builder_35.append("f)");
}
}
_builder_35.newLineIfNotEmpty();
_builder_35.append(" ");
{
ChartOption _charttype_26 = chart.getCharttype();
boolean _isTransparent = ((ChartBubble) _charttype_26).isTransparent();
if (_isTransparent) {
_builder_35.append(".setHighlightAlpha(0.8f).setBubbleAlpha(0.6f)");
}
}
_builder_35.newLineIfNotEmpty();
_builder_35.append("\t");
{
ChartOption _charttype_27 = chart.getCharttype();
boolean _isGradient = ((ChartBubble) _charttype_27).isGradient();
if (_isGradient) {
_builder_35.append(".setBubbleGradients(true)");
}
}
_builder_35.newLineIfNotEmpty();
_builder_35.append("\t");
_builder_35.append(".setShowLabels(false)");
_builder_35.newLine();
_builder_35.append("\t");
_builder_35.append(".setAutoscaleBubbles(true));");
_builder_35.newLine();
body = _builder_35.toString();
} else {
ChartOption _charttype_28 = chart.getCharttype();
if ((_charttype_28 instanceof ChartGauge)) {
String intervalValues = "";
String intervalColors = "";
ChartOption _charttype_29 = chart.getCharttype();
boolean _isHasIntervals = ((ChartGauge) _charttype_29).isHasIntervals();
if (_isHasIntervals) {
ChartOption _charttype_30 = chart.getCharttype();
EList<ChartInterval> _intervals = ((ChartGauge) _charttype_30).getIntervals();
for (final ChartInterval interval : _intervals) {
if ((interval instanceof ChartNumberInterval)) {
StringConcatenation _builder_36 = new StringConcatenation();
_builder_36.append(intervalValues, "");
{
int _length = intervalValues.length();
boolean _greaterThan = (_length > 0);
if (_greaterThan) {
_builder_36.append(",");
}
}
int _numberIntervalValue = ((ChartNumberInterval) interval).getNumberIntervalValue();
_builder_36.append(_numberIntervalValue, "");
_builder_36.append("f");
intervalValues = _builder_36.toString();
ChartRangeElement _numberRange = ((ChartNumberInterval) interval).getNumberRange();
if ((_numberRange instanceof ChartSegmentColor)) {
StringConcatenation _builder_37 = new StringConcatenation();
_builder_37.append(intervalColors, "");
{
int _length_1 = intervalColors.length();
boolean _greaterThan_1 = (_length_1 > 0);
if (_greaterThan_1) {
_builder_37.append(",");
}
}
_builder_37.append("\"");
ChartRangeElement _numberRange_1 = ((ChartNumberInterval) interval).getNumberRange();
String _rgb = ((ChartSegmentColor) _numberRange_1).getRgb();
String _hex = this.toHex(_rgb);
_builder_37.append(_hex, "");
_builder_37.append("\"");
intervalColors = _builder_37.toString();
}
}
}
}
StringConcatenation _builder_38 = new StringConcatenation();
_builder_38.append(body, "");
_builder_38.append("seriesDefaults.setRendererOptions(new MeterGaugeRenderer()");
_builder_38.newLineIfNotEmpty();
_builder_38.append("\t");
_builder_38.append(".setShowTickLabels(");
ChartOption _charttype_31 = chart.getCharttype();
boolean _isHasTicks = ((ChartGauge) _charttype_31).isHasTicks();
String _string_3 = Boolean.valueOf(_isHasTicks).toString();
_builder_38.append(_string_3, "\t");
_builder_38.append(")");
_builder_38.newLineIfNotEmpty();
_builder_38.append("\t");
{
ChartOption _charttype_32 = chart.getCharttype();
boolean _isLabeled = ((ChartGauge) _charttype_32).isLabeled();
if (_isLabeled) {
_builder_38.append(".setLabel(\"");
ChartOption _charttype_33 = chart.getCharttype();
String _labelValue = ((ChartGauge) _charttype_33).getLabelValue();
_builder_38.append(_labelValue, "\t");
_builder_38.append("\")");
}
}
_builder_38.newLineIfNotEmpty();
_builder_38.append("\t");
{
ChartOption _charttype_34 = chart.getCharttype();
boolean _isHasIntervals_1 = ((ChartGauge) _charttype_34).isHasIntervals();
if (_isHasIntervals_1) {
_builder_38.append(".setIntervals(");
_builder_38.append(intervalValues, "\t");
_builder_38.append(")");
}
}
_builder_38.newLineIfNotEmpty();
_builder_38.append("\t");
{
ChartOption _charttype_35 = chart.getCharttype();
boolean _isHasIntervals_2 = ((ChartGauge) _charttype_35).isHasIntervals();
if (_isHasIntervals_2) {
_builder_38.append(".setIntervalColors(");
_builder_38.append(intervalColors, "\t");
_builder_38.append(")");
}
}
_builder_38.append(");");
_builder_38.newLineIfNotEmpty();
body = _builder_38.toString();
} else {
ChartOption _charttype_36 = chart.getCharttype();
if ((_charttype_36 instanceof ChartBar)) {
StringConcatenation _builder_39 = new StringConcatenation();
_builder_39.append(body, "");
_builder_39.append("seriesDefaults.setFillToZero(true);");
_builder_39.newLineIfNotEmpty();
_builder_39.append("seriesDefaults.setRendererOptions(new BarRenderer()");
_builder_39.newLine();
_builder_39.append(" ");
{
if (axisSwitch) {
_builder_39.append(".setBarDirection(BarDirections.HOTIZONTAL));");
} else {
_builder_39.append(".setBarDirection(BarDirections.VERTICAL));");
}
}
_builder_39.newLineIfNotEmpty();
body = _builder_39.toString();
ChartOption _charttype_37 = chart.getCharttype();
boolean _isStacked = ((ChartBar) _charttype_37).isStacked();
if (_isStacked) {
StringConcatenation _builder_40 = new StringConcatenation();
_builder_40.append(body, "");
_builder_40.append("options.setStackSeries(true);");
_builder_40.newLineIfNotEmpty();
body = _builder_40.toString();
}
ChartOption _charttype_38 = chart.getCharttype();
boolean _isShadow = ((ChartBar) _charttype_38).isShadow();
if (_isShadow) {
StringConcatenation _builder_41 = new StringConcatenation();
_builder_41.append(body, "");
_builder_41.append("seriesDefaults.setShadow(true).setShadowAlpha(0.05f);");
_builder_41.newLineIfNotEmpty();
body = _builder_41.toString();
}
ChartOption _charttype_39 = chart.getCharttype();
boolean _isAnimated = ((ChartBar) _charttype_39).isAnimated();
if (_isAnimated) {
StringConcatenation _builder_42 = new StringConcatenation();
_builder_42.append(body, "");
_builder_42.append("options.setAnimate(true);");
_builder_42.newLineIfNotEmpty();
body = _builder_42.toString();
}
}
}
}
}
}
StringConcatenation _builder_43 = new StringConcatenation();
_builder_43.append(body, "");
_builder_43.newLineIfNotEmpty();
_builder_43.append("String[] seriesColors = {\"#98E958\",\"#3090F0\",\"#EC6464\",\"#F9DD51\",\"#24DCD4\",\"#EC64A5\",\"#685CB0\",\"#FF7D42\",\"#AA514D\",\"#7FB053\",\"#BBA85B\",\"#247981\"};");
_builder_43.newLine();
_builder_43.append("options.setSeriesColors(seriesColors);");
_builder_43.newLine();
body = _builder_43.toString();
if (hasAxis) {
StringConcatenation _builder_44 = new StringConcatenation();
_builder_44.append(body, "");
_builder_44.append("Axes axes = new Axes();");
_builder_44.newLineIfNotEmpty();
body = _builder_44.toString();
ChartOption _charttype_40 = chart.getCharttype();
if ((_charttype_40 instanceof ChartBubble)) {
StringConcatenation _builder_45 = new StringConcatenation();
_builder_45.append(body, "");
_builder_45.append("CanvasAxisTickRenderer axisTickRenderer = new CanvasAxisTickRenderer();");
_builder_45.newLineIfNotEmpty();
_builder_45.append("axisTickRenderer.setTextColor(\"#202020\");");
_builder_45.newLine();
_builder_45.append("if (");
DatamartAxis _axis_42 = data_axis.getAxis();
AxisEnum _name_49 = _axis_42.getName();
String _literal_34 = _name_49.getLiteral();
_builder_45.append(_literal_34, "");
_builder_45.append("TitlesArray.size() > 0) {");
_builder_45.newLineIfNotEmpty();
_builder_45.append("\t");
_builder_45.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt = axisPrefix.charAt(0);
_builder_45.append(_charAt, "\t");
_builder_45.append(").setLabel(");
DatamartAxis _axis_43 = data_axis.getAxis();
AxisEnum _name_50 = _axis_43.getName();
String _literal_35 = _name_50.getLiteral();
_builder_45.append(_literal_35, "\t");
_builder_45.append("TitlesArray.get(0)).setTickOptions(axisTickRenderer");
{
int _angle = category_axis.getAngle();
boolean _notEquals = (_angle != 0);
if (_notEquals) {
_builder_45.append(".setAngle(");
int _angle_1 = data_axis.getAngle();
_builder_45.append(_angle_1, "\t");
_builder_45.append(")");
}
}
_builder_45.append("));");
_builder_45.newLineIfNotEmpty();
_builder_45.append("\t");
_builder_45.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_1 = axisPrefix.charAt(1);
_builder_45.append(_charAt_1, "\t");
_builder_45.append(").setLabel(");
DatamartAxis _axis_44 = data_axis.getAxis();
AxisEnum _name_51 = _axis_44.getName();
String _literal_36 = _name_51.getLiteral();
_builder_45.append(_literal_36, "\t");
_builder_45.append("TitlesArray.get(1)).setTickOptions(axisTickRenderer");
{
int _angle_2 = category_axis.getAngle();
boolean _notEquals_1 = (_angle_2 != 0);
if (_notEquals_1) {
_builder_45.append(".setAngle(");
int _angle_3 = data_axis.getAngle();
_builder_45.append(_angle_3, "\t");
_builder_45.append(")");
}
}
_builder_45.append("));");
_builder_45.newLineIfNotEmpty();
_builder_45.append("\t");
_builder_45.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_2 = axisPrefix.charAt(1);
_builder_45.append(_charAt_2, "\t");
_builder_45.append("2).setLabel(");
DatamartAxis _axis_45 = data_axis.getAxis();
AxisEnum _name_52 = _axis_45.getName();
String _literal_37 = _name_52.getLiteral();
_builder_45.append(_literal_37, "\t");
_builder_45.append("TitlesArray.get(2)).setTickOptions(axisTickRenderer");
{
int _angle_4 = category_axis.getAngle();
boolean _notEquals_2 = (_angle_4 != 0);
if (_notEquals_2) {
_builder_45.append(".setAngle(");
int _angle_5 = data_axis.getAngle();
_builder_45.append(_angle_5, "\t");
_builder_45.append(")");
}
}
_builder_45.append("));");
_builder_45.newLineIfNotEmpty();
_builder_45.append("}");
_builder_45.newLine();
body = _builder_45.toString();
} else {
StringConcatenation _builder_46 = new StringConcatenation();
_builder_46.append(body, "");
_builder_46.append("CanvasAxisTickRenderer tickRenderer = new CanvasAxisTickRenderer();");
_builder_46.newLineIfNotEmpty();
_builder_46.append("tickRenderer.setTextColor(\"#202020\");");
_builder_46.newLine();
_builder_46.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_3 = axisPrefix.charAt(0);
_builder_46.append(_charAt_3, "");
_builder_46.append(")");
_builder_46.newLineIfNotEmpty();
_builder_46.append("\t");
_builder_46.append(".setRenderer(AxisRenderers.");
RenderTypeEnum _renderType_5 = category_axis.getRenderType();
String _name_53 = _renderType_5.name();
String _string_4 = _name_53.toString();
_builder_46.append(_string_4, "\t");
_builder_46.append(")");
_builder_46.newLineIfNotEmpty();
_builder_46.append("\t");
_builder_46.append(".setLabel(");
DatamartAxis _axis_46 = category_axis.getAxis();
AxisEnum _name_54 = _axis_46.getName();
String _literal_38 = _name_54.getLiteral();
_builder_46.append(_literal_38, "\t");
_builder_46.append("AxisLabel)");
_builder_46.newLineIfNotEmpty();
_builder_46.append("\t");
_builder_46.append(".setTicks(");
DatamartAxis _axis_47 = category_axis.getAxis();
AxisEnum _name_55 = _axis_47.getName();
String _literal_39 = _name_55.getLiteral();
_builder_46.append(_literal_39, "\t");
_builder_46.append("Ticks)");
_builder_46.newLineIfNotEmpty();
_builder_46.append("\t");
_builder_46.append(".setTickOptions(tickRenderer");
{
int _angle_6 = category_axis.getAngle();
boolean _notEquals_3 = (_angle_6 != 0);
if (_notEquals_3) {
_builder_46.append(".setAngle(");
int _angle_7 = category_axis.getAngle();
_builder_46.append(_angle_7, "\t");
_builder_46.append(")");
}
}
_builder_46.append("));");
_builder_46.newLineIfNotEmpty();
body = _builder_46.toString();
StringConcatenation _builder_47 = new StringConcatenation();
_builder_47.append(body, "");
_builder_47.append("CanvasAxisTickRenderer axisTickRenderer = new CanvasAxisTickRenderer();");
_builder_47.newLineIfNotEmpty();
_builder_47.append("axisTickRenderer.setTextColor(\"#202020\");");
_builder_47.newLine();
_builder_47.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_4 = axisPrefix.charAt(1);
_builder_47.append(_charAt_4, "");
_builder_47.append(")");
_builder_47.newLineIfNotEmpty();
_builder_47.append("\t");
_builder_47.append(".setPad(1.05f)");
_builder_47.newLine();
_builder_47.append("\t");
_builder_47.append(".setTickOptions(axisTickRenderer");
{
int _angle_8 = data_axis.getAngle();
boolean _notEquals_4 = (_angle_8 != 0);
if (_notEquals_4) {
_builder_47.append(".setAngle(");
int _angle_9 = data_axis.getAngle();
_builder_47.append(_angle_9, "\t");
_builder_47.append(")");
}
}
_builder_47.append("));");
_builder_47.newLineIfNotEmpty();
body = _builder_47.toString();
Set<String> _keySet = multipleAxes.keySet();
for (final String axisKey : _keySet) {
boolean _equals_7 = axisKey.equals("1");
boolean _not_1 = (!_equals_7);
if (_not_1) {
StringConcatenation _builder_48 = new StringConcatenation();
_builder_48.append(body, "");
String _get = multipleAxes.get(axisKey);
_builder_48.append(_get, "");
body = _builder_48.toString();
}
}
Set<String> _keySet_1 = multipleAxes.keySet();
int _size = _keySet_1.size();
boolean _greaterThan_2 = (_size > 0);
if (_greaterThan_2) {
StringConcatenation _builder_49 = new StringConcatenation();
_builder_49.append(body, "");
_builder_49.append("LinearAxisRenderer linearAxisRenderer = new LinearAxisRenderer();");
_builder_49.newLineIfNotEmpty();
_builder_49.append("linearAxisRenderer.setAlignTicks(true);");
_builder_49.newLine();
_builder_49.append("AxesDefaults axesDefaults = new AxesDefaults()");
_builder_49.newLine();
_builder_49.append("\t");
_builder_49.append(".setUseSeriesColor(true)");
_builder_49.newLine();
_builder_49.append("\t");
_builder_49.append(".setBorderWidth(3)\t");
_builder_49.newLine();
_builder_49.append("\t");
_builder_49.append(".setRendererOptions(linearAxisRenderer);");
_builder_49.newLine();
_builder_49.append("options.setAxesDefaults(axesDefaults);");
_builder_49.newLine();
body = _builder_49.toString();
}
}
StringConcatenation _builder_50 = new StringConcatenation();
_builder_50.append(body, "");
_builder_50.append("options.setAxes(axes);");
_builder_50.newLineIfNotEmpty();
body = _builder_50.toString();
}
ChartDatamart _source_1 = chart.getSource();
EList<ChartElement> _elements_1 = _source_1.getElements();
for (final ChartElement element_1 : _elements_1) {
if ((element_1 instanceof ChartLegend)) {
ChartLegend legend = ((ChartLegend) element_1);
StringConcatenation _builder_51 = new StringConcatenation();
_builder_51.append(body, "");
_builder_51.append("Legend legend = new Legend().setShow(");
boolean _notEquals_5 = (!Objects.equal(legend, null));
boolean _booleanValue_2 = Boolean.valueOf(_notEquals_5).booleanValue();
String _string_5 = Boolean.valueOf(_booleanValue_2).toString();
_builder_51.append(_string_5, "");
_builder_51.append(");");
_builder_51.newLineIfNotEmpty();
body = _builder_51.toString();
StringConcatenation _builder_52 = new StringConcatenation();
_builder_52.append(body, "");
_builder_52.append("legend.setPlacement(LegendPlacements.");
LegendPlacementEnum _placement = legend.getPlacement();
String _name_56 = _placement.name();
_builder_52.append(_name_56, "");
_builder_52.append(");");
_builder_52.newLineIfNotEmpty();
body = _builder_52.toString();
boolean _isToggle = legend.isToggle();
if (_isToggle) {
StringConcatenation _builder_53 = new StringConcatenation();
_builder_53.append(body, "");
_builder_53.append("EnhancedLegendRenderer renderer = new EnhancedLegendRenderer();");
_builder_53.newLineIfNotEmpty();
_builder_53.append("renderer.setSeriesToggle(SeriesToggles.");
ToggleTypeEnum _toggleType = legend.getToggleType();
String _name_57 = _toggleType.getName();
_builder_53.append(_name_57, "");
_builder_53.append(");");
_builder_53.newLineIfNotEmpty();
_builder_53.append("renderer.setSeriesToggleReplot(");
boolean _isReplot = legend.isReplot();
boolean _booleanValue_3 = Boolean.valueOf(_isReplot).booleanValue();
String _string_6 = Boolean.valueOf(_booleanValue_3).toString();
_builder_53.append(_string_6, "");
_builder_53.append(");");
_builder_53.newLineIfNotEmpty();
_builder_53.append("legend.setRendererOptions(renderer);");
_builder_53.newLine();
body = _builder_53.toString();
}
StringConcatenation _builder_54 = new StringConcatenation();
_builder_54.append(body, "");
_builder_54.append("options.setLegend(legend);");
_builder_54.newLineIfNotEmpty();
body = _builder_54.toString();
}
}
ChartDatamart _source_2 = chart.getSource();
EList<ChartElement> _elements_2 = _source_2.getElements();
for (final ChartElement element_2 : _elements_2) {
if ((element_2 instanceof ChartHighlighter)) {
ChartHighlighter highlighter = ((ChartHighlighter) element_2);
StringConcatenation _builder_55 = new StringConcatenation();
_builder_55.append(body, "");
_builder_55.append("Highlighter highlighter = new Highlighter().setShow(");
boolean _notEquals_6 = (!Objects.equal(highlighter, null));
boolean _booleanValue_4 = Boolean.valueOf(_notEquals_6).booleanValue();
String _string_7 = Boolean.valueOf(_booleanValue_4).toString();
_builder_55.append(_string_7, "");
_builder_55.append(");");
_builder_55.newLineIfNotEmpty();
body = _builder_55.toString();
StringConcatenation _builder_56 = new StringConcatenation();
_builder_56.append(body, "");
_builder_56.append("highlighter.setShowTooltip(true)");
_builder_56.newLineIfNotEmpty();
_builder_56.append(".setTooltipAlwaysVisible(");
boolean _isTooltipAlways = highlighter.isTooltipAlways();
boolean _booleanValue_5 = Boolean.valueOf(_isTooltipAlways).booleanValue();
String _string_8 = Boolean.valueOf(_booleanValue_5).toString();
_builder_56.append(_string_8, "");
_builder_56.append(")");
_builder_56.newLineIfNotEmpty();
_builder_56.append(".setKeepTooltipInsideChart(");
boolean _isInsideChart = highlighter.isInsideChart();
boolean _booleanValue_6 = Boolean.valueOf(_isInsideChart).booleanValue();
String _string_9 = Boolean.valueOf(_booleanValue_6).toString();
_builder_56.append(_string_9, "");
_builder_56.append(")");
_builder_56.newLineIfNotEmpty();
_builder_56.append(".setTooltipLocation(TooltipLocations.");
TooltipLocationEnum _location = highlighter.getLocation();
String _name_58 = _location.name();
_builder_56.append(_name_58, "");
_builder_56.append(")");
_builder_56.newLineIfNotEmpty();
_builder_56.append(".setBringSeriesToFront(true)");
_builder_56.newLine();
_builder_56.append(".setFadeTooltip(true)");
_builder_56.newLine();
_builder_56.append(".setShowMarker(true);");
_builder_56.newLine();
body = _builder_56.toString();
StringConcatenation _builder_57 = new StringConcatenation();
_builder_57.append(body, "");
_builder_57.append("highlighter.setTooltipAxes(TooltipAxes.");
_builder_57.append(axisPrefix, "");
_builder_57.append(postfix, "");
_builder_57.append(");");
_builder_57.newLineIfNotEmpty();
body = _builder_57.toString();
StringConcatenation _builder_58 = new StringConcatenation();
_builder_58.append(body, "");
_builder_58.append("options.setHighlighter(highlighter);");
_builder_58.newLineIfNotEmpty();
body = _builder_58.toString();
}
}
ChartOption _charttype_41 = chart.getCharttype();
if ((_charttype_41 instanceof ChartLine)) {
ChartOption _charttype_42 = chart.getCharttype();
boolean _isCursor = ((ChartLine) _charttype_42).isCursor();
if (_isCursor) {
StringConcatenation _builder_59 = new StringConcatenation();
_builder_59.append(body, "");
_builder_59.append("Cursor cursor = new Cursor()");
_builder_59.newLineIfNotEmpty();
_builder_59.append("\t");
_builder_59.append(".setShow(true)");
_builder_59.newLine();
_builder_59.append("\t");
_builder_59.append(".setZoom(");
ChartOption _charttype_43 = chart.getCharttype();
boolean _isZoom = ((ChartLine) _charttype_43).isZoom();
String _string_10 = Boolean.valueOf(_isZoom).toString();
_builder_59.append(_string_10, "\t");
_builder_59.append(")");
_builder_59.newLineIfNotEmpty();
_builder_59.append("\t");
_builder_59.append(".setShowTooltip(");
ChartOption _charttype_44 = chart.getCharttype();
boolean _isTooltip = ((ChartLine) _charttype_44).isTooltip();
String _string_11 = Boolean.valueOf(_isTooltip).toString();
_builder_59.append(_string_11, "\t");
_builder_59.append(");");
_builder_59.newLineIfNotEmpty();
_builder_59.append("options.setCursor(cursor);");
_builder_59.newLine();
body = _builder_59.toString();
}
ChartOption _charttype_45 = chart.getCharttype();
boolean _isAnimated_1 = ((ChartLine) _charttype_45).isAnimated();
if (_isAnimated_1) {
StringConcatenation _builder_60 = new StringConcatenation();
_builder_60.append(body, "");
_builder_60.append("options.setAnimate(true);");
_builder_60.newLineIfNotEmpty();
body = _builder_60.toString();
}
}
if (hasAxis) {
StringConcatenation _builder_61 = new StringConcatenation();
_builder_61.append(body, "");
_builder_61.append("options.setSeries(");
DatamartAxis _axis_48 = data_axis.getAxis();
AxisEnum _name_59 = _axis_48.getName();
String _literal_40 = _name_59.getLiteral();
_builder_61.append(_literal_40, "");
_builder_61.append("Series);");
_builder_61.newLineIfNotEmpty();
body = _builder_61.toString();
}
StringConcatenation _builder_62 = new StringConcatenation();
_builder_62.append(body, "");
_builder_62.append("DCharts chart = new DCharts()");
_builder_62.newLineIfNotEmpty();
_builder_62.append("\t");
_builder_62.append(".setDataSeries(dataSeries)");
_builder_62.newLine();
_builder_62.append("\t");
_builder_62.append(".setOptions(options)");
_builder_62.newLine();
_builder_62.append("\t");
_builder_62.append(".setEnableDownload(true)");
_builder_62.newLine();
_builder_62.append("\t");
_builder_62.append(".setDownloadButtonCaption(dslMetadataService.translate(locale.toLanguageTag(), \"download\"))");
_builder_62.newLine();
_builder_62.append("\t");
_builder_62.append(".setDownloadFilename(\"");
String _name_60 = chart.getName();
_builder_62.append(_name_60, "\t");
_builder_62.append("\")");
_builder_62.newLineIfNotEmpty();
_builder_62.append("\t");
_builder_62.append(".setDownloadButtonLocation(DownloadButtonLocation.TOP_RIGHT);");
_builder_62.newLine();
body = _builder_62.toString();
StringConcatenation _builder_63 = new StringConcatenation();
_builder_63.append(body, "");
_builder_63.append("chart.setId(\"chart\");");
_builder_63.newLineIfNotEmpty();
_builder_63.append("chart.setImmediate(true);");
_builder_63.newLine();
_builder_63.append("if(chartRefresherDone) {");
_builder_63.newLine();
_builder_63.append("\t");
_builder_63.append("chart.show();");
_builder_63.newLine();
_builder_63.append("}");
_builder_63.newLine();
_builder_63.append("charts.add(chart);");
_builder_63.newLine();
_builder_63.append("return chart;");
body = _builder_63.toString();
return body;
}
/**
* <p>helper method to convert a rgb string to a hex string.</p>
*/
public String toHex(final String rgb) {
String colorHex = "#";
String[] _split = rgb.split(",");
for (final String color : _split) {
{
Integer i = new Integer(color);
StringConcatenation _builder = new StringConcatenation();
_builder.append(colorHex, "");
String _format = String.format("%02x", i);
_builder.append(_format, "");
colorHex = _builder.toString();
}
}
return colorHex;
}
/**
* <p>build the label series. Create multiple y-axes when the underlying datamart presents different scales.</p>
*
* <p>scales are used to display line charts together for comparison reason but they are of different scalings.</p>
*/
public String createLabelSeries(final Chart chart, final ChartAxis data_axis, final HashMap<String, String> multipleAxes, final String axisPrefix, final boolean showMarker) {
String body = "";
int msrCnt = 0;
ChartDatamart _source = chart.getSource();
DatamartDefinition _datamartRef = ((ChartDatamart) _source).getDatamartRef();
DatamartSource _source_1 = _datamartRef.getSource();
if ((_source_1 instanceof DatamartCube)) {
ChartDatamart _source_2 = chart.getSource();
DatamartDefinition _datamartRef_1 = ((ChartDatamart) _source_2).getDatamartRef();
DatamartSource _source_3 = _datamartRef_1.getSource();
EList<DatamartCubeElement> _axisslicer = ((DatamartCube) _source_3).getAxisslicer();
for (final DatamartCubeElement axisOrSlicer : _axisslicer) {
if ((axisOrSlicer instanceof DatamartAxis)) {
EList<DatamartElement> _elements = ((DatamartAxis) axisOrSlicer).getElements();
for (final DatamartElement element : _elements) {
{
if ((element instanceof DatamartDerivedMeasure)) {
boolean _isScaled = ((DatamartDerivedMeasure) element).isScaled();
if (_isScaled) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
ValueScaleEnum _scale = ((DatamartDerivedMeasure) element).getScale();
String _createScale = this.createScale(_scale, data_axis, multipleAxes, msrCnt, axisPrefix, showMarker);
_builder.append(_createScale, "");
body = _builder.toString();
msrCnt = (msrCnt + 1);
}
}
if ((element instanceof DatamartMeasure)) {
boolean _isScaled_1 = ((DatamartMeasure) element).isScaled();
if (_isScaled_1) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
ValueScaleEnum _scale_1 = ((DatamartMeasure) element).getScale();
String _createScale_1 = this.createScale(_scale_1, data_axis, multipleAxes, msrCnt, axisPrefix, showMarker);
_builder_1.append(_createScale_1, "");
body = _builder_1.toString();
msrCnt = (msrCnt + 1);
}
}
}
}
}
}
} else {
ChartDatamart _source_4 = chart.getSource();
DatamartDefinition _datamartRef_2 = ((ChartDatamart) _source_4).getDatamartRef();
DatamartSource _source_5 = _datamartRef_2.getSource();
if ((_source_5 instanceof DatamartEntity)) {
ChartDatamart _source_6 = chart.getSource();
DatamartDefinition _datamartRef_3 = ((ChartDatamart) _source_6).getDatamartRef();
DatamartSource _source_7 = _datamartRef_3.getSource();
DatamartEntity entity = ((DatamartEntity) _source_7);
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
String _entityScale = this.entityScale(entity, data_axis, multipleAxes, msrCnt, axisPrefix, showMarker);
_builder.append(_entityScale, "");
body = _builder.toString();
}
}
Set<String> _keySet = multipleAxes.keySet();
int _size = _keySet.size();
boolean _equals = (_size == 0);
if (_equals) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.append("\tfor (String title : ");
DatamartAxis _axis = data_axis.getAxis();
AxisEnum _name = _axis.getName();
String _literal = _name.getLiteral();
_builder_1.append(_literal, "");
_builder_1.append("TitlesArray) {");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
DatamartAxis _axis_1 = data_axis.getAxis();
AxisEnum _name_1 = _axis_1.getName();
String _literal_1 = _name_1.getLiteral();
_builder_1.append(_literal_1, "\t\t");
_builder_1.append("Series.addSeries(new XYseries().setLabel(title).setShowMarker(");
String _string = Boolean.valueOf(showMarker).toString();
_builder_1.append(_string, "\t\t");
_builder_1.append("));");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
body = _builder_1.toString();
}
return body;
}
/**
* <p>helper method for scales coming from datamart entities not from cubes.</p>
*/
public String entityScale(final DatamartEntity entity, final ChartAxis data_axis, final HashMap<String, String> multipleAxes, final int msrCnt, final String axisPrefix, final boolean showMarker) {
int counter = msrCnt;
String body = "";
EList<DatamartProperty> _properties = entity.getProperties();
for (final DatamartProperty property : _properties) {
if ((property instanceof DatamartProperty)) {
boolean _isScaled = property.isScaled();
if (_isScaled) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
ValueScaleEnum _scale = property.getScale();
String _createScale = this.createScale(_scale, data_axis, multipleAxes, counter, axisPrefix, showMarker);
_builder.append(_createScale, "");
body = _builder.toString();
counter = (counter + 1);
}
}
}
EList<DatamartNavigation> _navigations = entity.getNavigations();
for (final DatamartNavigation navigation : _navigations) {
{
if ((navigation instanceof DatamartMember)) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
DatamartEntity _datamartEntity = ((DatamartMember) navigation).getDatamartEntity();
String _entityScale = this.entityScale(_datamartEntity, data_axis, multipleAxes, counter, axisPrefix, showMarker);
_builder_1.append(_entityScale, "");
body = _builder_1.toString();
}
if ((navigation instanceof DatamartOwner)) {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body, "");
DatamartEntity _datamartEntity_1 = ((DatamartOwner) navigation).getDatamartEntity();
String _entityScale_1 = this.entityScale(_datamartEntity_1, data_axis, multipleAxes, counter, axisPrefix, showMarker);
_builder_2.append(_entityScale_1, "");
body = _builder_2.toString();
}
}
}
return body;
}
/**
* <p>helper method for scales.</p>
*/
public String createScale(final ValueScaleEnum scale, final ChartAxis data_axis, final HashMap<String, String> multipleAxes, final int msrCnt, final String axisPrefix, final boolean showMarker) {
String multipleBody = "";
String body = "";
int scaleOrdinal = scale.ordinal();
String scaleName = scale.toString();
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
_builder.newLineIfNotEmpty();
_builder.append("\t");
DatamartAxis _axis = data_axis.getAxis();
AxisEnum _name = _axis.getName();
String _literal = _name.getLiteral();
_builder.append(_literal, "\t");
_builder.append("Series.addSeries(new XYseries(");
char _charAt = axisPrefix.charAt(1);
_builder.append(_charAt, "\t");
_builder.append("axes.");
char _charAt_1 = axisPrefix.charAt(1);
_builder.append(_charAt_1, "\t");
{
if ((scaleOrdinal != 0)) {
_builder.append((scaleOrdinal + 1), "\t");
}
}
_builder.append(").setLabel(");
DatamartAxis _axis_1 = data_axis.getAxis();
AxisEnum _name_1 = _axis_1.getName();
String _literal_1 = _name_1.getLiteral();
_builder.append(_literal_1, "\t");
_builder.append("TitlesArray.get(");
_builder.append(msrCnt, "\t");
_builder.append(")).setShowMarker(");
String _string = Boolean.valueOf(showMarker).toString();
_builder.append(_string, "\t");
_builder.append("));");
_builder.newLineIfNotEmpty();
body = _builder.toString();
Set<String> _keySet = multipleAxes.keySet();
boolean _contains = _keySet.contains(scaleName);
boolean _not = (!_contains);
if (_not) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_2 = axisPrefix.charAt(1);
_builder_1.append(_charAt_2, "");
{
if ((scaleOrdinal != 0)) {
_builder_1.append((scaleOrdinal + 1), "");
}
}
_builder_1.append(").setTickOptions(axisTickRenderer");
{
int _angle = data_axis.getAngle();
boolean _notEquals = (_angle != 0);
if (_notEquals) {
_builder_1.append(".setAngle(");
int _angle_1 = data_axis.getAngle();
_builder_1.append(_angle_1, "");
_builder_1.append(")");
}
}
_builder_1.append("));");
_builder_1.newLineIfNotEmpty();
multipleBody = _builder_1.toString();
multipleAxes.put(scaleName, multipleBody);
}
return body;
}
/**
* <p>helper method to get a property name or its alias if present of a entity's property object.</p>
*/
public String getPropertyName(final DatamartProperty property) {
LEntityAttribute _propertyRef = property.getPropertyRef();
String _name = ((LAttribute) _propertyRef).getName();
return _name.toUpperCase();
}
/**
* <p>helper method to get a level name of a hierarchy's level object.</p>
*/
public String getLevelName(final CubeLevel level) {
return level.getName();
}
public String setup(final Chart chart) {
String body = "";
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
_builder.newLineIfNotEmpty();
_builder.append("subscribe();");
body = _builder.toString();
HashMap<String, String> filterIdMap = CollectionLiterals.<String, String>newHashMap();
boolean _and = false;
boolean _and_1 = false;
ChartDatamart _source = chart.getSource();
boolean _notEquals = (!Objects.equal(_source, null));
if (!_notEquals) {
_and_1 = false;
} else {
ChartDatamart _source_1 = chart.getSource();
DatamartDefinition _datamartRef = _source_1.getDatamartRef();
boolean _notEquals_1 = (!Objects.equal(_datamartRef, null));
_and_1 = _notEquals_1;
}
if (!_and_1) {
_and = false;
} else {
ChartDatamart _source_2 = chart.getSource();
DatamartDefinition _datamartRef_1 = _source_2.getDatamartRef();
String _name = _datamartRef_1.getName();
boolean _notEquals_2 = (!Objects.equal(_name, null));
_and = _notEquals_2;
}
if (_and) {
ChartDatamart _source_3 = chart.getSource();
DatamartDefinition _datamartRef_2 = _source_3.getDatamartRef();
this.datamartInferrer.createFilterMap(_datamartRef_2, filterIdMap);
}
Set<String> _keySet = filterIdMap.keySet();
for (final String filter : _keySet) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
String _get = filterIdMap.get(filter);
CharSequence _setupEvent = this.setupEvent(_get, filter);
_builder_1.append(_setupEvent, "");
body = _builder_1.toString();
}
return body;
}
public CharSequence setupEvent(final String eventId, final String filter) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("eventBroker.subscribe(\"");
_builder.append(eventId, "");
_builder.append("\",");
_builder.newLineIfNotEmpty();
_builder.append("new org.osgi.service.event.EventHandler() {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void handleEvent(org.osgi.service.event.Event event) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("final EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(org.eclipse.e4.core.di.extensions.EventUtils.DATA);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("filterGenerator.selectItem(\"");
_builder.append(filter, "\t\t");
_builder.append("\", msg.getName());");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("});");
_builder.newLine();
return _builder;
}
public CharSequence localeChanged(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("this.locale = locale;");
_builder.newLine();
_builder.append("if(charts != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("for(DCharts chart:charts) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("chart.setLocale(locale);");
_builder.newLine();
{
boolean _and = false;
ChartDatamart _source = chart.getSource();
DatamartDefinition _datamartRef = _source.getDatamartRef();
boolean _isDescription = _datamartRef.isDescription();
if (!_isDescription) {
_and = false;
} else {
ChartDatamart _source_1 = chart.getSource();
DatamartDefinition _datamartRef_1 = _source_1.getDatamartRef();
String _descriptionValue = _datamartRef_1.getDescriptionValue();
boolean _notEquals = (!Objects.equal(_descriptionValue, null));
_and = _notEquals;
}
if (_and) {
_builder.append("\t\t");
_builder.append("chart.setDescription(dslMetadataService.translate(locale.toLanguageTag(), \"");
ChartDatamart _source_2 = chart.getSource();
DatamartDefinition _datamartRef_2 = _source_2.getDatamartRef();
String _descriptionValue_1 = _datamartRef_2.getDescriptionValue();
_builder.append(_descriptionValue_1, "\t\t");
_builder.append("\"));");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("chart.setDownloadButtonCaption(dslMetadataService.translate(locale.toLanguageTag(), \"download\"));");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("if(filterGenerator != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("filterGenerator.setLocale(locale);");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("if(layoutManager != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("layoutManager.setLabelValue(dslMetadataService.translate(locale.toLanguageTag(), \"");
String _name = chart.getName();
_builder.append(_name, "\t");
_builder.append("\"));");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
return _builder;
}
public void infer(final EObject pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
if (pckg instanceof ChartPackage) {
_infer((ChartPackage)pckg, acceptor, isPreIndexingPhase);
return;
} else if (pckg != null) {
_infer(pckg, acceptor, isPreIndexingPhase);
return;
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(pckg, acceptor, isPreIndexingPhase).toString());
}
}
}