package tpm;

import com.bea.control.ServiceBrokerControl;
import com.bea.jpd.JpdContext;
import com.bea.wli.jpd.CallbackInterface;
import org.apache.beehive.controls.api.events.EventHandler;
import org.apache.xmlbeans.XmlObject;
import weblogic.wsee.jws.wlw.schemas.soap11.EnvelopeDocument;

@com.bea.wli.jpd.Process(process = "<process name=\"BuyerAlert\"> " +
                                   "  <clientRequest name=\"Client Request\" method=\"clientRequest\"/> " +
                                   "  <controlSend name=\"setProperties\" method=\"sellerControlSetProperties\"/> " +
                                   "  <controlSend name=\"request\" method=\"sellerControlRequest\"/> " +
                                   "  <controlReceive name=\"onAck\" method=\"sellerControl_onAck\"> " +
                                   "    <onTimeout name=\"OnTimeout\" duration=\"10 s\"/> " +
                                   "  </controlReceive> " +
                                   "  <controlSend name=\"getBasicProperties\" method=\"tpmGetBasicProperties\"/> " +
                                   "  <controlSend name=\"sendEmail\" method=\"alertSendEmail\"/> " +
                                   "</process>")
public class BuyerAlert implements com.bea.jpd.ProcessDefinition
{
    public com.bea.x2003.x03.wli.tpm.TradingPartnerDocument basicPartnerInfo;

    public EnvelopeDocument env;

    public java.lang.String partnerId;

    public XmlObject payload;

    static final long serialVersionUID = 1L;

    @com.bea.wli.jpd.Callback()
    public Callback callback;

    /*
     * The area above this comment contains Variable Declarations created from the Design View.
     * The area below this comment contains Control Declarations created from the Design View.
     *
     * Code in these areas is generated automatically.
     *
     * 2-Way editing is fully supported in these areas of code.
     * Warning: changing Process Variables and Control Declarations already in use by your application
     * may generate errors in your application if you do not update these declarations
     * in all locations where they are used.
     */

    /**
     * @common:control
     */
    @Control()
    private tpm.SellerControl sellerControl;

    /**
     * @common:control
     */
    @Control()
    private com.bea.control.TPMControl tpm;

    /**
     * @common:control
     */
    @Control()
    private tpm.Alert alert;

    /**
     * This is a control instance, which will be instantiated automatically at
     * runtime.
     * @jpd:transform
     */
    @com.bea.wli.jpd.Transform()
    private tpm.BuyerAlertTransformation transformations;

    /**
     * @common:context
     */
    @com.bea.wli.jpd.Context()
    JpdContext context; //(..control insertion marker - do not modify this line)

    /*
     * The area below this comment contains java methods referenced by communication nodes in the Process Language.
     *
     * Code in this area is generated automatically.
     *
     * 2-Way editing is partially supported in this area of code.
     * Warning: you can safely add code inside a method body but it must be outside of any PROTECTED SECTION
     * block comments. Modifications to code within these comments will prevent you from viewing information
     * in the Design View builder that generated this code.
     */

    public void clientRequest(XmlObject x0, java.lang.String x1)
    {
        //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
        // input transform
        // parameter assignment
        this.payload = x0;
        this.partnerId = x1;
        //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
    }



    public void sellerControlRequest() throws Exception
    {
        //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
        // input transform
        // method call
        sellerControl.request(this.payload);
        // output transform
        // output assignments
        //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
    }

    @EventHandler(field = "sellerControl",
                  eventSet = SellerControl.Callback.class,
                  eventName = "onAck")
    public void sellerControl_onAck(EnvelopeDocument arg0)
    {
        //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
        // input transform
        // parameter assignment
        //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
    }



    public void tpmGetBasicProperties() throws Exception
    {
        //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
        // input transform
        // return method call
        this.basicPartnerInfo = tpm.getBasicProperties(this.partnerId);
        // output transform
        // output assignments
        //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
    }

    public void alertSendEmail() throws Exception
    {
        //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
        // input transform
        tpm.BuyerAlertTransformation.alertSendEmailObject obj = transformations.alertSendEmail(this.basicPartnerInfo);
        // method call
        alert.sendEmail(obj.to, obj.cc, obj.bcc, obj.subject, obj.body, obj.attachments);
        // output transform
        // output assignments
        //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
    }

    public void sellerControlSetProperties() throws Exception
    {
        //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
        // input transform
        com.bea.wli.control.dynamicProperties.EBXMLControlPropertiesDocument obj = transformations.sellerControlSetProperties(this.partnerId);
        // method call
        sellerControl.setProperties(obj);
        // output transform
        // output assignments
        //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
    }

	@CallbackInterface()
    public interface Callback extends ServiceBrokerControl //(..region end marker - do not modify this line)
    {
    }

    /*
     * Code inserted below this comment is for methods corresponding to Perform or Condition nodes
     * created in the Design View.
     *
     * Feel free to make modifications or add new code here.
     */

}
