@Override
  public void init(int WindowNo, FormFrame frame) {
    m_WindowNo = WindowNo;
    m_frame = frame;
    log.info(
        "WinNo="
            + m_WindowNo
            + " - AD_Client_ID="
            + m_AD_Client_ID
            + ", AD_Org_ID="
            + m_AD_Org_ID
            + ", By="
            + m_by);
    Env.getCtx().setIsSOTrx(m_WindowNo, false);
    trans = Trx.get("XX_ModifyDebtCredit");

    try {
      //	UI
      jbInit();
      dynInit();
      frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
      frame.getContentPane().add(statusBar, BorderLayout.SOUTH);

    } catch (Exception e) {
      log.log(Level.SEVERE, "", e);
    }
  }
示例#2
0
  /**
   * Initialize Panel
   *
   * @param WindowNo window
   */
  protected void initForm() {
    log.info("");
    try {
      jbInit();
      dynInit();

      this.setWidth("100%");
      this.setClosable(true);
      this.setTitle("Import File Loader");
      this.setBorder("normal");

      Borderlayout layout = new Borderlayout();
      layout.setHeight("100%");
      layout.setWidth("100%");
      this.appendChild(layout);
      North north = new North();
      layout.appendChild(north);
      north.appendChild(northPanel);
      Center center = new Center();
      center.setFlex(true);
      layout.appendChild(center);
      center.appendChild(centerPanel);
      South south = new South();
      layout.appendChild(south);
      south.appendChild(confirmPanel);
    } catch (Exception e) {
      log.log(Level.SEVERE, "init", e);
    }
  } //	init
 /*
  * Write to file
  *
  * @param sb string buffer
  * @param fileName file name
  */
 private void writeToFile(StringBuffer sb, String fileName) {
   try {
     new File(fileName.substring(0, fileName.lastIndexOf("/"))).mkdirs();
     File out = new File(fileName);
     Writer fw = new OutputStreamWriter(new FileOutputStream(out, false), "UTF-8");
     for (int i = 0; i < sb.length(); i++) {
       char c = sb.charAt(i);
       // after
       if (c == ';' || c == '}') {
         fw.write(c);
         if (sb.substring(i + 1).startsWith("//")) fw.write('\t');
         else fw.write(NL);
       }
       // before & after
       else if (c == '{') {
         fw.write(NL);
         fw.write(c);
         fw.write(NL);
       } else fw.write(c);
     }
     fw.flush();
     fw.close();
     float size = out.length();
     size /= 1024;
     log.info(out.getAbsolutePath() + " - " + size + " kB");
   } catch (Exception ex) {
     log.log(Level.SEVERE, fileName, ex);
     throw new RuntimeException(ex);
   }
 }
 /**
  * ************************************************************************ Receive notification
  * of the start of an element.
  *
  * @param uri namespace
  * @param localName simple name
  * @param qName qualified name
  * @param attributes attributes
  * @throws org.xml.sax.SAXException
  */
 public void startElement(String uri, String localName, String qName, Attributes attributes)
     throws org.xml.sax.SAXException {
   //	log.fine( "TranslationHandler.startElement", qName);	// + " - " + uri + " - " + localName);
   if (qName.equals(Translation.XML_TAG)
       || qName.equals(Translation.XML_TAG2)
       || qName.equals(Translation.XML_TAG3)) {
     m_AD_Language = attributes.getValue(Translation.XML_ATTRIBUTE_LANGUAGE);
     m_isBaseLanguage = Language.isBaseLanguage(m_AD_Language);
     m_TableName = attributes.getValue(Translation.XML_ATTRIBUTE_TABLE);
     m_updateSQL = "UPDATE " + m_TableName;
     if (!m_isBaseLanguage) m_updateSQL += "_Trl";
     m_updateSQL += " SET ";
     if (log.isLoggable(Level.FINE))
       log.fine(
           "AD_Language="
               + m_AD_Language
               + ", Base="
               + m_isBaseLanguage
               + ", TableName="
               + m_TableName);
   } else if (qName.equals(Translation.XML_ROW_TAG)) {
     m_curID = attributes.getValue(Translation.XML_ROW_ATTRIBUTE_ID);
     m_curUUID = attributes.getValue(Translation.XML_ROW_ATTRIBUTE_UUID);
     m_trl = attributes.getValue(Translation.XML_ROW_ATTRIBUTE_TRANSLATED);
     //	log.finest( "ID=" + m_curID);
     m_sql = new StringBuffer();
   } else if (qName.equals(Translation.XML_VALUE_TAG)) {
     m_curColumnName = attributes.getValue(Translation.XML_VALUE_ATTRIBUTE_COLUMN);
     //	log.finest( "ColumnName=" + m_curColName);
   } else log.severe("UNKNOWN TAG: " + qName);
   m_curValue = new StringBuffer();
 } //	startElement
 protected boolean beforeSave(boolean newRecord) {
   // TODO - Think about implement a determination of DocType similar to in MPayment.beforeSave()
   if (!newRecord) {
     MPayment[] pays;
     try {
       pays = getPayments(get_TrxName());
     } catch (SQLException e) {
       s_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
       return false;
     }
     for (int i = 0; i < pays.length; i++) {
       pays[i].setC_DocType_ID(getC_DocType_ID());
       pays[i].setDocumentNo(getDocumentNo());
       pays[i].setDateTrx(getDateTrx());
       pays[i].setDateAcct(getDateTrx());
       pays[i].setC_BPartner_ID(getC_BPartner_ID());
       pays[i].setIsReceipt(isReceipt());
       pays[i].setIsActive(isActive());
       if (!pays[i].save(get_TrxName())) {
         try {
           DB.rollback(false, get_TrxName());
         } catch (SQLException e) {
           s_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
         }
         return false;
       }
     }
   }
   return true;
 }
