Package com.pullreports.model
Class QueryLabelValuesProvider
- Object
-
- com.pullreports.model.QueryLabelValuesProvider
-
- All Implemented Interfaces:
LabelValuesProvider
public class QueryLabelValuesProvider extends Object implements LabelValuesProvider
LabelValuesProvider which retrieves label values from a SQL query.Schema analog: <label_value_query>
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_LABEL_COLUMN
static String
DEFAULT_VALUE_COLUMN
-
Constructor Summary
Constructors Constructor Description QueryLabelValuesProvider(String query)
Constructs a new QueryLabelValuesProvider that returns a list ofLabelValue
s for the given SQL query.QueryLabelValuesProvider(String query, String labelColumnName, String valueColumnName)
Constructs a new QueryLabelValuesProvider that returns a list ofLabelValue
s for the given SQL query, label, and value columns.QueryLabelValuesProvider(String query, String labelColumnName, String valueColumnName, String groupColumnName)
Constructs a new QueryLabelValuesProvider that returns a list ofLabelValue
s for the given SQL query, label, value, and group columns.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<LabelValue>
createLabelValues(javax.sql.DataSource dataSource, javax.servlet.http.HttpServletRequest request)
Returns a List ofLabelValue
beans to use as values for the parentColumn
within the Pull Reports Ad Hoc Creator Filter web form.boolean
equals(Object obj)
Optional<String>
getGroupColumn()
String
getLabelColumn()
String
getQuery()
String
getValueColumn()
int
hashCode()
String
toString()
-
-
-
Field Detail
-
DEFAULT_LABEL_COLUMN
public static final String DEFAULT_LABEL_COLUMN
- See Also:
- Constant Field Values
-
DEFAULT_VALUE_COLUMN
public static final String DEFAULT_VALUE_COLUMN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
QueryLabelValuesProvider
public QueryLabelValuesProvider(String query)
Constructs a new QueryLabelValuesProvider that returns a list ofLabelValue
s for the given SQL query. The SQL query must have columns named 'label' and 'value' whose values will be used to construct theLabelValue
label and value respectively.- Parameters:
query
- A SQL query from which to retrieve the label values. The query must have label and value columns named 'label' and 'value' respectively.
-
QueryLabelValuesProvider
public QueryLabelValuesProvider(String query, String labelColumnName, String valueColumnName)
Constructs a new QueryLabelValuesProvider that returns a list ofLabelValue
s for the given SQL query, label, and value columns. The returned LabelValues will have a the emptyOptional
as the group value.- Parameters:
query
- A SQL query from which to retrieve the label values. The query must have label and value columns named as per thelabelColumnName
andvalueColumnName
parameters respectively.labelColumnName
- The name of the column in the SQL query whose value is theLabelValue
label.valueColumnName
- The name of the column in the SQL query whose value is theLabelValue
value.
-
QueryLabelValuesProvider
public QueryLabelValuesProvider(String query, String labelColumnName, String valueColumnName, String groupColumnName)
Constructs a new QueryLabelValuesProvider that returns a list ofLabelValue
s for the given SQL query, label, value, and group columns.- Parameters:
query
- A SQL query from which to retrieve the label values. The query must have label, value, and group columns named as per thelabelColumnName
,valueColumnName
, andgroupColumnName
parameters respectively. The given SQL query should be ordered by the column identified bygroupColumnName
.labelColumnName
- The name of the column in the SQL query whose value is theLabelValue
label.valueColumnName
- The name of the column in the SQL query whose value is theLabelValue
value.groupColumnName
- The name of the column in the SQL query whose value is theLabelValue
group.
-
-
Method Detail
-
createLabelValues
public List<LabelValue> createLabelValues(javax.sql.DataSource dataSource, javax.servlet.http.HttpServletRequest request)
Description copied from interface:LabelValuesProvider
Returns a List ofLabelValue
beans to use as values for the parentColumn
within the Pull Reports Ad Hoc Creator Filter web form. The Ad Hoc Creator uses the labels and values within an HTML <select> element associated with the Filtervalue
field.The Ad Hoc Creator will surround consecutive LabelValue beans which have equal
group
properties with an HTML <optgroup> element labeled with thegroup
.- Specified by:
createLabelValues
in interfaceLabelValuesProvider
- Parameters:
dataSource
- TheDataSource
used to fill the parentReport
. Use the dataSource to dynamically materialize a list ofLabelValue
beans from a JDBC query. Any opened JDBC connection must be closed by the implementing method.request
- TheHttpServletRequest
sent to the GET Label Value List API. to retrieve the LabelValue list. Use the request parameter to contextualize the returned list to the current user.- Returns:
- A List of
LabelValue
beans representing the values of the parentColumn
.
-
getLabelColumn
public String getLabelColumn()
-
getValueColumn
public String getValueColumn()
-
getGroupColumn
public Optional<String> getGroupColumn()
-
getQuery
public String getQuery()
-
toString
public String toString()
- Overrides:
toString
in classObject
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
-
-