|
@@ 4899-4960 (lines=62) @@
|
| 4896 |
|
str(new_values['data']['point_id']) |
| 4897 |
|
|
| 4898 |
|
|
| 4899 |
|
class EnergyStorageContainerPCSPointItem: |
| 4900 |
|
def __init__(self): |
| 4901 |
|
"""Initializes EnergyStorageContainerPCSPointItem""" |
| 4902 |
|
pass |
| 4903 |
|
|
| 4904 |
|
@staticmethod |
| 4905 |
|
def on_options(req, resp, id_, pcsid, pid): |
| 4906 |
|
resp.status = falcon.HTTP_200 |
| 4907 |
|
|
| 4908 |
|
@staticmethod |
| 4909 |
|
@user_logger |
| 4910 |
|
def on_delete(req, resp, id_, pcsid, pid): |
| 4911 |
|
"""Handles DELETE requests""" |
| 4912 |
|
admin_control(req) |
| 4913 |
|
if not id_.isdigit() or int(id_) <= 0: |
| 4914 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 4915 |
|
description='API.INVALID_ENERGY_STORAGE_CONTAINER_ID') |
| 4916 |
|
if not pcsid.isdigit() or int(pcsid) <= 0: |
| 4917 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 4918 |
|
description='API.INVALID_PCS_ID') |
| 4919 |
|
if not pid.isdigit() or int(pid) <= 0: |
| 4920 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 4921 |
|
description='API.INVALID_POINT_ID') |
| 4922 |
|
|
| 4923 |
|
cnx = mysql.connector.connect(**config.myems_system_db) |
| 4924 |
|
cursor = cnx.cursor() |
| 4925 |
|
|
| 4926 |
|
cursor.execute(" SELECT name " |
| 4927 |
|
" FROM tbl_energy_storage_containers_pcses " |
| 4928 |
|
" WHERE energy_storage_container_id = %s AND id = %s ", (id_, pcsid,)) |
| 4929 |
|
if cursor.fetchone() is None: |
| 4930 |
|
cursor.close() |
| 4931 |
|
cnx.close() |
| 4932 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 4933 |
|
description='API.ENERGY_STORAGE_CONTAINER_PCS_NOT_FOUND') |
| 4934 |
|
|
| 4935 |
|
cursor.execute(" SELECT name " |
| 4936 |
|
" FROM tbl_points " |
| 4937 |
|
" WHERE id = %s ", (pid,)) |
| 4938 |
|
if cursor.fetchone() is None: |
| 4939 |
|
cursor.close() |
| 4940 |
|
cnx.close() |
| 4941 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 4942 |
|
description='API.POINT_NOT_FOUND') |
| 4943 |
|
|
| 4944 |
|
cursor.execute(" SELECT id " |
| 4945 |
|
" FROM tbl_energy_storage_containers_pcses_points " |
| 4946 |
|
" WHERE pcs_id = %s AND point_id = %s ", (pcsid, pid)) |
| 4947 |
|
if cursor.fetchone() is None: |
| 4948 |
|
cursor.close() |
| 4949 |
|
cnx.close() |
| 4950 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 4951 |
|
description='API.PCS_POINT_RELATION_NOT_FOUND') |
| 4952 |
|
|
| 4953 |
|
cursor.execute(" DELETE FROM tbl_energy_storage_containers_pcses_points " |
| 4954 |
|
" WHERE pcs_id = %s AND point_id = %s ", (pcsid, pid)) |
| 4955 |
|
cnx.commit() |
| 4956 |
|
|
| 4957 |
|
cursor.close() |
| 4958 |
|
cnx.close() |
| 4959 |
|
|
| 4960 |
|
resp.status = falcon.HTTP_204 |
| 4961 |
|
|
| 4962 |
|
|
| 4963 |
|
class EnergyStorageContainerScheduleCollection: |
|
@@ 4325-4386 (lines=62) @@
|
| 4322 |
|
str(new_values['data']['point_id']) |
| 4323 |
|
|
| 4324 |
|
|
| 4325 |
|
class EnergyStorageContainerLoadPointItem: |
| 4326 |
|
def __init__(self): |
| 4327 |
|
"""Initializes EnergyStorageContainerLoadPointItem""" |
| 4328 |
|
pass |
| 4329 |
|
|
| 4330 |
|
@staticmethod |
| 4331 |
|
def on_options(req, resp, id_, lid, pid): |
| 4332 |
|
resp.status = falcon.HTTP_200 |
| 4333 |
|
|
| 4334 |
|
@staticmethod |
| 4335 |
|
@user_logger |
| 4336 |
|
def on_delete(req, resp, id_, lid, pid): |
| 4337 |
|
"""Handles DELETE requests""" |
| 4338 |
|
admin_control(req) |
| 4339 |
|
if not id_.isdigit() or int(id_) <= 0: |
| 4340 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 4341 |
|
description='API.INVALID_ENERGY_STORAGE_CONTAINER_ID') |
| 4342 |
|
if not lid.isdigit() or int(lid) <= 0: |
| 4343 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 4344 |
|
description='API.INVALID_LOAD_ID') |
| 4345 |
|
if not pid.isdigit() or int(pid) <= 0: |
| 4346 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 4347 |
|
description='API.INVALID_POINT_ID') |
| 4348 |
|
|
| 4349 |
|
cnx = mysql.connector.connect(**config.myems_system_db) |
| 4350 |
|
cursor = cnx.cursor() |
| 4351 |
|
|
| 4352 |
|
cursor.execute(" SELECT name " |
| 4353 |
|
" FROM tbl_energy_storage_containers_loads " |
| 4354 |
|
" WHERE energy_storage_container_id = %s AND id = %s ", (id_, lid,)) |
| 4355 |
|
if cursor.fetchone() is None: |
| 4356 |
|
cursor.close() |
| 4357 |
|
cnx.close() |
| 4358 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 4359 |
|
description='API.ENERGY_STORAGE_CONTAINER_LOAD_NOT_FOUND') |
| 4360 |
|
|
| 4361 |
|
cursor.execute(" SELECT name " |
| 4362 |
|
" FROM tbl_points " |
| 4363 |
|
" WHERE id = %s ", (pid,)) |
| 4364 |
|
if cursor.fetchone() is None: |
| 4365 |
|
cursor.close() |
| 4366 |
|
cnx.close() |
| 4367 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 4368 |
|
description='API.POINT_NOT_FOUND') |
| 4369 |
|
|
| 4370 |
|
cursor.execute(" SELECT id " |
| 4371 |
|
" FROM tbl_energy_storage_containers_loads_points " |
| 4372 |
|
" WHERE load_id = %s AND point_id = %s ", (lid, pid)) |
| 4373 |
|
if cursor.fetchone() is None: |
| 4374 |
|
cursor.close() |
| 4375 |
|
cnx.close() |
| 4376 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 4377 |
|
description='API.LOAD_POINT_RELATION_NOT_FOUND') |
| 4378 |
|
|
| 4379 |
|
cursor.execute(" DELETE FROM tbl_energy_storage_containers_loads_points " |
| 4380 |
|
" WHERE load_id = %s AND point_id = %s ", (lid, pid)) |
| 4381 |
|
cnx.commit() |
| 4382 |
|
|
| 4383 |
|
cursor.close() |
| 4384 |
|
cnx.close() |
| 4385 |
|
|
| 4386 |
|
resp.status = falcon.HTTP_204 |
| 4387 |
|
|
| 4388 |
|
|
| 4389 |
|
class EnergyStorageContainerPCSCollection: |
|
@@ 3701-3762 (lines=62) @@
|
| 3698 |
|
str(new_values['data']['point_id']) |
| 3699 |
|
|
| 3700 |
|
|
| 3701 |
|
class EnergyStorageContainerHVACPointItem: |
| 3702 |
|
def __init__(self): |
| 3703 |
|
"""Initializes EnergyStorageContainerHVACPointItem""" |
| 3704 |
|
pass |
| 3705 |
|
|
| 3706 |
|
@staticmethod |
| 3707 |
|
def on_options(req, resp, id_, hid, pid): |
| 3708 |
|
resp.status = falcon.HTTP_200 |
| 3709 |
|
|
| 3710 |
|
@staticmethod |
| 3711 |
|
@user_logger |
| 3712 |
|
def on_delete(req, resp, id_, hid, pid): |
| 3713 |
|
"""Handles DELETE requests""" |
| 3714 |
|
admin_control(req) |
| 3715 |
|
if not id_.isdigit() or int(id_) <= 0: |
| 3716 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 3717 |
|
description='API.INVALID_ENERGY_STORAGE_CONTAINER_ID') |
| 3718 |
|
if not hid.isdigit() or int(hid) <= 0: |
| 3719 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 3720 |
|
description='API.INVALID_HVAC_ID') |
| 3721 |
|
if not pid.isdigit() or int(pid) <= 0: |
| 3722 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 3723 |
|
description='API.INVALID_POINT_ID') |
| 3724 |
|
|
| 3725 |
|
cnx = mysql.connector.connect(**config.myems_system_db) |
| 3726 |
|
cursor = cnx.cursor() |
| 3727 |
|
|
| 3728 |
|
cursor.execute(" SELECT name " |
| 3729 |
|
" FROM tbl_energy_storage_containers_hvacs " |
| 3730 |
|
" WHERE energy_storage_container_id = %s AND id = %s ", (id_, hid,)) |
| 3731 |
|
if cursor.fetchone() is None: |
| 3732 |
|
cursor.close() |
| 3733 |
|
cnx.close() |
| 3734 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 3735 |
|
description='API.ENERGY_STORAGE_CONTAINER_HVAC_NOT_FOUND') |
| 3736 |
|
|
| 3737 |
|
cursor.execute(" SELECT name " |
| 3738 |
|
" FROM tbl_points " |
| 3739 |
|
" WHERE id = %s ", (pid,)) |
| 3740 |
|
if cursor.fetchone() is None: |
| 3741 |
|
cursor.close() |
| 3742 |
|
cnx.close() |
| 3743 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 3744 |
|
description='API.POINT_NOT_FOUND') |
| 3745 |
|
|
| 3746 |
|
cursor.execute(" SELECT id " |
| 3747 |
|
" FROM tbl_energy_storage_containers_hvacs_points " |
| 3748 |
|
" WHERE hvac_id = %s AND point_id = %s ", (hid, pid)) |
| 3749 |
|
if cursor.fetchone() is None: |
| 3750 |
|
cursor.close() |
| 3751 |
|
cnx.close() |
| 3752 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 3753 |
|
description='API.HVAC_POINT_RELATION_NOT_FOUND') |
| 3754 |
|
|
| 3755 |
|
cursor.execute(" DELETE FROM tbl_energy_storage_containers_hvacs_points " |
| 3756 |
|
" WHERE hvac_id = %s AND point_id = %s ", (hid, pid)) |
| 3757 |
|
cnx.commit() |
| 3758 |
|
|
| 3759 |
|
cursor.close() |
| 3760 |
|
cnx.close() |
| 3761 |
|
|
| 3762 |
|
resp.status = falcon.HTTP_204 |
| 3763 |
|
|
| 3764 |
|
|
| 3765 |
|
class EnergyStorageContainerLoadCollection: |
|
@@ 3222-3283 (lines=62) @@
|
| 3219 |
|
str(new_values['data']['point_id']) |
| 3220 |
|
|
| 3221 |
|
|
| 3222 |
|
class EnergyStorageContainerGridPointItem: |
| 3223 |
|
def __init__(self): |
| 3224 |
|
"""Initializes EnergyStorageContainerGridPointItem""" |
| 3225 |
|
pass |
| 3226 |
|
|
| 3227 |
|
@staticmethod |
| 3228 |
|
def on_options(req, resp, id_, gid, pid): |
| 3229 |
|
resp.status = falcon.HTTP_200 |
| 3230 |
|
|
| 3231 |
|
@staticmethod |
| 3232 |
|
@user_logger |
| 3233 |
|
def on_delete(req, resp, id_, gid, pid): |
| 3234 |
|
"""Handles DELETE requests""" |
| 3235 |
|
admin_control(req) |
| 3236 |
|
if not id_.isdigit() or int(id_) <= 0: |
| 3237 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 3238 |
|
description='API.INVALID_ENERGY_STORAGE_CONTAINER_ID') |
| 3239 |
|
if not gid.isdigit() or int(gid) <= 0: |
| 3240 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 3241 |
|
description='API.INVALID_GRID_ID') |
| 3242 |
|
if not pid.isdigit() or int(pid) <= 0: |
| 3243 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 3244 |
|
description='API.INVALID_POINT_ID') |
| 3245 |
|
|
| 3246 |
|
cnx = mysql.connector.connect(**config.myems_system_db) |
| 3247 |
|
cursor = cnx.cursor() |
| 3248 |
|
|
| 3249 |
|
cursor.execute(" SELECT name " |
| 3250 |
|
" FROM tbl_energy_storage_containers_grids " |
| 3251 |
|
" WHERE energy_storage_container_id = %s AND id = %s ", (id_, gid,)) |
| 3252 |
|
if cursor.fetchone() is None: |
| 3253 |
|
cursor.close() |
| 3254 |
|
cnx.close() |
| 3255 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 3256 |
|
description='API.ENERGY_STORAGE_CONTAINER_GRID_NOT_FOUND') |
| 3257 |
|
|
| 3258 |
|
cursor.execute(" SELECT name " |
| 3259 |
|
" FROM tbl_points " |
| 3260 |
|
" WHERE id = %s ", (pid,)) |
| 3261 |
|
if cursor.fetchone() is None: |
| 3262 |
|
cursor.close() |
| 3263 |
|
cnx.close() |
| 3264 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 3265 |
|
description='API.POINT_NOT_FOUND') |
| 3266 |
|
|
| 3267 |
|
cursor.execute(" SELECT id " |
| 3268 |
|
" FROM tbl_energy_storage_containers_grids_points " |
| 3269 |
|
" WHERE grid_id = %s AND point_id = %s ", (gid, pid)) |
| 3270 |
|
if cursor.fetchone() is None: |
| 3271 |
|
cursor.close() |
| 3272 |
|
cnx.close() |
| 3273 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 3274 |
|
description='API.GRID_POINT_RELATION_NOT_FOUND') |
| 3275 |
|
|
| 3276 |
|
cursor.execute(" DELETE FROM tbl_energy_storage_containers_grids_points " |
| 3277 |
|
" WHERE grid_id = %s AND point_id = %s ", (gid, pid)) |
| 3278 |
|
cnx.commit() |
| 3279 |
|
|
| 3280 |
|
cursor.close() |
| 3281 |
|
cnx.close() |
| 3282 |
|
|
| 3283 |
|
resp.status = falcon.HTTP_204 |
| 3284 |
|
|
| 3285 |
|
|
| 3286 |
|
class EnergyStorageContainerHVACCollection: |
|
@@ 2558-2619 (lines=62) @@
|
| 2555 |
|
str(new_values['data']['point_id']) |
| 2556 |
|
|
| 2557 |
|
|
| 2558 |
|
class EnergyStorageContainerFirecontrolPointItem: |
| 2559 |
|
def __init__(self): |
| 2560 |
|
"""Initializes MeterPointItem""" |
| 2561 |
|
pass |
| 2562 |
|
|
| 2563 |
|
@staticmethod |
| 2564 |
|
def on_options(req, resp, id_, fid, pid): |
| 2565 |
|
resp.status = falcon.HTTP_200 |
| 2566 |
|
|
| 2567 |
|
@staticmethod |
| 2568 |
|
@user_logger |
| 2569 |
|
def on_delete(req, resp, id_, fid, pid): |
| 2570 |
|
"""Handles DELETE requests""" |
| 2571 |
|
admin_control(req) |
| 2572 |
|
if not id_.isdigit() or int(id_) <= 0: |
| 2573 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 2574 |
|
description='API.INVALID_ENERGY_STORAGE_CONTAINER_ID') |
| 2575 |
|
if not fid.isdigit() or int(fid) <= 0: |
| 2576 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 2577 |
|
description='API.INVALID_DCDC_ID') |
| 2578 |
|
if not pid.isdigit() or int(pid) <= 0: |
| 2579 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 2580 |
|
description='API.INVALID_POINT_ID') |
| 2581 |
|
|
| 2582 |
|
cnx = mysql.connector.connect(**config.myems_system_db) |
| 2583 |
|
cursor = cnx.cursor() |
| 2584 |
|
|
| 2585 |
|
cursor.execute(" SELECT name " |
| 2586 |
|
" FROM tbl_energy_storage_containers_firecontrols " |
| 2587 |
|
" WHERE energy_storage_container_id = %s AND id = %s ", (id_, fid,)) |
| 2588 |
|
if cursor.fetchone() is None: |
| 2589 |
|
cursor.close() |
| 2590 |
|
cnx.close() |
| 2591 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 2592 |
|
description='API.ENERGY_STORAGE_CONTAINER_FIRECONTROL_NOT_FOUND') |
| 2593 |
|
|
| 2594 |
|
cursor.execute(" SELECT name " |
| 2595 |
|
" FROM tbl_points " |
| 2596 |
|
" WHERE id = %s ", (pid,)) |
| 2597 |
|
if cursor.fetchone() is None: |
| 2598 |
|
cursor.close() |
| 2599 |
|
cnx.close() |
| 2600 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 2601 |
|
description='API.POINT_NOT_FOUND') |
| 2602 |
|
|
| 2603 |
|
cursor.execute(" SELECT id " |
| 2604 |
|
" FROM tbl_energy_storage_containers_firecontrols_points " |
| 2605 |
|
" WHERE firecontrol_id = %s AND point_id = %s ", (fid, pid)) |
| 2606 |
|
if cursor.fetchone() is None: |
| 2607 |
|
cursor.close() |
| 2608 |
|
cnx.close() |
| 2609 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 2610 |
|
description='API.DCDC_POINT_RELATION_NOT_FOUND') |
| 2611 |
|
|
| 2612 |
|
cursor.execute(" DELETE FROM tbl_energy_storage_containers_firecontrols_points " |
| 2613 |
|
" WHERE firecontrol_id = %s AND point_id = %s ", (fid, pid)) |
| 2614 |
|
cnx.commit() |
| 2615 |
|
|
| 2616 |
|
cursor.close() |
| 2617 |
|
cnx.close() |
| 2618 |
|
|
| 2619 |
|
resp.status = falcon.HTTP_204 |
| 2620 |
|
|
| 2621 |
|
|
| 2622 |
|
class EnergyStorageContainerGridCollection: |
|
@@ 2079-2140 (lines=62) @@
|
| 2076 |
|
str(new_values['data']['point_id']) |
| 2077 |
|
|
| 2078 |
|
|
| 2079 |
|
class EnergyStorageContainerDCDCPointItem: |
| 2080 |
|
def __init__(self): |
| 2081 |
|
"""Initializes MeterPointItem""" |
| 2082 |
|
pass |
| 2083 |
|
|
| 2084 |
|
@staticmethod |
| 2085 |
|
def on_options(req, resp, id_, did, pid): |
| 2086 |
|
resp.status = falcon.HTTP_200 |
| 2087 |
|
|
| 2088 |
|
@staticmethod |
| 2089 |
|
@user_logger |
| 2090 |
|
def on_delete(req, resp, id_, did, pid): |
| 2091 |
|
"""Handles DELETE requests""" |
| 2092 |
|
admin_control(req) |
| 2093 |
|
if not id_.isdigit() or int(id_) <= 0: |
| 2094 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 2095 |
|
description='API.INVALID_ENERGY_STORAGE_CONTAINER_ID') |
| 2096 |
|
if not did.isdigit() or int(did) <= 0: |
| 2097 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 2098 |
|
description='API.INVALID_DCDC_ID') |
| 2099 |
|
if not pid.isdigit() or int(pid) <= 0: |
| 2100 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 2101 |
|
description='API.INVALID_POINT_ID') |
| 2102 |
|
|
| 2103 |
|
cnx = mysql.connector.connect(**config.myems_system_db) |
| 2104 |
|
cursor = cnx.cursor() |
| 2105 |
|
|
| 2106 |
|
cursor.execute(" SELECT name " |
| 2107 |
|
" FROM tbl_energy_storage_containers_dcdcs " |
| 2108 |
|
" WHERE energy_storage_container_id = %s AND id = %s ", (id_, did,)) |
| 2109 |
|
if cursor.fetchone() is None: |
| 2110 |
|
cursor.close() |
| 2111 |
|
cnx.close() |
| 2112 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 2113 |
|
description='API.ENERGY_STORAGE_CONTAINER_DCDC_NOT_FOUND') |
| 2114 |
|
|
| 2115 |
|
cursor.execute(" SELECT name " |
| 2116 |
|
" FROM tbl_points " |
| 2117 |
|
" WHERE id = %s ", (pid,)) |
| 2118 |
|
if cursor.fetchone() is None: |
| 2119 |
|
cursor.close() |
| 2120 |
|
cnx.close() |
| 2121 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 2122 |
|
description='API.POINT_NOT_FOUND') |
| 2123 |
|
|
| 2124 |
|
cursor.execute(" SELECT id " |
| 2125 |
|
" FROM tbl_energy_storage_containers_dcdcs_points " |
| 2126 |
|
" WHERE dcdc_id = %s AND point_id = %s ", (did, pid)) |
| 2127 |
|
if cursor.fetchone() is None: |
| 2128 |
|
cursor.close() |
| 2129 |
|
cnx.close() |
| 2130 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 2131 |
|
description='API.DCDC_POINT_RELATION_NOT_FOUND') |
| 2132 |
|
|
| 2133 |
|
cursor.execute(" DELETE FROM tbl_energy_storage_containers_dcdcs_points " |
| 2134 |
|
" WHERE dcdc_id = %s AND point_id = %s ", (did, pid)) |
| 2135 |
|
cnx.commit() |
| 2136 |
|
|
| 2137 |
|
cursor.close() |
| 2138 |
|
cnx.close() |
| 2139 |
|
|
| 2140 |
|
resp.status = falcon.HTTP_204 |
| 2141 |
|
|
| 2142 |
|
|
| 2143 |
|
class EnergyStorageContainerFirecontrolCollection: |
|
@@ 1424-1485 (lines=62) @@
|
| 1421 |
|
str(new_values['data']['point_id']) |
| 1422 |
|
|
| 1423 |
|
|
| 1424 |
|
class EnergyStorageContainerBatteryPointItem: |
| 1425 |
|
def __init__(self): |
| 1426 |
|
"""Initializes MeterPointItem""" |
| 1427 |
|
pass |
| 1428 |
|
|
| 1429 |
|
@staticmethod |
| 1430 |
|
def on_options(req, resp, id_, bid, pid): |
| 1431 |
|
resp.status = falcon.HTTP_200 |
| 1432 |
|
|
| 1433 |
|
@staticmethod |
| 1434 |
|
@user_logger |
| 1435 |
|
def on_delete(req, resp, id_, bid, pid): |
| 1436 |
|
"""Handles DELETE requests""" |
| 1437 |
|
admin_control(req) |
| 1438 |
|
if not id_.isdigit() or int(id_) <= 0: |
| 1439 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 1440 |
|
description='API.INVALID_ENERGY_STORAGE_CONTAINER_ID') |
| 1441 |
|
if not bid.isdigit() or int(bid) <= 0: |
| 1442 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 1443 |
|
description='API.INVALID_BMS_ID') |
| 1444 |
|
if not pid.isdigit() or int(pid) <= 0: |
| 1445 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
| 1446 |
|
description='API.INVALID_POINT_ID') |
| 1447 |
|
|
| 1448 |
|
cnx = mysql.connector.connect(**config.myems_system_db) |
| 1449 |
|
cursor = cnx.cursor() |
| 1450 |
|
|
| 1451 |
|
cursor.execute(" SELECT name " |
| 1452 |
|
" FROM tbl_energy_storage_containers_batteries " |
| 1453 |
|
" WHERE energy_storage_container_id = %s AND id = %s ", (id_, bid,)) |
| 1454 |
|
if cursor.fetchone() is None: |
| 1455 |
|
cursor.close() |
| 1456 |
|
cnx.close() |
| 1457 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 1458 |
|
description='API.ENERGY_STORAGE_CONTAINER_BMS_NOT_FOUND') |
| 1459 |
|
|
| 1460 |
|
cursor.execute(" SELECT name " |
| 1461 |
|
" FROM tbl_points " |
| 1462 |
|
" WHERE id = %s ", (pid,)) |
| 1463 |
|
if cursor.fetchone() is None: |
| 1464 |
|
cursor.close() |
| 1465 |
|
cnx.close() |
| 1466 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 1467 |
|
description='API.POINT_NOT_FOUND') |
| 1468 |
|
|
| 1469 |
|
cursor.execute(" SELECT id " |
| 1470 |
|
" FROM tbl_energy_storage_containers_bmses_points " |
| 1471 |
|
" WHERE bms_id = %s AND point_id = %s ", (bid, pid)) |
| 1472 |
|
if cursor.fetchone() is None: |
| 1473 |
|
cursor.close() |
| 1474 |
|
cnx.close() |
| 1475 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 1476 |
|
description='API.BMS_POINT_RELATION_NOT_FOUND') |
| 1477 |
|
|
| 1478 |
|
cursor.execute(" DELETE FROM tbl_energy_storage_containers_bmses_points " |
| 1479 |
|
" WHERE bms_id = %s AND point_id = %s ", (bid, pid)) |
| 1480 |
|
cnx.commit() |
| 1481 |
|
|
| 1482 |
|
cursor.close() |
| 1483 |
|
cnx.close() |
| 1484 |
|
|
| 1485 |
|
resp.status = falcon.HTTP_204 |
| 1486 |
|
|
| 1487 |
|
|
| 1488 |
|
class EnergyStorageContainerCommandCollection: |