示例#6
0
  /**
   * Is Period Open for Doc Base Type
   *
   * @param DocBaseType document base type
   * @param dateAcct accounting date
   * @return error message or null
   */
  public String isOpen(String DocBaseType, Timestamp dateAcct) {
    if (!isActive()) {
      s_log.warning("Period not active: " + getName());
      return "@C_Period_ID@ <> @IsActive@";
    }

    MAcctSchema as = MClient.get(getCtx(), getAD_Client_ID()).getAcctSchema();
    if (as != null && as.isAutoPeriodControl()) {
      if (!as.isAutoPeriodControlOpen(dateAcct)) return "@PeriodClosed@ - @AutoPeriodControl@";
      //	We are OK
      Timestamp today = new Timestamp(System.currentTimeMillis());
      if (isInPeriod(today) && as.getC_Period_ID() != getC_Period_ID()) {
        as.setC_Period_ID(getC_Period_ID());
        as.save();
      }
      return null;
    }

    //	Standard Period Control
    if (DocBaseType == null) {
      log.warning(getName() + " - No DocBaseType");
      return "@NotFound@ @DocBaseType@";
    }
    MPeriodControl pc = getPeriodControl(DocBaseType);
    if (pc == null) {
      log.warning(getName() + " - Period Control not found for " + DocBaseType);
      return "@NotFound@ @C_PeriodControl_ID@: " + DocBaseType;
    }
    log.fine(getName() + ": " + DocBaseType);
    if (pc.isOpen()) return null;
    return "@PeriodClosed@ - @C_PeriodControl_ID@ (" + DocBaseType + ", " + dateAcct + ")";
  } //	isOpen
示例#7
0
  /**
   * Save (Insert new) Row of Tab
   *
   * @param windowNo relative window
   * @param AD_Tab_ID tab
   * @param curRow insert after relative row number in results
   * @param context current (relevant) context of new row
   * @return error message or null
   */
  public ChangeVO insertRow(
      int windowNo, int AD_Tab_ID, int queryResultID, int curRow, Map<String, String> context) {
    if (context == null || context.size() == 0) return new ChangeVO(true, "No Context");
    UITab tab = getTab(AD_Tab_ID);
    if (tab == null) {
      log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
      return new ChangeVO(true, "@NotFound@ @AD_Tab_ID@=" + AD_Tab_ID);
    }

    log.info("Line Amt:" + context.get("LineNetAmt"));
    CContext ctx = new CContext(m_context.entrySet());
    ctx.addWindow(windowNo, context);
    ChangeVO retValue = tab.saveRow(ctx, windowNo, true);
    if (retValue.hasError()) return retValue;
    // Update Results
    ArrayList<String[]> data = m_results.get(queryResultID);
    if (data == null) retValue.addError("Data Not Found");
    else {
      String[] dataRow = retValue.rowData;
      if (curRow >= data.size()) data.add(dataRow);
      else data.add(curRow, dataRow);
      retValue.trxInfo = GridTab.getTrxInfo(tab.getTableName(), ctx, windowNo, tab.getTabNo());
    }
    return retValue;
  } // insertRow
