/**
  * 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
Example #2
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
Example #3
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
 /**
  * ************************************************************************ 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
 /**
  * ************************************************************************ 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
  /**
   * Table selection changed
   *
   * @param e event
   */
  public void valueChanged(ListSelectionEvent e) {
    m_M_AttributeSetInstance_ID = -1;
    m_M_AttributeSetInstanceName = null;
    m_M_Locator_ID = 0;

    int row = m_table.getSelectedRow();
    if (row > -1) {
      Integer ID = m_table.getSelectedRowKey();
      if (ID != null) {
        m_M_AttributeSetInstance_ID = ID.intValue();
        m_M_AttributeSetInstanceName = (String) m_table.getValueAt(row, 1);
        //
        Object oo = m_table.getValueAt(row, 5);
        if (oo instanceof KeyNamePair) {
          KeyNamePair pp = (KeyNamePair) oo;
          m_M_Locator_ID = pp.getKey();
        }
      }
    }
    log.fine(
        "M_AttributeSetInstance_ID="
            + m_M_AttributeSetInstance_ID
            + " - "
            + m_M_AttributeSetInstanceName
            + "; M_Locator_ID="
            + m_M_Locator_ID);

    enableButtons();
  }
Example #7
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
Example #8
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
Example #9
0
  /**
   * Add Editor to parameterPanel alernative right/left depending on m_newRow. Field Value changes
   * update Editors
   *
   * @param field field
   * @param editor editor
   * @param mandatory mandatory
   */
  private void addLine(GridField field, VEditor editor, boolean mandatory) {
    log.fine("Field=" + field);
    JLabel label = VEditorFactory.getLabel(field);
    label.setLabelFor((Component) editor);
    editor.setReadWrite(true);
    editor.setMandatory(mandatory);
    //  MField => VEditor
    field.addPropertyChangeListener(editor);

    //	label
    if (m_newRow) {
      m_gbc.gridy = m_line++;
      m_gbc.gridx = 0;
    } else m_gbc.gridx = 2;
    m_gbc.insets = m_labelInsets;
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    m_gbc.weightx = 0;
    parameterPanel.add(label, m_gbc);

    //	Field
    if (m_newRow) m_gbc.gridx = 1;
    else m_gbc.gridx = 3;
    m_gbc.insets = m_fieldInsets;
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    m_gbc.weightx = 1;
    parameterPanel.add((Component) editor, m_gbc);
    //
    m_newRow = !m_newRow;
  } //	addLine
Example #10
0
 /**
  * ************************************************************************ Start Workflow.
  *
  * @param AD_Workflow_ID workflow
  * @return true if started
  */
 private boolean startWorkflow(int AD_Workflow_ID) {
   log.fine(AD_Workflow_ID + " - " + m_pi);
   boolean started = false;
   if (DB.isRemoteProcess()) {
     log.info("trying to running on the server");
     Server server = CConnection.get().getServer();
     try {
       if (server != null) { // 	See ServerBean
         log.info("running on the server");
         m_pi = server.workflow(m_wscctx, m_pi, AD_Workflow_ID);
         log.finest("server => " + m_pi);
         started = true;
       }
     } catch (Exception ex) {
       log.log(Level.SEVERE, "AppsServer error", ex);
       started = false;
     }
   }
   //	Run locally
   if (!started && !m_IsServerProcess) {
     log.info("running locally");
     MWorkflow wf = MWorkflow.get(m_wscctx, AD_Workflow_ID);
     MWFProcess wfProcess = null;
     if (m_pi.isBatch()) wfProcess = wf.start(m_pi); // 	may return null
     else wfProcess = wf.startWait(m_pi); // 	may return null
     started = wfProcess != null;
   }
   return started;
 } //  startWorkflow
