Ejemplo n.º 1
0
  /**
   * Test
   *
   * @param args ignored
   */
  public static void main(String[] args) {

    Adempiere.startupEnvironment(false);
    CLogMgt.setLevel(Level.CONFIG);

    ColumnEncryption columnEncryption = new ColumnEncryption();

    int processId = 328; // AD_ColumnEncryption
    int columnId = 417; // AD_User - Password
    Env.setContext(Env.getCtx(), I_AD_Column.COLUMNNAME_AD_Column_ID, columnId);

    MPInstance instance;
    MPInstancePara instanceParameters;

    instance = new MPInstance(Env.getCtx(), processId, columnId);
    instance.saveEx();

    instanceParameters = new MPInstancePara(instance, 10);
    instanceParameters.setParameter(I_AD_Column.COLUMNNAME_IsEncrypted, true);
    instanceParameters.saveEx();

    instanceParameters = new MPInstancePara(instance, 20);
    instanceParameters.setParameter("ChangeSetting", true);
    instanceParameters.saveEx();

    ProcessInfo pi = new ProcessInfo("AD_ColumnEncryption", processId);
    pi.setRecord_ID(instance.getRecord_ID());
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    pi.setAD_Client_ID(0);
    pi.setAD_User_ID(100);

    columnEncryption.startProcess(Env.getCtx(), pi, null);

    /*List<MUser> users = new Query(Env.getCtx(), I_AD_User.Table_Name , "Password IS NOT NULL", null).list();
    for (MUser user : users)
    {
        user.setPassword(user.getPassword());
        user.saveEx();
    }*/

    processId = 53259; // Convert password to hashed

    pi = new ProcessInfo("AD_User_HashPassword", processId);
    pi.setAD_Client_ID(0);
    pi.setAD_User_ID(100);

    HashPasswords process = new HashPasswords();
    process.startProcess(Env.getCtx(), pi, null);
  }
Ejemplo n.º 2
0
  // @emmie custom
  public String generate(
      IStatusBar statusBar, KeyNamePair docTypeKNPair, int C_POS_ID, String docActionSelected)
        // @emmie custom
      {
    String info = "";
    String trxName = Trx.createTrxName("IVG");
    Trx trx = Trx.get(trxName, true); // trx needs to be committed too

    setSelectionActive(false); //  prevents from being called twice
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateGen"));
    statusBar.setStatusDB(String.valueOf(getSelection().size()));

    //	Prepare Process
    int AD_Process_ID = 0;

    if (docTypeKNPair.getKey() == MRMA.Table_ID) {
      AD_Process_ID =
          PROCESS_C_INVOICE_GENERATERMA_MANUAL; // C_Invoice_GenerateRMA -
                                                // org.adempiere.process.InvoiceGenerateRMA
    } else {
      AD_Process_ID = PROCESS_C_INVOICE_GENERATE_MANUAL; // HARDCODED    C_InvoiceCreate
    }
    MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
    if (!instance.save()) {
      info = Msg.getMsg(Env.getCtx(), "ProcessNoInstance");
      return info;
    }

    // insert selection
    StringBuffer insert = new StringBuffer();
    insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
    int counter = 0;
    for (Integer selectedId : getSelection()) {
      counter++;
      if (counter > 1) insert.append(" UNION ");
      insert.append("SELECT ");
      insert.append(instance.getAD_PInstance_ID());
      insert.append(", ");
      insert.append(selectedId);
      insert.append(" FROM DUAL ");

      if (counter == 1000) {
        if (DB.executeUpdate(insert.toString(), trxName) < 0) {
          String msg = "No Invoices"; //  not translated!
          info = msg;
          log.config(msg);
          trx.rollback();
          return info;
        }
        insert = new StringBuffer();
        insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
        counter = 0;
      }
    }
    if (counter > 0) {
      if (DB.executeUpdate(insert.toString(), trxName) < 0) {
        String msg = "No Invoices"; //  not translated!
        info = msg;
        log.config(msg);
        trx.rollback();
        return info;
      }
    }

    ProcessInfo pi = new ProcessInfo("", AD_Process_ID);
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());

    //	Add Parameters
    MPInstancePara para = new MPInstancePara(instance, 10);
    para.setParameter("Selection", "Y");
    if (!para.save()) {
      String msg = "No Selection Parameter added"; //  not translated
      info = msg;
      log.log(Level.SEVERE, msg);
      return info;
    }

    para = new MPInstancePara(instance, 20);
    para.setParameter("DocAction", docActionSelected);

    if (!para.save()) {
      String msg = "No DocAction Parameter added"; //  not translated
      info = msg;
      log.log(Level.SEVERE, msg);
      return info;
    }
    // @emmie custom
    para = new MPInstancePara(instance, 30);
    para.setParameter("C_POS_ID", C_POS_ID);

    if (!para.save()) {
      String msg = "No C_POS_ID Parameter added"; //  not translated
      info = msg;
      log.log(Level.SEVERE, msg);
      return info;
    }
    // @emmie custom

    setTrx(trx);
    setProcessInfo(pi);

    return info;
  } //	generateInvoices