/** * @return return the lineage, most remote ancestor first, of the data model object his filter's field is * defined on. */ public String[] getOwnerLineage() { return this.dataModelObject.getField(this.fieldName).getOwnerLineage(); }
/** * @return a list of the names of DataModelObjects from the most remote ancestor that is * not a built-in parent to this data model object. */ public String[] getAttributeOwnerLineage() { return this.dataModelObject.getField(this.sortAttribute).getOwnerLineage(); }
/** * @return the type of the field we are filtering on. */ public FieldType getType() { return this.dataModelObject.getField(fieldName).getType(); }
/** * @return the name of the data model object on which this split's field is defined. */ public String getOwnerName() { return this.dataModelObject.getField(fieldName).getOwnerName(); }
/** * @return the name of the data model object this filter's field is defined on. */ public String getOwnerName() { return this.dataModelObject.getField(this.fieldName).getOwnerName(); }
/** * @return the lineage, most remote ancestor first, on which the split's field is defined. */ public String[] getOwnerLineage() { return this.dataModelObject.getField(fieldName).getOwnerLineage(); }
StringPivotFilter(DataModelObject dataModelObject, String fieldName, StringComparison comparison, String comparisonValue) { super(dataModelObject, fieldName); if (dataModelObject.getField(fieldName).getType() != FieldType.STRING) { throw new IllegalArgumentException("Field " + fieldName + " on the data model object was of type " + dataModelObject.getField(fieldName).getType().toString() + ", expected string."); } this.comparison = comparison; this.comparisonValue = comparisonValue; }
BooleanPivotFilter(DataModelObject dataModelObject, String fieldName, BooleanComparison comparison, boolean comparisonValue) { super(dataModelObject, fieldName); if (dataModelObject.getField(fieldName).getType() != FieldType.BOOLEAN) { throw new IllegalArgumentException("Field " + fieldName + " on the data model object was of type " + dataModelObject.getField(fieldName).getType().toString() + ", expected boolean."); } this.comparison = comparison; this.comparisonValue = comparisonValue; }
IPv4PivotFilter(DataModelObject dataModelObject, String field, IPv4Comparison comparison, String comparisonValue) { super(dataModelObject, field); if (dataModelObject.getField(field).getType() != FieldType.IPV4) { throw new IllegalArgumentException("Field " + field + " on the data model object was of type " + dataModelObject.getField(field).getType().toString() + ", expected ipv4."); } this.comparison = comparison; this.comparisonValue = comparisonValue; }
NumberPivotFilter(DataModelObject dataModelObject, String field, NumberComparison comparison, double comparisonValue) { super(dataModelObject, field); if (dataModelObject.getField(field).getType() != FieldType.NUMBER) { throw new IllegalArgumentException("Field " + field + " on the data model object was of type " + dataModelObject.getField(field).getType().toString() + ", expected number."); } this.comparison = comparison; this.comparisonValue = comparisonValue; }
private void assertCorrectlyTypedField(String fieldName, FieldType[] acceptableTypes) { DataModelField field = this.dataModelObject.getField(fieldName); if (field == null) { throw new IllegalArgumentException("No such field named " + fieldName); } else if (!Arrays.asList(acceptableTypes).contains(field.getType())) { StringBuilder errorMessage = new StringBuilder(); errorMessage.append("Expected a field of one of the following types: "); boolean first = true; for (FieldType t : acceptableTypes) { if (!first) errorMessage.append(", "); errorMessage.append(t.toString()); first = false; } errorMessage.append("; found type " + field.getType().toString()); throw new IllegalArgumentException(errorMessage.toString()); } }
/** * Add keys common to all row splits to a JSON serialization. * * @param obj JSON serialization to modify. */ protected void addCommonFields(JsonObject obj) { DataModelField field = this.dataModelObject.getField(this.fieldName); obj.addProperty("fieldName", this.fieldName); obj.addProperty("owner", Util.join(".", field.getOwnerLineage())); obj.addProperty("type", field.getType().toString()); obj.addProperty("label", this.label); }
protected void addCommonFields(JsonObject obj) { DataModelField field = this.owner.getField(this.fieldName); obj.addProperty("fieldName", this.fieldName); obj.addProperty("owner", Util.join(".", field.getOwnerLineage())); obj.addProperty("type", field.getType().toString()); }
/** * Called by subclasses to add the fields common to all subclasses to JSON serializations. * * @param root a JsonObject instance representing a serialization of this object. */ protected void addCommonFields(JsonObject root) { root.addProperty("fieldName", this.fieldName); root.addProperty("owner", Util.join(".", this.dataModelObject.getField(fieldName).getOwnerLineage())); root.addProperty("type", this.getType().toString()); } }
/** * @return a JSON serialization of this object. */ JsonObject toJson() { JsonObject root = new JsonObject(); DataModelField f = this.dataModelObject.getField(fieldName); root.addProperty("fieldName", this.fieldName); root.addProperty("owner", Util.join(".", f.getOwnerLineage())); root.addProperty("type", f.getType().toString()); root.addProperty("label", this.label); root.addProperty("sparkline", false); // Not properly implemented in core yet. root.addProperty("value", this.statsFunction.toString()); return root; } }
/** * Add a row split on a numeric or string valued field, splitting on each distinct value of the field. * * @param field name of the field to split on * @param label a human readable name for this set of rows * @return The PivotSpecification you are modifying. */ public PivotSpecification addRowSplit(String field, String label) { assertCorrectlyTypedField(field, new FieldType[] { FieldType.NUMBER, FieldType.STRING }); FieldType t = this.dataModelObject.getField(field).getType(); if (t == FieldType.NUMBER) { rows.add(new NumberPivotRowSplit(this.dataModelObject, field, label)); } else if (t == FieldType.STRING) { rows.add(new StringPivotRowSplit(this.dataModelObject, field, label)); } else { throw new IllegalArgumentException("Field not of type number or string despite precondition asserting so."); } return this; }
/** * Add a column split on a string or number valued field, producing a column for * each distinct value of the field. * * @param field the field to split on. * @return The PivotSpecification you are modifying. */ public PivotSpecification addColumnSplit(String field) { assertCorrectlyTypedField(field, new FieldType[] { FieldType.NUMBER, FieldType.STRING }); FieldType t = this.dataModelObject.getField(field).getType(); if (t == FieldType.NUMBER) { columns.add(new NumericPivotColumnSplit(this.dataModelObject, field)); } else if (t == FieldType.STRING) { columns.add(new StringPivotColumnSplit(this.dataModelObject, field)); } return this; }
StatsFunction statsFunction) { super(dataModelObject, fieldName); FieldType type = dataModelObject.getField(fieldName).getType(); if (type != FieldType.NUMBER && type != FieldType.STRING && type != FieldType.OBJECTCOUNT) { throw new IllegalArgumentException("Field " + fieldName + " on the data model object was of type " + dataModelObject.getField(fieldName).getType().toString() + ", expected number, string, " + "or object count.");
FieldType t = dataModelObject.getField(fieldName).getType();