Example #11
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
Example #12
0
 /**
  * Set Line Net Amt Difference
  *
  * @param diff difference (to be subtracted)
  */
 public void setLineNetAmtDifference(BigDecimal diff) {
   String msg = "Diff=" + diff + " - LineNetAmt=" + m_LineNetAmt;
   m_LineNetAmt = m_LineNetAmt.subtract(diff);
   m_DiscountAmt = m_ListAmt.subtract(m_LineNetAmt);
   setAmount(m_ListAmt, m_DiscountAmt);
   msg += " -> " + m_LineNetAmt;
   log.fine(msg);
 } //	setLineNetAmtDifference
  /**
   * Given <code>aKey</code> and the model, returns the row that should become selected. Return -1
   * if no match was found.
   *
   * @param key a char value, usually indicating a keyboard key that was pressed
   * @param model a ComboBoxModel -- the component's data model, containing the list of selectable
   *     items
   * @return an int equal to the selected row, where 0 is the first item and -1 is none
   */
  public int selectionForKey(char key, ComboBoxModel model) {
    log.fine("Key=" + key);
    //
    int currentSelection = -1;
    Object selectedItem = model.getSelectedItem();

    return 0;
  } //	selectionForKey
Example #14
0
 /** Fill Table */
 private Vector<Vector<Object>> fillTable(String sql, int parameter) {
   if (log.isLoggable(Level.FINE)) log.fine(sql + "; Parameter=" + parameter);
   Vector<Vector<Object>> data = new Vector<Vector<Object>>();
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try {
     pstmt = DB.prepareStatement(sql, null);
     pstmt.setInt(1, parameter);
     rs = pstmt.executeQuery();
     while (rs.next()) {
       Vector<Object> line = new Vector<Object>(6);
       //	0-Name, 1-PriceActual, 2-QtyInvoiced, 3-Discount, 4-DocumentNo, 5-DateInvoiced
       line.add(rs.getString(1)); //  Name
       line.add(rs.getBigDecimal(2)); // 	Price
       line.add(rs.getString(3)); // 	Currency
       line.add(new Double(rs.getDouble(5))); //  Qty
       BigDecimal discountBD = rs.getBigDecimal(9);
       if (discountBD == null) {
         double priceList = rs.getDouble(4);
         double priceActual = rs.getDouble(2);
         if (priceList != 0) {
           discountBD = BigDecimal.valueOf((priceList - priceActual) / priceList * 100);
           // Rounding:
           int precision = MPriceList.getStandardPrecision(Env.getCtx(), rs.getInt(10));
           if (discountBD.scale() > precision)
             discountBD = discountBD.setScale(precision, RoundingMode.HALF_UP);
         } else discountBD = Env.ZERO;
       }
       line.add(discountBD); //  Discount
       line.add(rs.getString(7)); //  DocNo
       line.add(rs.getTimestamp(6)); //  Date
       line.add(rs.getString(8)); // 	Org/Warehouse
       data.add(line);
     }
   } catch (SQLException e) {
     log.log(Level.SEVERE, sql, e);
   } finally {
     DB.close(rs, pstmt);
     rs = null;
     pstmt = null;
   }
   if (log.isLoggable(Level.FINE)) log.fine("#" + data.size());
   return data;
 } //	fillTable
 @Override
 public void actionPerformed(ActionEvent e) {
   log.fine("actionPerformed - Text:" + getHtmlText());
   if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
     m_text = editor.getHtmlText();
     m_isPressedOK = true;
     dispose();
   } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
     dispose();
   }
 }
 /** Create Lines. Called by WF Layout Manager */
 protected void createLines() {
   log.fine("Lines #" + m_lines.size());
   for (int i = 0; i < m_lines.size(); i++) {
     WFLine line = (WFLine) m_lines.get(i);
     Rectangle from = findBounds(line.getAD_WF_Node_ID());
     Rectangle to = findBounds(line.getAD_WF_Next_ID());
     line.setFromTo(from, to);
     //	same bounds as parent
     //	line.setBounds(0,0, width, height);
   } //	for all lines
 }
Example #17
0
 public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   log.fine("doGet");
   WWindowStatus ws = WWindowStatus.get(request);
   WebDoc doc = null;
   if (ws == null) {
     doc = WebDoc.createPopup("No Context");
     doc.addPopupClose(Env.getCtx());
   } else doc = ws.mWindow.getHelpDoc(false);
   WebUtil.createResponse(request, response, this, null, doc, false);
 }
