| /** |
| * 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 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * 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.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.core.api.persistence.IPersistenceService; |
| import org.eclipse.osbp.datainterchange.api.IDataInterchange; |
| import org.eclipse.osbp.dsl.entity.xtext.extensions.ModelExtensions; |
| 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.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.runtime.common.event.IEventDispatcher; |
| import org.eclipse.osbp.ui.api.customfields.IBlobService; |
| import org.eclipse.osbp.ui.api.datamart.IDataMart; |
| import org.eclipse.osbp.utils.annotation.CommonUtils; |
| import org.eclipse.osbp.utils.common.EntityUtils; |
| import org.eclipse.osbp.utils.entityhelper.DataType; |
| import org.eclipse.osbp.xtext.datainterchange.jvmmodel.DataDSLJvmModelInferrer; |
| import org.eclipse.osbp.xtext.entitymock.CompleteYearFiller; |
| import org.eclipse.osbp.xtext.entitymock.DateIterate; |
| import org.eclipse.osbp.xtext.entitymock.EDateStepType; |
| import org.eclipse.osbp.xtext.entitymock.EntityMock; |
| 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.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.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.EntityMockTemplate; |
| 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.PropertyFillerDateType; |
| 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.osbp.xtext.entitymock.common.ABaseMockEntity; |
| import org.eclipse.osbp.xtext.entitymock.common.ABaseMockObject; |
| import org.eclipse.osbp.xtext.entitymock.common.ABaseMockResource; |
| import org.eclipse.osbp.xtext.entitymock.common.AEntityMockDataGenerator; |
| import org.eclipse.osbp.xtext.entitymock.common.IEntityMockDataDbFiller; |
| import org.eclipse.osbp.xtext.entitymock.common.IEntityMockDataGenerator; |
| 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.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.naming.IQualifiedNameProvider; |
| 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.osgi.service.component.annotations.Component; |
| 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("restriction") |
| 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 IQualifiedNameProvider _iQualifiedNameProvider; |
| |
| @Inject |
| @Extension |
| private EntityUtils _entityUtils; |
| |
| @Inject |
| private ModelExtensions entityExtensions; |
| |
| @Inject |
| @Extension |
| private CommonUtils _commonUtils; |
| |
| @Inject |
| private DataType dtType; |
| |
| /** |
| * The dispatch method {@code infer} is called for each instance of the |
| * given element's type that is contained in a resource. |
| */ |
| protected void _infer(final EntityMock mock, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| EntityMockResources _resources = mock.getResources(); |
| EList<EntityMockResource> _resources_1 = null; |
| if (_resources!=null) { |
| _resources_1=_resources.getResources(); |
| } |
| if (_resources_1!=null) { |
| final Consumer<EntityMockResource> _function = (EntityMockResource mockResource) -> { |
| try { |
| this.generateMockResource(mock, acceptor, 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 = mock.getObjects(); |
| EList<EntityMockObject> _objects_1 = null; |
| if (_objects!=null) { |
| _objects_1=_objects.getObjects(); |
| } |
| if (_objects_1!=null) { |
| final Consumer<EntityMockObject> _function_1 = (EntityMockObject mockObject) -> { |
| try { |
| this.generateMockObject(mock, acceptor, 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 = mock.getEntities(); |
| EList<EntityMockEntity> _entities_1 = null; |
| if (_entities!=null) { |
| _entities_1=_entities.getEntities(); |
| } |
| if (_entities_1!=null) { |
| final Consumer<EntityMockEntity> _function_2 = (EntityMockEntity mockEntity) -> { |
| try { |
| this.generateMockEntity(mock, acceptor, 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 { |
| this.generateMockDataGenerator(mock, acceptor); |
| } catch (final Throwable _t) { |
| if (_t instanceof Exception) { |
| final Exception e = (Exception)_t; |
| e.printStackTrace(); |
| } else { |
| throw Exceptions.sneakyThrow(_t); |
| } |
| } |
| } |
| |
| /** |
| * generate the full qualified mock package name corresponding to the imported entities |
| */ |
| public String entityMockName(final EntityMock mock) { |
| StringConcatenation _builder = new StringConcatenation(); |
| EObject _eContainer = mock.eContainer(); |
| String _string = this._iQualifiedNameProvider.getFullyQualifiedName(((EntityMockPackage) _eContainer)).toString(); |
| _builder.append(_string); |
| _builder.append("."); |
| String _name = mock.getName(); |
| _builder.append(_name); |
| _builder.append("Mock"); |
| return _builder.toString(); |
| } |
| |
| /** |
| * generate the class name for a template mock object |
| */ |
| public String entityMockName(final EntityMockTemplate template, final EntityMock mock) { |
| EntityMockObject _object = template.getObject(); |
| return this.entityMockName(((EntityMockObject) _object), mock); |
| } |
| |
| /** |
| * generate the class name for a mock resource class |
| */ |
| public String entityMockName(final EntityMockResource resource, final EntityMock mock) { |
| StringConcatenation _builder = new StringConcatenation(); |
| EObject _eContainer = mock.eContainer(); |
| String _string = this._iQualifiedNameProvider.getFullyQualifiedName(((EntityMockPackage) _eContainer)).toString(); |
| _builder.append(_string); |
| _builder.append("."); |
| String _name = mock.getName(); |
| _builder.append(_name); |
| _builder.append("Resource"); |
| String _capitalize = WordUtils.capitalize(resource.getName()); |
| _builder.append(_capitalize); |
| return _builder.toString(); |
| } |
| |
| /** |
| * generate the class name for a mock object class |
| */ |
| public String entityMockName(final EntityMockObject object, final EntityMock mock) { |
| StringConcatenation _builder = new StringConcatenation(); |
| EObject _eContainer = mock.eContainer(); |
| String _string = this._iQualifiedNameProvider.getFullyQualifiedName(((EntityMockPackage) _eContainer)).toString(); |
| _builder.append(_string); |
| _builder.append("."); |
| String _name = mock.getName(); |
| _builder.append(_name); |
| _builder.append("Object"); |
| String _capitalize = WordUtils.capitalize(object.getName()); |
| _builder.append(_capitalize); |
| return _builder.toString(); |
| } |
| |
| /** |
| * generate the class name for a mock entity |
| */ |
| public String entityMockName(final EntityMockEntity entity, final EntityMock mock) { |
| StringConcatenation _builder = new StringConcatenation(); |
| EObject _eContainer = mock.eContainer(); |
| String _string = this._iQualifiedNameProvider.getFullyQualifiedName(((EntityMockPackage) _eContainer)).toString(); |
| _builder.append(_string); |
| _builder.append("."); |
| String _name = mock.getName(); |
| _builder.append(_name); |
| _builder.append("Entity"); |
| String _capitalize = WordUtils.capitalize(entity.getName()); |
| _builder.append(_capitalize); |
| return _builder.toString(); |
| } |
| |
| /** |
| * get the entity name referenced by a mock entity |
| */ |
| public String entityName(final EntityMockEntity entity) { |
| return this.entityName(entity.getEntityRef()); |
| } |
| |
| /** |
| * get the entity name |
| */ |
| public String entityName(final LEntity entity) { |
| return entity.getName(); |
| } |
| |
| /** |
| * get the entity name |
| */ |
| public String enumName(final LEnum lenum) { |
| return lenum.getName(); |
| } |
| |
| /** |
| * get the full qualified entity name referenced by a mock entity |
| */ |
| public String entityFQN(final EntityMockEntity entity) { |
| return EntityUtils.getFQNForLEntity(entity.getEntityRef()); |
| } |
| |
| /** |
| * get the full qualified dto name referenced by a mock entity |
| */ |
| public String entityDtoFQN(final EntityMockEntity entity) { |
| return EntityUtils.getDtoFQNForLEntity(entity.getEntityRef()); |
| } |
| |
| /** |
| * get the full qualified dto class name referenced by a mock entity |
| */ |
| public String entityDtoFQNClass(final EntityMockEntity entity) { |
| return this.entityDtoFQNClass(entity.getEntityRef()); |
| } |
| |
| /** |
| * get the full qualified entity class name |
| */ |
| public String entityDtoFQNClass(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 EntityMock model, final IJvmDeclaredTypeAcceptor acceptor, final EntityMockObject mockObject) { |
| JvmGenericType mockClass = this._jvmTypesBuilder.toClass(model, this.entityMockName(mockObject, model)); |
| final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { |
| this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(model)); |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(ABaseMockObject.class); |
| this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| JvmField field = null; |
| final Procedure1<JvmField> _function_1 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("LoggerFactory.getLogger(\"mock\")"); |
| it_2.append(_builder); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_2); |
| }; |
| field = this._jvmTypesBuilder.toField(model, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function_1); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| 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 = new StringConcatenation(); |
| String _name = enumeration.getName(); |
| _builder.append(_name); |
| _builder.append("_resource"); |
| final Procedure1<JvmField> _function_2 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("new "); |
| String _entityMockName = this.entityMockName(resource, model); |
| _builder_1.append(_entityMockName); |
| _builder_1.append("()"); |
| it_2.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_3); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(enumeration)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field = this._jvmTypesBuilder.toField(mockObject, _builder.toString(), |
| this._typeReferenceBuilder.typeRef(ABaseMockResource.class), _function_2); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_1, _field); |
| } |
| } |
| EList<IEntityMockObjectAttribute> _attributes = mockObject.getAttributes(); |
| for (final IEntityMockObjectAttribute attribute : _attributes) { |
| boolean _matched = false; |
| 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_1 = new StringConcatenation(); |
| _builder_1.append("\""); |
| _builder_1.append(value); |
| _builder_1.append("\""); |
| items.add(_builder_1.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectPlainValue)attribute).getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append("_items"); |
| final Procedure1<JvmField> _function_3 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_3.append(_join); |
| _builder_3.append("}"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_4); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(mockObject, _builder_2.toString(), |
| this._typeReferenceBuilder.typeRef(Object[].class), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_1); |
| } |
| 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; |
| LEnum _usingResource_2 = ((EntityMockObjectArrayValue)attribute).getEnumeration().getUsingResource(); |
| if ((_usingResource_2 instanceof EntityMockResource)) { |
| _xifexpression = "String"; |
| } else { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| String _dtoFQNForLEnum = EntityUtils.getDtoFQNForLEnum(((EntityMockObjectArrayValue)attribute).getEnumeration().getUsingResource()); |
| _builder_1.append(_dtoFQNForLEnum); |
| _xifexpression = _builder_1.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_2 = new StringConcatenation(); |
| _builder_2.append("\""); |
| _builder_2.append(value); |
| _builder_2.append("\""); |
| items.add(_builder_2.toString()); |
| } |
| LEnumLiteral _datarow = enumItem.getDatarow(); |
| if ((_datarow instanceof EntityMockResourceDataRow)) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("put(\""); |
| String _name_1 = enumItem.getDatarow().getName(); |
| _builder_3.append(_name_1); |
| _builder_3.append("\", new Object[] {"); |
| String _join = StringUtils.join(items, ","); |
| _builder_3.append(_join); |
| _builder_3.append("});"); |
| enums.add(_builder_3.toString()); |
| } else { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("put("); |
| _builder_4.append(keyType); |
| _builder_4.append("."); |
| String _name_2 = enumItem.getDatarow().getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append(", new Object[] {"); |
| String _join_1 = StringUtils.join(items, ","); |
| _builder_4.append(_join_1); |
| _builder_4.append("});"); |
| enums.add(_builder_4.toString()); |
| } |
| } |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectArrayValue)attribute).getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append("_items"); |
| final Procedure1<JvmField> _function_3 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("new HashMap<"); |
| _builder_3.append(keyType); |
| _builder_3.append(", Object[]>() {{"); |
| _builder_3.newLineIfNotEmpty(); |
| String _join = StringUtils.join(enums, "\r\n"); |
| _builder_3.append(_join); |
| _builder_3.newLineIfNotEmpty(); |
| _builder_3.append("}}"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_4); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(mockObject, _builder_2.toString(), this._typeReferenceBuilder.typeRef(Map.class), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_1); |
| } |
| } |
| 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 (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_1 = new StringConcatenation(); |
| _builder_1.append("\""); |
| _builder_1.append(item); |
| _builder_1.append("\""); |
| items.add(_builder_1.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append("_items"); |
| final Procedure1<JvmField> _function_3 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_3.append(_join); |
| _builder_3.append("}"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_4); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(mockObject, _builder_2.toString(), |
| this._typeReferenceBuilder.typeRef(Object[].class), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_1); |
| } |
| 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_1 = new StringConcatenation(); |
| _builder_1.append(item); |
| items.add(_builder_1.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append("_items"); |
| final Procedure1<JvmField> _function_3 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_3.append(_join); |
| _builder_3.append("}"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_4); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(mockObject, _builder_2.toString(), |
| this._typeReferenceBuilder.typeRef(double[].class), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_1); |
| } |
| } |
| 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_1 = new StringConcatenation(); |
| _builder_1.append(item); |
| items.add(_builder_1.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append("_items"); |
| final Procedure1<JvmField> _function_3 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_3.append(_join); |
| _builder_3.append("}"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_4); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(mockObject, _builder_2.toString(), |
| this._typeReferenceBuilder.typeRef(double[].class), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_1); |
| } |
| } |
| 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_1 = new StringConcatenation(); |
| _builder_1.append(item); |
| items.add(_builder_1.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append("_items"); |
| final Procedure1<JvmField> _function_3 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_3.append(_join); |
| _builder_3.append("}"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_4); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(mockObject, _builder_2.toString(), |
| this._typeReferenceBuilder.typeRef(int[].class), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_1); |
| } |
| } |
| 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_1 = new StringConcatenation(); |
| _builder_1.append(item); |
| items.add(_builder_1.toString()); |
| } |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = ((EntityMockObjectFill)attribute).getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append("_items"); |
| final Procedure1<JvmField> _function_3 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_3.append(_join); |
| _builder_3.append("}"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_4); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(mockObject, _builder_2.toString(), |
| this._typeReferenceBuilder.typeRef(int[].class), _function_3); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_1); |
| } |
| } |
| } |
| } |
| } |
| EList<EntityMockObjectFunction> _calculations = mockObject.getCalculations(); |
| for (final EntityMockObjectFunction calculation : _calculations) { |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("calculate_"); |
| String _name_1 = calculation.getName(); |
| _builder_1.append(_name_1); |
| final Procedure1<JvmOperation> _function_3 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PROTECTED); |
| EList<EntityMockObjectFunctionParameter> _params = calculation.getParams(); |
| for (final EntityMockObjectFunctionParameter param : _params) { |
| { |
| JvmTypeReference type = param.getParameterType(); |
| EList<JvmFormalParameter> _parameters = it_1.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(param, this.getName(param.getName()), type); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| } |
| } |
| it_1.setFinal(true); |
| this._jvmTypesBuilder.setBody(it_1, calculation.getBody()); |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(mockObject, _builder_1.toString(), calculation.getOftype(), _function_3); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method); |
| } |
| EList<JvmMember> _members_3 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("generateDataRow"); |
| final Procedure1<JvmOperation> _function_4 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PROTECTED); |
| it_1.setFinal(true); |
| final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_2) -> { |
| EList<EntityMockObjectEnum> _enumerations_1 = mockObject.getEnumerations(); |
| for (final EntityMockObjectEnum enumeration_1 : _enumerations_1) { |
| { |
| String doc = this._jvmTypesBuilder.getDocumentation(enumeration_1); |
| if (((doc instanceof String) && (!doc.trim().isEmpty()))) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("/** "); |
| _builder_3.append(doc); |
| _builder_3.append(" */"); |
| _builder_3.newLineIfNotEmpty(); |
| it_2.append(_builder_3); |
| } |
| LEnum _usingResource_2 = enumeration_1.getUsingResource(); |
| if ((_usingResource_2 instanceof EntityMockResource)) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = enumeration_1.getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = enumeration_1.getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_resource.getDataRows().toArray());"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } else { |
| final LEnum lenum = enumeration_1.getUsingResource(); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateAttribute(\""); |
| String _name_4 = enumeration_1.getName(); |
| _builder_5.append(_name_4); |
| _builder_5.append("\","); |
| String _dtoFQNForLEnum = EntityUtils.getDtoFQNForLEnum(lenum); |
| _builder_5.append(_dtoFQNForLEnum); |
| _builder_5.append(".values());"); |
| _builder_5.newLineIfNotEmpty(); |
| it_2.append(_builder_5); |
| } |
| } |
| } |
| EList<IEntityMockObjectAttribute> _attributes_1 = mockObject.getAttributes(); |
| for (final IEntityMockObjectAttribute attribute_1 : _attributes_1) { |
| { |
| String doc = this._jvmTypesBuilder.getDocumentation(attribute_1); |
| if (((doc instanceof String) && (!doc.trim().isEmpty()))) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("/** "); |
| _builder_3.append(doc); |
| _builder_3.append(" */"); |
| _builder_3.newLineIfNotEmpty(); |
| it_2.append(_builder_3); |
| } |
| boolean _matched_1 = false; |
| if (attribute_1 instanceof EntityMockObjectPlainValue) { |
| _matched_1=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectPlainValue)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = ((EntityMockObjectPlainValue)attribute_1).getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_items);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockObjectResourceValue) { |
| _matched_1=true; |
| LEnum _usingResource_2 = ((EntityMockObjectResourceValue)attribute_1).getResourceEnum().getUsingResource(); |
| if ((_usingResource_2 instanceof EntityMockResource)) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("setFixAttribute(\""); |
| String _name_2 = ((EntityMockObjectResourceValue)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = ((EntityMockObjectResourceValue)attribute_1).getResourceEnum().getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_resource.getAttribute(getAttribute(\""); |
| String _name_4 = ((EntityMockObjectResourceValue)attribute_1).getResourceEnum().getName(); |
| _builder_4.append(_name_4); |
| _builder_4.append("\").toString(), \""); |
| String _name_5 = ((EntityMockObjectResourceValue)attribute_1).getResourceAttribute().getName(); |
| _builder_4.append(_name_5); |
| _builder_4.append("\"));"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } else { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("setFixAttribute(\""); |
| String _name_6 = ((EntityMockObjectResourceValue)attribute_1).getName(); |
| _builder_5.append(_name_6); |
| _builder_5.append("\", getAttribute(\""); |
| String _name_7 = ((EntityMockObjectResourceValue)attribute_1).getResourceEnum().getName(); |
| _builder_5.append(_name_7); |
| _builder_5.append("\"));"); |
| _builder_5.newLineIfNotEmpty(); |
| it_2.append(_builder_5); |
| } |
| } |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockObjectArrayValue) { |
| _matched_1=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectArrayValue)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", \""); |
| String _name_3 = ((EntityMockObjectArrayValue)attribute_1).getEnumeration().getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("\", "); |
| String _name_4 = ((EntityMockObjectArrayValue)attribute_1).getName(); |
| _builder_4.append(_name_4); |
| _builder_4.append("_items);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockObjectEmbed) { |
| _matched_1=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectEmbed)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", new "); |
| String _entityMockName = this.entityMockName(((EntityMockObjectEmbed)attribute_1).getObject(), model); |
| _builder_4.append(_entityMockName); |
| _builder_4.append("());"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockObjectFill) { |
| _matched_1=true; |
| PropertyFillerType type = ((EntityMockObjectFill)attribute_1).getFillerType(); |
| boolean _matched_2 = false; |
| if (type instanceof PropertyFillerDateFuture) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateDateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", 0 ,"); |
| int _dateFutureYears = ((PropertyFillerDateFuture)type).getDateFutureYears(); |
| _builder_4.append(_dateFutureYears); |
| _builder_4.append(");"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerDatePast) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateDateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", -"); |
| int _datePastYears = ((PropertyFillerDatePast)type).getDatePastYears(); |
| _builder_4.append(_datePastYears); |
| _builder_4.append(", 0);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerDateRange) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateDateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| int _dateBeginYears = ((PropertyFillerDateRange)type).getDateBeginYears(); |
| _builder_4.append(_dateBeginYears); |
| _builder_4.append(", "); |
| int _dateEndYears = ((PropertyFillerDateRange)type).getDateEndYears(); |
| _builder_4.append(_dateEndYears); |
| _builder_4.append(");"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerBoolean) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateBooleanAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\");"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedDoubleRange) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerSignedDoubleRange)type).getBeginRange(); |
| _builder_4.append(_beginRange); |
| String beginRange = _builder_4.toString(); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerSignedDoubleRange)type).getEndRange(); |
| _builder_5.append(_endRange); |
| String endRange = _builder_5.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals = (_beginRangeRef != null); |
| if (_tripleNotEquals) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("get_\""); |
| String _name_2 = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef().getName(); |
| _builder_6.append(_name_2); |
| _builder_6.append("\"()"); |
| beginRange = _builder_6.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_1 = (_endRangeRef != null); |
| if (_tripleNotEquals_1) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("get_\""); |
| String _name_3 = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef().getName(); |
| _builder_7.append(_name_3); |
| _builder_7.append("\"()"); |
| endRange = _builder_7.toString(); |
| } |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append("generateSignedAttribute(\""); |
| String _name_4 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_8.append(_name_4); |
| _builder_8.append("\", "); |
| int _decimals = ((PropertyFillerSignedDoubleRange)type).getDecimals(); |
| _builder_8.append(_decimals); |
| _builder_8.append(", "); |
| _builder_8.append(beginRange); |
| _builder_8.append(", "); |
| _builder_8.append(endRange); |
| _builder_8.append(", "); |
| double _rounded = ((PropertyFillerSignedDoubleRange)type).getRounded(); |
| _builder_8.append(_rounded); |
| _builder_8.append(");"); |
| _builder_8.newLineIfNotEmpty(); |
| it_2.append(_builder_8); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedDoubleRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_items);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedDoubleRange) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerUnsignedDoubleRange)type).getBeginRange(); |
| _builder_4.append(_beginRange); |
| String beginRange = _builder_4.toString(); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerUnsignedDoubleRange)type).getEndRange(); |
| _builder_5.append(_endRange); |
| String endRange = _builder_5.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals = (_beginRangeRef != null); |
| if (_tripleNotEquals) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("(double)get_\""); |
| String _name_2 = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef().getName(); |
| _builder_6.append(_name_2); |
| _builder_6.append("\"()"); |
| beginRange = _builder_6.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_1 = (_endRangeRef != null); |
| if (_tripleNotEquals_1) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("(double)get_\""); |
| String _name_3 = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef().getName(); |
| _builder_7.append(_name_3); |
| _builder_7.append("\"()"); |
| endRange = _builder_7.toString(); |
| } |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append("generateUnsignedAttribute(\""); |
| String _name_4 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_8.append(_name_4); |
| _builder_8.append("\", "); |
| int _decimals = ((PropertyFillerUnsignedDoubleRange)type).getDecimals(); |
| _builder_8.append(_decimals); |
| _builder_8.append(", "); |
| _builder_8.append(beginRange); |
| _builder_8.append(", "); |
| _builder_8.append(endRange); |
| _builder_8.append(", "); |
| double _rounded = ((PropertyFillerUnsignedDoubleRange)type).getRounded(); |
| _builder_8.append(_rounded); |
| _builder_8.append(");"); |
| _builder_8.newLineIfNotEmpty(); |
| it_2.append(_builder_8); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedDoubleRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_items);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedIntegerRange) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerSignedIntegerRange)type).getBeginRange(); |
| _builder_4.append(_beginRange); |
| String beginRange = _builder_4.toString(); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerSignedIntegerRange)type).getEndRange(); |
| _builder_5.append(_endRange); |
| String endRange = _builder_5.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals = (_beginRangeRef != null); |
| if (_tripleNotEquals) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("(int)get_\""); |
| String _name_2 = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef().getName(); |
| _builder_6.append(_name_2); |
| _builder_6.append("\"()"); |
| beginRange = _builder_6.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_1 = (_endRangeRef != null); |
| if (_tripleNotEquals_1) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("(int)get_\""); |
| String _name_3 = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef().getName(); |
| _builder_7.append(_name_3); |
| _builder_7.append("\"()"); |
| endRange = _builder_7.toString(); |
| } |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append("generateSignedAttribute(\""); |
| String _name_4 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_8.append(_name_4); |
| _builder_8.append("\", "); |
| _builder_8.append(beginRange); |
| _builder_8.append(", "); |
| _builder_8.append(endRange); |
| _builder_8.append(", "); |
| int _rounded = ((PropertyFillerSignedIntegerRange)type).getRounded(); |
| _builder_8.append(_rounded); |
| _builder_8.append(");"); |
| _builder_8.newLineIfNotEmpty(); |
| it_2.append(_builder_8); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedIntegerRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_items);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedIntegerRange) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerUnsignedIntegerRange)type).getBeginRange(); |
| _builder_4.append(_beginRange); |
| String beginRange = _builder_4.toString(); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerUnsignedIntegerRange)type).getEndRange(); |
| _builder_5.append(_endRange); |
| String endRange = _builder_5.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals = (_beginRangeRef != null); |
| if (_tripleNotEquals) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("(int)get_\""); |
| String _name_2 = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef().getName(); |
| _builder_6.append(_name_2); |
| _builder_6.append("\"()"); |
| beginRange = _builder_6.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_1 = (_endRangeRef != null); |
| if (_tripleNotEquals_1) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("(int)get_\""); |
| String _name_3 = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef().getName(); |
| _builder_7.append(_name_3); |
| _builder_7.append("\"()"); |
| endRange = _builder_7.toString(); |
| } |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append("generateUnsignedAttribute(\""); |
| String _name_4 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_8.append(_name_4); |
| _builder_8.append("\", "); |
| _builder_8.append(beginRange); |
| _builder_8.append(", "); |
| _builder_8.append(endRange); |
| _builder_8.append(", "); |
| int _rounded = ((PropertyFillerUnsignedIntegerRange)type).getRounded(); |
| _builder_8.append(_rounded); |
| _builder_8.append(");"); |
| _builder_8.newLineIfNotEmpty(); |
| it_2.append(_builder_8); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedIntegerRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_items);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| String _name_3 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_3); |
| _builder_4.append("_items);"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextParagraphs) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateParagraphsAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| int _count = ((PropertyFillerTextParagraphs)type).getCount(); |
| _builder_4.append(_count); |
| _builder_4.append(");"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextSentences) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateSentencesAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| int _count = ((PropertyFillerTextSentences)type).getCount(); |
| _builder_4.append(_count); |
| _builder_4.append(");"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextWords) { |
| _matched_2=true; |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("generateWordsAttribute(\""); |
| String _name_2 = ((EntityMockObjectFill)attribute_1).getName(); |
| _builder_4.append(_name_2); |
| _builder_4.append("\", "); |
| int _count = ((PropertyFillerTextWords)type).getCount(); |
| _builder_4.append(_count); |
| _builder_4.append(");"); |
| _builder_4.newLineIfNotEmpty(); |
| it_2.append(_builder_4); |
| } |
| } |
| } |
| } |
| } |
| } |
| EList<EntityMockObjectFunction> _calculations_1 = mockObject.getCalculations(); |
| for (final EntityMockObjectFunction calculation_1 : _calculations_1) { |
| { |
| String doc = this._jvmTypesBuilder.getDocumentation(calculation_1); |
| if (((doc instanceof String) && (!doc.trim().isEmpty()))) { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("/** "); |
| _builder_3.append(doc); |
| _builder_3.append(" */"); |
| _builder_3.newLineIfNotEmpty(); |
| it_2.append(_builder_3); |
| } |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| String paramString = _builder_4.toString(); |
| EList<EntityMockObjectFunctionParameter> _params = calculation_1.getParams(); |
| for (final EntityMockObjectFunctionParameter param : _params) { |
| { |
| boolean _isEmpty = paramString.isEmpty(); |
| boolean _not = (!_isEmpty); |
| if (_not) { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append(paramString); |
| _builder_5.append(","); |
| paramString = _builder_5.toString(); |
| } |
| JvmType _type = param.getParameterType().getType(); |
| if ((_type instanceof JvmEnumerationType)) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append(paramString); |
| _builder_6.append(" "); |
| String _identifier = param.getParameterType().getIdentifier(); |
| _builder_6.append(_identifier); |
| _builder_6.append(".valueOf(getAttribute(\""); |
| String _name_2 = this.getName(param.getName()); |
| _builder_6.append(_name_2); |
| _builder_6.append("\").toString())"); |
| paramString = _builder_6.toString(); |
| } else { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append(paramString); |
| _builder_7.append("("); |
| String _identifier_1 = param.getParameterType().getIdentifier(); |
| _builder_7.append(_identifier_1); |
| _builder_7.append(")getAttribute(\""); |
| String _name_3 = this.getName(param.getName()); |
| _builder_7.append(_name_3); |
| _builder_7.append("\")"); |
| paramString = _builder_7.toString(); |
| } |
| } |
| } |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("try {"); |
| _builder_5.newLine(); |
| _builder_5.append("\t"); |
| _builder_5.append("setFixAttribute(\""); |
| String _name_2 = calculation_1.getName(); |
| _builder_5.append(_name_2, "\t"); |
| _builder_5.append("\", calculate_"); |
| String _name_3 = calculation_1.getName(); |
| _builder_5.append(_name_3, "\t"); |
| _builder_5.append("("); |
| _builder_5.append(paramString, "\t"); |
| _builder_5.append("));"); |
| _builder_5.newLineIfNotEmpty(); |
| _builder_5.append("}"); |
| _builder_5.newLine(); |
| _builder_5.append("catch (NullPointerException npe) {}"); |
| _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(); |
| it_2.append(_builder_5); |
| } |
| } |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_5); |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(mockObject, _builder_2.toString(), this._typeReferenceBuilder.typeRef(Void.TYPE), _function_4); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_1); |
| }; |
| acceptor.<JvmGenericType>accept(mockClass, _function); |
| } |
| |
| public String getName(final IEntityMockObjectUsable attribute) { |
| boolean _matched = false; |
| 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 EntityMock model, final IJvmDeclaredTypeAcceptor acceptor, final EntityMockEntity mockEntity) { |
| JvmGenericType mockClass = this._jvmTypesBuilder.toClass(model, this.entityMockName(mockEntity, model)); |
| final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { |
| this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(model)); |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(ABaseMockEntity.class); |
| this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| JvmField field = null; |
| final Procedure1<JvmField> _function_1 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("LoggerFactory.getLogger(\"mock\")"); |
| it_2.append(_builder); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_2); |
| }; |
| field = this._jvmTypesBuilder.toField(model, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function_1); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| CompleteYearFiller _completeYearFiller = mockEntity.getCompleteYearFiller(); |
| boolean _tripleNotEquals = (_completeYearFiller != null); |
| if (_tripleNotEquals) { |
| field = this._jvmTypesBuilder.toField(model, "dataRow", this._typeReferenceBuilder.typeRef(Object.class)); |
| EList<JvmMember> _members_1 = it.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field); |
| } |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| boolean _tripleNotEquals_1 = (_byResource != null); |
| if (_tripleNotEquals_1) { |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder = new StringConcatenation(); |
| String _name = mockEntity.getByResource().getName(); |
| _builder.append(_name); |
| _builder.append("_resource"); |
| final Procedure1<JvmField> _function_2 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("new "); |
| String _entityMockName = this.entityMockName(mockEntity.getByResource(), model); |
| _builder_1.append(_entityMockName); |
| _builder_1.append("()"); |
| it_2.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_3); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(mockEntity.getByResource())); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field = this._jvmTypesBuilder.toField(model, _builder.toString(), |
| this._typeReferenceBuilder.typeRef(ABaseMockResource.class), _function_2); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field); |
| } |
| EList<JvmMember> _members_3 = it.getMembers(); |
| final Procedure1<JvmConstructor> _function_3 = (JvmConstructor it_1) -> { |
| EList<JvmFormalParameter> _parameters = it_1.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(mockEntity, "mockDataGenerator", this._typeReferenceBuilder.typeRef(AEntityMockDataGenerator.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("super(mockDataGenerator, \""); |
| String _persistenceUnit = mockEntity.getEntityRef().getPersistenceUnit(); |
| _builder_1.append(_persistenceUnit); |
| _builder_1.append("\");"); |
| it_2.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_4); |
| }; |
| JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(model, _function_3); |
| this._jvmTypesBuilder.<JvmConstructor>operator_add(_members_3, _constructor); |
| EList<EntityMockTemplate> _templates = mockEntity.getTemplates(); |
| for (final EntityMockTemplate template : _templates) { |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| String _name_1 = template.getName(); |
| _builder_1.append(_name_1); |
| _builder_1.append("_template"); |
| final Procedure1<JvmField> _function_4 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("new "); |
| String _entityMockName = this.entityMockName(template, model); |
| _builder_2.append(_entityMockName); |
| _builder_2.append("()"); |
| it_2.append(_builder_2); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_5); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(template)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(model, _builder_1.toString(), |
| this._typeReferenceBuilder.typeRef(ABaseMockObject.class), _function_4); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_4, _field_1); |
| } |
| EList<IEntityMockAttribute> _attributes = mockEntity.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| boolean _matched = false; |
| if (attribute instanceof EntityMockAttributeByObject) { |
| _matched=true; |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeFiller) { |
| _matched=true; |
| PropertyFillerType type = ((EntityMockAttributeFiller)attribute).getFillerType(); |
| boolean _matched_1 = false; |
| 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_5 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_2 = ((EntityMockAttributeFiller)attribute).getAttributeRef().getName(); |
| _builder_3.append(_name_2); |
| _builder_3.append("_items"); |
| final Procedure1<JvmField> _function_5 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_4.append(_join); |
| _builder_4.append("}"); |
| it_2.append(_builder_4); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_6); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_2 = this._jvmTypesBuilder.toField(model, _builder_3.toString(), |
| this._typeReferenceBuilder.typeRef(Object[].class), _function_5); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_5, _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_5 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_2 = ((EntityMockAttributeFiller)attribute).getAttributeRef().getName(); |
| _builder_3.append(_name_2); |
| _builder_3.append("_items"); |
| final Procedure1<JvmField> _function_5 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_4.append(_join); |
| _builder_4.append("}"); |
| it_2.append(_builder_4); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_6); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_2 = this._jvmTypesBuilder.toField(model, _builder_3.toString(), |
| this._typeReferenceBuilder.typeRef(double[].class), _function_5); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_5, _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_5 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_2 = ((EntityMockAttributeFiller)attribute).getAttributeRef().getName(); |
| _builder_3.append(_name_2); |
| _builder_3.append("_items"); |
| final Procedure1<JvmField> _function_5 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_4.append(_join); |
| _builder_4.append("}"); |
| it_2.append(_builder_4); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_6); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_2 = this._jvmTypesBuilder.toField(model, _builder_3.toString(), |
| this._typeReferenceBuilder.typeRef(double[].class), _function_5); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_5, _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_5 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_2 = ((EntityMockAttributeFiller)attribute).getAttributeRef().getName(); |
| _builder_3.append(_name_2); |
| _builder_3.append("_items"); |
| final Procedure1<JvmField> _function_5 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_4.append(_join); |
| _builder_4.append("}"); |
| it_2.append(_builder_4); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_6); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_2 = this._jvmTypesBuilder.toField(model, _builder_3.toString(), |
| this._typeReferenceBuilder.typeRef(int[].class), _function_5); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_5, _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_5 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| String _name_2 = ((EntityMockAttributeFiller)attribute).getAttributeRef().getName(); |
| _builder_3.append(_name_2); |
| _builder_3.append("_items"); |
| final Procedure1<JvmField> _function_5 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("{"); |
| String _join = StringUtils.join(items, ","); |
| _builder_4.append(_join); |
| _builder_4.append("}"); |
| it_2.append(_builder_4); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_6); |
| this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(attribute)); |
| it_1.setVisibility(JvmVisibility.PRIVATE); |
| it_1.setStatic(true); |
| }; |
| JvmField _field_2 = this._jvmTypesBuilder.toField(model, _builder_3.toString(), |
| this._typeReferenceBuilder.typeRef(int[].class), _function_5); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_5, _field_2); |
| } |
| } |
| } |
| } |
| if (!_matched) { |
| if (attribute instanceof EntityMockAttributeByReference) { |
| _matched=true; |
| } |
| } |
| } |
| EntityMockResource _byResource_1 = mockEntity.getByResource(); |
| boolean _tripleNotEquals_2 = (_byResource_1 != null); |
| if (_tripleNotEquals_2) { |
| EList<JvmMember> _members_5 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("getDataRows"); |
| final Procedure1<JvmOperation> _function_5 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PUBLIC); |
| it_1.setFinal(true); |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("return "); |
| String _name_2 = mockEntity.getByResource().getName(); |
| _builder_3.append(_name_2); |
| _builder_3.append("_resource.getDataRows();"); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_6); |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(model, _builder_2.toString(), this._typeReferenceBuilder.typeRef(Set.class), _function_5); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method); |
| EList<JvmMember> _members_6 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("generateEntity"); |
| final Procedure1<JvmOperation> _function_6 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PUBLIC); |
| EList<JvmFormalParameter> _parameters = it_1.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(model, "dataRow", this._typeReferenceBuilder.typeRef(Object.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| it_1.setFinal(true); |
| final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("reset();"); |
| _builder_4.newLine(); |
| String _entityDtoFQN = this.entityDtoFQN(mockEntity); |
| _builder_4.append(_entityDtoFQN); |
| _builder_4.append(" internal = new "); |
| String _entityDtoFQN_1 = this.entityDtoFQN(mockEntity); |
| _builder_4.append(_entityDtoFQN_1); |
| _builder_4.append("();"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("entity = internal;"); |
| _builder_4.newLine(); |
| _builder_4.append("generateData();"); |
| _builder_4.newLine(); |
| _builder_4.append("try {"); |
| _builder_4.newLine(); |
| it_2.append(_builder_4); |
| EList<EntityMockByResourceAttribute> _byResourceAttributes = mockEntity.getByResourceAttributes(); |
| for (final EntityMockByResourceAttribute attribute_1 : _byResourceAttributes) { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("internal.set"); |
| String _capitalize = WordUtils.capitalize(attribute_1.getAttributeRef().getName()); |
| _builder_5.append(_capitalize); |
| _builder_5.append("("); |
| LEntityAttribute _attributeRef = attribute_1.getAttributeRef(); |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| String _name_2 = mockEntity.getByResource().getName(); |
| _builder_6.append(_name_2); |
| _builder_6.append("_resource.getAttribute(dataRow.toString(), \""); |
| String _name_3 = attribute_1.getResourceAttribute().getName(); |
| _builder_6.append(_name_3); |
| _builder_6.append("\")"); |
| String _baseMockDataTypeCasting = this.baseMockDataTypeCasting(_attributeRef, _builder_6.toString()); |
| _builder_5.append(_baseMockDataTypeCasting); |
| _builder_5.append(");"); |
| _builder_5.newLineIfNotEmpty(); |
| it_2.append(_builder_5); |
| } |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("}"); |
| _builder_7.newLine(); |
| _builder_7.append("catch (Exception e) {"); |
| _builder_7.newLine(); |
| _builder_7.append(" "); |
| _builder_7.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_7.newLine(); |
| _builder_7.append("}"); |
| _builder_7.newLine(); |
| _builder_7.append("return entity;"); |
| it_2.append(_builder_7); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_7); |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(model, _builder_3.toString(), this._typeReferenceBuilder.typeRef(Object.class), _function_6); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_1); |
| } |
| EList<EntityMockEntityFunction> _calculations = mockEntity.getCalculations(); |
| for (final EntityMockEntityFunction calculation : _calculations) { |
| EList<JvmMember> _members_7 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("calculate_"); |
| String _name_2 = calculation.getAttributeRef().getName(); |
| _builder_4.append(_name_2); |
| final Procedure1<JvmOperation> _function_7 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PROTECTED); |
| EList<EntityMockEntityFunctionParameter> _params = calculation.getParams(); |
| for (final EntityMockEntityFunctionParameter param : _params) { |
| EList<JvmFormalParameter> _parameters = it_1.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(param, this.getParamName(param, "__"), this.getJvmType(param)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| } |
| it_1.setFinal(true); |
| this._jvmTypesBuilder.setBody(it_1, calculation.getBody()); |
| }; |
| JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(model, _builder_4.toString(), |
| this.jvmTypeRef(calculation.getAttributeRef()), _function_7); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_2); |
| } |
| EList<JvmMember> _members_8 = it.getMembers(); |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("generateDataRow"); |
| final Procedure1<JvmOperation> _function_8 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PROTECTED); |
| it_1.setFinal(true); |
| final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_2) -> { |
| EList<EntityMockTemplate> _templates_1 = mockEntity.getTemplates(); |
| for (final EntityMockTemplate template_1 : _templates_1) { |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("generateAttribute(\""); |
| String _name_3 = template_1.getName(); |
| _builder_6.append(_name_3); |
| _builder_6.append("\", "); |
| String _name_4 = template_1.getName(); |
| _builder_6.append(_name_4); |
| _builder_6.append("_template);"); |
| _builder_6.newLineIfNotEmpty(); |
| it_2.append(_builder_6); |
| } |
| EList<IEntityMockAttribute> _attributes_1 = mockEntity.getAttributes(); |
| for (final IEntityMockAttribute attribute_1 : _attributes_1) { |
| boolean _matched_1 = false; |
| if (attribute_1 instanceof EntityMockAttributeByObject) { |
| _matched_1=true; |
| String sourceKey = ((EntityMockAttributeByObject)attribute_1).getReference().getTemplate().getName(); |
| EList<EntityMockObjectEmbed> _embedded = ((EntityMockAttributeByObject)attribute_1).getReference().getEmbedded(); |
| for (final EntityMockObjectEmbed embed : _embedded) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append(sourceKey); |
| _builder_7.append("."); |
| String _name_5 = embed.getName(); |
| _builder_7.append(_name_5); |
| sourceKey = _builder_7.toString(); |
| } |
| final IEntityMockObjectUsable refAttribute = ((EntityMockAttributeByObject)attribute_1).getReference().getAttribute(); |
| if ((refAttribute instanceof EntityMockObjectEnum)) { |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append(sourceKey); |
| _builder_8.append("."); |
| String _name_6 = ((EntityMockObjectEnum) refAttribute).getName(); |
| _builder_8.append(_name_6); |
| sourceKey = _builder_8.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectPlainValue)) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append(sourceKey); |
| _builder_9.append("."); |
| String _name_7 = ((EntityMockObjectPlainValue) refAttribute).getName(); |
| _builder_9.append(_name_7); |
| sourceKey = _builder_9.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectResourceValue)) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append(sourceKey); |
| _builder_10.append("."); |
| String _name_8 = ((EntityMockObjectResourceValue) refAttribute).getName(); |
| _builder_10.append(_name_8); |
| sourceKey = _builder_10.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectArrayValue)) { |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append(sourceKey); |
| _builder_11.append("."); |
| String _name_9 = ((EntityMockObjectArrayValue) refAttribute).getName(); |
| _builder_11.append(_name_9); |
| sourceKey = _builder_11.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectEmbed)) { |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append(sourceKey); |
| _builder_12.append("."); |
| String _name_10 = ((EntityMockObjectEmbed) refAttribute).getName(); |
| _builder_12.append(_name_10); |
| sourceKey = _builder_12.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectFill)) { |
| StringConcatenation _builder_13 = new StringConcatenation(); |
| _builder_13.append(sourceKey); |
| _builder_13.append("."); |
| String _name_11 = ((EntityMockObjectFill) refAttribute).getName(); |
| _builder_13.append(_name_11); |
| sourceKey = _builder_13.toString(); |
| } |
| if ((refAttribute instanceof EntityMockObjectFunction)) { |
| StringConcatenation _builder_14 = new StringConcatenation(); |
| _builder_14.append(sourceKey); |
| _builder_14.append("."); |
| String _name_12 = ((EntityMockObjectFunction) refAttribute).getName(); |
| _builder_14.append(_name_12); |
| sourceKey = _builder_14.toString(); |
| } |
| StringConcatenation _builder_15 = new StringConcatenation(); |
| _builder_15.append("generateAttribute(\""); |
| String _name_13 = ((EntityMockAttributeByObject)attribute_1).getAttributeRef().getName(); |
| _builder_15.append(_name_13); |
| _builder_15.append("\", \""); |
| _builder_15.append(sourceKey); |
| _builder_15.append("\");"); |
| _builder_15.newLineIfNotEmpty(); |
| it_2.append(_builder_15); |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockAttributeFiller) { |
| _matched_1=true; |
| PropertyFillerType type = ((EntityMockAttributeFiller)attribute_1).getFillerType(); |
| boolean _matched_2 = false; |
| if (type instanceof PropertyFillerDateFuture) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateDateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", 0 ,"); |
| int _dateFutureYears = ((PropertyFillerDateFuture)type).getDateFutureYears(); |
| _builder_7.append(_dateFutureYears); |
| _builder_7.append(");"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerDatePast) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateDateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", -"); |
| int _datePastYears = ((PropertyFillerDatePast)type).getDatePastYears(); |
| _builder_7.append(_datePastYears); |
| _builder_7.append(", 0);"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerDateRange) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateDateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| int _dateBeginYears = ((PropertyFillerDateRange)type).getDateBeginYears(); |
| _builder_7.append(_dateBeginYears); |
| _builder_7.append(", "); |
| int _dateEndYears = ((PropertyFillerDateRange)type).getDateEndYears(); |
| _builder_7.append(_dateEndYears); |
| _builder_7.append(");"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerBoolean) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateBooleanAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\");"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedDoubleRange) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerSignedDoubleRange)type).getBeginRange(); |
| _builder_7.append(_beginRange); |
| String beginRange = _builder_7.toString(); |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerSignedDoubleRange)type).getEndRange(); |
| _builder_8.append(_endRange); |
| String endRange = _builder_8.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals_3 = (_beginRangeRef != null); |
| if (_tripleNotEquals_3) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("get_\""); |
| String _name_5 = ((PropertyFillerSignedDoubleRange)type).getBeginRangeRef().getName(); |
| _builder_9.append(_name_5); |
| _builder_9.append("\"()"); |
| beginRange = _builder_9.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_4 = (_endRangeRef != null); |
| if (_tripleNotEquals_4) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("get_\""); |
| String _name_6 = ((PropertyFillerSignedDoubleRange)type).getEndRangeRef().getName(); |
| _builder_10.append(_name_6); |
| _builder_10.append("\"()"); |
| endRange = _builder_10.toString(); |
| } |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("generateSignedAttribute(\""); |
| String _name_7 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_11.append(_name_7); |
| _builder_11.append("\", "); |
| int _decimals = ((PropertyFillerSignedDoubleRange)type).getDecimals(); |
| _builder_11.append(_decimals); |
| _builder_11.append(", "); |
| _builder_11.append(beginRange); |
| _builder_11.append(", "); |
| _builder_11.append(endRange); |
| _builder_11.append(", "); |
| double _rounded = ((PropertyFillerSignedDoubleRange)type).getRounded(); |
| _builder_11.append(_rounded); |
| _builder_11.append(");"); |
| _builder_11.newLineIfNotEmpty(); |
| it_2.append(_builder_11); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedDoubleRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| String _name_6 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_6); |
| _builder_7.append("_items);"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedDoubleRange) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| double _beginRange = ((PropertyFillerUnsignedDoubleRange)type).getBeginRange(); |
| _builder_7.append(_beginRange); |
| String beginRange = _builder_7.toString(); |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| double _endRange = ((PropertyFillerUnsignedDoubleRange)type).getEndRange(); |
| _builder_8.append(_endRange); |
| String endRange = _builder_8.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals_3 = (_beginRangeRef != null); |
| if (_tripleNotEquals_3) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("(double)get_\""); |
| String _name_5 = ((PropertyFillerUnsignedDoubleRange)type).getBeginRangeRef().getName(); |
| _builder_9.append(_name_5); |
| _builder_9.append("\"()"); |
| beginRange = _builder_9.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_4 = (_endRangeRef != null); |
| if (_tripleNotEquals_4) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("(double)get_\""); |
| String _name_6 = ((PropertyFillerUnsignedDoubleRange)type).getEndRangeRef().getName(); |
| _builder_10.append(_name_6); |
| _builder_10.append("\"()"); |
| endRange = _builder_10.toString(); |
| } |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("generateUnsignedAttribute(\""); |
| String _name_7 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_11.append(_name_7); |
| _builder_11.append("\", "); |
| int _decimals = ((PropertyFillerUnsignedDoubleRange)type).getDecimals(); |
| _builder_11.append(_decimals); |
| _builder_11.append(", "); |
| _builder_11.append(beginRange); |
| _builder_11.append(", "); |
| _builder_11.append(endRange); |
| _builder_11.append(", "); |
| double _rounded = ((PropertyFillerUnsignedDoubleRange)type).getRounded(); |
| _builder_11.append(_rounded); |
| _builder_11.append(");"); |
| _builder_11.newLineIfNotEmpty(); |
| it_2.append(_builder_11); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedDoubleRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| String _name_6 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_6); |
| _builder_7.append("_items);"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedIntegerRange) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerSignedIntegerRange)type).getBeginRange(); |
| _builder_7.append(_beginRange); |
| String beginRange = _builder_7.toString(); |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerSignedIntegerRange)type).getEndRange(); |
| _builder_8.append(_endRange); |
| String endRange = _builder_8.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals_3 = (_beginRangeRef != null); |
| if (_tripleNotEquals_3) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("(int)get_\""); |
| String _name_5 = ((PropertyFillerSignedIntegerRange)type).getBeginRangeRef().getName(); |
| _builder_9.append(_name_5); |
| _builder_9.append("\"()"); |
| beginRange = _builder_9.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_4 = (_endRangeRef != null); |
| if (_tripleNotEquals_4) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("(int)get_\""); |
| String _name_6 = ((PropertyFillerSignedIntegerRange)type).getEndRangeRef().getName(); |
| _builder_10.append(_name_6); |
| _builder_10.append("\"()"); |
| endRange = _builder_10.toString(); |
| } |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("generateSignedAttribute(\""); |
| String _name_7 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_11.append(_name_7); |
| _builder_11.append("\", "); |
| _builder_11.append(beginRange); |
| _builder_11.append(", "); |
| _builder_11.append(endRange); |
| _builder_11.append(", "); |
| int _rounded = ((PropertyFillerSignedIntegerRange)type).getRounded(); |
| _builder_11.append(_rounded); |
| _builder_11.append(");"); |
| _builder_11.newLineIfNotEmpty(); |
| it_2.append(_builder_11); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerSignedIntegerRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| String _name_6 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_6); |
| _builder_7.append("_items);"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedIntegerRange) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| int _beginRange = ((PropertyFillerUnsignedIntegerRange)type).getBeginRange(); |
| _builder_7.append(_beginRange); |
| String beginRange = _builder_7.toString(); |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| int _endRange = ((PropertyFillerUnsignedIntegerRange)type).getEndRange(); |
| _builder_8.append(_endRange); |
| String endRange = _builder_8.toString(); |
| LEntityAttribute _beginRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef(); |
| boolean _tripleNotEquals_3 = (_beginRangeRef != null); |
| if (_tripleNotEquals_3) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("(int)get_\""); |
| String _name_5 = ((PropertyFillerUnsignedIntegerRange)type).getBeginRangeRef().getName(); |
| _builder_9.append(_name_5); |
| _builder_9.append("\"()"); |
| beginRange = _builder_9.toString(); |
| } |
| LEntityAttribute _endRangeRef = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef(); |
| boolean _tripleNotEquals_4 = (_endRangeRef != null); |
| if (_tripleNotEquals_4) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("(int)get_\""); |
| String _name_6 = ((PropertyFillerUnsignedIntegerRange)type).getEndRangeRef().getName(); |
| _builder_10.append(_name_6); |
| _builder_10.append("\"()"); |
| endRange = _builder_10.toString(); |
| } |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("generateUnsignedAttribute(\""); |
| String _name_7 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_11.append(_name_7); |
| _builder_11.append("\", "); |
| _builder_11.append(beginRange); |
| _builder_11.append(", "); |
| _builder_11.append(endRange); |
| _builder_11.append(", "); |
| int _rounded = ((PropertyFillerUnsignedIntegerRange)type).getRounded(); |
| _builder_11.append(_rounded); |
| _builder_11.append(");"); |
| _builder_11.newLineIfNotEmpty(); |
| it_2.append(_builder_11); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerUnsignedIntegerRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| String _name_6 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_6); |
| _builder_7.append("_items);"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextRandom) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| String _name_6 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_6); |
| _builder_7.append("_items);"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextParagraphs) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateParagraphsAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| int _count = ((PropertyFillerTextParagraphs)type).getCount(); |
| _builder_7.append(_count); |
| _builder_7.append(");"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextSentences) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateSentencesAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| int _count = ((PropertyFillerTextSentences)type).getCount(); |
| _builder_7.append(_count); |
| _builder_7.append(");"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| if (!_matched_2) { |
| if (type instanceof PropertyFillerTextWords) { |
| _matched_2=true; |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateWordsAttribute(\""); |
| String _name_5 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| int _count = ((PropertyFillerTextWords)type).getCount(); |
| _builder_7.append(_count); |
| _builder_7.append(");"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| } |
| } |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockAttributeByReference) { |
| _matched_1=true; |
| EntityMockEntity _mockedEntity = ((EntityMockAttributeByReference)attribute_1).getMockedEntity(); |
| boolean _tripleEquals = (_mockedEntity == null); |
| if (_tripleEquals) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("generateAttribute(\""); |
| String _name_5 = ((EntityMockAttributeByReference)attribute_1).getAttributeRef().getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", "); |
| String _dtoFQNForLEntity = EntityUtils.getDtoFQNForLEntity(((EntityMockAttributeByReference)attribute_1).getAttributeRef().getType()); |
| _builder_7.append(_dtoFQNForLEntity); |
| _builder_7.append(".class, "); |
| int _optionalFor = ((EntityMockAttributeByReference)attribute_1).getOptionalFor(); |
| double _divide = (((double) _optionalFor) / 100.0); |
| _builder_7.append(_divide); |
| _builder_7.append(");"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } else { |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append("generateAttribute(\""); |
| String _name_6 = ((EntityMockAttributeByReference)attribute_1).getAttributeRef().getName(); |
| _builder_8.append(_name_6); |
| _builder_8.append("\", \""); |
| String _name_7 = ((EntityMockAttributeByReference)attribute_1).getMockedEntity().getName(); |
| _builder_8.append(_name_7); |
| _builder_8.append("\", "); |
| int _optionalFor_1 = ((EntityMockAttributeByReference)attribute_1).getOptionalFor(); |
| double _divide_1 = (((double) _optionalFor_1) / 100.0); |
| _builder_8.append(_divide_1); |
| _builder_8.append(");"); |
| _builder_8.newLineIfNotEmpty(); |
| it_2.append(_builder_8); |
| } |
| } |
| } |
| } |
| EList<EntityMockEntityFunction> _calculations_1 = mockEntity.getCalculations(); |
| for (final EntityMockEntityFunction calculation_1 : _calculations_1) { |
| { |
| String doc = this._jvmTypesBuilder.getDocumentation(calculation_1); |
| if (((doc instanceof String) && (!doc.trim().isEmpty()))) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("/** "); |
| _builder_7.append(doc); |
| _builder_7.append(" */"); |
| _builder_7.newLineIfNotEmpty(); |
| it_2.append(_builder_7); |
| } |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| String paramString = _builder_8.toString(); |
| EList<EntityMockEntityFunctionParameter> _params = calculation_1.getParams(); |
| for (final EntityMockEntityFunctionParameter param : _params) { |
| { |
| boolean _isEmpty = paramString.isEmpty(); |
| boolean _not = (!_isEmpty); |
| if (_not) { |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append(paramString); |
| _builder_9.append(","); |
| paramString = _builder_9.toString(); |
| } |
| LEntityAttribute _attributeRef = param.getAttributeRef(); |
| boolean _tripleNotEquals_3 = (_attributeRef != null); |
| if (_tripleNotEquals_3) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append(paramString); |
| _builder_10.append("("); |
| String _identifier = this.getJvmType(param).getIdentifier(); |
| _builder_10.append(_identifier); |
| _builder_10.append(")getAttribute(\""); |
| String _paramName = this.getParamName(param, "."); |
| _builder_10.append(_paramName); |
| _builder_10.append("\")"); |
| paramString = _builder_10.toString(); |
| } else { |
| boolean _isReferenceOnExistingDto = this.isReferenceOnExistingDto(param); |
| if (_isReferenceOnExistingDto) { |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append(paramString); |
| _builder_11.append("("); |
| String _identifier_1 = this.getJvmType(param).getIdentifier(); |
| _builder_11.append(_identifier_1); |
| _builder_11.append(")(("); |
| String _dtoFQNForLEntity = EntityUtils.getDtoFQNForLEntity(param.getNestedAttribute().getReference().getType()); |
| _builder_11.append(_dtoFQNForLEntity); |
| _builder_11.append(")getAttribute(\""); |
| String _name_5 = param.getNestedAttribute().getAttribute().getName(); |
| _builder_11.append(_name_5); |
| _builder_11.append("\", mockDataGenerator, persistenceUnit)).get"); |
| String _firstUpper = StringExtensions.toFirstUpper(param.getNestedAttribute().getReference().getName()); |
| _builder_11.append(_firstUpper); |
| _builder_11.append("()"); |
| paramString = _builder_11.toString(); |
| } else { |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append(paramString); |
| _builder_12.append("("); |
| String _identifier_2 = this.getJvmType(param).getIdentifier(); |
| _builder_12.append(_identifier_2); |
| _builder_12.append(")getAttribute(\""); |
| String _paramName_1 = this.getParamName(param, "."); |
| _builder_12.append(_paramName_1); |
| _builder_12.append("\", mockDataGenerator, persistenceUnit)"); |
| paramString = _builder_12.toString(); |
| } |
| } |
| } |
| } |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("try {"); |
| _builder_9.newLine(); |
| _builder_9.append("\t"); |
| _builder_9.append("setFixAttribute(\""); |
| String _name_5 = calculation_1.getAttributeRef().getName(); |
| _builder_9.append(_name_5, "\t"); |
| _builder_9.append("\", calculate_"); |
| String _name_6 = calculation_1.getAttributeRef().getName(); |
| _builder_9.append(_name_6, "\t"); |
| _builder_9.append("("); |
| _builder_9.append(paramString, "\t"); |
| _builder_9.append("));"); |
| _builder_9.newLineIfNotEmpty(); |
| _builder_9.append("}"); |
| _builder_9.newLine(); |
| _builder_9.append("catch (NullPointerException npe) {}"); |
| _builder_9.newLine(); |
| _builder_9.append("catch (Exception e) {"); |
| _builder_9.newLine(); |
| _builder_9.append(" "); |
| _builder_9.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_9.newLine(); |
| _builder_9.append("}"); |
| _builder_9.newLine(); |
| it_2.append(_builder_9); |
| } |
| } |
| CompleteYearFiller _completeYearFiller_1 = mockEntity.getCompleteYearFiller(); |
| boolean _tripleNotEquals_3 = (_completeYearFiller_1 != null); |
| if (_tripleNotEquals_3) { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("getMockData().put(\""); |
| String _name_5 = mockEntity.getName(); |
| _builder_7.append(_name_5); |
| _builder_7.append("\", this.dataRow);"); |
| it_2.append(_builder_7); |
| } |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_9); |
| }; |
| JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(model, _builder_5.toString(), this._typeReferenceBuilder.typeRef(Void.TYPE), _function_8); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_3); |
| EntityMockResource _byResource_2 = mockEntity.getByResource(); |
| boolean _tripleEquals = (_byResource_2 == null); |
| if (_tripleEquals) { |
| EList<JvmMember> _members_9 = it.getMembers(); |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("generateEntity"); |
| final Procedure1<JvmOperation> _function_9 = (JvmOperation it_1) -> { |
| it_1.setVisibility(JvmVisibility.PUBLIC); |
| EList<JvmFormalParameter> _parameters = it_1.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(mockEntity, "dataRow", this._typeReferenceBuilder.typeRef(Object.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| it_1.setFinal(true); |
| final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("reset();"); |
| _builder_7.newLine(); |
| it_2.append(_builder_7); |
| LEntityAttribute _iterator = mockEntity.getIterator(); |
| boolean _tripleNotEquals_3 = (_iterator != null); |
| if (_tripleNotEquals_3) { |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| _builder_8.append("setFixAttribute(\""); |
| String _name_3 = mockEntity.getIterator().getName(); |
| _builder_8.append(_name_3); |
| _builder_8.append("\", dataRow);"); |
| _builder_8.newLineIfNotEmpty(); |
| it_2.append(_builder_8); |
| } |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| String _entityDtoFQN = this.entityDtoFQN(mockEntity); |
| _builder_9.append(_entityDtoFQN); |
| _builder_9.append(" internal = new "); |
| String _entityDtoFQN_1 = this.entityDtoFQN(mockEntity); |
| _builder_9.append(_entityDtoFQN_1); |
| _builder_9.append("();"); |
| _builder_9.newLineIfNotEmpty(); |
| _builder_9.append("entity = internal;"); |
| _builder_9.newLine(); |
| { |
| CompleteYearFiller _completeYearFiller_1 = mockEntity.getCompleteYearFiller(); |
| boolean _tripleNotEquals_4 = (_completeYearFiller_1 != null); |
| if (_tripleNotEquals_4) { |
| _builder_9.append("this.dataRow = dataRow;"); |
| } |
| } |
| _builder_9.newLineIfNotEmpty(); |
| _builder_9.append("generateData();"); |
| _builder_9.newLine(); |
| _builder_9.append("mockDataGenerator.addDtoMockData(internal, getMockData());"); |
| _builder_9.newLine(); |
| _builder_9.append("try {"); |
| _builder_9.newLine(); |
| it_2.append(_builder_9); |
| EList<IEntityMockAttribute> _attributes_1 = mockEntity.getAttributes(); |
| for (final IEntityMockAttribute attribute_1 : _attributes_1) { |
| boolean _matched_1 = false; |
| if (attribute_1 instanceof EntityMockAttributeByObject) { |
| _matched_1=true; |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("\t"); |
| _builder_10.append("internal.set"); |
| String _capitalize = WordUtils.capitalize(((EntityMockAttributeByObject)attribute_1).getAttributeRef().getName()); |
| _builder_10.append(_capitalize, "\t"); |
| _builder_10.append("("); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeByObject)attribute_1).getAttributeRef(); |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("getMockData().get(\""); |
| String _name_4 = ((EntityMockAttributeByObject)attribute_1).getAttributeRef().getName(); |
| _builder_11.append(_name_4); |
| _builder_11.append("\")"); |
| String _baseMockDataTypeCasting = this.baseMockDataTypeCasting(_attributeRef, _builder_11.toString()); |
| _builder_10.append(_baseMockDataTypeCasting, "\t"); |
| _builder_10.append(");"); |
| _builder_10.newLineIfNotEmpty(); |
| it_2.append(_builder_10); |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockAttributeFiller) { |
| _matched_1=true; |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("\t"); |
| _builder_10.append("internal.set"); |
| String _capitalize = WordUtils.capitalize(((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName()); |
| _builder_10.append(_capitalize, "\t"); |
| _builder_10.append("("); |
| LEntityAttribute _attributeRef = ((EntityMockAttributeFiller)attribute_1).getAttributeRef(); |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("getMockData().get(\""); |
| String _name_4 = ((EntityMockAttributeFiller)attribute_1).getAttributeRef().getName(); |
| _builder_11.append(_name_4); |
| _builder_11.append("\")"); |
| String _baseMockDataTypeCasting = this.baseMockDataTypeCasting(_attributeRef, _builder_11.toString()); |
| _builder_10.append(_baseMockDataTypeCasting, "\t"); |
| _builder_10.append(");"); |
| _builder_10.newLineIfNotEmpty(); |
| it_2.append(_builder_10); |
| } |
| } |
| if (!_matched_1) { |
| if (attribute_1 instanceof EntityMockAttributeByReference) { |
| _matched_1=true; |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("\t"); |
| _builder_10.append("internal.set"); |
| String _capitalize = WordUtils.capitalize(((EntityMockAttributeByReference)attribute_1).getAttributeRef().getName()); |
| _builder_10.append(_capitalize, "\t"); |
| _builder_10.append("(("); |
| String _dtoFQNForLEntity = EntityUtils.getDtoFQNForLEntity(((EntityMockAttributeByReference)attribute_1).getAttributeRef().getType()); |
| _builder_10.append(_dtoFQNForLEntity, "\t"); |
| _builder_10.append(")getMockData().get(\""); |
| String _name_4 = ((EntityMockAttributeByReference)attribute_1).getAttributeRef().getName(); |
| _builder_10.append(_name_4, "\t"); |
| _builder_10.append("\"));"); |
| _builder_10.newLineIfNotEmpty(); |
| it_2.append(_builder_10); |
| } |
| } |
| } |
| EList<EntityMockEntityFunction> _calculations_1 = mockEntity.getCalculations(); |
| for (final EntityMockEntityFunction calculation_1 : _calculations_1) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| _builder_10.append("\t"); |
| _builder_10.append("internal.set"); |
| String _capitalize = WordUtils.capitalize(calculation_1.getAttributeRef().getName()); |
| _builder_10.append(_capitalize, "\t"); |
| _builder_10.append("("); |
| LEntityAttribute _attributeRef = calculation_1.getAttributeRef(); |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("getMockData().get(\""); |
| String _name_4 = calculation_1.getAttributeRef().getName(); |
| _builder_11.append(_name_4); |
| _builder_11.append("\")"); |
| String _baseMockDataTypeCasting = this.baseMockDataTypeCasting(_attributeRef, _builder_11.toString()); |
| _builder_10.append(_baseMockDataTypeCasting, "\t"); |
| _builder_10.append(");"); |
| _builder_10.newLineIfNotEmpty(); |
| it_2.append(_builder_10); |
| } |
| CompleteYearFiller _completeYearFiller_2 = mockEntity.getCompleteYearFiller(); |
| boolean _tripleNotEquals_5 = (_completeYearFiller_2 != null); |
| if (_tripleNotEquals_5) { |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append("\t"); |
| _builder_12.append("internal.set"); |
| String _capitalize_1 = WordUtils.capitalize(mockEntity.getName()); |
| _builder_12.append(_capitalize_1, "\t"); |
| _builder_12.append("(asDate(getMockData().get(\""); |
| String _name_5 = mockEntity.getName(); |
| _builder_12.append(_name_5, "\t"); |
| _builder_12.append("\")));"); |
| _builder_12.newLineIfNotEmpty(); |
| it_2.append(_builder_12); |
| } |
| StringConcatenation _builder_13 = new StringConcatenation(); |
| _builder_13.append("}"); |
| _builder_13.newLine(); |
| _builder_13.append("catch (Exception e) {"); |
| _builder_13.newLine(); |
| _builder_13.append(" "); |
| _builder_13.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_13.newLine(); |
| _builder_13.append("}"); |
| _builder_13.newLine(); |
| _builder_13.append("return entity;"); |
| it_2.append(_builder_13); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_10); |
| }; |
| JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(model, _builder_6.toString(), this._typeReferenceBuilder.typeRef(Object.class), _function_9); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_4); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(mockClass, _function); |
| } |
| |
| public boolean isReferenceOnExistingDto(final EntityMockEntityFunctionParameter param) { |
| EObject _eContainer = param.eContainer().eContainer(); |
| final EntityMockEntity entityMock = ((EntityMockEntity) _eContainer); |
| EList<IEntityMockAttribute> _attributes = entityMock.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| if ((attribute instanceof EntityMockAttributeByReference)) { |
| EntityMockEntity _mockedEntity = ((EntityMockAttributeByReference)attribute).getMockedEntity(); |
| boolean _tripleEquals = (_mockedEntity == null); |
| if (_tripleEquals) { |
| boolean _equals = ((EntityMockAttributeByReference)attribute).getAttributeRef().getType().equals(param.getNestedAttribute().getReference().eContainer()); |
| if (_equals) { |
| return true; |
| } |
| } |
| } |
| } |
| return false; |
| } |
| |
| public JvmTypeReference getJvmType(final EntityMockEntityFunctionParameter param) { |
| LEntityAttribute _attributeRef = param.getAttributeRef(); |
| boolean _tripleNotEquals = (_attributeRef != null); |
| if (_tripleNotEquals) { |
| return this.jvmTypeRef(param.getAttributeRef()); |
| } else { |
| return this.entityExtensions.toTypeReference(param.getNestedAttribute().getAttribute()); |
| } |
| } |
| |
| public String getParamName(final EntityMockEntityFunctionParameter param, final String separator) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String paramName = _builder.toString(); |
| LEntityAttribute _attributeRef = param.getAttributeRef(); |
| boolean _tripleNotEquals = (_attributeRef != null); |
| if (_tripleNotEquals) { |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| String _name = param.getAttributeRef().getName(); |
| _builder_1.append(_name); |
| paramName = _builder_1.toString(); |
| } else { |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| String _name_1 = param.getNestedAttribute().getReference().getName(); |
| _builder_2.append(_name_1); |
| _builder_2.append(separator); |
| paramName = _builder_2.toString(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append(paramName); |
| String _name_2 = param.getNestedAttribute().getAttribute().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("\""); |
| String _format = String.format("%04d-%02d-%02d", Integer.valueOf(date.getYear()), Integer.valueOf(date.getMonth()), Integer.valueOf(date.getDay())); |
| 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 EntityMock mock, final IJvmDeclaredTypeAcceptor acceptor) { |
| JvmGenericType mockClass = this._jvmTypesBuilder.toClass(mock, this.entityMockName(mock)); |
| final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { |
| this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(mock)); |
| JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Component.class); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IEntityMockDataGenerator.class); |
| this._commonUtils.addAnnAttr(annotationRef, mock, "service", ((JvmTypeReference) _typeRef)); |
| this._commonUtils.addAnnAttr(annotationRef, mock, "immediate", Boolean.valueOf(true)); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef); |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(AEntityMockDataGenerator.class); |
| this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef_1); |
| it.setFinal(true); |
| JvmField field = null; |
| final Procedure1<JvmField> _function_1 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("LoggerFactory.getLogger(\"mock\")"); |
| it_2.append(_builder); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_2); |
| }; |
| field = this._jvmTypesBuilder.toField(mock, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function_1); |
| field.setFinal(true); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| EList<JvmMember> _members_1 = it.getMembers(); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("getRunWithPriority"); |
| final Procedure1<JvmOperation> _function_2 = (JvmOperation it_1) -> { |
| EList<JvmAnnotationReference> _annotations_1 = it_1.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_2) -> { |
| int count = IEntityMockDataGenerator.DEFAULT_PRIORITY; |
| int _runPriority = mock.getRunPriority(); |
| boolean _greaterThan = (_runPriority > 0); |
| if (_greaterThan) { |
| count = mock.getRunPriority(); |
| } |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("return "); |
| _builder_1.append(count); |
| _builder_1.append(";"); |
| _builder_1.newLineIfNotEmpty(); |
| it_2.append(_builder_1); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_3); |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(mock, _builder.toString(), this._typeReferenceBuilder.typeRef(int.class), _function_2); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method); |
| EList<JvmMember> _members_2 = it.getMembers(); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| _builder_1.append("getDataInterchangeSteps"); |
| final Procedure1<JvmOperation> _function_3 = (JvmOperation it_1) -> { |
| EList<JvmAnnotationReference> _annotations_1 = it_1.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> { |
| int count = 0; |
| RunningDataInterchanges _datainterchanges = mock.getDatainterchanges(); |
| boolean _tripleNotEquals = (_datainterchanges != null); |
| if (_tripleNotEquals) { |
| count = mock.getDatainterchanges().getDatainterchanges().size(); |
| } |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("return "); |
| _builder_2.append(count); |
| _builder_2.append(";"); |
| _builder_2.newLineIfNotEmpty(); |
| it_2.append(_builder_2); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_4); |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(mock, _builder_1.toString(), this._typeReferenceBuilder.typeRef(int.class), _function_3); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_1); |
| EList<JvmMember> _members_3 = it.getMembers(); |
| StringConcatenation _builder_2 = new StringConcatenation(); |
| _builder_2.append("getEntityMockSteps"); |
| final Procedure1<JvmOperation> _function_4 = (JvmOperation it_1) -> { |
| EList<JvmAnnotationReference> _annotations_1 = it_1.getAnnotations(); |
| JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); |
| this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef); |
| final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_2) -> { |
| int count = 0; |
| EntityMockEntities _entities = mock.getEntities(); |
| boolean _tripleNotEquals = (_entities != null); |
| if (_tripleNotEquals) { |
| count = mock.getEntities().getEntities().size(); |
| } |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("return "); |
| _builder_3.append(count); |
| _builder_3.append(";"); |
| _builder_3.newLineIfNotEmpty(); |
| it_2.append(_builder_3); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_5); |
| }; |
| JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(mock, _builder_2.toString(), this._typeReferenceBuilder.typeRef(int.class), _function_4); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_2); |
| EList<JvmMember> _members_4 = it.getMembers(); |
| StringConcatenation _builder_3 = new StringConcatenation(); |
| _builder_3.append("runDataInterchanges"); |
| final Procedure1<JvmOperation> _function_5 = (JvmOperation it_1) -> { |
| EList<JvmFormalParameter> _parameters = it_1.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(mock, "persistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it_1.getParameters(); |
| JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(mock, "dataInterchange", this._typeReferenceBuilder.typeRef(IDataInterchange.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| EList<JvmFormalParameter> _parameters_2 = it_1.getParameters(); |
| JvmFormalParameter _parameter_2 = this._jvmTypesBuilder.toParameter(mock, "eventDispatcher", this._typeReferenceBuilder.typeRef(IEventDispatcher.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2); |
| EList<JvmFormalParameter> _parameters_3 = it_1.getParameters(); |
| JvmFormalParameter _parameter_3 = this._jvmTypesBuilder.toParameter(mock, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_3, _parameter_3); |
| EList<JvmFormalParameter> _parameters_4 = it_1.getParameters(); |
| JvmFormalParameter _parameter_4 = this._jvmTypesBuilder.toParameter(mock, "entityMockDbFiller", this._typeReferenceBuilder.typeRef(IEntityMockDataDbFiller.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_4, _parameter_4); |
| final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_2) -> { |
| RunningDataInterchanges _datainterchanges = mock.getDatainterchanges(); |
| boolean _tripleNotEquals = (_datainterchanges != null); |
| if (_tripleNotEquals) { |
| EList<RunningDataInterchange> _datainterchanges_1 = mock.getDatainterchanges().getDatainterchanges(); |
| for (final RunningDataInterchange runDatainterchange : _datainterchanges_1) { |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("try {"); |
| _builder_4.newLine(); |
| _builder_4.append("\t"); |
| _builder_4.append("entityMockDbFiller.notifyInitializationStep(\"datainterchange "); |
| String _name = runDatainterchange.getDatainterchangeRef().getName(); |
| _builder_4.append(_name, "\t"); |
| _builder_4.append("\", 1, 0.3);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("\t"); |
| String _basicRunConfiguration = this._dataDSLJvmModelInferrer.getBasicRunConfiguration(runDatainterchange.getDatainterchangeRef(), true, "import", null); |
| _builder_4.append(_basicRunConfiguration, "\t"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("\t"); |
| _builder_4.append("entityMockDbFiller.notifyInitializationStep(\"datainterchange "); |
| String _name_1 = runDatainterchange.getDatainterchangeRef().getName(); |
| _builder_4.append(_name_1, "\t"); |
| _builder_4.append("\", 0, 0.4);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("\t"); |
| String _defaultVariableName = this._dataDSLJvmModelInferrer.getDefaultVariableName(runDatainterchange.getDatainterchangeRef()); |
| _builder_4.append(_defaultVariableName, "\t"); |
| _builder_4.append(".run(entityMockDbFiller);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("\t"); |
| _builder_4.append("entityMockDbFiller.notifyInitializationStep(\"datainterchange "); |
| String _name_2 = runDatainterchange.getDatainterchangeRef().getName(); |
| _builder_4.append(_name_2, "\t"); |
| _builder_4.append("\", 0, 0.9);"); |
| _builder_4.newLineIfNotEmpty(); |
| _builder_4.append("} "); |
| _builder_4.newLine(); |
| _builder_4.append("catch (Exception e) {"); |
| _builder_4.newLine(); |
| _builder_4.append("\t"); |
| _builder_4.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_4.newLine(); |
| _builder_4.append("}"); |
| _builder_4.newLine(); |
| it_2.append(_builder_4); |
| } |
| } |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_6); |
| }; |
| JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(mock, _builder_3.toString(), this._typeReferenceBuilder.typeRef(Void.TYPE), _function_5); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_3); |
| EList<JvmMember> _members_5 = it.getMembers(); |
| StringConcatenation _builder_4 = new StringConcatenation(); |
| _builder_4.append("getMockData"); |
| final Procedure1<JvmOperation> _function_6 = (JvmOperation it_1) -> { |
| EList<JvmFormalParameter> _parameters = it_1.getParameters(); |
| JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(mock, "entityMockDbFiller", this._typeReferenceBuilder.typeRef(IEntityMockDataDbFiller.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it_1.getParameters(); |
| JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(mock, "persistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| EList<JvmFormalParameter> _parameters_2 = it_1.getParameters(); |
| JvmFormalParameter _parameter_2 = this._jvmTypesBuilder.toParameter(mock, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class)); |
| this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2); |
| final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder_5 = new StringConcatenation(); |
| _builder_5.append("initialize();"); |
| _builder_5.newLine(); |
| it_2.append(_builder_5); |
| ArrayList<EntityMockEntity> mockEntitiesDone = new ArrayList<EntityMockEntity>(); |
| ArrayList<EntityMockEntity> mockEntitiesToDo = new ArrayList<EntityMockEntity>(); |
| EntityMockEntities _entities = mock.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 = 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_6 = new StringConcatenation(); |
| StringConcatenation _builder_7 = new StringConcatenation(); |
| _builder_7.append("Iterator<Integer> iterator"); |
| String _name = mockEntity.getName(); |
| _builder_7.append(_name); |
| _builder_7.append(" = new IntegerIterator("); |
| int _from = iterate.getFrom(); |
| _builder_7.append(_from); |
| _builder_7.append(", "); |
| int _until = iterate.getUntil(); |
| _builder_7.append(_until); |
| _builder_7.append(", "); |
| int _step = iterate.getStep(); |
| _builder_7.append(_step); |
| _builder_7.append(");"); |
| Object _textForGetMockData = this.textForGetMockData(mockEntity, mock, _builder_7.toString()); |
| _builder_6.append(_textForGetMockData); |
| it_2.append(_builder_6); |
| } |
| IIterate _iterate_2 = mockEntity.getIterate(); |
| if ((_iterate_2 instanceof DateIterate)) { |
| IIterate _iterate_3 = mockEntity.getIterate(); |
| DateIterate iterate_1 = ((DateIterate) _iterate_3); |
| StringConcatenation _builder_8 = new StringConcatenation(); |
| StringConcatenation _builder_9 = new StringConcatenation(); |
| _builder_9.append("Iterator<Date> iterator"); |
| String _name_1 = mockEntity.getName(); |
| _builder_9.append(_name_1); |
| _builder_9.append(" = new DateIterator("); |
| String _asString = this.asString(iterate_1.getFrom()); |
| _builder_9.append(_asString); |
| _builder_9.append(", "); |
| String _asString_1 = this.asString(iterate_1.getUntil()); |
| _builder_9.append(_asString_1); |
| _builder_9.append(", "); |
| int _stepCount = iterate_1.getStepCount(); |
| _builder_9.append(_stepCount); |
| _builder_9.append(", \""); |
| EDateStepType _stepType = iterate_1.getStepType(); |
| _builder_9.append(_stepType); |
| _builder_9.append("\");"); |
| Object _textForGetMockData_1 = this.textForGetMockData(mockEntity, mock, _builder_9.toString()); |
| _builder_8.append(_textForGetMockData_1); |
| it_2.append(_builder_8); |
| } else { |
| EntityMockResource _byResource = mockEntity.getByResource(); |
| boolean _tripleNotEquals = (_byResource != null); |
| if (_tripleNotEquals) { |
| StringConcatenation _builder_10 = new StringConcatenation(); |
| StringConcatenation _builder_11 = new StringConcatenation(); |
| _builder_11.append("Iterator iterator"); |
| String _name_2 = mockEntity.getName(); |
| _builder_11.append(_name_2); |
| _builder_11.append(" = entity"); |
| String _name_3 = mockEntity.getName(); |
| _builder_11.append(_name_3); |
| _builder_11.append(".getDataRows().iterator();"); |
| Object _textForGetMockData_2 = this.textForGetMockData(mockEntity, mock, _builder_11.toString()); |
| _builder_10.append(_textForGetMockData_2); |
| it_2.append(_builder_10); |
| boolean _isCreateBlobMapping = mockEntity.isCreateBlobMapping(); |
| if (_isCreateBlobMapping) { |
| StringConcatenation _builder_12 = new StringConcatenation(); |
| _builder_12.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName = this.entityMockName(mockEntity, mock); |
| _builder_12.append(_entityMockName); |
| _builder_12.append("Blobs\", 0, 0.93);"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append("List list"); |
| String _name_4 = mockEntity.getName(); |
| _builder_12.append(_name_4); |
| _builder_12.append("Blobs = new ArrayList<org.eclipse.osbp.blob.dtos.BlobDto>();"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_1 = this.entityMockName(mockEntity, mock); |
| _builder_12.append(_entityMockName_1); |
| _builder_12.append("Blobs\", 0, 0.96);"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append("for (Object list"); |
| String _name_5 = mockEntity.getName(); |
| _builder_12.append(_name_5); |
| _builder_12.append("Object : list"); |
| String _name_6 = mockEntity.getName(); |
| _builder_12.append(_name_6); |
| _builder_12.append(") {"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append(" "); |
| _builder_12.append("if (list"); |
| String _name_7 = mockEntity.getName(); |
| _builder_12.append(_name_7, " "); |
| _builder_12.append("Object instanceof org.eclipse.osbp.blob.dtos.BlobMappingDto) {"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append(" "); |
| _builder_12.append("org.eclipse.osbp.blob.dtos.BlobMappingDto blobMappingDto = (org.eclipse.osbp.blob.dtos.BlobMappingDto)list"); |
| String _name_8 = mockEntity.getName(); |
| _builder_12.append(_name_8, " "); |
| _builder_12.append("Object;"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append(" "); |
| _builder_12.append("try {"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("InputStream inputStream = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(\"/resources/entitymock/\"+blobMappingDto.getFileName()));"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("if (inputStream != null) {"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("List<Object> blobs = blobService.createBlobMappingBlobs(inputStream, blobMappingDto.getMimeTypeId());"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("for(Object obj:blobs) {"); |
| _builder_12.newLine(); |
| _builder_12.append("\t "); |
| _builder_12.append("blobMappingDto.addToBlobsRef((org.eclipse.osbp.blob.dtos.BlobDto)obj);"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("list"); |
| String _name_9 = mockEntity.getName(); |
| _builder_12.append(_name_9, " "); |
| _builder_12.append("Blobs.add((org.eclipse.osbp.blob.dtos.BlobDto)obj);"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append(" "); |
| _builder_12.append("}"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("}"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("}"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("catch (Exception e) {"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("log.error(e.getLocalizedMessage()+e.getCause());"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("}"); |
| _builder_12.newLine(); |
| _builder_12.append(" "); |
| _builder_12.append("}"); |
| _builder_12.newLine(); |
| _builder_12.append("}"); |
| _builder_12.newLine(); |
| _builder_12.append("addMockObjects(\""); |
| String _name_10 = mockEntity.getName(); |
| _builder_12.append(_name_10); |
| _builder_12.append("Blobs\", org.eclipse.osbp.blob.dtos.BlobDto.class, \"blob\", list"); |
| String _name_11 = mockEntity.getName(); |
| _builder_12.append(_name_11); |
| _builder_12.append("Blobs);"); |
| _builder_12.newLineIfNotEmpty(); |
| _builder_12.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_2 = this.entityMockName(mockEntity, mock); |
| _builder_12.append(_entityMockName_2); |
| _builder_12.append("Blobs\", 0, 0.99);"); |
| _builder_12.newLineIfNotEmpty(); |
| it_2.append(_builder_12); |
| } |
| } else { |
| CompleteYearFiller _completeYearFiller = mockEntity.getCompleteYearFiller(); |
| boolean _tripleNotEquals_1 = (_completeYearFiller != null); |
| if (_tripleNotEquals_1) { |
| String iteratorParams = ""; |
| PropertyFillerDateType _fillerDateType = mockEntity.getCompleteYearFiller().getFillerDateType(); |
| if ((_fillerDateType instanceof PropertyFillerDateFuture)) { |
| StringConcatenation _builder_13 = new StringConcatenation(); |
| PropertyFillerDateType _fillerDateType_1 = mockEntity.getCompleteYearFiller().getFillerDateType(); |
| int _dateFutureYears = ((PropertyFillerDateFuture) _fillerDateType_1).getDateFutureYears(); |
| _builder_13.append(_dateFutureYears); |
| iteratorParams = _builder_13.toString(); |
| } else { |
| PropertyFillerDateType _fillerDateType_2 = mockEntity.getCompleteYearFiller().getFillerDateType(); |
| if ((_fillerDateType_2 instanceof PropertyFillerDatePast)) { |
| StringConcatenation _builder_14 = new StringConcatenation(); |
| _builder_14.append("-"); |
| PropertyFillerDateType _fillerDateType_3 = mockEntity.getCompleteYearFiller().getFillerDateType(); |
| int _datePastYears = ((PropertyFillerDatePast) _fillerDateType_3).getDatePastYears(); |
| _builder_14.append(_datePastYears); |
| iteratorParams = _builder_14.toString(); |
| } else { |
| PropertyFillerDateType _fillerDateType_4 = mockEntity.getCompleteYearFiller().getFillerDateType(); |
| if ((_fillerDateType_4 instanceof PropertyFillerDateRange)) { |
| StringConcatenation _builder_15 = new StringConcatenation(); |
| PropertyFillerDateType _fillerDateType_5 = mockEntity.getCompleteYearFiller().getFillerDateType(); |
| int _dateBeginYears = ((PropertyFillerDateRange) _fillerDateType_5).getDateBeginYears(); |
| _builder_15.append(_dateBeginYears); |
| _builder_15.append(", "); |
| PropertyFillerDateType _fillerDateType_6 = mockEntity.getCompleteYearFiller().getFillerDateType(); |
| int _dateEndYears = ((PropertyFillerDateRange) _fillerDateType_6).getDateEndYears(); |
| _builder_15.append(_dateEndYears); |
| iteratorParams = _builder_15.toString(); |
| } |
| } |
| } |
| StringConcatenation _builder_16 = new StringConcatenation(); |
| StringConcatenation _builder_17 = new StringConcatenation(); |
| _builder_17.append("Iterator<Date> iterator"); |
| String _name_12 = mockEntity.getName(); |
| _builder_17.append(_name_12); |
| _builder_17.append(" = new DateIterator("); |
| _builder_17.append(iteratorParams); |
| _builder_17.append(");"); |
| Object _textForGetMockData_3 = this.textForGetMockData(mockEntity, mock, _builder_17.toString()); |
| _builder_16.append(_textForGetMockData_3); |
| it_2.append(_builder_16); |
| } else { |
| StringConcatenation _builder_18 = new StringConcatenation(); |
| StringConcatenation _builder_19 = new StringConcatenation(); |
| _builder_19.append("Iterator<Integer> iterator"); |
| String _name_13 = mockEntity.getName(); |
| _builder_19.append(_name_13); |
| _builder_19.append(" = new IntegerIterator(1, getFillerProvider().signedinteger("); |
| int _minRows = mockEntity.getMinRows(); |
| _builder_19.append(_minRows); |
| _builder_19.append(", "); |
| int _maxRows = mockEntity.getMaxRows(); |
| _builder_19.append(_maxRows); |
| _builder_19.append("));"); |
| Object _textForGetMockData_4 = this.textForGetMockData(mockEntity, mock, _builder_19.toString()); |
| _builder_18.append(_textForGetMockData_4); |
| it_2.append(_builder_18); |
| } |
| } |
| } |
| mockEntitiesDone.add(((EntityMockEntity) mockEntity)); |
| mockEntitiesToDo.remove(mockEntity); |
| } |
| } |
| } |
| breakTodo = (handled == 0); |
| } |
| } |
| StringConcatenation _builder_6 = new StringConcatenation(); |
| _builder_6.append("return mockDataClassMap;"); |
| it_2.append(_builder_6); |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_7); |
| }; |
| JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(mock, _builder_4.toString(), this._typeReferenceBuilder.typeRef(Map.class), _function_6); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_4); |
| }; |
| acceptor.<JvmGenericType>accept(mockClass, _function); |
| } |
| |
| protected Object textForGetMockData(final EntityMockEntity mockEntity, final EntityMock mock, final String iteratorLine) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName = this.entityMockName(mockEntity, mock); |
| _builder.append(_entityMockName); |
| _builder.append("\", 1, 0.3);"); |
| _builder.newLineIfNotEmpty(); |
| String _entityMockName_1 = this.entityMockName(mockEntity, mock); |
| _builder.append(_entityMockName_1); |
| _builder.append(" entity"); |
| String _name = mockEntity.getName(); |
| _builder.append(_name); |
| _builder.append(" = new "); |
| String _entityMockName_2 = this.entityMockName(mockEntity, mock); |
| _builder.append(_entityMockName_2); |
| _builder.append("(this);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append(iteratorLine); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("List list"); |
| String _name_1 = mockEntity.getName(); |
| _builder.append(_name_1); |
| _builder.append(" = new ArrayList<"); |
| String _entityDtoFQN = this.entityDtoFQN(mockEntity); |
| _builder.append(_entityDtoFQN); |
| _builder.append(">();"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_3 = this.entityMockName(mockEntity, mock); |
| _builder.append(_entityMockName_3); |
| _builder.append("\", 0, 0.6);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("persistenceService.registerPersistenceUnit(entity"); |
| String _name_2 = mockEntity.getName(); |
| _builder.append(_name_2); |
| _builder.append(".getPersistenceUnit(), "); |
| String _entityFQN = this.entityFQN(mockEntity); |
| _builder.append(_entityFQN); |
| _builder.append(".class);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("while (iterator"); |
| String _name_3 = mockEntity.getName(); |
| _builder.append(_name_3); |
| _builder.append(".hasNext()) {"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append(" "); |
| _builder.append("list"); |
| String _name_4 = mockEntity.getName(); |
| _builder.append(_name_4, " "); |
| _builder.append(".add(entity"); |
| String _name_5 = mockEntity.getName(); |
| _builder.append(_name_5, " "); |
| _builder.append(".generateEntity(iterator"); |
| String _name_6 = mockEntity.getName(); |
| _builder.append(_name_6, " "); |
| _builder.append(".next()));"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("}"); |
| _builder.newLine(); |
| _builder.append("addMockObjects(\""); |
| String _name_7 = mockEntity.getName(); |
| _builder.append(_name_7); |
| _builder.append("\", "); |
| String _entityDtoFQNClass = this.entityDtoFQNClass(mockEntity); |
| _builder.append(_entityDtoFQNClass); |
| _builder.append(", \""); |
| String _persistenceUnit = mockEntity.getEntityRef().getPersistenceUnit(); |
| _builder.append(_persistenceUnit); |
| _builder.append("\", list"); |
| String _name_8 = mockEntity.getName(); |
| _builder.append(_name_8); |
| _builder.append(");"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("entityMockDbFiller.notifyInitializationStep(\"generate "); |
| String _entityMockName_4 = this.entityMockName(mockEntity, mock); |
| _builder.append(_entityMockName_4); |
| _builder.append("\", 0, 0.9);"); |
| _builder.newLineIfNotEmpty(); |
| return _builder; |
| } |
| |
| /** |
| * 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 _tripleNotEquals = (_byResource != null); |
| if (_tripleNotEquals) { |
| return true; |
| } |
| EList<IEntityMockAttribute> _attributes = mockEntityTodo.getAttributes(); |
| for (final IEntityMockAttribute attribute : _attributes) { |
| if ((attribute instanceof EntityMockAttributeByReference)) { |
| EntityMockEntity referencedMockEntity = ((EntityMockAttributeByReference) attribute).getMockedEntity(); |
| if (((referencedMockEntity != null) && (!mockEntitiesDone.contains(referencedMockEntity)))) { |
| return false; |
| } |
| } |
| } |
| return true; |
| } |
| |
| /** |
| * generate a mock object class |
| */ |
| public void generateMockResource(final EntityMock model, final IJvmDeclaredTypeAcceptor acceptor, final EntityMockResource mockResource) { |
| JvmGenericType mockClass = this._jvmTypesBuilder.toClass(model, this.entityMockName(mockResource, model)); |
| final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { |
| this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(model)); |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(ABaseMockResource.class); |
| this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); |
| JvmField field = null; |
| final Procedure1<JvmField> _function_1 = (JvmField it_1) -> { |
| final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_2) -> { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("LoggerFactory.getLogger(\"mock\")"); |
| it_2.append(_builder); |
| }; |
| this._jvmTypesBuilder.setInitializer(it_1, _function_2); |
| }; |
| field = this._jvmTypesBuilder.toField(model, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function_1); |
| field.setFinal(true); |
| field.setStatic(true); |
| EList<JvmMember> _members = it.getMembers(); |
| final Procedure1<JvmConstructor> _function_2 = (JvmConstructor it_1) -> { |
| final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_2) -> { |
| 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_2.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_2.append(_builder_4); |
| } |
| } |
| }; |
| this._jvmTypesBuilder.setBody(it_1, _function_3); |
| }; |
| JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(model, _function_2); |
| this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor); |
| }; |
| acceptor.<JvmGenericType>accept(mockClass, _function); |
| } |
| |
| public void infer(final EObject mock, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { |
| if (mock instanceof EntityMock) { |
| _infer((EntityMock)mock, acceptor, isPreIndexingPhase); |
| return; |
| } else if (mock != null) { |
| _infer(mock, acceptor, isPreIndexingPhase); |
| return; |
| } else { |
| throw new IllegalArgumentException("Unhandled parameter types: " + |
| Arrays.<Object>asList(mock, acceptor, isPreIndexingPhase).toString()); |
| } |
| } |
| } |