addColumn (QueryResultsProcessor - Java™)
Define in
Syntax
public void addColumn(String name, String title, String formula, int sortorder, boolean ishidden, boolean
iscategorized) throws NotesException
public void addColumn(String name) throws NotesException
Parameters
string name
The unique programmatic name of the column within a QueryResults Processor instance. If there is no override using the addFormula method call, the name provided is treated as a field name in each database involved in the QueryResultsProcessor object.
In JSON output, the name value used is the element name for each returned entry. Values in the name field can also specify aggregate functions. Aggregate functions require categorized columns and they return computed numerical values across sets of results within a given category. For more information, see the description of booleaniscategorized. For aggregate functions requiring a name as an argument, that name can be overridden the same as any name value without the aggregate function.
Shortened call parameter values
Using the second call (with a single parameter) is equivalent to the following:
addColumn(name, “”, SORT_UNORDERED, false, false, “”);
Full call parameter values
String title
The display title of the column. Used only in generated views, the title is the UI column header.
String formula
- AddFormula Formula Language override
- Formula argument of the AddColumn method
- Use the name argument of the AddColumn method as a database field name
int sortorder
A constant to indicate how to sort the column. Values are sorted case and accent insensitively, by default. Legal values are:
SORT_UNORDERED
SORT_ASCENDING
SORT_DESCENDING
Multiple sort columns can have sortorders, and each order specified is sequentially applied in the order of addColumn calls. Field lists (multiply-occurring field values) are compared processed using field occurrences from first to last sequentially.
boolean ishidden
Specify this to sort by a column value but not return it. If true, the column cannot have a sortorder of SORT_UNORDERED and cannot have an iscategorized value of true.
boolean iscategorized
Categorized columns have a single entry returned for each unique value with entries containing that value nested under it. In JSON results, these nested entries are represented in arrays under each categorized unique value.
Multiply-occurring fields (i.e. lists) are not allowed to be categorized.
Any categorized column with a preceding uncategorized column or columns will force the creation of categorized values containing all prior uncategorized columns plus the categorized column.
Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 |
categorized | categorized | categorized |
@@avg(col1)
Returns the sum all values of col1 within the current category divided by the number of documents.@@sum(col2)
Returns the sum of all values of col2 within the current category.@@max(col3)
Returns the maximum numeric value of col3 within the current category.*@@min(col4)
Returns the minimum numeric value of col4 within the current category.*@@count()
Returns the count of documents within the current category.*
Aggregate function columns must appear after the categorized column whose values control their computation. They are always SORT_UNORDERED, that is, unsorted.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Col1 |
Col2 |
@@avg(col3) |
@@sum(col4) |
Col5 |
Col6 |
@@avg(col7) |
Col8 |
- a. Any non-categorized, non-aggregate columns
- b. A single categorized column
- c. Any aggregate columns (can be multiple as above)
- d. Finally, any document-level columns not taking part in categorization. That is, document detail.
Example
QueryResultsProcessor qrp = db.createDominoQuery();
…
qrp.addColumn("sales_person", "",””,
QueryResultsProcessor.SORT_ASCENDING, false, true); // categorized also
qrp.addColumn("ordno, "", “”,
QueryResultsProcessor.SORT_DESCENDING, false, false, “order_number + 1000”);
qrp.addColumn("order_origin", "", “”,
QueryResultsProcessor.SORT_UNORDERED, false, false);
Example with categories and aggregate functions
// 1st category - 2 fields making 1 categorized key value
qrp.addColumn("Department", "Dept", , “@left(dept; 10)”,
QueryResultsProcessor.SORT_ASCENDING,
false, false);
qrp.addColumn("JobTitle", "Job Title ", “”, QueryResultsProcessor.SORT_ASCENDING,
false, true);
// aggregates off the first category
qrp.addColumn("@@avg(salary)", "", “”, QueryResultsProcessor.SORT_UNORDERED,
false, false);
qrp.addColumn("@@sum(salary)", "", “”, QueryResultsProcessor.SORT_UNORDERED,
false, false);
// 2nd category - 2 field categorized key
qrp.addColumn("GEO”); // see shortened method form below
qrp.addColumn("OU", "Organizational Unit ", “”, QueryResultsProcessor.SORT_ASCENDING,
false, true);
// 4 aggregates off the 2nd category
qrp.addColumn("@@count()", "", “”, QueryResultsProcessor.SORT_UNORDERED, false, false);
qrp.addColumn("@@avg(salary)", "", “”, QueryResultsProcessor.SORT_UNORDERED,
false, false);
qrp.addColumn("@@sum(salwithraise)", "", “”, “”, QueryResultsProcessor.SORT_UNORDERED,
false, false);
qrp.addColumn("@@avg(salwithraise)", "", “”, QueryResultsProcessor.SORT_UNORDERED,
false, false);
// document detail under both categories - unique to Domino
qrp.addColumn("FullName", "Full Name ", “”, QueryResultsProcessor.SORT_ASCENDING,
false, false);
Example: Shortened call parameter values
QueryResultsProcessor qrp = db.createQueryResultsProcessor ();
…
qrp.addColumn("sales_person", "", “”,
QueryResultsProcessor.SORT_ASCENDING, false, true); // categorized also
qrp.addColumn("ordno_adjusted, "", “”,
QueryResultsProcessor.SORT_DESCENDING, false, false);
qrp.addColumn("order_origin"); // to use simplified syntax