示例#8
0
  /**
   * Caret Listener
   *
   * @param e event
   */
  public void caretUpdate(CaretEvent e) {
    log.finest("Dot=" + e.getDot() + ",Last=" + m_lastDot + ", Mark=" + e.getMark());
    //	Selection
    if (e.getDot() != e.getMark()) {
      m_lastDot = e.getDot();
      return;
    }
    //

    //	Is the current position a fixed character?
    if (e.getDot() + 1 > m_mask.length() || m_mask.charAt(e.getDot()) != DELIMITER) {
      m_lastDot = e.getDot();
      return;
    }

    //	Direction?
    int newDot = -1;
    if (m_lastDot > e.getDot()) // 	<-
    newDot = e.getDot() - 1;
    else //	-> (or same)
    newDot = e.getDot() + 1;
    if (e.getDot() == 0) // 	first
    newDot = 1;
    else if (e.getDot() == m_mask.length() - 1) // 	last
    newDot = e.getDot() - 1;
    //
    log.fine(
        "OnFixedChar=" + m_mask.charAt(e.getDot()) + ", newDot=" + newDot + ", last=" + m_lastDot);
    //
    m_lastDot = e.getDot();
    if (newDot >= 0 && newDot < getText().length()) m_tc.setCaretPosition(newDot);
  } //	caretUpdate
示例#9
0
  public ArrayList<KeyNamePair> getPaySelectionData() {
    ArrayList<KeyNamePair> data = new ArrayList<KeyNamePair>();

    log.config("");
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());

    //  Load PaySelect
    String sql =
        "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection "
            + "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'"
            + "ORDER BY PayDate DESC";
    try {
      PreparedStatement pstmt = DB.prepareStatement(sql, null);
      pstmt.setInt(1, AD_Client_ID);
      ResultSet rs = pstmt.executeQuery();
      //
      while (rs.next()) {
        KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
        data.add(pp);
      }
      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    }

    return data;
  }
示例#10
0
 /** PaySelect changed - load Bank */
 public void loadPaySelectInfo(int C_PaySelection_ID) {
   //  load Banks from PaySelectLine
   m_C_BankAccount_ID = -1;
   String sql =
       "SELECT ps.C_BankAccount_ID, b.Name || ' ' || ba.AccountNo," //	1..2
           + " c.ISO_Code, CurrentBalance, ba.PaymentExportClass " //	3..5
           + "FROM C_PaySelection ps"
           + " INNER JOIN C_BankAccount ba ON (ps.C_BankAccount_ID=ba.C_BankAccount_ID)"
           + " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID)"
           + " INNER JOIN C_Currency c ON (ba.C_Currency_ID=c.C_Currency_ID) "
           + "WHERE ps.C_PaySelection_ID=? AND ps.Processed='Y' AND ba.IsActive='Y'";
   try {
     PreparedStatement pstmt = DB.prepareStatement(sql, null);
     pstmt.setInt(1, C_PaySelection_ID);
     ResultSet rs = pstmt.executeQuery();
     if (rs.next()) {
       m_C_BankAccount_ID = rs.getInt(1);
       bank = rs.getString(2);
       currency = rs.getString(3);
       balance = rs.getBigDecimal(4);
       m_PaymentExportClass = rs.getString(5);
     } else {
       m_C_BankAccount_ID = -1;
       bank = "";
       currency = "";
       balance = Env.ZERO;
       m_PaymentExportClass = null;
       log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID);
     }
     rs.close();
     pstmt.close();
   } catch (SQLException e) {
     log.log(Level.SEVERE, sql, e);
   }
 } //  loadPaySelectInfo
示例#11
0
  /** Bank changed - load PaymentRule */
  public ArrayList<ValueNamePair> loadPaymentRule(int C_PaySelection_ID) {
    ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();

    // load PaymentRule for Bank
    int AD_Reference_ID = 195; //  MLookupInfo.getAD_Reference_ID("All_Payment Rule");
    Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
    MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
    String sql =
        info.Query.substring(0, info.Query.indexOf(" ORDER BY"))
            + " AND "
            + info.KeyColumn
            + " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) "
            + info.Query.substring(info.Query.indexOf(" ORDER BY"));
    try {
      PreparedStatement pstmt = DB.prepareStatement(sql, null);
      pstmt.setInt(1, C_PaySelection_ID);
      ResultSet rs = pstmt.executeQuery();
      //
      while (rs.next()) {
        ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
        data.add(pp);
      }
      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    }

    if (data.size() == 0)
      log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);

    return data;
  } //  loadPaymentRule
