Propose a new REST API for the whole project

Description

The pattern below has been modified by https://openhospital.atlassian.net/browse/OP-118 so at the moment on the ‘master’ branch we no longer have the responsebodyadvice class (commented) but a discussion is in progress on the final pattern to be used for https://openhospital.atlassian.net/browse/OP-6 and related subtasks.

This task consists in analysing the core logic and propose in the wiki a REST API useful for any frontend application (e.g. AngularJS application, mobile app, etc).

This task is completed when a wiki document describes all the REST API, with detailed informations (e.g. parameters, return values, etc).

Proposal (implemented in OP-6):

  • each OpenHospital Module will have an API REST module (org.isf.<module> packages)

  • each OpenHospital Model will have a DTO1 model (org.isf.<module>.dto packages)

  • each OpenHospital Model will have a Mapper3 class (org.isf.<module>.mapper packages)

  • each OpenHospital Manager will have a REST Controller (org.isf.<module>.rest) that maps each URL to the correct Manager

  • common package org.isf.security: it contains classes for Login and tokens' management

  • common package org.isf.shared.exception: it contains classes for exceptions handling

  • common package org.isf.shared.responsebodyadvice: it contains classes for DTO handling

  • common package org.isf.config: it contains classes for Swagger2 configuration

1 DTO = Data Transfer Object, to be used by the User Interface and between processes; it differs from the business logic model defined in the ‘core’, but the two mostly overlap in our case

2 Swagger API: is an open-source software framework backed by a large ecosystem of tools that helps developers design, build, document, and consume RESTful web services.

3 Mapper = Helper to map Model to DTO and viceversa

‘core' packages org.isf.<module>: OpenHospital 'core’ module
‘core’ packages org.isf.<module>.model.*: OpenHospital ‘core’ module’s models
‘core’ packages org.isf.<module>.manager.*: OpenHospital ‘core’ module’s managers

‘api’ packages org.isf.<module>: OpenHospital ‘api’ module
‘api’ packages org.isf.<module>.dto.*: OpenHospital ‘api’ module’s models
‘api’ packages org.isf.<module>.rest.*: OpenHospital ‘controller’ module’s controllers

 

Testing:

Once compiled with command ‘mvn clean install’ (it needs openhospital-core component) run it with:

path\to\target\folder> java -jar openhospital-api-0.0.1.jar

you will see:

path\to\target\folder> java -jar openhospital-api-0.0.1.jar ... . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.3.RELEASE)

then access at http://localhost:8080/oh-api/auth/login

//TODO

 

Swagger at http://localhost:8080/oh-api/swagger-ui.html

 

Environment

None

Attachments

1
  • 03 Oct 2019, 03:44 PM

causes

is blocked by

relates to

Activity

Alessandro Domanico March 5, 2020 at 10:41 AM
Edited

About this task a new discussion about the proposed pattern has been held in the last working group call https://openhospital.atlassian.net/wiki/spaces/OHC/pages/769622123 .

Briefly, the org.isf.shared.responsebodyadvice has been commented out by https://openhospital.atlassian.net/browse/OP-118 opting for a direct DTO mapping in the controller themselves.

The discussion is meant to propose a third (final) pattern, if needed, in which we could have both “automatic mapping” and “manual mapping” depending on the module complexity.

Done

Details

Assignee

Reporter

Labels

Components

Fix versions

Time tracking

4h 30m logged

Due date

Priority

Created November 20, 2015 at 6:19 PM
Updated April 29, 2020 at 10:24 AM
Resolved October 3, 2019 at 1:06 PM