Package org.openbravo.model.ad.ui

Examples of org.openbravo.model.ad.ui.Process


  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    VariablesSecureApp vars = new VariablesSecureApp(request);

    final Process HBProcess = OBDal.getInstance().get(Process.class, HB_Process_ID);
    final SystemInformation sysInfo = OBDal.getInstance().get(SystemInformation.class,
        SystemInfomation_ID);
    final boolean isHearbeatEnabled = sysInfo.isEnableHeartbeat() == null ? false : sysInfo
        .isEnableHeartbeat();

    final String clickedButton = vars.getStringParameter("inpLastFieldChanged");

    if (isHearbeatEnabled || clickedButton.equalsIgnoreCase("inpisheartbeatactive")) {
      // 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
View Full Code Here

TOP

Related Classes of org.openbravo.model.ad.ui.Process

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.