Examples of Trx


Examples of org.compiere.util.Trx

   */
  public String generate(IStatusBar statusBar, KeyNamePair docTypeKNPair, String docActionSelected)
  {
    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 = 52002; // C_Invoice_GenerateRMA - org.adempiere.process.InvoiceGenerateRMA
        }
        else
        {
            AD_Process_ID = 134// 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);
View Full Code Here

Examples of org.compiere.util.Trx

  public static void create (MClient client)
  {
    MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(client.getCtx(), client.getAD_Client_ID());
    String trxName = client.get_TrxName();
    String trxNameUsed = trxName;
    Trx trx = null;
    if (trxName == null)
    {
      trxNameUsed = Trx.createTrxName("Cost");
      trx = Trx.get(trxNameUsed, true);
    }
    boolean success = true;
    //  For all Products
    String sql = "SELECT * FROM M_Product p "
      + "WHERE AD_Client_ID=?"
      + " AND EXISTS (SELECT * FROM M_CostDetail cd "
        + "WHERE p.M_Product_ID=cd.M_Product_ID AND Processed='N')";
    PreparedStatement pstmt = null;
    try
    {
      pstmt = DB.prepareStatement (sql, trxNameUsed);
      pstmt.setInt (1, client.getAD_Client_ID());
      ResultSet rs = pstmt.executeQuery ();
      while (rs.next ())
      {
        MProduct product = new MProduct (client.getCtx(), rs, trxNameUsed);
        for (int i = 0; i < ass.length; i++)
        {
          BigDecimal cost = getCurrentCost(product, 0, ass[i], 0,
            null, Env.ONE, 0, false, trxNameUsed);    //  create non-zero costs
          s_log.info(product.getName() + " = " + cost);
        }
      }
      rs.close ();
      pstmt.close ();
      pstmt = null;
    }
    catch (Exception e)
    {
      s_log.log (Level.SEVERE, sql, e);
      success = false;
    }
    try
    {
      if (pstmt != null)
        pstmt.close ();
      pstmt = null;
    }
    catch (Exception e)
    {
      pstmt = null;
    }
    //  Transaction
    if (trx != null)
    {
      if (success)
        trx.commit();
      else
        trx.rollback();
      trx.close();
    }
  }  //  create
View Full Code Here

Examples of org.compiere.util.Trx

  {
    log.info("Sta=" + status + " DT=" + getDocumentType()
      + " ID=" +  p_po.get_ID());
    p_Status = status;

    Trx trx = Trx.get(getTrxName(), true);
    try
    {
    //  *** Transaction Start       ***
      //  Commit Facts
      if (status.equals(STATUS_Posted))
      {
        for (int i = 0; i < m_fact.size(); i++)
        {
          Fact fact = m_fact.get(i);
          if (fact == null)
            ;
          else if (fact.save(getTrxName()))
            ;
          else
          {
            log.log(Level.SEVERE, "(fact not saved) ... rolling back");
            trx.rollback();
            trx.close();
            unlock();
            return STATUS_Error;
          }
        }
      }
      //  Commit Doc
      if (!save(getTrxName()))     //  contains unlock & document status update
      {
        log.log(Level.SEVERE, "(doc not saved) ... rolling back");
        trx.rollback();
        trx.close();
        unlock();
        return STATUS_Error;
      }
      //  Success
      trx.commit(true);
      trx.close();
      trx = null;
    //  *** Transaction End         ***
    }
    catch (Exception e)
    {
      log.log(Level.SEVERE, "... rolling back", e);
      status = STATUS_Error;
      try {
        if (trx != null)
          trx.rollback();
      } catch (Exception e2) {}
      try {
        if (trx != null)
          trx.close();
        trx = null;
      } catch (Exception e3) {}
      unlock();
    }
    p_Status = status;
View Full Code Here

Examples of org.xrace.desjardins.reponse.Trx

    {
      @Override
      public java.lang.Object getValue(java.lang.Object object)
          throws IllegalStateException
      {
        Trx target = (Trx) object;
        return target.getId();
      }

      @Override
      public void setValue(java.lang.Object object, java.lang.Object value)
          throws IllegalStateException, IllegalArgumentException
      {
        try
        {
          Trx target = (Trx) object;
          target.setId((java.lang.String) value);
        }
        catch (java.lang.Exception ex)
        {
          throw new IllegalStateException(ex.toString());
        }
      }

      @Override
      public java.lang.Object newInstance(java.lang.Object parent)
      {
        return null;
      }
    };
    desc.setSchemaType("string");
    desc.setHandler(handler);
    desc.setMultivalued(false);
    addFieldDescriptor(desc);

    //-- validation code for: _id
    fieldValidator = new org.exolab.castor.xml.FieldValidator();
    { //-- local scope
      org.exolab.castor.xml.validators.StringValidator typeValidator;
      typeValidator = new org.exolab.castor.xml.validators.StringValidator();
      fieldValidator.setValidator(typeValidator);
      typeValidator.setWhiteSpace("preserve");
      typeValidator.setMaxLength(40);
      typeValidator.setMinLength(1);
    }
    desc.setValidator(fieldValidator);
    //-- _key
    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
        java.lang.String.class, "_key", "key",
        org.exolab.castor.xml.NodeType.Attribute);
    desc.setImmutable(true);
    handler = new org.exolab.castor.xml.XMLFieldHandler()
    {
      @Override
      public java.lang.Object getValue(java.lang.Object object)
          throws IllegalStateException
      {
        Trx target = (Trx) object;
        return target.getKey();
      }

      @Override
      public void setValue(java.lang.Object object, java.lang.Object value)
          throws IllegalStateException, IllegalArgumentException
      {
        try
        {
          Trx target = (Trx) object;
          target.setKey((java.lang.String) value);
        }
        catch (java.lang.Exception ex)
        {
          throw new IllegalStateException(ex.toString());
        }
View Full Code Here

Examples of org.xrace.desjardins.trx.Trx

    request.setMerchant(merchant);

    Login login = new Login();
    merchant.setLogin(login);

    Trx trx = new Trx();
    trx.setId(context.getTxIdPrefix() + transaction.getId().toString());
    login.setTrx(new Trx[]
    { trx });

    return request;
  }
View Full Code Here

Examples of org.xrace.desjardins.trx.Trx

    {
      @Override
      public java.lang.Object getValue(java.lang.Object object)
          throws IllegalStateException
      {
        Trx target = (Trx) object;
        return target.getId();
      }

      @Override
      public void setValue(java.lang.Object object, java.lang.Object value)
          throws IllegalStateException, IllegalArgumentException
      {
        try
        {
          Trx target = (Trx) object;
          target.setId((java.lang.String) value);
        }
        catch (java.lang.Exception ex)
        {
          throw new IllegalStateException(ex.toString());
        }
      }

      @Override
      public java.lang.Object newInstance(java.lang.Object parent)
      {
        return null;
      }
    };
    desc.setSchemaType("string");
    desc.setHandler(handler);
    desc.setRequired(true);
    desc.setMultivalued(false);
    addFieldDescriptor(desc);

    //-- validation code for: _id
    fieldValidator = new org.exolab.castor.xml.FieldValidator();
    fieldValidator.setMinOccurs(1);
    { //-- local scope
      org.exolab.castor.xml.validators.StringValidator typeValidator;
      typeValidator = new org.exolab.castor.xml.validators.StringValidator();
      fieldValidator.setValidator(typeValidator);
      typeValidator.setWhiteSpace("preserve");
      typeValidator.setMaxLength(40);
      typeValidator.setMinLength(1);
    }
    desc.setValidator(fieldValidator);
    //-- _key
    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
        java.lang.String.class, "_key", "key",
        org.exolab.castor.xml.NodeType.Attribute);
    desc.setImmutable(true);
    handler = new org.exolab.castor.xml.XMLFieldHandler()
    {
      @Override
      public java.lang.Object getValue(java.lang.Object object)
          throws IllegalStateException
      {
        Trx target = (Trx) object;
        return target.getKey();
      }

      @Override
      public void setValue(java.lang.Object object, java.lang.Object value)
          throws IllegalStateException, IllegalArgumentException
      {
        try
        {
          Trx target = (Trx) object;
          target.setKey((java.lang.String) value);
        }
        catch (java.lang.Exception ex)
        {
          throw new IllegalStateException(ex.toString());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.