<#--
   ******************************************************
   *
   *                       NOTICE
   *
   *  THIS SOFTWARE IS THE PROPERTY OF AND CONTAINS
   *  CONFIDENTIAL INFORMATION OF INFOR, AND SHALL NOT BE
   *  COPIED, USED, NOR DISCLOSED WITHOUT EXPRESS WRITTEN
   *  AUTHORIZATION.  ALTHOUGH PUBLICATION IS NOT
   *  INTENDED, IN THE EVENT OF PUBLICATION, THE
   *  FOLLOWING NOTICE IS APPLICABLE:
   *
   *  Copyright © 2009 Infor. All rights reserved.
   *  The word and design marks set forth herein are
   *  trademarks and/or registered trademarks of Infor
   *  and/or related affiliates and subsidiaries.
   *  All rights reserved. All other trademarks listed
   *  herein are the property of their respective owners.
   *  www.infor.com.
   *
   ******************************************************
  -->
<@common.checkCancel/>
  
<#function AttrLen>
	<#return 50>
</#function>

<#function CompLen>
	<#return 50>
</#function>

<#function MethodLen>
	<#return 50>
</#function>

<#function CompAttrLen>
<#--
	length of attribute names including path for attribute
	groups. Note: this value has been defined in function
	tlbct5000 for define LEN_ATTRIBUTE
    -->
	<#return "1024">
</#function>

<#macro initListAllPublicAttributes>
	<#global attributesListAllPublStruct=[]>
</#macro>

<#function getAttributeImplementation iComponentImplementation iAttributeName>
	<#list iComponentImplementation.attributeImplementation as ai>
		<#if common.getAttributeName(ai)==iAttributeName>
			<#return ai>
		</#if>
	</#list>
	<#return "">
</#function>

<#function bdeHasMoreThanOneComponent>
	<#local count=0/>
	<#list protected.listProtectedComponents() as c>
  		<#local count=count+1/>
	</#list><#--protected.listProtectedComponents() as c-->
	<#return (count > 1)>
</#function><#--bdeHasMoreThanOneComponent-->

<#function convertComponentName iComponentName iObject=object>
	<#if iObject.visibility!="public" || iObject.businessInterfaceDefinition.idref.type=="bod">
		<#if iComponentName=iObject.businessInterfaceDefinition.idref.name>
			<#return iObject.name/>
		</#if>
	</#if>
	<#return iComponentName>
</#function>

<#function getComponentName iComponentImplementation iObject=object>
	<#if (iObject.visibility!="public" && iComponentImplementation.name?exists)>
		<#return convertComponentName(iComponentImplementation.name, iObject)>
	</#if>
	<#return convertComponentName(iComponentImplementation.component.idref.name, iObject)>
</#function>

<#function getComponentPublicName iComponentImplementation>
	<#if iComponentImplementation.component.idref.publicName?has_content>
		<#return convertComponentName(iComponentImplementation.component.idref.publicName)>
	</#if>
	<#if (object.visibility!="public" && iComponentImplementation.name?exists)>
		<#return convertComponentName(iComponentImplementation.name)>
	</#if>
	<#return convertComponentName(iComponentImplementation.component.idref.name)>
</#function>

<#function getComponentPublicNameFromName iComponentName="">
	<#list listComponentImplementations() as c>
		<#if c.componentImplementation.component.idref.name==iComponentName>
			<#return getComponentPublicName(c.componentImplementation)>
		</#if>
	</#list>
	<#return iComponentName>
</#function>

<#function getComponentNameFromMethodArgument iMethodArgument>
	<#list listComponentImplementations() as c>
		<#if c.componentImplementation.component.idref.name==iMethodArgument.component.idref.name>
			<#return getComponentName(c.componentImplementation)>
		</#if>
	</#list>
	<#return iMethodArgument.component.idref.name>
</#function>

