Package org.compiere.model
Class MQuery
- java.lang.Object
-
- org.compiere.model.MQuery
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class MQuery extends Object implements Serializable, Cloneable
Query Descriptor. Maintains restrictions (WHERE clause)- Version:
- $Id: MQuery.java,v 1.4 2006/07/30 00:58:04 jjanke Exp $
- Author:
- Jorg Janke, Teo Sarca
- BF [ 2860022 ] MQuery.get() is generating restrictions for non-existent column https://sourceforge.net/p/adempiere/bugs/2099/
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BETWEEN
Betweenstatic int
BETWEEN_INDEX
Between - 8static String
EQUAL
Equalstatic int
EQUAL_INDEX
Equal - 0static String
GREATER
Greaterstatic String
GREATER_EQUAL
Greater Equalstatic String
LESS
Lessstatic String
LESS_EQUAL
Less Equalstatic String
LIKE
Likestatic String
MSG_BETWEEN
static String
MSG_EQUAL
static String
MSG_GREATER
static String
MSG_GREATER_EQUAL
static String
MSG_LESS
static String
MSG_LESS_EQUAL
static String
MSG_LIKE
static String
MSG_NOT_EQUAL
static String
MSG_NOT_LIKE
static String
MSG_NOT_NULL
static String
MSG_NULL
static String
NOT_EQUAL
Not Equalstatic int
NOT_EQUAL_INDEX
Not Equal - 1static String
NOT_LIKE
Not Likestatic String
NOT_NULL
For IDEMPIERE-377static String
NULL
For IDEMPIERE-377static ValueNamePair[]
OPERATORS
All the Operatorsstatic ValueNamePair[]
OPERATORS_DATES
Operators for Datesstatic ValueNamePair[]
OPERATORS_ENCRYPTED
Operators for encrypted fieldsstatic ValueNamePair[]
OPERATORS_LOOKUP
Operators for Lookups and Lists (including Y/N)static ValueNamePair[]
OPERATORS_NUMBERS
Operators for Numbers, Integersstatic ValueNamePair[]
OPERATORS_STRINGS
Operators for Strings
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRangeRestriction(String ColumnName, Object Code, Object Code_to)
Add Range Restriction (BETWEEN)void
addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to)
Add Range Restriction (BETWEEN)void
addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to, boolean andCondition, boolean notCondition, int depth)
Add Range Restriction (BETWEEN)void
addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to, boolean andCondition, int depth)
Add Range Restriction (BETWEEN)void
addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to, String andOrCondition, int depth)
Add Range Restriction (BETWEEN)void
addRestriction(String whereClause)
Add Restrictionvoid
addRestriction(String whereClause, boolean andCondition, boolean notCondition, boolean existsCondition, int joinDepth)
Add Restrictionvoid
addRestriction(String whereClause, boolean andCondition, boolean notCondition, int joinDepth)
Add Restrictionvoid
addRestriction(String whereClause, boolean andCondition, int joinDepth)
Add Restrictionvoid
addRestriction(String whereClause, int joinDepth, String andOrCondition)
Add Restrictionvoid
addRestriction(String ColumnName, String Operator, int Code)
Add Restrictionvoid
addRestriction(String ColumnName, String Operator, Object Code)
Add Restrictionvoid
addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay)
Add Restrictionvoid
addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, boolean notCondition, int depth)
Add Restrictionvoid
addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, int depth)
Add Restrictionvoid
addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, String andOrCondition, int depth)
Add Restrictionvoid
addRestriction(String whereClause, String Operator, String InfoName, String InfoDisplay)
protected void
addRestriction(org.compiere.model.Restriction r)
Add RestrictionMQuery
clone()
MQuery
deepCopy()
Clone Querystatic MQuery
get(Properties ctx, int AD_PInstance_ID, String TableName)
Get Query from Parameterint
getAD_PInstance_ID()
Object
getCode(int index)
Get Operator of indexObject
getCode_to(int index)
Get Operator of indexString
getColumnName(int index)
Get ColumnName of indexString
getDisplayName(Properties ctx)
Get Display Namestatic MQuery
getEqualQuery(String columnName, int value)
Create simple Equal Query.static MQuery
getEqualQuery(String columnName, Object value)
Create simple Equal Query.String
getInfo()
Get printable Query InfoString
getInfoDisplay(int index)
Get Restriction Display of indexString
getInfoDisplay_to(int index)
Get TO Restriction Display of indexString
getInfoDisplayAll(int index)
Get Display with optional ToString
getInfoName(int index)
Get Info NameString
getInfoOperator(int index)
Get Info Operatorstatic MQuery
getNoRecordQuery(String tableName, boolean newRecord)
Create No Record query.String
getOperator(int index)
Get Operator of indexint
getRecordCount()
Get Record CountMQuery
getReportProcessQuery()
int
getRestrictionCount()
Get Restriction CountString
getRestrictionSQL(String ColumnName, Object Code, Object Code_To, String InfoName, String InfoDisplay, String InfoDisplay_To, boolean andCondition, int depth)
String
getRestrictionSQL(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, int depth)
String
getTableName()
Get Table NameString
getWhereClause()
Create the resulting Query WHERE ClauseString
getWhereClause(boolean fullyQualified)
Create the resulting Query WHERE ClauseString
getWhereClause(int index)
Create Query WHERE Clause.String
getZoomColumnName()
static String
getZoomColumnName(String columnName)
Get Zoom Column Name.String
getZoomTableName()
static String
getZoomTableName(String columnName)
Derive Zoom Table Name from column name.Object
getZoomValue()
int
getZoomWindowID()
boolean
isActive()
Is Query Activeboolean
isNewRecordQuery()
New Record Queryprotected void
setColumnName(int index, String ColumnName)
Set ColumnName of indexvoid
setRecordCount(int count)
Set Record Countvoid
setReportProcessQuery(MQuery query)
void
setTableName(String TableName)
Set Table Namevoid
setZoomColumnName(String column)
void
setZoomTableName(String tableName)
void
setZoomValue(Object value)
void
setZoomWindowID(int m_zoomWindow_ID)
String
toString()
String representation
-
-
-
Field Detail
-
EQUAL
public static final String EQUAL
Equal- See Also:
- Constant Field Values
-
MSG_EQUAL
public static final String MSG_EQUAL
- See Also:
- Constant Field Values
-
EQUAL_INDEX
public static final int EQUAL_INDEX
Equal - 0- See Also:
- Constant Field Values
-
NOT_EQUAL
public static final String NOT_EQUAL
Not Equal- See Also:
- Constant Field Values
-
MSG_NOT_EQUAL
public static final String MSG_NOT_EQUAL
- See Also:
- Constant Field Values
-
NOT_EQUAL_INDEX
public static final int NOT_EQUAL_INDEX
Not Equal - 1- See Also:
- Constant Field Values
-
LIKE
public static final String LIKE
Like- See Also:
- Constant Field Values
-
MSG_LIKE
public static final String MSG_LIKE
- See Also:
- Constant Field Values
-
NOT_LIKE
public static final String NOT_LIKE
Not Like- See Also:
- Constant Field Values
-
MSG_NOT_LIKE
public static final String MSG_NOT_LIKE
- See Also:
- Constant Field Values
-
GREATER
public static final String GREATER
Greater- See Also:
- Constant Field Values
-
MSG_GREATER
public static final String MSG_GREATER
- See Also:
- Constant Field Values
-
GREATER_EQUAL
public static final String GREATER_EQUAL
Greater Equal- See Also:
- Constant Field Values
-
MSG_GREATER_EQUAL
public static final String MSG_GREATER_EQUAL
- See Also:
- Constant Field Values
-
LESS
public static final String LESS
Less- See Also:
- Constant Field Values
-
MSG_LESS
public static final String MSG_LESS
- See Also:
- Constant Field Values
-
LESS_EQUAL
public static final String LESS_EQUAL
Less Equal- See Also:
- Constant Field Values
-
MSG_LESS_EQUAL
public static final String MSG_LESS_EQUAL
- See Also:
- Constant Field Values
-
BETWEEN
public static final String BETWEEN
Between- See Also:
- Constant Field Values
-
MSG_BETWEEN
public static final String MSG_BETWEEN
- See Also:
- Constant Field Values
-
BETWEEN_INDEX
public static final int BETWEEN_INDEX
Between - 8- See Also:
- Constant Field Values
-
NOT_NULL
public static final String NOT_NULL
For IDEMPIERE-377- See Also:
- Constant Field Values
-
MSG_NOT_NULL
public static final String MSG_NOT_NULL
- See Also:
- Constant Field Values
-
NULL
public static final String NULL
For IDEMPIERE-377- See Also:
- Constant Field Values
-
MSG_NULL
public static final String MSG_NULL
- See Also:
- Constant Field Values
-
OPERATORS
public static final ValueNamePair[] OPERATORS
All the Operators
-
OPERATORS_STRINGS
public static final ValueNamePair[] OPERATORS_STRINGS
Operators for Strings
-
OPERATORS_LOOKUP
public static final ValueNamePair[] OPERATORS_LOOKUP
Operators for Lookups and Lists (including Y/N)
-
OPERATORS_ENCRYPTED
public static final ValueNamePair[] OPERATORS_ENCRYPTED
Operators for encrypted fields
-
OPERATORS_NUMBERS
public static final ValueNamePair[] OPERATORS_NUMBERS
Operators for Numbers, Integers
-
OPERATORS_DATES
public static final ValueNamePair[] OPERATORS_DATES
Operators for Dates
-
-
Constructor Detail
-
MQuery
public MQuery()
Constructor w/o table name
-
MQuery
public MQuery(String TableName)
Constructor- Parameters:
TableName
- Table Name
-
MQuery
public MQuery(int AD_Table_ID)
Constructor get TableNAme from Table- Parameters:
AD_Table_ID
- Table_ID
-
-
Method Detail
-
get
public static MQuery get(Properties ctx, int AD_PInstance_ID, String TableName)
Get Query from Parameter- Parameters:
ctx
- context (to determine language)AD_PInstance_ID
- instanceTableName
- table name- Returns:
- where clause
-
getZoomColumnName
public static String getZoomColumnName(String columnName)
Get Zoom Column Name. Converts Synonyms like SalesRep_ID to AD_User_ID- Parameters:
columnName
- column name- Returns:
- column name
-
getZoomTableName
public static String getZoomTableName(String columnName)
Derive Zoom Table Name from column name. (e.g. drop _ID)- Parameters:
columnName
- column name- Returns:
- table name
-
getEqualQuery
public static MQuery getEqualQuery(String columnName, Object value)
Create simple Equal Query. Creates columnName=value or columnName='value'- Parameters:
columnName
- columnNamevalue
- value- Returns:
- quary
-
getEqualQuery
public static MQuery getEqualQuery(String columnName, int value)
Create simple Equal Query. Creates columnName=value- Parameters:
columnName
- columnNamevalue
- value- Returns:
- query
-
getNoRecordQuery
public static MQuery getNoRecordQuery(String tableName, boolean newRecord)
Create No Record query.- Parameters:
tableName
- table namenewRecord
- new Record Indicator (2=3)- Returns:
- query
-
getZoomWindowID
public int getZoomWindowID()
-
setZoomWindowID
public void setZoomWindowID(int m_zoomWindow_ID)
-
getRecordCount
public int getRecordCount()
Get Record Count- Returns:
- count - default 999999
-
setRecordCount
public void setRecordCount(int count)
Set Record Count- Parameters:
count
- count
-
addRestriction
public void addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, int depth)
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)andCondition
- true=and, false=ordepth
- ( = no open brackets )
-
addRestriction
public void addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, boolean notCondition, int depth)
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)andCondition
- true=and, false=ornotCondition
- true=not, false=emptydepth
- ( = no open brackets )
-
addRangeRestriction
public void addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to, boolean andCondition, boolean notCondition, int depth)
Add Range Restriction (BETWEEN)- Parameters:
ColumnName
- ColumnNameCode
- Code, e.g 0, All%Code_to
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code (Lookup)andCondition
- true=and, false=ornotCondition
- true=not, false=emptydepth
- ( = no open brackets )
-
addRestriction
public void addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, String andOrCondition, int depth)
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)andOrCondition
- AND/OR/AND NOT/OR NOT - concatenation of parenthesisdepth
- ( = no open brackets )
-
addRestriction
public void addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay)
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)
-
addRestriction
public void addRestriction(String ColumnName, String Operator, Object Code)
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- Code, e.g 0, All%
-
addRestriction
public void addRestriction(String ColumnName, String Operator, int Code)
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- Code, e.g 0
-
addRangeRestriction
public void addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to, boolean andCondition, int depth)
Add Range Restriction (BETWEEN)- Parameters:
ColumnName
- ColumnNameCode
- Code, e.g 0, All%Code_to
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code (Lookup)andCondition
- true=and, false=ordepth
- ( = no open brackets )
-
addRangeRestriction
public void addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to, String andOrCondition, int depth)
Add Range Restriction (BETWEEN)- Parameters:
ColumnName
- ColumnNameCode
- Code, e.g 0, All%Code_to
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code (Lookup)andOrCondition
- AND/OR/AND NOT/OR NOT - concatenation of parenthesisdepth
- ( = no open brackets )
-
addRangeRestriction
public void addRangeRestriction(String ColumnName, Object Code, Object Code_to, String InfoName, String InfoDisplay, String InfoDisplay_to)
Add Range Restriction (BETWEEN)- Parameters:
ColumnName
- ColumnNameCode
- Code, e.g 0, All%Code_to
- Code, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code (Lookup)
-
addRangeRestriction
public void addRangeRestriction(String ColumnName, Object Code, Object Code_to)
Add Range Restriction (BETWEEN)- Parameters:
ColumnName
- ColumnNameCode
- Code, e.g 0, All%Code_to
- Code, e.g 0, All%
-
addRestriction
protected void addRestriction(org.compiere.model.Restriction r)
Add Restriction- Parameters:
r
- Restriction
-
addRestriction
public void addRestriction(String whereClause, boolean andCondition, int joinDepth)
Add Restriction- Parameters:
whereClause
- SQL WHERE clauseandCondition
-joinDepth
-
-
addRestriction
public void addRestriction(String whereClause, boolean andCondition, boolean notCondition, int joinDepth)
Add Restriction- Parameters:
whereClause
- SQL WHERE clause
-
addRestriction
public void addRestriction(String whereClause, boolean andCondition, boolean notCondition, boolean existsCondition, int joinDepth)
Add Restriction- Parameters:
whereClause
- SQL WHERE clause
-
addRestriction
public void addRestriction(String whereClause, int joinDepth, String andOrCondition)
Add Restriction- Parameters:
whereClause
- SQL WHERE clausejoinDepth
-andOrCondition
-
-
addRestriction
public void addRestriction(String whereClause)
Add Restriction- Parameters:
whereClause
- SQL WHERE clause
-
addRestriction
public void addRestriction(String whereClause, String Operator, String InfoName, String InfoDisplay)
-
isNewRecordQuery
public boolean isNewRecordQuery()
New Record Query- Returns:
- true if new record query
-
getWhereClause
public String getWhereClause()
Create the resulting Query WHERE Clause- Returns:
- Where Clause
-
getWhereClause
public String getWhereClause(boolean fullyQualified)
Create the resulting Query WHERE Clause- Parameters:
fullyQualified
- fully qualified Table.ColumnName- Returns:
- Where Clause
-
getInfo
public String getInfo()
Get printable Query Info- Returns:
- info
-
getWhereClause
public String getWhereClause(int index)
Create Query WHERE Clause. Not fully qualified- Parameters:
index
- restriction index- Returns:
- Where Clause or "" if not valid
-
getRestrictionCount
public int getRestrictionCount()
Get Restriction Count- Returns:
- number of restrictions
-
isActive
public boolean isActive()
Is Query Active- Returns:
- true if number of restrictions > 0
-
getTableName
public String getTableName()
Get Table Name- Returns:
- Table Name
-
setTableName
public void setTableName(String TableName)
Set Table Name- Parameters:
TableName
- Table Name
-
getColumnName
public String getColumnName(int index)
Get ColumnName of index- Parameters:
index
- index- Returns:
- ColumnName
-
setColumnName
protected void setColumnName(int index, String ColumnName)
Set ColumnName of index- Parameters:
index
- indexColumnName
- new column name
-
getOperator
public String getOperator(int index)
Get Operator of index- Parameters:
index
- index- Returns:
- Operator
-
getCode
public Object getCode(int index)
Get Operator of index- Parameters:
index
- index- Returns:
- Operator
-
getCode_to
public Object getCode_to(int index)
Get Operator of index- Parameters:
index
- index- Returns:
- Operator
-
getInfoDisplay
public String getInfoDisplay(int index)
Get Restriction Display of index- Parameters:
index
- index- Returns:
- Restriction Display
-
getInfoDisplay_to
public String getInfoDisplay_to(int index)
Get TO Restriction Display of index- Parameters:
index
- index- Returns:
- Restriction Display
-
getInfoName
public String getInfoName(int index)
Get Info Name- Parameters:
index
- index- Returns:
- Info Name
-
getInfoOperator
public String getInfoOperator(int index)
Get Info Operator- Parameters:
index
- index- Returns:
- info Operator
-
getInfoDisplayAll
public String getInfoDisplayAll(int index)
Get Display with optional To- Parameters:
index
- index- Returns:
- info display
-
toString
public String toString()
String representation
-
getDisplayName
public String getDisplayName(Properties ctx)
Get Display Name- Parameters:
ctx
- context- Returns:
- display Name
-
deepCopy
public MQuery deepCopy()
Clone Query- Returns:
- Query
-
getAD_PInstance_ID
public int getAD_PInstance_ID()
- Returns:
- AD_PInstance_ID; this value is set if you created this query by using
get(Properties, int, String)
-
setZoomTableName
public void setZoomTableName(String tableName)
- Parameters:
tableName
-
-
getZoomTableName
public String getZoomTableName()
- Returns:
- zoom table name
-
setZoomColumnName
public void setZoomColumnName(String column)
- Parameters:
column
-
-
getZoomColumnName
public String getZoomColumnName()
- Returns:
- zoom column name
-
setZoomValue
public void setZoomValue(Object value)
- Parameters:
value
-
-
getZoomValue
public Object getZoomValue()
- Returns:
- zoom value, usually an integer
-
setReportProcessQuery
public void setReportProcessQuery(MQuery query)
-
getReportProcessQuery
public MQuery getReportProcessQuery()
-
getRestrictionSQL
public String getRestrictionSQL(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, int depth)
- Parameters:
ColumnName
-Operator
-Code
-InfoName
-InfoDisplay
-andCondition
-depth
-- Returns:
-
getRestrictionSQL
public String getRestrictionSQL(String ColumnName, Object Code, Object Code_To, String InfoName, String InfoDisplay, String InfoDisplay_To, boolean andCondition, int depth)
- Parameters:
ColumnName
-Code
-Code_To
-InfoName
-InfoDisplay
-InfoDisplay_To
-andCondition
-depth
-- Returns:
-
-