GithubHelp home page GithubHelp logo

alerts's Introduction

SafetyNet - Alerts v2.0.1 release

Infos

author: Thierry 'Docky' SCHREINER - DA Java student - Open ClassRooms

mentored by: Yann 'Monsieur Plus' IRRILO

release date: 12/05/2020

###Install

  • The application 'Safetynet Alerts' works with MySQL 8.0 DataBase that is called alerts_prod.

  • A second DataBase, called alerts_tests, is used for integration tests.

  • Both Databases use the same user ("root") and password ("rootroot").

  • An SQL script file, named 'alerts.sql' is available in src/main/resources.

  • In src/main/resources you can found the Alerts_postman_collection.json file that you can import in Postman to use my request collection. Also available online at https://app.getpostman.com/run-collection/a63d09364c2b8fad69c1

  • The JSON data importation is made using administrative endpoints. The Postman collection provide 3 batch POST requests, that must be executed in this order : firestation/batch, person/batch and finally medicalRecord/batch (logical and mandatory to link data).

Content

This fifteenth release v2.0.1 fixes some problems:

  • moving MedicalRecordDTO from model package to DTO package,

  • replacing AlertsApplication.class by ClassName.class in the LoggerFactory.getLogger method of each Class where it has been forgot.

Previous releases contains :

  • the administrative Person endpoint that can be used for CRUD operations on person data (since v0.1);

  • the administrative firestation endpoint that can be used for CRUD operations on address - FireStation associations (since v0.2);

  • the endpoints OPS#7 'comunityEmail/{city}' and OPS#3 'phoneAlert/{firestation}' (since v1.0);

  • the administrative medicalRecord endpoint to perform CRUD operations on MedicalRecord (since v1.1);

  • the OPS#1 endpoint allows user to get the list of persons covered by a given fire station and the dissociated count of adults and children covered (since v1.2);

  • the administrative endpoints integration tests (for firestation, person, medicalRecords) and increase JaCoCo covering rate by adding unit tests (PersonMappingTest and missed branches in existing tests), since v1.21;

  • the OPS#2 ChildAlert that provides a list of children (first name, last name, age) and a list of adults living at a given address (since v1.3);

  • a bugfix in update methods of person and medicalRecord administrative endpoints (v1.3.1);

  • a rewrited OPS#1 'firestation' endpoint, and improvement of OPS#2 'chilAlert' and added OPS#4 'fire' and OPS#5 'flood' endpoints (v1.4);

  • the OPS#6 'personInfo/{firstName}/{lastName} endpoints and refactors a great part of project classes. OPS#6 returns a list of PersonInfoDTO instead of a single PersonInfoDTO, to be able to deal with with namesakes (since v1.5).

  • the modification of the seven OPS requests using @RequestParam instead of @PathVariables, and the addition of a slf4j - log4j logger that performs info and debug logs to console & file for each OPS request (since 1.6).

  • The twelfth one v1.6.1 modifies v1.6.2 setter, getter & constructor of PersonInfoDTO & MedicalRecord to avoid the exposition of internal representation by returning reference to mutable object and replaces bad practices (!= comparison in MedicalMapping)

  • Release v1.6.2 fix the inactive httptrace actuator bug and adds details in health one.

The fourteenth release v2.0 comes with a big refactoring of all the application:

- split AddressFirestation class in 2 classes, AddressDTO and AddressEntity;

- add a new AddressMapping class;

- rename all AddressFireStation* as Address*;

- fix put requests troubles;

- develop logging;

- work on http responses;

- consolidate tests;

- fix CheckStyle issues... 

Application also contains actuators (health, info, metrics & httptrace).

The person endpoint

POST - http://localhost:8080/person/batch >>> add a list of persons in DB persons table. Used to copy all JSON list of person. for example you can add the project 5 given data:

	[
	    {
	        "firstName": "John",
	        "lastName": "Boyd",
	        "address": "1509 Culver St",
	        "city": "Culver",
	        "zip": "97451",
	        "phone": "841-874-6512",
	        "email": "[email protected]"
	    },
	    {
	        "firstName": "Jacob",
	        "lastName": "Boyd",
	        "address": "1509 Culver St",
	        "city": "Culver",
	        "zip": "97451",
	        "phone": "841-874-6513",
	        "email": "[email protected]"
	    },
	    ...
	    {
	        "firstName": "Eric",
	        "lastName": "Cadigan",
	        "address": "951 LoneTree Rd",
	        "city": "Culver",
	        "zip": "97451",
	        "phone": "841-874-7458",
	        "email": "[email protected]"
	    }
	]

