144 ''' |
144 ''' |
145 where = list() # for WHERE clause |
145 where = list() # for WHERE clause |
146 intol = list() # for INTO clause |
146 intol = list() # for INTO clause |
147 vals = list() # for VALUES clause |
147 vals = list() # for VALUES clause |
148 for crit in AIdb.getCriteria(queue, table, onlyUsed=False, strip=True): |
148 for crit in AIdb.getCriteria(queue, table, onlyUsed=False, strip=True): |
|
149 |
|
150 # Determine if this crit is a range criteria or not. |
|
151 is_range_crit = AIdb.isRangeCriteria(queue, crit, table) |
|
152 |
149 # Get the value from the manifest |
153 # Get the value from the manifest |
150 values = criteria[crit] |
154 values = criteria[crit] |
151 # the critera manifest didn't specify this criteria |
155 # the critera manifest didn't specify this criteria |
152 if values is None: |
156 if values is None: |
153 # if the criteria we're processing is a range criteria, fill in |
157 # if the criteria we're processing is a range criteria, fill in |
154 # NULL for two columns, MINcrit and MAXcrit |
158 # NULL for two columns, MINcrit and MAXcrit |
155 vals += ["NULL"] |
159 vals += ["NULL"] |
156 if AIdb.isRangeCriteria(queue, crit, table): |
160 if is_range_crit: |
157 where += ["MIN" + crit + " IS NULL"] |
161 where += ["MIN" + crit + " IS NULL"] |
158 where += ["MAX" + crit + " IS NULL"] |
162 where += ["MAX" + crit + " IS NULL"] |
159 intol += ["MIN" + crit] |
163 intol += ["MIN" + crit] |
160 intol += ["MAX" + crit] |
164 intol += ["MAX" + crit] |
161 vals += ["NULL"] |
165 vals += ["NULL"] |
162 # this is a single value |
166 # this is a single value |
163 else: |
167 else: |
164 where += [crit + " IS NULL"] |
168 where += [crit + " IS NULL"] |
165 intol += [crit] |
169 intol += [crit] |
166 # this is a single criteria (not a range) |
170 # This is a value criteria (not a range). 'values' is a list |
167 elif isinstance(values, basestring): |
171 # with one or more items. |
168 # use lower case for text strings |
172 elif not is_range_crit: |
169 intol += [crit] |
173 intol += [crit] |
170 val = AIdb.format_value(crit, values).lower() |
174 val = AIdb.format_value(crit, " ".join(values)) |
171 where += [crit + "=" + val] |
175 where += [crit + "=" + val] |
172 vals += [val] |
176 vals += [val] |
173 # Else the values are a list this is a range criteria |
177 # Else this is a range criteria. 'values' is a two-item list |
174 else: |
178 else: |
175 # Set the MIN column for this range criteria |
179 # Set the MIN column for this range criteria |
176 if values[0] == 'unbounded': |
180 if values[0] == 'unbounded': |
177 if not gbl: |
181 if not gbl: |
178 where += ["MIN" + crit + " IS NULL"] |
182 where += ["MIN" + crit + " IS NULL"] |
315 # verify each range criteria is well formed |
319 # verify each range criteria is well formed |
316 for crit in criteria: |
320 for crit in criteria: |
317 # gather this criteria's values |
321 # gather this criteria's values |
318 man_criterion = criteria[crit] |
322 man_criterion = criteria[crit] |
319 # check "value" criteria here (check the criteria exists in DB |
323 # check "value" criteria here (check the criteria exists in DB |
320 if isinstance(man_criterion, basestring): |
324 if not AIdb.isRangeCriteria(dbo.getQueue(), crit, table): |
321 # only check criteria in use in the DB |
325 # only check criteria in use in the DB |
322 if crit not in critlist: |
326 if crit not in critlist: |
323 raise SystemExit(_( |
327 raise SystemExit(_( |
324 "Error:\tCriteria %s is not a valid criteria!") % crit) |
328 "Error:\tCriteria %s is not a valid criteria!") % crit) |
325 # This is a range criteria. (Check that ranges are valid, that |
329 # This is a range criteria. (Check that ranges are valid, that |