Example #18
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
Example #19
0
 /**
  * ************************************************************************ Start Java Process
  * Class. instanciate the class implementing the interface ProcessCall. The class can be a
  * Server/Client class (when in Package org compiere.process or org.compiere.model) or a client
  * only class (e.g. in org.compiere.report)
  *
  * @return true if success
  */
 private boolean startProcess() {
   log.fine(m_pi.toString());
   boolean started = false;
   if (DB.isRemoteProcess()) {
     Server server = CConnection.get().getServer();
     try {
       if (server != null) { // 	See ServerBean
         m_pi = server.process(m_wscctx, m_pi);
         log.finest("server => " + m_pi);
         started = true;
       }
     } catch (UndeclaredThrowableException ex) {
       Throwable cause = ex.getCause();
       if (cause != null) {
         if (cause instanceof InvalidClassException)
           log.log(
               Level.SEVERE, "Version Server <> Client: " + cause.toString() + " - " + m_pi, ex);
         else
           log.log(Level.SEVERE, "AppsServer error(1b): " + cause.toString() + " - " + m_pi, ex);
       } else log.log(Level.SEVERE, " AppsServer error(1) - " + m_pi, ex);
       started = false;
     } catch (Exception ex) {
       Throwable cause = ex.getCause();
       if (cause == null) cause = ex;
       log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause);
       started = false;
     }
   }
   //	Run locally
   if (!started && !m_IsServerProcess) {
     ProcessCall myObject = null;
     try {
       Class myClass = Class.forName(m_pi.getClassName());
       myObject = (ProcessCall) myClass.newInstance();
       if (myObject == null) m_pi.setSummary("No Instance for " + m_pi.getClassName(), true);
       else myObject.startProcess(m_wscctx, m_pi, m_trx);
       if (m_trx != null) {
         m_trx.commit();
         m_trx.close();
       }
     } catch (Exception e) {
       if (m_trx != null) {
         m_trx.rollback();
         m_trx.close();
       }
       m_pi.setSummary("Error starting Class " + m_pi.getClassName(), true);
       log.log(Level.SEVERE, m_pi.getClassName(), e);
     }
   }
   return !m_pi.isError();
 } //  startProcess
 private void verifyChangedField(GridField field, String columnName) {
   ArrayList<String> list = field.getDependentOn();
   if (list.contains(columnName)) {
     if (field.getLookup() instanceof MLookup) {
       MLookup mLookup = (MLookup) field.getLookup();
       // if the lookup is dynamic (i.e. contains this columnName as variable)
       if (mLookup.getValidation().indexOf("@" + columnName + "@") != -1) {
         log.fine(columnName + " changed - " + field.getColumnName() + " set to null");
         // invalidate current selection
         field.setValue(null, true);
       }
     }
   }
 }
  /**
   * Receive notification of the end of an element.
   *
   * @param uri namespace
   * @param localName simple name
   * @param qName qualified name
   * @throws SAXException
   */
  public void endElement(String uri, String localName, String qName) throws SAXException {
    //	Log.trace(Log.l6_Database+1, "TranslationHandler.endElement", qName);
    if (qName.equals(Translation.XML_TAG)
        || qName.equals(Translation.XML_TAG2)
        || qName.equals(Translation.XML_TAG3)) {

    } else if (qName.equals(Translation.XML_ROW_TAG)) {
      //	Set section
      if (m_sql.length() > 0) m_sql.append(",");
      m_sql.append("Updated=").append(DB.TO_DATE(m_time, false));
      if (!m_isBaseLanguage) {
        if (m_trl != null && ("Y".equals(m_trl) || "N".equals(m_trl)))
          m_sql.append(",IsTranslated='").append(m_trl).append("'");
        else m_sql.append(",IsTranslated='Y'");
      }
      //	Where section
      m_sql.append(" WHERE ");
      if (m_curUUID != null) {
        StringBuilder sql =
            new StringBuilder("SELECT ")
                .append(m_TableName)
                .append("_ID")
                .append(" FROM ")
                .append(m_TableName)
                .append(" WHERE ")
                .append(m_TableName)
                .append("_UU =?");
        int ID = DB.getSQLValueEx(null, sql.toString(), m_curUUID);
        m_sql.append(m_TableName).append("_ID=").append(ID);
      } else {
        m_sql.append(m_TableName).append("_ID=").append(m_curID);
      }
      if (!m_isBaseLanguage) m_sql.append(" AND AD_Language='").append(m_AD_Language).append("'");
      if (m_AD_Client_ID >= 0) m_sql.append(" AND AD_Client_ID=").append(m_AD_Client_ID);
      //	Update section
      m_sql.insert(0, m_updateSQL);

      //	Execute
      int no = DB.executeUpdate(m_sql.toString(), null);
      if (no == 1) {
        if (log.isLoggable(Level.FINE)) log.fine(m_sql.toString());
        m_updateCount++;
      } else if (no == 0) log.warning("Not Found - " + m_sql.toString());
      else log.severe("Update Rows=" + no + " (Should be 1) - " + m_sql.toString());
    } else if (qName.equals(Translation.XML_VALUE_TAG)) {
      if (m_sql.length() > 0) m_sql.append(",");
      m_sql.append(m_curColumnName).append("=").append(DB.TO_STRING(m_curValue.toString()));
    }
  } //	endElement
  @Override
  public void setValue(Object value) {
    if (value == null || NO_INSTANCE.equals(value)) {
      getComponent().setText("");
      m_value = value;
      return;
    }

    //	The same
    if (value.equals(m_value)) return;
    //	new value
    log.fine("Value=" + value);
    m_value = value;
    getComponent().setText(m_mPAttribute.getDisplay(value)); // 	loads value
  }