<#function getAttributeName iAttributeImplementation>
	<#if iAttributeImplementation.attribute?exists && iAttributeImplementation.attribute.idref?exists>
		<#return iAttributeImplementation.attribute.idref.name>
	<#else>
		<#return iAttributeImplementation.name>
	</#if>
	<#return "">
</#function>

<#function getAttributeType iAttributeImplementation>
	<#if iAttributeImplementation.attribute?exists && iAttributeImplementation.attribute.idref?exists>
		<#return iAttributeImplementation.attribute.idref.type>
	</#if>
	<#return "">
</#function>

<#function getIsIdentifier iAttributeImplementation>
	<#if iAttributeImplementation.attribute?exists && iAttributeImplementation.attribute.idref?exists>
		<#return iAttributeImplementation.attribute.idref.isIdentifier>
	<#else>
		<#return iAttributeImplementation.isIdentifier>
	</#if>
	<#return false>
</#function>

<#function getIsMandatory iAttributeImplementation>
	<#if iAttributeImplementation.attribute?exists && iAttributeImplementation.attribute.idref?exists>
		<#return iAttributeImplementation.attribute.idref.isMandatory>
	<#else>
		<#return iAttributeImplementation.isMandatory>
	</#if>
	<#return false>
</#function>

<#function getIsReadOnly iAttributeImplementation>
	<#if iAttributeImplementation.attribute?exists && iAttributeImplementation.attribute.idref?exists>
		<#return iAttributeImplementation.attribute.idref.isReadOnly>
	<#else>
		<#return iAttributeImplementation.isReadOnly>
	</#if>
	<#return false>
</#function>

<#function getDatatype iAttributeImplementation>
	<#return getDatatypeFromAttributeImplementation(iAttributeImplementation)>
</#function>

<#function getDatatypeName iDatatype>
	<#if iDatatype.nativeDatatype?exists>
		<#return iDatatype.nativeDatatype>
	</#if>
	<#return iDatatype.name>
</#function>

<#function listMethodArgumentImplementations iMethodName>
	<#return listMethodArgumentImplementationsAA(object, iMethodName)>
</#function>

<#function listMethodArgumentImplementationsAA iComponentImplementation iMethodName>
	<#local methodArgumentImplementationList=[]/>
	<#list iComponentImplementation.methodImplementation as methodImplementation>
		<#if getNameFromMethodImplementation(methodImplementation)==iMethodName>
			<#list methodImplementation.methodArgumentImplementation as methodArgumentImplementation>
				<#local methodArgumentImplementationList=methodArgumentImplementationList+[methodArgumentImplementation]/>
			</#list>	
		</#if>
	</#list>
	<#list iComponentImplementation.relationshipImplementation as relationshipImplementation>
		<#if relationshipImplementation.relationship?has_content && relationshipImplementation.relationship.idref.type=="aggregation">
			<#list listMethodArgumentImplementationsAA(relationshipImplementation.componentImplementation, iMethodName) as methodArgumentImplementation>
				<#local methodArgumentImplementationList=methodArgumentImplementationList+[methodArgumentImplementation]/>
			</#list>
		</#if>
	</#list>
	<#return methodArgumentImplementationList>
</#function>

<#function getAttributeImplementationActionType iMethodImplementation iComponentImplementation>
	<#list iComponentImplementation.methodImplementation as methodImplementation>
		<#if iMethodImplementation==methodImplementation>
			<#if isStandardMethod(getNameFromMethodImplementation(iMethodImplementation))>
				<#list iMethodImplementation.methodArgumentImplementation as methodArgumentImplementation>
					<#if methodArgumentImplementation.attributeImplementation?exists && methodArgumentImplementation.attributeImplementation.idref?exists>
						<#local attributeImplementation=methodArgumentImplementation.attributeImplementation.idref/>
						<#if getAttributeName(attributeImplementation)="actionType" && isComponentQualifier(attributeImplementation)>
							<#return attributeImplementation>
						</#if>
					</#if>
				</#list>
			</#if>
		</#if>
	</#list>
	<#return "">
