Search in sources :

Example 41 with Query

use of org.compiere.model.Query in project adempiere by adempiere.

the class MWFNode method loadNext.

//	setClientOrg
/**
	 * 	Load Next
	 */
private void loadNext() {
    m_next = new Query(getCtx(), MWFNodeNext.Table_Name, "AD_WF_Node_ID=?", get_TrxName()).setParameters(new Object[] { get_ID() }).setOnlyActiveRecords(true).setOrderBy(MWFNodeNext.COLUMNNAME_SeqNo).list();
    boolean splitAnd = SPLITELEMENT_AND.equals(getSplitElement());
    for (MWFNodeNext next : m_next) {
        next.setFromSplitAnd(splitAnd);
    }
    log.fine("#" + m_next.size());
}
Also used : Query(org.compiere.model.Query)

Example 42 with Query

use of org.compiere.model.Query in project adempiere by adempiere.

the class VFactReconcile method resetReconciliation.

//	zoom
private void resetReconciliation() {
    log.info("");
    //
    miniTable.stopEditor(true);
    if (miniTable.getRowCount() == 0)
        return;
    miniTable.setRowSelectionInterval(0, 0);
    calculateSelection();
    if (m_noSelected == 0)
        return;
    for (int r = 0; r < miniTable.getModel().getRowCount(); r++) {
        if (((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).isSelected()) {
            int factId = ((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).getRecord_ID();
            MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null).setParameters(new Object[] { factId }).first();
            if (rec == null) {
                continue;
            }
            rec.setMatchCode(null);
            rec.saveEx();
            ((DefaultTableModel) miniTable.getModel()).removeRow(r--);
        }
    }
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) Query(org.compiere.model.Query) MFactReconciliation(org.compiere.model.MFactReconciliation) DefaultTableModel(javax.swing.table.DefaultTableModel)

Example 43 with Query

use of org.compiere.model.Query in project adempiere by adempiere.

the class Browser method getAxisRecordIds.

/**
	 * Get record ID for axis
	 * @param tableName
	 * @param tableWhereClause
	 * @return
	 */
private int[] getAxisRecordIds(String tableName, String tableWhereClause) {
    StringBuilder whereClause = new StringBuilder();
    StringBuilder orderBy = new StringBuilder();
    whereClause.append("EXISTS (SELECT 1 FROM AD_Table t WHERE t.TableName=? AND t.AD_Table_ID=AD_Column.AD_Table_ID) AND ");
    whereClause.append(I_AD_Column.COLUMNNAME_IsIdentifier).append("=?");
    List<MColumn> columns = new Query(Env.getCtx(), I_AD_Column.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).setParameters(tableName, true).setOrderBy(I_AD_Column.COLUMNNAME_SeqNo).list();
    int count = 1;
    for (MColumn column : columns) {
        orderBy.append(column.getColumnName());
        if (count != columns.size())
            orderBy.append(",");
        count++;
    }
    return new Query(Env.getCtx(), tableName, tableWhereClause, null).setOnlyActiveRecords(true).setOrderBy(orderBy.toString()).getIDs();
}
Also used : MColumn(org.compiere.model.MColumn) MQuery(org.compiere.model.MQuery) Query(org.compiere.model.Query)

Example 44 with Query

use of org.compiere.model.Query in project adempiere by adempiere.

the class WMRuleEngine method applyDefinition.

/**
	 * Apply Definition for Warehouse  Strategy
	 * @param inOutBoundLine Order Bound Line
	 * @param warehouseAreaTypeId Area Type Id
	 * @param warehouseSectionTypeId Section Type Id
	 * */
private MWMStrategy applyDefinition(MWMInOutBoundLine inOutBoundLine, int warehouseAreaTypeId, int warehouseSectionTypeId) {
    StringBuffer whereClause = new StringBuffer("(");
    whereClause.append(MWMDefinition.COLUMNNAME_M_Product_ID + " IN (0,?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_M_Product_ID + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_M_Product_Category_ID + " IN (0,?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_M_Product_Category_ID + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_Group1 + " IN ('',?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_Group1 + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_Group2 + " IN ('',?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_Group2 + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_Classification + " IN ('',?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_Classification + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_C_BPartner_ID + " IN (0,?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_C_BPartner_ID + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_C_BP_Group_ID + " IN (0,?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_C_BP_Group_ID + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_WM_Area_Type_ID + " IN (0,?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_WM_Area_Type_ID + " IS NULL");
    whereClause.append(") AND ");
    whereClause.append("(");
    whereClause.append(MWMDefinition.COLUMNNAME_WM_Section_Type_ID + " IN (0,?) OR ");
    whereClause.append(MWMDefinition.COLUMNNAME_WM_Section_Type_ID + " IS NULL");
    whereClause.append(")");
    whereClause.append(" AND EXISTS (SELECT 1 FROM " + MWMStrategy.Table_Name);
    whereClause.append(" WHERE ");
    whereClause.append(MWMStrategy.Table_Name + "." + MWMStrategy.COLUMNNAME_WM_Strategy_ID + "=");
    whereClause.append(MWMDefinition.Table_Name + "." + MWMDefinition.COLUMNNAME_WM_Strategy_ID);
    whereClause.append(" AND ");
    whereClause.append(MWMStrategy.COLUMNNAME_InOutBoundType + "=?");
    whereClause.append(")");
    MProduct product = inOutBoundLine.getMProduct();
    MBPartner partner = inOutBoundLine.getBPartner();
    MWMDefinition definition = new Query(inOutBoundLine.getCtx(), MWMDefinition.Table_Name, whereClause.toString(), inOutBoundLine.get_TrxName()).setClient_ID().setParameters(product.getM_Product_ID(), product.getM_Product_Category_ID(), product.getGroup1(), product.getGroup2(), product.getClassification(), partner.getC_BPartner_ID(), partner.getC_BP_Group_ID(), warehouseAreaTypeId, warehouseSectionTypeId, MWMStrategy.INOUTBOUNDTYPE_OutboundOperation).first();
    if (definition == null) {
        throw new AdempiereException("@WM_Definition_ID@ @NotFound@");
    }
    return definition.getWarehouseStrategy();
}
Also used : MProduct(org.compiere.model.MProduct) Query(org.compiere.model.Query) AdempiereException(org.adempiere.exceptions.AdempiereException) MWMDefinition(org.eevolution.model.MWMDefinition) MBPartner(org.compiere.model.MBPartner)

Example 45 with Query

use of org.compiere.model.Query in project adempiere by adempiere.

the class ExpressReceiptScanBar method getInOutBoundLines.

private List<MWMInOutBoundLine> getInOutBoundLines() {
    StringBuilder whereClause = new StringBuilder();
    whereClause.append(MWMInOutBoundLine.COLUMNNAME_WM_InOutBound_ID).append("=?");
    return new Query(Env.getCtx(), MWMInOutBoundLine.Table_Name, whereClause.toString(), null).setClient_ID().setParameters(getRecord_ID()).list();
}
Also used : Query(org.compiere.model.Query)

Aggregations

Query (org.compiere.model.Query)212 ArrayList (java.util.ArrayList)49 BigDecimal (java.math.BigDecimal)25 Properties (java.util.Properties)22 MProduct (org.compiere.model.MProduct)20 AdempiereException (org.adempiere.exceptions.AdempiereException)13 MTable (org.compiere.model.MTable)12 MOrderLine (org.compiere.model.MOrderLine)8 MWarehouse (org.compiere.model.MWarehouse)8 PO (org.compiere.model.PO)8 MBPartner (org.compiere.model.MBPartner)6 MQuery (org.compiere.model.MQuery)6 MPPProductBOM (org.eevolution.model.MPPProductBOM)6 MColumn (org.compiere.model.MColumn)5 MLocation (org.compiere.model.MLocation)5 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)5 SQLException (java.sql.SQLException)4 Timestamp (java.sql.Timestamp)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 MClient (org.compiere.model.MClient)4