<#--
   ******************************************************
   *
   *                       NOTICE
   *
   *  THIS SOFTWARE IS THE PROPERTY OF AND CONTAINS
   *  CONFIDENTIAL INFORMATION OF INFOR GLOBAL 
   *  SOLUTIONS, INC., 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:
   *
   *  (c) COPYRIGHT 2007 INFOR GLOBAL SOLUTIONS, INC.
   *
   *           INFOR GLOBAL SOLUTIONS, INC.
   *
   ******************************************************
 -->
<#function getName component>
	<#if component.publicName?has_content>
		<#return component.publicName>
	<#else>
		<#return component.name>	
	</#if>	
</#function>
 
<#macro showSelectionAttributes component indent>
	<#if !component.isHidden && component.attribute?has_content>
${indent}<selectionAttribute>${getName(component)}.*</selectionAttribute>		
		<#list component.attribute as attribute>
			<#if !attribute.isHidden && !isUsedInComplexOrGroup(component,attribute)>
				<#switch attribute.type>
					<#case "simple">
${indent}<selectionAttribute>${getName(component)}.${attribute.name}</selectionAttribute>				
					<#break>
					<#case "group">			
					<#case "complex">
						<@showComplexSelectionAttributes component=component indent=indent iCompleteName="" iAttribute=attribute iAttributeRelation=""/>
					<#break>
				</#switch>  			
			</#if>
		</#list>
	</#if>
	<#if component.relationship?has_content>
		<#list component.relationship as relationship>
			<#if relationship.type = "aggregation">
				<#local subComponent = relationship.component>
				<@showSelectionAttributes component=subComponent indent=indent/>
			<#elseif relationship.type = "association">
				<#-- association not supported -->	
			</#if>
		</#list>
	</#if>
</#macro>
<#macro showComplexSelectionAttributes component indent iCompleteName iAttribute iAttributeRelation>
	<#if !component.isHidden && !iAttribute.isHidden>
		<#switch iAttribute.type>
			<#case "simple">
${indent}<selectionAttribute>${getName(component)}.${iCompleteName}${iAttributeRelation.name}</selectionAttribute>
			<#break>
			<#case "group">
			<#case "complex">		
				<#if iAttributeRelation?has_content>
${indent}<selectionAttribute>${getName(component)}.${iCompleteName}${iAttributeRelation.name}.*</selectionAttribute>
				<#else>
${indent}<selectionAttribute>${getName(component)}.${iCompleteName}${iAttribute.name}.*</selectionAttribute>
				</#if>
				<#list iAttribute.attributeRelationship as ar>
	 				<#if iAttributeRelation?has_content>
						<@showComplexSelectionAttributes component=component indent=indent iCompleteName = iCompleteName+iAttributeRelation.name+"." iAttribute=ar.attribute.idref iAttributeRelation=ar/>
					<#else>
						<@showComplexSelectionAttributes component=component indent=indent iCompleteName = iCompleteName+iAttribute.name+"." iAttribute=ar.attribute.idref iAttributeRelation=ar/>				
					</#if>
				</#list>
			<#break>
		</#switch>
	</#if>
</#macro>
<#macro showAttributes component indent>
	<#if component.isHidden>
		<#return>
	</#if>
	<@showAnchoredComponents iComponent=component iAnchorAttribute="" iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=false methodRelated=false/>
	<#if component.attribute?has_content>
		<#list component.attribute as attribute>
			<#if !attribute.isHidden && !isUsedInComplexOrGroup(component,attribute)>		
				<#switch attribute.type>
					<#case "simple">
						<#list 1..getDimensions(attribute) as i>
							<#assign attributeQualifier="">
    						<#if attribute.isIdentifier>
    							<#assign attributeQualifier= " _identifier=\"true\"">
    						<#else>
			    				<#if !attribute.isMandatory>
									<#assign attributeQualifier=" _optional=\"true\"">
								</#if>
							</#if>
							<#list attribute.attributeRelationship as ar>
								<#if ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden>
									<#assign attributeQualifier=attributeQualifier + " " + ar.name + "=\"\"">							
								</#if>
							</#list>
							<#assign enums=getEnumAttribute(attribute)>
							<@showAnchoredComponents iComponent=component iAnchorAttribute=attribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=false methodRelated=false/>
