forked from cemaden-educacao/WPD-MobileApp
GabrielTrettel
3 years ago
6 changed files with 412 additions and 0 deletions
-
280db/create_config_tables.sql
-
46db/floodzones-river-rain-api.json
-
21db/forms-fields-answers.json
-
18db/pluviometer-api.json
-
27db/pluviometer-modal-api.json
-
20db/pluviometer-register-api.json
@ -0,0 +1,280 @@ |
|||
DO $$ |
|||
DECLARE |
|||
--id fields |
|||
idfieldsituationcode bigint; |
|||
idfieldslatitude bigint; |
|||
idfieldslongitude bigint; |
|||
idfieldsaddress bigint; |
|||
idfieldsdate bigint; |
|||
idfieldstime bigint; |
|||
idfieldscomment bigint; |
|||
idfieldsimages bigint; |
|||
idfieldsinsname bigint; |
|||
idfieldsinstype bigint; |
|||
idfieldsvalue bigint; |
|||
|
|||
--id forms |
|||
idfloodzonesform bigint; |
|||
idrainform bigint; |
|||
idriverform bigint; |
|||
idpluvform bigint; |
|||
idpluvregsform bigint; |
|||
|
|||
BEGIN |
|||
---------------------------------- Fields -------------------------------------------------- |
|||
--situação do evento |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Situation', 'situation of the event', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldsituationcode; |
|||
|
|||
--Latitude |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Latitude', 'Event location latitude', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'real' |
|||
RETURNING id INTO idfieldslatitude; |
|||
|
|||
--Longitude |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Longitude', 'Event location longitude', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'real' |
|||
RETURNING id INTO idfieldslongitude; |
|||
|
|||
--Endereço |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Address', 'Event adress', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldsaddress; |
|||
|
|||
--Data |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Date_event', 'Event date', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldsdate; |
|||
|
|||
--Hora |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Time_event', 'Event time', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldstime; |
|||
|
|||
--Comentário |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Comment', 'Additional comment about the event', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldscomment; |
|||
|
|||
--Imagens |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Images', 'Event Images', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldsimages; |
|||
|
|||
--Qtd de agua no pluviometro |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Rain_amount', 'amount of rain recorded in the pluviometer', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'real' |
|||
RETURNING id INTO idfieldsvalue; |
|||
|
|||
--Tipo da instituição |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Institute_type', 'Kind of an institute', '', 1 |
|||
FROM fieldsdatatypes fdt WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldsinstype; |
|||
|
|||
--Nome da Instituição |
|||
INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active) |
|||
SELECT fdt.id, 'Institute_name', 'Name of an institute', '', 1 |
|||
FROM fieldsdatatypes fdt |
|||
WHERE fdt.name = 'text' |
|||
RETURNING id INTO idfieldsinsname; |
|||
|
|||
---------------------------------- Formulários --------------------------------------- |
|||
--Begin FloodZones Form |
|||
INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) |
|||
SELECT fo.id, 'FLOODZONES_FORM', 'Flood Zones Form', 'Flood Zones Form', current_timestamp, 1 |
|||
FROM formsorigins fo |
|||
WHERE fo.name = 'WP6.MobileApp' |
|||
RETURNING id INTO idfloodzonesform; |
|||
|
|||
--situação |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldsituationcode, 1); |
|||
|
|||
--local (lat, log e endereço) |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldslatitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldslongitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldsaddress, 1); |
|||
|
|||
--data e hora |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldsdate, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldstime, 1); |
|||
|
|||
--comentário |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldscomment, 1); |
|||
|
|||
--imagens |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idfloodzonesform, idfieldsimages, 1); |
|||
--End FloodZones Form |
|||
|
|||
--Begin Rain Form |
|||
INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) |
|||
SELECT fo.id, 'RAIN_FORM', 'Rain', 'Rain zones Form', current_timestamp, 1 |
|||
FROM formsorigins fo |
|||
WHERE fo.name = 'WP6.MobileApp' |
|||
RETURNING id INTO idrainform; |
|||
|
|||
--situação |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldsituationcode, 1); |
|||
|
|||
--local (lat, log e endereço) |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldslatitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldslongitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldsaddress, 1); |
|||
|
|||
--data e hora |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldsdate, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldstime, 1); |
|||
|
|||
--comentário |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldscomment, 1); |
|||
|
|||
--imagens |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idrainform, idfieldsimages, 1); |
|||
--End Rain Form |
|||
|
|||
--Begin Pluviometer Form |
|||
INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) |
|||
SELECT fo.id, 'PLUVIOMETERS_FORM', 'Pluviometers', 'Pluviometers Form', current_timestamp, 1 |
|||
FROM formsorigins fo |
|||
WHERE fo.name = 'WP6.MobileApp' |
|||
RETURNING id INTO idpluvform; |
|||
|
|||
--situação |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldsituationcode, 1); |
|||
|
|||
--local (lat, log e endereço) |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldslatitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldslongitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldsaddress, 1); |
|||
|
|||
--data e hora |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldsdate, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldstime, 1); |
|||
|
|||
--comentário |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldscomment, 1); |
|||
|
|||
--imagens |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvform, idfieldsimages, 1); |
|||
--End Pluviometer Form |
|||
--Begin River Form |
|||
INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) |
|||
SELECT fo.id, 'RIVERFLOOD_FORM', 'River Flood', 'River Flood Form', current_timestamp, 1 |
|||
FROM formsorigins fo |
|||
WHERE fo.name = 'WP6.MobileApp' |
|||
RETURNING id INTO idriverform; |
|||
|
|||
--situação |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldsituationcode, 1); |
|||
|
|||
--local (lat, log e endereço) |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldslatitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldslongitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldsaddress, 1); |
|||
|
|||
--data e hora |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldsdate, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldstime, 1); |
|||
|
|||
--comentário |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldscomment, 1); |
|||
|
|||
--imagens |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idriverform, idfieldsimages, 1); |
|||
--End River Form |
|||
|
|||
--Pluviometer Registration Form |
|||
INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) |
|||
SELECT fo.id, 'PLUVIOMETERS_REGISTRATION', 'Pluviometer registration', 'Pluviometer registration', current_timestamp, 1 |
|||
FROM formsorigins fo |
|||
WHERE fo.name = 'WP6.MobileApp' |
|||
RETURNING id INTO idpluvregsform; |
|||
|
|||
--local (lat, log e endereço) |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvregsform, idfieldslatitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvregsform, idfieldslongitude, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvregsform, idfieldsaddress, 1); |
|||
|
|||
--data e hora |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvregsform, idfieldsdate, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvregsform, idfieldstime, 1); |
|||
|
|||
--Instituição (tipo e nome) |
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvregsform, idfieldsinstype, 1); |
|||
|
|||
INSERT INTO formsfields(id, idforms, idfields, active) |
|||
VALUES (DEFAULT, idpluvregsform, idfieldsinsname, 1); |
|||
--End Pluviometer Registration Form |
|||
END $$' |
@ -0,0 +1,46 @@ |
|||
JSON intended to get all forms |
|||
|
|||
|
|||
{ |
|||
"responseTimestamp": "2021-08-05T19:23:50.126Z", |
|||
"responseData": { |
|||
"array_to_json": [ |
|||
{ |
|||
"code": "vegetation_sp_wsg84", |
|||
"name": "Vegetation_SP_WSG84 sh file", |
|||
"description": "Vegetation_SP_WSG84 shape file" |
|||
}, |
|||
{ |
|||
"code": "FLOODZONES_FORM", |
|||
"name": "Flood Zones Form", |
|||
"description": "FloodZones Form" |
|||
}, |
|||
{ |
|||
"code": "susceptibilidade_inundacao", |
|||
"name": "Áreas com Suscetibilidade a Inundação", |
|||
"description": "CPRM areas with classes of susceptibility to flooding" |
|||
}, |
|||
{ |
|||
"code": "PLUVIOMETERS_FORM", |
|||
"name": "Pluviometers", |
|||
"description": "Pluviometers Form" |
|||
}, |
|||
{ |
|||
"code": "RAIN_FORM", |
|||
"name": "Rain", |
|||
"description": "Rain zones Form" |
|||
}, |
|||
{ |
|||
"code": "RIVERFLOOD_FORM", |
|||
"name": "River Flood", |
|||
"description": "River Flood Form" |
|||
}, |
|||
{ |
|||
"code": "PLUVIOMETERS_REGISTRATION", |
|||
"name": "Pluviometer registration", |
|||
"description": "Pluviometer registration" |
|||
} |
|||
] |
|||
}, |
|||
"success": true |
|||
} |
@ -0,0 +1,21 @@ |
|||
This example for floodzones also applies for river and rain. All fields are equal. |
|||
|
|||
|
|||
{ |
|||
"responseData": { |
|||
"array_to_json": [{ |
|||
"formcode": "FLOODZONES_FORM", |
|||
"formsanswersuserinformer": "admin@wpd.com", |
|||
"filds": [{ |
|||
"fieldsanswerssituation": "intransitavel", |
|||
"fieldsanswerslatitude": 4.750550953715424, |
|||
"fieldsanswerslongitude": -74.1179903701844, |
|||
"fieldsanswerseventaddress": "Rua dos bobos, 81", |
|||
"fieldsanswerseventdate": "11-08-2021", |
|||
"fieldsanswerseventtime": "21:52", |
|||
"fielsanswercomment": "users description about the current event", |
|||
"fieldsanswerimages": "base64" |
|||
}] |
|||
}] |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
JSON intended to display pluviometer icons on map |
|||
|
|||
|
|||
{ |
|||
"responseData": { |
|||
"array_to_json": [{ |
|||
"formcode": "PLUVIOMETERS_FORM", |
|||
"formsanswersuserinformer": "admin@wpd.com", |
|||
"fieldsanswerslatitude": 4.750550953715424, |
|||
"fieldsanswerslongitude": -74.1179903701844 |
|||
}, |
|||
"formcode": "PLUVIOMETERS_FORM", |
|||
"formsanswersuserinformer": "admin222@wpd.com", |
|||
"fieldsanswerslatitude": 4.23876482872188, |
|||
"fieldsanswerslongitude": -79.1179903701844 |
|||
}] |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
JSON intended to display pluviometer data on modal |
|||
|
|||
|
|||
{ |
|||
"responseData": { |
|||
"array_to_json": [{ |
|||
"formcode": "PLUVIOMETERS_FORM", |
|||
"formsanswersuserinformer": "admin@wpd.com", |
|||
"fias": [{ |
|||
"username" : "Fulano", |
|||
"userrole" : "Professor", |
|||
"institutionname": "E.E. Vicente Leporace", |
|||
"address" : "Rua Nassau", |
|||
"images" : "base64", |
|||
"pluviometerformsanswers" : [ |
|||
{"fieldsanswersdate": "11/02", "fieldsanswersrainamount": 5}, |
|||
{"fieldsanswersdate": "10/02", "fieldsanswersrainamount": 5}, |
|||
{"fieldsanswersdate": "9/02", "fieldsanswersrainamount": 5}, |
|||
{"fieldsanswersdate": "8/02", "fieldsanswersrainamount": 5}, |
|||
{"fieldsanswersdate": "7/02", "fieldsanswersrainamount": 5}, |
|||
{"fieldsanswersdate": "6/02", "fieldsanswersrainamount": 5}, |
|||
{"fieldsanswersdate": "2/02", "fieldsanswersrainamount": 5} |
|||
] |
|||
}] |
|||
}] |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
This JSON is used to insert Pluviometer data into datalake |
|||
|
|||
|
|||
{ |
|||
"responseData": { |
|||
"array_to_json": [{ |
|||
"formcode": "PLUVIOMETERS_REGISTRATION", |
|||
"formsanswersuserinformer": "admin@wpd.com", |
|||
"filds": [{ |
|||
"fieldsanswerslatitude": 4.750550953715424, |
|||
"fieldsanswerslongitude": -74.1179903701844, |
|||
"fieldsanswerseventaddress": "Rua dos bobos, 81", |
|||
"fieldsanswerseventdate": "11-08-2021", |
|||
"fieldsanswerseventtime": "21:52", |
|||
"fieldsanswersinstitutename": "E. E. Vagner", |
|||
"fieldsanswerrinstitutetype": "Escola" |
|||
}] |
|||
}] |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue