The main purpose of safetyNetAlerts is to alert people or get information to send to the emergency services.
The application should provide information about people exposed to potential dangers such as fires, floods, hurricanes and so on. To achieve this task, SafetyNetAlerts will order data from a file and order it to extract specific information about people who are living in an area exposed to danger.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
#Prerequisites What things you need to install and how will you install them:
\1. Java 1.8 or later.
\2. Maven 3.6.3 (It is optional since the maven wrapper is present in the project)
\3. Postman 7 is optional. The application can be used as well with a browser.
#Installing A step by step series of examples that tell you how to get a development environment:
1.Install Java:
https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html
2.Install Maven:
https://maven.apache.org/install.html
3.Install Postman:
https://learning.postman.com/docs/getting-started/installation-and-updates/
#Running App
After installing all the required software, you will be ready to import the code into your favourite IDE and run the SafetyNetAlertsApplication.java to launch the application.
To retrieve all fire stations
http://localhost:8080/fireStation
None
[
{
"address": "1509 Culver St",
"station": 3
}
]
API will return the Json and a 200 OK code if success
You can add a new fire station
http://localhost:8080/fireStation
Address is mandatory
Station is mandatory
{
"address": "1509 Culver St",
"station": "3"
}
API will return a 204 No Content code if success
API will return a 400 Bad Request code if you didn’t provide all the element
Update an existing fire station
http://localhost:8080/fireStation
Address is mandatory to update the station id
Station is mandatory to be updated
{
"address": "1509 Culver St",
"station": "3"
}
API will return a 201 Created code if success
API will return a 422 Unprocessable Entity with message “Address was unknown”, if the fire station is not found
API will return a 400 Bad Request code if you didn’t provide all the element
Delete an existing fire station
http://localhost:8080/fireStation
Address OR station are mandatory to delete the station
{
"address": "1509 Culver St",
"station": "3"
}
API will return a 200 Ok code if success
API will return a 422 Unprocessable Entity with message “Address was unknown”, if the fire station is not found
API will return a 400 Bad Request code if you didn’t provide all the element
To retrieve all person
None
[
{
"firstName": "John",
"lastName": "Boyd",
"address": "1509 Culver St",
"city": "Culver",
"zip": "97451",
"phone": "841-874-6512",
"email": "[email protected]"
}
]
API will return the Json and a 200 OK code if success
You can add a new person
All fields are mandatory
{
"firstName": "John",
"lastName": "Boyd",
"address": "1509 Culver St",
"city": "Culver",
"zip": "97451",
"phone": "841-874-6512",
"email": "[email protected]"
}
API will return a 204 No Content code if success
API will return a 400 Bad Request code if you didn’t provide all the element
Update an existing person
First Name and Last Name are mandatory to find the person to modify
All other fields are also mandatory
{
"firstName": "John",
"lastName": "Boyd",
"address": "1509 Culver St",
"city": "Culver",
"zip": "97451",
"phone": "841-874-6512",
"email": "[email protected]"
}
API will return a 201 Created code if success
API will return a 422 Unprocessable Entity if the person is not found
API will return a 400 Bad Request code if you didn’t provide all the element
Delete an existing person
firstName and lastName are mandatory to process request
{
"firstName": "John",
"lastName": "Boyd",
}
API will return a 200 Ok code if success
API will return a 422 Unprocessable Entity if the person is not found
API will return a 400 Bad Request code if you didn’t provide all the element
To retrieve all medical record
http://localhost:8080/medicalrecord
None
[
{
"firstName": "John",
"lastName": "Boyd",
"birthdate": "1984-06-03",
"medications": [
"aznol:350mg",
"hydrapermazol:100mg"
],
"allergies": [
"nillacilan"
]
}
]
API will return the Json and a 200 OK code if success
You can add a new medical record
http://localhost:8080/medicalrecord
All fields are mandatory
{
"firstName": "John",
"lastName": "Boyd",
"birthdate": "1984-06-03",
"medications": [
"aznol:350mg",
"hydrapermazol:100mg"
],
"allergies": [
"nillacilan"
]
}
API will return a 204 No Content code if success
API will return a 400 Bad Request code if you didn’t provide all the element
Update an existing person
http://localhost:8080/medicalrecord
First Name and Last Name are mandatory to find the person to modify
All other fields are also mandatory
{
"firstName": "John",
"lastName": "Boyd",
"birthdate": "1984-06-03",
"medications": [
"aznol:350mg",
"hydrapermazol:100mg"
],
"allergies": [
"nillacilan"
]
}
API will return a 201 Created code if success
API will return a 422 Unprocessable Entity if the medical record is not found
API will return a 400 Bad Request code if you didn’t provide all the element
- Delete an existing medical record
http://localhost:8080/medicalrecord
firstName and lastName are mandatory to process request
{
"firstName": "John",
"lastName": "Boyd",
}
API will return a 200 Ok code if success
API will return a 422 Unprocessable Entity if the medical record is not found
API will return a 400 Bad Request code if you didn’t provide all the element
firestation/stationNumber
http://localhost:8080/fireStation/stationNumber?id=<fire_station_id>
The number of the station number
{
"person": [
{
"firstName": "Peter",
"lastName": "Duncan",
"address": "644 Gershwin Cir",
"phone": "841-874-6512"
}
],
"numberOfAdult": 5,
"numberOfChildren": 1
}
The URL will return a list of persons that are covered by the station ID provided. The list will return first name, last name, address and phone. Moreover, it will include the number of adult and child (under 18) from the covered area.
/childAlert
[http://localhost:8080/childAlert?address=
](http://localhost:8080/childAlert?address=1509 Culver St)The address of the children
{
"child": [
{
"firstName": "Tenley",
"lastName": "Boyd",
"age": 7
},
{
"firstName": "Roger",
"lastName": "Boyd",
"age": 3
}
],
"familyMember": [
{
"firstName": "John",
"lastName": "Boyd"
},
{
"firstName": "Jacob",
"lastName": "Boyd"
},
{
"firstName": "Felicia",
"lastName": "Boyd"
}
]
}
The API will return a list of children with their age, first name and last name. It will include the names of the inhabitant of the address.
/phoneAlert
http://localhost:8080/phoneAlert?firestation=
the ID of the fire station
{
"phoneNumber": [
"841-874-6512",
"841-874-6513",
"841-874-6512",
"841-874-6512",
"841-874-6544",
"841-874-6512",
"841-874-6544",
"841-874-6741",
"841-874-6874",
"841-874-8888",
"841-874-9888",
"841-874-6544",
"841-874-6741"
]
}
The API will return a list of phone numbers that are covered by the station ID put as parameter.
/fire
[http://localhost:8080/fire?address=
](http://localhost:8080/fire?address=951 LoneTree Rd)The address of the fire station
{
"station": 2,
"inhabitant": [
{
"firstName": "Eric",
"lastName": "Cadigan",
"phone": "841-874-7458",
"age": 75,
"medications": [
"tradoxidine:400mg"
]
}
]
}
The API will return the fire station ID covering the habitation. It will also include the list of inhabitant with the names, phone, age and the medication they are under.
/flood/stations
http://localhost:8080/flood/stations?stations=
a list of ID as integers
[
{
"address": "644 Gershwin Cir",
"inhabitant": [
{
"firstName": "Peter",
"lastName": "Duncan",
"phone": "841-874-6512",
"age": 20,
"medications": []
}
]
}
]
The API will return a list of addresses that are covered by the fire station with the list of inhabitant inside.
/personInfo
http://localhost:8080/personInfo?firstName=&lastName=
the first name and the last name of a person
[
{
"firstName": "John",
"lastName": "Boyd",
"address": "1509 Culver St",
"age": 36,
"email": "[email protected]",
"medication": [
"aznol:350mg",
"hydrapermazol:100mg"
]
}
]
The API will return a list of person with homonyms. It will include the names, address, age, email and the medications of the person.
/communityEmail
http://localhost:8080/communityEmail?city=
The name of the city
{
"email": [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
]
}
The API will return a list of all the emails of the person living in the city put as parameter
Use either mvn test if you have maven on your machine or ./mvnw test if you do not have maven on your machine.
To get all the different reports, you can use either mvn site or ./mvnw site
You can find the generated test reports in the target directory.