</#function>

<#function isComponentQualifier iAttributeImplementation>
	<#if iAttributeImplementation.attribute?exists>
		<#if getAttributeType(iAttributeImplementation)="qualifier">
			<#list listAttributeImplementations() as ai>
				<#if ai.attributeImplementation.attribute?exists && ai.attributeImplementation.attribute.idref?exists>
					<#list ai.attributeImplementation.attribute.idref.attributeRelationship as ar>
						<#if iAttributeImplementation.attribute.idref == ar.attribute.idref>
							<#return false>
						</#if>
					</#list>
				</#if>
			</#list>
			<#return true>		
		</#if>
	</#if>
	<#return false>
</#function>

<#function isStandardActionType iActionType>
	<#switch iActionType>
		<#case "create">
		<#case "createOrChange">
		<#case "change">
		<#case "delete">
		<#case "unchanged">
			<#return true>
	</#switch>
	<#return false>
</#function>

<#function isAnyType iAttributeImplementation>
	<#if common.getMandatoryDatatype(iAttributeImplementation).primitiveDatatype?exists && common.getMandatoryDatatype(iAttributeImplementation).primitiveDatatype=="anyType">
		<#return true>
	</#if>
	<#return false>
</#function>

<#function isStandardMethod iMethodName>
	<#switch iMethodName>
		<#case "Read">	
		<#case "Create">
		<#case "Change">
		<#case "Delete">
		<#case "List">
		<#case "Show">
		<#case "DeleteRef">
		<#case "CreateRef">
		<#case "SubscribeList">
		<#case "SubscribeEvent">
		<#case "UnSubscribeEvent">
		<#case "PublishEvent">
		<#case "OnEvent">
		<#case "SupportsReferentialIntegrity">
		<#case "SupportsProcessingScope">
		<#-- deprecated -->
		<#case "PublishList">
		<#case "PublishChanges">
		<#case "UnpublishChanges">
			<#return true>
	</#switch>
	<#return false>
</#function>

<#function isSpecificMethod iMethodName>
	<#return !isStandardMethod(iMethodName)>
</#function>			

<#function isQueryMethod iMethodName>
	<#switch iMethodName>
		<#case "Show">
		<#case "List">
		<#case "Read"><#--superfluous, read is always generated-->
			<#return true>
	</#switch>
	<#return false>
</#function>	

<#function queryMethodPresent>
	<#list object.methodImplementation as methodImplementation>
			<#if isQueryMethod(getNameFromMethodImplementation(methodImplementation)) && !isBatchMethodWithHook(methodImplementation) &&
				 protected.hasMethodAlternativeImplementation(getNameFromMethodImplementation(methodImplementation))=="">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>

<#function isBatchMethodWithHook iMethodImplementationRef>
	<#if iMethodImplementationRef.processingOrder?exists && 
			iMethodImplementationRef.processingOrder == "batch" &&
			iMethodImplementationRef.onExecuteHookExpression?exists &&
			iMethodImplementationRef.onExecuteHookExpression?has_content>
		<#--if processingOrder does not exist we must assume it is a method impl on a subcomponent, so it can't be batch-->
		<#return true>
	<#else>
		<#return false>
	</#if>
</#function>

<#function eventMethodPresent>
	<#list object.methodImplementation as methodImplementation>
		<#if isEventMethod(getNameFromMethodImplementation(methodImplementation)) &&
			protected.hasMethodAlternativeImplementation(getNameFromMethodImplementation(methodImplementation))=="">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>

<#function batchMethodPresent>
	<#list object.methodImplementation as methodImplementation>
		<#if methodImplementation.processingOrder == "batch">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>

