Method for creating queries
ReportValues is needed on two levels, the
DuPontModel level and the editor level.
- On the DuPontModel level, the values for each dupont model spec can be obtained either from another dupont model spec or from the database. If the values must be obtained from the database, a subclass of ReportValues must be created.
- First create a method called createQueries. In this method should be inserted the specifications for all the queries needed for this class. For the dupont model, you need two queries, for actual and budget, and insert them in the QueriesHolder. There are two methods in this class for the insertion:
- name: {name of the query} budget: {the budget query} actual: {the actual query}.
- name: {name of the query} query: {the query}. This method is more general than the first and can be used when the queries don't come in pairs.
- Then create a method called createElementSpecs. In this method should be specified all the specifications on the queries that you have created in the method createQueries. For the dupont model, you need only one element spec, with the default name, total. There are three methods in the ReportValues class for creating the necessary element specs. Once they are created, put them into the ElementSpecs class by using the method: at: {name of element spec} put: {element spec}.
- queryValue: {name of the query} sumOn: {summation field name} constraint: {constraints on the query for selecting only certain rows | nil for no constraint}
- queryValue: {name of the query} datedSumOn: {summation field name} dateField: {name of the field holding the date} constraint: {constraint}. This method is used when there must be additional constraint on the date. See DatedElementSpec for more information.
- otherQueryValuesOf: {name of the query}. Get the summation of the rows that are not selected by all the previous element specs which access the same query and field name.
There are two methods for creating the constraints:
- selectOn: {field name} values: {collection of values for accepting the row}.
- rejectOn: {field name} values: {collection of values for rejecting the row}
Note that the query must be specified so that at least the summation field column is returned. If there are constraints on the query, then the field names involved in the constraints must also be returned.
-
Jee Myeong Ku
Last modified: Thu Nov 7 14:47:37 CST