<<#-- 
     SSA Global copyright notice
  -->
<#macro copyright>
/******************************************************
 *  Copyright SSA Global Technologies, Inc. 2000-2005.
 *  All rights reserved.
 * 
 *  Generated by generator,
 *  Name    : ${versionhelper.templatename}
 *  Id      : ${versionhelper.templateid}
 *  version : ${versionhelper.templateversion} 
 *  version : ${versionhelper.generatorversion} (framework)
 *
 *  on ${today?datetime}. 
 *  Please: DO NOT EDIT THIS GENERATED SOURCE !
 *
</#macro>
<#-- 
     A macro to clean up a string value for use as a name 
     - remove all spaces
     - convert any other invalid characters to underscores
     - and insert an underscore at the start if the first character is a digit 
  -->
<#macro toName name>${name?replace(" ","")?replace("[^_a-zA-Z0-9]","_")?replace("^([0-9])","_\\1")}</#macro>
<#-- 
     Make a valid Java name out of a String value
     - name is the value that's to be converted to a name
     
     In BidProxyName.ftl I used StringHelper's name() attribute to do this to demonstrate that there's 
     another way to do the same thing.  This function really should be in a separate FreeMarker template 
     that's included in this one with an #import directive, but I'm doing it the proxy template just to
     simplify things.
     
     One of the things we'll need to do is build a library of standard templates (like asName).
  -->
<#function asName name>
	<#return '${name?replace(" ","")?replace("[^_a-zA-Z0-9]","_")?replace("^([0-9])","_\\\\1")}'>
</#function>
<#function getdotnetdt bdeDatatype>
	<#switch bdeDatatype>
		<#case "date">
			<#return 'DateTime'>
			<#break>
			
		<#case "time">
			<#return 'DateTime'>
			<#break>
			
		<#case "dateTime">
			<#return 'DateTime'>
			<#break>
			
		<#case "decimal">
		<#case "Decimal">		
		<#case "double">		
			<#return 'double'>
			<#break>

		<#case "float">		
			<#return 'float'>
			<#break>
			
			
		<#case "gDay">
		<#case "gMonth">
		<#case "gMonthDay">
		<#case "gYear">
		<#case "gYearMonth">
			<#return 'int'>
			<#break>

		<#case "nonNegativeInteger">
		<#case "nonPositiveInteger">
			<#return 'int'>
			<#break>


		<#case "unsignedByte">
		<#case "byte">
			<#return 'byte'>
			<#break>

		
		<#case "unsignedInt">
		<#case "int">
		<#case "positiveInteger">
		<#case "negativeInteger">
		<#case "nonNegativeInteger">
		<#case "nonPositiveInteger">
			<#return 'int'>
			<#break>

		<#case "unsignedLong">
		<#case "long">
		<#case "integer">
			<#return 'long'>
			<#break>

		<#case "short">
		<#case "unsignedShort">
			<#return 'short'>
			<#break>

		<#case "string">
		<#case "duration">
			<#return 'string'>
			<#break>

		<#case "boolean">
			<#return 'bool'>
			<#break>
			
		<#-- Everything else is a String -->
		<#default> 
		 	<#return 'string'>
	</#switch>  
</#function>
<#function getSchemadt bdeDatatype>
	<#switch bdeDatatype>
		<#case "date">
		<#case "time">
		<#case "dateTime">
		<#case "decimal">
		<#case "Decimal">
			<#return bdeDatatype>
			<#break>
			
		<#default> 
		 	<#return getdotnetdt(bdeDatatype)>
	</#switch>  
</#function>
<#function getFunctiondt bdeDatatype>
	<#switch bdeDatatype>
		<#case "date">
		<#case "time">
		<#case "dateTime">
			<#return bdeDatatype>
			<#break>
			
		<#default> 
		 	<#return getdotnetdt(bdeDatatype)>
	</#switch>  
</#function>
<#function asName name>
	<#return '${name?replace(" ","")?replace("[^_a-zA-Z0-9]","_")?replace("^([0-9])","_\\\\1")}'>
</#function>
<#function primkeys_names subObject>
  	<#assign countPKeys = countPrimKeys(subObject)>
  	<#assign result = "">
	<#list subObject.attribute as attribute>
		<#if attribute.isIdentifier && !attribute.isHidden && !common.isUsedInComplexOrGroup(subObject, attribute)>
			<#assign countPKeys = countPKeys -1>
			<#if ( countPKeys != 0 )>
				<#assign result = '${result}p_${attribute.name},'/>	
			<#else>
				<#assign result = '${result}p_${attribute.name}'/>
			</#if>
		</#if>
	</#list>
	<#return '${result}'>
</#function>
<#function primkeys_types_and_names subObject>
  	<#assign countPKeys = countPrimKeys(subObject)>
  	<#assign result = "">
	<#list subObject.attribute as attribute>
		<#if attribute.isIdentifier && !attribute.isHidden && !common.isUsedInComplexOrGroup(subObject, attribute)>
			<#switch attribute.type>
			  	<#case "simple">
					<#assign dataType = common.getdotnetdt(attribute.datatype.idref.primitiveDatatype)>		  	
				<#break>
				<#case "group">
					<#assign dataType = attribute.name?cap_first>
				<#break>
				<#case "complex">
					<#assign dataType = attribute.datatype.idref.name?cap_first>			
				<#break>	
			</#switch>  
			<#assign countPKeys = countPKeys -1>
			<#if ( countPKeys != 0 )>
				<#assign result = '${result}${dataType} p_${attribute.name}, '/>	
			<#else>
				<#assign result = '${result}${dataType} p_${attribute.name}'/>
			</#if>
		</#if>
	</#list>
	<#return '${result}'>
</#function>
<#function mandatoryAttributes subObject>
  	<#assign countPKeys = 0>
  	<#assign result = "">
  	<#list subObject.attribute as attribute>
		<#if !attribute.isHidden && attribute.isMandatory>  	
			<#assign countPKeys = countPKeys + 1>
		</#if>
	</#list>
	<#list subObject.attribute as attribute>
		<#if !attribute.isHidden && attribute.isMandatory>
			<#assign countPKeys = countPKeys -1>
			<#if ( countPKeys != 0 )>
				<#assign result = '${result}${attribute.name}, '/>	
			<#else>
				<#assign result = '${result}${attribute.name}'/>
			</#if>
		</#if>
	</#list>
	<#return '${result}'>
</#function>
<#function countPrimKeys subObject>
  	<#assign countPKeys = 0>
  	<#list subObject.attribute as attribute>
		<#if attribute.isIdentifier && !attribute.isHidden && !isUsedInComplexOrGroup(subObject, attribute)>
			<#assign countPKeys = countPKeys + 1>
		</#if>
	</#list>
	<#return countPKeys>
</#function>
<#function identifyingAttributes subObject>
  	<#assign countPKeys = countPrimKeys(subObject)>
  	<#assign result = "">
	<#list subObject.attribute as attribute>
		<#if attribute.isIdentifier && !attribute.isHidden && !common.isUsedInComplexOrGroup(subObject, attribute)>
			<#assign countPKeys = countPKeys -1>
			<#if ( countPKeys != 0 )>
				<#assign result = '${result}${attribute.name}, '/>	
			<#else>
				<#assign result = '${result}${attribute.name}'/>
			</#if>
		</#if>
	</#list>
	<#return '${result}'>
</#function>
<#function getBIDName subObject>
	<#assign bidName = subObject.id>
	<#assign bidName = bidName?replace("bid", "") >
	<#assign bidName = bidName?replace("-comp"+subObject.name, "") >
	<#return bidName>
</#function>
<#function getSubComponent relations>
	<#-- code to access subcomponents for Association an Aggregation -->
	<#if relations.type = "aggregation">
		<#assign subComponent = relations.component >	
	<#else>
		<#-- code if subcomponent is BID or just a Component -->	
		<#if relations.toComponent?exists>
			<#assign subComponent = relations.toComponent.idref >			
		<#else>	
			<#assign subComponent = relations.toBusinessInterface.idref >			
		</#if>	
	</#if>
	<#return subComponent>
</#function>
<#function isUsedInComplexOrGroup iComponent iAttribute>
	<#return iAttribute.parentAttribute?has_content>
</#function>
<#macro printAttributeInfo _attr>${_attr.name} '${_attr.type}' attribute.<#if _attr.isIdentifier>${'\n'}		/// Attribute is identifier.</#if><#if _attr.isMandatory>${'\n'}		/// <br>Attribute is mandatory.</#if>	</#macro>
<#macro printAttributeDescription _attr><#if _attr.description?has_content>Description is '${_attr.description}'.</#if></#macro>