<#function isEventMethod iMethodName>
	<#switch iMethodName>
		<#case "SubscribeList">
		<#case "SubscribeEvent">
		<#case "UnSubscribeEvent">
		<#case "PublishEvent">
		<#case "OnEvent">
			<#return true>
	</#switch>
	<#return false>
</#function>

<#function publishMethodPresent>
	<#list object.methodImplementation as methodImplementation>
		<#if isPublishMethod(getNameFromMethodImplementation(methodImplementation)) &&
			protected.hasMethodAlternativeImplementation(getNameFromMethodImplementation(methodImplementation))=="">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>

<#function isPublishMethod iMethodName>
	<#switch iMethodName>
		<#case "PublishList">			<#-- deprecated -->
		<#case "PublishChanges">		<#-- deprecated -->
		<#case "UnpublishChanges">		<#-- deprecated -->
			<#return true>
	</#switch>
	<#return false>
</#function>

<#function isReferenceMethod iMethodName>
	<#switch iMethodName>
		<#case "DeleteRef">
		<#case "CreateRef">
			<#return true>
	</#switch>
	<#return false>
</#function>

<#function referenceMethodPresent>
	<#list object.methodImplementation as methodImplementation>
		<#if common.isReferenceMethod(getNameFromMethodImplementation(methodImplementation)) &&
			 protected.hasMethodAlternativeImplementation(getNameFromMethodImplementation(methodImplementation))=="">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>

<#function methodPresent iMethodName iComponentImplementation="">
	<#local componentImplementation=object>
 	<#if iComponentImplementation!="">
		<#local componentImplementation=iComponentImplementation>
 	</#if>
	<#list componentImplementation.methodImplementation as methodImplementation>
		<#if iMethodName == getNameFromMethodImplementation(methodImplementation) &&
		     protected.hasMethodAlternativeImplementation(iMethodName)=="">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>

<#function publicMethodPresent iMethodName iComponentImplementation="">
	<#local componentImplementation=object>
 	<#if iComponentImplementation!="">
		<#local componentImplementation=iComponentImplementation>
 	</#if>
	<#list componentImplementation.methodImplementation as methodImplementation>
		<#if (methodImplementation.method?has_content) && (iMethodName == methodImplementation.method.idref.name) &&
		protected.hasMethodAlternativeImplementation(iMethodName)=="">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function> 

<#function protectedMethodPresent iMethodName iComponentImplementation="">
	<#local componentImplementation=object>
 	<#if iComponentImplementation!="">
		<#local componentImplementation=iComponentImplementation>
 	</#if>
	<#list componentImplementation.methodImplementation as methodImplementation>
		<#if iMethodName == methodImplementation.name &&
	 		 protected.hasMethodAlternativeImplementation(iMethodName)=="">
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function> 

<#function hasEnumerations iDatatype>
	<#if iDatatype.facet?exists>
		<#list iDatatype.facet as facet>
			<#if facet.type=="enumeration">
				<#return true>
			</#if>
		</#list>
	</#if>		
	<#return false>
</#function>

<#--#unused.so--
<#function listMethodArgumentImplementations iMethodName>
	<#return listMethodArgumentImplementationsAA(object, iMethodName)>
</#function>

<#function listMethodArgumentImplementationsAA iComponentImplementation iMethodName>
	<#local methodArgumentImplementationList=[]/>
	<#list iComponentImplementation.methodImplementation as methodImplementation>
		<#if getNameFromMethodImplementation(methodImplementation)==iMethodName>
			<#list methodImplementation.methodArgumentImplementation as methodArgumentImplementation>
				<#local methodArgumentImplementationList=methodArgumentImplementationList+[methodArgumentImplementation]/>
			</#list>
			<#break>
		</#if>
	</#list>
	<#list iComponentImplementation.relationshipImplementation as relationshipImplementation>
		<#if relationshipImplementation.relationship?has_content && relationshipImplementation.relationship.idref.type=="aggregation">
			<#list listMethodArgumentImplementationsAA(relationshipImplementation.componentImplementation, iMethodName) as methodArgumentImplementation>
				<#local methodArgumentImplementationList=methodArgumentImplementationList+[methodArgumentImplementation]/>
			</#list>
		</#if>
	</#list>
	<#return methodArgumentImplementationList>
