Advertisement
tko_pb

ProcessedDocumentHandlerAction 7 septer ber versi 2

Sep 7th, 2018
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.61 KB | None | 0 0
  1. package org.wirabumi.gen.oez.event;
  2.  
  3. import java.util.List;
  4.  
  5. import org.openbravo.base.model.Entity;
  6. import org.openbravo.base.model.ModelProvider;
  7. import org.openbravo.base.secureApp.VariablesSecureApp;
  8. import org.openbravo.base.structure.BaseOBObject;
  9. import org.openbravo.dal.service.OBDal;
  10. import org.openbravo.model.ad.ui.Tab;
  11.  
  12. public class ProcessedDocumentHandlerAction extends DocumentRoutingHandlerAction {
  13.     private final String processed="processed";
  14.     private final String complete="co";
  15.     private final String reactive="re";
  16.     private final String waitingRelease1="oez_waitingrelease1";
  17.     private final String waitingRelease2="oez_waitingrelease2";
  18.     private final String waitingRelease3="oez_waitingrelease3";
  19.     private final String waitingRelease4="oez_waitingrelease4";
  20.     private final String waitingRelease5="oez_waitingrelease5";
  21.  
  22.     @Override
  23.     public void doRouting(String adWindowId, String adTabId, String doc_status_to,
  24.             VariablesSecureApp vars, List<String> recordId) {
  25.         //dari tabId dapatkan tableID
  26.         Tab tab = OBDal.getInstance().get(Tab.class, adTabId);
  27.         String tableId = tab.getTable().getId();
  28.         Entity entity = ModelProvider.getInstance().getEntityByTableId(
  29.                 tableId);
  30.  
  31.         // doc status to=CO maka activate
  32.         //if ((doc_status_to.equalsIgnoreCase(complete)) || doc_status_to.equalsIgnoreCase(waitingRelease1)) {
  33.         switch (doc_status_to) {
  34.         case "CO":
  35.         case "oez_waitingrelease1":
  36.         case "oez_waitingrelease2":
  37.         case "oez_waitingrelease3":
  38.         case "oez_waitingrelease4":
  39.         case "oez_waitingrelease5":
  40.             for (int i = 0; i < recordId.size(); i++) {
  41.                 BaseOBObject objek = OBDal.getInstance().get(entity.toString(), recordId.get(i));
  42.  
  43.                 objek.set(processed, true);
  44.                 OBDal.getInstance().save(objek);
  45.             }
  46.             try {
  47.                 OBDal.getInstance().commitAndClose();
  48.             } catch (Exception e) {
  49.                 e.printStackTrace();
  50.             }
  51.  
  52.         break;
  53.        
  54.         case "re":
  55.         for (int i = 0; i < recordId.size(); i++) {
  56.             BaseOBObject objek = OBDal.getInstance().get(entity.toString(), recordId.get(i));
  57.             objek.set(processed, false);
  58.             OBDal.getInstance().save(objek);
  59.         }
  60.         try {
  61.             OBDal.getInstance().commitAndClose();
  62.         } catch (Exception e) {
  63.             e.printStackTrace();
  64.         }
  65.         break;
  66.        
  67.         default:
  68.             break;
  69.         }
  70.     }
  71.  
  72.     @Override
  73.     public Boolean updateDocumentStatus(Entity entity, List<String> RecordId, String document_status_to,
  74.             String column) {
  75.         return super.updateDocumentStatus(entity, RecordId, document_status_to, column);
  76.     }
  77.  
  78.     @Override
  79.     public String getCoDocumentNo(String record, Tab tab) {
  80.         // do nothing, cuma activate/deactivate pada kolom isactive
  81.         return null;
  82.     }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement