Package org.openbravo.scheduling

Examples of org.openbravo.scheduling.ProcessBundle


        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "800006", (("C_Project_Vendor_ID".equalsIgnoreCase("AD_Language"))?"0":strC_Project_Vendor_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here


PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "cheaper", strcheaper, vars.getClient(), vars.getOrg(), vars.getUser());
String strcalcQty = vars.getStringParameter("inpcalcQty", "N");
PInstanceProcessData.insertPInstanceParam(this, pinstance, "20", "calc_qty", strcalcQty, vars.getClient(), vars.getOrg(), vars.getUser());

         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myMessage.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myMessage);
        }
        //close popup
        if (myMessage!=null) {
          if (log4j.isDebugEnabled()) log4j.debug(myMessage.getMessage());
          vars.setMessage(tabId, myMessage);
        }
        printPageClosePopUp(response, vars);
    } else if (vars.commandIn("SAVE_BUTTONDocAction109")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpKey", windowId + "|M_InOut_ID", "");
        @SuppressWarnings("unused")
        String strdocaction = vars.getStringParameter("inpdocaction");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "109", (("M_InOut_ID".equalsIgnoreCase("AD_Language"))?"0":strM_InOut_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
          HeaderData.updateDocAction(this, strdocaction, strM_InOut_ID);

          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here

        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "800118", (("MA_Wrphase_ID".equalsIgnoreCase("AD_Language"))?"0":strMA_Wrphase_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here

        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "800105", (("M_ProductionPlan_ID".equalsIgnoreCase("AD_Language"))?"0":strM_ProductionPlan_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here

          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "800002", (("C_Project_ID".equalsIgnoreCase("AD_Language"))?"0":strC_Project_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
          PInstanceProcessData.insertPInstanceParam(this, pinstance, "0", "ChangeProjectStatus", strchangeprojectstatus, vars.getClient(), vars.getOrg(), vars.getUser());

         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myMessage.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myMessage);
        }
        //close popup
        if (myMessage!=null) {
          if (log4j.isDebugEnabled()) log4j.debug(myMessage.getMessage());
          vars.setMessage(tabId, myMessage);
        }
        printPageClosePopUp(response, vars);
    } else if (vars.commandIn("SAVE_BUTTONGenerateOrder800005")) {
        String strC_Project_ID = vars.getGlobalVariable("inpKey", windowId + "|C_Project_ID", "");
        @SuppressWarnings("unused")
        String strgenerateorder = vars.getStringParameter("inpgenerateorder");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "800005", (("C_Project_ID".equalsIgnoreCase("AD_Language"))?"0":strC_Project_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here

          PInstanceProcessData.insertPInstance(this, pinstance, "800136", (("A_Asset_Group_Acct_ID".equalsIgnoreCase("AD_Language"))?"0":strA_Asset_Group_Acct_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
          String straAssetGroupId = vars.getStringParameter("inpaAssetGroupId");
PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "A_Asset_Group_ID", straAssetGroupId, vars.getClient(), vars.getOrg(), vars.getUser());

         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here

      // Disable Heartbeat
      try {

        if (sysInfo.isEnableHeartbeat() != null && sysInfo.isEnableHeartbeat()) {
          // Sending beat
          ProcessBundle beat = new ProcessBundle(HB_Process_ID, vars).init(this);
          new ProcessRunner(beat).execute(this);
        }

        // Deactivating the process at SystemInfo
        sysInfo.setEnableHeartbeat(false);
        sysInfo.setTestHeartbeat("N");
        OBDal.getInstance().save(sysInfo);

        // Un-scheduling the process
        final OBCriteria<ProcessRequest> prCriteria = OBDal.getInstance().createCriteria(
            ProcessRequest.class);
        prCriteria.add(Expression.eq(ProcessRequest.PROPERTY_PROCESS, HBProcess));
        prCriteria
            .add(Expression.eq(ProcessRequest.PROPERTY_CHANNEL, Channel.SCHEDULED.toString()));
        final List<ProcessRequest> requestList = prCriteria.list();

        if (requestList.size() != 0) {

          final ProcessRequest pr = requestList.get(0);

          OBDal.getInstance().save(pr);
          OBDal.getInstance().commitAndClose();

          final ProcessBundle bundle = ProcessBundle.request(pr.getId(), vars, this);

          OBScheduler.getInstance().unschedule(pr.getId(), bundle.getContext());
        }

        String msg = Utility.messageBD(this, "HB_SUCCESS", vars.getLanguage());
        advisePopUpRefresh(request, response, "SUCCESS", "Heartbeat Configuration", msg);

      } catch (Exception e) {
        log4j.error(e.getMessage(), e);
        advisePopUpRefresh(request, response, "ERROR", "Heartbeat Configuration", e.getMessage());
      }

    } else { // Enable Heartbeat

      try {

        HBProcess.setActive(true);
        OBDal.getInstance().save(HBProcess);

        OBDal.getInstance().commitAndClose();

        // Sending beat
        ProcessBundle bundle = new ProcessBundle(HB_Process_ID, vars).init(this);
        final String beatExecutionId = new ProcessRunner(bundle).execute(this);

        // Getting beat result
        final ProcessRun result = OBDal.getInstance().get(ProcessRun.class, beatExecutionId);

        if (result.getStatus().equals("ERR")) {
          // Restoring not active state
          sysInfo.setEnableHeartbeat(false);
          sysInfo.setTestHeartbeat("N");
          OBDal.getInstance().save(sysInfo);
          OBDal.getInstance().commitAndClose();

          String msg = Utility.messageBD(this, "HB_INTERNAL_ERROR", vars.getLanguage());
          // Extracting the last line from the log
          String log = result.getLog().substring(0, result.getLog().lastIndexOf("\n"));
          log = log.substring(log.lastIndexOf("\n"));

          msg += "\n" + log;
          msg = Utility.formatMessageBDToHtml(msg);

          if (vars.commandIn("CONFIGURE", "CONFIGURE_MODULE")) {
            OBError err = new OBError();
            err.setType("Error");
            err.setMessage(msg);
            vars.setMessage(HB_tabId, err);
            printPageRedirect(response, vars);
          } else {
            advisePopUpRefresh(request, response, "ERROR", "Heartbeat Configuration", msg);
          }
          return;
        }

        // Scheduling the process
        final OBCriteria<ProcessRequest> prCriteria = OBDal.getInstance().createCriteria(
            ProcessRequest.class);
        prCriteria.add(Expression.eq(ProcessRequest.PROPERTY_PROCESS, HBProcess));
        prCriteria
            .add(Expression.eq(ProcessRequest.PROPERTY_CHANNEL, Channel.SCHEDULED.toString()));
        final List<ProcessRequest> requestList = prCriteria.list();

        ProcessRequest pr = null;

        if (requestList.size() == 0) { // Creating a process request
          pr = OBProvider.getInstance().get(ProcessRequest.class);
          pr.setProcess(HBProcess);
          pr.setActive(true);
          final ProcessContext context = new ProcessContext(vars);
          pr.setOpenbravoContext(context.toString());
        } else {
          pr = requestList.get(0);
        }

        // Schedule the next beat in 7 days
        Calendar c1 = Calendar.getInstance();
        c1.add(Calendar.DATE, 7);
        pr.setStartDate(c1.getTime());

        // At today's same time
        pr.setStartTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        pr.setSecurityBasedOnRole(true);
        pr.setDailyOption(EVERY_N_DAYS);
        pr.setDailyInterval(Long.parseLong("7"));
        pr.setTiming(SCHEDULE);

        OBDal.getInstance().save(pr);

        // SQLC uses a different connection
        OBDal.getInstance().commitAndClose();

        final ProcessBundle bundle2 = ProcessBundle.request(pr.getId(), vars, this);
        if (requestList.size() == 0) {
          OBScheduler.getInstance().schedule(pr.getId(), bundle2);
        } else {
          OBScheduler.getInstance().reschedule(pr.getId(), bundle2);
        }
View Full Code Here

          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "104", (("C_Order_ID".equalsIgnoreCase("AD_Language"))?"0":strC_Order_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
          HeaderData.updateDocAction(this, strdocaction, strC_Order_ID);

          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here

    out.close();
  }

  private boolean activateRemote(VariablesSecureApp vars) {
    boolean result = false;
    ProcessBundle pb = new ProcessBundle(null, vars);

    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("publicKey", vars.getStringParameter("publicKey"));
    params.put("purpose", vars.getStringParameter("purpose"));
    params.put("instanceNo", vars.getStringParameter("instanceNo"));
    pb.setParams(params);

    OBError msg = null;
    try {
      new ActiveInstanceProcess().execute(pb);
      msg = (OBError) pb.getResult();
      result = msg.getType().equals("Success");
    } catch (Exception e) {
      log4j.error(e);
      msg.setType("Error");
      msg.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), e.getMessage()));
View Full Code Here

          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "111", (("C_Invoice_ID".equalsIgnoreCase("AD_Language"))?"0":strC_Invoice_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
          ExpenseInvoiceData.updateDocAction(this, strdocaction, strC_Invoice_ID);

          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
View Full Code Here

TOP

Related Classes of org.openbravo.scheduling.ProcessBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.