</#function>
<#--#unused.eo-->

<#--#perf.sn-->
<#macro initListComponentImplementations>
	<#global listOfAllComponentImplementations=[]>
</#macro>
<#--#perf.en-->

<#function listComponentImplementations iParentComponentName="" iobject=object>
	<#local componentImplementationList=[]>
	<#if iParentComponentName=="">
<#--#perf.sn-->
		<#if listOfAllComponentImplementations?size != 0>
			<#return listOfAllComponentImplementations>
		<#else>
<#--#perf.en-->
			<#local component={
				"parentComponentName":"", 
				"parentComponentImplementation":"",
				"componentName":names.businessInterfaceName,
				"componentPublicName":names.businessInterfaceName,
				"componentImplementation":iobject,
				"relationshipImplementation":""
			}>
			<#local componentImplementationList=listComponentImplementationsAA([component], component)> 
<#--#perf.sn-->
			<#assign listOfAllComponentImplementations=componentImplementationList>
		</#if>
<#--#perf.en-->
	<#else>
		<#list listComponentImplementations("", iobject) as c>
			<#if c.parentComponentName==iParentComponentName>
				<#local componentImplementationList=componentImplementationList+[c]>				
			</#if>
		</#list>
	</#if>
	<#return componentImplementationList>
</#function>

<#function listComponentImplementationsAA iComponentImplementationList iParent>
	<#list iParent.componentImplementation.relationshipImplementation as relationshipImplementation>	
		<#if relationshipImplementation.relationship?has_content && relationshipImplementation.relationship.idref.type=="aggregation">
			<#local component={
				"parentComponentName":iParent.componentName, 
				"parentComponentImplementation":iParent.componentImplementation,
				"componentName":getComponentName(relationshipImplementation.componentImplementation),
				"componentPublicName":getComponentPublicName(relationshipImplementation.componentImplementation),
				"componentImplementation":relationshipImplementation.componentImplementation,
				"relationshipImplementation":relationshipImplementation
			}>	
			<#local iComponentImplementationList=iComponentImplementationList+[component]>
			<#local iComponentImplementationList=listComponentImplementationsAA(iComponentImplementationList, component)>
		</#if>
	</#list>
	<#return iComponentImplementationList>
</#function>


<#function listComponentImplementationsXX>
	<#local componentImplementationList=[{
		"parentComponentName":"", 
		"parentComponentImplementation":"",
		"componentName":names.businessInterfaceName, 
		"componentImplementation":object}]>
	<#return listComponentImplementationsAA(componentImplementationList, object)> 
</#function>

<#function listComponentImplementationsYY iComponentImplementationList iComponentImplementation>
	<#list iComponentImplementation.relationshipImplementation as relationshipImplementation>
		<#if relationshipImplementation.relationship?has_content && relationshipImplementation.relationship.idref.type=="aggregation">
			<#local iComponentImplementationList=iComponentImplementationList+[{
				"parentComponentName":getComponentName(iComponentImplementation), 
				"parentComponentImplementation":iComponentImplementation, 
				"componentName":getComponentName(relationshipImplementation.componentImplementation), 
				"componentImplementation":relationshipImplementation.componentImplementation,
				"relationshipImplementation":relationshipImplementation}]>		
			<#local dummy=listComponentImplementationsAA(iComponentImplementationList, relationshipImplementation.componentImplementation)>
		</#if>
	</#list>
	<#return iComponentImplementationList>
</#function>