GET - http://localhost:8080/person >>> returns the list of persons recorded in DataBase.

	[
	    {
	        "firstName": "John",
	        "lastName": "Boyd",
	        "address": "1509 Culver St",
	        "city": "Culver",
	        "zip": "97451",
	        "phone": "841-874-6512",
	        "email": "[email protected]"
	    },
	    {
	        "firstName": "Jacob",
	        "lastName": "Boyd",
	        "address": "1509 Culver St",
	        "city": "Culver",
	        "zip": "97451",
	        "phone": "841-874-6513",
	        "email": "[email protected]"
	    },
	    ...
	    {
	        "firstName": "Eric",
	        "lastName": "Cadigan",
	        "address": "951 LoneTree Rd",
	        "city": "Culver",
	        "zip": "97451",
	        "phone": "841-874-7458",
	        "email": "[email protected]"
	    }
	]

GET - http://localhost:8080/person/{lastName}/{fistName} >>> returns the person named {firstName} {lastName} if exists in DB.

for example /Person/Boyd/Tenley returns :
	{
	    "firstName": "Tenley",
	    "lastName": "Boyd",
	    "address": "1509 Culver St",
	    "city": "Culver",
	    "zip": "97451",
	    "phone": "841-874-6512",
	    "email": "[email protected]"
	}

POST - http://localhost:8080/person >>> add the person in DB persons table, if this person is not already recorded in DB. for example you can add 'Tenley Boyd' with this JSON raw body:

	{
	    "firstName": "Tenley",
	    "lastName": "Boyd",
	    "address": "1509 Culver St",
	    "city": "Culver",
	    "zip": "97451",
	    "phone": "841-874-6512",
	    "email": "[email protected]"
	}

PUT - http://localhost:8080/person/{firstName}/{lastName} >>> update the person in DB persons table, if this person is not already recorded in DB.

for example you can update 'Tenley Boyd' data with this JSON raw body:
	{
	    "firstName": "Tenley",
	    "lastName": "Boyd",
	    "address": "1509 Culver St",
	    "city": "Culver",
	    "zip": "97451",
	    "phone": "123-456-7890",
	    "email": "[email protected]"
	}

DELETE - http://localhost:8080/person/{lastName}/{fistName} >>> Delete the person named {firstName} {lastName} if exists in DB.

The firestation endpoint

POST - http://localhost:8080/firestation/batch >>> add a list of address - FiresStation association in DB. Used to copy all JSON list of person. for example you can add the project 5 given data:

[
	{ "address":"1509 Culver St", "station":"3" },
    { "address":"29 15th St", "station":"2" },
    { "address":"834 Binoc Ave", "station":"3" },
    { "address":"644 Gershwin Cir", "station":"1" },
    { "address":"748 Townings Dr", "station":"3" },
    { "address":"112 Steppes Pl", "station":"3" },
    { "address":"489 Manchester St", "station":"4" },
    { "address":"892 Downing Ct", "station":"2" },
    { "address":"908 73rd St", "station":"1" },
    { "address":"947 E. Rose Dr", "station":"1" },
    { "address":"951 LoneTree Rd", "station":"2" }
]

GET - http://localhost:8080/firestation >>> returns the list of address - FireStation associations recorded in DataBase.

[
    {
        "address": "1509 Culver St",
        "city": "Culver",
        "zip": "97451",
        "station": "3"
    },
    {
        "address": "29 15th St",
        "city": "Culver",
        "zip": "97451",
        "station": "2"
    },
		...
		
    {
        "address": "951 LoneTree Rd",
        "city": "Culver",
        "zip": "97451",
        "station": "2"
    }
]

GET - http://localhost:8080/firestation/{address} >>> returns the AddressDTO if exists in DB.

for example /firestation/29 15th St returns :
    {
       "address": "29 15th St",
		"city" 
        "city": "Culver",
        "zip": "97451",
       "station": "2"
    }  