示例#12
0
 /**
  * Generate LDAPResult
  *
  * @param dn Distinguished Name
  * @param resultProtocol Result protocol/operation code
  * @param resultCode Result code
  * @param errMsg Error Message
  * @return reponse
  */
 private void generateResult(String dn, int resultProtocol, int resultCode, String errMsg) {
   try {
     m_encoder.beginSeq(48); // Hard coded here for Envelope header
     m_encoder.encodeInt(m_ldapMsg.getMsgId());
     m_encoder.beginSeq(resultProtocol);
     m_encoder.encodeInt(resultCode, 10); // Enumeration - 10
     // Adding LDAPDN
     m_encoder.encodeString(dn, true);
     // Adding error message
     m_encoder.encodeString(errMsg == null ? "" : errMsg, true);
     m_encoder.endSeq();
     m_encoder.endSeq();
     log.fine(
         "#"
             + m_ldapMsg.getMsgId()
             + ": "
             + "dn="
             + dn
             + ", op="
             + resultProtocol
             + ", result="
             + resultCode
             + ", errMsg="
             + errMsg);
   } catch (Exception ex) {
     log.log(Level.SEVERE, "", ex);
   }
 } // generateResult
示例#13
0
  /**
   * After Save
   *
   * @param newRecord new
   * @param success success
   * @return success
   */
  @Override
  protected boolean afterSave(boolean newRecord, boolean success) {
    //	also used for afterDelete
    String sql =
        "UPDATE M_AttributeSet mas"
            + " SET IsInstanceAttribute='Y' "
            + "WHERE M_AttributeSet_ID= ? "
            + " AND IsInstanceAttribute='N'"
            + " AND (IsSerNo='Y' OR IsLot='Y' OR IsGuaranteeDate='Y'"
            + " OR EXISTS (SELECT * FROM M_AttributeUse mau"
            + " INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) "
            + "WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID"
            + " AND mau.IsActive='Y' AND ma.IsActive='Y'"
            + " AND ma.IsInstanceAttribute='Y')"
            + ")";
    int no = DB.executeUpdate(get_Trx(), sql, getM_AttributeSet_ID());
    if (no != 0) log.fine("afterSave - Set Instance Attribute");
    //
    sql =
        "UPDATE M_AttributeSet mas"
            + " SET IsInstanceAttribute='N' "
            + "WHERE M_AttributeSet_ID=? "
            + " AND IsInstanceAttribute='Y'"
            + "	AND IsSerNo='N' AND IsLot='N' AND IsGuaranteeDate='N'"
            + " AND NOT EXISTS (SELECT * FROM M_AttributeUse mau"
            + " INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) "
            + "WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID"
            + " AND mau.IsActive='Y' AND ma.IsActive='Y'"
            + " AND ma.IsInstanceAttribute='Y')";
    no = DB.executeUpdate(get_Trx(), sql, getM_AttributeSet_ID());
    if (no != 0) log.fine("afterSave - Reset Instance Attribute");

    return success;
  } //	afterSave
  /**
   * Action Listener
   *
   * @param e event
   */
  public void actionPerformed(ActionEvent e) {
    log.info(e.toString());

    //	Add new Node
    if (e.getSource() == m_NewMenuNode) {
      log.info("Create New Node");
      String nameLabel = Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Name"));
      String name =
          JOptionPane.showInputDialog(
              this,
              nameLabel, //	message
              Msg.getMsg(Env.getCtx(), "CreateNewNode"), // 	title
              JOptionPane.QUESTION_MESSAGE);
      if (name != null && name.length() > 0) {
        int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
        MWFNode node = new MWFNode(m_wf, name, name);
        node.setClientOrg(AD_Client_ID, 0);
        node.save();
        m_parent.load(m_wf.getAD_Workflow_ID(), true);
      }
    }
    //	Add/Delete Line
    else if (e.getSource() instanceof WFPopupItem) {
      WFPopupItem item = (WFPopupItem) e.getSource();
      item.execute();
    }
  } //	actionPerformed
