<#-- 
     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 getjavadt bdeDatatype>
	<#switch bdeDatatype>
		<#case "date">
			<#return 'Date'>
			<#break>
			
		<#case "time">
			<#return 'Time'>
			<#break>
			
		<#case "dateTime">
			<#return 'DateTime'>
			<#break>
			
		<#case "gDay">
		<#case "gMonth">
		<#case "gMonthDay">
		<#case "gYear">
		<#case "gYearMonth">
			<#return 'int'>
			<#break>

		<#case "decimal">
			<#return 'double'>
			<#break>
			
		<#case "integer">
			<#return 'BigInteger'>
			<#break>
			
		<#case "nonNegativeInteger">
		<#case "nonPositiveInteger">
			<#return 'int'>
			<#break>

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

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

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

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

		<#case "string">
		<#case "duration">
			<#return 'String'>
			<#break>
			
		<#default> 
		 	<#return 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.getjavadt(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'}	 * <br>Attribute is identifier.</#if><#if _attr.isMandatory>${'\n'}	 * <br>Attribute is mendatory.</#if>	</#macro>
<#macro printAttributeDescription _attr><#if _attr.description?has_content>Description is '${_attr.description}'.</#if></#macro>