|
@@ 1745-1760 (lines=16) @@
|
| 1742 |
|
" FROM tbl_points " |
| 1743 |
|
" WHERE id = %s ", (point['id'],)) |
| 1744 |
|
row = cursor.fetchone() |
| 1745 |
|
if row is None: |
| 1746 |
|
cursor.close() |
| 1747 |
|
cnx.close() |
| 1748 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 1749 |
|
description='API.POINT_NOT_FOUND') |
| 1750 |
|
elif row[1] == 'ENERGY_VALUE': |
| 1751 |
|
query = (" SELECT p.id " |
| 1752 |
|
" FROM tbl_meters_points mp, tbl_points p " |
| 1753 |
|
" WHERE mp.meter_id = %s AND mp.point_id = p.id AND p.object_type = 'ENERGY_VALUE' ") |
| 1754 |
|
cursor.execute(query, (new_id,)) |
| 1755 |
|
rows_points = cursor.fetchall() |
| 1756 |
|
if rows_points is not None and len(rows_points) > 0: |
| 1757 |
|
cursor.close() |
| 1758 |
|
cnx.close() |
| 1759 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.ERROR', |
| 1760 |
|
description= |
| 1761 |
|
'API.METER_CANNOT_HAVE_MORE_THAN_ONE_ENERGY_VALUE_POINTS') |
| 1762 |
|
|
| 1763 |
|
query = (" SELECT id " |
|
@@ 1892-1907 (lines=16) @@
|
| 1889 |
|
" FROM tbl_points " |
| 1890 |
|
" WHERE id = %s ", (point['id'],)) |
| 1891 |
|
row = cursor.fetchone() |
| 1892 |
|
if row is None: |
| 1893 |
|
cursor.close() |
| 1894 |
|
cnx.close() |
| 1895 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 1896 |
|
description='API.POINT_NOT_FOUND') |
| 1897 |
|
elif row[1] == 'ENERGY_VALUE': |
| 1898 |
|
query = (" SELECT p.id " |
| 1899 |
|
" FROM tbl_meters_points mp, tbl_points p " |
| 1900 |
|
" WHERE mp.meter_id = %s AND mp.point_id = p.id AND p.object_type = 'ENERGY_VALUE' ") |
| 1901 |
|
cursor.execute(query, (new_id,)) |
| 1902 |
|
rows_points = cursor.fetchall() |
| 1903 |
|
if rows_points is not None and len(rows_points) > 0: |
| 1904 |
|
cursor.close() |
| 1905 |
|
cnx.close() |
| 1906 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.ERROR', |
| 1907 |
|
description= |
| 1908 |
|
'API.METER_CANNOT_HAVE_MORE_THAN_ONE_ENERGY_VALUE_POINTS') |
| 1909 |
|
|
| 1910 |
|
query = (" SELECT id " |
|
@@ 1157-1172 (lines=16) @@
|
| 1154 |
|
" FROM tbl_points " |
| 1155 |
|
" WHERE id = %s ", (new_values['data']['point_id'],)) |
| 1156 |
|
row = cursor.fetchone() |
| 1157 |
|
if row is None: |
| 1158 |
|
cursor.close() |
| 1159 |
|
cnx.close() |
| 1160 |
|
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
| 1161 |
|
description='API.POINT_NOT_FOUND') |
| 1162 |
|
elif row[1] == 'ENERGY_VALUE': |
| 1163 |
|
query = (" SELECT p.id " |
| 1164 |
|
" FROM tbl_meters_points mp, tbl_points p " |
| 1165 |
|
" WHERE mp.meter_id = %s AND mp.point_id = p.id AND p.object_type = 'ENERGY_VALUE' ") |
| 1166 |
|
cursor.execute(query, (id_,)) |
| 1167 |
|
rows_points = cursor.fetchall() |
| 1168 |
|
if rows_points is not None and len(rows_points) > 0: |
| 1169 |
|
cursor.close() |
| 1170 |
|
cnx.close() |
| 1171 |
|
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.ERROR', |
| 1172 |
|
description='API.METER_CANNOT_HAVE_MORE_THAN_ONE_ENERGY_VALUE_POINTS') |
| 1173 |
|
|
| 1174 |
|
query = (" SELECT id " |
| 1175 |
|
" FROM tbl_meters_points " |