Rahmadnet

develop java based process

Sep 3rd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. package org.rahmadnet.learning.ad_callout;
  2.  
  3. import org.openbravo.dal.service.OBDal;
  4. import org.openbravo.erpCommon.utility.OBError;
  5. import org.openbravo.model.common.businesspartner.BusinessPartner;
  6. import org.openbravo.model.common.enterprise.Organization;
  7. import org.openbravo.scheduling.ProcessBundle;
  8. import org.openbravo.service.db.DalBaseProcess;
  9.  
  10. public class ExampleJavaProcess extends DalBaseProcess
  11. {
  12.      
  13.       public void doExecute(ProcessBundle bundle) throws Exception {
  14.         try {
  15.      
  16.           // retrieve the parameters from the bundle
  17.           final String bPartnerId = (String) bundle.getParams().get("cBpartnerId");
  18.           final String organizationId = (String) bundle.getParams().get("adOrgId");
  19.           final String tabId = (String) bundle.getParams().get("tabId");
  20.      
  21.           final String myString = (String) bundle.getParams().get("mystring");
  22.      
  23.           // implement your process here
  24.      
  25.           // Show a result
  26.           final StringBuilder sb = new StringBuilder();
  27.           sb.append("Read information:<br/>");
  28.           if (bPartnerId != null) {
  29.             final BusinessPartner bPartner = OBDal.getInstance().get(BusinessPartner.class, bPartnerId);
  30.             sb.append("Business Partner: " + bPartner.getIdentifier() + "<br/>");
  31.           }
  32.           if (organizationId != null) {
  33.             final Organization organization = OBDal.getInstance().get(Organization.class,
  34.                 organizationId);
  35.             sb.append("Organization: " + organization.getIdentifier() + "<br/>");
  36.           }
  37.           sb.append("MyString: " + myString + "<br/>");
  38.      
  39.           // OBError is also used for successful results
  40.           final OBError msg = new OBError();
  41.           msg.setType("Success");
  42.           msg.setTitle("Read parameters!");
  43.           msg.setMessage(sb.toString());
  44.      
  45.           bundle.setResult(msg);
  46.      
  47.         } catch (final Exception e) {
  48.           e.printStackTrace(System.err);
  49.           final OBError msg = new OBError();
  50.           msg.setType("Error");
  51.           msg.setMessage(e.getMessage());
  52.           msg.setTitle("Error occurred");
  53.           bundle.setResult(msg);
  54.         }
  55.       }
  56.     }
Advertisement
Add Comment
Please, Sign In to add comment