<#--
     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.
  -->
<#import "common.ftl" as common/>  
<@common.copyright/>
 *  BID Name: ${object.name?cap_first}<#if object.versionID?has_content>${'\n'} *  BID Version: ${object.versionID}</#if><#if object.description?has_content>${'\n'} *  BID Description: ${object.description}</#if><#if object.status?has_content>${'\n'} *  BID status: ${object.status}</#if><#if object.schemaVersion?has_content>${'\n'} *  Schema Version: ${object.schemaVersion}</#if>
 *****************************************************/
<#assign bdeName>
	<@common.toName name="${object.name?cap_first}"/>
</#assign>

<#if properties.javaPackage?has_content>package ${properties.javaPackage};</#if>

import com.ssaglobal.bdeimpl.java.BdeManager;
import com.ssaglobal.bdeimpl.java.BusinessDataEntity;
import com.ssaglobal.bdeimpl.java.BdeIterator;
import com.ssaglobal.bde.BdeException;
import com.ssaglobal.bde.IPublishControl;
import com.ssaglobal.bde.Date;
import com.ssaglobal.bde.DateTime;
import com.ssaglobal.bde.Time;
import java.math.BigDecimal;
import java.math.BigInteger;


/**
 * Generated typesafe BDE Proxy Manager for the BDE ${object.name?cap_first}.
 * <br>This ${object.name?cap_first}Manager extends com.ssaglobal.bdeimpl.java.BdeManager.<br>
 * BID Name: ${object.name?cap_first}<br>
<#if object.versionID?has_content>${'\n'} * BID Version: ${object.versionID}<br></#if><#if object.schemaVersion?has_content>${'\n'} * Schema Version: ${object.schemaVersion}<br></#if><#if object.description?has_content>${'\n'} * BID Description: ${object.description}<br></#if> */
public class ${bdeName?cap_first}Manager extends BdeManager
{
	/**
	 * Create a new ${bdeName}Manager for accessing ${bdeName} BDE components on the backend.
	 */
	public ${bdeName}Manager() throws BdeException
	{
		super();
	}

<#list object.method as method>
	<#switch method.name>
  	<#case "Show">
	/**
	 * Try to retreive a ${bdeName} from the backend based in passed Identifying attributes, and Selection set in this ${bdeName}Manager.
	 * <br>A ${bdeName} proxy is returned.
	 * The parameters are identifying information which is used as input for the Show method.	 	 
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this List. This exception contains detailed information about the error on the server. <br>
	 */
	public ${bdeName} Show(${common.primkeys_types_and_names(object)}) throws BdeException
	{
		return (${bdeName}) super.show(new ${bdeName}(${common.primkeys_names(object)}));
	}

	<#break>
	<#case "List">
	/**
	 * Try to retreive a number of ${bdeName} from the backend using Selection and Filter set in this ${bdeName}Manager.
	 * <br>A ${bdeName}Iterator is returned, which can be used to iterate trough the retreived components.
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this List. This exception contains detailed information about the error on the server. <br>
	 */
	public ${bdeName}Iterator List() throws BdeException 	
	{
		return (${bdeName}Iterator) super.list(-1);	
	}
	/**
	 * Try to retreive a number of ${bdeName} from the backend using Selection and Filter set in this ${bdeName}Manager.
	 * <br>A ${bdeName}Iterator is returned, which can be used to iterate trough the retreived components.
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @param maxNrOfObjects Limits the number of returned components.
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this List. This exception contains detailed information about the error on the server. <br>
	 */
	public ${bdeName}Iterator List(int maxNrOfObjects) throws BdeException 	
	{
		return (${bdeName}Iterator) super.list(maxNrOfObjects);
	}
	
	<#break>
	<#case "Create">
	/**
	 * Try to Create a new ${bdeName} in the backend with all data currently present in the ${bdeName} proxy.
	 * <br>If the Create succeeds then the ${bdeName} proxy is filled with new data from the backend.<br>
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @param p_bde the ${bdeName} component which is used as input and output for the Create method.
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this Create. This exception contains detailed information about the error on the server. <br>
	 */
	public void Create(${bdeName} p_bde) throws BdeException
	{
		super.create(p_bde);
	}