${indent}<${attribute.name}${attributeQualifier}${enums}/>
							<@showAnchoredComponents iComponent=component iAnchorAttribute=attribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=false methodRelated=false/>
						</#list>				
					<#break>
					<#case "group">			
					<#case "complex">
						<@showComplexAttributes iComponent=component iAttribute=attribute iAttributeRelation="" indent=indent/>
					<#break>
				</#switch>							
			</#if>
		</#list>
	</#if>
	<@showAnchoredComponents iComponent=component iAnchorAttribute="" iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=false methodRelated=false/>
</#macro>
<#macro showComplexAttributes iComponent iAttribute iAttributeRelation indent>
	<#if iAttribute.isHidden>
		<#return>
	</#if>
	<#if iAttributeRelation?has_content>
		<#local name=iAttributeRelation.name>
	<#else>
		<#local name=iAttribute.name>
	</#if>
	<#switch iAttribute.type>
		<#case "simple">
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=false methodRelated=false/>
			<#list 1..getDimensions(iAttribute) as i>
				<#local attributeQualifier="">
				<#list iAttribute.attributeRelationship as ar>
					<#if ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden>
						<#local attributeQualifier=attributeQualifier + " " + ar.name + "=\"\"">
			 		</#if>
				</#list>
				<#if (!iAttribute.isMandatory)>		
					<#local attributeQualifier=attributeQualifier + " _optional=\"true\"">
				</#if>
				<#local enums=getEnumAttribute(iAttribute)>
${indent}<${name}${attributeQualifier}${enums}/>
			</#list>
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=false methodRelated=false/>
		<#break>
		<#case "group">		
			<#local attributeQualifier="">
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=false methodRelated=false/>
			<#list iAttribute.attributeRelationship as ar>
				<#if ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden>
					<#local attributeQualifier=attributeQualifier + " " + ar.name + "=\"\"">
		 		</#if>
			</#list>
			<#if (!iAttribute.isMandatory)>		
				<#local attributeQualifier=attributeQualifier + " _optional=\"true\"">
			</#if>
${indent}<${name}${attributeQualifier}>
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute="" iAnchorGroup=iAttribute iAnchorLocation="before" indent=indent+"\t" actionType=false methodRelated=false/>
			<#list iAttribute.attributeRelationship as ar>
	 			<@showComplexAttributes iComponent=iComponent iAttribute=ar.attribute.idref iAttributeRelation=ar indent=indent+"\t"/>
			</#list>
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute="" iAnchorGroup=iAttribute iAnchorLocation="after" indent=indent+"\t" actionType=false methodRelated=false/>
${indent}</${name}>								
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=false methodRelated=false/>
		<#break>
		<#case "complex">		
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=false methodRelated=false/>
			<#if iAttribute.isMandatory>		
${indent}<${name}>
			<#else>
${indent}<${name} _optional="true">								
			</#if>
			<#list iAttribute.attributeRelationship as ar>
				<@showComplexAttributes iComponent=iComponent iAttribute=ar.attribute.idref iAttributeRelation=ar indent=indent+"\t"/>
			</#list>					
${indent}</${name}>								
			<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=false methodRelated=false/>
		<#break>
	</#switch>  
</#macro>
<#function isUsedInComplexOrGroup component attributeToCheck>
	<#return attributeToCheck.parentAttribute?has_content>
</#function>
<#function isUsedAsMethodAttribute attributeToCheck>
	<#list object.methodArgument as methodArgument>
		<#if methodArgument.type == "attribute">
			<#if methodArgument.scope=="in" || methodArgument.scope=="inout">
				<#if methodArgument.attribute.idref = attributeToCheck>
					<#return true>
				</#if>
			</#if>
		</#if>
	</#list>
	<#return false>
