
Query builder for plot
PlotFilterBuilder.RdAllow building progressively a SQL query to filter plots following different criteria using the builder pattern
Methods
new(connection)Initialize the builder with a database connection.
connection: A DBI connection object to the database
filter_country(country, interactive = FALSE)Filter plots by country name(s).
country: Character vector of country name(s)interactive: Logical. If TRUE, uses .link_table for fuzzy matching
filter_plot_name(plot_name, interactive = FALSE)Filter plots by plot name(s).
plot_name: Character vector of plot name(s)interactive: Logical. If TRUE, uses .link_table for fuzzy matching
filter_method(method, interactive = FALSE)Filter plots by method(s).
method: Character vector of method name(s)interactive: Logical. If TRUE, uses .link_table for fuzzy matching
filter_locality(locality_name)Filter plots by locality name(s).
locality_name: Character vector of locality name(s)
build(operator = "AND")Build the final SQL query.
operator: Character. Join operator between conditions ("AND" or "OR"). Default is "AND"
Returns a SQL query object
build_with_or()Build the SQL query with OR operator between conditions. Returns a SQL query object
add_custom_condition(condition, wrap_parentheses = TRUE)Add a custom SQL condition.
condition: Character. Raw SQL condition stringwrap_parentheses: Logical. If TRUE, wraps condition in parentheses
print_conditions()Display current filter conditions (for debugging).
Methods
Method new()
Usage
PlotFilterBuilder$new(connection)Examples
if (FALSE) { # \dontrun{
con <- call.mydb()
query <- PlotFilterBuilder$new(con)$
filter_country("Gabon")$
filter_method("transect")$
build()
} # }