示例#15
0
 /**
  * ************************************************************************ Write to file
  *
  * @param sb string buffer
  * @param fileName file name
  */
 private void writeToFile(StringBuffer sb, String fileName) {
   try {
     File out = new File(fileName);
     FileWriter fw = new FileWriter(out);
     for (int i = 0; i < sb.length(); i++) {
       char c = sb.charAt(i);
       //	after
       if (c == ';' || c == '}') {
         fw.write(c);
         if (sb.substring(i + 1).startsWith("//")) fw.write('\t');
         else fw.write(Env.NL);
       }
       //	before & after
       else if (c == '{') {
         fw.write(Env.NL);
         fw.write(c);
         fw.write(Env.NL);
       } else fw.write(c);
     }
     fw.flush();
     fw.close();
     float size = out.length();
     size /= 1024;
     log.info(out.getAbsolutePath() + " - " + size + " kB");
   } catch (Exception ex) {
     log.log(Level.SEVERE, fileName, ex);
   }
 } //	writeToFile
示例#16
0
 /**
  * Set Amount (Callout)
  *
  * @param windowNo window
  * @param columnName changed column
  */
 private void setAmt(int windowNo, String columnName) {
   //	get values
   BigDecimal ExpenseAmt = getExpenseAmt();
   int C_Currency_From_ID = getC_Currency_ID();
   int C_Currency_To_ID = getCtx().getContextAsInt("$C_Currency_ID");
   Timestamp DateExpense = getDateExpense();
   //
   log.fine("Amt=" + ExpenseAmt + ", C_Currency_ID=" + C_Currency_From_ID);
   //	Converted Amount = Unit price
   BigDecimal ConvertedAmt = ExpenseAmt;
   //	convert if required
   if (ConvertedAmt.signum() != 0 && C_Currency_To_ID != C_Currency_From_ID) {
     ConvertedAmt =
         MConversionRate.convert(
             getCtx(),
             ConvertedAmt,
             C_Currency_From_ID,
             C_Currency_To_ID,
             DateExpense,
             0,
             getAD_Client_ID(),
             getAD_Org_ID());
   }
   setConvertedAmt(ConvertedAmt);
   log.fine("ConvertedAmt=" + ConvertedAmt);
 } //	setAmt
示例#17
0
  /** Answer Button */
  private void cmd_button() {
    log.config("Activity=" + m_activity);
    if (m_activity == null) return;
    //
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserWindow.equals(node.getAction())) {
      int AD_Window_ID = node.getAD_Window_ID(); // Explicit Window
      String ColumnName = m_activity.getPO().get_TableName() + "_ID";
      int Record_ID = m_activity.getRecord_ID();
      MQuery query = MQuery.getEqualQuery(ColumnName, Record_ID);
      boolean IsSOTrx = m_activity.isSOTrx();
      //
      log.info(
          "Zoom to AD_Window_ID=" + AD_Window_ID + " - " + query + " (IsSOTrx=" + IsSOTrx + ")");

      AEnv.zoom(AD_Window_ID, query);
    } else if (MWFNode.ACTION_UserForm.equals(node.getAction())) {
      int AD_Form_ID = node.getAD_Form_ID();

      Window form = ADForm.openForm(AD_Form_ID);
      AEnv.showWindow(form);
    } else if (MWFNode.ACTION_SmartBrowse.equals(node.getAction())) {
      int AD_Browse_ID = node.getAD_Browse_ID();

      Window browse = WBrowser.openBrowse(AD_Browse_ID);
      AEnv.showWindow(browse);
    } else log.log(Level.SEVERE, "No User Action:" + node.getAction());
  } //	cmd_button
示例#18
0
 /**
  * ************************************************************************ Create Missing
  * Document Types
  *
  * @param ctx context
  * @param AD_Client_ID client
  * @param sp server process
  * @param trx transaction
  */
 public static void createDocumentTypes(Ctx ctx, int AD_Client_ID, SvrProcess sp, Trx trx) {
   s_log.info("AD_Client_ID=" + AD_Client_ID);
   String sql =
       "SELECT rl.Value, rl.Name "
           + "FROM AD_Ref_List rl "
           + "WHERE rl.AD_Reference_ID=183"
           + " AND rl.IsActive='Y' AND NOT EXISTS "
           + " (SELECT * FROM C_DocType dt WHERE dt.AD_Client_ID=? AND rl.Value=dt.DocBaseType)";
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try {
     pstmt = DB.prepareStatement(sql, trx);
     pstmt.setInt(1, AD_Client_ID);
     rs = pstmt.executeQuery();
     while (rs.next()) {
       String name = rs.getString(2);
       String value = rs.getString(1);
       s_log.config(name + "=" + value);
       MDocType dt = new MDocType(ctx, value, name, trx);
       if (dt.save()) {
         if (sp != null) sp.addLog(0, null, null, name);
         else s_log.fine(name);
       } else {
         if (sp != null) sp.addLog(0, null, null, "Not created: " + name);
         else s_log.warning("Not created: " + name);
       }
     }
   } catch (Exception e) {
     s_log.log(Level.SEVERE, sql, e);
   } finally {
     DB.closeResultSet(rs);
     DB.closeStatement(pstmt);
   }
 } //	createDocumentTypes
  /** Refresh Query */
  private void refresh() {
    String sql = m_sql;
    int pos = m_sql.lastIndexOf(" ORDER BY ");
    if (!showAll.isSelected()) {
      sql = m_sql.substring(0, pos) + s_sqlWhereSameWarehouse;
      if (s_sqlMinLife.length() > 0) sql += s_sqlMinLife;
      sql += m_sql.substring(pos);
    }
    //
    log.finest(sql);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      pstmt.setInt(1, m_M_Product_ID);
      if (!showAll.isSelected()) {
        pstmt.setInt(2, m_M_Warehouse_ID);
      }

      rs = pstmt.executeQuery();
      m_table.loadTable(rs);
    } catch (Exception e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }
    enableButtons();
  }
