Class DatasourceSchemaUtils
java.lang.Object
com.inductiveautomation.ignition.designer.ai.datasource.DatasourceSchemaUtils
-
Method Summary
Modifier and TypeMethodDescriptioncolumnsAsync(String datasource, String tableName) Fetches all columns oftableNameindatasource.static StringcreateColumnsForToolCall(List<DatasourceRpc.ColumnMetaInfo> columns, String tableName) Turns a list of column metadata into a string representation suitable to return from a tool callFetches all datasources currently on the gateway.static List<DatasourceRpc.ColumnMetaInfo> fetchColumns(String datasource, String tableName) Fetches all columns oftableNameindatasource.static List<DatasourceRpc.DatasourceMetaInfo> Fetches all datasources currently on the gateway.fetchTables(String datasource) Fetches all tables indatasource.static @Nullable StringlongestMatch(List<String> candidates, String query) Longest entry incandidatesthatquerycontinues with a., ornullwhen the query has not named one yet.static List<PromptAssist.Option> renderColumns(String datasource, String tableName, List<DatasourceRpc.ColumnMetaInfo> columns, String filter) Filterscolumnsto names starting withfilter(case-insensitive) and renders each match as anPromptAssist.Optionfor the column prompt assist popup.static List<PromptAssist.Option> renderDatasources(List<DatasourceRpc.DatasourceMetaInfo> datasources, String prefix) Filtersdatasourcesto names containingprefix(case-insensitive) and renders each match as anPromptAssist.Optionfor the datasource prompt assist popup.static List<PromptAssist.Option> renderTables(String datasource, List<String> tables, String prefix) Filterstablesto names starting withprefix(case-insensitive) and renders each match as anPromptAssist.Optionfor the table prompt assist popup.static CompletableFuture<List<String>> tablesAsync(String datasource) Fetches all tables indatasource.
-
Method Details
-
longestMatch
Longest entry incandidatesthatquerycontinues with a., ornullwhen the query has not named one yet. When several candidates match, the longest wins.Resolving a query against the names that actually exist is what lets those names contain dots themselves: a schema-qualified table arrives already flattened to
schema.table, so the separator alone cannot tell a qualified name from a name followed by a child. -
datasourcesAsync
Fetches all datasources currently on the gateway. Resolves to an empty list if the fetch fails. -
tablesAsync
Fetches all tables indatasource. Resolves to an empty list if the fetch fails.- Parameters:
datasource- the name of the datasource to fetch tables from.
-
columnsAsync
public static CompletableFuture<List<DatasourceRpc.ColumnMetaInfo>> columnsAsync(String datasource, String tableName) Fetches all columns oftableNameindatasource. Resolves to an empty list if the fetch fails.- Parameters:
datasource- the name of the datasource containing the table.tableName- the name of the table to fetch columns from.
-
renderDatasources
public static List<PromptAssist.Option> renderDatasources(List<DatasourceRpc.DatasourceMetaInfo> datasources, String prefix) Filtersdatasourcesto names containingprefix(case-insensitive) and renders each match as anPromptAssist.Optionfor the datasource prompt assist popup. Datasources with a blank name are skipped.- Parameters:
datasources- the datasources to filter and render.prefix- the case-insensitive substring to match against each datasource's name.- Returns:
- one option per matching datasource, in
datasourcesorder.
-
renderTables
public static List<PromptAssist.Option> renderTables(String datasource, List<String> tables, String prefix) Filterstablesto names starting withprefix(case-insensitive) and renders each match as anPromptAssist.Optionfor the table prompt assist popup. Tables with a blank name are skipped.- Parameters:
datasource- the name of the datasource to render tables for.tables- the list of tables to filter and render.prefix- the case-insensitive prefix to match against each table's name.- Returns:
- one option per matching table, in
tablesorder.
-
renderColumns
public static List<PromptAssist.Option> renderColumns(String datasource, String tableName, List<DatasourceRpc.ColumnMetaInfo> columns, String filter) Filterscolumnsto names starting withfilter(case-insensitive) and renders each match as anPromptAssist.Optionfor the column prompt assist popup. Columns with a blank name are skipped.- Parameters:
datasource- the name of the datasource to render columns for.tableName- the name of the table to render columns for.columns- the list of columns to filter and render.filter- the case-insensitive prefix to match against each column's name.- Returns:
- one option per matching column, in
columnsorder.
-
fetchDatasources
public static List<DatasourceRpc.DatasourceMetaInfo> fetchDatasources() throws DatasourceFetchExceptionFetches all datasources currently on the gateway.- Returns:
- the gateway's datasources.
- Throws:
DatasourceFetchException- if the fetch fails.
-
fetchTables
Fetches all tables indatasource.- Parameters:
datasource- the name of the datasource to fetch tables from.- Returns:
- the names of the tables in
datasource. - Throws:
DatasourceFetchException- if the fetch fails.
-
fetchColumns
public static List<DatasourceRpc.ColumnMetaInfo> fetchColumns(String datasource, String tableName) throws DatasourceFetchException Fetches all columns oftableNameindatasource.- Parameters:
datasource- the name of the datasource containing the table.tableName- the name of the table to fetch columns from.- Returns:
- the columns of
tableName. - Throws:
DatasourceFetchException- if the fetch fails.
-
createColumnsForToolCall
public static String createColumnsForToolCall(List<DatasourceRpc.ColumnMetaInfo> columns, String tableName) Turns a list of column metadata into a string representation suitable to return from a tool call- Parameters:
columns- a list of column metadatatableName- the name of the table- Returns:
- a string representation of the column suitable for use in a tool call or an error message for no columns reported.
-