@@ 796-812 (lines=17) @@ | ||
793 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
794 | description='API.COST_CENTER_NOT_FOUND') |
|
795 | ||
796 | if energy_item_id is not None: |
|
797 | cursor.execute(" SELECT name, energy_category_id " |
|
798 | " FROM tbl_energy_items " |
|
799 | " WHERE id = %s ", |
|
800 | (new_values['data']['energy_item_id'],)) |
|
801 | row = cursor.fetchone() |
|
802 | if row is None: |
|
803 | cursor.close() |
|
804 | cnx.disconnect() |
|
805 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
806 | description='API.ENERGY_ITEM_NOT_FOUND') |
|
807 | else: |
|
808 | if row[1] != energy_category_id: |
|
809 | cursor.close() |
|
810 | cnx.disconnect() |
|
811 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
812 | description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
813 | ||
814 | for variable in new_values['data']['expression']['variables']: |
|
815 | if variable['meter_type'].lower() == 'meter': |
|
@@ 261-277 (lines=17) @@ | ||
258 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
259 | description='API.COST_CENTER_NOT_FOUND') |
|
260 | ||
261 | if energy_item_id is not None: |
|
262 | cursor.execute(" SELECT name, energy_category_id " |
|
263 | " FROM tbl_energy_items " |
|
264 | " WHERE id = %s ", |
|
265 | (new_values['data']['energy_item_id'],)) |
|
266 | row = cursor.fetchone() |
|
267 | if row is None: |
|
268 | cursor.close() |
|
269 | cnx.disconnect() |
|
270 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
271 | description='API.ENERGY_ITEM_NOT_FOUND') |
|
272 | else: |
|
273 | if row[1] != energy_category_id: |
|
274 | cursor.close() |
|
275 | cnx.disconnect() |
|
276 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
277 | description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
278 | ||
279 | for variable in new_values['data']['expression']['variables']: |
|
280 | if variable['meter_type'].lower() == 'meter': |
@@ 688-704 (lines=17) @@ | ||
685 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
686 | description='API.ENERGY_ITEM_DOES_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
687 | ||
688 | if parent_meter_id is not None: |
|
689 | cursor.execute(" SELECT name, energy_category_id " |
|
690 | " FROM tbl_meters " |
|
691 | " WHERE id = %s ", |
|
692 | (new_values['data']['parent_meter_id'],)) |
|
693 | row = cursor.fetchone() |
|
694 | if row is None: |
|
695 | cursor.close() |
|
696 | cnx.disconnect() |
|
697 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
698 | description='API.PARENT_METER_NOT_FOUND') |
|
699 | else: |
|
700 | if row[1] != energy_category_id: |
|
701 | cursor.close() |
|
702 | cnx.disconnect() |
|
703 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
704 | description='API.PARENT_METER_DOES_NOT BELONG_TO_SAME_ENERGY_CATEGORY') |
|
705 | ||
706 | if parent_meter_id is not None: |
|
707 | cursor.execute(" SELECT name " |
|
@@ 670-686 (lines=17) @@ | ||
667 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
668 | description='API.COST_CENTER_NOT_FOUND') |
|
669 | ||
670 | if energy_item_id is not None: |
|
671 | cursor.execute(" SELECT name, energy_category_id " |
|
672 | " FROM tbl_energy_items " |
|
673 | " WHERE id = %s ", |
|
674 | (new_values['data']['energy_item_id'],)) |
|
675 | row = cursor.fetchone() |
|
676 | if row is None: |
|
677 | cursor.close() |
|
678 | cnx.disconnect() |
|
679 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
680 | description='API.ENERGY_ITEM_NOT_FOUND') |
|
681 | else: |
|
682 | if row[1] != energy_category_id: |
|
683 | cursor.close() |
|
684 | cnx.disconnect() |
|
685 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
686 | description='API.ENERGY_ITEM_DOES_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
687 | ||
688 | if parent_meter_id is not None: |
|
689 | cursor.execute(" SELECT name, energy_category_id " |
|
@@ 230-246 (lines=17) @@ | ||
227 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
228 | description='API.ENERGY_ITEM_DOES_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
229 | ||
230 | if parent_meter_id is not None: |
|
231 | cursor.execute(" SELECT name, energy_category_id " |
|
232 | " FROM tbl_meters " |
|
233 | " WHERE id = %s ", |
|
234 | (new_values['data']['parent_meter_id'],)) |
|
235 | row = cursor.fetchone() |
|
236 | if row is None: |
|
237 | cursor.close() |
|
238 | cnx.disconnect() |
|
239 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
240 | description='API.PARENT_METER_NOT_FOUND') |
|
241 | else: |
|
242 | if row[1] != energy_category_id: |
|
243 | cursor.close() |
|
244 | cnx.disconnect() |
|
245 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
246 | description='API.PARENT_METER_DOES_NOT BELONG_TO_SAME_ENERGY_CATEGORY') |
|
247 | ||
248 | add_values = (" INSERT INTO tbl_meters " |
|
249 | " (name, uuid, energy_category_id, is_counted, hourly_low_limit, hourly_high_limit," |
|
@@ 212-228 (lines=17) @@ | ||
209 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
210 | description='API.COST_CENTER_NOT_FOUND') |
|
211 | ||
212 | if energy_item_id is not None: |
|
213 | cursor.execute(" SELECT name, energy_category_id " |
|
214 | " FROM tbl_energy_items " |
|
215 | " WHERE id = %s ", |
|
216 | (new_values['data']['energy_item_id'],)) |
|
217 | row = cursor.fetchone() |
|
218 | if row is None: |
|
219 | cursor.close() |
|
220 | cnx.disconnect() |
|
221 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
222 | description='API.ENERGY_ITEM_NOT_FOUND') |
|
223 | else: |
|
224 | if row[1] != energy_category_id: |
|
225 | cursor.close() |
|
226 | cnx.disconnect() |
|
227 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
228 | description='API.ENERGY_ITEM_DOES_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
229 | ||
230 | if parent_meter_id is not None: |
|
231 | cursor.execute(" SELECT name, energy_category_id " |
@@ 583-599 (lines=17) @@ | ||
580 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
581 | description='API.COST_CENTER_NOT_FOUND') |
|
582 | ||
583 | if energy_item_id is not None: |
|
584 | cursor.execute(" SELECT name, energy_category_id " |
|
585 | " FROM tbl_energy_items " |
|
586 | " WHERE id = %s ", |
|
587 | (new_values['data']['energy_item_id'],)) |
|
588 | row = cursor.fetchone() |
|
589 | if row is None: |
|
590 | cursor.close() |
|
591 | cnx.disconnect() |
|
592 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
593 | description='API.ENERGY_ITEM_NOT_FOUND') |
|
594 | else: |
|
595 | if row[1] != energy_category_id: |
|
596 | cursor.close() |
|
597 | cnx.disconnect() |
|
598 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
599 | description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
600 | ||
601 | update_row = (" UPDATE tbl_offline_meters " |
|
602 | " SET name = %s, energy_category_id = %s," |
|
@@ 178-194 (lines=17) @@ | ||
175 | cnx.disconnect() |
|
176 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
177 | description='API.ENERGY_CATEGORY_NOT_FOUND') |
|
178 | if energy_item_id is not None: |
|
179 | cursor.execute(" SELECT name, energy_category_id " |
|
180 | " FROM tbl_energy_items " |
|
181 | " WHERE id = %s ", |
|
182 | (new_values['data']['energy_item_id'],)) |
|
183 | row = cursor.fetchone() |
|
184 | if row is None: |
|
185 | cursor.close() |
|
186 | cnx.disconnect() |
|
187 | raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', |
|
188 | description='API.ENERGY_ITEM_NOT_FOUND') |
|
189 | else: |
|
190 | if row[1] != energy_category_id: |
|
191 | cursor.close() |
|
192 | cnx.disconnect() |
|
193 | raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST', |
|
194 | description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
195 | ||
196 | cursor.execute(" SELECT name " |
|
197 | " FROM tbl_cost_centers " |