| @GenModel(fileExtensions="dto", modelDirectory="/org.eclipse.osbp.dsl.dto.xtext/src-gen", editDirectory="/org.eclipse.osbp.dsl.dto.xtext.edit/src", childCreationExtenders="true") | 
 | @GenModel(modelName="DTO") | 
 | @GenModel(prefix="OSBPDto") | 
 | @GenModel(suppressEMFModelTags="true") | 
 | @GenModel(runtimeVersion="2.9") | 
 | @GenModel(copyrightText="Copyright (c) 2011, 2016 - Lunifera GmbH (Gross Enzersdorf), Loetz GmbH&Co.KG (Heidelberg) | 
 |  All rights reserved. This program and the accompanying materials  | 
 |  are made available under the terms of the Eclipse Public License v1.0  | 
 |  which accompanies this distribution, and is available at  | 
 |  http://www.eclipse.org/legal/epl-v10.html  | 
 |  | 
 |  Contributors:   | 
 |  		Florian Pirchner - Initial implementation  | 
 |  ") | 
 | @GenModel(operationReflection="false") | 
 | @Ecore(nsURI="http://osbp.eclipse.org/dsl/dto/v1") | 
 | @Ecore(nsPrefix="dto") | 
 | @Ecore(rootPackage="dto") | 
 | package org.eclipse.osbp.dsl.semantic.dto | 
 |  | 
 | import java.util.List | 
 | import org.eclipse.emf.ecore.EObject | 
 | import org.eclipse.emf.ecore.InternalEObject | 
 | import org.eclipse.xtext.common.types.JvmTypeReference | 
 | import org.eclipse.xtext.xbase.XExpression | 
 | import org.eclipse.osbp.dsl.semantic.common.types.FeaturesList | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LAttribute | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LClass | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LFeature | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LFeaturesHolder | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LKeyAndValue | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LLazyResolver | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LMultiplicity | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LReference | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LScalarType | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LType | 
 | import org.eclipse.osbp.dsl.semantic.common.types.LTypedPackage | 
 | import org.eclipse.osbp.dsl.xtext.lazyresolver.api.EcoreUtil3 | 
 | import java.util.ArrayList | 
 | import java.util.Collections | 
 |  | 
 | class LDtoModel { | 
 | 	contains LTypedPackage[] packages | 
 | 	op EObject eResolveProxy(InternalEObject proxy) { | 
 | 		return EcoreUtil3.resolve(proxy, this.eResource().resourceSet); | 
 | 	} | 
 | } | 
 |  | 
 | /** | 
 |  * A bean is an embeddable element that may become added to a entity using the @embedd annotation.  | 
 |  */ | 
 | class LDto extends LClass, LFeaturesHolder, LScalarType { | 
 | 	contains LDtoFeature[] features | 
 | 	refers LDto superType opposite subTypes | 
 | 	contains transient JvmTypeReference superTypeJvm | 
 | 	// helper proxy for lazy loading the mapper from super type | 
 | 	contains transient JvmTypeReference superTypeMapperJvm | 
 | 	refers LDto[] subTypes opposite superType | 
 | 	refers LType wrappedType | 
 | 	contains transient JvmTypeReference wrappedTypeJvm | 
 | 	/**  | 
 |  	 * Returns all features of type LOperation | 
 |  	 */ | 
 | 	op OperationsList getOperations() { | 
 | 		features.filter(typeof(LDtoOperation)).toList | 
 | 	} | 
 | 	/** | 
 |  	 * Returns all features of type LDtoReference | 
 |  	 */ | 
 | 	op DtoReferenceList getReferences() { | 
 | 		features.filter(typeof(LDtoAbstractReference)).toList | 
 | 	} | 
 | 	/** | 
 |  	 * Returns all features of type LDtoAttribute | 
 |  	 */ | 
 | 	op DtoAttributeList getAttributes() { | 
 | 		features.filter(typeof(LDtoAbstractAttribute)).toList | 
 | 	} | 
 | 	/** | 
 | 	 * Returns all features of the holder and from super types | 
 | 	 */ | 
 | 	op FeaturesList getAllFeatures() { | 
 | 		val List<LDtoFeature> result = newArrayList() | 
 | 		collectAllOSBPFeatures(result) | 
 | 		return result | 
 | 	} | 
 | 	op void collectAllOSBPFeatures(LDto current, DtoFeatureList result) { | 
 | 		if (current == null) { | 
 | 			return | 
 | 		} | 
 |  | 
 | 		// collect from current feature | 
 | 		result.addAll(current.features) | 
 |  | 
 | 		// call for super class | 
 | 		current.superType.collectAllOSBPFeatures(result) | 
 | 	} | 
 | 	op LDtoAbstractAttribute getPrimaryKeyAttribute() { | 
 | 		return allFeatures.filter(typeof(LDtoAbstractAttribute)).findFirst [ | 
 | 			switch (it) { | 
 | 				LDtoInheritedAttribute: | 
 | 					return it.inheritedFeature?.id || it.inheritedFeature?.uuid | 
 | 				LDtoAttribute: | 
 | 					return it.id || it.uuid | 
 | 			} | 
 | 			return false | 
 | 		] | 
 | 	} | 
 | 	op String getIdAttributeName() { | 
 | 		var attribute = getPrimaryKeyAttribute() | 
 | 		switch (attribute) { | 
 | 			LDtoInheritedAttribute: | 
 | 				return attribute.inheritedFeature.name | 
 | 			LDtoAttribute: | 
 | 				return attribute.name | 
 | 		} | 
 | 		return null | 
 | 	} | 
 | 	op LScalarType getIdAttributeType() { | 
 | 		var attribute = getPrimaryKeyAttribute() | 
 | 		switch (attribute) { | 
 | 			LDtoInheritedAttribute: | 
 | 				return attribute.inheritedFeature.^type | 
 | 			case LDtoAttribute: | 
 | 				return attribute.^type | 
 | 		} | 
 | 		return null | 
 | 	} | 
 | } | 
 |  | 
 | class LAutoInheritDto extends LDto { | 
 | } | 
 |  | 
 | class LDtoMapper extends LLazyResolver { | 
 | 	contains XExpression toDTO | 
 | 	contains XExpression fromDTO | 
 | } | 
 |  | 
 | class LDtoFeature extends LFeature { | 
 | 	contains LDtoMapper mapper | 
 | 	op LDto getDTO() { | 
 |  | 
 | 		//		if (eContainer instanceof LFeature) { | 
 | 		//			return null // this happens since the feature may be the annotation info  | 
 | 		//		} | 
 | 		return eContainer as LDto | 
 | 	} | 
 | } | 
 |  | 
 | abstract class LDtoAbstractAttribute extends LDtoFeature, LAttribute { | 
 | 	op PropertiesList getResolvedProperties() { | 
 | 		if (this instanceof LDtoInheritedAttribute) { | 
 | 			val temp = this as LDtoInheritedAttribute | 
 | 			if (temp.inheritedFeature == null) { | 
 | 				return Collections.emptyList() | 
 | 			} | 
 | 			val result = new ArrayList<LKeyAndValue>(temp.inheritedFeature.properties) | 
 | 			result.addAll(properties) | 
 | 			return result | 
 | 		} else { | 
 | 			return properties | 
 | 		} | 
 | 	} | 
 | } | 
 |  | 
 | class LDtoInheritedAttribute extends LDtoAbstractAttribute{ | 
 | 	refers LAttribute inheritedFeature | 
 | 	contains transient JvmTypeReference inheritedFeatureTypeJvm | 
 | 	op LScalarType getInheritedType() { | 
 | 		return inheritedFeature.^type | 
 | 	} | 
 | 	op LMultiplicity getInheritedMultiplicity() { | 
 | 		return inheritedFeature.multiplicity | 
 | 	} | 
 | } | 
 |  | 
 | class LDtoAttribute  extends LDtoAbstractAttribute { | 
 | } | 
 |  | 
 | abstract class LDtoAbstractReference extends LDtoFeature, LReference { | 
 | 	refers LDto ^type | 
 | 	contains transient JvmTypeReference typeJvm | 
 | 	op PropertiesList getResolvedProperties() { | 
 | 		if (this instanceof org.eclipse.osbp.dsl.semantic.dto.LDtoInheritedReference) { | 
 | 			val temp = this as LDtoInheritedReference | 
 | 			if (temp.inheritedFeature == null) { | 
 | 				return Collections.emptyList() | 
 | 			} | 
 | 			val result = new ArrayList<LKeyAndValue>(temp.inheritedFeature.properties) | 
 | 			result.addAll(properties) | 
 | 			return result | 
 | 		} else { | 
 | 			return properties | 
 | 		} | 
 | 	} | 
 | } | 
 |  | 
 | class LDtoInheritedReference extends LDtoAbstractReference{ | 
 | 	refers LReference inheritedFeature | 
 | 	contains transient JvmTypeReference inheritedFeatureTypeJvm | 
 | 	op LMultiplicity getInheritedMultiplicity() { | 
 | 		return inheritedFeature.multiplicity | 
 | 	} | 
 | } | 
 |  | 
 | class LDtoReference  extends LDtoAbstractReference { | 
 | 	refers LDtoReference ^opposite | 
 | } | 
 |  | 
 | class LDtoOperation extends org.eclipse.osbp.dsl.semantic.common.types.LOperation, LDtoFeature { | 
 | } | 
 |  | 
 | type DtoFeatureList wraps java.util.List<LDtoFeature> | 
 |  | 
 | type OperationsList wraps java.util.List<LDtoOperation> | 
 |  | 
 | type DtoReferenceList wraps java.util.List<LDtoAbstractReference> | 
 |  | 
 | type DtoAttributeList wraps java.util.List<LDtoAbstractAttribute> | 
 |  | 
 | type DtoAbstractAttributeList wraps java.util.List<LDtoAbstractAttribute> | 
 |  | 
 | type InternalEObject wraps InternalEObject | 
 |  | 
 | type PropertiesList wraps java.util.List<LKeyAndValue> | 
 | 	 | 
 | 	 | 
 | 	 | 
 | 	 |