Example #23
0
 /**
  * Parse Original SQL. Called from setSql or Constructor.
  *
  * @return true if pased
  */
 public boolean parse() {
   if (m_sqlOriginal == null || m_sqlOriginal.length() == 0)
     throw new IllegalArgumentException("No SQL");
   //
   //	if (CLogMgt.isLevelFinest())
   //		log.fine(m_sqlOriginal);
   getSelectStatements();
   //	analyse each select
   for (int i = 0; i < m_sql.length; i++) {
     TableInfo[] info = getTableInfo(m_sql[i].trim());
     m_tableInfo.add(info);
   }
   //
   if (CLogMgt.isLevelFinest()) log.fine(toString());
   return m_tableInfo.size() > 0;
 } //	parse
Example #24
0
 /** Process the HTTP Get request */
 public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   log.fine("doGet");
   WebSessionCtx wsc = WebSessionCtx.get(request);
   WWindowStatus ws = WWindowStatus.get(request);
   //
   WebDoc doc = null;
   if (ws == null) {
     doc = WebDoc.createPopup("No Context");
     doc.addPopupClose(wsc.ctx);
   } else {
     doc = CreateChatPage(ws, wsc, doc, 0);
   }
   //
   WebUtil.createResponse(request, response, this, null, doc, false);
 } //  doGet