</#function>
<#function isMandatoryMethodAttribute attributeToCheck>
	<#list object.methodArgument as methodArgument>
		<#if methodArgument.type == "attribute">
			<#if methodArgument.scope=="in" || methodArgument.scope=="inout">
				<#if methodArgument.attribute.idref = attributeToCheck>
					<#if methodArgument.isMandatory>
						<#return true>
					<#else>
						<#return false>
					</#if>
				</#if>
			</#if>
		</#if>
	</#list>
	<#return false>	
</#function>
<#function componentContainsMethodAttribute componentToCheck>
	<#list componentToCheck.attribute as attribute>
		<#if containsMethodAttribute(attribute)>
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>
<#function componentContainsMandatoryMethodAttribute componentToCheck>
	<#list componentToCheck.attribute as attribute>
		<#if containsMandatoryMethodAttribute(attribute)>
			<#return true>
		</#if>
	</#list>
	<#return false>
</#function>
<#function containsMethodAttribute attributeToCheck>
	<#switch attributeToCheck.type>
		<#case "simple">
			<#if isUsedAsMethodAttribute(attributeToCheck)>
				<#return true>
			</#if>
		<#break>		
		<#case "group">		
		<#case "complex">	
			<#list attributeToCheck.attributeRelationship as ar>
				<#if containsMethodAttribute(ar.attribute.idref)>
					<#return true>
				</#if>
			</#list>		
		<#break>	
	</#switch>  	
	<#return false>				
</#function>
<#function containsMandatoryMethodAttribute attributeToCheck>
	<#switch attributeToCheck.type>
		<#case "simple">
			<#if isMandatoryMethodAttribute(attributeToCheck)>
				<#return true>
			</#if>
		<#break>		
		<#case "group">		
		<#case "complex">	
			<#list attributeToCheck.attributeRelationship as ar>
				<#if containsMandatoryMethodAttribute(ar.attribute.idref)>
					<#return true>
				</#if>
			</#list>		
		<#break>	
	</#switch>  	
	<#return false>				
</#function>
<#function getEnumerations iAttribute>
	<#assign enums="">
	<#if iAttribute.datatype?has_content && iAttribute.datatype.idref?has_content && iAttribute.type == "simple">
		<#list iAttribute.datatype.idref.facet as facet>
			<#if facet.type == "enumeration">
				<#if enums != "">
					<#assign enums = enums + "|">
				</#if>
				<#assign enums = enums + facet.value>
			</#if>
		</#list>
	</#if>
	<#return enums>
</#function>
<#function getEnumAttribute iAttribute>
	<#local enums=getEnumerations(iAttribute)>
	<#if enums != "">
		<#local enums = " _enum=\"" + enums + "\"">
	</#if>
	<#return enums>
</#function>
<#function getDimensions iAttribute>
	<#local dimensions="1">
	<#if iAttribute.datatype?has_content && iAttribute.datatype.idref?has_content && iAttribute.datatype.idref.dimensions?exists>	
		<#local dimensions=iAttribute.datatype.idref.dimensions> 
		<#if dimensions?contains(",") || dimensions?number == 0>
			<#local dimensions="1">
		</#if> 	  														
	</#if>
	<#return dimensions?number>
</#function>
<#macro showMethodAttributes component indent actionType>
	<@showAnchoredComponents iComponent=component iAnchorAttribute="" iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=actionType methodRelated=true/>
	<#if component.attribute?has_content>
		<#if componentContainsMethodAttribute(component)>
			<#list component.attribute as attribute>
				<#if !attribute.isHidden && !isUsedInComplexOrGroup(component,attribute)>		
					<#switch attribute.type>    				
						<#case "simple">
    						<#if isUsedAsMethodAttribute(attribute)>								
								<@showAnchoredComponents iComponent=component iAnchorAttribute=attribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=actionType methodRelated=true/>
								<#list 1..getDimensions(attribute) as i>	
									<#local attributeQualifier="">
									<#list attribute.attributeRelationship as ar>
										<#if ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden>
											<#local attributeQualifier=attributeQualifier + " " + ar.name + "=\"\"">							
 										</#if> 
									</#list>		
									<#if !isMandatoryMethodAttribute(attribute)>
										<#local attributeQualifier=attributeQualifier + " _optional=\"true\"">
									</#if>							
									<#local enums=getEnumAttribute(attribute)>