示例#20
0
  /**
   * Invalid Entry - Start Calculator
   *
   * @param jc parent
   * @param value value
   * @param format format
   * @param displayType display type
   * @param title title
   * @param operator optional math operator +-/*
   * @return value
   */
  public static String startCalculator(
      Container jc,
      String value,
      DecimalFormat format,
      int displayType,
      String title,
      char operator) {
    log.config("Value=" + value);
    BigDecimal startValue = new BigDecimal(0.0);
    try {
      if (value != null && value.length() > 0) {
        Number number = format.parse(value);
        startValue = new BigDecimal(number.toString());
      }
    } catch (ParseException pe) {
      log.info("InvalidEntry - " + pe.getMessage());
    }

    //	Find frame
    Frame frame = Env.getFrame(jc);
    //	Actual Call
    Calculator calc = new Calculator(frame, title, displayType, format, startValue);
    if ("*+-/%".indexOf(operator) > -1) calc.handleInput(operator);
    AEnv.showCenterWindow(frame, calc);
    BigDecimal result = calc.getNumber();
    log.config("Result=" + result);
    //
    calc = null;
    if (result != null) return format.format(result);
    else return value; // 	original value
  } //	startCalculator
示例#21
0
  /**
   * Execute Task locally and wait
   *
   * @param cmd command
   * @return execution info
   */
  public String executeLocal(String cmd) {
    log.config(cmd);
    if (m_task != null && m_task.isAlive()) m_task.interrupt();

    m_task = new Task(cmd);
    m_task.start();

    StringBuffer sb = new StringBuffer();
    while (true) {
      //  Give it a bit of time
      try {
        Thread.sleep(500);
      } catch (InterruptedException ioe) {
        log.log(Level.SEVERE, cmd, ioe);
      }
      //  Info to user
      sb.append(m_task.getOut())
          .append("\n-----------\n")
          .append(m_task.getErr())
          .append("\n-----------");

      //  Are we done?
      if (!m_task.isAlive()) break;
    }
    log.config("done");
    return sb.toString();
  } //	executeLocal
示例#22
0
 /**
  * Execute Script Loads environment and saves result
  *
  * @return null or Exception
  */
 public Exception execute() {
   m_result = null;
   if (m_variable == null
       || m_variable.length() == 0
       || m_script == null
       || m_script.length() == 0) {
     IllegalArgumentException e = new IllegalArgumentException("No variable/script");
     log.config(e.toString());
     return e;
   }
   Interpreter i = new Interpreter();
   loadEnvironment(i);
   try {
     log.config(m_script);
     i.eval(m_script);
   } catch (Exception e) {
     log.config(e.toString());
     return e;
   }
   try {
     m_result = i.get(m_variable);
     log.config("Result (" + m_result.getClass().getName() + ") " + m_result);
   } catch (Exception e) {
     log.config("Result - " + e);
     if (e instanceof NullPointerException)
       e = new IllegalArgumentException("Result Variable not found - " + m_variable);
     return e;
   }
   return null;
 } //  execute
