<#import "common.ftl" as common/>  
<#--
     Generate the type-safe Java proxy for a BusinessInterfaceDefinition
     - object is an instance of BusinessInterfaceDefinition
     - properties is a HashMap generated by PropertiesHelper.getInstance() - it provides access to the
       named GeneratorProperty elements in ApplicationControlData.
  -->
<@common.copyright/>
 *  Component Name: ${object.name?cap_first}
 * <#if object.versionID?has_content> Component Version: ${object.versionID}</#if>
 * <#if object.description?has_content> Component Description: ${object.description}</#if>
 *****************************************************/
<#if object.type == "group">
<#assign TypeName><@common.toName name="${object.name?cap_first}"/></#assign>
<#else>
<#assign TypeName><@common.toName name="${object.datatype.idref.name?cap_first}"/></#assign>
</#if>

using System;
using OpenWorld.Adapter.BdeImpl;

<#if properties.namespace?has_content>namespace ${properties.namespace}
{
</#if>

 	/// Generated typesafe BDE '${object.type}' Type ${TypeName}.
 	/// <#if object.versionID?has_content>Component Version: ${object.versionID}<br></#if>
 	/// <#if object.description?has_content>Component Description: ${object.description}</#if>
	public class ${TypeName} : BusinessDataEntity
	{
		/// Constructor for creating an 'empty' type ${TypeName}.
		/// <br>Depending on the action you want to perform identifying or mandatory attributes may be required.
		public ${TypeName}() : base(s_metaData[0][ITEM_NAME])
		{
		}


<#assign attributeIndex=0>
<#list object.attributeRelationship as attr>
	<#assign subAttribute=attr.attribute.idref>
	<#if !subAttribute.isHidden>  
	<#assign attributeIndex=attributeIndex+1>
	<#switch subAttribute.type>
	  	<#case "simple">
		<#assign dataType = common.getdotnetdt(subAttribute.datatype.idref.primitiveDatatype)>
		<#assign functionType = common.getFunctiondt(subAttribute.datatype.idref.primitiveDatatype)>		  	
		<#assign subAttributeName=attr.name>		
		<#break>
		<#case "group">
		<#assign dataType = subAttribute.name?cap_first>
		<#assign subAttributeName=subAttribute.name>		
		<#break>
		<#case "complex">		
		<#assign dataType = subAttribute.datatype.idref.name?cap_first>
		<#assign subAttributeName=attr.name>		
		<#break>	
	</#switch>  
		/// Get <@common.printAttributeInfo _attr=subAttribute/>
		/// <@common.printAttributeDescription _attr=subAttribute/>
		public ${dataType} Get${subAttributeName?cap_first}() 
	   	{
			<#if subAttribute.type = "simple">
			return get${functionType?cap_first}Value(${attributeIndex});
			<#else>
			${dataType} new${dataType} = new ${dataType}();
			getComplexValue(${attributeIndex}, new${dataType});
			return new${dataType};
			</#if>
	   	}
    
		/// Set <@common.printAttributeInfo _attr=subAttribute/>
		/// <@common.printAttributeDescription _attr=subAttribute/>
	   	public void Set${subAttributeName?cap_first}(${dataType} value) 
	   	{
			<#if subAttribute.type = "simple">
			set${functionType?cap_first}Value(${attributeIndex}, value);
			<#else>
			setComplexValue(${attributeIndex}, value);
			</#if>
	   	}
	   		
		/// Has <@common.printAttributeInfo _attr=subAttribute/>
		/// <@common.printAttributeDescription _attr=subAttribute/>
	   	public Boolean Has${subAttributeName?cap_first}()
	   	{
	       	return hasValue(${attributeIndex});
	   	}	
	   	
		/// Unset <@common.printAttributeInfo _attr=subAttribute/>
		/// <@common.printAttributeDescription _attr=subAttribute/>
	   	public void Unset${subAttributeName?cap_first}()
	   	{
	       	unsetValue(${attributeIndex});
	   	}	  

	</#if>	
</#list>
		private static String [][] s_metaData = 
		{
			new string[]{"${TypeName}"}
<#list object.attributeRelationship as attr>
	<#assign subAttribute=attr.attribute.idref>
	<#if !subAttribute.isHidden>
	<#switch subAttribute.type>
	  	<#case "simple">
			,new string[]{"${attr.name}", "${common.getSchemadt(subAttribute.datatype.idref.primitiveDatatype)}"<#list subAttribute.datatype.idref.facet as facet><#if facet_index = 0>,</#if><#break></#list><#list subAttribute.datatype.idref.facet as facet>"${facet.type?j_string}:${facet.value?j_string}"<#if facet_has_next>,</#if></#list>}  	
		<#break>
		<#case "group">
			,new string[]{"${attr.name}", "group"}
		<#break>
		<#case "complex">
			,new string[]{"${attr.name}", "complex"}
		<#break>	
	</#switch>  	
	</#if>
</#list>
		};
	
	
		protected override String getMetaData(int ItemIndex, int ProperyIndex)
		{
			try
    	    {
        	    return s_metaData[ItemIndex][ProperyIndex];
	        }
    	    catch (Exception) 
	        {
    	        return null;
       		}
		}


		protected override BdeIterator _createComponentIterator(int index)
		{
			return null;
		}
	
		internal static String _getPrimaryKeys(String sParentName)
		{
			return null;
		}
	}
	
<#if properties.namespace?has_content>}</#if>