${indent}<${attribute.name}${attributeQualifier}${enums}/>
								</#list>	
								<@showAnchoredComponents iComponent=component iAnchorAttribute=attribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=actionType methodRelated=true/>
							</#if>										
						<#break>
						<#case "qualifier">
							<#-- qualifiers handled by attributeRelationship -->
						<#break>
						<#case "group">
						<#case "complex">
							<@showComplexMethodAttributes iComponent=component iAttribute=attribute iAttributeRelation="" indent=indent actionType=actionType/>
						<#break>
					</#switch>							
				</#if>
			</#list>
		</#if>		
	</#if>
	<@showAnchoredComponents iComponent=component iAnchorAttribute="" iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=actionType methodRelated=true/>
</#macro>
<#macro showAnchoredComponents iComponent iAnchorAttribute iAnchorGroup iAnchorLocation indent actionType methodRelated>
	<#if iComponent.relationship?has_content>
		<#list iComponent.relationship as relationship>
			<#if relationship.type = "aggregation" && 
				(
					(!relationship.anchorAttribute?has_content && 
					 !relationship.anchorGroup?has_content &&
					 !iAnchorAttribute?has_content &&
					 !iAnchorGroup?has_content
					) 
					||
					(
						(relationship.anchorAttribute?has_content && 
						 relationship.anchorAttribute.idref == iAnchorAttribute
						) 
						|| 
				 		(relationship.anchorGroup?has_content && 
				 		 relationship.anchorGroup.idref == iAnchorGroup
				 		)
				 	)
				) 
				&& 
				relationship.anchorLocation == iAnchorLocation>
				<#local subComponent = relationship.component>
				<#if !subComponent.isHidden>
					<#local attributes = "">
					<#if relationship.multiplicity?contains("Many")>
						<#local attributes = attributes + " _many=\"true\"">
					</#if>
					<#if methodRelated>
						<#if componentContainsMethodAttribute(subComponent)>
							<#if actionType>
								<#local attributes = attributes + " actionType=\"create|change|createOrChange|delete|unchanged\"">
							</#if>
							<#if !componentContainsMandatoryMethodAttribute(subComponent)>
								<#local attributes = attributes + " _optional=\"true\"">
							</#if>						
${indent}<${getName(subComponent)}${attributes}>					
						</#if>						
					<#else>
						<#if relationship.multiplicity?contains("zero")>
							<#local attributes = attributes + " _optional=\"true\"">
						</#if>
					</#if>
					<#if methodRelated>
						<@showMethodAttributes component=subComponent indent=indent+"\t" actionType=actionType/>
						<#if componentContainsMethodAttribute(subComponent)>				
${indent}</${getName(subComponent)}>					
						</#if>												
					<#else>
${indent}<${getName(subComponent)}${attributes}>					
						<@showAttributes component=subComponent indent=indent+"\t"/>
${indent}</${getName(subComponent)}>
					</#if>
				</#if>
			<#elseif relationship.type = "association">
				<#-- association not supported -->	
			</#if>
		</#list>
	</#if>
</#macro>
<#macro showComplexMethodAttributes iComponent iAttribute iAttributeRelation indent actionType>
	<#if iAttributeRelation?has_content>
		<#local name=iAttributeRelation.name>
	<#else>
		<#local name=iAttribute.name>
	</#if>
	<#switch iAttribute.type>
		<#case "simple">		
	    	<#if isUsedAsMethodAttribute(iAttribute)>	
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=actionType methodRelated=true/>
				<#list 1..getDimensions(iAttribute) as i>	
					<#local attributeQualifier="">
					<#list iAttribute.attributeRelationship as ar>		
						<#if ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden>
							<#local attributeQualifier=attributeQualifier + " " + ar.name + "=\"\"">			
				 		</#if> 
					</#list>
					<#if !isMandatoryMethodAttribute(iAttribute)>
						<#local attributeQualifier=attributeQualifier + " _optional=\"true\"">
					</#if>							
					<#local enums=getEnumAttribute(iAttribute)>