Example #25
0
  /**
   * Set Resource Assignment - Callout
   *
   * @param oldS_ResourceAssignment_ID old value
   * @param newS_ResourceAssignment_ID new value
   * @param windowNo window
   * @throws Exception
   */
  @UICallout
  public void setS_ResourceAssignment_ID(
      String oldS_ResourceAssignment_ID, String newS_ResourceAssignment_ID, int windowNo)
      throws Exception {
    if (newS_ResourceAssignment_ID == null || newS_ResourceAssignment_ID.length() == 0) return;
    int S_ResourceAssignment_ID = Integer.parseInt(newS_ResourceAssignment_ID);
    if (S_ResourceAssignment_ID == 0) return;
    //
    super.setS_ResourceAssignment_ID(S_ResourceAssignment_ID);

    int M_Product_ID = 0;
    String Name = null;
    String Description = null;
    BigDecimal Qty = null;
    String sql =
        "SELECT p.M_Product_ID, ra.Name, ra.Description, ra.Qty "
            + "FROM S_ResourceAssignment ra"
            + " INNER JOIN M_Product p ON (p.S_Resource_ID=ra.S_Resource_ID) "
            + "WHERE ra.S_ResourceAssignment_ID=?";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, get_Trx());
      pstmt.setInt(1, S_ResourceAssignment_ID);
      rs = pstmt.executeQuery();
      if (rs.next()) {
        M_Product_ID = rs.getInt(1);
        Name = rs.getString(2);
        Description = rs.getString(3);
        Qty = rs.getBigDecimal(4);
      }
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
    log.fine(
        "S_ResourceAssignment_ID=" + S_ResourceAssignment_ID + " - M_Product_ID=" + M_Product_ID);
    if (M_Product_ID != 0) {
      setM_Product_ID(M_Product_ID);
      if (Description != null) Name += " (" + Description + ")";
      if (!".".equals(Name)) setDescription(Name);
      if (Qty != null) setQty(Qty);
    }
  } //	setS_ResourceAssignment_ID
Example #26
0
 /**
  * ************************************************************************ Start Database Process
  *
  * @param ProcedureName PL/SQL procedure name
  * @return true if success
  */
 private boolean startDBProcess(String ProcedureName) {
   //  execute on this thread/connection
   log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")");
   String sql = "{call " + ProcedureName + "(?)}";
   try {
     CallableStatement cstmt = DB.prepareCall(sql, ResultSet.CONCUR_UPDATABLE, null); // 	ro??
     cstmt.setInt(1, m_pi.getAD_PInstance_ID());
     cstmt.executeUpdate();
     cstmt.close();
   } catch (Exception e) {
     log.log(Level.SEVERE, sql, e);
     m_pi.setSummary(Msg.getMsg(m_wscctx, "ProcessRunError") + " " + e.getLocalizedMessage());
     m_pi.setError(true);
     return false;
   }
   //	log.fine(Log.l4_Data, "ProcessCtl.startProcess - done");
   return true;
 } //  startDBProcess
Example #27
0
 /**
  * After Save
  *
  * @param newRecord new
  * @param success success
  * @return success
  */
 @Override
 protected boolean afterSave(boolean newRecord, boolean success) {
   if (newRecord) {
     //	SELECT Value FROM AD_Ref_List WHERE AD_Reference_ID=183
     MDocType[] types = MDocType.getOfClient(getCtx());
     int count = 0;
     ArrayList<String> baseTypes = new ArrayList<String>();
     for (MDocType type : types) {
       String DocBaseType = type.getDocBaseType();
       if (baseTypes.contains(DocBaseType)) continue;
       MPeriodControl pc = new MPeriodControl(this, DocBaseType);
       if (pc.save()) count++;
       baseTypes.add(DocBaseType);
     }
     log.fine("PeriodControl #" + count);
   }
   return success;
 } //	afterSave
