public abstract class ANetricsCompoundQueryBuilder
extends java.lang.Object
This class is analogous to the ANetricsQueryBuilder abstract class. It provides the ability to build matching queries for compound records, whereas the ANetricsQueryBuilder class builds queries for matching a single table. A compound record is a parent record with zero or more child records. There may be child records for multiple child tables, and there may be multiple child records for a single on of the child tables. A compound record matching query finds the best matching combination of parent record and child records.
A compound query consists of one or more feature querylets. Each feature querylet is a query against a single table. There can be at most one feature querylet for each child table. To build the complete compound query an ANetricsCompoundQueryBuilder object must have an ANetricsQueryBuilder object for each feature querylet. The parent table may have multiple feature querylets. However all parent table querylets must have the exact same set of default input and output field names.
The setting of input and output field names and item names is by table. Essentially the setting of input and output field names, and item names, is passed on to the ANetricsQueryBuilder objects associated with the table.
| Constructor and Description |
|---|
ANetricsCompoundQueryBuilder() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
changeItemName(java.lang.String item_type,
java.lang.String default_name,
java.lang.String new_name)
Change a single item name to be output in the generated query.
|
java.util.List<java.lang.String> |
getCurInputFieldNames(java.lang.String table_name)
Return the list of field names for the specified table used to
identify input fields.
|
java.lang.String |
getCurItemName(java.lang.String item_type,
java.lang.String default_name)
Get the current name of an item for the given item type and default name.
|
java.util.List<java.lang.String> |
getCurJoinedFieldNames()
Return the list of field names used in the generated query with join
table prefix.
|
java.util.List<java.lang.String> |
getCurJoinedFieldNames(java.lang.String table_name)
Return the list of field names with join table prefix,
for the given table.
|
java.util.List<java.lang.String> |
getCurOutputFieldNames(java.lang.String table_name)
Return the list of field names that is used in the generated query
for the given table.
|
java.util.List<java.lang.String> |
getCurrentInputTableNames()
Return a list of table names as recognized in the input record data.
|
java.util.List<java.lang.String> |
getCurrentOutputTableNames()
Return a list of table names as output in the generate queries.
|
java.util.List<java.lang.String> |
getDefaultItemNames(java.lang.String item_type)
Return the list of default item names for the specified item type.
|
java.util.List<java.lang.String> |
getDefaultTableNames()
Return a list of all tables used by this compound query builder.
|
java.util.List<java.lang.String> |
getDfltInputNames(java.lang.String table_name)
Return the default set of Input field names for the given table.
|
java.util.List<java.lang.String> |
getDfltOutputNames(java.lang.String table_name)
Return the default set of Output field names for the given table.
|
abstract NetricsQuery |
getQuery()
Generate and return a Query object for the current field set.
|
java.util.List<java.lang.String> |
getUsedItemTypes()
Return the list of used item types.
|
java.lang.Object |
setConfiguration(java.io.File config_file)
Initialize the builder from a configuration file.
|
java.lang.Object |
setConfiguration(java.io.InputStream config_stream)
Initialize the builder from an InputStream.
|
void |
setConfiguration(java.lang.Object config_object)
Initialize the builder from a configuration object.
|
java.lang.Object |
setConfiguration(java.lang.String config_source)
Initialize the builder from a configuration source.
|
ANetricsCompoundQueryBuilder |
setDefaultValue(java.lang.String default_field_value)
Set the default field value.
|
ANetricsCompoundQueryBuilder |
setFieldValuesFromList(java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>> record_data)
Set the current field values.
|
ANetricsCompoundQueryBuilder |
setFieldValuesFromMap(java.util.Map<java.lang.String,java.util.List<java.util.Map<java.lang.String,java.lang.String>>> record_data)
Set the current field values.
|
ANetricsCompoundQueryBuilder |
setFieldValuesFromRecord(NetricsCompoundRecord record)
Set the current field values.
|
ANetricsCompoundQueryBuilder |
setInputFieldName(java.lang.String table_name,
java.lang.String default_name,
java.lang.String new_name)
Set a field name for the given table to be used to identify
an input field.
|
ANetricsCompoundQueryBuilder |
setInputFieldNames(java.lang.String table_name,
java.util.List<java.lang.String> new_names)
Set the field names for a table to be used for input field values.
|
ANetricsCompoundQueryBuilder |
setInputFieldOrdering(java.lang.String table_name,
java.util.List<java.lang.String> input_fields)
Set the input field ordering for the specified table.
|
ANetricsCompoundQueryBuilder |
setInputTableName(java.lang.String table_name,
java.lang.String input_alias)
Set the table name as recognized in the input record data.
|
ANetricsCompoundQueryBuilder |
setInputTableNames(java.util.List<java.lang.String> new_names)
Set the table names as recognized in the input record data.
|
ANetricsCompoundQueryBuilder |
setOutputFieldName(java.lang.String table_name,
java.lang.String default_name,
java.lang.String new_name)
For the specified table change a single field name to be output
in the generated query.
|
ANetricsCompoundQueryBuilder |
setOutputFieldNames(java.lang.String table_name,
java.util.List<java.lang.String> new_names)
Set the field names for the given table to be output in the generated
query.
|
ANetricsCompoundQueryBuilder |
setOutputTableName(java.lang.String table_name,
java.lang.String output_alias)
Set the table name to be used in the generated queries.
|
NetricsSearchCfg |
setQueryConfiguration(NetricsSearchCfg cfg)
Add any query configuration options to the configuration.
|
NetricsSearchOpts |
setSearchOpts(NetricsSearchOpts opts)
Add search options.
|
public java.util.List<java.lang.String> getDfltInputNames(java.lang.String table_name)
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
table_name - the original default table name.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if table_name is null, empty
or not a valid default table name.public java.util.List<java.lang.String> getCurInputFieldNames(java.lang.String table_name)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException
table_name - the original default table name.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if table_name is null, empty
or not a valid default table name.public java.util.List<java.lang.String> getDfltOutputNames(java.lang.String table_name)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException
table_name - the original default table name.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if table_name is null, empty
or not a valid default table name.public java.util.List<java.lang.String> getCurOutputFieldNames(java.lang.String table_name)
table_name - the original default table name.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if table_name is null, empty
or not a valid default table name.public java.util.List<java.lang.String> getCurJoinedFieldNames()
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if table_name is null, empty
or not a valid default table name.public java.util.List<java.lang.String> getCurJoinedFieldNames(java.lang.String table_name)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException
table_name - the original default table name.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if table_name is null, empty
or not a valid default table name.public ANetricsCompoundQueryBuilder setOutputFieldNames(java.lang.String table_name, java.util.List<java.lang.String> new_names) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
table_name - the original default table name.new_names - The new list of names. This list must be the same
length as the default field name list. Names must
be presented in the same order as for the default
field name list.java.lang.IllegalArgumentException - if there is no such table as table_name,
if the given list is null, not the right length,
or contains null or empty entries.java.lang.IllegalStateException - if features have not been established.public ANetricsCompoundQueryBuilder setOutputFieldName(java.lang.String table_name, java.lang.String default_name, java.lang.String new_name) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
table_name - the original default table name.default_name - the default name for the field.new_name - the new name for the field.java.lang.IllegalArgumentException - if default_name is not in the default
name list, or new_name is null or empty.java.lang.IllegalStateException - if features have not been established.public ANetricsCompoundQueryBuilder setInputFieldNames(java.lang.String table_name, java.util.List<java.lang.String> new_names) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
table_name - the original default table name.new_names - The new list of names. This list must be the same
length as the default field name list. Names must
be presented in the same order as for the default
field name list.java.lang.IllegalArgumentException - if the given list is null,
not the right length, or contains null or empty entries.java.lang.IllegalStateException - if features have not been established.public ANetricsCompoundQueryBuilder setInputFieldName(java.lang.String table_name, java.lang.String default_name, java.lang.String new_name) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
table_name - the original default table name.default_name - the default name for the field.new_name - the new name for the field.java.lang.IllegalArgumentException - if default_name is not in the default
name list, or new_name is null or empty.java.lang.IllegalStateException - if features have not been established.public ANetricsCompoundQueryBuilder setInputFieldOrdering(java.lang.String table_name, java.util.List<java.lang.String> input_fields)
This defines the fields that are given in the input field list for the specified table, and the order in which they appear. This list consists of field names as returned by the getCurInputFieldNames(table_name) method. The list may be shorter than that returned by getCurInputFieldNames, but each name given must be on the list, and a name must appear at most once.
If this call is not made the ordering is assumed to be the same as returned by getCurInputFieldNames.
table_name - the original default table name.input_fields - A subset of the fields returned by
getCurInputFieldNames.java.lang.IllegalArgumentException - if input_fields is null, or contains
null or empty entries, repeated entries, or an entry
that does not match a current input field name.java.lang.IllegalStateException - if features have not been established.public ANetricsCompoundQueryBuilder setDefaultValue(java.lang.String default_field_value) throws java.lang.IllegalStateException
This sets the value used for any field in the query that does not appear in the input field ordering list. It also sets the default value for null field values. By default the default value is null, which will generate an exception when the query is generated. So if the ordering list is shorter than the complete field list this must be set.
The default value is the same for all tables.
default_field_value - the value used as the default.java.lang.IllegalStateException - if features have not been established.public java.util.List<java.lang.String> getDefaultTableNames()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if features have not been established.public java.util.List<java.lang.String> getCurrentOutputTableNames()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if features have not been established.public java.util.List<java.lang.String> getCurrentInputTableNames()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if features have not been established.public ANetricsCompoundQueryBuilder setOutputTableName(java.lang.String table_name, java.lang.String output_alias) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
table_name - the original default table name.output_alias - the name as it should appear in the
generated query.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if either name is null or empty,
or if table_name is not a defined default table name.public ANetricsCompoundQueryBuilder setInputTableNames(java.util.List<java.lang.String> new_names) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
new_names - a list of the table names as used in the input
record data. The list must be the same length and
same order as that returned by getDefaultTableNames().
Null or empty names are not allowed.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if new_names is null, not the same
length as the default list, or contains empty elements.public ANetricsCompoundQueryBuilder setInputTableName(java.lang.String table_name, java.lang.String input_alias) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
table_name - the original default table name.input_alias - the name as it will appear in the input record data.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if either name is null or empty,
or if table_name is not a defined default table name.public java.util.List<java.lang.String> getDefaultItemNames(java.lang.String item_type)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException
item_type - the type of item to be listed.java.lang.IllegalStateException - if features have not been established.java.lang.IllegalArgumentException - if the item_type is null or empty.public java.util.List<java.lang.String> getUsedItemTypes()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if features have not been established.public java.lang.String getCurItemName(java.lang.String item_type,
java.lang.String default_name)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException
item_type - the type of object.default_name - the default name for this item.java.lang.IllegalArgumentException - if item_type or default_name is null
or empty.java.lang.IllegalStateException - if features have not been established.public boolean changeItemName(java.lang.String item_type,
java.lang.String default_name,
java.lang.String new_name)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException
item_type - The type of item.default_name - the default name for the item.new_name - the new name for the item.java.lang.IllegalArgumentException - if any argument is null or empty.java.lang.IllegalStateException - if features have not been established.public ANetricsCompoundQueryBuilder setFieldValuesFromRecord(NetricsCompoundRecord record) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.Exception
This method takes the field data from a NetricsCompoundRecord object. The table names for the child records in the compound record must match those as returned by the getCurrentInputTableNames method. The number of fields and ordering of the fields for a record must match those as established by the setFieldOrdering call for the associated table. If no setFieldOrdering call was made they must match the ordering as returned by the getCurInputFieldNames method.
record - the compound record containing the field data.java.lang.IllegalArgumentException - if the compound record doesn't contain
data for any of the currently defined tables, or if
record is null or contains null field data and no
default value is established.java.lang.IllegalStateException - if features have not been established,
or if one of the builders is not properly initialized.java.lang.Exception - as thrown by ANetricsQueryBuilder.getQuery.public ANetricsCompoundQueryBuilder setFieldValuesFromList(java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>> record_data) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.Exception
This method takes the field data from a Map. The index of the map is a table name as returned by the getCurrentInputTableNames method. The value is a list of record values. The record values are passed as a list of String values. The length of the list and the ordering of the values must match those as established by the setFieldOrdering call for the associated table. If no setFieldOrdering call was made they must match the ordering as returned by the getCurInputFieldNames method.
An entry for the parent table is required. Entries for child tables are optional. It is an error if there is more than one record in the parent table list.
record_data - the mapping as described above.java.lang.IllegalArgumentException - if the record data doesn't contain
data for any of the currently defined tables, or if
record_data is null or contains null field data and no
default value is established.java.lang.IllegalStateException - if features have not been established,
or if one of the builders is not properly initialized.java.lang.Exception - as thrown by ANetricsQueryBuilder.getQuery.public ANetricsCompoundQueryBuilder setFieldValuesFromMap(java.util.Map<java.lang.String,java.util.List<java.util.Map<java.lang.String,java.lang.String>>> record_data) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.Exception
This method takes the field data from a Map. The index of the map is a table name as returned by the getCurrentInputTableNames method. The value is a list of record values. The record values are passed as a Mapping of String keys, to String values. The key must be an input field name as returned by getCurInputFieldNames for the associated table. The value is the field value.
There must be at least one entry for one table. It is an error if there is more than one record in the parent table list.
record_data - the mapping as described above.java.lang.IllegalArgumentException - if record_data is null, if any
key value does not correspond to a table name as
returned by getCurrentInputTableNames, if there is
no entry for the parent table, or if its list does not
contain exactly one entry, if the record data mapping
contains a key that is not a current input field name
for the associated table, or if any field value is null,
or not given in the mapping and there is no default value
established.java.lang.IllegalStateException - if features have not been established.java.lang.Exception - as thrown by ANetricsQueryBuilder.getQuery.public java.lang.Object setConfiguration(java.io.File config_file)
throws java.lang.UnsupportedOperationException,
java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.IllegalStateException
This configures the query builder from a configuration file. The configuration file may configure new input/output field names, object names, etc. It may set internal weights and parameters. It may define the feature querylets and tables for this builder. It is completely up to the implementation what this configures.
The configuration read in is returned as an object. New query builders from the same class can then be configured directly from the object, avoiding the overhead of reading in the file each time.
config_file - A file reference to the configuration file to
be processed by this query builder.java.lang.UnsupportedOperationException - if this class does not support
setting of the configuration from a File.java.io.IOException - on errors opening or reading the given file.java.lang.IllegalArgumentException - if the file is not a valid configuration
file for this class.java.lang.IllegalStateException - if this object is already iniitalized.public java.lang.Object setConfiguration(java.lang.String config_source)
throws java.lang.UnsupportedOperationException,
java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.IllegalStateException
This configures the query builder from a configuration source identified by a string. Typically this is a file name or file path. The configuration source may configure new input/output field names, object names, etc. It may set internal weights and parameters. It may define the feature querylets and tables for this builder. It is completely up to the implementation what this configures.
The configuration read in is returned as an object. New query builders from the same class can then be configured directly from the object, avoiding the overhead of reading and parsing the configuration each time.
config_source - A string reference to the configuration
source data to be processed by this query builder.java.lang.UnsupportedOperationException - if this class does not support
setting of the configuration from a source string.java.io.IOException - on errors opening or reading the given source.java.lang.IllegalArgumentException - if the source is not a valid configuration
for this class.java.lang.IllegalStateException - if this object is already iniitalized.public java.lang.Object setConfiguration(java.io.InputStream config_stream)
throws java.lang.UnsupportedOperationException,
java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.IllegalStateException
This configures the query builder from an InputStream containing the configuration data. The configuration data may configure new input/output field names, object names, etc. It may set internal weights and parameters. It may define the feature querylets and tables for this builder. It is completely up to the implementation what this configures.
The configuration read in is returned as an object. New query builders from the same class can then be configured directly from the object, avoiding the overhead of reading and parsing the configuration each time.
config_stream - An open input stream that returns the
configuration data.java.lang.UnsupportedOperationException - if this class does not support
setting of the configuration from a source stream.java.io.IOException - on errors reading the given source.java.lang.IllegalArgumentException - if the stream data isn't a
valid configuration for this class.java.lang.IllegalStateException - if this object is already iniitalized.public void setConfiguration(java.lang.Object config_object)
throws java.lang.UnsupportedOperationException,
java.lang.IllegalArgumentException,
java.lang.IllegalStateException
This configures the query builder from a configuration object. The configuration object is normally obtained from a previous call to the setConfiguration(File config_file) method. The configuration object may configure new input/output field names, object names, etc. It may set internal weights and parameters. It is completely up to the implementation what this configures.
config_object - An object holding the configuration information
for this query builder. Each class defines its own object
type.java.lang.UnsupportedOperationException - if this class does not support
setting of the configuration from an Object.java.lang.IllegalArgumentException - if the object is not a valid
configuration object for this class.java.lang.IllegalStateException - if this object is already iniitalized.public abstract NetricsQuery getQuery() throws java.lang.IllegalStateException, java.lang.Exception
java.lang.IllegalStateException - if field values are not established.java.lang.Exception - on other errors.public NetricsSearchOpts setSearchOpts(NetricsSearchOpts opts)
opts - a search options object.java.lang.IllegalStateException - the method may throw this exception if
field values are required but not set.public NetricsSearchCfg setQueryConfiguration(NetricsSearchCfg cfg) throws java.lang.IllegalStateException, java.lang.Exception
This method adds any search configuration options associated with the query that would be built by this object, to the given NetricsSearchCfg object. This is primarily intended to allow for filtering predicates. If cfg is null a new configuration is created with the appropriate join definition, any configuration options are then added. If cfg is not null it is assumed the appropriate join definition is already established and only additional options are added.
The default implementation creates a JOIN_FULL_AND_PARTIALS mode join using single parent mode. It uses all defined tables.
cfg - a search configration object.java.lang.IllegalStateException - the method may throw this exception if
field values are required but not set.java.lang.Exception - other exceptions may be thrown by custom
implementations.