Package com.groiss.reporting
Class Query
java.lang.Object
com.groiss.reporting.Query
Class describing a report. Holds all Informations given by Query-XML and Request.
-
Field Summary
Modifier and TypeFieldDescription -
Constructor Summary
ConstructorDescriptionConstructs q query for internal useQuery
(String id, String title, Document xml, Date execution, Map<String, String[]> paramMap, Report q) Constructs a Query, builds the SQL StatementQuery
(String id, String title, Document xml, Date execution, Map<String, String[]> paramMap, Report q, boolean doSQLInit) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCondition
(String condId, String tablename, String alias, String attrib, String condition, String selection, List<?> condValues) Add a condition to the queryvoid
addCondition
(String condId, String tablename, String alias, String condition, String selection, List<?> condValues) Add a condition to the queryvoid
addCondition
(String tablename, String alias, String condition, String selection, List<?> condValues) Add a condition to the queryvoid
addConditionForAttrib
(String tablename, String alias, String attrib, String condition, String selection, List<?> condValues) Add a condition to the queryprotected void
addConditions
(Element cond) void
use this method to order resultset to calculate AggregateValue Types correctlyvoid
boolean
int
addSelect
(String tablename, String selectAttribute, String alias, String selection, boolean addToGroupBy, boolean addAliasAsPrefix) Adds a select Attribute to the query.void
addSelectIndexOfAttrib
(Element attribute, int name) stores the attributenames gained fromaddSelect(String, String, String, String, boolean, boolean)
void
addTempJoin
(String key1, String key2, Element rel) protected void
boolean
containsTable
(String table, String alias) boolean
boolean
returns a list of all attributes of this querygetAttributeValue
(Element e, String attribute) get the attribute-value from a query.xml elementint
int
get the number of the current condition. is needed inReportingData.addConditionToQuery(Query, Element)
to gain the maybe already filled parameter at execution values from parametermapgetConditions
(String attribute) get a list of values that will be bound to the specified attribute (tablename.alias.attribute)getDisplayStringForAttribute
(Element attr, boolean addSortPattern) returns a displayname for the attributereturns a displayname for the condtion cthe execution timestamp of the querystatic Pair<ReportingExporter,
Map<String, String>> getExporterInfos
(Document xml) get Exportinginformation from xml-documentgetExportingParam
(String key) getId()
returns the id of this queryprotected int
get the max unit of timeintervals used in this queryget the min unit of timeintervals used in this queryReturns the parameter from Map... if param has several values, they are returned seperated by a semicolonget the Parameter Map of this querygetSelectIndexOfAttribs
(Element attribute) get the sql query stringget the timemodel used by this querygetTitle()
get a List of values of the prepared statementget a list of values that will be bound to the specified attribute (tablename.alias.attribute)returns the xml document describing this querystatic boolean
protected boolean
protected boolean
boolean
void
setExportingParam
(String key, String value) protected void
setQueryPlan
(String queryPlan) void
Set the displayed title of the queryboolean
String[]
-
Field Details
-
NULL_OPERATORS
-
DATE_OPERATORS
-
ARETH_OPERATORS
-
SET_OPERATORS
-
STRING_OPERATORS
-
EMPTY_OPERATOR
-
-
Constructor Details
-
Query
- Parameters:
id
- the id of the querytitle
- the title to show in resultxml
- the xml document defining the reportexecution
- timestamp which is taken as execution time to calculate time intevalsreq
- - the HttpServletRequest parameter Map is used forQuery(String, String, Document, Date, Map, Report)
- See Also:
-
Query
public Query(String id, String title, Document xml, Date execution, HttpServletRequest req, Report sq) - Parameters:
id
- the id of the querytitle
- the title to show in resultxml
- the xml document defining the reportexecution
- timestamp which is taken as execution time to calculate time intevalsreq
- the HttpServletRequest parameter Map is used forQuery(String, String, Document, Date, Map, Report)
sq
- the storedquery object defining this report- See Also:
-
Query
Constructs q query for internal use- Parameters:
q
- the StoredQueryparamMap
- a map of parameters to execute the query
-
Query
public Query(String id, String title, Document xml, Date execution, Map<String, String[]> paramMap, Report q) Constructs a Query, builds the SQL Statement- Parameters:
id
- the id of querytitle
- the query titlexml
- the xml documents descibing the queryexecution
- the timestamp of executionparamMap
- a map with parameters (e.g. params at execution), usually all request params are stored in this map
-
Query
-
-
Method Details
-
getXMLDoc
returns the xml document describing this query -
getId
returns the id of this query -
getTimemodel
get the timemodel used by this query -
getMaxUnit
get the max unit of timeintervals used in this query -
getMinUnit
get the min unit of timeintervals used in this query -
getConditionCount
public int getConditionCount()get the number of the current condition. is needed inReportingData.addConditionToQuery(Query, Element)
to gain the maybe already filled parameter at execution values from parametermap -
getParamMap
get the Parameter Map of this query -
getParam
Returns the parameter from Map... if param has several values, they are returned seperated by a semicolon- Parameters:
key
- - the param name- Returns:
- the Parameter
-
addConditions
-
addSelect
public int addSelect(String tablename, String selectAttribute, String alias, String selection, boolean addToGroupBy, boolean addAliasAsPrefix) Adds a select Attribute to the query. Returns the attribut name for every select, bechaus if the similar select is required twice in query, it is selected only once.- Parameters:
tablename
- - the tablename in databaseselectAttribute
- - the sql select statementalias
- - the used tablealiasselection
- - an additional (additional to the selection defined in schema) selection to the table if neededaddToGroupBy
- -false
if sqlaggr is the selected aggregation.false
otherwiseaddAliasAsPrefix
- -true
if tablealias shoulb be added in front of selectAttribute.false
otherwise- Returns:
- the attribute for the select
-
addCondition
public void addCondition(String tablename, String alias, String condition, String selection, List<?> condValues) Add a condition to the query- Parameters:
tablename
- - the tablename in databasealias
- - the used tablealiascondition
- - the condition stringselection
- - an additional (additional to the selection defined in schema) selection to the table if neededcondValues
- - a vector with values for the prepared statement. There has to be an element in the vector for each?
in condition
-
addConditionForAttrib
public void addConditionForAttrib(String tablename, String alias, String attrib, String condition, String selection, List<?> condValues) Add a condition to the query- Parameters:
tablename
- - the tablename in databasealias
- - the used tablealiascondition
- - the condition stringselection
- - an additional (additional to the selection defined in schema) selection to the table if neededcondValues
- - a vector with values for the prepared statement. There has to be an element in the vector for each?
in condition
-
addCondition
public void addCondition(String condId, String tablename, String alias, String condition, String selection, List<?> condValues) Add a condition to the query- Parameters:
condId
- - conditionIdtablename
- - the tablename in databasealias
- - the used tablealiascondition
- - the condition stringselection
- - an additional (additional to the selection defined in schema) selection to the table if neededcondValues
- - a vector with values for the prepared statement. There has to be an element in the vector for each?
in condition
-
addCondition
public void addCondition(String condId, String tablename, String alias, String attrib, String condition, String selection, List<?> condValues) Add a condition to the query- Parameters:
condId
- - conditionIdtablename
- - the tablename in databasealias
- - the used tablealiascondition
- - the condition stringselection
- - an additional (additional to the selection defined in schema) selection to the table if neededcondValues
- - a vector with values for the prepared statement. There has to be an element in the vector for each?
in condition
-
addOrderByForAggregateValueData
use this method to order resultset to calculate AggregateValue Types correctly -
containsTable
- Parameters:
table
- - the tablename in databasealias
- - the used tablealias- Returns:
true
if table is already added with thos alias
-
addTempJoin
-
getSqlQueryString
get the sql query string -
getValues
get a List of values of the prepared statement -
getQueryPlan
-
setQueryPlan
-
getValues
get a list of values that will be bound to the specified attribute (tablename.alias.attribute)- Parameters:
attribute
-- Returns:
-
getConditions
get a list of values that will be bound to the specified attribute (tablename.alias.attribute)- Parameters:
attribute
-- Returns:
-
getAttributes
returns a list of all attributes of this query- Returns:
- a list of DOM elements
-
getSelectIndexOfAttribs
- Parameters:
attribute
- - the attribute- Returns:
- a List of attribute Index to read them from the ResultSet
-
addSelectIndexOfAttrib
stores the attributenames gained fromaddSelect(String, String, String, String, boolean, boolean)
- Parameters:
attribute
- - the attribute, which caused this select statementname
- - the attribute index in the sql query
-
buildSQLStatement
protected void buildSQLStatement() -
splitIntoTableAndAlias
-
getTableAndAliases
- Returns:
- the tableAndAliases
-
getExecutionTime
the execution timestamp of the query -
getAddArchive
public boolean getAddArchive()- Returns:
true
if query includes data from archive schema
-
getCondNeedsParam
- Returns:
- a map with all conditions needing parameter at execution input
-
getConditionString
- Returns:
- a string represanting the query's condtions.
-
getDisplayStringForAttribute
returns a displayname for the attribute- Parameters:
attr
- - attributeaddSortPattern
- - iftrue
the sortpaterns%ASC%, %DESC% and %NONE%
are added to the displayname- Returns:
- an I18N string for the attribute
-
getDispStringForConditions
returns a displayname for the condtion c- Parameters:
c
- - condition- Returns:
- an I18N string for the condition
-
getExporter
- Returns:
- the exporter object of this query
-
getExportingParam
- Parameters:
key
- - the name of the exporting parameter- Returns:
- the valuo of this parameter
-
setExportingParam
-
getExporterInfos
get Exportinginformation from xml-document- Parameters:
xml
-- Returns:
- a Pair of ReportingExporter instance and key-value map of paramters
-
getAttributeValue
get the attribute-value from a query.xml element- Parameters:
e
- the element (attribute, condition,...)attribute
- the attribute-id- Returns:
- the value
-
getTitle
- Returns:
- the I18N keys of the title of this query
-
isExecutable
protected boolean isExecutable()- Returns:
true
if query is already executeable...
-
isDistinct
protected boolean isDistinct()- Returns:
true
if query does not display equal rows twice...
-
getReqParamMap
-
addRowNumber
public boolean addRowNumber()- Returns:
true
if report should include row numbers
-
getParamMask
-
getCondCountWithParams
public int getCondCountWithParams()- Returns:
- the index of the last parameter of execution condition
-
lockOperatorInParamMaskMode
- Returns:
TRUE
if operator shall be readonly in parammaskHIDE
if operator shall be hidden in parammaskFALSE
otherwise
-
shallLockOperatorInParamMask
public boolean shallLockOperatorInParamMask()- Returns:
true
if operator shall be readonly in parammask
-
getTimezone
-
getLocale
-
getResource
-
setTitle
Set the displayed title of the query- Parameters:
title
- - the title string. this String is given to Resource.localize of the Query, so you may use I18N Keys.
-
queryHasClobSelects
public boolean queryHasClobSelects() -
isAttributeTypeClob
-
getMaxTableResult
protected int getMaxTableResult()- Returns:
- maximum number of result rows
-
getQueryInformations
- Returns:
- a map of informations about this report
-
getResultModifier
- Returns:
-
getRootStoredQuery
- Returns:
- the root stored query which was the base for this query object null if query object does not origin from a stored query but is an adhoc query.
-
finishedParamMask
public boolean finishedParamMask()- Returns:
- true if the query has shown param mask already (so no pram mask will be shown)
-
getReportingDataInstance
- Parameters:
attr
-- Returns:
-
addPermissionRelevantAttribute
-
getPermissionRelevantAttributes
-