
package processing;

import java.lang.reflect.Field;
import org.apache.beehive.controls.api.ControlException;
import org.apache.beehive.controls.api.bean.Controls;
import org.apache.beehive.controls.api.versioning.VersionRequired;
import org.apache.beehive.controls.api.context.ControlBeanContext;
import org.apache.beehive.controls.runtime.bean.EventAdaptor;
import org.apache.beehive.controls.runtime.bean.AdaptorPersistenceDelegate;

@SuppressWarnings("all")
public class ProcessExternalApplicationClientInitializer
extends org.apache.beehive.controls.runtime.bean.ClientInitializer
{
    static final Field _appTaskControlIIField;
    static
    {
        try
        {
            _appTaskControlIIField = processing.ProcessExternalApplication.class.getDeclaredField("appTaskControlII");
            _appTaskControlIIField.setAccessible(true);
        }
        catch (NoSuchFieldException __bc_nsfe)
        {
            throw new ExceptionInInitializerError(__bc_nsfe);
        }
    }
    
    public static class AppTaskControlIICustomCallbackEventAdaptor 
    implements controls.AppTaskControlII.CustomCallback, 
    EventAdaptor, java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
        
        processing.ProcessExternalApplication __bc_client;
        
        public AppTaskControlIICustomCallbackEventAdaptor(processing.ProcessExternalApplication client) { __bc_client = client; }
        
        public Object getClient() { return __bc_client; }
        
        public void onApplicationApprovedStep(controls.AppTaskControlII.ApplicationApproved step) 
        {
            __bc_client.appTaskControlII_onApplicationApprovedStep(step);
        }
        public void onApprovalPendingStep(controls.AppTaskControlII.ApprovalPending step) 
        {
        }
        public void onApplicationRejectedStep(controls.AppTaskControlII.ApplicationRejected step) 
        {
            __bc_client.appTaskControlII_onApplicationRejectedStep(step);
        }
    }
    
    
    private static void initializeFields(ControlBeanContext cbc,
    processing.ProcessExternalApplication client)
    {
        try
        {
            String __bc_id;
            //
            // Initialize any nested controls used by the client
            //
            __bc_id = "appTaskControlII";
            controls.AppTaskControlIIBean _appTaskControlII = (cbc == null ? null : (controls.AppTaskControlIIBean)cbc.getBean(__bc_id));
            if (_appTaskControlII == null)
            _appTaskControlII = (controls.AppTaskControlIIBean) Controls.instantiate(controls.AppTaskControlIIBean.class, getAnnotationMap(cbc, _appTaskControlIIField), cbc, __bc_id );
            _appTaskControlII.addCustomCallbackListener(new AppTaskControlIICustomCallbackEventAdaptor(client));
            
            
            _appTaskControlIIField.set(client, _appTaskControlII);
        }
        catch (RuntimeException __bc_re) { throw __bc_re; }
        catch (Exception __bc_e)
        {
            __bc_e.printStackTrace();
            throw new ControlException("Initializer failure", __bc_e);
        }
    }
    
    public static void initialize(ControlBeanContext cbc, processing.ProcessExternalApplication client)
    {
        
        initializeFields( cbc, client );
    }
}
