Class ItemSummaryQuery.Projection

Object
Projection
Enclosing class:
ItemSummaryQuery<T extends PersistedObject & HasCalculableObjectItems>

public static class ItemSummaryQuery.Projection extends Object
One aggregated field of the summary query. Add projections with ItemSummaryQuery.addProjection(String, String) and its overloads rather than creating instances of this class.
  • Constructor Details

    • Projection

      public Projection()
      Internal: used by the server to read saved queries. Not for use in logic.
    • Projection

      public Projection(String distinctName, String fieldName, String aggregationMode, String weight)
      Internal: used by the server. Not for use in logic. Use ItemSummaryQuery.addProjection(String, String, String) instead.
      Parameters:
      distinctName - the identifier of the projection in the database query
      fieldName - the name or label of the aggregated item field
      aggregationMode - the aggregation: "SUM", "AVG", "MIN" or "MAX"
      weight - the name or label of the weight field, or null
    • Projection

      public Projection(String distinctName, String fieldNamePrefix, String fieldName, String aggregationMode, String weight)
      Internal: used by the server. Not for use in logic. Use ItemSummaryQuery.addProjection(String, String, String, String) instead.
      Parameters:
      distinctName - the identifier of the projection in the database query
      fieldNamePrefix - the attribute-extension prefix, or an empty string
      fieldName - the name or label of the aggregated item field
      aggregationMode - the aggregation: "SUM", "AVG", "MIN" or "MAX"
      weight - the name or label of the weight field, or null
  • Method Details

    • getFieldNamePrefix

      public String getFieldNamePrefix()
      Returns the attribute-extension prefix of the aggregated field.
      Returns:
      the prefix passed to ItemSummaryQuery.addProjection(String, String, String, String), with attributeExtension___ added in front of it (for example attributeExtension___oldVal_ for the prefix oldVal_), or an empty string for a regular item field
    • getFieldName

      public String getFieldName()
      Returns the name or label of the aggregated item field, as it was passed to ItemSummaryQuery.addProjection(String, String).
      Returns:
      the field name or label
    • getAggregationMode

      public String getAggregationMode()
      Returns the aggregation of this projection.
      Returns:
      "SUM", "AVG", "MIN" or "MAX"
    • getWeight

      public String getWeight()
      Returns the name or label of the field that weights the aggregated values.
      Returns:
      the weight field, or null when the projection is not weighted
    • getDistinctName

      public String getDistinctName()
      Internal: used in SQL queries, overcomes ORACLE 32byte length identifier limit. Not for use in logic.
      Returns:
      the short identifier of the projection in the database query, for example dn_0
    • getClientSideDistinctName

      public String getClientSideDistinctName()
      Returns the key under which the result rows of PublicGroovyAPI.runSummaryQuery(ItemSummaryQuery) hold the value of this projection. It is the lower-case form of <prefix><aggregation>_<field>_<weight>. attributeExtension___ is removed from the prefix, the field and the weight, spaces are removed, and % and * are replaced with _x_. For example, the prefix oldVal_ gives a key that starts with oldval_.

      Example:

      
       def query = api.getSimulationSummaryQuery()
       query.addProjection("resultPrice", "SUM")
       def key = query.getProjections()[0].getClientSideDistinctName()
       // key is "sum_resultprice_"
       
      Returns:
      the key of this projection in the result rows