<#function listAttributeImplementations iComponentName="">
	<#assign attributeImplementationList=[]/>
	<#list listComponentImplementations() as ci>
		<#if iComponentName=="" || ci.componentName==iComponentName>
			<#list ci.componentImplementation.attributeImplementation as ai>
				<#local attributeImplementationList=attributeImplementationList+[{
					"componentName":ci.componentName,
					"componentImplementation":ci.componentImplementation,					
					"attributeName":getAttributeName(ai),
					"attributeImplementation":ai
				}]>				
			</#list>
			<#if iComponentName!="">
				<#break>
			</#if>
		</#if>
	</#list>
	<#return attributeImplementationList>
</#function>

<#function get_BaanDatatype_from_XMLSchemaDatatype iDatatype>
	<#if common.hasEnumerations(iDatatype)>
		<#return "DB.ENUM">
	<#else>
		<#if isTextDatatype(iDatatype)>
			<#return "DB.TEXT">
		</#if>
		<#switch iDatatype.primitiveDatatype>
			<#case "string">
			<#case "normalizedString">
				<#return "DB.STRING">
				<#break>
			<#case "byte">
			<#case "int">
			<#case "integer">
			<#case "negativeInteger">
			<#case "nonNegativeInteger">
			<#case "nonPositiveInteger">
			<#case "positiveInteger">
			<#case "short">			
			<#case "unsignedByte">
			<#case "unsignedInt">
			<#case "unsignedLong">
			<#case "unsignedShort">
			<#case "long">
				<#return "DB.LONG">
				<#break>
			<#case "float">
				<#return "DB.FLOAT">
			<#case "decimal">
			<#case "double">
				<#return "DB.DOUBLE">
				<#break>
			<#case "date">
				<#return "DB.DATE">
				<#break>
			<#case "time">
			<#case "dateTime">
				<#return "DB.TIME">
				<#break>
			<#case "boolean">
				<#return "DB.BOOLEAN">
				<#break>
			<#case "anyType">
				<#--used for XML attributes, which are declared as long in erp ln-->
				<#return "DB.LONG">
				<#break>
			<#case "anyURI">
			<#case "duration">
			<#case "Name">
				<#return "DB.STRING">
				<#break>
			<#case "base64Binary">	
			<#case "ENTITIES">
			<#case "ENTITY">
			<#case "gDay">
			<#case "gMonth">
			<#case "gMonthDay">
			<#case "gYear">
			<#case "gYearMonth">
			<#case "hexBinary">
			<#case "ID">
			<#case "IDREF">
			<#case "IDREFS">
			<#case "language">
			<#case "NCName">
			<#case "NMTOKEN">
			<#case "NMTOKENS">
			<#case "NOTATION">
			<#case "QName">
			<#case "token">
			<#default>
				${logger.error(object, "Primitive datatype "+iDatatype.primitiveDatatype+" is unsupported for ERP LN")}
				<#--we could as well use error, because the generation or compilation will no doubt fail later on-->
				<#return "">
				<#break>
		</#switch>
	</#if>
</#function>

<#function isTextDatatype iDatatype>
	<#if iDatatype.dbDatatype?exists && iDatatype.dbDatatype == "db.text">
		<#return true>
	<#else>
		<#-- fallback to original check -->
		<#-- iDatatype is a reference, not a string containing data type name -->
		<#if iDatatype.nativeDatatype?exists>
			<#if  ( iDatatype.nativeDatatype?ends_with("text") || 
					iDatatype.nativeDatatype?ends_with("txta") || 
					iDatatype.nativeDatatype?ends_with("txtn") ) &&
					( iDatatype.nativeDatatype?length == 6 || 
						iDatatype.nativeDatatype?length == 10 )>
				<#return true>
			</#if> <#--iDatatype.nativeDatatype?matches...-->
		</#if> <#--iDatatype.nativeDatatype?exists-->
	</#if>
	<#return false>
</#function> <#--isTextDatatype-->