POST - http://localhost:8080/firestation >>> add the address - FiresStation association, if this person is not already recorded in DB.

for example you can add '29 15th St' address with this JSON raw body (Do not add an id):
    {
        "address": "29 15th St",
        "station": "2"
    }

PUT - http://localhost:8080/firestation/{address} >>> update the address - FiresStation association, if this address is recorded in DB.

for example you can update '29 15th St' address  with this JSON raw body :
	{
        "address": "29 15th St",
        "station": "3"
    }

DELETE - http://localhost:8080/firestation/{address} >>> Delete the address - FiresStation association if exists in DB.

The medicalRecord endpoint

POST - http://localhost:8080/medicalRecord/batch >>> add a list of medical record in DB. It uses a for each loop and the add one MedicalRecord to add and join each medical record.

GET - http://localhost:8080/medicalRecord >>> returns the list of MedicalRecord in DataBase.

[
    {
        "firstName": "John",
        "lastName": "Boyd",
        "birthdate": "03/06/1984",
        "medications": [
            "aznol:350mg",
            "hydrapermazol:100mg"
        ],
        "allergies": [
            "nillacilan"
        ]
    },
    {
        "firstName": "Jacob",
        "lastName": "Boyd",
        "birthate": "03/06/1989",
        "medications": [
            "pharmacol:5000mg",
            "terazine:10mg",
            "noznazol:250mg"
        ],
        "allergies": []
    },
	...
    {
        "firstName": "Eric",
        "lastName": "Cadigan",
        "birthdate": "08/06/1945",
        "medications": [
            "tradoxidine:400mg"
        ],
        "allergies": []
    }
]

GET - http://localhost:8080/medicalRecord/{lastName}/{firstName} >>> returns the medical record if exists in DB.

for example /firestation/29 15th St returns :
    {
        "firstName": "Jacob",
        "lastName": "Boyd",
        "birthDate": "03/06/1989",
        "medications": [
            "pharmacol:5000mg",
            "terazine:10mg",
            "noznazol:250mg"
        ],
        "allergies": []
    }

PUT - http://localhost:8080/medicalRecord/{lastName}/{firstName} >>> update a medical record, if it exists in DB.

Response 201 Created or 404 Not found
for example you can update Boyd/Jacob medical record with this JSON raw body (Do not add an id):
	{
        "firstName": "Jacob",
        "lastName": "Boyd",
        "birthDate": "03/06/1989",
        "medications": [
            "pharmacol:5000mg",
        ],
        "allergies": [
        	"peanuts"
        ]
    }

DELETE - http://localhost:8080/medicalRecord/{lastName}/{firstName} >>> Delete the medical record if exists in DB.

OPS endpoints

OPS#1: GET - http://localhost:8080/firestation/number?stationNumber= >>> returns the list of persons covered by the given fire station number. Use the same OpsPersonDTO class that is used in OPS#2.

{
    "adultCount": 8,
    "childCount": 3,
    "total": 11,
    "coveredPersons": [
	
	    {
	        "id": 1,
	        "firstName": "John",
	        "lastName": "Boyd",
	        "age": "36 years old",
	        "address": "1509 Culver St",
	        "phone": "841-874-6512"
	    },
	    {
	        "id": 2,
	        "firstName": "Jacob",
	        "lastName": "Boyd",
	        "age": "31 years old",
	        "address": "1509 Culver St",
	        "phone": "841-874-6513"
	    },
			...
	    {
	        "id": 18,
	        "firstName": "Allison",
	        "lastName": "Boyd",
	        "age": "55 years old",
	        "address": "112 Steppes Pl",
	        "phone": "841-874-9888"
	    }
	]
}

OPS#2: GET - http://localhost:8080/childAlert?address=

>>> returns the list of children (first name, last name, age) and a list of adults living at a given address. Use the same OpsPersonDTO class that is used in OPS#1.

{
    "address": "1509 Culver St",
    "childList": [
        {
            "firstName": "Tenley",
            "lastName": "Boyd",
            "age": "8 years old"
            "address": "1509 Culver St",
            "phone": "841-874-6512"
        },
        {
            "firstName": "Roger",
            "lastName": "Boyd",
            "age": "19 months old"
            "address": "1509 Culver St",
            "phone": "841-874-6512"
        }
    ],
    "adultList": [
        "John Boyd",
        "Jacob Boyd",
        "Felicia Boyd"
    ]
}

