Advertisement
tko_pb

ProcessedDocumentHandlerAction 7 septermber

Sep 7th, 2018
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.20 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.  
  17.   @Override
  18.   public void doRouting(String adWindowId, String adTabId, String doc_status_to,
  19.       VariablesSecureApp vars, List<String> recordId) {
  20.       //dari tabId dapatkan tableID
  21.       Tab tab = OBDal.getInstance().get(Tab.class, adTabId);
  22.       String tableId = tab.getTable().getId();
  23.       Entity entity = ModelProvider.getInstance().getEntityByTableId(
  24.                 tableId);
  25.      
  26.     // doc status to=CO maka activate
  27.     if (doc_status_to.equalsIgnoreCase(complete)) {
  28.       for (int i = 0; i < recordId.size(); i++) {
  29.         BaseOBObject objek = OBDal.getInstance().get(entity.toString(), recordId.get(i));
  30.        
  31.         objek.set(processed, true);
  32.         OBDal.getInstance().save(objek);
  33.       }
  34.       try {
  35.         OBDal.getInstance().commitAndClose();
  36.       } catch (Exception e) {
  37.         e.printStackTrace();
  38.       }
  39.     }
  40.     if (doc_status_to.equalsIgnoreCase(reactive)) {
  41.         for (int i = 0; i < recordId.size(); i++) {
  42.           BaseOBObject objek = OBDal.getInstance().get(entity.toString(), recordId.get(i));
  43.           objek.set(processed, false);
  44.           OBDal.getInstance().save(objek);
  45.         }
  46.         try {
  47.           OBDal.getInstance().commitAndClose();
  48.         } catch (Exception e) {
  49.           e.printStackTrace();
  50.         }
  51.       }
  52.   }
  53.  
  54.   @Override
  55.   public Boolean updateDocumentStatus(Entity entity, List<String> RecordId, String document_status_to,
  56.       String column) {
  57.     return super.updateDocumentStatus(entity, RecordId, document_status_to, column);
  58.   }
  59.  
  60.   @Override
  61.   public String getCoDocumentNo(String record, Tab tab) {
  62.     // do nothing, cuma activate/deactivate pada kolom isactive
  63.     return null;
  64.   }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement