Class Query

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

public class Query extends Object
Class describing a report. Holds all Informations given by Query-XML and Request.
  • Field Details

  • Constructor Details

  • Method Details

    • getXMLDoc

      public Document getXMLDoc()
      returns the xml document describing this query
    • getId

      public String getId()
      returns the id of this query
    • getTimemodel

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

      public String getMaxUnit()
      get the max unit of timeintervals used in this query
    • getMinUnit

      public 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 Map<String,String[]> getParamMap()
      get the Parameter Map of this query
    • getParam

      public String getParam(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
    • addConditions

      protected void addConditions(Element cond)
    • 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 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(String tablename, String alias, String condition, String selection, 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
    • 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 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
    • addCondition

      public void addCondition(String condId, String tablename, String alias, String condition, String selection, List<?> condValues)
      Add a condition to the query
      Parameters:
      condId - - conditionId
      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
    • 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 - - conditionId
      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(Integer att)
      use this method to order resultset to calculate AggregateValue Types correctly
    • containsTable

      public boolean containsTable(String table, 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(String key1, String key2, Element rel)
    • getSqlQueryString

      public String getSqlQueryString()
      get the sql query string
    • getValues

      public List<Object> getValues()
      get a List of values of the prepared statement
    • getQueryPlan

      public String getQueryPlan()
    • setQueryPlan

      protected void setQueryPlan(String queryPlan)
    • getValues

      public List<Object> getValues(String attribute)
      get a list of values that will be bound to the specified attribute (tablename.alias.attribute)
      Parameters:
      attribute -
      Returns:
    • getConditions

      public List<Pair<String,List<?>>> getConditions(String attribute)
      get a list of values that will be bound to the specified attribute (tablename.alias.attribute)
      Parameters:
      attribute -
      Returns:
    • getAttributes

      public List<Element> getAttributes()
      returns a list of all attributes of this query
      Returns:
      a list of DOM elements
    • getSelectIndexOfAttribs

      public List<Integer> getSelectIndexOfAttribs(Element attribute)
      Parameters:
      attribute - - the attribute
      Returns:
      a List of attribute Index to read them from the ResultSet
    • addSelectIndexOfAttrib

      public void addSelectIndexOfAttrib(Element attribute, int name)
      Parameters:
      attribute - - the attribute, which caused this select statement
      name - - the attribute index in the sql query
    • buildSQLStatement

      protected void buildSQLStatement()
    • splitIntoTableAndAlias

      public String[] splitIntoTableAndAlias(String key)
    • getTableAndAliases

      public MultiMap<String,String> getTableAndAliases()
      Returns:
      the tableAndAliases
    • getExecutionTime

      public Date getExecutionTime()
      the execution timestamp of the query
    • getAddArchive

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

      public Map<Integer,Element> getCondNeedsParam()
      Returns:
      a map with all conditions needing parameter at execution input
    • getConditionString

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

      public String getDisplayStringForAttribute(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 String getDispStringForConditions(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 String getExportingParam(String key)
      Parameters:
      key - - the name of the exporting parameter
      Returns:
      the valuo of this parameter
    • setExportingParam

      public void setExportingParam(String key, String value)
    • getExporterInfos

      public static Pair<ReportingExporter,Map<String,String>> getExporterInfos(Document xml)
      get Exportinginformation from xml-document
      Parameters:
      xml -
      Returns:
      a Pair of ReportingExporter instance and key-value map of paramters
    • getAttributeValue

      public String getAttributeValue(Element e, String attribute)
      get the attribute-value from a query.xml element
      Parameters:
      e - the element (attribute, condition,...)
      attribute - the attribute-id
      Returns:
      the value
    • getTitle

      public 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...
    • getReqParamMap

      protected static Map<String,String[]> getReqParamMap(HttpServletRequest req)
    • addRowNumber

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

      public String getParamMask()
    • getCondCountWithParams

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

      public String lockOperatorInParamMaskMode()
      Returns:
      TRUE if operator shall be readonly in parammask HIDE if operator shall be hidden in parammask FALSE otherwise
    • shallLockOperatorInParamMask

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

      public String getTimezone()
    • getLocale

      public String getLocale()
    • getResource

      public Resource getResource()
    • setTitle

      public void setTitle(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
    • getQueryInformations

      public Map<String,String> getQueryInformations()
      Returns:
      a map of informations about this report
    • getResultModifier

      public ResultModifier getResultModifier()
      Returns:
    • getRootStoredQuery

      public Report 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

      public ReportingData getReportingDataInstance(Element attr)
      Parameters:
      attr -
      Returns:
    • addPermissionRelevantAttribute

      public void addPermissionRelevantAttribute(Element e)
    • getPermissionRelevantAttributes

      public List<Element> getPermissionRelevantAttributes()