OPS#3: GET - http://localhost:8080/phoneAlert?station= >>> returns the list of phone numbers of inhabitants covered by the given fire station number.

[
    "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"
]

OPS#4: GET - http://localhost:8080/fire?address=

>>> returns the household list of persons for a given address and the covering fire station number. Use the same OpsPersonInfoDTO class that is used in OPS#5 & #6.

{
    "personList": [
        {
            "firstName": "Foster",
            "lastName": "Shepard",
            "age": "40 years old",
            "medications": [],
            "allergies": [],
            "phone": "841-874-6544"
        },
        {
            "firstName": "Clive",
            "lastName": "Ferguson",
            "age": "26 years old",
            "medications": [],
            "allergies": [],
            "phone": "841-874-6741"
        }
    ],
    "addressDTO": {
        "address": "748 Townings Dr",
        "city": "Culver",
        "zip": "97451",
        "station": "3"
    }
}

OPS#5: GET - http://localhost:8080/flood?stations= >>> returns the list of household covered by the given list of fire station number. Use the same OpsPersonInfoDTO class that is used in OPS#4 & #6.

[
{
    "station": "1",
    "householdList": [
        {
            "personList": [
                {
                    "firstName": "Peter",
                    "lastName": "Duncan",
                    "age": "19 years old",
                    "medications": [],
                    "allergies": [
                        "shellfish"
                    ],
                    "phone": "841-874-6512"
                }
            ],
            "addressDTO": {
                "address": "644 Gershwin Cir",
                "city": "Culver",
                "zip": "97451",
                "station": "1"
            }
        },
        {
            "personList": [
                {
                    "firstName": "Reginold",
                    "lastName": "Walker",
                    "age": "40 years old",
                    "medications": [
                        "thradox:700mg"
                    ],
                    "allergies": [
                        "illisoxian"
                    ],
                    "phone": "841-874-8547"
                },
                {
                    "firstName": "Jamie",
                    "lastName": "Peters",
                    "age": "38 years old",
                    "medications": [],
                    "allergies": [],
                    "phone": "841-874-7462"
                }
            ],
            "addressDTO": {
                "address": "644 Gershwin Cir",
                "city": "Culver",
                "zip": "97451",
                "station": "1"
            }
        },
			...
        {
            "personList": [
                {
                    "firstName": "Foster",
                    "lastName": "Shepard",
                    "age": "40 years old",
                    "medications": [],
                    "allergies": [],
                    "phone": "841-874-6544"
                },
                {
                    "firstName": "Clive",
                    "lastName": "Ferguson",
                    "age": "26 years old",
                    "medications": [],
                    "allergies": [],
                    "phone": "841-874-6741"
                }
            ],
            "addressDTO": {
                "address": "644 Gershwin Cir",
                "city": "Culver",
                "zip": "97451",
                "station": "1"
            }
        },
        {
            "personList": [
                {
                    "firstName": "Tessa",
                    "lastName": "Carman",
                    "age": "8 years old",
                    "medications": [],
                    "allergies": [],
                    "phone": "841-874-6512"
                }
            ],
            "addressDTO": {
                "address": "834 Binoc Ave",
                "city": "Culver",
                "zip": "97451",
                "station": "3"
            }
        }
    ]
}

]

OPS#6: GET - http://localhost:8080/personInfo?firstName=&lastName= >>> returns the PersonInfoDTO list of person(s) that have this firstName and lastName (a list to be able to deal with with namesake, more than a single PersonInfoDTO).

This example show the response if John Boyd'son is first named John like his father (instead of Roger).

[
    {
        "firstName": "John",
        "lastName": "Boyd",
        "age": "36 years old",
        "medications": [
            "aznol:350mg",
            "hydrapermazol:100mg"
        ],
        "allergies": [
            "nillacilan"
        ],
        "phone": "841-874-6512"
    }
]

OPS#7: GET - http://localhost:8080/communityEmail?city= >>> returns the list of eMail address of inhabitants of the given city.

alerts's People

Contributors

docky37 avatar

Watchers

 avatar  avatar  avatar

alerts's Issues

Create OPS#6 person info

  • Written to return a List instead of one PersonInfoDTO so method is able to deal with namesake, and return more than one PersonInfoDTO.
  • The mapping method for OPS#6 is a part of OPS#4 one.

OPS#5: Flood (List of all addresses covered by a given station)

Cette liste doit regrouper les personnes par adresse. Elle doit aussi inclure le nom, le numéro de téléphone et l'âge des habitants, etfaire figurer leurs antécédents médicaux (médicaments, posologie et allergies) à côté de chaque nom.
List of Person (names, phone, age, medical data)
Group by Address

Data input validation

  • Need to avoid duplicates in address (PB with POST request because omnipotent)
  • Need to avoid duplicate persons (PB with POST request because omnipotent)
  • Verify Put request: same FirstName + LastName in URI than in Content
  • Verify mails format
  • Verify phone format

BugFix: The http PUT requests that are not correct (it does not use path variable)

Norme HTTP. D’après la RFC 2616 (HTTP methods), PUT sert à
Créer une entité :
L’URI doit être celle de l’entité à créer . Si l’entité dans la requête est acceptée et créée côté serveur, le serveur doit renvoyer un code 201 (created).
Si l’entité peut avoir plusieurs URIs (exemple : /script/v1.2 ou /script/current), le serveur peut donc définir ces URIs alternatives comme pointant sur la nouvelle entité

Modifier une entité :
Si une entité avec la même URI que celle de la requête existe déjà, l’entité de la requête devrait la remplacer. Ce n’est pas une création, le code retourné par le serveur en cas de succès doit être 200 (OK) ou 204 (No content). En effet, en pratique un PUT va très rarement générer une réponse avec un contenu.

Refactor

  • remove id in CoveredPerson class used in OPS#1 (done)
  • rename birthDate as birthdate (done)
  • extract service interfaces (done)
  • use a PersonDTO class for OPS#1 et 2 (done)
  • rename model DTO classes and move them in alerts/DTO (done)

Prepare Project

  • Install Spring Boot Starter MVC (2.2.5)
  • Add JaCoCo, Findbugs
  • Add Surfire report, JaCoCo report and FindBugs report

Add MedicalRecords endpoint

  • add MedicalRecords (model)
  • add MedicalReportController & unit tests
  • add MedicalReportService & unit tests

Create Controllers class and unit tests

  • Create PersonControllerTest class with first test on Get request.
  • Create PersonService class mocked in PersonControllerTest.
  • Create PersonController with Get request.

After that same process test + feat for

  • Get Person/lastName/firstName
  • Push Person
  • Put Person/lastName/firstName
  • Delete

Fix Bug in update methods

  • In PersonService & MedicalRecordsService update method do not check if firstName & lastName are the same in content than in parameters !!! So it is possible to rename a Person !

BugFix : FindBugs issues

EI: May expose internal representation by returning reference to mutable object

La méthode com.safetynet.alerts.DTO.PersonInfoDTO.getAllergies() risque d'exposer sa représentation interne en renvoyant com.safetynet.alerts.DTO.PersonInfoDTO.allergies
La méthode com.safetynet.alerts.DTO.PersonInfoDTO.getMedications() risque d'exposer sa représentation interne en renvoyant com.safetynet.alerts.DTO.PersonInfoDTO.medications
La méthode new com.safetynet.alerts.DTO.PersonInfoDTO(String, String, String, String[], String[], String) risque d'exposer sa représentation interne en stockant un objet externe modifiable dans com.safetynet.alerts.DTO.PersonInfoDTO.allergies
La méthode new com.safetynet.alerts.DTO.PersonInfoDTO(String, String, String, String[], String[], String) risque d'exposer sa représentation interne en stockant un objet externe modifiable dans com.safetynet.alerts.DTO.PersonInfoDTO.medications
La méthode com.safetynet.alerts.DTO.PersonInfoDTO.setAllergies(String[]) risque d'exposer sa représentation interne en stockant un objet externe modifiable dans com.safetynet.alerts.DTO.PersonInfoDTO.allergies
La méthode com.safetynet.alerts.DTO.PersonInfoDTO.setMedications(String[]) risque d'exposer sa représentation interne en stockant un objet externe modifiable dans com.safetynet.alerts.DTO.PersonInfoDTO.medications

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.