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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations