Package org.openbravo.scheduling

Examples of org.openbravo.scheduling.ProcessContext


    final String windowId = vars.getStringParameter("inpwindowId");
    final String requestId = vars.getSessionValue(windowId + "|" + PROCESS_REQUEST_ID);

    String message;
    try {
      OBScheduler.getInstance().unschedule(requestId, new ProcessContext(vars));

    } catch (final SchedulerException e) {
      message = Utility.messageBD(this, "UNSCHED_ERROR", vars.getLanguage());
      advisePopUp(request, response, "ERROR", "Process Request", message + " " + e.getMessage());
    }
View Full Code Here


   */
  private void processClient(VariablesSecureApp vars, ProcessBundle bundle) throws ServletException {
    final String processId = bundle.getProcessId();
    final String pinstanceId = bundle.getPinstanceId();

    final ProcessContext ctx = bundle.getContext();
    isDirect = bundle.getChannel() == Channel.DIRECT;

    if (log4j.isDebugEnabled()) {
      log4j.debug("Processing client: " + vars.getClient());
    }

    String adNoteId = "";
    if (isDirect) {
      addLog("@DL_STARTING@", false);
    } else {
      addLog("Starting background process.");
    }
    if (vars == null) {
      try {
        final AcctServerProcessData[] dataOrg = AcctServerProcessData.selectUserOrg(connection,
            processId);
        if (dataOrg == null || dataOrg.length == 0) {
          if (isDirect) {
            addLog("@DL_LOAD_FAILED@");
          } else {
            addLog("User and Organization loading failed.");
          }
          return;
        }
        vars = new VariablesSecureApp(dataOrg[0].adUserId, ctx.getClient(), dataOrg[0].adOrgId);
      } catch (final ServletException ex) {
        log4j.error(ex.getMessage());
        return;
      }
    }
    try {
      final AcctServerProcessData[] data = AcctServerProcessData.selectAcctTable(connection);
      final ArrayList<Object> vTableIds = new ArrayList<Object>();
      for (int i = 0; i < data.length; i++) {
        vTableIds.add(data[i].adTableId);
      }
      TableIds = new String[vTableIds.size()];
      vTableIds.toArray(TableIds);
    } catch (final ServletException ex) {
      log4j.error(ex.getMessage());
      return;
    }
    adNoteId = saveLog(adNoteId, vars.getClient());
    String[] tables = null;
    String strTable = "";
    // If it is the background process, we use 0
    String strOrg = "0";
    // if called by 'Posting by DB tables' get params from ad_pinstance
    if (isDirect) {
      strTable = AcctServerProcessData.selectTable(connection, pinstanceId);
      strOrg = AcctServerProcessData.selectOrg(connection, pinstanceId);
    }
    if (!strTable.equals("")) {
      tables = new String[1];
      tables[0] = new String(strTable);
    } else {
      tables = TableIds;
    }
    String strTableDesc;
    for (int i = 0; i < tables.length; i++) {
      final AcctServer acct = AcctServer.get(tables[i], vars.getClient(), strOrg, connection);
      acct.setBatchSize(BATCH_SIZE);
      strTableDesc = AcctServerProcessData.selectDescription(connection, ctx.getLanguage(),
          acct.AD_Table_ID);
      int total = 0;
      while (acct.checkDocuments()) {

        if (total == 0) {
          if (isDirect)
            addLog("@DL_ACCOUNTING@ - " + strTableDesc, false);
          else
            addLog("Accounting - " + strTableDesc, false);
        } else {
          if (isDirect)
            addLog("@DL_COUNTED@ " + total + " - " + strTableDesc, false);
          else
            addLog("Counted " + total + " - " + strTableDesc, false);
        }

        try {
          acct.run(vars);
        } catch (final Exception ex) {
          log4j.error(ex.getMessage(), ex);
          return;
        }

        total += Integer.valueOf(BATCH_SIZE).intValue();
      }
      if (isDirect) {
        addLog("@DL_TABLE@ = " + strTableDesc + " - " + acct.getInfo(ctx.getLanguage()), false);
      } else {
        addLog("Table = " + strTableDesc + " - " + acct.getInfo(ctx.getLanguage()));
      }
      adNoteId = saveLog(adNoteId, vars.getClient());
    }
  }
View Full Code Here

    } else if (vars.commandIn("CANCELAR")) {
      String strTableId = vars.getStringParameter("inpadTableId", "");
      String strAdOrgId = vars.getStringParameter("inpadOrgId");
      if (data.length > 0 && data[0].status.equals(org.openbravo.scheduling.Process.SCHEDULED)) {
        try {
          OBScheduler.getInstance().unschedule(data[0].id, new ProcessContext(vars));
        } catch (SchedulerException e) {
          throw new ServletException(e.getMessage(), e);
        }
      }
      // acctServer.cancelDirectProcess();
View Full Code Here

        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
View Full Code Here

   *
   * @param bundle
   *          provides the current user and other context information.
   */
  public void execute(ProcessBundle bundle) throws Exception {
    final ProcessContext processContext = bundle.getContext();

    boolean errorOccured = true;
    final OBContext currentOBContext = OBContext.getOBContext();
    try {
      String userId = processContext.getUser();
      String roleId = processContext.getRole();
      String clientId = processContext.getClient();
      String orgId = processContext.getOrganization();

      log.debug("Setting user context to user=" + userId + ",roleId=" + roleId + ",client="
          + clientId + ",org=" + orgId);

      OBContext.setOBContext(userId, roleId, clientId, orgId);
View Full Code Here

TOP

Related Classes of org.openbravo.scheduling.ProcessContext

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.