templates.DataView.xpt Maven / Gradle / Ivy
?IMPORT dom?
?IMPORT core?
?EXTENSION extensions::EntityExtension?
?EXTENSION extensions::DataViewExtension?
?EXTENSION extensions::MapperExtension?
?EXTENSION extensions::File?
?EXTENSION extensions::JavaUtil?
?EXTENSION extensions::Names?
?EXTENSION extensions::Properties?
?EXTENSION extensions::Validation?
?EXTENSION org::openxma::dsl::common::extensions::LogUtil?
?DEFINE main FOR Model?
?IF !isNameSpaceGenerated()-?
?addGeneratedNameSpaceName()-?
?EXPAND dtoAssemblerFactory FOR this?
?EXPAND manualDtoAssemblerFactory FOR this?
?ENDIF-?
?EXPAND dtoGenClass FOREACH elements.typeSelect(DataView)?
?EXPAND dtoManClass FOREACH elements.typeSelect(DataView)?
?ENDDEFINE?
?DEFINE manualDtoAssemblerFactory FOR Model?
?LET getNameSpaceDataViewsFromModel() AS dataViews-?
?IF !dataViews.isEmpty-?
?info("Write "+getDtoAssemblerFactoryClassFileName())?
?FILE getDtoAssemblerFactoryClassFileName() OUTLET_JAVA-?
package ?name?;
?addImports()-?
/**
* implementation of {@link org.openxma.dsl.platform.assembler.DtoAssemblerFactory}
* you can override dto mapping functionality here
*/
@?registerImport("org.springframework.stereotype.Component")?("?getCamelCasedModelNameSpaceName(name)?Daf")
public class ?getDtoAssemblerFactoryClassName()? extends ?getDtoAssemblerFactoryGenClassName()? {
}
?ENDFILE?
?ENDIF-?
?ENDLET-?
?ENDDEFINE?
?DEFINE dtoAssemblerFactory FOR Model?
?LET (Set[DataView]) getNameSpaceDataViewsFromModel() AS dataViews-?
?IF !dataViews.isEmpty-?
?info("Write "+getDtoAssemblerFactoryGenClassFileName())?
?FILE getDtoAssemblerFactoryGenClassFileName()-?
package ?name?;
import org.openxma.dsl.platform.service.MapperContextHolder;
?addImports()-?
public class ?getDtoAssemblerFactoryGenClassName()? implements ?registerImport("org.openxma.dsl.platform.assembler.DtoAssemblerFactory")? {
private ?registerImport("java.util.List")?> dtoAssemblers;
@?registerImport("org.springframework.beans.factory.annotation.Autowired")?
private ?registerImport("org.openxma.dsl.platform.assembler.DtoAssemblerRegistry")? dtoAssemblerRegistry;
@?registerImport("org.springframework.beans.factory.annotation.Autowired")?
private ?registerImport("org.openxma.dsl.platform.converter.Converter")? converter;
public ?getDtoAssemblerFactoryGenClassName()?() {
dtoAssemblers = new ?registerImport("java.util.ArrayList")?>(?dataViews.size?);
initDtoAssemblers();
}
public List> getDtoAssemblers() {
return dtoAssemblers;
}
protected DtoAssemblerRegistry getDtoAssemblerRegistry() {
return dtoAssemblerRegistry;
}
protected Converter getConverter() {
return converter;
}
private void initDtoAssemblers() {
?IF !dataViews.isEmpty-?
?FOREACH dataViews AS dataView ITERATOR iterator-?
dtoAssemblers.add(createDtoAssembler?dataView.name?());
?ENDFOREACH-?
?ENDIF-?
}
?FOREACH dataViews AS dataView ITERATOR iterator-?
private DtoAssembler createDtoAssembler?dataView.name?() {
return new DtoAssembler() {?EXPAND anonymousDtoAssemblerClass FOR dataView? };
}
?EXPAND mapping FOR dataView?
?ENDFOREACH-?
}
?ENDFILE?
?ENDIF-?
?ENDLET-?
?ENDDEFINE?
/**
* Creates a dto assembler class for each dataView
*/
?DEFINE anonymousDtoAssemblerClass FOR DataView?
?LET featureReferences.source.toSet() AS entities-?
public ?getClassName()? mapFromEntity(Object sourceEntity) {
?registerImport("org.springframework.util.Assert")-?.notNull(sourceEntity, "parameter 'sourceEntity' must not be null");
?FOREACH entities AS entity ITERATOR iterator-?
?IF iterator.counter0>0-?else if (sourceEntity instanceof ?entity.name?) {
?ELSE-?
if (sourceEntity instanceof ?entity.name?) {
?ENDIF-?
?entity.getQualifiedInterfaceName()? ?entity.name.toVariableName()? = (?entity.name?) sourceEntity;
?getClassName()? result = mapFrom?entity.name?To?getClassName()?(?entity.name.toVariableName()?);
?FOREACH entity.allAttributes.select(reference|featureReferences.exists(e|e.getProperty("sourceReference")==reference)) AS requiredReference-?
if (null != ?entity.name.toVariableName()?.?requiredReference.getAccessorMethodName()?()) {
result.?featureReferences.selectFirst(e|e.getProperty("sourceReference")==requiredReference).target.getMutatorMethodName()?(?entity.name.toVariableName()?.?requiredReference.getAccessorMethodName()?().?((Entity)requiredReference.dataType).identifier.getAccessorMethodName()?());
}
?ENDFOREACH-?
return result;
}?ENDFOREACH-??IF superType!=null && !superType.featureReferences.isEmpty-?else {
?getClassName()? result = new ?getClassName()?();
dtoAssemblerRegistry.getDtoAssembler(?superType.getFullyQualifiedNameAndRegister(false)?.class)
.mapTo(dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class)
.mapFromEntity(sourceEntity), result);
return result;
}?ELSE-?
throw new IllegalArgumentException("mapping from object '"+sourceEntity+"' is not supported");
?ENDIF?
}
public ?getClassName()? mapFromEntity(Object sourceEntity, ?getClassName()? targetDto) {
?registerImport("org.springframework.util.Assert")-?.notNull(sourceEntity, "parameter 'sourceEntity' must not be null");
?registerImport("org.springframework.util.Assert")-?.notNull(targetDto, "parameter 'targetDto' must not be null");
?FOREACH entities AS entity ITERATOR iterator-?
?IF iterator.counter0>0-?else if (sourceEntity instanceof ?entity.name?) {
?ELSE-?
if (sourceEntity instanceof ?entity.name?) {
?ENDIF-?
?entity.getQualifiedInterfaceName()? ?entity.name.toVariableName()? = (?entity.name?) sourceEntity;
mapFrom?entity.name?To?getClassName()?(?entity.name.toVariableName()?, targetDto);
?FOREACH entity.allAttributes.select(reference|featureReferences.exists(e|e.getProperty("sourceReference")==reference)) AS requiredReference-?
if (null != ?entity.name.toVariableName()?.?requiredReference.getAccessorMethodName()?()) {
targetDto.?featureReferences.selectFirst(e|e.getProperty("sourceReference")==requiredReference).target.getMutatorMethodName()?(?entity.name.toVariableName()?.?requiredReference.getAccessorMethodName()?().?((Entity)requiredReference.dataType).identifier.getAccessorMethodName()?());
}
?ENDFOREACH-?
return targetDto;
}?ENDFOREACH-??IF superType!=null && !superType.featureReferences.isEmpty-?else {
dtoAssemblerRegistry.getDtoAssembler(?superType.getFullyQualifiedNameAndRegister(false)?.class)
.mapTo(dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class)
.mapFromEntity(sourceEntity), targetDto);
return targetDto;
}?ELSE-?
throw new IllegalArgumentException("mapping from object '"+sourceEntity+"' is not supported");
?ENDIF?
}
public T mapTo(?getClassName()? sourceDto, Class target) {
if (?getClassName()?.class.equals(target)) {
?getClassName()? result = new ?getClassName()?();
mapFrom?getClassName()?To?getClassName()?(sourceDto, result);
return target.cast(result);
}
?LET (Set[Mapper])getMappersByDataView() AS mappers-?
?FOREACH mappers AS mapper-?
?IF dataViewIsMapperSource(this,mapper)-?
else if (?registerImport(getOppositeElementFullyQualifiedName(this,mapper))?.class.equals(target) && MapperContextHolder.getContext().containsKey("mapper:?mapper.name?")) {
return target.cast(mapper?mapper.name?MapsFrom?getClassName()?To?getOppositeElementName(this,mapper)?(sourceDto));
}
?ELSE-?
//?info("dataView: '"+this.name+"' is not a mapping source in mapper: '"+mapper.name+"'")?
?ENDIF?
?ENDFOREACH-?
?ENDLET-?
?FOREACH entities AS entity-?
else if (?entity.name?.class.equals(target)) {
return target.cast(mapFrom?getClassName()?To?entity.name?(sourceDto));
}
?ENDFOREACH-?
?IF superType!=null && !superType.featureReferences.isEmpty-?
else {
return dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class).mapTo(sourceDto, target);
}
?ELSE-?
else {
throw new IllegalArgumentException("mapping to class '"+target+"' is not supported");
}
?ENDIF-?
}
public void mapTo(?getClassName()? sourceDto, Object targetObject) {
if (targetObject instanceof ?getClassName()?) {
mapFrom?getClassName()?To?getClassName()?(sourceDto, (?getClassName()?) targetObject);
}
?LET (Set[Mapper])getMappersByDataView() AS mappers-?
?FOREACH mappers AS mapper-?
?IF dataViewIsMapperSource(this,mapper)-?
else if (targetObject instanceof ?registerImport(getOppositeElementFullyQualifiedName(this,mapper))? && MapperContextHolder.getContext().containsKey("mapper:?mapper.name?")) {
mapper?mapper.name?MapsFrom?getClassName()?To?getOppositeElementName(this,mapper)?(sourceDto, (?getOppositeElementName(this,mapper)?)targetObject);
}
?ELSE-?
//?info("dataView: '"+this.name+"' is not a mapping source in mapper: '"+mapper.name+"'")?
?ENDIF?
?ENDFOREACH-?
?ENDLET-?
?FOREACH entities AS entity-?
else if (targetObject instanceof ?entity.name?) {
mapFrom?getClassName()?To?entity.name?(sourceDto, (?entity.name?)targetObject);
}
?ENDFOREACH-?
?IF superType!=null && !superType.featureReferences.isEmpty-?
else {
dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class).mapTo(sourceDto, targetObject);
}
?ELSE-?
else if (targetObject != null) {
throw new IllegalArgumentException("mapping to object '"+targetObject+"' is not supported");
}
?ENDIF-?
}
?ENDLET-?
?ENDDEFINE?
?DEFINE mapping FOR DataView-?
protected void mapFrom?getClassName()?To?getClassName()?(?getClassName()? sourceDto, ?getClassName()? ?getClassName().toFirstLower()?) {
?IF superType!=null-?
dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class).mapTo(sourceDto, ?getClassName().toFirstLower()?);
?ENDIF??FOREACH featureReferences.select(e|e.attribute!=null && !e.attribute.readOnly) AS featureReference-?
?getClassName().toFirstLower()?.?featureReference.target.getMutatorMethodName()?(sourceDto.?featureReference.target.getAccessorMethodName()?());
?ENDFOREACH-?
}
?LET featureReferences.source.toSet() AS entities-?
?IF !entities.isEmpty-?
?FOREACH entities AS entity?
protected ?entity.name? mapFrom?getClassName()?To?entity.name?(?getClassName()? sourceDto) {
return mapFrom?getClassName()?To?entity.name?(sourceDto, MapperContextHolder.createEntity(?entity.name?.class));
}
protected ?entity.name? mapFrom?getClassName()?To?entity.name?(?getClassName()? sourceDto, ?entity.name? ?entity.name.toVariableName()?) {
if (MapperContextHolder.getContext().containsKey(sourceDto)) {
return ?entity.name.toVariableName()?;
}
?IF superType!=null && superType.featureReferences.source.contains(entity)-?
dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class).mapTo(sourceDto, ?entity.name.toVariableName()?);
?ELSE-?
MapperContextHolder.getContext().put(sourceDto, ?entity.name.toVariableName()?);
?ENDIF-?
?FOREACH featureReferences.select(e|e.source==entity && e.attribute!=null && !e.attribute.reference && !e.attribute.readOnly) AS featureReference-?
?IF featureReference.attribute.identifier-?
if (sourceDto.?featureReference.target.getAccessorMethodName()?() != null?IF featureReference.getProperty("sourceReference")!=null? ?setProperty("generateIsContextMethod","true")? && MapperContextHolder.isContext("?((Attribute)featureReference.getProperty("sourceReference")).name?")?ENDIF?) {
?entity.name.toVariableName()?.?entity.identifier.getMutatorMethodName()?(sourceDto.?featureReference.target.getAccessorMethodName()?());
}
?ELSE-?
?entity.name.toVariableName()?.?featureReference.attribute.getMutatorMethodName()?(sourceDto.?featureReference.target.getAccessorMethodName()?());
?ENDIF-?
?ENDFOREACH-?
?FOREACH featureReferences.select(e|e.source==entity && e.attribute.reference && e.view!=null) AS includedFeatureReference ITERATOR iterator-?
?IF iterator.firstIteration-?
?setProperty("generateIsContextMethod","true")-?
if (!MapperContextHolder.isContext("save?entity.name?") && !MapperContextHolder.isContext("update?entity.name?")) {
?ENDIF-?
?IF !includedFeatureReference.attribute.many-?
if (null != sourceDto.?includedFeatureReference.target.getAccessorMethodName()?()) {
?includedFeatureReference.attribute.dataType.getQualifiedInterfaceName()? ?includedFeatureReference.attribute.name? = (?includedFeatureReference.attribute.dataType.name?) dtoAssemblerRegistry.getDtoAssembler(?includedFeatureReference.view.name?.class).mapTo(sourceDto.?includedFeatureReference.target.getAccessorMethodName()?(), ?includedFeatureReference.attribute.dataType.name?.class);
?entity.name.toVariableName()?.?includedFeatureReference.attribute.getMutatorMethodName()?(?includedFeatureReference.attribute.name?);
}
?ELSE-?
if (null != sourceDto.?includedFeatureReference.target.getAccessorMethodName()?()) {
for (?registerImport(includedFeatureReference.view.getFullClassNameForDatamapping())? ?includedFeatureReference.view.name.toFirstLower()? : sourceDto.?includedFeatureReference.target.getAccessorMethodName()?()) {
?includedFeatureReference.attribute.dataType.getQualifiedInterfaceName()? ?includedFeatureReference.attribute.name? = (?includedFeatureReference.attribute.dataType.name?) dtoAssemblerRegistry.getDtoAssembler(?includedFeatureReference.view.name?.class).mapTo(?includedFeatureReference.view.name.toFirstLower()?, ?includedFeatureReference.attribute.dataType.name?.class);
?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAddMethodName()?(?includedFeatureReference.attribute.name?);
}
}
?ENDIF-?
?IF iterator.lastIteration-?
}
?ENDIF-?
?ENDFOREACH-?
return ?entity.name.toVariableName()?;
}
?ENDFOREACH-?
?ENDIF-?
?FOREACH entities AS entity?
protected ?getClassName()? mapFrom?entity.name?To?getClassName()?(?entity.name? ?entity.name.toVariableName()?) {
if (MapperContextHolder.getContext().containsKey(?entity.name.toVariableName()?)) {
return (?getClassName()?) MapperContextHolder.getContext().get(?entity.name.toVariableName()?);
}
?getClassName()? ?getClassName().toFirstLower()? = new ?getClassName()?();
?IF superType!=null && superType.featureReferences.source.contains(entity)-?
dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class)
.mapTo(dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class)
.mapFromEntity(?entity.name.toVariableName()?), ?getClassName().toFirstLower()?);
?ENDIF-?
MapperContextHolder.getContext().put(?entity.name.toVariableName()?, ?getClassName().toFirstLower()?);
?FOREACH featureReferences.select(e|(e.source==entity && e.getProperty("sourceReference")==null) && !e.attribute.reference && !e.attribute.readOnly) AS featureReference-?
?getClassName().toFirstLower()?.?featureReference.target.getMutatorMethodName()?(?entity.name.toVariableName()?.?featureReference.attribute.getAccessorMethodName()?());
?ENDFOREACH-?
?FOREACH featureReferences.select(e|e.source==entity && e.attribute.reference && e.view!=null) AS includedFeatureReference-?
?IF !includedFeatureReference.attribute.many-?
if (null != ?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?()) {
?registerImport(getFullyQualifiedName(includedFeatureReference.view,true))? ?includedFeatureReference.attribute.name? = (?includedFeatureReference.view.name?) MapperContextHolder.getContext().get(?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?());
if (null == ?includedFeatureReference.attribute.name?) {
?includedFeatureReference.attribute.name? = dtoAssemblerRegistry.getDtoAssembler(?includedFeatureReference.view.name?.class).mapFromEntity(?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?());
}
?getClassName().toFirstLower()?.?includedFeatureReference.target.getMutatorMethodName()?(?includedFeatureReference.attribute.name?);
}
?ELSE-?
if (?entity.name.toVariableName()?.?includedFeatureReference.attribute.getHasMethodName()?()) {
for (?includedFeatureReference.attribute.dataType.name? next : ?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?()) {
?includedFeatureReference.view.name? next?includedFeatureReference.view.name? = (?includedFeatureReference.view.name?) MapperContextHolder.getContext().get(next);
if (null == next?includedFeatureReference.view.name?) {
next?includedFeatureReference.view.name? = dtoAssemblerRegistry.getDtoAssembler(?includedFeatureReference.view.name?.class).mapFromEntity(next);
}
?getClassName().toFirstLower()?.?includedFeatureReference.target.getAddMethodName()?(next?includedFeatureReference.view.name?);
}
}
?ENDIF-?
?ENDFOREACH-?
return ?getClassName().toFirstLower()?;
}
protected ?getClassName()? mapFrom?entity.name?To?getClassName()?(?entity.name? ?entity.name.toVariableName()?, ?getClassName()? ?getClassName().toFirstLower()?) {
if (MapperContextHolder.getContext().containsKey(?entity.name.toVariableName()?)) {
return ?getClassName().toFirstLower()?;
}
?IF superType!=null && superType.featureReferences.source.contains(entity)-?
dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class)
.mapTo(dtoAssemblerRegistry.getDtoAssembler(?superType.name?.class)
.mapFromEntity(?entity.name.toVariableName()?), ?getClassName().toFirstLower()?);
?ENDIF-?
MapperContextHolder.getContext().put(?entity.name.toVariableName()?, ?getClassName().toFirstLower()?);
?FOREACH featureReferences.select(e|(e.source==entity && e.getProperty("sourceReference")==null) && !e.attribute.reference && !e.attribute.readOnly) AS featureReference-?
?getClassName().toFirstLower()?.?featureReference.target.getMutatorMethodName()?(?entity.name.toVariableName()?.?featureReference.attribute.getAccessorMethodName()?());
?ENDFOREACH-?
?FOREACH featureReferences.select(e|e.source==entity && e.attribute.reference && e.view!=null) AS includedFeatureReference-?
?IF !includedFeatureReference.attribute.many-?
if (null != ?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?()) {
?registerImport(getFullyQualifiedName(includedFeatureReference.view,true))? ?includedFeatureReference.attribute.name? = (?includedFeatureReference.view.name?) MapperContextHolder.getContext().get(?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?());
if (null == ?includedFeatureReference.attribute.name?) {
?includedFeatureReference.attribute.name? = dtoAssemblerRegistry.getDtoAssembler(?includedFeatureReference.view.name?.class).mapFromEntity(?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?());
}
?getClassName().toFirstLower()?.?includedFeatureReference.target.getMutatorMethodName()?(?includedFeatureReference.attribute.name?);
}
?ELSE-?
if (?entity.name.toVariableName()?.?includedFeatureReference.attribute.getHasMethodName()?()) {
for (?includedFeatureReference.attribute.dataType.name? next : ?entity.name.toVariableName()?.?includedFeatureReference.attribute.getAccessorMethodName()?()) {
?includedFeatureReference.view.name? next?includedFeatureReference.view.name? = (?includedFeatureReference.view.name?) MapperContextHolder.getContext().get(next);
if (null == next?includedFeatureReference.view.name?) {
next?includedFeatureReference.view.name? = dtoAssemblerRegistry.getDtoAssembler(?includedFeatureReference.view.name?.class).mapFromEntity(next);
}
?getClassName().toFirstLower()?.?includedFeatureReference.target.getAddMethodName()?(next?includedFeatureReference.view.name?);
}
}
?ENDIF-?
?ENDFOREACH-?
return ?getClassName().toFirstLower()?;
}
?ENDFOREACH-?
?LET (Set[Mapper])getMappersByDataView() AS mappers-?
?FOREACH mappers AS mapper-?
protected ?getOppositeElementName(this,mapper)? mapper?mapper.name?MapsFrom?getClassName()?To?getOppositeElementName(this,mapper)?(?getClassName()? sourceDto) {
?getOppositeElementName(this,mapper)? target = MapperContextHolder.createComplexType(?getOppositeElementName(this,mapper)?.class);
mapper?mapper.name?MapsFrom?getClassName()?To?getOppositeElementName(this,mapper)?(sourceDto, target);
return target;
}
protected void mapper?mapper.name?MapsFrom?getClassName()?To?getOppositeElementName(this,mapper)?(?getClassName()? sourceDto, ?getOppositeElementName(this,mapper)? target ) {
?IF mapper.propertyMappings.isEmpty-?
?IF dataViewIsMapperSource(this,mapper)-?
?IF dataViewIsLeft(this,mapper)-?
?FOREACH mapper.left.attributes.select(lA|lA!=null && !lA.reference && lA.eContainer==mapper.left
&& mapper.right.attributes.exists(rA|rA!=null && !rA.reference && !rA.readOnly
&& rA.getAccessorMethodName()==lA.getAccessorMethodName())) AS sA-?
?LET mapper.right.attributes.selectFirst(rA|rA.getAccessorMethodName()==sA.getAccessorMethodName()) AS tA-?
?IF sA.dataTypeName==tA.dataTypeName -?
target.?tA.getMutatorMethodName()?(sourceDto.?sA.getAccessorMethodName()?());
?ELSE-?
?IF isBigDecimalSimpleType(tA)-?
target.?tA.getMutatorMethodName()?(converter.convert(?registerImport("java.math.BigDecimal")-?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ELSEIF isTimestampSimpleType(tA)-?
target.?tA.getMutatorMethodName()?(converter.convert(?registerImport("java.sql.Timestamp")-?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ELSEIF isDateSimpleType(tA)-?
target.?tA.getMutatorMethodName()?(converter.convert(?registerImport("java.util.Date")-?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ELSE-?
target.?tA.getMutatorMethodName()?(converter.convert(?tA.dataTypeName?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ENDIF-?
?ENDIF-?
?ENDLET-?
?ENDFOREACH-?
?ENDIF-?
?IF dataViewIsRight(this,mapper)-?
?FOREACH mapper.right.attributes.select(rA|rA!=null && !rA.reference && rA.eContainer==mapper.right
&& mapper.left.attributes.exists(lA|lA!=null && !lA.reference && !lA.readOnly
&& lA.getAccessorMethodName()==rA.getAccessorMethodName())) AS sA-?
?LET mapper.left.attributes.selectFirst(lA|lA.getAccessorMethodName()==sA.getAccessorMethodName()) AS tA-?
?IF sA.dataTypeName==tA.dataTypeName -?
target.?tA.getMutatorMethodName()?(sourceDto.?sA.getAccessorMethodName()?());
?ELSE-?
?IF isBigDecimalSimpleType(tA)-?
target.?tA.getMutatorMethodName()?(converter.convert(?registerImport("java.math.BigDecimal")-?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ELSEIF isTimestampSimpleType(tA)-?
target.?tA.getMutatorMethodName()?(converter.convert(?registerImport("java.sql.Timestamp")-?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ELSEIF isDateSimpleType(tA)-?
target.?tA.getMutatorMethodName()?(converter.convert(?registerImport("java.util.Date")-?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ELSE-?
target.?tA.getMutatorMethodName()?(converter.convert(?tA.dataTypeName?.class, sourceDto.?sA.getAccessorMethodName()?()));
?ENDIF-?
?ENDIF-?
?ENDLET-?
?ENDFOREACH-?
?ENDIF-?
?ENDIF-?
?ELSE-?
?FOREACH mapper.propertyMappings.select(e|true==dataViewIsPropertyMappingSource(this,mapper,e)) AS propertyMapping-?
?IF dataViewIsLeft(this,mapper)-?
?IF propertyMapping.left.dataTypeName.matches(propertyMapping.right.dataTypeName) -?
target.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getMutatorMethodName()?(sourceDto.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getAccessorMethodName()?());
?ELSE-?
?IF isBigDecimalSimpleType(getDerivedAttributeFromMapperRight(propertyMapping.right,mapper))-?
target.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getMutatorMethodName()?(converter.convert(?registerImport("java.math.BigDecimal")-?.class, sourceDto.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getAccessorMethodName()?()));
?ELSEIF isTimestampSimpleType(getDerivedAttributeFromMapperRight(propertyMapping.right,mapper))-?
target.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getMutatorMethodName()?(converter.convert(?registerImport("java.sql.Timestamp")-?.class, sourceDto.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getAccessorMethodName()?()));
?ELSEIF isDateSimpleType(getDerivedAttributeFromMapperRight(propertyMapping.right,mapper))-?
target.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getMutatorMethodName()?(converter.convert(?registerImport("java.util.Date")-?.class, sourceDto.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getAccessorMethodName()?()));
?ELSE-?
target.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getMutatorMethodName()?(converter.convert(?propertyMapping.right.dataTypeName?.class, sourceDto.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getAccessorMethodName()?()));
?ENDIF-?
?ENDIF-?
?ENDIF-?
?IF dataViewIsRight(this,mapper)-?
?IF propertyMapping.right.dataTypeName.matches(propertyMapping.left.dataTypeName) -?
target.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getMutatorMethodName()?(sourceDto.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getAccessorMethodName()?());
?ELSE-?
?IF isBigDecimalSimpleType(getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper))-?
target.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getMutatorMethodName()?(converter.convert(?registerImport("java.math.BigDecimal")-?.class, sourceDto.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getAccessorMethodName()?()));
?ELSEIF isTimestampSimpleType(getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper))-?
target.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getMutatorMethodName()?(converter.convert(?registerImport("java.sql.Timestamp")-?.class, sourceDto.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getAccessorMethodName()?()));
?ELSEIF isDateSimpleType(getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper))-?
target.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getMutatorMethodName()?(converter.convert(?registerImport("java.util.Date")-?.class, sourceDto.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getAccessorMethodName()?()));
?ELSE-?
target.?getDerivedAttributeFromMapperLeft(propertyMapping.left,mapper).getMutatorMethodName()?(converter.convert(?propertyMapping.left.dataTypeName?.class, sourceDto.?getDerivedAttributeFromMapperRight(propertyMapping.right,mapper).getAccessorMethodName()?()));
?ENDIF-?
?ENDIF-?
?ENDIF-?
?ENDFOREACH-?
?ENDIF-?
}
?ENDFOREACH-?
?ENDLET-?
?ENDLET-?
?ENDDEFINE?
/**
* Creates a dto for each dataView
*/
?DEFINE dtoGenClass FOR DataView?
?info("Write "+getGenClassFileName())?
?FILE getGenClassFileName()-?
package ?getPackageName(true)?;
import java.io.Serializable;
?addImports()-?
?EXPAND Documentation::documentation FOR this-?
public abstract class ?getGenClassName()??IF superType!=null? extends ?superType.getQualifiedClassName()??ENDIF? implements Serializable {
?EXPAND Features::serialVersionUID FOR this-?
?EXPAND Features::attributes FOR this-?
?EXPAND Features::properties FOR this-?
?EXPAND Features::toString FOR this-?
}
?ENDFILE?
?ENDDEFINE?
/**
* Creates a manual dto for each dataView
*/
?DEFINE dtoManClass FOR DataView?
?info("Write "+getClassFileName())?
?FILE getClassFileName() OUTLET_JAVA-?
package ?getPackageName(true)?;
?EXPAND Documentation::documentation FOR this-?
public class ?name? extends ?getGenClassName()? {
?EXPAND Features::serialVersionUID FOR this-?
}
?ENDFILE?
?ENDDEFINE?
?DEFINE dtoAssemblerFactoryJUnitTest FOR Model?
?LET (Set[DataView]) getNameSpaceDataViewsFromModel() AS dataViews-?
?IF !dataViews.isEmpty-?
?info("Write "+getDtoAssemblerFactoryTestClassFileName())?
?FILE getDtoAssemblerFactoryTestClassFileName() OUTLET_TEST-?
package ?name?;
?addImports()-?
public class ?getDtoAssemblerFactoryTestClassName()? extends ?registerImport("org.openxma.demo.AbstractDemoSpringIntegrationTest")?{
@?registerImport("org.springframework.beans.factory.annotation.Autowired")?
private ?registerImport("org.openxma.dsl.platform.assembler.DtoAssemblerRegistry")? dtoAssemblerRegistry;
@Autowired
private ?registerImport("org.openxma.dsl.platform.dao.EntityFactoryRegistry")? entityFactoryRegistry;
private ?registerImport("java.util.Map")?