PivotFilter(DataModelObject dataModelObject, String fieldName) { this.dataModelObject = dataModelObject; if (!dataModelObject.containsField(fieldName)) { throw new IllegalArgumentException("No such field " + fieldName + " on specified data model object."); } this.fieldName = fieldName; }
/** * Add a filter that limits the number of values of an aggregated field that will be allowed * into the pivot. * * @param field the name of a field * @param sortAttribute field to aggregate for limiting * @param sortDirection whether to take the lowest or highest values of the aggregated field * @param limit how many values of the aggregated field to take * @param statsFunction the function to use for aggregation * @return The PivotSpecification you are modifying. */ public PivotSpecification addFilter(String field, String sortAttribute, SortDirection sortDirection, int limit, StatsFunction statsFunction) { if (!dataModelObject.containsField(field)) { throw new IllegalArgumentException("No such field " + sortAttribute); } assertCorrectlyTypedField( sortAttribute, new FieldType[] { FieldType.STRING, FieldType.NUMBER, FieldType.OBJECTCOUNT } ); LimitPivotFilter filter = new LimitPivotFilter(this.dataModelObject, field, sortAttribute, sortDirection, limit, statsFunction); filters.add(filter); return this; }
this.statsFunction = statsFunction; if (!dataModelObject.containsField(fieldName)) { throw new IllegalArgumentException("No such field named " + fieldName + " on data model object.");