Package org.compiere.model
Class MQuery
java.lang.Object
org.compiere.model.MQuery
- All Implemented Interfaces:
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:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Betweenstatic final int
Between - 8static final String
Equalstatic final int
Equal - 0static final String
Greaterstatic final String
Greater Equalstatic final String
Lessstatic final String
Less Equalstatic final String
Likestatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Not Equalstatic final int
Not Equal - 1static final String
Not Likestatic final String
For IDEMPIERE-377static final String
For IDEMPIERE-377static final ValueNamePair[]
All the Operatorsstatic final ValueNamePair[]
Operators for Datesstatic final ValueNamePair[]
Operators for encrypted fieldsstatic final ValueNamePair[]
Operators for Lookups and Lists (including Y/N)static final ValueNamePair[]
Operators for Numbers, Integersstatic final ValueNamePair[]
Operators for Strings -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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) Add restrictionprotected void
addRestriction
(org.compiere.model.Restriction r) Add Restrictionclone()
deepCopy()
Clone Querystatic MQuery
get
(Properties ctx, int AD_PInstance_ID, String TableName) Create new Query for reportint
getCode
(int index) Get Operator of indexgetCode_to
(int index) Get Operator of indexgetColumnName
(int index) Get ColumnName of indexgetDisplayName
(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.
Create restriction of columnName=value or columnName='value'getInfo()
Get printable Query InfogetInfoDisplay
(int index) Get display text of indexgetInfoDisplay_to
(int index) Get display text of to restrictiongetInfoDisplayAll
(int index) Get Display with optional TogetInfoName
(int index) Get Info NamegetInfoOperator
(int index) Get Info Operatorstatic MQuery
getNoRecordQuery
(String tableName, boolean newRecord) Create No Record query.getOperator
(int index) Get Operator of indexint
Get Record Countint
Get Restriction CountgetRestrictionSQL
(String ColumnName, Object Code, Object Code_To, String InfoName, String InfoDisplay, String InfoDisplay_To, boolean andCondition, int depth) getRestrictionSQL
(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, int depth) Get Table NameCreate the resulting Query WHERE ClausegetWhereClause
(boolean fullyQualified) Create the resulting Query WHERE ClausegetWhereClause
(int index) Create Query WHERE Clause.static String
getZoomColumnName
(String columnName) Get Zoom Column Name.
Convert well known synonyms like SalesRep_ID to AD_User_ID.static String
getZoomTableName
(String columnName) Derive Zoom Table Name from column name (drop _ID or _UU).int
boolean
isActive()
Is Query Activeboolean
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) toString()
String representation
-
Field Details
-
EQUAL
Equal- See Also:
-
MSG_EQUAL
- See Also:
-
EQUAL_INDEX
public static final int EQUAL_INDEXEqual - 0- See Also:
-
NOT_EQUAL
Not Equal- See Also:
-
MSG_NOT_EQUAL
- See Also:
-
NOT_EQUAL_INDEX
public static final int NOT_EQUAL_INDEXNot Equal - 1- See Also:
-
LIKE
Like- See Also:
-
MSG_LIKE
- See Also:
-
NOT_LIKE
Not Like- See Also:
-
MSG_NOT_LIKE
- See Also:
-
GREATER
Greater- See Also:
-
MSG_GREATER
- See Also:
-
GREATER_EQUAL
Greater Equal- See Also:
-
MSG_GREATER_EQUAL
- See Also:
-
LESS
Less- See Also:
-
MSG_LESS
- See Also:
-
LESS_EQUAL
Less Equal- See Also:
-
MSG_LESS_EQUAL
- See Also:
-
BETWEEN
Between- See Also:
-
MSG_BETWEEN
- See Also:
-
BETWEEN_INDEX
public static final int BETWEEN_INDEXBetween - 8- See Also:
-
NOT_NULL
For IDEMPIERE-377- See Also:
-
MSG_NOT_NULL
- See Also:
-
NULL
For IDEMPIERE-377- See Also:
-
MSG_NULL
- See Also:
-
OPERATORS
All the Operators -
OPERATORS_STRINGS
Operators for Strings -
OPERATORS_LOOKUP
Operators for Lookups and Lists (including Y/N) -
OPERATORS_ENCRYPTED
Operators for encrypted fields -
OPERATORS_NUMBERS
Operators for Numbers, Integers -
OPERATORS_DATES
Operators for Dates
-
-
Constructor Details
-
MQuery
public MQuery()Constructor w/o table name -
MQuery
Constructor- Parameters:
TableName
- Table Name
-
MQuery
public MQuery(int AD_Table_ID) Constructor get TableName from table id- Parameters:
AD_Table_ID
-
-
-
Method Details
-
get
Create new Query for report- Parameters:
ctx
- contextAD_PInstance_ID
- process instance for reportTableName
- table name- Returns:
- MQuery
-
getZoomColumnName
Get Zoom Column Name.
Convert well known synonyms like SalesRep_ID to AD_User_ID.- Parameters:
columnName
- column name- Returns:
- zoom column name
-
getZoomTableName
Derive Zoom Table Name from column name (drop _ID or _UU).- Parameters:
columnName
- column name- Returns:
- table name
-
getEqualQuery
Create simple Equal Query.
Create restriction of columnName=value or columnName='value'- Parameters:
columnName
- columnNamevalue
- value- Returns:
- query
-
getEqualQuery
Create simple Equal Query. Create restriction of columnName=value.- Parameters:
columnName
- columnNamevalue
- value- Returns:
- query
-
getNoRecordQuery
Create No Record query.- Parameters:
tableName
- table namenewRecord
- new Record Indicator. if true, add restriction of "2=3", otherwise add restriction of "1-2"- Returns:
- query
-
getZoomWindowID
public int getZoomWindowID()- Returns:
- zoom AD_Window_ID
-
setZoomWindowID
public void setZoomWindowID(int m_zoomWindow_ID) - Parameters:
m_zoomWindow_ID
- AD_Window_ID for zoom
-
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
- query value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)andCondition
- true=and, false=ordepth
- number of parenthesis
-
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
- query value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)andCondition
- true=and, false=ornotCondition
- true=notdepth
- number of parenthesis
-
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
- from value, e.g 0, All%Code_to
- to value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code_to (Lookup)andCondition
- true=and, false=ornotCondition
- true=notdepth
- number of parenthesis
-
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
- query value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)andOrCondition
- AND/OR/AND NOT/OR NOT - concatenation of parenthesisdepth
- number of parenthesis
-
addRestriction
public void addRestriction(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay) Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- query value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)
-
addRestriction
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- query value, e.g 0, All%
-
addRestriction
Add Restriction- Parameters:
ColumnName
- ColumnNameOperator
- Operator, e.g. = != ..Code
- query value, 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
- from value, e.g 0, All%Code_to
- to value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code_to (Lookup)andCondition
- true=and, false=ordepth
- number of parenthesis
-
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
- from value, e.g 0, All%Code_to
- to value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code_to (Lookup)andOrCondition
- AND/OR/AND NOT/OR NOT - concatenation of parenthesisdepth
- number of parenthesis
-
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
- from value, e.g 0, All%Code_to
- to value, e.g 0, All%InfoName
- Display NameInfoDisplay
- Display of Code (Lookup)InfoDisplay_to
- Display of Code_to (Lookup)
-
addRangeRestriction
Add Range Restriction (BETWEEN)- Parameters:
ColumnName
- ColumnNameCode
- from value, e.g 0, All%Code_to
- to value, e.g 0, All%
-
addRestriction
protected void addRestriction(org.compiere.model.Restriction r) Add Restriction- Parameters:
r
- Restriction
-
addRestriction
Add Restriction- Parameters:
whereClause
- SQL WHERE clauseandCondition
- true=and, false=orjoinDepth
- number of parenthesis
-
addRestriction
public void addRestriction(String whereClause, boolean andCondition, boolean notCondition, int joinDepth) Add Restriction- Parameters:
whereClause
- SQL WHERE clauseandCondition
- true=and, false=ornotCondition
- true=notjoinDepth
- number of parenthesis
-
addRestriction
public void addRestriction(String whereClause, boolean andCondition, boolean notCondition, boolean existsCondition, int joinDepth) Add Restriction- Parameters:
whereClause
- SQL WHERE clauseandCondition
- true=and, false=ornotCondition
- true=notexistsCondition
- true=existsjoinDepth
- number of parenthesis
-
addRestriction
Add Restriction- Parameters:
whereClause
- SQL WHERE clausejoinDepth
- number of parenthesisandOrCondition
-
-
addRestriction
Add Restriction- Parameters:
whereClause
- SQL WHERE clause
-
addRestriction
public void addRestriction(String whereClause, String Operator, String InfoName, String InfoDisplay) Add restriction- Parameters:
whereClause
-Operator
-InfoName
-InfoDisplay
-
-
isNewRecordQuery
public boolean isNewRecordQuery()New Record Query- Returns:
- true if new record query
-
getWhereClause
Create the resulting Query WHERE Clause- Returns:
- Where Clause
-
getWhereClause
Create the resulting Query WHERE Clause- Parameters:
fullyQualified
- fully qualified Table.ColumnName- Returns:
- Where Clause
-
getInfo
Get printable Query Info- Returns:
- info
-
getWhereClause
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
Get Table Name- Returns:
- Table Name
-
setTableName
Set Table Name- Parameters:
TableName
- Table Name
-
getColumnName
Get ColumnName of index- Parameters:
index
- index- Returns:
- ColumnName or null
-
setColumnName
Set ColumnName of index- Parameters:
index
- indexColumnName
- new column name
-
getOperator
Get Operator of index- Parameters:
index
- index- Returns:
- Operator or null
-
getCode
Get Operator of index- Parameters:
index
- index- Returns:
- Operator or null
-
getCode_to
Get Operator of index- Parameters:
index
- index- Returns:
- Operator or null
-
getInfoDisplay
Get display text of index- Parameters:
index
- index- Returns:
- Display Text
-
getInfoDisplay_to
Get display text of to restriction- Parameters:
index
- index of restriction- Returns:
- Display Text
-
getInfoName
Get Info Name- Parameters:
index
- index- Returns:
- Info Name
-
getInfoOperator
Get Info Operator- Parameters:
index
- index- Returns:
- info Operator
-
getInfoDisplayAll
Get Display with optional To- Parameters:
index
- index- Returns:
- info display
-
toString
String representation -
getDisplayName
Get Display Name- Parameters:
ctx
- context- Returns:
- display Name
-
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
- Parameters:
tableName
-
-
getZoomTableName
- Returns:
- zoom table name
-
setZoomColumnName
- Parameters:
column
-
-
getZoomColumnName
- Returns:
- zoom column name
-
setZoomValue
- Parameters:
value
-
-
getZoomValue
- Returns:
- zoom value, usually an integer
-
setReportProcessQuery
- Parameters:
query
-
-
getReportProcessQuery
- Returns:
- query
-
getRestrictionSQL
public String getRestrictionSQL(String ColumnName, String Operator, Object Code, String InfoName, String InfoDisplay, boolean andCondition, int depth) - Parameters:
ColumnName
-Operator
-Code
- query valueInfoName
-InfoDisplay
- display text of codeandCondition
- true=and, false=ordepth
- number of parenthesis- Returns:
- SQL
-
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
- from valueCode_To
- to valueInfoName
-InfoDisplay
- display text of from valueInfoDisplay_To
- display text of to valueandCondition
- true=and, false=ordepth
- number of parenthesis- Returns:
- SQL
-
clone
-