	<#break>
	<#case "Change">
	/**
	 * Try to Change a ${bdeName} in the backend with data currently present in the passed ${bdeName} proxy.
	 * <br>If the Change succeeds then the ${bdeName} proxy is filled with new data from the backend.<br>
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @param p_bde the ${bdeName} component which is used as input and output for the Change method.	 
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this Create. This exception contains detailed information about the error on the server. <br>
	 */	
	public void Change(${bdeName} p_bde) throws BdeException
	{
		super.change(p_bde);
	}
	
	<#break>
	<#case "Delete">
	/**
	 * Try to Delete a ${bdeName} in the backend with identifying information present in the passed ${bdeName} proxy.
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @param p_bde the ${bdeName} component which is used as input for the Delete method.	 
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this Create. This exception contains detailed information about the error on the server. <br>
	 */	
	public void Delete(${bdeName} p_bde) throws BdeException
	{
		super.delete(p_bde);
	}

	/**
	 * Try to Delete a ${bdeName} in the backend with identifying information passed.
	 * The parameters are identifying information which is used as input for the Delete method.	 
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this Create. This exception contains detailed information about the error on the server. <br>
	 */	
	public void Delete(${common.primkeys_types_and_names(object)}) throws BdeException
	{
		super.delete(new ${bdeName}(${common.primkeys_names(object)}));
	}
	
	<#break>
	<#case "SubscribeEvent">	
	/**
	 * With the SubscribeEvent method a request can be issued for publishing all changes of a BDE each time a change occurs. 
	 * As Argument this method has a IPublishControl object which holds all publishing controlling data.<br>
	 * The IPublishControl object can be created using the BdeToolkit with an 'eventConsumer' argument.<br>
	 * Other optional 'PublishChanges' IPublishControl attributes are 'destination'.<br>
	 * The SubscribeEvent method uses the Selection and Filter currently set in this Manager.
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @param publishControl the IPublishControl for this publishing control method.	 
	 */
	public void ${method.name}(IPublishControl publishControl) throws BdeException
	{
		super.specific((BusinessDataEntity) publishControl, "${method.name}");
	}
	
	<#break>
	<#case "UnSubscribeEvent">	
	/**
	 * With the UnSubscribeEvent an application server can be notified that publishing of the changes in the instances of a specific BDE is not required anymore and should be stopped. 
	 * As Argument this method has a IPublishControl object which holds all publishing controlling data.<br>
	 * The IPublishControl object can be created using the BdeToolkit with an 'eventConsumer' argument.<br>
	 * There are no other optional IPublishControl attributes necceserry for UnpublishChanges.
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @param publishControl the IPublishControl for this publishing control method.	 
	 */
	public void ${method.name}(IPublishControl publishControl) throws BdeException
	{
		super.specific((BusinessDataEntity) publishControl, "${method.name}");
	}

	<#break>
	<#case "SubscribeList">	
	/**
	 * With the SubscribeList method a request can be issued for a full list of a BDE being published only once, to a specific consumer.
	 * The SubscribeList returns the same data as an asynchronous ListRequest, with the exception that the data is send using events.
	 * As Argument this method has a IPublishControl object which holds all publishing controlling data.<br>
	 * The IPublishControl object can be created using the BdeToolkit with an 'eventConsumer' argument.<br>
	 * Other optional 'SubscribeList' IPublishControl attributes are 'destination', 'maxNumberOfObjects' and 'eventBatchSize'.<br>
	 * The SubscribeList uses the Selection and Filter currently set in this Manager.
<@GenerateControlAttributesJavadoc oMethod=method />	 
	 * @param publishControl the IPublishControl for this publishing control method.	 
	 */
	public void ${method.name}(IPublishControl publishControl) throws BdeException
	{
		super.specific((BusinessDataEntity) publishControl, "${method.name}");
	}

	<#break><#-- "UnpublishChanges" "PublishList" "PublishChanges" are nog generated, can be used as user methods -->
	<#case "OnEvent"><#-- Ignore in proxy code --><#break>
	<#case "PublishEvent"><#-- Ignore in proxy code --><#break>
	<#default>
	/**
	 * Specific method ${method.name} for BDE ${bdeName}
<@GenerateControlAttributesJavadoc oMethod=method />
	 * @throws BdeException If anything goes wrong, superclass of BdeResultException and BdeCommunicationException.<br>
	 * @throws BdeCommunicationException If anything goes wrong on the transport level.	 <br>
	 * @throws BdeResultException If an error occurs on the backend during this method call. This exception contains detailed information about the error on the server. <br>
	 */
	public void ${method.name}(${bdeName} p_bde) throws BdeException
	{
		super.specific(p_bde, "${method.name}");
	}
	