示例#23
0
 /** Parses m_sqlOriginal and creates Array of m_sql statements */
 private void getSelectStatements() {
   String[] sqlIn = new String[] {m_sqlOriginal};
   String[] sqlOut = null;
   try {
     sqlOut = getSubSQL(sqlIn);
   } catch (Exception e) {
     log.log(Level.SEVERE, m_sqlOriginal, e);
     throw new IllegalArgumentException(m_sqlOriginal);
   }
   //	a sub-query was found
   while (sqlIn.length != sqlOut.length) {
     sqlIn = sqlOut;
     try {
       sqlOut = getSubSQL(sqlIn);
     } catch (Exception e) {
       log.log(Level.SEVERE, m_sqlOriginal, e);
       throw new IllegalArgumentException(sqlOut.length + ": " + m_sqlOriginal);
     }
   }
   m_sql = sqlOut;
   /**
    * List & check ** for (int i = 0; i < m_sql.length; i++) { if (m_sql[i].indexOf("SELECT ",2) !=
    * -1) log.log(Level.SEVERE, "#" + i + " Has embedded SQL - " + m_sql[i]); else log.fine("#" + i
    * + " - " + m_sql[i]); } /** *
    */
 } //	getSelectStatements
示例#24
0
  /** Reload/Load file */
  private void cmd_reloadFile() {
    if (m_file_istream == null) return;

    m_data.clear();
    rawData.setText("");

    try {
      //  see NaturalAccountMap

      ListItem listitem = fCharset.getSelectedItem();
      Charset charset = null;

      if (listitem == null) return;

      charset = (Charset) listitem.getValue();
      BufferedReader in = new BufferedReader(new InputStreamReader(m_file_istream, charset), 10240);

      //	not safe see p108 Network pgm
      String s = null;
      String concat = "";

      while ((s = in.readLine()) != null) {
        m_data.add(s);

        concat += s;
        concat += "\n";

        if (m_data.size() < MAX_LOADED_LINES) {
          rawData.setValue(concat);
        }
      }
      in.close();
    } catch (Exception e) {
      log.log(Level.SEVERE, "", e);
      bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
    }

    int index = 1; // 	second line as first may be heading

    if (m_data.size() == 1) index = 0;

    int length = 0;

    if (m_data.size() > 0) length = m_data.get(index).toString().length();

    info.setValue(
        Msg.getMsg(Env.getCtx(), "Records")
            + "="
            + m_data.size()
            + ", "
            + Msg.getMsg(Env.getCtx(), "Length")
            + "="
            + length
            + "   ");

    // setCursor (Cursor.getDefaultCursor());

    log.config("Records=" + m_data.size() + ", Length=" + length);
  } //	cmd_loadFile
示例#25
0
 /**
  * Model Change of a monitored Table. Called after PO.beforeSave/PO.beforeDelete when you called
  * addModelChange for the table
  *
  * @param po persistent object
  * @param type TYPE_
  * @return error message or null
  * @exception Exception if the recipient wishes the change to be not accept.
  */
 public String modelChange(PO po, int type) throws Exception {
   if (po.get_TableName().equals("C_Order") && type == TYPE_CHANGE) {
     @SuppressWarnings("unused")
     MOrder order = (MOrder) po;
     if (log.isLoggable(Level.INFO)) log.info(po.toString());
   }
   return null;
 } //	modelChange
示例#26
0
 /** Close */
 @Override
 public void close() {
   log.config(toString());
   if (m_ds != null) {
     try {
       m_ds.close();
     } catch (Exception e) {
       log.log(Level.SEVERE, "Could not close Data Source");
     }
   }
   m_ds = null;
 } //  close
示例#27
0
  /** Display. Fill Editors */
  public void display(int index) {
    log.fine("Index=" + index);
    //
    m_activity = resetDisplay(index);
    //	Nothing to show
    if (m_activity == null) {
      return;
    }
    //	Display Activity
    fNode.setText(m_activity.getNodeName());
    fDescription.setValue(m_activity.getNodeDescription());
    fHelp.setValue(m_activity.getNodeHelp());
    //
    fHistory.setContent(HISTORY_DIV_START_TAG + m_activity.getHistoryHTML() + "</div>");

    //	User Actions
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserChoice.equals(node.getAction())) {
      if (m_column == null) m_column = node.getColumn();
      if (m_column != null && m_column.get_ID() != 0) {
        fAnswerList.removeAllItems();
        int dt = m_column.getAD_Reference_ID();
        if (dt == DisplayType.YesNo) {
          ValueNamePair[] values = MRefList.getList(Env.getCtx(), 319, false); // 	_YesNo
          for (int i = 0; i < values.length; i++) {
            fAnswerList.appendItem(values[i].getName(), values[i].getValue());
          }
          fAnswerList.setVisible(true);
        } else if (dt == DisplayType.List) {
          ValueNamePair[] values =
              MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false);
          for (int i = 0; i < values.length; i++) {
            fAnswerList.appendItem(values[i].getName(), values[i].getValue());
          }
          fAnswerList.setVisible(true);
        } else //	other display types come here
        {
          fAnswerText.setText("");
          fAnswerText.setVisible(true);
        }
      }
    }
    //	--
    else if (MWFNode.ACTION_UserWindow.equals(node.getAction())
        || MWFNode.ACTION_UserForm.equals(node.getAction())) {
      fAnswerButton.setLabel(node.getName());
      fAnswerButton.setTooltiptext(node.getDescription());
      fAnswerButton.setVisible(true);
    } else log.log(Level.SEVERE, "Unknown Node Action: " + node.getAction());

    statusBar.setStatusDB((m_index + 1) + "/" + m_activities.length);
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFActivities"));
  } //	display