${indent}<${name}${attributeQualifier}${enums}/>
				</#list>
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=actionType methodRelated=true/>
			</#if>
		<#break>
		<#case "qualifier">
			<#-- qualifiers handled by attributeRelationship -->
		<#break>
		<#case "group">		
			<#if containsMethodAttribute(iAttribute)>
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=actionType methodRelated=true/>
				<#local attributeQualifier="">
				<#list iAttribute.attributeRelationship as ar>		
					<#if ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden>
						<#local attributeQualifier=attributeQualifier + " " + ar.name + "=\"\"">			
			 		</#if> 
				</#list>
				<#if !containsMandatoryMethodAttribute(iAttribute)>
					<#local attributeQualifier=attributeQualifier + " _optional=\"true\"">
				</#if>
${indent}<${name}${attributeQualifier}>								
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute="" iAnchorGroup=iAttribute iAnchorLocation="before" indent=indent+"\t" actionType=actionType methodRelated=true/>
				<#list iAttribute.attributeRelationship as ar>
		 			<@showComplexMethodAttributes iComponent=iComponent iAttribute=ar.attribute.idref iAttributeRelation=ar indent=indent+"\t" actionType=actionType/>
				</#list>
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute="" iAnchorGroup=iAttribute iAnchorLocation="after" indent=indent+"\t" actionType=actionType methodRelated=true/>
${indent}</${name}>								
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=actionType methodRelated=true/>
			</#if> 			
		<#break>
		<#case "complex">		
			<#if containsMethodAttribute(iAttribute)>
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="before" indent=indent actionType=actionType methodRelated=true/>
				<#if containsMandatoryMethodAttribute(iAttribute)>
${indent}<${name}>								
				<#else>
${indent}<${name} _optional="true">								
				</#if>
				<#list iAttribute.attributeRelationship as ar>
					<@showComplexMethodAttributes iComponent=iComponent iAttribute=ar.attribute.idref iAttributeRelation=ar indent=indent+"\t" actionType=actionType/>
				</#list>					
${indent}</${name}>						
				<@showAnchoredComponents iComponent=iComponent iAnchorAttribute=iAttribute iAnchorGroup="" iAnchorLocation="after" indent=indent actionType=actionType methodRelated=true/>
			</#if> 			
		<#break>
	</#switch>  
</#macro>
<#macro showApplicationArea indent noun verb original>
	<#if original>
${indent}<OriginalApplicationArea _optional="true">
	<#else>
${indent}<ApplicationArea>
	</#if>
${indent}	<Sender>
${indent}		<LogicalID>lid://infor.erpln.bs</LogicalID>
${indent}		<ComponentID>erp</ComponentID>
${indent}	</Sender>
${indent}	<CreationDateTime>${today?string("yyyy-MM-dd'T'HH:mm:ss")}</CreationDateTime>
${indent}	<BODID>infor-nid:_tenantID_:_accountingEntityID_:_LocationID_:_documentID_:_revisionID_?${noun}&amp;verb=${verb}&amp;variationID=_variationID_</BODID>
	<#if original>
${indent}</OriginalApplicationArea>
	<#else>
${indent}</ApplicationArea>
	</#if>
</#macro>
<#function isClassMethod>
	<#list object.methodArgument as methodArgument>
		<#if methodArgument.scope=="in" || methodArgument.scope=="inout">
			<#return false>
		</#if>
	</#list>
	<#return true>	
</#function>
<#function methodHasControllingArguments>
	<#list object.methodArgument as methodArgument>
		<#if methodArgument.type == "controllingAttribute">
			<#if methodArgument.scope=="in" || methodArgument.scope=="inout">
				<#return true>	
			</#if>
		</#if>
	</#list>
	<#return false>
</#function>