<#function listRelationshipDetails iComponentImplementation iRelationshipImplementation>
	<#local container=[]>

	<#if iRelationshipImplementation.componentImplementation?exists>
		<#local toComponentImplementation=iRelationshipImplementation.componentImplementation>
	<#else>
		<#local toComponentImplementation=iRelationshipImplementation.toBusinessInterfaceImplementation.idref>
		<#if iRelationshipImplementation.toComponentImplementation?exists>
			<#local toComponentImplementation=iRelationshipImplementation.toComponentImplementation.idref>
		</#if>
	</#if>
	
	<#if iRelationshipImplementation.relationshipImplementationAttribute?size!=0>
		<#list iRelationshipImplementation.relationshipImplementationAttribute as ra>
			<#local fromAttributeImplementation=ra.from.idref>	
			<#local toAttributeImplementation=ra.to.idref>
				<#local container=container+[{
					"fromComponentImplementation":iComponentImplementation,
					"fromComponentName":getComponentName(iComponentImplementation),
					"fromAttributeName":common.getAttributeName(fromAttributeImplementation),
					"fromAttributeImplementation":fromAttributeImplementation, 
					"toComponentImplementation":toComponentImplementation,
					"toComponentName":getComponentName(toComponentImplementation),
					"toAttributeName":common.getAttributeName(toAttributeImplementation),
					"toAttributeImplementation":toAttributeImplementation
				}]>
		</#list>
	<#else>
	
		<#list iRelationshipImplementation.relationship.idref.relationshipAttribute as ra>
			<#local fromAttributeImplementation=common.getAttributeImplementation(iComponentImplementation, ra.from.idref.name)>	
			<#local toAttributeImplementation=common.getAttributeImplementation(toComponentImplementation, ra.to.idref.name)>

				<#local container=container+[{
					"fromComponentImplementation":iComponentImplementation,
					"fromComponentName":getComponentName(iComponentImplementation),
					"fromAttributeName":common.getAttributeName(fromAttributeImplementation),
					"fromAttributeImplementation":fromAttributeImplementation, 
					"toComponentImplementation":toComponentImplementation,
					"toComponentName":getComponentName(toComponentImplementation),
					"toAttributeName":common.getAttributeName(toAttributeImplementation),
					"toAttributeImplementation":toAttributeImplementation
				}]>
		</#list>
	</#if>
	<#return container>
</#function>

<#function getDatatypeFromAttributeImplementation iAttributeImplementation>
	<#if iAttributeImplementation.datatype?exists>
		<#return iAttributeImplementation.datatype.idref>
	<#else>
		<#if !iAttributeImplementation.type?exists>
			<#return "">
		</#if>
		<#if iAttributeImplementation.type=="column">
			<#return iAttributeImplementation.column.idref.datatype.idref>
		<#elseif iAttributeImplementation.type=="association">
			<#return getDatatypeFromAttributeImplementation(iAttributeImplementation.attributeFromAssociation.idref)>
		<#elseif iAttributeImplementation.type=="interactionpoint">
			<#if iAttributeImplementation.interactionPoint.idref.datatype?exists>
				<#return iAttributeImplementation.interactionPoint.idref.datatype.idref>
			</#if>
		</#if>
	</#if>
	<#return "">
</#function>

<#function getPublicDatatypeFromAttributeImplementation iAttributeImplementation>
	<#if iAttributeImplementation.attribute?has_content>
		<#if iAttributeImplementation.attribute.idref.datatype?exists>	
			<#return iAttributeImplementation.attribute.idref.datatype.idref>
		</#if>
	</#if>
</#function>

<#function getMandatoryDatatype iAttributeImplementation>
	<#local datatype=getDatatype(iAttributeImplementation)>
	<#if datatype=="">
		${logger.error(object, "Failed to get Datatype from Attribute ${getAttributeName(iAttributeImplementation)}.")}
	</#if>
	<#return datatype>
</#function>

