| /** |
| * 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.entitymock.jvmmodel; |
| |
| import com.google.common.base.Objects; |
| import com.google.inject.Inject; |
| import java.util.ArrayList; |
| import java.util.Arrays; |
| import java.util.Date; |
| import java.util.List; |
| import java.util.Map; |
| import java.util.Set; |
| import java.util.function.Consumer; |
| import org.apache.commons.lang.StringUtils; |
| import org.apache.commons.lang.WordUtils; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.osbp.dsl.semantic.common.types.LEnum; |
| import org.eclipse.osbp.dsl.semantic.common.types.LEnumLiteral; |
| import org.eclipse.osbp.dsl.semantic.common.types.LImport; |
| import org.eclipse.osbp.dsl.semantic.common.types.LScalarType; |
| import org.eclipse.osbp.dsl.semantic.entity.LBean; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntity; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityReference; |
| import org.eclipse.osbp.persistence.IPersistenceService; |
| import org.eclipse.osbp.ui.api.datamart.IDataMart; |
| import org.eclipse.osbp.utils.common.EntityUtils; |
| import org.eclipse.osbp.utils.entityhelper.DataType; |
| import org.eclipse.osbp.utils.entitymock.ABaseMockEntity; |
| import org.eclipse.osbp.utils.entitymock.ABaseMockObject; |
| import org.eclipse.osbp.utils.entitymock.ABaseMockResource; |
| import org.eclipse.osbp.utils.entitymock.AEntityMockDataGenerator; |
| import org.eclipse.osbp.utils.entitymock.IEntityMockDataDbFiller; |
| import org.eclipse.osbp.utils.entitymock.IEntityMockDataGenerator; |
| import org.eclipse.osbp.xtext.datainterchange.DataInterchange; |
| import org.eclipse.osbp.xtext.datainterchange.jvmmodel.DataDSLJvmModelInferrer; |
| import org.eclipse.osbp.xtext.entitymock.DateIterate; |
| import org.eclipse.osbp.xtext.entitymock.EDateStepType; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockAttributeByObject; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockAttributeByReference; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockAttributeFiller; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockByResourceAttribute; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockEntities; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockEntity; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockEntityFunction; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockEntityFunctionParameter; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockModel; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObject; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectArrayValue; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectEmbed; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectEnum; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectFill; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectFunction; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectFunctionParameter; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectItemValue; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectPlainValue; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjectResourceValue; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockObjects; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockPackage; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockReferencedObjectAttribute; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockResource; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockResourceAttribute; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockResourceDataRow; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockResources; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockTemporary; |
| import org.eclipse.osbp.xtext.entitymock.IEntityMockAttribute; |
| import org.eclipse.osbp.xtext.entitymock.IEntityMockObjectAttribute; |
| import org.eclipse.osbp.xtext.entitymock.IEntityMockObjectUsable; |
| import org.eclipse.osbp.xtext.entitymock.IIterate; |
| import org.eclipse.osbp.xtext.entitymock.IntegerIterate; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerBoolean; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerDateFuture; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerDatePast; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerDateRange; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedDoubleRandom; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedDoubleRange; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedIntegerRandom; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedIntegerRange; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextParagraphs; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextRandom; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextSentences; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextWords; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerType; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedDoubleRandom; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedDoubleRange; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedIntegerRandom; |
| import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedIntegerRange; |
| import org.eclipse.osbp.xtext.entitymock.RunningDataInterchange; |
| import org.eclipse.osbp.xtext.entitymock.RunningDataInterchanges; |
| 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.JvmEnumerationType; |
| 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.JvmType; |
| import org.eclipse.xtext.common.types.JvmTypeReference; |
| import org.eclipse.xtext.common.types.JvmVisibility; |
| import org.eclipse.xtext.xbase.XExpression; |
| 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.Exceptions; |
| import org.eclipse.xtext.xbase.lib.Extension; |
| import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; |
| import org.eclipse.xtext.xbase.lib.StringExtensions; |
| 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 EntityMockDSLJvmModelInferrer extends AbstractModelInferrer { |
| /** |
| * convenience API to build and initialize JVM types and their members. |
| */ |
| @Inject |
| @Extension |
| private JvmTypesBuilder _jvmTypesBuilder; |
| |
| @Inject |
| @Extension |
| private DataDSLJvmModelInferrer _dataDSLJvmModelInferrer; |
| |
| @Inject |
| @Extension |
| private EntityUtils _entityUtils; |
| |
| @Inject |
| private DataType dtType; |
| |
| /** |
| * get the full qualified package name for the imported entities, removing the trailing |
| */ |
| public static String getEntityPackageName(final EntityMockPackage pckg) { |
| String pckgName = ""; |
| EList<LImport> _imports = pckg.getImports(); |
| for (final LImport import_ : _imports) { |
| boolean _isEmpty = pckgName.isEmpty(); |
| if (_isEmpty) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _importedNamespace = import_.getImportedNamespace(); |
| _builder.append(_importedNamespace, ""); |
| String _string = _builder.toString(); |
| pckgName = _string; |
| String _replace = pckgName.replace(".*", ""); |
| pckgName = _replace; |
| } |
| } |
| return pckgName; |
| } |
| |
| /** |
| * generate the full qualified mock package name corresponding to the imported entities |
| */ |
| public static String getEntityMockName(final EntityMockPackage pckg) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityPackageName = EntityMockDSLJvmModelInferrer.getEntityPackageName(pckg); |
| _builder.append(_entityPackageName, ""); |
| _builder.append("mock"); |
| return _builder.toString(); |
| } |
| |
| /** |
| * generate the class name for a temporary mock object |
| */ |
| public String getEntityMockName(final EntityMockTemporary temporary) { |
| EntityMockObject _object = temporary.getObject(); |
| return this.getEntityMockName(((EntityMockObject) _object)); |
| } |
| |
| /** |
| * generate the class name for a mock resource class |
| */ |
| public String getEntityMockName(final EntityMockResource resource) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("Resource"); |
| String _name = resource.getName(); |
| String _capitalize = WordUtils.capitalize(_name); |
| _builder.append(_capitalize, ""); |
| return _builder.toString(); |
| } |
| |
| /** |
| * generate the class name for a mock object class |
| */ |
| public String getEntityMockName(final EntityMockObject object) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("Object"); |
| String _name = object.getName(); |
| String _capitalize = WordUtils.capitalize(_name); |
| _builder.append(_capitalize, ""); |
| return _builder.toString(); |
| } |
| |
| /** |
| * generate the class name for a mock entity |
| */ |
| public String getEntityMockName(final EntityMockEntity entity) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("Entity"); |
| String _name = entity.getName(); |
| String _capitalize = WordUtils.capitalize(_name); |
| _builder.append(_capitalize, ""); |
| return _builder.toString(); |
| } |
| |
| /** |
| * get the entity name referenced by a mock entity |
| */ |
| public String getEntityName(final EntityMockEntity entity) { |
| LEntity _entityRef = entity.getEntityRef(); |
| return this.getEntityName(_entityRef); |
| } |
| |
| /** |
| * get the entity name |
| */ |
| public String getEntityName(final LEntity entity) { |
| return entity.getName(); |
| } |
| |
| /** |
| * get the entity name |
| */ |
| public String getEnumName(final LEnum lenum) { |
| return lenum.getName(); |
| } |
| |
| /** |
| * get the full qualified entity name referenced by a mock entity |
| */ |
| public String getEntityDtoFQN(final EntityMockEntity entity) { |
| LEntity _entityRef = entity.getEntityRef(); |
| return EntityUtils.getDtoFQNForLEntity(_entityRef); |
| } |
| |
| /** |
| * get the full qualified entity class name referenced by a mock entity |
| */ |
| public String getEntityDtoFQNClass(final EntityMockEntity entity) { |
| LEntity _entityRef = entity.getEntityRef(); |
| return this.getEntityDtoFQNClass(_entityRef); |
| } |
| |
| /** |
| * get the full qualified entity class name |
| */ |
| public String getEntityDtoFQNClass(final LEntity entity) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _dtoFQNForLEntity = EntityUtils.getDtoFQNForLEntity(entity); |
| _builder.append(_dtoFQNForLEntity, ""); |
| _builder.append(".class"); |
| return _builder.toString(); |
| } |
| |
| /** |
| * generate a mock object class |
| */ |
| public void generateMockObject(final EntityMockModel model, final IJvmDeclaredTypeAcceptor acceptor, final EntityMockPackage pckg, final EntityMockObject mockObject) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| String _entityMockName_1 = this.getEntityMockName(mockObject); |
| _builder.append(_entityMockName_1, ""); |
| JvmGenericType _class = this._jvmTypesBuilder.toClass(model, _builder.toString()); |
| final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ABaseMockObject.class); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("<b>This class was auto generated! Leave it unmodified to avoid unpredictable results!</b><br>"); |
| _builder.newLine(); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(mockObject); |
| _builder.append(_documentation, ""); |
| _builder.newLineIfNotEmpty(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _builder.toString()); |
| it.setFinal(true); |
| JvmField field = null; |
| JvmTypeReference _typeRef_1 = EntityMockDSLJvmModelInferrer.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("LoggerFactory.getLogger("); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| String _entityMockName_1 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockObject); |
| _builder.append(_entityMockName_1, ""); |
| _builder.append(".class)"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(model, "log", _typeRef_1, _function); |
| field = _field; |
| field.setFinal(true); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| EList<EntityMockObjectEnum> _enumerations = mockObject.getEnumerations(); |
| for (final EntityMockObjectEnum enumeration : _enumerations) { |
| LEnum _usingResource = enumeration.getUsingResource(); |
| if ((_usingResource instanceof EntityMockResource)) { |
| LEnum _usingResource_1 = enumeration.getUsingResource(); |
| final EntityMockResource resource = ((EntityMockResource) _usingResource_1); |
| EList<JvmMember> _members_1 = it.getMembers(); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| String _name = enumeration.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("_resource"); |
| JvmTypeReference _typeRef_2 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ABaseMockResource.class); |
| final Procedure1<JvmField> _function_1 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new "); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.this.getEntityMockName(resource); |
| _builder.append(_entityMockName, ""); |
| _builder.append("()"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(enumeration); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_1 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_1.toString(), _typeRef_2, _function_1); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_1, _field_1); |
| } else { |
| } |
| } |
| EList<IEntityMockObjectAttribute> _attributes = mockObject.getAttributes(); |
| for (final IEntityMockObjectAttribute attribute : _attributes) { |
| boolean _matched = false; |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectPlainValue) { |
| _matched=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<String> _values = ((EntityMockObjectPlainValue)attribute).getValues(); |
| for (final String value : _values) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("\""); |
| _builder_2.append(value, ""); |
| _builder_2.append("\""); |
| items.add(_builder_2.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectPlainValue)attribute).getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Object[].class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_3.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectResourceValue) { |
| _matched=true; |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectArrayValue) { |
| _matched=true; |
| final List<String> enums = new ArrayList<String>(); |
| String _xifexpression = null; |
| EntityMockObjectEnum _enumeration = ((EntityMockObjectArrayValue)attribute).getEnumeration(); |
| LEnum _usingResource_2 = _enumeration.getUsingResource(); |
| if ((_usingResource_2 instanceof EntityMockResource)) { |
| _xifexpression = "String"; |
| } else { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| EntityMockObjectEnum _enumeration_1 = ((EntityMockObjectArrayValue)attribute).getEnumeration(); |
| LEnum _usingResource_3 = _enumeration_1.getUsingResource(); |
| String _dtoFQNForLEnum = EntityUtils.getDtoFQNForLEnum(_usingResource_3); |
| _builder_2.append(_dtoFQNForLEnum, ""); |
| _xifexpression = _builder_2.toString(); |
| } |
| final String keyType = _xifexpression; |
| EList<EntityMockObjectItemValue> _items = ((EntityMockObjectArrayValue)attribute).getItems(); |
| for (final EntityMockObjectItemValue enumItem : _items) { |
| { |
| final List<String> items = new ArrayList<String>(); |
| EList<String> _values = enumItem.getValues(); |
| for (final String value : _values) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("\""); |
| _builder_3.append(value, ""); |
| _builder_3.append("\""); |
| items.add(_builder_3.toString()); |
| } |
| LEnumLiteral _datarow = enumItem.getDatarow(); |
| if ((_datarow instanceof EntityMockResourceDataRow)) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("put(\""); |
| LEnumLiteral _datarow_1 = enumItem.getDatarow(); |
| String _name_1 = _datarow_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\", new Object[] {"); |
| String _join = StringUtils.join(items, ","); |
| _builder_4.append(_join, ""); |
| _builder_4.append("});"); |
| enums.add(_builder_4.toString()); |
| } else { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("put("); |
| _builder_5.append(keyType, ""); |
| _builder_5.append("."); |
| LEnumLiteral _datarow_2 = enumItem.getDatarow(); |
| String _name_2 = _datarow_2.getName(); |
| _builder_5.append(_name_2, ""); |
| _builder_5.append(", new Object[] {"); |
| String _join_1 = StringUtils.join(items, ","); |
| _builder_5.append(_join_1, ""); |
| _builder_5.append("});"); |
| enums.add(_builder_5.toString()); |
| } |
| } |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectArrayValue)attribute).getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Map.class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new HashMap<"); |
| _builder.append(keyType, ""); |
| _builder.append(", Object[]>() {{"); |
| _builder.newLineIfNotEmpty(); |
| String _join = StringUtils.join(enums, "\r\n"); |
| _builder.append(_join, ""); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("}}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_3.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectEmbed) { |
| _matched=true; |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectFill) { |
| _matched=true; |
| PropertyFillerType type = ((EntityMockObjectFill)attribute).getFillerType(); |
| boolean _matched_1 = false; |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<String> _items = ((PropertyFillerTextRandom)type).getItems(); |
| for (final String item : _items) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("\""); |
| _builder_2.append(item, ""); |
| _builder_2.append("\""); |
| items.add(_builder_2.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Object[].class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_3.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedDoubleRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Double> _items = ((PropertyFillerSignedDoubleRandom)type).getItems(); |
| for (final Double item : _items) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(item, ""); |
| items.add(_builder_2.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(double[].class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_3.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedDoubleRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Double> _items = ((PropertyFillerUnsignedDoubleRandom)type).getItems(); |
| for (final Double item : _items) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(item, ""); |
| items.add(_builder_2.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(double[].class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_3.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedIntegerRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Integer> _items = ((PropertyFillerSignedIntegerRandom)type).getItems(); |
| for (final Integer item : _items) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(item, ""); |
| items.add(_builder_2.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(int[].class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_3.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedIntegerRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Integer> _items = ((PropertyFillerUnsignedIntegerRandom)type).getItems(); |
| for (final Integer item : _items) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(item, ""); |
| items.add(_builder_2.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("_items"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(int[].class); |
| final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(mockObject, _builder_3.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); |
| } |
| } |
| } |
| } |
| } |
| EList<EntityMockObjectFunction> _calculations = mockObject.getCalculations(); |
| for (final EntityMockObjectFunction calculation : _calculations) { |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("calculate_"); |
| String _name_1 = calculation.getName(); |
| _builder_2.append(_name_1, ""); |
| JvmTypeReference _oftype = calculation.getOftype(); |
| final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<EntityMockObjectFunctionParameter> _params = calculation.getParams(); |
| for (final EntityMockObjectFunctionParameter param : _params) { |
| { |
| JvmTypeReference type = param.getParameterType(); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| IEntityMockObjectUsable _name = param.getName(); |
| String _name_1 = EntityMockDSLJvmModelInferrer.this.getName(_name); |
| JvmFormalParameter _parameter = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(param, _name_1, type); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| } |
| } |
| it.setFinal(true); |
| XExpression _body = calculation.getBody(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _body); |
| } |
| }; |
| JvmOperation _method = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(mockObject, _builder_2.toString(), _oftype, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method); |
| } |
| EList<JvmMember> _members_3 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("generateDataRow"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_3 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| it.setFinal(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| EList<EntityMockObjectEnum> _enumerations = mockObject.getEnumerations(); |
| for (final EntityMockObjectEnum enumeration : _enumerations) { |
| { |
| String doc = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(enumeration); |
| boolean _and = false; |
| if (!(doc instanceof String)) { |
| _and = false; |
| } else { |
| String _trim = doc.trim(); |
| boolean _isEmpty = _trim.isEmpty(); |
| boolean _not = (!_isEmpty); |
| _and = _not; |
| } |
| if (_and) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("/** "); |
| _builder.append(doc, ""); |
| _builder.append(" */"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| LEnum _usingResource = enumeration.getUsingResource(); |
| if ((_usingResource instanceof EntityMockResource)) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = enumeration.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| String _name_1 = enumeration.getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_resource.getDataRows().toArray());"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } else { |
| final LEnum lenum = enumeration.getUsingResource(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("generateAttribute(\""); |
| String _name_2 = enumeration.getName(); |
| _builder_2.append(_name_2, ""); |
| _builder_2.append("\","); |
| String _dtoFQNForLEnum = EntityUtils.getDtoFQNForLEnum(lenum); |
| _builder_2.append(_dtoFQNForLEnum, ""); |
| _builder_2.append(".values());"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| } |
| } |
| } |
| EList<IEntityMockObjectAttribute> _attributes = mockObject.getAttributes(); |
| for (final IEntityMockObjectAttribute attribute : _attributes) { |
| { |
| String doc = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| boolean _and = false; |
| if (!(doc instanceof String)) { |
| _and = false; |
| } else { |
| String _trim = doc.trim(); |
| boolean _isEmpty = _trim.isEmpty(); |
| boolean _not = (!_isEmpty); |
| _and = _not; |
| } |
| if (_and) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("/** "); |
| _builder.append(doc, ""); |
| _builder.append(" */"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| boolean _matched = false; |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectPlainValue) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectPlainValue)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| String _name_1 = ((EntityMockObjectPlainValue)attribute).getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectResourceValue) { |
| _matched=true; |
| EntityMockObjectEnum _resourceEnum = ((EntityMockObjectResourceValue)attribute).getResourceEnum(); |
| LEnum _usingResource = _resourceEnum.getUsingResource(); |
| if ((_usingResource instanceof EntityMockResource)) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("setFixAttribute(\""); |
| String _name = ((EntityMockObjectResourceValue)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| EntityMockObjectEnum _resourceEnum_1 = ((EntityMockObjectResourceValue)attribute).getResourceEnum(); |
| String _name_1 = _resourceEnum_1.getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_resource.getAttribute(getAttribute(\""); |
| EntityMockObjectEnum _resourceEnum_2 = ((EntityMockObjectResourceValue)attribute).getResourceEnum(); |
| String _name_2 = _resourceEnum_2.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\").toString(), \""); |
| EntityMockResourceAttribute _resourceAttribute = ((EntityMockObjectResourceValue)attribute).getResourceAttribute(); |
| String _name_3 = _resourceAttribute.getName(); |
| _builder_1.append(_name_3, ""); |
| _builder_1.append("\"));"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } else { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("setFixAttribute(\""); |
| String _name_4 = ((EntityMockObjectResourceValue)attribute).getName(); |
| _builder_2.append(_name_4, ""); |
| _builder_2.append("\", getAttribute(\""); |
| EntityMockObjectEnum _resourceEnum_3 = ((EntityMockObjectResourceValue)attribute).getResourceEnum(); |
| String _name_5 = _resourceEnum_3.getName(); |
| _builder_2.append(_name_5, ""); |
| _builder_2.append("\"));"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| } |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectArrayValue) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectArrayValue)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", \""); |
| EntityMockObjectEnum _enumeration = ((EntityMockObjectArrayValue)attribute).getEnumeration(); |
| String _name_1 = _enumeration.getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("\", "); |
| String _name_2 = ((EntityMockObjectArrayValue)attribute).getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectEmbed) { |
| _matched=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectEmbed)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", new "); |
| EntityMockObject _object = ((EntityMockObjectEmbed)attribute).getObject(); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.this.getEntityMockName(_object); |
| _builder_1.append(_entityMockName, ""); |
| _builder_1.append("());"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectFill) { |
| _matched=true; |
| PropertyFillerType type = ((EntityMockObjectFill)attribute).getFillerType(); |
| boolean _matched_1 = false; |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerDateFuture) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateDateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", 0 ,"); |
| int _dateFutureYears = ((PropertyFillerDateFuture)type).getDateFutureYears(); |
| _builder_1.append(_dateFutureYears, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerDatePast) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateDateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", -"); |
| int _datePastYears = ((PropertyFillerDatePast)type).getDatePastYears(); |
| _builder_1.append(_datePastYears, ""); |
| _builder_1.append(", 0);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerDateRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateDateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| int _dateBeginYears = ((PropertyFillerDateRange)type).getDateBeginYears(); |
| _builder_1.append(_dateBeginYears, ""); |
| _builder_1.append(", "); |
| int _dateEndYears = ((PropertyFillerDateRange)type).getDateEndYears(); |
| _builder_1.append(_dateEndYears, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerBoolean) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateBooleanAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedDoubleRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerSignedDoubleRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerSignedDoubleRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateSignedAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_5.append(_name_2, ""); |
| _builder_5.append("\", "); |
| int _decimals = ((PropertyFillerSignedDoubleRange)type).getDecimals(); |
| _builder_5.append(_decimals, ""); |
| _builder_5.append(", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| double _rounded = ((PropertyFillerSignedDoubleRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedDoubleRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedDoubleRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerUnsignedDoubleRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerUnsignedDoubleRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("(double)get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("(double)get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateUnsignedAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_5.append(_name_2, ""); |
| _builder_5.append("\", "); |
| int _decimals = ((PropertyFillerUnsignedDoubleRange)type).getDecimals(); |
| _builder_5.append(_decimals, ""); |
| _builder_5.append(", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| double _rounded = ((PropertyFillerUnsignedDoubleRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedDoubleRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedIntegerRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerSignedIntegerRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerSignedIntegerRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("(int)get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("(int)get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateSignedAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_5.append(_name_2, ""); |
| _builder_5.append("\", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| int _rounded = ((PropertyFillerSignedIntegerRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedIntegerRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedIntegerRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerUnsignedIntegerRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerUnsignedIntegerRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("(int)get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| String _name = _beginRangeRef_1.getName(); |
| _builder_3.append(_name, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("(int)get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| String _name_1 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_1, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateUnsignedAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_5.append(_name_2, ""); |
| _builder_5.append("\", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| int _rounded = ((PropertyFillerUnsignedIntegerRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedIntegerRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextParagraphs) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateParagraphsAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| int _count = ((PropertyFillerTextParagraphs)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextSentences) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateSentencesAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| int _count = ((PropertyFillerTextSentences)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextWords) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateWordsAttribute(\""); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", "); |
| int _count = ((PropertyFillerTextWords)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| } |
| } |
| } |
| } |
| EList<EntityMockObjectFunction> _calculations = mockObject.getCalculations(); |
| for (final EntityMockObjectFunction calculation : _calculations) { |
| { |
| String doc = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(calculation); |
| boolean _and = false; |
| if (!(doc instanceof String)) { |
| _and = false; |
| } else { |
| String _trim = doc.trim(); |
| boolean _isEmpty = _trim.isEmpty(); |
| boolean _not = (!_isEmpty); |
| _and = _not; |
| } |
| if (_and) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("/** "); |
| _builder.append(doc, ""); |
| _builder.append(" */"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| String paramString = _builder_1.toString(); |
| EList<EntityMockObjectFunctionParameter> _params = calculation.getParams(); |
| for (final EntityMockObjectFunctionParameter param : _params) { |
| { |
| boolean _isEmpty_1 = paramString.isEmpty(); |
| boolean _not_1 = (!_isEmpty_1); |
| if (_not_1) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(paramString, ""); |
| _builder_2.append(","); |
| paramString = _builder_2.toString(); |
| } |
| JvmTypeReference _parameterType = param.getParameterType(); |
| JvmType _type = _parameterType.getType(); |
| if ((_type instanceof JvmEnumerationType)) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(paramString, ""); |
| _builder_3.append(" "); |
| JvmTypeReference _parameterType_1 = param.getParameterType(); |
| String _identifier = _parameterType_1.getIdentifier(); |
| _builder_3.append(_identifier, ""); |
| _builder_3.append(".valueOf(getAttribute(\""); |
| IEntityMockObjectUsable _name = param.getName(); |
| String _name_1 = EntityMockDSLJvmModelInferrer.this.getName(_name); |
| _builder_3.append(_name_1, ""); |
| _builder_3.append("\").toString())"); |
| paramString = _builder_3.toString(); |
| } else { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append(paramString, ""); |
| _builder_4.append("("); |
| JvmTypeReference _parameterType_2 = param.getParameterType(); |
| String _identifier_1 = _parameterType_2.getIdentifier(); |
| _builder_4.append(_identifier_1, ""); |
| _builder_4.append(")getAttribute(\""); |
| IEntityMockObjectUsable _name_2 = param.getName(); |
| String _name_3 = EntityMockDSLJvmModelInferrer.this.getName(_name_2); |
| _builder_4.append(_name_3, ""); |
| _builder_4.append("\")"); |
| paramString = _builder_4.toString(); |
| } |
| } |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("try {"); |
| _builder_2.newLine(); |
| _builder_2.append("\t"); |
| _builder_2.append("setFixAttribute(\""); |
| String _name = calculation.getName(); |
| _builder_2.append(_name, "\t"); |
| _builder_2.append("\", calculate_"); |
| String _name_1 = calculation.getName(); |
| _builder_2.append(_name_1, "\t"); |
| _builder_2.append("("); |
| _builder_2.append(paramString, "\t"); |
| _builder_2.append("));"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("}"); |
| _builder_2.newLine(); |
| _builder_2.append("catch (NullPointerException npe) {}"); |
| _builder_2.newLine(); |
| _builder_2.append("catch (Exception e) {"); |
| _builder_2.newLine(); |
| _builder_2.append(" "); |
| _builder_2.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_2.newLine(); |
| _builder_2.append("}"); |
| _builder_2.newLine(); |
| it.append(_builder_2); |
| } |
| } |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(mockObject, _builder_3.toString(), _typeRef_3, _function_3); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_1); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(_class, _function); |
| } |
| |
| public String getName(final IEntityMockObjectUsable attribute) { |
| boolean _matched = false; |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectFunction) { |
| _matched=true; |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = ((EntityMockObjectFunction)attribute).getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectEnum) { |
| _matched=true; |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = ((EntityMockObjectEnum)attribute).getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectPlainValue) { |
| _matched=true; |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = ((EntityMockObjectPlainValue)attribute).getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectArrayValue) { |
| _matched=true; |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = ((EntityMockObjectArrayValue)attribute).getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectEmbed) { |
| _matched=true; |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = ((EntityMockObjectEmbed)attribute).getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectFill) { |
| _matched=true; |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = ((EntityMockObjectFill)attribute).getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockObjectResourceValue) { |
| _matched=true; |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = ((EntityMockObjectResourceValue)attribute).getName(); |
| _builder.append(_name, ""); |
| return _builder.toString(); |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * generate a mock entity class |
| */ |
| public void generateMockEntity(final EntityMockModel model, final IJvmDeclaredTypeAcceptor acceptor, final EntityMockPackage pckg, final EntityMockEntity mockEntity) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| String _entityMockName_1 = this.getEntityMockName(mockEntity); |
| _builder.append(_entityMockName_1, ""); |
| JvmGenericType _class = this._jvmTypesBuilder.toClass(model, _builder.toString()); |
| final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ABaseMockEntity.class); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("<b>This class was auto generated! Leave it unmodified to avoid unpredictable results!</b><br>"); |
| _builder.newLine(); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(mockEntity); |
| _builder.append(_documentation, ""); |
| _builder.newLineIfNotEmpty(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _builder.toString()); |
| it.setFinal(true); |
| JvmField field = null; |
| JvmTypeReference _typeRef_1 = EntityMockDSLJvmModelInferrer.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("LoggerFactory.getLogger("); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| String _entityMockName_1 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder.append(_entityMockName_1, ""); |
| _builder.append(".class)"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(model, "log", _typeRef_1, _function); |
| field = _field; |
| field.setFinal(true); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| boolean _notEquals = (!Objects.equal(_byResource, null)); |
| if (_notEquals) { |
| EList<JvmMember> _members_1 = it.getMembers(); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| EntityMockResource _byResource_1 = mockEntity.getByResource(); |
| String _name = _byResource_1.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("_resource"); |
| JvmTypeReference _typeRef_2 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ABaseMockResource.class); |
| final Procedure1<JvmField> _function_1 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new "); |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.this.getEntityMockName(_byResource); |
| _builder.append(_entityMockName, ""); |
| _builder.append("()"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(_byResource); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_1 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(pckg, _builder_1.toString(), _typeRef_2, _function_1); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_1, _field_1); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| final Procedure1<JvmConstructor> _function_2 = new Procedure1<JvmConstructor>() { |
| public void apply(final JvmConstructor it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(AEntityMockDataGenerator.class); |
| JvmFormalParameter _parameter = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(mockEntity, "mockDataGenerator", _typeRef); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("super(mockDataGenerator, \""); |
| LEntity _entityRef = mockEntity.getEntityRef(); |
| String _persistenceUnit = _entityRef.getPersistenceUnit(); |
| _builder.append(_persistenceUnit, ""); |
| _builder.append("\");"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmConstructor _constructor = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toConstructor(pckg, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmConstructor>operator_add(_members_2, _constructor); |
| EList<EntityMockTemporary> _temporaries = mockEntity.getTemporaries(); |
| for (final EntityMockTemporary temporary : _temporaries) { |
| EList<JvmMember> _members_3 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = temporary.getName(); |
| _builder_2.append(_name_1, ""); |
| _builder_2.append("_temporary"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ABaseMockObject.class); |
| final Procedure1<JvmField> _function_3 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("new "); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.this.getEntityMockName(temporary); |
| _builder.append(_entityMockName, ""); |
| _builder.append("()"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(temporary); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(pckg, _builder_2.toString(), _typeRef_3, _function_3); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_3, _field_2); |
| } |
| EList<IEntityMockAttribute> _attributes = mockEntity.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| boolean _matched = false; |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeByObject) { |
| _matched=true; |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeFiller) { |
| _matched=true; |
| PropertyFillerType type = ((EntityMockAttributeFiller)attribute).getFillerType(); |
| boolean _matched_1 = false; |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<String> _items = ((PropertyFillerTextRandom)type).getItems(); |
| for (final String item : _items) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("\""); |
| _builder_3.append(item, ""); |
| _builder_3.append("\""); |
| items.add(_builder_3.toString()); |
| } |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("_items"); |
| JvmTypeReference _typeRef_4 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Object[].class); |
| final Procedure1<JvmField> _function_4 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_3 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(pckg, _builder_4.toString(), _typeRef_4, _function_4); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_4, _field_3); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedDoubleRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Double> _items = ((PropertyFillerSignedDoubleRandom)type).getItems(); |
| for (final Double item : _items) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(item, ""); |
| items.add(_builder_3.toString()); |
| } |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("_items"); |
| JvmTypeReference _typeRef_4 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(double[].class); |
| final Procedure1<JvmField> _function_4 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_3 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(pckg, _builder_4.toString(), _typeRef_4, _function_4); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_4, _field_3); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedDoubleRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Double> _items = ((PropertyFillerUnsignedDoubleRandom)type).getItems(); |
| for (final Double item : _items) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(item, ""); |
| items.add(_builder_3.toString()); |
| } |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("_items"); |
| JvmTypeReference _typeRef_4 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(double[].class); |
| final Procedure1<JvmField> _function_4 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_3 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(pckg, _builder_4.toString(), _typeRef_4, _function_4); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_4, _field_3); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedIntegerRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Integer> _items = ((PropertyFillerSignedIntegerRandom)type).getItems(); |
| for (final Integer item : _items) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(item, ""); |
| items.add(_builder_3.toString()); |
| } |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("_items"); |
| JvmTypeReference _typeRef_4 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(int[].class); |
| final Procedure1<JvmField> _function_4 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_3 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(pckg, _builder_4.toString(), _typeRef_4, _function_4); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_4, _field_3); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedIntegerRandom) { |
| _matched_1=true; |
| final List<String> items = new ArrayList<String>(); |
| EList<Integer> _items = ((PropertyFillerUnsignedIntegerRandom)type).getItems(); |
| for (final Integer item : _items) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(item, ""); |
| items.add(_builder_3.toString()); |
| } |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("_items"); |
| JvmTypeReference _typeRef_4 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(int[].class); |
| final Procedure1<JvmField> _function_4 = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder.append(_join, ""); |
| _builder.append("}"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(attribute); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _documentation); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| } |
| }; |
| JvmField _field_3 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(pckg, _builder_4.toString(), _typeRef_4, _function_4); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members_4, _field_3); |
| } |
| } |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeByReference) { |
| _matched=true; |
| } |
| } |
| } |
| EntityMockResource _byResource_2 = mockEntity.getByResource(); |
| boolean _notEquals_1 = (!Objects.equal(_byResource_2, null)); |
| if (_notEquals_1) { |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("getDataRows"); |
| JvmTypeReference _typeRef_4 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Set.class); |
| final Procedure1<JvmOperation> _function_4 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setFinal(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return "); |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| String _name = _byResource.getName(); |
| _builder.append(_name, ""); |
| _builder.append("_resource.getDataRows();"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(pckg, _builder_3.toString(), _typeRef_4, _function_4); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method); |
| EList<JvmMember> _members_5 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateEntity"); |
| JvmTypeReference _typeRef_5 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Object.class); |
| final Procedure1<JvmOperation> _function_5 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Object.class); |
| JvmFormalParameter _parameter = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(pckg, "dataRow", _typeRef); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| it.setFinal(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("reset();"); |
| _builder.newLine(); |
| String _entityDtoFQN = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder.append(_entityDtoFQN, ""); |
| _builder.append(" internal = new "); |
| String _entityDtoFQN_1 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder.append(_entityDtoFQN_1, ""); |
| _builder.append("();"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("entity = internal;"); |
| _builder.newLine(); |
| _builder.append("generateData();"); |
| _builder.newLine(); |
| _builder.append("try {"); |
| _builder.newLine(); |
| it.append(_builder); |
| EList<EntityMockByResourceAttribute> _byResourceAttributes = mockEntity.getByResourceAttributes(); |
| for (final EntityMockByResourceAttribute attribute : _byResourceAttributes) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("internal.set"); |
| LEntityAttribute _attributeRef = attribute.getAttributeRef(); |
| String _name = _attributeRef.getName(); |
| String _capitalize = WordUtils.capitalize(_name); |
| _builder_1.append(_capitalize, ""); |
| _builder_1.append("("); |
| LEntityAttribute _attributeRef_1 = attribute.getAttributeRef(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| String _name_1 = _byResource.getName(); |
| _builder_2.append(_name_1, ""); |
| _builder_2.append("_resource.getAttribute(dataRow.toString(), \""); |
| EntityMockResourceAttribute _resourceAttribute = attribute.getResourceAttribute(); |
| String _name_2 = _resourceAttribute.getName(); |
| _builder_2.append(_name_2, ""); |
| _builder_2.append("\")"); |
| String _baseMockDataTypeCasting = EntityMockDSLJvmModelInferrer.this.baseMockDataTypeCasting(_attributeRef_1, _builder_2.toString()); |
| _builder_1.append(_baseMockDataTypeCasting, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("}"); |
| _builder_3.newLine(); |
| _builder_3.append("catch (Exception e) {"); |
| _builder_3.newLine(); |
| _builder_3.append(" "); |
| _builder_3.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_3.newLine(); |
| _builder_3.append("}"); |
| _builder_3.newLine(); |
| _builder_3.append("return entity;"); |
| it.append(_builder_3); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(pckg, _builder_4.toString(), _typeRef_5, _function_5); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_1); |
| } |
| EList<EntityMockEntityFunction> _calculations = mockEntity.getCalculations(); |
| for (final EntityMockEntityFunction calculation : _calculations) { |
| EList<JvmMember> _members_6 = it.getMembers(); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("calculate_"); |
| LEntityAttribute _attributeRef = calculation.getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_5.append(_name_2, ""); |
| LEntityAttribute _attributeRef_1 = calculation.getAttributeRef(); |
| JvmTypeReference _jvmTypeRef = EntityMockDSLJvmModelInferrer.this.jvmTypeRef(_attributeRef_1); |
| final Procedure1<JvmOperation> _function_6 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<EntityMockEntityFunctionParameter> _params = calculation.getParams(); |
| for (final EntityMockEntityFunctionParameter param : _params) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| String _paramName = EntityMockDSLJvmModelInferrer.this.getParamName(param, "__"); |
| JvmTypeReference _jvmType = EntityMockDSLJvmModelInferrer.this.getJvmType(param); |
| JvmFormalParameter _parameter = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(param, _paramName, _jvmType); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| } |
| it.setFinal(true); |
| XExpression _body = calculation.getBody(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _body); |
| } |
| }; |
| JvmOperation _method_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(pckg, _builder_5.toString(), _jvmTypeRef, _function_6); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_2); |
| } |
| EList<JvmMember> _members_7 = it.getMembers(); |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("generateDataRow"); |
| JvmTypeReference _typeRef_6 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_7 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| it.setFinal(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| EList<EntityMockTemporary> _temporaries = mockEntity.getTemporaries(); |
| for (final EntityMockTemporary temporary : _temporaries) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("generateAttribute(\""); |
| String _name = temporary.getName(); |
| _builder.append(_name, ""); |
| _builder.append("\", "); |
| String _name_1 = temporary.getName(); |
| _builder.append(_name_1, ""); |
| _builder.append("_temporary);"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| EList<IEntityMockAttribute> _attributes = mockEntity.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| boolean _matched = false; |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeByObject) { |
| _matched=true; |
| EntityMockReferencedObjectAttribute _reference = ((EntityMockAttributeByObject)attribute).getReference(); |
| EntityMockTemporary _temporary = _reference.getTemporary(); |
| String sourceKey = _temporary.getName(); |
| EntityMockReferencedObjectAttribute _reference_1 = ((EntityMockAttributeByObject)attribute).getReference(); |
| EList<EntityMockObjectEmbed> _embedded = _reference_1.getEmbedded(); |
| for (final EntityMockObjectEmbed embed : _embedded) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append(sourceKey, ""); |
| _builder_1.append("."); |
| String _name_2 = embed.getName(); |
| _builder_1.append(_name_2, ""); |
| sourceKey = _builder_1.toString(); |
| } |
| EntityMockReferencedObjectAttribute _reference_2 = ((EntityMockAttributeByObject)attribute).getReference(); |
| final IEntityMockObjectUsable refAttribute = _reference_2.getAttribute(); |
| if ((refAttribute instanceof EntityMockObjectEnum)) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(sourceKey, ""); |
| _builder_2.append("."); |
| String _name_3 = ((EntityMockObjectEnum) refAttribute).getName(); |
| _builder_2.append(_name_3, ""); |
| sourceKey = _builder_2.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectPlainValue)) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(sourceKey, ""); |
| _builder_3.append("."); |
| String _name_4 = ((EntityMockObjectPlainValue) refAttribute).getName(); |
| _builder_3.append(_name_4, ""); |
| sourceKey = _builder_3.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectResourceValue)) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append(sourceKey, ""); |
| _builder_4.append("."); |
| String _name_5 = ((EntityMockObjectResourceValue) refAttribute).getName(); |
| _builder_4.append(_name_5, ""); |
| sourceKey = _builder_4.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectArrayValue)) { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append(sourceKey, ""); |
| _builder_5.append("."); |
| String _name_6 = ((EntityMockObjectArrayValue) refAttribute).getName(); |
| _builder_5.append(_name_6, ""); |
| sourceKey = _builder_5.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectEmbed)) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(sourceKey, ""); |
| _builder_6.append("."); |
| String _name_7 = ((EntityMockObjectEmbed) refAttribute).getName(); |
| _builder_6.append(_name_7, ""); |
| sourceKey = _builder_6.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectFill)) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append(sourceKey, ""); |
| _builder_7.append("."); |
| String _name_8 = ((EntityMockObjectFill) refAttribute).getName(); |
| _builder_7.append(_name_8, ""); |
| sourceKey = _builder_7.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectFunction)) { |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append(sourceKey, ""); |
| _builder_8.append("."); |
| String _name_9 = ((EntityMockObjectFunction) refAttribute).getName(); |
| _builder_8.append(_name_9, ""); |
| sourceKey = _builder_8.toString(); |
| } |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("generateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeByObject)attribute).getAttributeRef(); |
| String _name_10 = _attributeRef.getName(); |
| _builder_9.append(_name_10, ""); |
| _builder_9.append("\", \""); |
| _builder_9.append(sourceKey, ""); |
| _builder_9.append("\");"); |
| _builder_9.newLineIfNotEmpty(); |
| it.append(_builder_9); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeFiller) { |
| _matched=true; |
| PropertyFillerType type = ((EntityMockAttributeFiller)attribute).getFillerType(); |
| boolean _matched_1 = false; |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerDateFuture) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateDateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", 0 ,"); |
| int _dateFutureYears = ((PropertyFillerDateFuture)type).getDateFutureYears(); |
| _builder_1.append(_dateFutureYears, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerDatePast) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateDateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", -"); |
| int _datePastYears = ((PropertyFillerDatePast)type).getDatePastYears(); |
| _builder_1.append(_datePastYears, ""); |
| _builder_1.append(", 0);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerDateRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateDateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| int _dateBeginYears = ((PropertyFillerDateRange)type).getDateBeginYears(); |
| _builder_1.append(_dateBeginYears, ""); |
| _builder_1.append(", "); |
| int _dateEndYears = ((PropertyFillerDateRange)type).getDateEndYears(); |
| _builder_1.append(_dateEndYears, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerBoolean) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateBooleanAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedDoubleRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerSignedDoubleRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerSignedDoubleRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| String _name_2 = _beginRangeRef_1.getName(); |
| _builder_3.append(_name_2, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| String _name_3 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_3, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateSignedAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_4 = _attributeRef.getName(); |
| _builder_5.append(_name_4, ""); |
| _builder_5.append("\", "); |
| int _decimals = ((PropertyFillerSignedDoubleRange)type).getDecimals(); |
| _builder_5.append(_decimals, ""); |
| _builder_5.append(", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| double _rounded = ((PropertyFillerSignedDoubleRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedDoubleRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| LEntityAttribute _attributeRef_1 = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_3 = _attributeRef_1.getName(); |
| _builder_1.append(_name_3, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedDoubleRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerUnsignedDoubleRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerUnsignedDoubleRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("(double)get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| String _name_2 = _beginRangeRef_1.getName(); |
| _builder_3.append(_name_2, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("(double)get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| String _name_3 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_3, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateUnsignedAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_4 = _attributeRef.getName(); |
| _builder_5.append(_name_4, ""); |
| _builder_5.append("\", "); |
| int _decimals = ((PropertyFillerUnsignedDoubleRange)type).getDecimals(); |
| _builder_5.append(_decimals, ""); |
| _builder_5.append(", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| double _rounded = ((PropertyFillerUnsignedDoubleRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedDoubleRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| LEntityAttribute _attributeRef_1 = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_3 = _attributeRef_1.getName(); |
| _builder_1.append(_name_3, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedIntegerRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerSignedIntegerRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerSignedIntegerRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("(int)get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| String _name_2 = _beginRangeRef_1.getName(); |
| _builder_3.append(_name_2, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("(int)get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| String _name_3 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_3, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateSignedAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_4 = _attributeRef.getName(); |
| _builder_5.append(_name_4, ""); |
| _builder_5.append("\", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| int _rounded = ((PropertyFillerSignedIntegerRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerSignedIntegerRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| LEntityAttribute _attributeRef_1 = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_3 = _attributeRef_1.getName(); |
| _builder_1.append(_name_3, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedIntegerRange) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerUnsignedIntegerRange)type).getBeginRange(); |
| _builder_1.append(_beginRange, ""); |
| String beginRange = _builder_1.toString(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerUnsignedIntegerRange)type).getEndRange(); |
| _builder_2.append(_endRange, ""); |
| String endRange = _builder_2.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| boolean _notEquals = (!Objects.equal(_beginRangeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("(int)get_\""); |
| LEntityAttribute _beginRangeRef_1 = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| String _name_2 = _beginRangeRef_1.getName(); |
| _builder_3.append(_name_2, ""); |
| _builder_3.append("\"()"); |
| beginRange = _builder_3.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| boolean _notEquals_1 = (!Objects.equal(_endRangeRef, null)); |
| if (_notEquals_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("(int)get_\""); |
| LEntityAttribute _endRangeRef_1 = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| String _name_3 = _endRangeRef_1.getName(); |
| _builder_4.append(_name_3, ""); |
| _builder_4.append("\"()"); |
| endRange = _builder_4.toString(); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateUnsignedAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_4 = _attributeRef.getName(); |
| _builder_5.append(_name_4, ""); |
| _builder_5.append("\", "); |
| _builder_5.append(beginRange, ""); |
| _builder_5.append(", "); |
| _builder_5.append(endRange, ""); |
| _builder_5.append(", "); |
| int _rounded = ((PropertyFillerUnsignedIntegerRange)type).getRounded(); |
| _builder_5.append(_rounded, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerUnsignedIntegerRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| LEntityAttribute _attributeRef_1 = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_3 = _attributeRef_1.getName(); |
| _builder_1.append(_name_3, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextRandom) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| LEntityAttribute _attributeRef_1 = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_3 = _attributeRef_1.getName(); |
| _builder_1.append(_name_3, ""); |
| _builder_1.append("_items);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextParagraphs) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateParagraphsAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| int _count = ((PropertyFillerTextParagraphs)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextSentences) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateSentencesAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| int _count = ((PropertyFillerTextSentences)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| if (!_matched_1) { |
| if (type instanceof PropertyFillerTextWords) { |
| _matched_1=true; |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateWordsAttribute(\""); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| int _count = ((PropertyFillerTextWords)type).getCount(); |
| _builder_1.append(_count, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| } |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeByReference) { |
| _matched=true; |
| EntityMockEntity _mockedEntity = ((EntityMockAttributeByReference)attribute).getMockedEntity(); |
| boolean _equals = Objects.equal(_mockedEntity, null); |
| if (_equals) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("generateAttribute(\""); |
| LEntityReference _attributeRef = ((EntityMockAttributeByReference)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append("\", "); |
| LEntityReference _attributeRef_1 = ((EntityMockAttributeByReference)attribute).getAttributeRef(); |
| LEntity _type = _attributeRef_1.getType(); |
| String _dtoFQNForLEntity = EntityUtils.getDtoFQNForLEntity(_type); |
| _builder_1.append(_dtoFQNForLEntity, ""); |
| _builder_1.append(".class, "); |
| int _optionalFor = ((EntityMockAttributeByReference)attribute).getOptionalFor(); |
| _builder_1.append((((double) _optionalFor) / 100.0), ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } else { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("generateAttribute(\""); |
| LEntityReference _attributeRef_2 = ((EntityMockAttributeByReference)attribute).getAttributeRef(); |
| String _name_3 = _attributeRef_2.getName(); |
| _builder_2.append(_name_3, ""); |
| _builder_2.append("\", \""); |
| EntityMockEntity _mockedEntity_1 = ((EntityMockAttributeByReference)attribute).getMockedEntity(); |
| String _name_4 = _mockedEntity_1.getName(); |
| _builder_2.append(_name_4, ""); |
| _builder_2.append("\", "); |
| int _optionalFor_1 = ((EntityMockAttributeByReference)attribute).getOptionalFor(); |
| _builder_2.append((((double) _optionalFor_1) / 100.0), ""); |
| _builder_2.append(");"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| } |
| } |
| } |
| } |
| EList<EntityMockEntityFunction> _calculations = mockEntity.getCalculations(); |
| for (final EntityMockEntityFunction calculation : _calculations) { |
| { |
| String doc = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(calculation); |
| boolean _and = false; |
| if (!(doc instanceof String)) { |
| _and = false; |
| } else { |
| String _trim = doc.trim(); |
| boolean _isEmpty = _trim.isEmpty(); |
| boolean _not = (!_isEmpty); |
| _and = _not; |
| } |
| if (_and) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("/** "); |
| _builder_1.append(doc, ""); |
| _builder_1.append(" */"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String paramString = _builder_2.toString(); |
| EList<EntityMockEntityFunctionParameter> _params = calculation.getParams(); |
| for (final EntityMockEntityFunctionParameter param : _params) { |
| { |
| boolean _isEmpty_1 = paramString.isEmpty(); |
| boolean _not_1 = (!_isEmpty_1); |
| if (_not_1) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(paramString, ""); |
| _builder_3.append(","); |
| paramString = _builder_3.toString(); |
| } |
| LEntityAttribute _attributeRef = param.getAttributeRef(); |
| boolean _notEquals = (!Objects.equal(_attributeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append(paramString, ""); |
| _builder_4.append("("); |
| JvmTypeReference _jvmType = EntityMockDSLJvmModelInferrer.this.getJvmType(param); |
| String _identifier = _jvmType.getIdentifier(); |
| _builder_4.append(_identifier, ""); |
| _builder_4.append(")getAttribute(\""); |
| String _paramName = EntityMockDSLJvmModelInferrer.this.getParamName(param, "."); |
| _builder_4.append(_paramName, ""); |
| _builder_4.append("\")"); |
| paramString = _builder_4.toString(); |
| } else { |
| boolean _isReferenceOnExistingDto = EntityMockDSLJvmModelInferrer.this.isReferenceOnExistingDto(param); |
| if (_isReferenceOnExistingDto) { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append(paramString, ""); |
| _builder_5.append("("); |
| JvmTypeReference _jvmType_1 = EntityMockDSLJvmModelInferrer.this.getJvmType(param); |
| String _identifier_1 = _jvmType_1.getIdentifier(); |
| _builder_5.append(_identifier_1, ""); |
| _builder_5.append(")(("); |
| EList<LEntityReference> _referencePaths = param.getReferencePaths(); |
| LEntityReference _get = _referencePaths.get(0); |
| LEntity _type = _get.getType(); |
| String _dtoFQNForLEntity = EntityUtils.getDtoFQNForLEntity(_type); |
| _builder_5.append(_dtoFQNForLEntity, ""); |
| _builder_5.append(")getAttribute(\""); |
| EList<LEntityReference> _referencePaths_1 = param.getReferencePaths(); |
| LEntityReference _get_1 = _referencePaths_1.get(0); |
| String _name_2 = _get_1.getName(); |
| _builder_5.append(_name_2, ""); |
| _builder_5.append("\", mockDataGenerator, persistenceUnit)).get"); |
| LEntityAttribute _referenceRef = param.getReferenceRef(); |
| String _name_3 = _referenceRef.getName(); |
| String _firstUpper = StringExtensions.toFirstUpper(_name_3); |
| _builder_5.append(_firstUpper, ""); |
| _builder_5.append("()"); |
| paramString = _builder_5.toString(); |
| } else { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(paramString, ""); |
| _builder_6.append("("); |
| JvmTypeReference _jvmType_2 = EntityMockDSLJvmModelInferrer.this.getJvmType(param); |
| String _identifier_2 = _jvmType_2.getIdentifier(); |
| _builder_6.append(_identifier_2, ""); |
| _builder_6.append(")getAttribute(\""); |
| String _paramName_1 = EntityMockDSLJvmModelInferrer.this.getParamName(param, "."); |
| _builder_6.append(_paramName_1, ""); |
| _builder_6.append("\", mockDataGenerator, persistenceUnit)"); |
| paramString = _builder_6.toString(); |
| } |
| } |
| } |
| } |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("try {"); |
| _builder_3.newLine(); |
| _builder_3.append("\t"); |
| _builder_3.append("setFixAttribute(\""); |
| LEntityAttribute _attributeRef = calculation.getAttributeRef(); |
| String _name_2 = _attributeRef.getName(); |
| _builder_3.append(_name_2, "\t"); |
| _builder_3.append("\", calculate_"); |
| LEntityAttribute _attributeRef_1 = calculation.getAttributeRef(); |
| String _name_3 = _attributeRef_1.getName(); |
| _builder_3.append(_name_3, "\t"); |
| _builder_3.append("("); |
| _builder_3.append(paramString, "\t"); |
| _builder_3.append("));"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("}"); |
| _builder_3.newLine(); |
| _builder_3.append("catch (NullPointerException npe) {}"); |
| _builder_3.newLine(); |
| _builder_3.append("catch (Exception e) {"); |
| _builder_3.newLine(); |
| _builder_3.append(" "); |
| _builder_3.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_3.newLine(); |
| _builder_3.append("}"); |
| _builder_3.newLine(); |
| it.append(_builder_3); |
| } |
| } |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_3 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(pckg, _builder_6.toString(), _typeRef_6, _function_7); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_3); |
| EntityMockResource _byResource_3 = mockEntity.getByResource(); |
| boolean _equals = Objects.equal(_byResource_3, null); |
| if (_equals) { |
| EList<JvmMember> _members_8 = it.getMembers(); |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateEntity"); |
| JvmTypeReference _typeRef_7 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Object.class); |
| final Procedure1<JvmOperation> _function_8 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Object.class); |
| JvmFormalParameter _parameter = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(mockEntity, "dataRow", _typeRef); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| it.setFinal(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("reset();"); |
| _builder.newLine(); |
| it.append(_builder); |
| LEntityAttribute _iterator = mockEntity.getIterator(); |
| boolean _notEquals = (!Objects.equal(_iterator, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("setFixAttribute(\""); |
| LEntityAttribute _iterator_1 = mockEntity.getIterator(); |
| String _name = _iterator_1.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append("\", dataRow);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _entityDtoFQN = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder_2.append(_entityDtoFQN, ""); |
| _builder_2.append(" internal = new "); |
| String _entityDtoFQN_1 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder_2.append(_entityDtoFQN_1, ""); |
| _builder_2.append("();"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("entity = internal;"); |
| _builder_2.newLine(); |
| _builder_2.append("generateData();"); |
| _builder_2.newLine(); |
| _builder_2.append("mockDataGenerator.addDtoMockData(internal, mockData);"); |
| _builder_2.newLine(); |
| _builder_2.append("try {"); |
| _builder_2.newLine(); |
| it.append(_builder_2); |
| EList<IEntityMockAttribute> _attributes = mockEntity.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| boolean _matched = false; |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeByObject) { |
| _matched=true; |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("internal.set"); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeByObject)attribute).getAttributeRef(); |
| String _name_1 = _attributeRef.getName(); |
| String _capitalize = WordUtils.capitalize(_name_1); |
| _builder_3.append(_capitalize, ""); |
| _builder_3.append("("); |
| LEntityAttribute _attributeRef_1 = ((EntityMockAttributeByObject)attribute).getAttributeRef(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("mockData.get(\""); |
| LEntityAttribute _attributeRef_2 = ((EntityMockAttributeByObject)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef_2.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("\")"); |
| String _baseMockDataTypeCasting = EntityMockDSLJvmModelInferrer.this.baseMockDataTypeCasting(_attributeRef_1, _builder_4.toString()); |
| _builder_3.append(_baseMockDataTypeCasting, ""); |
| _builder_3.append(");"); |
| _builder_3.newLineIfNotEmpty(); |
| it.append(_builder_3); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeFiller) { |
| _matched=true; |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("internal.set"); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_1 = _attributeRef.getName(); |
| String _capitalize = WordUtils.capitalize(_name_1); |
| _builder_3.append(_capitalize, ""); |
| _builder_3.append("("); |
| LEntityAttribute _attributeRef_1 = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("mockData.get(\""); |
| LEntityAttribute _attributeRef_2 = ((EntityMockAttributeFiller)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef_2.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("\")"); |
| String _baseMockDataTypeCasting = EntityMockDSLJvmModelInferrer.this.baseMockDataTypeCasting(_attributeRef_1, _builder_4.toString()); |
| _builder_3.append(_baseMockDataTypeCasting, ""); |
| _builder_3.append(");"); |
| _builder_3.newLineIfNotEmpty(); |
| it.append(_builder_3); |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeByReference) { |
| _matched=true; |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("internal.set"); |
| LEntityReference _attributeRef = ((EntityMockAttributeByReference)attribute).getAttributeRef(); |
| String _name_1 = _attributeRef.getName(); |
| String _capitalize = WordUtils.capitalize(_name_1); |
| _builder_3.append(_capitalize, ""); |
| _builder_3.append("(("); |
| LEntityReference _attributeRef_1 = ((EntityMockAttributeByReference)attribute).getAttributeRef(); |
| LEntity _type = _attributeRef_1.getType(); |
| String _dtoFQNForLEntity = EntityUtils.getDtoFQNForLEntity(_type); |
| _builder_3.append(_dtoFQNForLEntity, ""); |
| _builder_3.append(")mockData.get(\""); |
| LEntityReference _attributeRef_2 = ((EntityMockAttributeByReference)attribute).getAttributeRef(); |
| String _name_2 = _attributeRef_2.getName(); |
| _builder_3.append(_name_2, ""); |
| _builder_3.append("\"));"); |
| _builder_3.newLineIfNotEmpty(); |
| it.append(_builder_3); |
| } |
| } |
| } |
| EList<EntityMockEntityFunction> _calculations = mockEntity.getCalculations(); |
| for (final EntityMockEntityFunction calculation : _calculations) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("internal.set"); |
| LEntityAttribute _attributeRef = calculation.getAttributeRef(); |
| String _name_1 = _attributeRef.getName(); |
| String _capitalize = WordUtils.capitalize(_name_1); |
| _builder_3.append(_capitalize, ""); |
| _builder_3.append("("); |
| LEntityAttribute _attributeRef_1 = calculation.getAttributeRef(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("mockData.get(\""); |
| LEntityAttribute _attributeRef_2 = calculation.getAttributeRef(); |
| String _name_2 = _attributeRef_2.getName(); |
| _builder_4.append(_name_2, ""); |
| _builder_4.append("\")"); |
| String _baseMockDataTypeCasting = EntityMockDSLJvmModelInferrer.this.baseMockDataTypeCasting(_attributeRef_1, _builder_4.toString()); |
| _builder_3.append(_baseMockDataTypeCasting, ""); |
| _builder_3.append(");"); |
| _builder_3.newLineIfNotEmpty(); |
| it.append(_builder_3); |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("}"); |
| _builder_5.newLine(); |
| _builder_5.append("catch (Exception e) {"); |
| _builder_5.newLine(); |
| _builder_5.append(" "); |
| _builder_5.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_5.newLine(); |
| _builder_5.append("}"); |
| _builder_5.newLine(); |
| _builder_5.append("return entity;"); |
| it.append(_builder_5); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_4 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(pckg, _builder_7.toString(), _typeRef_7, _function_8); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_4); |
| } |
| } |
| }; |
| acceptor.<JvmGenericType>accept(_class, _function); |
| } |
| |
| public boolean isReferenceOnExistingDto(final EntityMockEntityFunctionParameter param) { |
| EObject _eContainer = param.eContainer(); |
| EObject _eContainer_1 = _eContainer.eContainer(); |
| final EntityMockEntity entityMock = ((EntityMockEntity) _eContainer_1); |
| EList<IEntityMockAttribute> _attributes = entityMock.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| if ((attribute instanceof EntityMockAttributeByReference)) { |
| EntityMockEntity _mockedEntity = ((EntityMockAttributeByReference)attribute).getMockedEntity(); |
| boolean _equals = Objects.equal(_mockedEntity, null); |
| if (_equals) { |
| LEntityReference _attributeRef = ((EntityMockAttributeByReference)attribute).getAttributeRef(); |
| LEntity _type = _attributeRef.getType(); |
| LEntityAttribute _referenceRef = param.getReferenceRef(); |
| EObject _eContainer_2 = _referenceRef.eContainer(); |
| boolean _equals_1 = _type.equals(_eContainer_2); |
| if (_equals_1) { |
| return true; |
| } |
| } |
| } |
| } |
| return false; |
| } |
| |
| public JvmTypeReference getJvmType(final EntityMockEntityFunctionParameter param) { |
| LEntityAttribute _attributeRef = param.getAttributeRef(); |
| boolean _notEquals = (!Objects.equal(_attributeRef, null)); |
| if (_notEquals) { |
| LEntityAttribute _attributeRef_1 = param.getAttributeRef(); |
| return this.jvmTypeRef(_attributeRef_1); |
| } else { |
| LEntityAttribute _referenceRef = param.getReferenceRef(); |
| return _referenceRef.getTypeJvm(); |
| } |
| } |
| |
| public String getParamName(final EntityMockEntityFunctionParameter param, final String separator) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String paramName = _builder.toString(); |
| LEntityAttribute _attributeRef = param.getAttributeRef(); |
| boolean _notEquals = (!Objects.equal(_attributeRef, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| LEntityAttribute _attributeRef_1 = param.getAttributeRef(); |
| String _name = _attributeRef_1.getName(); |
| _builder_1.append(_name, ""); |
| paramName = _builder_1.toString(); |
| } else { |
| EList<LEntityReference> _referencePaths = param.getReferencePaths(); |
| for (final LEntityReference referencePath : _referencePaths) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append(paramName, ""); |
| String _name_1 = referencePath.getName(); |
| _builder_2.append(_name_1, ""); |
| _builder_2.append(separator, ""); |
| paramName = _builder_2.toString(); |
| } |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(paramName, ""); |
| LEntityAttribute _referenceRef = param.getReferenceRef(); |
| String _name_2 = _referenceRef.getName(); |
| _builder_3.append(_name_2, ""); |
| paramName = _builder_3.toString(); |
| } |
| return paramName; |
| } |
| |
| /** |
| * generate the JVM type reference needed for of the entity attribute |
| */ |
| public JvmTypeReference jvmTypeRef(final LEntityAttribute attribute) { |
| IDataMart.EType etype = this.dtType.getBasicType(attribute); |
| if (etype != null) { |
| switch (etype) { |
| case BOOLEAN: |
| return this._typeReferenceBuilder.typeRef(boolean.class); |
| case BYTE: |
| return this._typeReferenceBuilder.typeRef(byte.class); |
| case DATE: |
| return this._typeReferenceBuilder.typeRef(Date.class); |
| case FLOAT: |
| return this._typeReferenceBuilder.typeRef(float.class); |
| case DOUBLE: |
| return this._typeReferenceBuilder.typeRef(double.class); |
| case SHORT: |
| return this._typeReferenceBuilder.typeRef(short.class); |
| case INTEGER: |
| return this._typeReferenceBuilder.typeRef(int.class); |
| case LONG: |
| return this._typeReferenceBuilder.typeRef(long.class); |
| case STRING: |
| return this._typeReferenceBuilder.typeRef(String.class); |
| default: |
| return this._typeReferenceBuilder.typeRef(Object.class); |
| } |
| } else { |
| return this._typeReferenceBuilder.typeRef(Object.class); |
| } |
| } |
| |
| /** |
| * generate the code for casting a mock data to the data type of the entity attribute |
| */ |
| public String baseMockDataTypeCasting(final LEntityAttribute attribute, final String getting) { |
| LScalarType _type = attribute.getType(); |
| if ((_type instanceof LEnum)) { |
| StringConcatenation _builder = new StringConcatenation(); |
| LScalarType _type_1 = attribute.getType(); |
| String _dtoFQNForLEnum = EntityUtils.getDtoFQNForLEnum(((LEnum) _type_1)); |
| _builder.append(_dtoFQNForLEnum, ""); |
| _builder.append(".valueOf("); |
| _builder.append(getting, ""); |
| _builder.append(".toString())"); |
| return _builder.toString(); |
| } |
| LScalarType _type_2 = attribute.getType(); |
| if ((_type_2 instanceof LBean)) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("("); |
| LScalarType _type_3 = attribute.getType(); |
| String _dtoFQNForLBean = EntityUtils.getDtoFQNForLBean(((LBean) _type_3)); |
| _builder_1.append(_dtoFQNForLBean, ""); |
| _builder_1.append(")("); |
| _builder_1.append(getting, ""); |
| _builder_1.append(")"); |
| return _builder_1.toString(); |
| } |
| IDataMart.EType etype = this.dtType.getBasicType(attribute); |
| if (etype != null) { |
| switch (etype) { |
| case BOOLEAN: |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("asBoolean("); |
| _builder_2.append(getting, ""); |
| _builder_2.append(")"); |
| return _builder_2.toString(); |
| case BYTE: |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("asByte("); |
| _builder_3.append(getting, ""); |
| _builder_3.append(")"); |
| return _builder_3.toString(); |
| case DATE: |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("asDate("); |
| _builder_4.append(getting, ""); |
| _builder_4.append(")"); |
| return _builder_4.toString(); |
| case FLOAT: |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("asFloat("); |
| _builder_5.append(getting, ""); |
| _builder_5.append(")"); |
| return _builder_5.toString(); |
| case DOUBLE: |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("asDouble("); |
| _builder_6.append(getting, ""); |
| _builder_6.append(")"); |
| return _builder_6.toString(); |
| case SHORT: |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("asShort("); |
| _builder_7.append(getting, ""); |
| _builder_7.append(")"); |
| return _builder_7.toString(); |
| case INTEGER: |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append("asInt("); |
| _builder_8.append(getting, ""); |
| _builder_8.append(")"); |
| return _builder_8.toString(); |
| case LONG: |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("asLong("); |
| _builder_9.append(getting, ""); |
| _builder_9.append(")"); |
| return _builder_9.toString(); |
| case TIME: |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("asTime("); |
| _builder_10.append(getting, ""); |
| _builder_10.append(")"); |
| return _builder_10.toString(); |
| default: |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("asString("); |
| _builder_11.append(getting, ""); |
| _builder_11.append(")"); |
| return _builder_11.toString(); |
| } |
| } else { |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("asString("); |
| _builder_11.append(getting, ""); |
| _builder_11.append(")"); |
| return _builder_11.toString(); |
| } |
| } |
| |
| public final static String ENTITY_MOCK_GENERATOR = "EntityMockGenerator"; |
| |
| public String asString(final org.eclipse.osbp.xtext.entitymock.Date date) { |
| boolean _isYesterday = date.isYesterday(); |
| if (_isYesterday) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("\"yesterday\""); |
| return _builder.toString(); |
| } |
| boolean _isToday = date.isToday(); |
| if (_isToday) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("\"today\""); |
| return _builder_1.toString(); |
| } |
| boolean _isTomorrow = date.isTomorrow(); |
| if (_isTomorrow) { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("\"tomorrow\""); |
| return _builder_2.toString(); |
| } |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("\""); |
| int _year = date.getYear(); |
| int _month = date.getMonth(); |
| int _day = date.getDay(); |
| String _format = String.format("%04d-%02d-%02d", Integer.valueOf(_year), Integer.valueOf(_month), Integer.valueOf(_day)); |
| String _plus = (_builder_3.toString() + _format); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("\""); |
| return (_plus + _builder_4); |
| } |
| |
| /** |
| * generate the main mock data generator for the EntityMockPackage |
| */ |
| public void generateMockDataGenerator(final EntityMockModel model, final IJvmDeclaredTypeAcceptor acceptor, final EntityMockPackage pckg) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| _builder.append(EntityMockDSLJvmModelInferrer.ENTITY_MOCK_GENERATOR, ""); |
| JvmGenericType _class = this._jvmTypesBuilder.toClass(model, _builder.toString()); |
| final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(AEntityMockDataGenerator.class); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| it.setFinal(true); |
| JvmField field = null; |
| JvmTypeReference _typeRef_1 = EntityMockDSLJvmModelInferrer.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("LoggerFactory.getLogger("); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| _builder.append(EntityMockDSLJvmModelInferrer.ENTITY_MOCK_GENERATOR, ""); |
| _builder.append(".class)"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(model, "log", _typeRef_1, _function); |
| field = _field; |
| field.setFinal(true); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| EList<JvmMember> _members_1 = it.getMembers(); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("getRunWithPriority"); |
| JvmTypeReference _typeRef_2 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(int.class); |
| final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toAnnotation(pckg, Override.class); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotation); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| int count = IEntityMockDataGenerator.DEFAULT_PRIORITY; |
| int _runPriority = pckg.getRunPriority(); |
| boolean _greaterThan = (_runPriority > 0); |
| if (_greaterThan) { |
| int _runPriority_1 = pckg.getRunPriority(); |
| count = _runPriority_1; |
| } |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return "); |
| _builder.append(count, ""); |
| _builder.append(";"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(model, _builder.toString(), _typeRef_2, _function_1); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method); |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("getDataInterchangeSteps"); |
| JvmTypeReference _typeRef_3 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(int.class); |
| final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toAnnotation(pckg, Override.class); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotation); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| int count = 0; |
| RunningDataInterchanges _datainterchanges = pckg.getDatainterchanges(); |
| boolean _notEquals = (!Objects.equal(_datainterchanges, null)); |
| if (_notEquals) { |
| RunningDataInterchanges _datainterchanges_1 = pckg.getDatainterchanges(); |
| EList<RunningDataInterchange> _datainterchanges_2 = _datainterchanges_1.getDatainterchanges(); |
| int _size = _datainterchanges_2.size(); |
| count = _size; |
| } |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return "); |
| _builder.append(count, ""); |
| _builder.append(";"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(model, _builder_1.toString(), _typeRef_3, _function_2); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_1); |
| EList<JvmMember> _members_3 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("getEntityMockSteps"); |
| JvmTypeReference _typeRef_4 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(int.class); |
| final Procedure1<JvmOperation> _function_3 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toAnnotation(pckg, Override.class); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotation); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| int count = 0; |
| EntityMockEntities _entities = pckg.getEntities(); |
| boolean _notEquals = (!Objects.equal(_entities, null)); |
| if (_notEquals) { |
| EntityMockEntities _entities_1 = pckg.getEntities(); |
| EList<EntityMockEntity> _entities_2 = _entities_1.getEntities(); |
| int _size = _entities_2.size(); |
| count = _size; |
| } |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return "); |
| _builder.append(count, ""); |
| _builder.append(";"); |
| _builder.newLineIfNotEmpty(); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_2 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(model, _builder_2.toString(), _typeRef_4, _function_3); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_2); |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("runDataInterchanges"); |
| JvmTypeReference _typeRef_5 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_4 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| JvmFormalParameter _parameter = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(pckg, "persistenceService", _typeRef); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IEntityMockDataDbFiller.class); |
| JvmFormalParameter _parameter_1 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(pckg, "entityMockDbFiller", _typeRef_1); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| RunningDataInterchanges _datainterchanges = pckg.getDatainterchanges(); |
| boolean _notEquals = (!Objects.equal(_datainterchanges, null)); |
| if (_notEquals) { |
| RunningDataInterchanges _datainterchanges_1 = pckg.getDatainterchanges(); |
| EList<RunningDataInterchange> _datainterchanges_2 = _datainterchanges_1.getDatainterchanges(); |
| for (final RunningDataInterchange runDatainterchange : _datainterchanges_2) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("entityMockDbFiller.notifyInitializationStep(\"datainterchange "); |
| DataInterchange _datainterchangeRef = runDatainterchange.getDatainterchangeRef(); |
| String _name = _datainterchangeRef.getName(); |
| _builder.append(_name, "\t"); |
| _builder.append("\", 1, 0.3);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| DataInterchange _datainterchangeRef_1 = runDatainterchange.getDatainterchangeRef(); |
| String _fileURL = runDatainterchange.getFileURL(); |
| String _basicRunConfiguration = EntityMockDSLJvmModelInferrer.this._dataDSLJvmModelInferrer.getBasicRunConfiguration(_datainterchangeRef_1, true, _fileURL); |
| _builder.append(_basicRunConfiguration, "\t"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("entityMockDbFiller.notifyInitializationStep(\"datainterchange "); |
| DataInterchange _datainterchangeRef_2 = runDatainterchange.getDatainterchangeRef(); |
| String _name_1 = _datainterchangeRef_2.getName(); |
| _builder.append(_name_1, "\t"); |
| _builder.append("\", 0, 0.4);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| DataInterchange _datainterchangeRef_3 = runDatainterchange.getDatainterchangeRef(); |
| String _defaultVariableName = EntityMockDSLJvmModelInferrer.this._dataDSLJvmModelInferrer.getDefaultVariableName(_datainterchangeRef_3); |
| _builder.append(_defaultVariableName, "\t"); |
| _builder.append(".run(entityMockDbFiller);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("\t"); |
| _builder.append("entityMockDbFiller.notifyInitializationStep(\"datainterchange "); |
| DataInterchange _datainterchangeRef_4 = runDatainterchange.getDatainterchangeRef(); |
| String _name_2 = _datainterchangeRef_4.getName(); |
| _builder.append(_name_2, "\t"); |
| _builder.append("\", 0, 0.9);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("} "); |
| _builder.newLine(); |
| _builder.append("catch (Exception e) {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder.newLine(); |
| _builder.append("}"); |
| _builder.newLine(); |
| it.append(_builder); |
| } |
| } |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_3 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(model, _builder_3.toString(), _typeRef_5, _function_4); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_3); |
| EList<JvmMember> _members_5 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("getMockData"); |
| JvmTypeReference _typeRef_6 = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(Map.class); |
| final Procedure1<JvmOperation> _function_5 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(IEntityMockDataDbFiller.class); |
| JvmFormalParameter _parameter = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toParameter(pckg, "entityMockDbFiller", _typeRef); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("initialize();"); |
| _builder.newLine(); |
| it.append(_builder); |
| ArrayList<EntityMockEntity> mockEntitiesDone = new ArrayList<EntityMockEntity>(); |
| ArrayList<EntityMockEntity> mockEntitiesToDo = new ArrayList<EntityMockEntity>(); |
| EntityMockEntities _entities = pckg.getEntities(); |
| EList<EntityMockEntity> _entities_1 = null; |
| if (_entities!=null) { |
| _entities_1=_entities.getEntities(); |
| } |
| mockEntitiesToDo.addAll(_entities_1); |
| boolean breakTodo = false; |
| while (((!mockEntitiesToDo.isEmpty()) && (!breakTodo))) { |
| { |
| int handled = 0; |
| Object[] mockEntitesStepping = mockEntitiesToDo.toArray(); |
| for (final Object mockEntityO : mockEntitesStepping) { |
| { |
| EntityMockEntity mockEntity = ((EntityMockEntity) mockEntityO); |
| boolean _canBeHandled = EntityMockDSLJvmModelInferrer.this.canBeHandled(mockEntity, mockEntitiesDone); |
| if (_canBeHandled) { |
| handled++; |
| IIterate _iterate = mockEntity.getIterate(); |
| if ((_iterate instanceof IntegerIterate)) { |
| IIterate _iterate_1 = mockEntity.getIterate(); |
| IntegerIterate iterate = ((IntegerIterate) _iterate_1); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_1.append(_entityMockName, ""); |
| _builder_1.append("\", 1, 0.3);"); |
| _builder_1.newLineIfNotEmpty(); |
| String _entityMockName_1 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_1.append(_entityMockName_1, ""); |
| _builder_1.append(" entity"); |
| String _name = mockEntity.getName(); |
| _builder_1.append(_name, ""); |
| _builder_1.append(" = new "); |
| String _entityMockName_2 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_1.append(_entityMockName_2, ""); |
| _builder_1.append("(this);"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("Iterator<Integer> iterator"); |
| String _name_1 = mockEntity.getName(); |
| _builder_1.append(_name_1, ""); |
| _builder_1.append(" = new IntegerIterator("); |
| int _from = iterate.getFrom(); |
| _builder_1.append(_from, ""); |
| _builder_1.append(", "); |
| int _until = iterate.getUntil(); |
| _builder_1.append(_until, ""); |
| _builder_1.append(", "); |
| int _step = iterate.getStep(); |
| _builder_1.append(_step, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("List list"); |
| String _name_2 = mockEntity.getName(); |
| _builder_1.append(_name_2, ""); |
| _builder_1.append(" = new ArrayList<"); |
| String _entityDtoFQN = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder_1.append(_entityDtoFQN, ""); |
| _builder_1.append(">();"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_3 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_1.append(_entityMockName_3, ""); |
| _builder_1.append("\", 0, 0.6);"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("while (iterator"); |
| String _name_3 = mockEntity.getName(); |
| _builder_1.append(_name_3, ""); |
| _builder_1.append(".hasNext()) {"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append(" "); |
| _builder_1.append("list"); |
| String _name_4 = mockEntity.getName(); |
| _builder_1.append(_name_4, " "); |
| _builder_1.append(".add(entity"); |
| String _name_5 = mockEntity.getName(); |
| _builder_1.append(_name_5, " "); |
| _builder_1.append(".generateEntity(iterator"); |
| String _name_6 = mockEntity.getName(); |
| _builder_1.append(_name_6, " "); |
| _builder_1.append(".next()));"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("}"); |
| _builder_1.newLine(); |
| _builder_1.append("addMockObjects(\""); |
| String _name_7 = mockEntity.getName(); |
| _builder_1.append(_name_7, ""); |
| _builder_1.append("\", "); |
| String _entityDtoFQNClass = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQNClass(mockEntity); |
| _builder_1.append(_entityDtoFQNClass, ""); |
| _builder_1.append(", \""); |
| LEntity _entityRef = mockEntity.getEntityRef(); |
| String _persistenceUnit = _entityRef.getPersistenceUnit(); |
| _builder_1.append(_persistenceUnit, ""); |
| _builder_1.append("\", list"); |
| String _name_8 = mockEntity.getName(); |
| _builder_1.append(_name_8, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| _builder_1.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_4 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_1.append(_entityMockName_4, ""); |
| _builder_1.append("\", 0, 0.9);"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| } |
| IIterate _iterate_2 = mockEntity.getIterate(); |
| if ((_iterate_2 instanceof DateIterate)) { |
| IIterate _iterate_3 = mockEntity.getIterate(); |
| DateIterate iterate_1 = ((DateIterate) _iterate_3); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_5 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_2.append(_entityMockName_5, ""); |
| _builder_2.append("\", 1, 0.3);"); |
| _builder_2.newLineIfNotEmpty(); |
| String _entityMockName_6 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_2.append(_entityMockName_6, ""); |
| _builder_2.append(" entity"); |
| String _name_9 = mockEntity.getName(); |
| _builder_2.append(_name_9, ""); |
| _builder_2.append(" = new "); |
| String _entityMockName_7 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_2.append(_entityMockName_7, ""); |
| _builder_2.append("(this);"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("Iterator<Date> iterator"); |
| String _name_10 = mockEntity.getName(); |
| _builder_2.append(_name_10, ""); |
| _builder_2.append(" = new DateIterator("); |
| org.eclipse.osbp.xtext.entitymock.Date _from_1 = iterate_1.getFrom(); |
| String _asString = EntityMockDSLJvmModelInferrer.this.asString(_from_1); |
| _builder_2.append(_asString, ""); |
| _builder_2.append(", "); |
| org.eclipse.osbp.xtext.entitymock.Date _until_1 = iterate_1.getUntil(); |
| String _asString_1 = EntityMockDSLJvmModelInferrer.this.asString(_until_1); |
| _builder_2.append(_asString_1, ""); |
| _builder_2.append(", "); |
| int _stepCount = iterate_1.getStepCount(); |
| _builder_2.append(_stepCount, ""); |
| _builder_2.append(", \""); |
| EDateStepType _stepType = iterate_1.getStepType(); |
| _builder_2.append(_stepType, ""); |
| _builder_2.append("\");"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("List list"); |
| String _name_11 = mockEntity.getName(); |
| _builder_2.append(_name_11, ""); |
| _builder_2.append(" = new ArrayList<"); |
| String _entityDtoFQN_1 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder_2.append(_entityDtoFQN_1, ""); |
| _builder_2.append(">();"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_8 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_2.append(_entityMockName_8, ""); |
| _builder_2.append("\", 0, 0.6);"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("while (iterator"); |
| String _name_12 = mockEntity.getName(); |
| _builder_2.append(_name_12, ""); |
| _builder_2.append(".hasNext()) {"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append(" "); |
| _builder_2.append("list"); |
| String _name_13 = mockEntity.getName(); |
| _builder_2.append(_name_13, " "); |
| _builder_2.append(".add(entity"); |
| String _name_14 = mockEntity.getName(); |
| _builder_2.append(_name_14, " "); |
| _builder_2.append(".generateEntity(iterator"); |
| String _name_15 = mockEntity.getName(); |
| _builder_2.append(_name_15, " "); |
| _builder_2.append(".next()));"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("}"); |
| _builder_2.newLine(); |
| _builder_2.append("addMockObjects(\""); |
| String _name_16 = mockEntity.getName(); |
| _builder_2.append(_name_16, ""); |
| _builder_2.append("\", "); |
| String _entityDtoFQNClass_1 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQNClass(mockEntity); |
| _builder_2.append(_entityDtoFQNClass_1, ""); |
| _builder_2.append(", \""); |
| LEntity _entityRef_1 = mockEntity.getEntityRef(); |
| String _persistenceUnit_1 = _entityRef_1.getPersistenceUnit(); |
| _builder_2.append(_persistenceUnit_1, ""); |
| _builder_2.append("\", list"); |
| String _name_17 = mockEntity.getName(); |
| _builder_2.append(_name_17, ""); |
| _builder_2.append(");"); |
| _builder_2.newLineIfNotEmpty(); |
| _builder_2.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_9 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_2.append(_entityMockName_9, ""); |
| _builder_2.append("\", 0, 0.9);"); |
| _builder_2.newLineIfNotEmpty(); |
| it.append(_builder_2); |
| } else { |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| boolean _notEquals = (!Objects.equal(_byResource, null)); |
| if (_notEquals) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_10 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_3.append(_entityMockName_10, ""); |
| _builder_3.append("\", 1, 0.3);"); |
| _builder_3.newLineIfNotEmpty(); |
| String _entityMockName_11 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_3.append(_entityMockName_11, ""); |
| _builder_3.append(" entity"); |
| String _name_18 = mockEntity.getName(); |
| _builder_3.append(_name_18, ""); |
| _builder_3.append(" = new "); |
| String _entityMockName_12 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_3.append(_entityMockName_12, ""); |
| _builder_3.append("(this);"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("List list"); |
| String _name_19 = mockEntity.getName(); |
| _builder_3.append(_name_19, ""); |
| _builder_3.append(" = new ArrayList<"); |
| String _entityDtoFQN_2 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder_3.append(_entityDtoFQN_2, ""); |
| _builder_3.append(">();"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("Iterator iterator"); |
| String _name_20 = mockEntity.getName(); |
| _builder_3.append(_name_20, ""); |
| _builder_3.append(" = entity"); |
| String _name_21 = mockEntity.getName(); |
| _builder_3.append(_name_21, ""); |
| _builder_3.append(".getDataRows().iterator();"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_13 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_3.append(_entityMockName_13, ""); |
| _builder_3.append("\", 0, 0.6);"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("while (iterator"); |
| String _name_22 = mockEntity.getName(); |
| _builder_3.append(_name_22, ""); |
| _builder_3.append(".hasNext()) {"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append(" "); |
| _builder_3.append("list"); |
| String _name_23 = mockEntity.getName(); |
| _builder_3.append(_name_23, " "); |
| _builder_3.append(".add(entity"); |
| String _name_24 = mockEntity.getName(); |
| _builder_3.append(_name_24, " "); |
| _builder_3.append(".generateEntity(iterator"); |
| String _name_25 = mockEntity.getName(); |
| _builder_3.append(_name_25, " "); |
| _builder_3.append(".next()));"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("}"); |
| _builder_3.newLine(); |
| _builder_3.append("addMockObjects(\""); |
| String _name_26 = mockEntity.getName(); |
| _builder_3.append(_name_26, ""); |
| _builder_3.append("\", "); |
| String _entityDtoFQNClass_2 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQNClass(mockEntity); |
| _builder_3.append(_entityDtoFQNClass_2, ""); |
| _builder_3.append(", \""); |
| LEntity _entityRef_2 = mockEntity.getEntityRef(); |
| String _persistenceUnit_2 = _entityRef_2.getPersistenceUnit(); |
| _builder_3.append(_persistenceUnit_2, ""); |
| _builder_3.append("\", list"); |
| String _name_27 = mockEntity.getName(); |
| _builder_3.append(_name_27, ""); |
| _builder_3.append(");"); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_14 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_3.append(_entityMockName_14, ""); |
| _builder_3.append("\", 0, 0.9);"); |
| _builder_3.newLineIfNotEmpty(); |
| it.append(_builder_3); |
| boolean _isCreateBlobMapping = mockEntity.isCreateBlobMapping(); |
| if (_isCreateBlobMapping) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_15 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_4.append(_entityMockName_15, ""); |
| _builder_4.append("Blobs\", 0, 0.93);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("List list"); |
| String _name_28 = mockEntity.getName(); |
| _builder_4.append(_name_28, ""); |
| _builder_4.append("Blobs = new ArrayList<org.eclipse.osbp.utils.blob.dtos.BlobDto>();"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("BlobTypingAPI "); |
| String _name_29 = mockEntity.getName(); |
| _builder_4.append(_name_29, ""); |
| _builder_4.append("BlobTypingAPI = new BlobTypingAPI();"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("BlobUpload "); |
| String _name_30 = mockEntity.getName(); |
| _builder_4.append(_name_30, ""); |
| _builder_4.append("BlobUpload = new BlobUpload();"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_16 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_4.append(_entityMockName_16, ""); |
| _builder_4.append("Blobs\", 0, 0.96);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("for (Object list"); |
| String _name_31 = mockEntity.getName(); |
| _builder_4.append(_name_31, ""); |
| _builder_4.append("Object : list"); |
| String _name_32 = mockEntity.getName(); |
| _builder_4.append(_name_32, ""); |
| _builder_4.append(") {"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append(" "); |
| _builder_4.append("if (list"); |
| String _name_33 = mockEntity.getName(); |
| _builder_4.append(_name_33, " "); |
| _builder_4.append("Object instanceof org.eclipse.osbp.utils.blob.dtos.BlobMappingDto) {"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append(" "); |
| _builder_4.append("org.eclipse.osbp.utils.blob.dtos.BlobMappingDto blobMappingDto = (org.eclipse.osbp.utils.blob.dtos.BlobMappingDto)list"); |
| String _name_34 = mockEntity.getName(); |
| _builder_4.append(_name_34, " "); |
| _builder_4.append("Object;"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append(" "); |
| _builder_4.append("try {"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("InputStream inputStream = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(\"/resources/entitymock/\"+blobMappingDto.getFileName()));"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("if (inputStream != null) {"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("List<org.eclipse.osbp.utils.blob.dtos.BlobDto> blobs = "); |
| String _name_35 = mockEntity.getName(); |
| _builder_4.append(_name_35, " "); |
| _builder_4.append("BlobUpload.createBlobMappingBlobs("); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append(" "); |
| _builder_4.append("inputStream,"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| String _name_36 = mockEntity.getName(); |
| _builder_4.append(_name_36, " "); |
| _builder_4.append("BlobTypingAPI.getMimeTypeContentTypeById(blobMappingDto.getMimeTypeId()),"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append(" "); |
| String _name_37 = mockEntity.getName(); |
| _builder_4.append(_name_37, " "); |
| _builder_4.append("BlobTypingAPI,"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append(" "); |
| _builder_4.append("blobMappingDto.getId()"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append(");"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("blobMappingDto.setBlobsRef(blobs);"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("for (org.eclipse.osbp.utils.blob.dtos.BlobDto blob : blobs) {"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("list"); |
| String _name_38 = mockEntity.getName(); |
| _builder_4.append(_name_38, " "); |
| _builder_4.append("Blobs.add(blob);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append(" "); |
| _builder_4.append("}"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("}"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("}"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("catch (Exception e) {"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("}"); |
| _builder_4.newLine(); |
| _builder_4.append(" "); |
| _builder_4.append("}"); |
| _builder_4.newLine(); |
| _builder_4.append("}"); |
| _builder_4.newLine(); |
| _builder_4.append("addMockObjects(\""); |
| String _name_39 = mockEntity.getName(); |
| _builder_4.append(_name_39, ""); |
| _builder_4.append("Blobs\", org.eclipse.osbp.utils.blob.dtos.BlobDto.class, \"blob\", list"); |
| String _name_40 = mockEntity.getName(); |
| _builder_4.append(_name_40, ""); |
| _builder_4.append("Blobs);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_17 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_4.append(_entityMockName_17, ""); |
| _builder_4.append("Blobs\", 0, 0.99);"); |
| _builder_4.newLineIfNotEmpty(); |
| it.append(_builder_4); |
| } |
| } else { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_18 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_5.append(_entityMockName_18, ""); |
| _builder_5.append("\", 1, 0.3);"); |
| _builder_5.newLineIfNotEmpty(); |
| String _entityMockName_19 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_5.append(_entityMockName_19, ""); |
| _builder_5.append(" entity"); |
| String _name_41 = mockEntity.getName(); |
| _builder_5.append(_name_41, ""); |
| _builder_5.append(" = new "); |
| String _entityMockName_20 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_5.append(_entityMockName_20, ""); |
| _builder_5.append("(this);"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append("Iterator<Integer> iterator"); |
| String _name_42 = mockEntity.getName(); |
| _builder_5.append(_name_42, ""); |
| _builder_5.append(" = new IntegerIterator(1, fillerProvider.signedinteger("); |
| int _minRows = mockEntity.getMinRows(); |
| _builder_5.append(_minRows, ""); |
| _builder_5.append(", "); |
| int _maxRows = mockEntity.getMaxRows(); |
| _builder_5.append(_maxRows, ""); |
| _builder_5.append("));"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append("List list"); |
| String _name_43 = mockEntity.getName(); |
| _builder_5.append(_name_43, ""); |
| _builder_5.append(" = new ArrayList<"); |
| String _entityDtoFQN_3 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQN(mockEntity); |
| _builder_5.append(_entityDtoFQN_3, ""); |
| _builder_5.append(">();"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_21 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_5.append(_entityMockName_21, ""); |
| _builder_5.append("\", 0, 0.6);"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append("while (iterator"); |
| String _name_44 = mockEntity.getName(); |
| _builder_5.append(_name_44, ""); |
| _builder_5.append(".hasNext()) {"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append(" "); |
| _builder_5.append("list"); |
| String _name_45 = mockEntity.getName(); |
| _builder_5.append(_name_45, " "); |
| _builder_5.append(".add(entity"); |
| String _name_46 = mockEntity.getName(); |
| _builder_5.append(_name_46, " "); |
| _builder_5.append(".generateEntity(iterator"); |
| String _name_47 = mockEntity.getName(); |
| _builder_5.append(_name_47, " "); |
| _builder_5.append(".next()));"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append("}"); |
| _builder_5.newLine(); |
| _builder_5.append("addMockObjects(\""); |
| String _name_48 = mockEntity.getName(); |
| _builder_5.append(_name_48, ""); |
| _builder_5.append("\", "); |
| String _entityDtoFQNClass_3 = EntityMockDSLJvmModelInferrer.this.getEntityDtoFQNClass(mockEntity); |
| _builder_5.append(_entityDtoFQNClass_3, ""); |
| _builder_5.append(", \""); |
| LEntity _entityRef_3 = mockEntity.getEntityRef(); |
| String _persistenceUnit_3 = _entityRef_3.getPersistenceUnit(); |
| _builder_5.append(_persistenceUnit_3, ""); |
| _builder_5.append("\", list"); |
| String _name_49 = mockEntity.getName(); |
| _builder_5.append(_name_49, ""); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_22 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockEntity); |
| _builder_5.append(_entityMockName_22, ""); |
| _builder_5.append("\", 0, 0.9);"); |
| _builder_5.newLineIfNotEmpty(); |
| it.append(_builder_5); |
| } |
| } |
| mockEntitiesDone.add(((EntityMockEntity) mockEntity)); |
| mockEntitiesToDo.remove(mockEntity); |
| } |
| } |
| } |
| breakTodo = (handled == 0); |
| } |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return mockDataClassMap;"); |
| it.append(_builder_1); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_4 = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toMethod(pckg, _builder_4.toString(), _typeRef_6, _function_5); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_4); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(_class, _function); |
| } |
| |
| /** |
| * The dispatch method {@code infer} is called for each instance of the |
| * given element's type that is contained in a resource. |
| * |
| * @param element |
| * the model to create one or more |
| * {@link JvmDeclaredType declared |
| * types} from. |
| * @param acceptor |
| * each created |
| * {@link JvmDeclaredType type} |
| * without a container should be passed to the acceptor in order |
| * get attached to the current resource. The acceptor's |
| * {@link IJvmDeclaredTypeAcceptor#accept(org.eclipse.xtext.common.types.JvmDeclaredType) |
| * accept(..)} method takes the constructed empty type for the |
| * pre-indexing phase. This one is further initialized in the |
| * indexing phase using the closure you pass to the returned |
| * {@link IPostIndexingInitializing#initializeLater(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) |
| * initializeLater(..)}. |
| * @param isPreIndexingPhase |
| * whether the method is called in a pre-indexing phase, i.e. |
| * when the global index is not yet fully updated. You must not |
| * rely on linking using the index if isPreIndexingPhase is |
| * <code>true</code>. |
| */ |
| protected void _infer(final EntityMockModel model, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| EList<EntityMockPackage> _packages = model.getPackages(); |
| final Consumer<EntityMockPackage> _function = new Consumer<EntityMockPackage>() { |
| public void accept(final EntityMockPackage pckg) { |
| EntityMockResources _resources = pckg.getResources(); |
| EList<EntityMockResource> _resources_1 = null; |
| if (_resources!=null) { |
| _resources_1=_resources.getResources(); |
| } |
| if (_resources_1!=null) { |
| final Consumer<EntityMockResource> _function = new Consumer<EntityMockResource>() { |
| public void accept(final EntityMockResource mockResource) { |
| try { |
| EntityMockDSLJvmModelInferrer.this.generateMockResource(model, acceptor, pckg, mockResource); |
| } catch (final Throwable _t) { |
| if (_t instanceof Exception) { |
| final Exception e = (Exception)_t; |
| e.printStackTrace(); |
| } else { |
| throw Exceptions.sneakyThrow(_t); |
| } |
| } |
| } |
| }; |
| _resources_1.forEach(_function); |
| } |
| EntityMockObjects _objects = pckg.getObjects(); |
| EList<EntityMockObject> _objects_1 = null; |
| if (_objects!=null) { |
| _objects_1=_objects.getObjects(); |
| } |
| if (_objects_1!=null) { |
| final Consumer<EntityMockObject> _function_1 = new Consumer<EntityMockObject>() { |
| public void accept(final EntityMockObject mockObject) { |
| try { |
| EntityMockDSLJvmModelInferrer.this.generateMockObject(model, acceptor, pckg, mockObject); |
| } catch (final Throwable _t) { |
| if (_t instanceof Exception) { |
| final Exception e = (Exception)_t; |
| e.printStackTrace(); |
| } else { |
| throw Exceptions.sneakyThrow(_t); |
| } |
| } |
| } |
| }; |
| _objects_1.forEach(_function_1); |
| } |
| EntityMockEntities _entities = pckg.getEntities(); |
| EList<EntityMockEntity> _entities_1 = null; |
| if (_entities!=null) { |
| _entities_1=_entities.getEntities(); |
| } |
| if (_entities_1!=null) { |
| final Consumer<EntityMockEntity> _function_2 = new Consumer<EntityMockEntity>() { |
| public void accept(final EntityMockEntity mockEntity) { |
| try { |
| EntityMockDSLJvmModelInferrer.this.generateMockEntity(model, acceptor, pckg, mockEntity); |
| } catch (final Throwable _t) { |
| if (_t instanceof Exception) { |
| final Exception e = (Exception)_t; |
| e.printStackTrace(); |
| } else { |
| throw Exceptions.sneakyThrow(_t); |
| } |
| } |
| } |
| }; |
| _entities_1.forEach(_function_2); |
| } |
| try { |
| EntityMockDSLJvmModelInferrer.this.generateMockDataGenerator(model, acceptor, pckg); |
| } catch (final Throwable _t) { |
| if (_t instanceof Exception) { |
| final Exception e = (Exception)_t; |
| e.printStackTrace(); |
| } else { |
| throw Exceptions.sneakyThrow(_t); |
| } |
| } |
| } |
| }; |
| _packages.forEach(_function); |
| } |
| |
| /** |
| * checks if the mockEntityTodo can be handled, considering all requested references to other mock entities, |
| * which may already been mocked |
| */ |
| public boolean canBeHandled(final EntityMockEntity mockEntityTodo, final ArrayList<EntityMockEntity> mockEntitiesDone) { |
| EntityMockResource _byResource = mockEntityTodo.getByResource(); |
| boolean _notEquals = (!Objects.equal(_byResource, null)); |
| if (_notEquals) { |
| return true; |
| } |
| EList<IEntityMockAttribute> _attributes = mockEntityTodo.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| if ((attribute instanceof EntityMockAttributeByReference)) { |
| EntityMockEntity referencedMockEntity = ((EntityMockAttributeByReference) attribute).getMockedEntity(); |
| boolean _and = false; |
| boolean _notEquals_1 = (!Objects.equal(referencedMockEntity, null)); |
| if (!_notEquals_1) { |
| _and = false; |
| } else { |
| boolean _contains = mockEntitiesDone.contains(referencedMockEntity); |
| boolean _not = (!_contains); |
| _and = _not; |
| } |
| if (_and) { |
| return false; |
| } |
| } |
| } |
| return true; |
| } |
| |
| /** |
| * generate a mock object class |
| */ |
| public void generateMockResource(final EntityMockModel model, final IJvmDeclaredTypeAcceptor acceptor, final EntityMockPackage pckg, final EntityMockResource mockResource) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| String _entityMockName_1 = this.getEntityMockName(mockResource); |
| _builder.append(_entityMockName_1, ""); |
| JvmGenericType _class = this._jvmTypesBuilder.toClass(model, _builder.toString()); |
| final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = EntityMockDSLJvmModelInferrer.this._typeReferenceBuilder.typeRef(ABaseMockResource.class); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("<b>This class was auto generated! Leave it unmodified to avoid unpredictable results!</b><br>"); |
| _builder.newLine(); |
| String _documentation = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.getDocumentation(mockResource); |
| _builder.append(_documentation, ""); |
| _builder.newLineIfNotEmpty(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setDocumentation(it, _builder.toString()); |
| it.setFinal(true); |
| JvmField field = null; |
| JvmTypeReference _typeRef_1 = EntityMockDSLJvmModelInferrer.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("LoggerFactory.getLogger("); |
| String _entityMockName = EntityMockDSLJvmModelInferrer.getEntityMockName(pckg); |
| _builder.append(_entityMockName, ""); |
| _builder.append("."); |
| String _entityMockName_1 = EntityMockDSLJvmModelInferrer.this.getEntityMockName(mockResource); |
| _builder.append(_entityMockName_1, ""); |
| _builder.append(".class)"); |
| it.append(_builder); |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toField(model, "log", _typeRef_1, _function); |
| field = _field; |
| field.setFinal(true); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| EList<JvmMember> _members_1 = it.getMembers(); |
| final Procedure1<JvmConstructor> _function_1 = new Procedure1<JvmConstructor>() { |
| public void apply(final JvmConstructor it) { |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| final List<String> attributes = new ArrayList<String>(); |
| EList<EntityMockResourceAttribute> _attributes = mockResource.getAttributes(); |
| for (final EntityMockResourceAttribute attribute : _attributes) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("\""); |
| String _name = attribute.getName(); |
| _builder.append(_name, ""); |
| _builder.append("\""); |
| attributes.add(_builder.toString()); |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("setAttributes("); |
| String _join = StringUtils.join(attributes, ","); |
| _builder_1.append(_join, ""); |
| _builder_1.append(");"); |
| _builder_1.newLineIfNotEmpty(); |
| it.append(_builder_1); |
| EList<EntityMockResourceDataRow> _datarows = mockResource.getDatarows(); |
| for (final EntityMockResourceDataRow datarow : _datarows) { |
| { |
| final List<String> values = new ArrayList<String>(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("\""); |
| String _name_1 = datarow.getName(); |
| _builder_2.append(_name_1, ""); |
| _builder_2.append("\""); |
| values.add(_builder_2.toString()); |
| EList<String> _values = datarow.getValues(); |
| for (final String value : _values) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("\""); |
| _builder_3.append(value, ""); |
| _builder_3.append("\""); |
| values.add(_builder_3.toString()); |
| } |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("addDataRow("); |
| String _join_1 = StringUtils.join(values, ","); |
| _builder_4.append(_join_1, ""); |
| _builder_4.append(");"); |
| _builder_4.newLineIfNotEmpty(); |
| it.append(_builder_4); |
| } |
| } |
| } |
| }; |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmConstructor _constructor = EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.toConstructor(pckg, _function_1); |
| EntityMockDSLJvmModelInferrer.this._jvmTypesBuilder.<JvmConstructor>operator_add(_members_1, _constructor); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(_class, _function); |
| } |
| |
| public void infer(final EObject model, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| if (model instanceof EntityMockModel) { |
| _infer((EntityMockModel)model, acceptor, isPreIndexingPhase); |
| return; |
| } else if (model != null) { |
| _infer(model, acceptor, isPreIndexingPhase); |
| return; |
| } else { |
| throw new IllegalArgumentException("Unhandled parameter types: " + |
| Arrays.<Object>asList(model, acceptor, isPreIndexingPhase).toString()); |
| } |
| } |
| } |