示例#28
0
 /**
  * Complete: running -> completed
  *
  * @return true if set to completed
  */
 public boolean complete() {
   if (log == null) log = CLogger.getCLogger(getClass());
   if (isRunning()) {
     m_state = STATE_Completed;
     log.info("completing ...");
     return true;
   }
   String msg = "complete failed: Not Running (" + getState() + ")";
   if (m_throwException) throw new IllegalStateException(msg);
   log.warning(msg);
   return false;
 } //	complete
示例#29
0
 /**
  * ************************************************************************ Start: not started ->
  * running
  *
  * @return true if set to running
  */
 public boolean start() {
   if (log == null) log = CLogger.getCLogger(getClass());
   if (isNotStarted()) {
     m_state = STATE_Running;
     log.info("starting ...");
     return true;
   }
   String msg = "start failed: Not Not Started (" + getState() + ")";
   if (m_throwException) throw new IllegalStateException(msg);
   log.warning(msg);
   return false;
 } //	start
示例#30
0
  /**
   * Create Order from Basket
   *
   * @param wu web User
   * @param wb web basket
   * @return true if created & processed
   */
  private boolean createOrder(WebUser wu, WebBasket wb) {
    m_order = new MOrder(m_ctx, 0, null);
    log.fine(
        "AD_Client_ID="
            + m_order.getAD_Client_ID()
            + ",AD_Org_ID="
            + m_order.getAD_Org_ID()
            + " - "
            + m_order);
    //
    m_order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Prepay);
    m_order.setPaymentRule(MOrder.PAYMENTRULE_CreditCard);
    m_order.setDeliveryRule(MOrder.DELIVERYRULE_AfterReceipt);
    m_order.setInvoiceRule(MOrder.INVOICERULE_Immediate);
    m_order.setIsSelfService(true);
    if (wb.getM_PriceList_ID() > 0) m_order.setM_PriceList_ID(wb.getM_PriceList_ID());
    if (wb.getSalesRep_ID() != 0) m_order.setSalesRep_ID(wb.getSalesRep_ID());

    //	BPartner
    m_order.setC_BPartner_ID(wu.getC_BPartner_ID());
    m_order.setC_BPartner_Location_ID(wu.getC_BPartner_Location_ID());
    m_order.setAD_User_ID(wu.getAD_User_ID());
    //
    m_order.setSendEMail(true);
    m_order.setDocAction(MOrder.DOCACTION_Prepare);
    m_order.saveEx();
    log.fine("ID=" + m_order.getC_Order_ID() + ", DocNo=" + m_order.getDocumentNo());

    ArrayList<WebBasketLine> lines = wb.getLines();
    for (int i = 0; i < lines.size(); i++) {
      WebBasketLine wbl = lines.get(i);
      MOrderLine ol = new MOrderLine(m_order);
      ol.setM_Product_ID(wbl.getM_Product_ID(), true);
      ol.setQty(wbl.getQuantity());
      ol.setPrice();
      ol.setPrice(wbl.getPrice());
      ol.setTax();
      ol.saveEx();
    } //	for all lines
    boolean ok = m_order.processIt(MOrder.DOCACTION_Prepare);
    m_order.saveEx();

    //	Web User = Customer
    if (!wu.isCustomer()) {
      //	log.info("-------------------------------------- " + wu.isCustomer());
      wu.setIsCustomer(true);
      wu.save();
      //	log.info("-------------------------------------- " + wu.isCustomer());
    }
    BigDecimal amt = m_order.getGrandTotal();
    log.info("Amt=" + amt);
    return ok;
  } //	createOrder