Advertisement
tko_pb

GenerateXmlFromPopulate.java

Nov 16th, 2020
1,111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. package org.kosta.aoi.process;
  2.  
  3. import java.sql.Timestamp;
  4. import java.util.ArrayList;
  5. import java.util.Date;
  6. import java.util.List;
  7.  
  8. import org.aoi.enh.component.ENHValidatorFactory;
  9. import org.compiere.model.MOrder;
  10. import org.compiere.model.Query;
  11. import org.compiere.process.SvrProcess;
  12. import org.kosta.aoi.model.X_C_Populate_Generatexml;
  13.  
  14. public class GenerateXmlFromPopulate extends SvrProcess {
  15.    
  16.     protected String msg = null;
  17.     private ArrayList<String> orderIdSucess = new ArrayList<String>();
  18.    
  19.     @Override
  20.     protected void prepare() {
  21.        
  22.     }
  23.  
  24.     @Override
  25.     protected String doIt() throws Exception {
  26.         ENHValidatorFactory enhFactory = new ENHValidatorFactory();
  27.         List<X_C_Populate_Generatexml> populate_orderList = new Query(getCtx(), X_C_Populate_Generatexml.Table_Name, "processed='N'", get_TrxName())
  28.                                                         .setClient_ID()
  29.                                                         .setOnlyActiveRecords(true)
  30.                                                         .list();
  31.         for(X_C_Populate_Generatexml populateOrder : populate_orderList){
  32.             String validation = null;
  33.             MOrder order = new MOrder(getCtx(), populateOrder.getC_Order_ID(), get_TrxName());
  34.             validation = enhFactory.callWebPOUrlXml(order, msg);
  35.             if(validation == null ){
  36.                 populateOrder.setProcessed(true);
  37.                 populateOrder.setxmlgenerated(true);
  38.                 populateOrder.setgenerateddate(GetTime());
  39.                 populateOrder.saveEx();
  40.                 orderIdSucess.add(populateOrder.getC_Order().getDocumentNo());
  41.             }
  42.         }
  43.        
  44.         setMsgReturn();
  45.         return msg;
  46.     }
  47.    
  48.     private void setMsgReturn(){
  49.         msg+= "Generate XML Sucess For = ";
  50.         for(String populate : orderIdSucess){
  51.             msg += populate+", ";
  52.         }
  53.     }
  54.    
  55.     private Timestamp GetTime(){
  56.         // get timing when this function is running use for set id on description po header.
  57.         Date date= new Date();
  58.         long time = date.getTime();
  59.         Timestamp ts = new Timestamp(time);
  60.         return ts;
  61.     }
  62.  
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement