Search in sources :

Example 36 with Query

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

the class MBrowse method getFields.

/**
	 * get Fields
	 * 
	 * @return List Fields
	 */
public List<MBrowseField> getFields() {
    if (m_Fields == null) {
        final StringBuilder whereClause = new StringBuilder(MBrowseField.COLUMNNAME_AD_Browse_ID).append("=?");
        m_Fields = new Query(getCtx(), MBrowseField.Table_Name, whereClause.toString(), get_TrxName()).setParameters(get_ID()).setOnlyActiveRecords(true).setOrderBy(MBrowseField.COLUMNNAME_SeqNo).list();
    }
    return m_Fields;
}
Also used : Query(org.compiere.model.Query)

Example 37 with Query

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

the class MBrowse method getOrderByFields.

/**
	 * get Display Fields
	 * 
	 * @return List Fields
	 */
public List<MBrowseField> getOrderByFields() {
    if (m_OrderByFields == null) {
        final StringBuilder whereClause = new StringBuilder(MBrowseField.COLUMNNAME_AD_Browse_ID);
        whereClause.append("=? AND ").append(MBrowseField.COLUMNNAME_IsOrderBy).append("=? AND ").append(MBrowseField.COLUMNNAME_IsDisplayed).append("=? ");
        m_OrderByFields = new Query(getCtx(), MBrowseField.Table_Name, whereClause.toString(), get_TrxName()).setParameters(get_ID(), true, true).setOnlyActiveRecords(true).setOrderBy(MBrowseField.COLUMNNAME_SortNo).list();
    }
    return m_OrderByFields;
}
Also used : Query(org.compiere.model.Query)

Example 38 with Query

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

the class MBrowse method getDisplayFields.

/**
	 * get Display Fields
	 * 
	 * @return List Fields
	 */
public List<MBrowseField> getDisplayFields() {
    if (m_DisplayFields == null) {
        final StringBuilder whereClause = new StringBuilder(MBrowseField.COLUMNNAME_AD_Browse_ID);
        whereClause.append(" = ? AND ").append("(").append(MBrowseField.COLUMNNAME_IsDisplayed).append(" = ? ").append("OR ").append(MBrowseField.COLUMNNAME_IsIdentifier).append(" = ?").append(")");
        m_DisplayFields = new Query(getCtx(), MBrowseField.Table_Name, whereClause.toString(), get_TrxName()).setParameters(get_ID(), "Y", "Y").setOnlyActiveRecords(true).setOrderBy(MBrowseField.COLUMNNAME_SeqNo).list();
    }
    return m_DisplayFields;
}
Also used : Query(org.compiere.model.Query)

Example 39 with Query

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

the class MRelationType method retrieveRefTable.

public static MRefTable retrieveRefTable(final Properties ctx, final int referenceId, final String trxName) {
    final Object[] params = { referenceId };
    final MRefTable refTable = new Query(ctx, I_AD_Ref_Table.Table_Name, COLUMNNAME_AD_Reference_ID + "=?", trxName).setParameters(params).firstOnly();
    return refTable;
}
Also used : MQuery(org.compiere.model.MQuery) Query(org.compiere.model.Query) MRefTable(org.compiere.model.MRefTable)

Example 40 with Query

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

the class MView method getSQLFromView.

//	beforeDelete
/**
	 * get SQL from View
	 * 
	 * @param AD_View_ID
	 * @param trxName
	 * @return SQL string
	 */
public static String getSQLFromView(int AD_View_ID, String trxName) {
    StringBuffer sql = new StringBuffer();
    StringBuffer joins = new StringBuffer();
    StringBuffer cols = new StringBuffer();
    String from = "";
    MView view = new MView(Env.getCtx(), AD_View_ID, null);
    sql.append("SELECT ");
    boolean co = false;
    for (MViewDefinition def : view.getViewDefinitions()) {
        List<MViewColumn> columns = new Query(Env.getCtx(), MViewColumn.Table_Name, MViewDefinition.COLUMNNAME_AD_View_Definition_ID + "=?", trxName).setParameters(def.get_ID()).setOnlyActiveRecords(true).list();
        for (MViewColumn col : columns) {
            if (co)
                cols.append(",");
            if (col.getColumnSQL() != null && col.getColumnSQL().length() > 0) {
                cols.append(col.getColumnSQL() + " as " + col.getName());
                co = true;
            } else if (col.getColumnName() != null && col.getColumnName().length() > 0) {
                cols.append(def.getTableAlias() + "." + col.getColumnName() + " as " + col.getName());
                co = true;
            }
        }
        MTable table = new MTable(Env.getCtx(), def.getAD_Table_ID(), null);
        if (def.getJoinClause() != null && def.getJoinClause().length() > 0) {
            String jc = def.getJoinClause();
            joins.append(" ").append(jc).append(" ");
        } else
            from = table.getTableName() + " " + def.getTableAlias();
    }
    sql.append(cols).append(" from ").append(from).append(" ").append(joins);
    return sql.toString();
}
Also used : MTable(org.compiere.model.MTable) 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