com.groiss.reporting
Class Query

java.lang.Object
  extended by com.groiss.reporting.Query

public class Query
extends java.lang.Object

Class describing a report. Holds all Informations given by Query-XML and Request.


Constructor Summary
Query(java.lang.String id, java.lang.String title, org.jdom.Document xml, java.util.Date execution, javax.servlet.http.HttpServletRequest req)
           
Query(java.lang.String id, java.lang.String title, org.jdom.Document xml, java.util.Date execution, javax.servlet.http.HttpServletRequest req, com.groiss.reporting.StoredQuery sq)
           
Query(java.lang.String id, java.lang.String title, org.jdom.Document xml, java.util.Date execution, java.util.Map<java.lang.String,java.lang.String[]> paramMap, com.groiss.reporting.StoredQuery q)
          Constructs a Query, builds the SQL Statement
 
Method Summary
 void addCondition(java.lang.String tablename, java.lang.String alias, java.lang.String condition, java.lang.String selection, java.util.List<?> condValues)
          Add a condition to the query
 void addOrderByForAggregateValueData(java.lang.String att)
          use this method to order resultset to calculate AggregateValue Types correctly
 boolean addRowNumber()
           
 java.lang.String addSelect(java.lang.String tablename, java.lang.String selectAttribute, java.lang.String alias, java.lang.String selection, boolean addToGroupBy, boolean addAliasAsPrefix)
          Adds a select Attribute to the query.
 void addSelectNameOfAttrib(org.jdom.Element attribute, java.lang.String name)
          stores the attributenames gained from @link #addSelect(String, String, String, String, boolean, boolean)
 void addTempJoin(java.lang.String key1, java.lang.String key2, org.jdom.Element rel)
           
 boolean containsTable(java.lang.String table, java.lang.String alias)
           
 boolean getAddArchive()
           
 java.util.List<org.jdom.Element> getAttributes()
          returns a list of all attributes of this query
 int getCondCountWithParams()
           
 int getConditionCount()
          get the number of the current condition.
 java.lang.StringBuilder getConditionString()
           
 java.lang.String getDispStringForAttriubtes(org.jdom.Element attr, boolean addSortPattern)
          returns a displayname for the attribute
 java.lang.String getDispStringForConditions(org.jdom.Element c)
          returns a displayname for the condtion c
 java.util.Date getExecutionTime()
          the execution timestamp of the query
 ReportingExporter getExporter()
           
static Pair<ReportingExporter,java.util.Map<java.lang.String,java.lang.String>> getExporterInfos(org.jdom.Document xml)
          get Exportinginformation from xml-document
 java.lang.String getExportingParam(java.lang.String key)
           
 java.lang.String getId()
          returns the id of this query
protected  int getMaxTableResult()
           
 java.lang.String getMaxUnit()
          get the max unit of timeintervals used in this query
 java.lang.String getMinUnit()
          get the min unit of timeintervals used in this query
 java.lang.String getParam(java.lang.String key)
          Returns the parameter from Map...
 java.util.Map<java.lang.String,? extends java.lang.Object> getParamMap()
          get the Parameter Map of this query
 Resource getResource()
           
 java.util.List<java.lang.String> getSelectNamesOfAttribs(org.jdom.Element attribute)
           
 java.lang.String getSqlQueryString()
          get the sql query string
 com.groiss.reporting.StoredQuery getStoredQuery()
           
 TimeModel getTimemodel()
          get the timemodel used by this query
 java.lang.String getTitle()
           
 java.util.List<java.lang.Object> getValues()
          get a List of values of the prepared statement
 org.jdom.Document getXMLDoc()
          returns the xml document describing this query
static boolean isAttributeTypeClob(Entity e, Attribute a)
           
protected  boolean isDistinct()
           
protected  boolean isExecutable()
           
 boolean queryHasClobSelects()
           
 void setTitle(java.lang.String title)
          Set the displayed title of the query
 boolean shallLockOperatorInParamMask()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Query

public Query(java.lang.String id,
             java.lang.String title,
             org.jdom.Document xml,
             java.util.Date execution,
             javax.servlet.http.HttpServletRequest req)
Parameters:
id - the id of the query
title - the title to show in result
xml - the xml document defining the report
execution - timestamp which is taken as execution time to calculate time intevals
req - - the HttpServletRequest parameter Map is used for Query(String, String, Document, Date, Map, StoredQuery)
See Also:
Query(String, String, Document, Date, Map, StoredQuery)

Query

public Query(java.lang.String id,
             java.lang.String title,
             org.jdom.Document xml,
             java.util.Date execution,
             javax.servlet.http.HttpServletRequest req,
             com.groiss.reporting.StoredQuery sq)
Parameters:
id - the id of the query
title - the title to show in result
xml - the xml document defining the report
execution - timestamp which is taken as execution time to calculate time intevals
req - the HttpServletRequest parameter Map is used for Query(String, String, Document, Date, Map, StoredQuery)
sq - the storedquery object defining this report
See Also:
Query(String, String, Document, Date, Map, StoredQuery)

Query

public Query(java.lang.String id,
             java.lang.String title,
             org.jdom.Document xml,
             java.util.Date execution,
             java.util.Map<java.lang.String,java.lang.String[]> paramMap,
             com.groiss.reporting.StoredQuery q)
Constructs a Query, builds the SQL Statement