	</#switch>  
</#list>
<#assign cAttributeIndex=0>
<#list object.method as method>
	<#list method.methodArgument as methodArgument>
		<#if methodArgument.type == "controllingAttribute">
			<#assign dataType = common.getjavadt(methodArgument.datatype.idref.primitiveDatatype)>		  			
			
	/**
	 * has method for Specific Controlling Attribute '${methodArgument.name}' of method ${method.name}.
	 * <#if methodArgument.isMandatory>This Controlling attribute is mandatory !<#else>This Controlling attribute is optional.</#if>	 
	 */
	public boolean has${method.name}${methodArgument.name?cap_first}()
	{
		return super.hasSpecificControlAttribute(${cAttributeIndex});
	}
			
	/**
	 * unset method for Specific Controlling Attribute '${methodArgument.name}' of method ${method.name}.
	 * <#if methodArgument.isMandatory>This Controlling attribute is mandatory !<#else>This Controlling attribute is optional.</#if>	 
	 */
	public void unset${method.name}${methodArgument.name?cap_first}()
	{
		super.unsetSpecificControlAttribute(${cAttributeIndex});
	}
	
	<#if methodArgument.scope=="in" || methodArgument.scope=="inout">
	/**
	 * Set method for Specific Controlling Attribute '${methodArgument.name}' of method ${method.name}.
	 * <#if methodArgument.isMandatory>This Controlling attribute is mandatory !<#else>This Controlling attribute is optional.</#if>
	 * @param ${methodArgument.name}Value the ${dataType} to set.
	 * @throws BdeException If anything goes wrong setting the attribute<br>
	 */
	public void set${method.name}${methodArgument.name?cap_first}(${dataType} ${methodArgument.name}Value)  throws BdeException
	{
		super.set${dataType?cap_first}SpecificControlAttribute(${cAttributeIndex}, ${methodArgument.name}Value);
	}

	</#if>
	<#if methodArgument.scope=="out" || methodArgument.scope=="inout">
	/**
	 * Get method for Specific Controlling Attribute '${methodArgument.name}' of method ${method.name}.
	 * <#if methodArgument.isMandatory>This Controlling attribute is mandatory !<#else>This Controlling attribute is optional.</#if>
	 * @return ${dataType} value.
	 * @throws BdeException If anything goes wrong getting the attribute, f.e value is not set<br>
	 */
	public ${dataType} get${method.name}${methodArgument.name?cap_first}()  throws BdeException
	{
		return super.get${dataType?cap_first}SpecificControlAttribute(${cAttributeIndex});
	}
	
	</#if>
			<#assign cAttributeIndex=cAttributeIndex+1>
		</#if>
	</#list>
</#list>


	protected BusinessDataEntity _createBde()
	{
		return new ${bdeName}();
	}

	protected BdeIterator _createIterator()
	{
		return new ${bdeName}Iterator();
	}
	
	protected String _getBdeName()
	{
		return "${bdeName}<#list object.method as method><#list method.methodArgument as methodArgument><#if methodArgument.type == "controllingAttribute">:;:${method.name};${methodArgument.name};${methodArgument.scope};<#if methodArgument.isMandatory>true<#else>false</#if></#if></#list></#list>";
	}	
	
	private static String _primaryKeys = null;
	
	protected String _getPrimaryKeys()
	{
		if (_primaryKeys == null)
			_primaryKeys = ${bdeName}._getPrimaryKeys("");
		return _primaryKeys;
	}
}
<#macro GenerateControlAttributesJavadoc oMethod>
	<#list oMethod.methodArgument as methodArgument>
		<#if methodArgument.type == "controllingAttribute">
	 * Has <#if methodArgument.isMandatory>mandatory<#else>optional</#if> Controlling Attribute ${methodArgument.name} which has scope ${methodArgument.scope}.
	 	</#if>
	 </#list>
</#macro>
