home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / mqaoad21.zip / MQAOAdapterTester.java < prev    next >
Text File  |  2002-12-19  |  27KB  |  702 lines

  1. package com.ibm.extricity.adapters.mqseries.mqak;
  2.  
  3. /**
  4.  * Insert the type's description here.
  5.  * Creation date: (11/29/00 1:19:25 PM)
  6.  * @author: Administrator
  7.  */
  8. import java.io.*;
  9. import java.util.*;
  10.  
  11. import com.ibm.epic.adapters.eak.mcs.*;
  12.  
  13. public class MQAOAdapterTester implements Runnable
  14. {
  15.    protected static boolean _DEBUG = true;
  16.    protected static boolean TRACE = true;
  17.    protected static final String BFT_PFX = "BFT:";
  18.    protected static final String FAST_PFX = "FAST:";
  19.    protected static String MYCR = "\n";
  20.  
  21.    protected static final String PropFileName = new String("MQAOAdapterTester.properties");
  22.  
  23.    protected static PrintWriter logFile = null;
  24.  
  25.    private String gatewayComp = "GATEWAY";
  26.    private String appComp = "BFM";
  27.    private String protAndVer = "UNKNOWN";
  28.    private String msgBodyCategory = "DEFAULT";
  29.    private int NumTPs;
  30.    private Vector TPIds = new Vector();
  31.    private Hashtable traceLog = new Hashtable();
  32.    private Hashtable notifyLog = new Hashtable();
  33.  
  34.    private boolean xmlDumps = true;
  35.    private boolean fullDumps = true;
  36.  
  37.    private int poStartInstance = 0;
  38.    private int poMaxNum = -1;
  39.  
  40.    private ValWithRnd poGen = new ValWithRnd(240,true);
  41.    private ValWithRnd poCluster = new ValWithRnd(1);
  42.    private ValWithRnd poDropReflect1st = new ValWithRnd(0);
  43.    private ValWithRnd poDropReflectAll = new ValWithRnd(0);
  44.    private ValWithRnd poAckDropReflect1st = new ValWithRnd(0);
  45.    private ValWithRnd poAckDropReflectAll = new ValWithRnd(0);
  46.    private ValWithRnd poAccDropReflect1st = new ValWithRnd(0);
  47.    private ValWithRnd poAccDropReflectAll = new ValWithRnd(0);
  48.    private ValWithRnd otherAckDropReflect1st = new ValWithRnd(0);
  49.    private ValWithRnd oOtherAckDropReflectAll = new ValWithRnd(0);
  50.    private ValWithRnd poRejectRate = new ValWithRnd(0);
  51.  
  52. /**
  53.  * MQAOAdapterTester constructor comment.
  54.  */
  55. public MQAOAdapterTester()
  56. {
  57.    super();
  58. }
  59.  
  60. /**
  61.  * Insert the method's description here.
  62.  * Creation date: (6/1/00 3:18:23 PM)
  63.  */
  64. public LogData addTrace(String corId,String msgData)
  65. {
  66.    return addTrace(corId,msgData,null,LogData.STATE_NOCHANGE);
  67. }
  68.  
  69. /**
  70.  * Insert the method's description here.
  71.  * Creation date: (6/1/00 3:18:23 PM)
  72.  */
  73. public LogData addTrace(String corId,String msgData,int newState)
  74. {
  75.    return addTrace(corId,msgData,null,newState);
  76. }
  77.  
  78. /**
  79.  * Insert the method's description here.
  80.  * Creation date: (6/1/00 3:18:23 PM)
  81.  */
  82. public LogData addTrace(String corId,String msgData,String realCorId)
  83. {
  84.    return addTrace(corId,msgData,realCorId,LogData.STATE_NOCHANGE);
  85. }
  86.  
  87. /**
  88.  * Insert the method's description here.
  89.  * Creation date: (6/1/00 3:18:23 PM)
  90.  */
  91. public LogData addTrace(String corId,String msgData,String realCorId,int newState)
  92. {
  93.    LogData logDt;
  94.    LogData traceDt;
  95.  
  96.    msgData = (new Date()).toString() + ":" + msgData;
  97.  
  98.    // Check for null
  99.    if(corId == null)
  100.    {
  101.       // Cannot corelate to anything!
  102.       if(TRACE)
  103.       {
  104.          outputTraceMsg("XXXX(-null-) -- Invalid corilation ID" + MYCR + msgData + MYCR + "XXXX");
  105.       }
  106.       traceDt = null;
  107.    }
  108.    else if(corId.compareTo("BFP1") == 0)
  109.    {
  110.       // Invalid default Corilation ID
  111.       if(TRACE)
  112.       {
  113.          outputTraceMsg("XXXX(BFP1) -- Invalid default corilation ID" + MYCR + msgData + MYCR + "XXXX");
  114.       }
  115.       traceDt = null;
  116.    }
  117.    // Is it a fast-notify corelation ID?
  118.    else if( (LogData.mySubString(corId,0,FAST_PFX.length()).compareTo(FAST_PFX) == 0) ||
  119.            (LogData.mySubString(corId,0,FAST_PFX.length()+1).compareTo("E"+FAST_PFX) == 0) ||
  120.            (LogData.mySubString(corId,0,FAST_PFX.length()+1).compareTo("W"+FAST_PFX) == 0) )
  121.    {
  122.       if( (LogData.mySubString(corId,0,FAST_PFX.length()+1).compareTo("E"+FAST_PFX) == 0) ||
  123.           (LogData.mySubString(corId,0,FAST_PFX.length()+1).compareTo("W"+FAST_PFX) == 0) )
  124.       {
  125.          corId = corId.substring(1);
  126.       }
  127.       logDt = (LogData)notifyLog.get(corId);
  128.       if(logDt == null)
  129.       {
  130.          // build a new entry
  131.          logDt = new LogData(msgData,LogData.STATE_INIT);
  132.          notifyLog.put(corId,logDt);
  133.       }
  134.       else if(logDt.Data != null)
  135.       {
  136.          logDt.Data = logDt.Data + MYCR + msgData;
  137.       }
  138.       else
  139.       {
  140.          logDt.Data = msgData;
  141.       }
  142.       // Update the state if necesary
  143.       if(newState != LogData.STATE_NOCHANGE)
  144.       {
  145.          logDt.State = newState;
  146.       }
  147.       // Do we have a real ID
  148.       if(realCorId != null)
  149.       {
  150.          logDt.RealKey = realCorId;
  151.       }
  152.       // Do we corelate back to real
  153.       if(logDt.RealKey == null)
  154.       {
  155.          if(TRACE)
  156.          {
  157.             if(fullDumps)
  158.             {
  159.                System.out.println("XXXX(" + corId + ")\n" + logDt.Data + "\nXXXX");
  160.             }
  161.             else
  162.             {
  163.                System.out.println("ADDING(" + corId + ")\n" + msgData);
  164.             }
  165.          }
  166.          return logDt;
  167.       }
  168.       else
  169.       {
  170.          traceDt = (LogData)traceLog.remove(logDt.RealKey);
  171.          if(traceDt == null)
  172.          {
  173.             traceDt = new LogData("",logDt.State);
  174.          }
  175.          else
  176.          {
  177.             traceDt.Data = traceDt.Data + MYCR;
  178.             if(newState != LogData.STATE_NOCHANGE)
  179.             {
  180.                traceDt.State = newState;
  181.             }
  182.          }
  183.          if(logDt.Data != null)
  184.          {
  185.             traceDt.Data = traceDt.Data + logDt.Data;
  186.             logDt.Data = null;
  187.          }
  188.          traceLog.put(logDt.RealKey,traceDt);
  189.          if(TRACE)
  190.          {
  191.             if(fullDumps)
  192.             {
  193.                System.out.println("XXXX(" + logDt.RealKey + "-[" + corId + "])\n" + traceDt.Data + "\nXXXX");
  194.             }
  195.             else
  196.             {
  197.                System.out.println("ADDING(" + logDt.RealKey + "-[" + corId + "])\n" + msgData);
  198.             }
  199.          }
  200.       }
  201.    }
  202.    else if( (LogData.mySubString(corId,0,BFT_PFX.length()).compareTo(BFT_PFX) == 0) ||
  203.            (LogData.mySubString(corId,0,BFT_PFX.length()+1).compareTo("E"+BFT_PFX) == 0) ||
  204.            (LogData.mySubString(corId,0,BFT_PFX.length()+1).compareTo("W"+BFT_PFX) == 0) )
  205.    {
  206.       if( (LogData.mySubString(corId,0,BFT_PFX.length()+1).compareTo("E"+BFT_PFX) == 0) ||
  207.           (LogData.mySubString(corId,0,BFT_PFX.length()+1).compareTo("W"+BFT_PFX) == 0) )
  208.       {
  209.          corId = corId.substring(1);
  210.       }
  211.       traceDt = (LogData)traceLog.remove(corId);
  212.       if(traceDt == null)
  213.       {
  214.          traceDt = new LogData(msgData,LogData.STATE_INIT);
  215.          traceDt.RealKey = null;
  216.       }
  217.       else
  218.       {
  219.          traceDt.Data = traceDt.Data + MYCR + msgData;
  220.       }
  221.       if(newState != LogData.STATE_NOCHANGE)
  222.       {
  223.          traceDt.State = newState;
  224.       }
  225.       traceLog.put(corId,traceDt);
  226.       if(TRACE)
  227.       {
  228.          if(fullDumps)
  229.          {
  230.             System.out.println("XXXX(" + corId + ")\n" + traceDt.Data + "\nXXXX");
  231.          }
  232.          else
  233.          {
  234.             System.out.println("ADDING(" + corId + ")\n" + msgData);
  235.          }
  236.       }
  237.    }
  238.    else
  239.    {
  240.       // Unknown Corilation ID
  241.       if(TRACE)
  242.       {
  243.          outputTraceMsg("XXXX("+corId+") -- Unknown corilation ID" + MYCR + msgData + MYCR + "XXXX");
  244.       }
  245.       traceDt = null;
  246.    }
  247.    return traceDt;
  248. }
  249.  
  250. /**
  251.  * Insert the method's description here.
  252.  * Creation date: (10/23/00 3:07:55 PM)
  253.  * @param args java.lang.String[]
  254.  */
  255. public static void main(String[] args)
  256. {
  257.    MQAOAdapterTester tester = new MQAOAdapterTester();
  258.  
  259.    tester.readProperties();
  260.    /*
  261.    // Create
  262.    //String theXML = "<Pip3A4PurchaseOrderRequest><PurchaseOrder><ProductLineItem><shipFrom><GlobalLocationIdentifier>Home</GlobalLocationIdentifier></shipFrom><ProductQuantity>10</ProductQuantity><LineNumber>001</LineNumber><productUnit><ProductPackageDescription><ProductDescription><GlobalProductIdentifier>Junk</GlobalProductIdentifier></ProductDescription></ProductPackageDescription></productUnit><requestedShipDate><DateStamp>11/30/2000</DateStamp></requestedShipDate><GlobalProductUnitOfMeasureCode>Piece</GlobalProductUnitOfMeasureCode><SpecialHandlingInstruction><SpecialHandlingText><FreeFormText>None</FreeFormText></SpecialHandlingText></SpecialHandlingInstruction><requestedPrice><FinancialAmount><GlobalCurrencyCode>USD</GlobalCurrencyCode><MonetaryAmount>1000.00</MonetaryAmount></FinancialAmount></requestedPrice></ProductLineItem><GlobalShipmentTermsCode>FOB</GlobalShipmentTermsCode><RevisionNumber>0</RevisionNumber><GlobalFinanceTermsCode>NET30</GlobalFinanceTermsCode><PartnerDescription><GlobalPartnerClassificationCode>Provider</GlobalPartnerClassificationCode></PartnerDescription><GlobalPurchaseOrderTypeCode>RN</GlobalPurchaseOrderTypeCode></PurchaseOrder><fromRole><PartnerRoleDescription><GlobalPartnerRoleClassificationCode>Buyer</GlobalPartnerRoleClassificationCode></PartnerRoleDescription></fromRole><toRole><PartnerRoleDescription><GlobalPartnerRoleClassificationCode>Seler</GlobalPartnerRoleClassificationCode></PartnerRoleDescription></toRole><thisDocumentGenerationDateTime><DateTimeStamp>11/2/2000 09:17:00</DateTimeStamp></thisDocumentGenerationDateTime><thisDocumentIdentifier><ProprietaryDocumentIdentifier>PO98798</ProprietaryDocumentIdentifier></thisDocumentIdentifier><GlobalDocumentFunctionCode>PO</GlobalDocumentFunctionCode></Pip3A4PurchaseOrderRequest>";
  263.    // Accept
  264.    String theXML = "<Pip3A4PurchaseOrderAcceptance><PurchaseOrder><GlobalPurchaseOrderStatusCode>Accept</GlobalPurchaseOrderStatusCode><GlobalShipmentTermsCode>FOB</GlobalShipmentTermsCode><RevisionNumber>0</RevisionNumber><purchaseOrderDate><DateStamp>11/30/2000</DateStamp></purchaseOrderDate><purchaseOrderNumber><ProprietaryDocumentIdentifier>PO98798</ProprietaryDocumentIdentifier></purchaseOrderNumber></PurchaseOrder><fromRole><PartnerRoleDescription><GlobalPartnerRoleClassificationCode>Seler</GlobalPartnerRoleClassificationCode><PartnerDescription><GlobalPartnerClassificationCode>Seler</GlobalPartnerClassificationCode><BusinessDescription><GlobalBusinessIdentifier>Manufacturer</GlobalBusinessIdentifier><GlobalSupplyChainCode>Manufacturer</GlobalSupplyChainCode></BusinessDescription></PartnerDescription></PartnerRoleDescription></fromRole><toRole><PartnerRoleDescription><GlobalPartnerRoleClassificationCode>Buyer</GlobalPartnerRoleClassificationCode><PartnerDescription><GlobalPartnerClassificationCode>Buyer</GlobalPartnerClassificationCode><BusinessDescription><GlobalBusinessIdentifier>Shopper</GlobalBusinessIdentifier><GlobalSupplyChainCode>Shopper</GlobalSupplyChainCode></BusinessDescription></PartnerDescription></PartnerRoleDescription></toRole><thisDocumentGenerationDateTime><DateTimeStamp>11/2/2000 09:17:00</DateTimeStamp></thisDocumentGenerationDateTime><thisDocumentIdentifier><ProprietaryDocumentIdentifier>PO98798</ProprietaryDocumentIdentifier></thisDocumentIdentifier><requestingDocumentIdentifier><ProprietaryDocumentIdentifier>PO98798</ProprietaryDocumentIdentifier></requestingDocumentIdentifier><GlobalDocumentFunctionCode>PO</GlobalDocumentFunctionCode><requestingDocumentDateTime><DateTimeStamp>11/2/2000 09:17:00</DateTimeStamp></requestingDocumentDateTime></Pip3A4PurchaseOrderAcceptance>";
  265.    String theCorID = new String("4.ijcxbwsq");//(new Date()).toString();
  266.    //String theCorID = new String("16.ij12cmjo");//(new Date()).toString();
  267.    //String theCorID = new String("14.ij12cmjo");//(new Date()).toString();
  268.    String theMsgID = null;
  269.    String pID = "4.iiclkt4n.im4d42.000000e2970e17104.ihxblcrg.im4d42..DICAM.847409406.ORG-3A4-1_1-Create Purchase Order.1.0.1";
  270.  
  271.    _DEBUG = true;
  272.  
  273.    try
  274.    {
  275.       ProcessDataInt pd = new ProcessData(theCorID,"847409406");
  276.  
  277.       if((new Random((new Date()).getTime())).nextFloat() < 0.0)
  278.       {
  279.          theCorID = EpicMessageExt.NO_EXTRICITYPROCESSID;
  280.       }
  281.       ad.startup("BFM","GATEWAY","RosettaNet-1_1","DEFAULT",true,true);
  282.       msghdr.setData("SrcTradingPartnerID","847409406");
  283.       msghdr.setData("DstTradingPartnerID","103");
  284.       msghdr.setData("BOCorrelationID",theCorID);
  285.       msghdr.setData("ProcessTransactionID","3A4-1_1-CreatePurchaseOrder");
  286.       System.out.println("SEND msghdr: " + msghdr.toString());
  287.       System.out.println("   XML: " + theXML);
  288.       comCtx = ad.executeSendMsg(theCorID,msghdr,theXML,opstat,"TestUniqueID");
  289.       //comCtx = ad.executeSendMsg(theCorID,msghdr,theXML,opstat,"TestUniqueID");
  290.       ad.executeCommit(theCorID,comCtx,opstat);
  291.  
  292.       //ad.poolENA.clear();
  293.       ad.startup("GATEWAY","BFM","RosettaNet-1_1","DEFAULT",true,true);
  294.       if(theCorID.compareTo(EpicMessageExt.NO_EXTRICITYPROCESSID) == 0)
  295.       {
  296.          do
  297.          {
  298.             //theXML = ad.executeRecvMsg(theCorID,theMsgID,null,msghdr,comctx,opstat);
  299.             ad.checkForEvents(ec);
  300.             theMsgID = ec.getVariantEvent();
  301.          } while(theMsgID == null);
  302.          System.out.println("\n\n======================\nEVENT msgid: " + theMsgID + "\n================\n");
  303.       }
  304.       //theCorID = "Wed Oct 25 10:41:51 EDT ";
  305.       msghdr.clearAll();
  306.       ProcessDataInt pdXML = ad.executeRecvMsg(pID,theMsgID,false,null,msghdr,opstat);
  307.       System.out.println("RECEIVE msghdr: " + msghdr.toString());
  308.       System.out.println("   XML: " + pdXML.getMsgXML());
  309.       ad.executeCommit(pID,pdXML.getCommitContext(),opstat);
  310.       theCorID = msghdr.getData("BOCorrelationID");
  311.  
  312.       //ProcessData pd = new ProcessData(pID,"847409406");
  313.       ad.executeSetProcessData(theCorID,pd);
  314.       pd = ad.executeGetProcessData(theCorID);
  315.       System.out.println("PROCESSDATA: " + pd.toString());
  316.       ad.executeDelProcessData(theCorID);
  317.    }
  318.    catch(ISException e)
  319.    {
  320.       System.out.println("executeRecvMsg->ISException: " + e.toString());
  321.    }*/
  322. }
  323.  
  324. /**
  325.  * Insert the method's description here.
  326.  * Creation date: (6/6/00 9:48:23 AM)
  327.  * @param corId java.lang.String
  328.  * @param realCorId java.lang.String
  329.  */
  330. public void outputTrace(String corId, String realCorId)
  331. {
  332.    LogData logDt;
  333.  
  334.    // Is it a fast-notify corelation ID?
  335.    if(corId.substring(0,FAST_PFX.length()).compareTo(FAST_PFX) == 0)
  336.    {
  337.       if(realCorId == null)
  338.       {
  339.          logDt = (LogData)notifyLog.get(corId);
  340.          if(logDt != null)
  341.          {
  342.             // Do we have a real ID
  343.             corId = logDt.RealKey;
  344.          }
  345.          else
  346.          {
  347.             corId = null;
  348.          }
  349.       }
  350.       else
  351.       {
  352.          corId = realCorId;
  353.       }
  354.    }
  355.    if(corId != null)
  356.    {
  357.       logDt = (LogData)traceLog.get(corId);
  358.       if(logDt != null)
  359.       {
  360.          outputTraceMsg("XXX:"+corId+MYCR+logDt.Data+MYCR+"XXX");
  361.       }
  362.    }
  363.    System.out.println("@@@---Processing complete for:"+corId);
  364. }
  365.  
  366. /**
  367.  * Insert the method's description here.
  368.  * Creation date: (6/6/00 5:12:43 PM)
  369.  * @param msg java.lang.String
  370.  */
  371. public void outputTraceMsg(String msg)
  372. {
  373.    if(logFile == null)
  374.    {
  375.       try
  376.       {
  377.          logFile = new PrintWriter(new FileOutputStream("GatewayTester.log",true));
  378.       }
  379.       catch(Exception e)
  380.       {
  381.          e.printStackTrace();
  382.       }
  383.    }
  384.    try
  385.    {
  386.       if(TRACE)
  387.       {
  388.          System.out.println(msg);
  389.       }
  390.       logFile.flush();
  391.    }
  392.    catch(Exception e)
  393.    {
  394.       e.printStackTrace();
  395.    }
  396.    logFile.println(msg);
  397. }
  398.  
  399. /**
  400.  * Insert the method's description here.
  401.  * Creation date: (11/30/00 10:31:28 AM)
  402.  */
  403. public void readProperties()
  404. {
  405.    InputStream propin = null;
  406.    Properties prop = null;
  407.    String partnerDUNS;
  408.    String tmp;
  409.    int ix;
  410.  
  411.    try
  412.    {
  413.       try
  414.       {
  415.          propin = new FileInputStream(PropFileName);
  416.       }
  417.       catch(FileNotFoundException e1)
  418.       {
  419.          try
  420.          {
  421.             propin = new FileInputStream("properties/"+PropFileName);
  422.          }
  423.          catch(FileNotFoundException e2)
  424.          {
  425.             try
  426.             {
  427.                propin = new FileInputStream("d:/ePIC/ExtricityMQAOAdapter/"+PropFileName);
  428.             }
  429.             catch(FileNotFoundException e)
  430.             {
  431.                System.out.println("!!!Properties file not found-- Using builtin defaults!!!");
  432.                outputTraceMsg("!!!Properties file not found-- Using builtin defaults!!!");
  433.                e.printStackTrace();
  434.             }
  435.          }
  436.       }
  437.       if(propin != null)
  438.       {
  439.          prop = new Properties();
  440.          prop.load(propin);
  441.          appComp = prop.getProperty("BFMName","BFM");
  442.          gatewayComp = prop.getProperty("GatewayName","GATEWAY");
  443.          protAndVer = prop.getProperty("ProtocolAndVersion","RosettaNet_RNIF1.1");
  444.          msgBodyCategory = prop.getProperty("BodyCategory","DEFAULT");
  445.  
  446.          //# Business partner definitions
  447.          NumTPs = 0;
  448.          while( (partnerDUNS = prop.getProperty("BusinessPartnerId_" + NumTPs,null)) != null )
  449.          {
  450.             //tp.spawnListner(listenUrl,partnerDUNS,srvUrl);
  451.             TPIds.addElement(partnerDUNS);
  452.             NumTPs += 1;
  453.          };
  454.          //# Logging control definitions
  455.          fullDumps = (new Boolean(prop.getProperty("FullDumps","true"))).booleanValue();
  456.          xmlDumps = (new Boolean(prop.getProperty("XMLDumps","true"))).booleanValue();
  457.          //# Stress definitions (Fixed: #, Random: R#)
  458.          poStartInstance = (new Integer(prop.getProperty("POStartInstance","0"))).intValue();
  459.          poMaxNum = (new Integer(prop.getProperty("POMaxNum","-1"))).intValue();
  460.          poGen = new ValWithRnd(prop.getProperty("POGenRate","R240"));
  461.          poCluster = new ValWithRnd(prop.getProperty("POClusterSize","1"),1);
  462.          poDropReflect1st = new ValWithRnd(prop.getProperty("PODropReflect1st","0"));
  463.          poDropReflectAll = new ValWithRnd(prop.getProperty("PODropReflectAll","0"));
  464.          poAckDropReflect1st = new ValWithRnd(prop.getProperty("POAckDropReflect1st","0"));
  465.          poAckDropReflectAll = new ValWithRnd(prop.getProperty("POAckDropReflectAll","0"));
  466.          poAccDropReflect1st = new ValWithRnd(prop.getProperty("POAccDropReflect1st","0"));
  467.          poAccDropReflectAll = new ValWithRnd(prop.getProperty("POAccDropReflectAll","0"));
  468.          otherAckDropReflect1st = new ValWithRnd(prop.getProperty("OtherAckDropReflect1st","0"));
  469.          oOtherAckDropReflectAll = new ValWithRnd(prop.getProperty("OtherAckDropReflectAll","0"));
  470.          poRejectRate = new ValWithRnd(prop.getProperty("PORejectRate","0"));
  471.       }
  472.    }
  473.    catch(Exception e)
  474.    {
  475.       e.printStackTrace();
  476.    }
  477. }
  478.  
  479. /**
  480.  * Insert the method's description here.
  481.  * Creation date: (5/23/00 4:45:32 PM)
  482.  */
  483. public void run()
  484. {
  485.    int insId;
  486.    int clSize = 1;
  487.    int newState;
  488.    long sval;
  489.  
  490.    outputTraceMsg((new Date()).toString() + ":=============== PO generation started! ===============");
  491.    insId = poStartInstance;
  492.    while( (insId < poMaxNum) || (poMaxNum < 0) )
  493.    {
  494.       clSize = poCluster.getVal();
  495.       while( (clSize > 0) && ((insId < poMaxNum) || (poMaxNum < 0)) )
  496.       {
  497.          newState = LogData.STATE_NOCHANGE;
  498.          if(poDropReflect1st.getOutOf100())
  499.          {
  500.             newState = LogData.STATE_POLOOSE1ST;
  501.          }
  502.          else if(poDropReflectAll.getOutOf100())
  503.          {
  504.             newState = LogData.STATE_POLOOSEALL;
  505.          }
  506.          addTrace(BFT_PFX+insId,"@@@>>>Generating:BFT:"+insId,newState);
  507.          sendPORequest(BFT_PFX + insId,"" + insId,(String)TPIds.elementAt(insId % NumTPs),(String)TPIds.elementAt((insId + 1) % NumTPs));
  508.          insId++;
  509.          clSize--;
  510.       }
  511.       try
  512.       {
  513.          sval = poGen.getVal();
  514.          System.out.println("Sleeping for:"+sval+"sec.");
  515.          Thread.sleep(sval * 1000);
  516.       }
  517.       catch(Exception e)
  518.       {
  519.          e.printStackTrace(System.out);
  520.       }
  521.    };
  522.    outputTraceMsg((new Date()).toString() + ":=============== PO generation complete! ===============");
  523. }
  524.  
  525. /**
  526.  * Insert the method's description here.
  527.  * Creation date: (5/19/00 1:35:21 PM)
  528.  */
  529. public void sendPORequest(String colIx,String instanceId,String ReqId,String DstId)
  530. {
  531.    EpicMessage msgout;
  532.    GatewayCommands cmdout;
  533.    MQAOCSRJ preamblecsr = null;
  534.    MQAOCSRJ srvHeadercsr = null;
  535.    MQAOCSRJ requestcsr = null;
  536.  
  537.    try
  538.    {
  539.       preamblecsr = getXMLCSRJ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
  540.                     "<!DOCTYPE Preamble SYSTEM \"PreamblePartMessageGuideline.dtd\">" +
  541.                 "<Preamble><VersionIdentifier>1.1</VersionIdentifier>" +
  542.                 "<DateTimeStamp>"+"19990531T132000.0500Z"+"</DateTimeStamp>" +
  543.                 "<GlobalAdministeringAuthorityCode>RosettaNet</GlobalAdministeringAuthorityCode>" +
  544.                 "<GlobalUsageCode>Test</GlobalUsageCode></Preamble>");
  545.  
  546.       requestcsr = MQAOXMLIJ.createXMLDocument("Pip3A4PurchaseOrderRequest",
  547.                                 "3A4PurchaseOrderRequestMessageGuideline_v1_1.dtd",
  548.                                 "3A4PurchaseOrderRequestMessageGuideline_v1_1.dtd",
  549.                                 "1.0",
  550.                                 "UTF-8",
  551.                                 null);
  552.       MQAOXMLIJ.addElement(requestcsr,"Pip3A4PurchaseOrderRequest");
  553.  
  554.       srvHeadercsr = MQAOXMLIJ.createXMLDocument("ServiceHeader",
  555.                                   "ServiceHeaderPartMessageGuideline.dtd",
  556.                                   "ServiceHeaderPartMessageGuideline.dtd",
  557.                                   "1.0",
  558.                                   "UTF-8",
  559.                                   null);
  560.       MQAOXMLIJ.addElement(srvHeadercsr,"ServiceHeader");
  561.       MQAOXMLIJ.addElement(srvHeadercsr,"ProcessControl");
  562.       MQAOXMLIJ.addElement(srvHeadercsr,"ProcessIdentity");
  563.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalProcessCode","Manage Purchase Order");
  564.       MQAOXMLIJ.addElementText(srvHeadercsr,"VersionIdentifier","1.1");
  565.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalProcessIndicatorCode","3A4");
  566.       MQAOXMLIJ.addElement(srvHeadercsr,"initiatingPartner");
  567.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalBusinessIdentifier",ReqId);
  568.       srvHeadercsr.up();
  569.       MQAOXMLIJ.addElementText(srvHeadercsr,"InstanceIdentifier",instanceId);
  570.       MQAOXMLIJ.addElement(srvHeadercsr,"description");
  571.       MQAOXMLIJ.addElementText(srvHeadercsr,"FreeFormText",colIx);
  572.       MQAOXMLIJ.getElement(srvHeadercsr,"FreeFormText");
  573.       MQAOXMLIJ.addAttribute(srvHeadercsr,"xml:lang","en");
  574.       srvHeadercsr.up();
  575.       srvHeadercsr.up();
  576.       srvHeadercsr.up();
  577.       MQAOXMLIJ.addElement(srvHeadercsr,"ServiceRoute");
  578.       MQAOXMLIJ.addElement(srvHeadercsr,"fromService");
  579.       MQAOXMLIJ.addElement(srvHeadercsr,"BusinessServiceDescription");
  580.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalBusinessServiceCode","Buyer Service");
  581.       srvHeadercsr.up();
  582.       srvHeadercsr.up();
  583.       MQAOXMLIJ.addElement(srvHeadercsr,"toService");
  584.       MQAOXMLIJ.addElement(srvHeadercsr,"BusinessServiceDescription");
  585.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalBusinessServiceCode","Seller Service");
  586.       srvHeadercsr.up();
  587.       srvHeadercsr.up();
  588.       srvHeadercsr.up();
  589.       MQAOXMLIJ.addElement(srvHeadercsr,"TransactionControl");
  590.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalTransactionCommandCode","Send");
  591.       MQAOXMLIJ.addElementText(srvHeadercsr,"AttemptCount","1");
  592.       MQAOXMLIJ.addElement(srvHeadercsr,"TransactionIdentity");
  593.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalTransactionCode","Create Purchase Order");
  594.       MQAOXMLIJ.addElementText(srvHeadercsr,"InstanceIdentifier","1");
  595.       MQAOXMLIJ.addElement(srvHeadercsr,"description");
  596.       MQAOXMLIJ.addElementText(srvHeadercsr,"FreeFormText","Activity creates a Purchase Order Notification.");
  597.       MQAOXMLIJ.getElement(srvHeadercsr,"FreeFormText");
  598.       MQAOXMLIJ.addAttribute(srvHeadercsr,"xml:lang","en");
  599.       srvHeadercsr.up();
  600.       srvHeadercsr.up();
  601.       srvHeadercsr.up();
  602.       MQAOXMLIJ.addElement(srvHeadercsr,"PartnerRoleRoute");
  603.       MQAOXMLIJ.addElement(srvHeadercsr,"fromRole");
  604.       MQAOXMLIJ.addElement(srvHeadercsr,"PartnerRoleDescription");
  605.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalPartnerRoleClassificationCode","Buyer");
  606.       srvHeadercsr.up();
  607.       srvHeadercsr.up();
  608.       MQAOXMLIJ.addElement(srvHeadercsr,"toRole");
  609.       MQAOXMLIJ.addElement(srvHeadercsr,"PartnerRoleDescription");
  610.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalPartnerRoleClassificationCode","Seller");
  611.       srvHeadercsr.up();
  612.       srvHeadercsr.up();
  613.       srvHeadercsr.up();
  614.       MQAOXMLIJ.addElement(srvHeadercsr,"ActionControl");
  615.       MQAOXMLIJ.addElement(srvHeadercsr,"ActionIdentity");
  616.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalBusinessActionCode","Purchase Order Request");
  617.       MQAOXMLIJ.addElementText(srvHeadercsr,"VersionIdentifier","1.1");
  618.       MQAOXMLIJ.addElementText(srvHeadercsr,"InstanceIdentifier","1");
  619.       MQAOXMLIJ.addElement(srvHeadercsr,"description");
  620.       MQAOXMLIJ.addElementText(srvHeadercsr,"FreeFormText","A notification informing the Seller that A Purchase Order has been issued.");
  621.       MQAOXMLIJ.getElement(srvHeadercsr,"FreeFormText");
  622.       MQAOXMLIJ.addAttribute(srvHeadercsr,"xml:lang","en");
  623.       srvHeadercsr.up();
  624.       srvHeadercsr.up();
  625.       srvHeadercsr.up();
  626.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalDocumentFunctionCode","Request");
  627.       MQAOXMLIJ.addElement(srvHeadercsr,"PartnerRoute");
  628.       MQAOXMLIJ.addElement(srvHeadercsr,"fromPartner");
  629.       MQAOXMLIJ.addElement(srvHeadercsr,"PartnerDescription");
  630.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalPartnerClassificationCode","Shopper");
  631.       MQAOXMLIJ.addElement(srvHeadercsr,"BusinessDescription");
  632.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalBusinessIdentifier",ReqId);
  633.       srvHeadercsr.up();
  634.       srvHeadercsr.up();
  635.       srvHeadercsr.up();
  636.       MQAOXMLIJ.addElement(srvHeadercsr,"toPartner");
  637.       MQAOXMLIJ.addElement(srvHeadercsr,"PartnerDescription");
  638.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalPartnerClassificationCode","Manufacturer");
  639.       MQAOXMLIJ.addElement(srvHeadercsr,"BusinessDescription");
  640.       MQAOXMLIJ.addElementText(srvHeadercsr,"GlobalBusinessIdentifier",DstId);
  641.       if(supPerformance)
  642.       {
  643.          srvHeadercsr.up();
  644.          srvHeadercsr.up();
  645.          srvHeadercsr.up();
  646.          srvHeadercsr.up();
  647.          MQAOXMLIJ.addElement(srvHeadercsr,"PerformanceControlRequest");
  648.          MQAOXMLIJ.addElement(srvHeadercsr,"timeToAcknowledgeAcceptance");
  649.          MQAOXMLIJ.addElementText(srvHeadercsr,"TimeDuration",ackAccTime);
  650.          srvHeadercsr.up();
  651.          MQAOXMLIJ.addElement(srvHeadercsr,"timeToAcknowledgeReceipt");
  652.          MQAOXMLIJ.addElementText(srvHeadercsr,"TimeDuration",ackRecTime);
  653.          srvHeadercsr.up();
  654.          MQAOXMLIJ.addElement(srvHeadercsr,"timeToPerform");
  655.          MQAOXMLIJ.addElementText(srvHeadercsr,"TimeDuration",perform);
  656.       }
  657.  
  658.       // Output the xml
  659.       if(xmlDumps)
  660.       {
  661.          System.out.println("SRVHDR:\n" + MQAOXMLIJ.printWithFormat(srvHeadercsr));
  662.       }
  663.       // Build reply command
  664.       // - Header
  665.       cmdout = new GatewayCommands();
  666.       cmdout.setCommand("CreateTPPInstanceCommand");
  667.       //cmdout.setMailboxID(cmdin.getMailboxID());
  668.       cmdout.setTpID(ReqId);
  669.       cmdout.setTppType("RosettaNet");
  670.       cmdout.setBFPCorrelationID(colIx);
  671.       cmdout.setProcessID("3A4");
  672.       // - Parameters
  673.       cmdout.setBFPNotificationID(colIx);
  674.       cmdout.setEPNotificationID("E"+colIx);
  675.       cmdout.setWMPNotificationID("W"+colIx);
  676.       // Build the RosettaNet body
  677.       cmdout.setMessage(MQAOXMLIJ.printWithoutFormat(preamblecsr) +
  678.               MQAOXMLIJ.printWithoutFormat(srvHeadercsr) +
  679.               MQAOXMLIJ.printWithoutFormat(requestcsr));
  680.  
  681.       // Build the MQAO message
  682.       msgout = new EpicMessage("DEFAULT","APPLICATION");
  683.       msgout.setDestinationLogicalID("GATEWAY");
  684.       msgout.setSourceLogicalID("BFM");
  685.       msgout.setBodyCategory("GATEWAY");
  686.       msgout.setBodyType("REPLY");
  687.       msgout.setBodyData(cmdout.createCommandMsg());
  688.  
  689.       addTrace(cmdout.getBFPCorrelationID(),
  690.               "###>>>REPLY(CreateTPPInstanceCommand):TPPInstanceID="+cmdout.getTPPInstanceID()+
  691.              ",BFPCorrelationID="+cmdout.getBFPCorrelationID()+
  692.              ",MessageRecordID="+cmdout.getMessageRecordID());
  693.  
  694.       // Send the MQAO message
  695.       getEpicNativeAdapter().sendMsg(msgout);
  696.    }
  697.    catch(Exception e)
  698.    {
  699.       e.printStackTrace();
  700.    }
  701. }
  702. }