Example #28
0
 /**
  * Get SalesRegion. - get Sales Region from BPartner
  *
  * @return C_SalesRegion_ID
  */
 public int getC_SalesRegion_ID() {
   if (m_C_SalesRegion_ID == -1) // 	never tried
   {
     if (getC_BPartner_Location_ID() != 0)
     //	&& m_acctSchema.isAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_SalesRegion))
     {
       String sql =
           "SELECT COALESCE(C_SalesRegion_ID,0) FROM C_BPartner_Location WHERE C_BPartner_Location_ID=?";
       m_C_SalesRegion_ID = DB.getSQLValue(null, sql, getC_BPartner_Location_ID());
       if (log.isLoggable(Level.FINE))
         log.fine("C_SalesRegion_ID=" + m_C_SalesRegion_ID + " (from BPL)");
       if (m_C_SalesRegion_ID == 0) m_C_SalesRegion_ID = -2; // 	don't try again
     } else m_C_SalesRegion_ID = -2; // 	don't try again
   }
   if (m_C_SalesRegion_ID < 0) // 	invalid
   return 0;
   return m_C_SalesRegion_ID;
 } //  getC_SalesRegion_ID
 /**
  * WMRule factory instance
  *
  * @return document factory instance
  */
 public ForecastRule getForecastRuleFactory(String className) {
   if (m_ForecastRules.containsKey(className)) {
     return (ForecastRule) m_ForecastRules.get(className);
   }
   // Check negative cache:
   /*
    * if (s_RuleNoImplement.contains(rule.getInOutboundClass())) {
    * log.info("Ignore "+rule.getInOutboundClass()+
    * " doesn't have accounting implementation (WMRule* class)"); }
    */
   //
   try {
     Class<? extends ForecastRule> cl = getClass(className);
     //
     // Check <constructor>():
     Constructor<?> constructor = null;
     try {
       constructor = cl.getDeclaredConstructor();
     } catch (Exception e) {
       log.fine("Not found <ForecastRule>()");
     }
     if (constructor != null) {
       ForecastRule rule = (ForecastRule) constructor.newInstance();
       m_ForecastRules.put(className, rule);
       return rule;
     }
     //
     // Check <constructor>():
     constructor = cl.getDeclaredConstructor();
     ForecastRule rule = (ForecastRule) constructor.newInstance();
     m_ForecastRules.put(className, rule);
     return rule;
   } catch (ClassNotFoundException e) {
     s_RuleNoImplement.add(className); // Add to negative cache (won't
     // try to load again)
   } catch (Throwable e) {
     throw new AdempiereException(e);
   }
   return null;
 }
Example #30
0
 /**
  * Load Information
  *
  * @param C_ValidCombination_ID valid combination
  * @param C_AcctSchema_ID acct schema
  */
 private void loadInfo(int C_ValidCombination_ID, int C_AcctSchema_ID) {
   log.fine("C_ValidCombination_ID=" + C_ValidCombination_ID);
   String sql =
       "SELECT * FROM C_ValidCombination WHERE C_ValidCombination_ID=? AND C_AcctSchema_ID=?";
   try {
     PreparedStatement pstmt = DB.prepareStatement(sql, null);
     pstmt.setInt(1, C_ValidCombination_ID);
     pstmt.setInt(2, C_AcctSchema_ID);
     ResultSet rs = pstmt.executeQuery();
     if (rs.next()) {
       if (f_Alias != null) f_Alias.setValue(rs.getString("Alias"));
       f_Combination.setValue(rs.getString("Combination"));
       //
       loadInfoOf(rs, f_AD_Org_ID, "AD_Org_ID");
       loadInfoOf(rs, f_Account_ID, "Account_ID");
       loadInfoOf(rs, f_SubAcct_ID, "C_SubAcct_ID");
       //
       loadInfoOf(rs, f_M_Product_ID, "M_Product_ID");
       loadInfoOf(rs, f_C_BPartner_ID, "C_BPartner_ID");
       loadInfoOf(rs, f_C_Campaign_ID, "C_Campaign_ID");
       loadInfoOf(rs, f_C_LocFrom_ID, "C_LocFrom_ID");
       loadInfoOf(rs, f_C_LocTo_ID, "C_LocTo_ID");
       loadInfoOf(rs, f_C_Project_ID, "C_Project_ID");
       loadInfoOf(rs, f_C_SalesRegion_ID, "C_SalesRegion_ID");
       loadInfoOf(rs, f_AD_OrgTrx_ID, "AD_OrgTrx_ID");
       loadInfoOf(rs, f_C_Activity_ID, "C_Activity_ID");
       loadInfoOf(rs, f_User1_ID, "User1_ID");
       loadInfoOf(rs, f_User2_ID, "User2_ID");
       //
       f_Description.setText(rs.getString("Description"));
     }
     rs.close();
     pstmt.close();
   } catch (SQLException e) {
     log.log(Level.SEVERE, sql, e);
   }
 } //	loadInfo