Parameters:
id - the id of query
title - the query title
xml - the xml documents descibing the query
execution - the timestamp of execution
paramMap - a map with parameters (e.g. params at execution), usually all request params are stored in this map
Method Detail

getXMLDoc

public org.jdom.Document getXMLDoc()
returns the xml document describing this query


getId

public java.lang.String getId()
returns the id of this query


getTimemodel

public TimeModel getTimemodel()
get the timemodel used by this query


getMaxUnit

public java.lang.String getMaxUnit()
get the max unit of timeintervals used in this query


getMinUnit

public java.lang.String getMinUnit()
get the min unit of timeintervals used in this query


getConditionCount

public int getConditionCount()
get the number of the current condition. is needed in ReportingData.addConditionToQuery(Query, Element) to gain the maybe already filled parameter at execution values from parametermap


getParamMap

public java.util.Map<java.lang.String,? extends java.lang.Object> getParamMap()
get the Parameter Map of this query


getParam

public java.lang.String getParam(java.lang.String key)
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

addSelect

public java.lang.String addSelect(java.lang.String tablename,
                                  java.lang.String selectAttribute,
                                  java.lang.String alias,
                                  java.lang.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 database
selectAttribute - - the sql select statement
alias - - the used tablealias
selection - - an additional (additional to the selection defined in schema) selection to the table if needed
addToGroupBy - - false if sqlaggr is the selected aggregation. false otherwise
addAliasAsPrefix - - true if tablealias shoulb be added in front of selectAttribute. false otherwise
Returns:
the attribute for the select

addCondition

public void addCondition(java.lang.String tablename,
                         java.lang.String alias,
                         java.lang.String condition,
                         java.lang.String selection,
                         java.util.List<?> condValues)
Add a condition to the query

Parameters:
tablename - - the tablename in database
alias - - the used tablealias
condition - - the condition string
selection - - an additional (additional to the selection defined in schema) selection to the table if needed
condValues - - a vector with values for the prepared statement. There has to be an element in the vector for each ? in condition

addOrderByForAggregateValueData

public void addOrderByForAggregateValueData(java.lang.String att)
use this method to order resultset to calculate AggregateValue Types correctly


containsTable

public boolean containsTable(java.lang.String table,
                             java.lang.String alias)
Parameters:
table - - the tablename in database
alias - - the used tablealias
Returns:
true if table is already added with thos alias

addTempJoin

public void addTempJoin(java.lang.String key1,
                        java.lang.String key2,
                        org.jdom.Element rel)

getSqlQueryString

public java.lang.String getSqlQueryString()
get the sql query string


getValues

public java.util.List<java.lang.Object> getValues()
get a List of values of the prepared statement


getAttributes

public java.util.List<org.jdom.Element> getAttributes()
returns a list of all attributes of this query

Returns:
a list of DOM elements

getSelectNamesOfAttribs

public java.util.List<java.lang.String> getSelectNamesOfAttribs(org.jdom.Element attribute)
Parameters:
attribute - - the attribute
Returns:
a Vector of attribute names to read them from the ResultSet

addSelectNameOfAttrib

public void addSelectNameOfAttrib(org.jdom.Element attribute,
                                  java.lang.String name)
stores the attributenames gained from @link #addSelect(String, String, String, String, boolean, boolean)

Parameters:
attribute - - the attribute, which caused this select statement
name - - the attribute name in the sql query

getExecutionTime

public java.util.Date getExecutionTime()
the execution timestamp of the query


getAddArchive

public boolean getAddArchive()
Returns:
true if query includes data from archive schema

getConditionString

public java.lang.StringBuilder getConditionString()
Returns:
a string represanting the query's condtions.

getDispStringForAttriubtes

public java.lang.String getDispStringForAttriubtes(org.jdom.Element attr,
                                                   boolean addSortPattern)
returns a displayname for the attribute

Parameters:
attr - - attribute
addSortPattern - - if true the sortpaterns %ASC%, %DESC% and %NONE% are added to the displayname
Returns:
an I18N string for the attribute

getDispStringForConditions

public java.lang.String getDispStringForConditions(org.jdom.Element c)
returns a displayname for the condtion c

Parameters:
c - - condition
Returns:
an I18N string for the condition

getExporter

public ReportingExporter getExporter()
Returns:
the exporter object of this query

getExportingParam

public java.lang.String getExportingParam(java.lang.String key)
Parameters:
key - - the name of the exorting parameter
Returns:
the valuo of this parameter

getExporterInfos

public static Pair<ReportingExporter,java.util.Map<java.lang.String,java.lang.String>> getExporterInfos(org.jdom.Document xml)
get Exportinginformation from xml-document

Parameters:
xml -
Returns:
a Pair of ReportingExporter instance and key-value map of paramters

getTitle

public java.lang.String 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...

addRowNumber

public boolean addRowNumber()
Returns:
true if report should include row numbers

getCondCountWithParams

public int getCondCountWithParams()
Returns:
the index of the last parameter of execution condition

shallLockOperatorInParamMask

public boolean shallLockOperatorInParamMask()
Returns:
true if operator shall be readonly in parammask

getResource

public Resource getResource()

setTitle

public void setTitle(java.lang.String title)
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

public static boolean isAttributeTypeClob(Entity e,
                                          Attribute a)

getMaxTableResult

protected int getMaxTableResult()
Returns:
maximum number of result rows

getStoredQuery

public com.groiss.reporting.StoredQuery getStoredQuery()


@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.