catch up with branch daily Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.xtext.entitymock/src/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.xtend b/org.eclipse.osbp.xtext.entitymock/src/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.xtend index 9841fc2..dfaf422 100644 --- a/org.eclipse.osbp.xtext.entitymock/src/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.xtend +++ b/org.eclipse.osbp.xtext.entitymock/src/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.xtend
@@ -92,6 +92,7 @@ import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder import org.osgi.service.component.annotations.Component import org.slf4j.Logger +import org.eclipse.osbp.dsl.semantic.entity.LEntityReference /** * <p>Infers a JVM model from the source model.</p> @@ -1224,9 +1225,8 @@ ''') } EntityMockAttributeByReference: { - append(''' internal.set«WordUtils.capitalize(attribute.attributeRef.name)»((«EntityUtils. - getDtoFQNForLEntity(attribute.attributeRef.type)»)getMockData().get("«attribute. - attributeRef.name»")); + append(''' internal.set«WordUtils.capitalize(attribute.attributeRef.name)»(«attribute.attributeRef.baseMockDataTypeCasting('''getMockData().get("«attribute. + attributeRef.name»")''')»); ''') } } @@ -1255,7 +1255,7 @@ } ] } - + def boolean isReferenceOnExistingDto(EntityMockEntityFunctionParameter param) { val entityMock = param.eContainer.eContainer as EntityMockEntity for (attribute : entityMock.attributes) { @@ -1319,6 +1319,18 @@ } } + + /** + * generate the code for casting a mock data to the data type of the entity attribute + */ + def String baseMockDataTypeCasting(LEntityReference entityRef, String getting) { + var text = EntityUtils.getDtoFQNForLEntity(entityRef.type) + if (entityRef.multiplicity !== null) { + text = '''List<«text»>''' + } + return '''(«text»)«getting»''' + } + /** * generate the code for casting a mock data to the data type of the entity attribute */ @@ -1329,6 +1341,9 @@ if (attribute.type instanceof LBean) { return '''(«EntityUtils.getDtoFQNForLBean(attribute.type as LBean)»)(«getting»)''' } + if (attribute.type instanceof LBean) { + return '''(«EntityUtils.getDtoFQNForLBean(attribute.type as LBean)»)(«getting»)''' + } var etype = dtType.getBasicType(attribute) switch (etype) { case BOOLEAN: return '''asBoolean(«getting»)''' @@ -1577,7 +1592,6 @@ «iteratorLine» List list«mockEntity.name» = new ArrayList<«mockEntity.entityDtoFQN»>(); entityMockDbFiller.notifyInitializationStep("generate «mockEntity.entityMockName(mock)»", 0, 0.6); - persistenceService.registerPersistenceUnit(entity«mockEntity.name».getPersistenceUnit(), «mockEntity.entityFQN».class); while (iterator«mockEntity.name».hasNext()) { list«mockEntity.name».add(entity«mockEntity.name».generateEntity(iterator«mockEntity.name».next())); }
diff --git a/org.eclipse.osbp.xtext.entitymock/xtend-gen/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.java b/org.eclipse.osbp.xtext.entitymock/xtend-gen/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.java index 029a6c8..d30f88d 100644 --- a/org.eclipse.osbp.xtext.entitymock/xtend-gen/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.java +++ b/org.eclipse.osbp.xtext.entitymock/xtend-gen/org/eclipse/osbp/xtext/entitymock/jvmmodel/EntityMockDSLJvmModelInferrer.java
@@ -33,10 +33,12 @@ 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.LMultiplicity; import org.eclipse.osbp.dsl.semantic.common.types.LScalarType; import org.eclipse.osbp.dsl.semantic.entity.LBean; import org.eclipse.osbp.dsl.semantic.entity.LEntity; import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute; +import org.eclipse.osbp.dsl.semantic.entity.LEntityReference; import org.eclipse.osbp.runtime.common.event.IEventDispatcher; import org.eclipse.osbp.ui.api.customfields.IBlobService; import org.eclipse.osbp.ui.api.datamart.IDataMart; @@ -2563,13 +2565,16 @@ _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(\""); + _builder_10.append("("); + LEntityReference _attributeRef = ((EntityMockAttributeByReference)attribute_1).getAttributeRef(); + StringConcatenation _builder_11 = new StringConcatenation(); + _builder_11.append("getMockData().get(\""); String _name_4 = ((EntityMockAttributeByReference)attribute_1).getAttributeRef().getName(); - _builder_10.append(_name_4, "\t"); - _builder_10.append("\"));"); + _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); } @@ -2722,6 +2727,28 @@ /** * generate the code for casting a mock data to the data type of the entity attribute */ + public String baseMockDataTypeCasting(final LEntityReference entityRef, final String getting) { + String text = EntityUtils.getDtoFQNForLEntity(entityRef.getType()); + LMultiplicity _multiplicity = entityRef.getMultiplicity(); + boolean _tripleNotEquals = (_multiplicity != null); + if (_tripleNotEquals) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append("List<"); + _builder.append(text); + _builder.append(">"); + text = _builder.toString(); + } + StringConcatenation _builder_1 = new StringConcatenation(); + _builder_1.append("("); + _builder_1.append(text); + _builder_1.append(")"); + _builder_1.append(getting); + return _builder_1.toString(); + } + + /** + * 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)) { @@ -2746,76 +2773,88 @@ _builder_1.append(")"); return _builder_1.toString(); } + LScalarType _type_4 = attribute.getType(); + if ((_type_4 instanceof LBean)) { + StringConcatenation _builder_2 = new StringConcatenation(); + _builder_2.append("("); + LScalarType _type_5 = attribute.getType(); + String _dtoFQNForLBean_1 = EntityUtils.getDtoFQNForLBean(((LBean) _type_5)); + _builder_2.append(_dtoFQNForLBean_1); + _builder_2.append(")("); + _builder_2.append(getting); + _builder_2.append(")"); + return _builder_2.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("asBoolean("); _builder_3.append(getting); _builder_3.append(")"); return _builder_3.toString(); - case DATE: + case BYTE: StringConcatenation _builder_4 = new StringConcatenation(); - _builder_4.append("asDate("); + _builder_4.append("asByte("); _builder_4.append(getting); _builder_4.append(")"); return _builder_4.toString(); - case FLOAT: + case DATE: StringConcatenation _builder_5 = new StringConcatenation(); - _builder_5.append("asFloat("); + _builder_5.append("asDate("); _builder_5.append(getting); _builder_5.append(")"); return _builder_5.toString(); - case DOUBLE: + case FLOAT: StringConcatenation _builder_6 = new StringConcatenation(); - _builder_6.append("asDouble("); + _builder_6.append("asFloat("); _builder_6.append(getting); _builder_6.append(")"); return _builder_6.toString(); - case SHORT: + case DOUBLE: StringConcatenation _builder_7 = new StringConcatenation(); - _builder_7.append("asShort("); + _builder_7.append("asDouble("); _builder_7.append(getting); _builder_7.append(")"); return _builder_7.toString(); - case INTEGER: + case SHORT: StringConcatenation _builder_8 = new StringConcatenation(); - _builder_8.append("asInt("); + _builder_8.append("asShort("); _builder_8.append(getting); _builder_8.append(")"); return _builder_8.toString(); - case LONG: + case INTEGER: StringConcatenation _builder_9 = new StringConcatenation(); - _builder_9.append("asLong("); + _builder_9.append("asInt("); _builder_9.append(getting); _builder_9.append(")"); return _builder_9.toString(); - case TIME: + case LONG: StringConcatenation _builder_10 = new StringConcatenation(); - _builder_10.append("asTime("); + _builder_10.append("asLong("); _builder_10.append(getting); _builder_10.append(")"); return _builder_10.toString(); - default: + case TIME: StringConcatenation _builder_11 = new StringConcatenation(); - _builder_11.append("asString("); + _builder_11.append("asTime("); _builder_11.append(getting); _builder_11.append(")"); return _builder_11.toString(); + default: + StringConcatenation _builder_12 = new StringConcatenation(); + _builder_12.append("asString("); + _builder_12.append(getting); + _builder_12.append(")"); + return _builder_12.toString(); } } else { - StringConcatenation _builder_11 = new StringConcatenation(); - _builder_11.append("asString("); - _builder_11.append(getting); - _builder_11.append(")"); - return _builder_11.toString(); + StringConcatenation _builder_12 = new StringConcatenation(); + _builder_12.append("asString("); + _builder_12.append(getting); + _builder_12.append(")"); + return _builder_12.toString(); } } @@ -3346,36 +3385,28 @@ _builder.append(_entityMockName_3); _builder.append("\", 0, 0.6);"); _builder.newLineIfNotEmpty(); - _builder.append("persistenceService.registerPersistenceUnit(entity"); + _builder.append("while (iterator"); 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_3 = mockEntity.getName(); + _builder.append(_name_3, " "); + _builder.append(".add(entity"); String _name_4 = mockEntity.getName(); _builder.append(_name_4, " "); - _builder.append(".add(entity"); + _builder.append(".generateEntity(iterator"); 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); + String _name_6 = mockEntity.getName(); + _builder.append(_name_6); _builder.append("\", "); String _entityDtoFQNClass = this.entityDtoFQNClass(mockEntity); _builder.append(_entityDtoFQNClass); @@ -3383,8 +3414,8 @@ String _persistenceUnit = mockEntity.getEntityRef().getPersistenceUnit(); _builder.append(_persistenceUnit); _builder.append("\", list"); - String _name_8 = mockEntity.getName(); - _builder.append(_name_8); + String _name_7 = mockEntity.getName(); + _builder.append(_name_7); _builder.append(");"); _builder.newLineIfNotEmpty(); _builder.append("entityMockDbFiller.notifyInitializationStep(\"generate ");