<#function getDimensionsForDataType iDatatype>
	<#if iDatatype.dimensions?exists>
		<#if !(iDatatype.dimensions?contains(",")) && !(iDatatype.dimensions?number == 0)>
			<#return iDatatype.dimensions>
		<#else>		
			${logger.error(object, "2b. Datatype ${common.getDataTypeName(iDatatype)} has an invalid dimensions value ${iDatatype.dimensions}.")}
		</#if>
	</#if>
	<#return 1>
</#function>

<#function getDatatypeFromMethodArgumentImplementation iMethodArgumentImplementation>
	<#if iMethodArgumentImplementation.datatype?exists>
		<#return iMethodArgumentImplementation.datatype.idref>
	<#else>
		<#if iMethodArgumentImplementation.attributeImplementation?exists>	
			<#return getDatatypeFromAttributeImplementation(iMethodArgumentImplementation.attributeImplementation.idref)>
		<#else>	
			${logger.warn(object, "Failed to get Datatype from MethodArgumentImplementation ${iMethodArgumentImplementation.name}")}
		</#if>
	</#if>
	<#return "">
</#function>

<#function getScopeFromMethodArgumentImplementation iMethodArgumentImplementation>
	<#if iMethodArgumentImplementation.scope?exists>
		<#return iMethodArgumentImplementation.scope>
	<#else>
		<#if iMethodArgumentImplementation.methodArgument?exists>
			<#return iMethodArgumentImplementation.methodArgument.idref.scope>
		<#else>	
			${logger.warn(object, "Failed to get Scope from MethodArgumentImplementation ${iMethodArgumentImplementation.name}")}
		</#if>
	</#if>
	<#return "">
</#function>
		
<#function getIsMandatoryFromMethodArgumentImplementation iMethodArgumentImplementation>
	<#if iMethodArgumentImplementation.isMandatory?exists>
		<#return iMethodArgumentImplementation.isMandatory>
	<#else>
		<#if iMethodArgumentImplementation.methodArgument?exists>
			<#return iMethodArgumentImplementation.methodArgument.idref.isMandatory>
		<#elseif iMethodArgumentImplementation.attributeImplementation?exists>
			<#assign attributeImplementation=iMethodArgumentImplementation.attributeImplementation.idref>
			<#if attributeImplementation.isMandatory?exists>
				<#return attributeImplementation.isMandatory>
			<#elseif attributeImplementation.attribute?exists && attributeImplementation.attribute.idref?exists>
				<#assign attribute=attributeImplementation.attribute.idref>
				<#if attribute.isMandatory?exists>
					<#return attribute.isMandatory>
				</#if>
			</#if>
		<#else>	
			${logger.warn(object, "Failed to get IsMandatory from MethodArgumentImplementation ${iMethodArgumentImplementation.name}")}
		</#if>
	</#if>
	<#return false>
</#function>

<#function getNameFromMethodImplementation iMethodImplementation>
	<#if iMethodImplementation.method?has_content>
		<#if iMethodImplementation.method.idref.name?exists>
			<#return iMethodImplementation.method.idref.name>
		</#if>
	</#if>
	<#return iMethodImplementation.name>
</#function>

<#function eventCanBeReceived(iEventName)>
	<#list object.businessInterfaceDefinition.idref.event as event>
		<#if event.name == iEventName>
			<#return event.canBeReceived>
		</#if>
	</#list>
	<#return false>
</#function>

<#function eventCanBePublished(iEventName)>
	<#list object.businessInterfaceDefinition.idref.event as event>
		<#if event.name == iEventName>
			<#return event.canBePublished>
		</#if>
	</#list>
	<#return false>
</#function>

<#macro checkCancel>
	<#if monitor.isCancelled()>
		<#-- Cancel pressed on progress dialog, stop processing -->
		${logger.warn(object, "Generation canceled by user.")}
		<#stop "Generation canceled by user.">
	</#if>
 </#macro>
