diff --git a/README.md b/README.md index 8f9ab4fa..fdb29ef3 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This is the API project of [Open Hospital][openhospital]: it exposes a REST API * [How to build [WIP]](#how-to-build-wip) + [Using Swagger-UI](#using-swagger-ui) + [Using Postman](#using-postman) + * [How to build a war file](#how-to-build-a-war-file) * [How to deploy backend in docker environment](#how-to-deploy-backend-in-docker-environment) * [How to generate openapi specs](#how-to-generate-openapi-specs) * [Cleaning](#cleaning) @@ -41,7 +42,7 @@ For the moment, to build this project you should rsc/database.properties rsc/log4j2-spring.properties rsc/... - + 4. set target/rsc/database.properties DB can be created with `docker-compose up` from `openhospital-core` or using a dedicated MySQL server @@ -94,6 +95,40 @@ You can see Swagger API Documentation at: http://localhost:8080/swagger-ui/index 1. import postman_collection.json in your Postman installation +## How to build a war file + + 1. Prepare settings from each `rsc/*.dist` file + + ``` + ### Note: + ### server.address, server.port, server.servlet.context-path and server.tomcat.accesslog.* will be ignored + ### jwt.token.secret <- set a SHA-256 jwt token + ### api.host <- set to openhospital-api-0.1.0 (-) or any that will match .war + rsc/application.properties + + ### note: if the DB is on the host, use 'host.docker.internal' as hostname + rsc/database.properties + + ### note: if the DB is on the host, use 'host.docker.internal' as DBSERVER + rsc/log4j2-spring.properties + + ### as required in [Admin Doc](https://github.com/informatici/openhospital-doc/blob/develop/doc_admin/AdminManual.adoc#settings-properties) + rsc/settings.properties + ``` + + 2. Build war file + + ``` + ### OH-core must have been built and available in .m2 (Maven) repo + ./mvnw clean install -DskipTests=true -P war + ``` + + 3. (Optional) rename war to the desired `.war`: + + ``` + mv /target/openhospital-api-0.1.0.war .war + ``` + ## How to deploy backend in Docker environment Make sure you have docker with docker-compose installed, then run the following commands: diff --git a/pom.xml b/pom.xml index d61d2c0d..cd05f153 100644 --- a/pom.xml +++ b/pom.xml @@ -8,13 +8,16 @@ 3.3.5 + org.isf openhospital-api 0.1.0 + ${packaging.type} openhospital-api Open Hospital Spring Boot REST API + jar 1.14.2-SNAPSHOT 17 UTF-8 @@ -31,16 +34,9 @@ org.springframework.boot spring-boot-starter-logging - - org.springframework.boot - spring-boot-starter-tomcat - - - org.springframework.boot - spring-boot-starter-jetty - + org.springframework.boot spring-boot-starter-security @@ -308,6 +304,32 @@ + + war + + war + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + + + src/main/resources + + + rsc + + **/*.properties + + false + + + + - diff --git a/src/main/java/org/isf/OpenHospitalApiApplication.java b/src/main/java/org/isf/OpenHospitalApiApplication.java index 80d9337e..3fd89e11 100644 --- a/src/main/java/org/isf/OpenHospitalApiApplication.java +++ b/src/main/java/org/isf/OpenHospitalApiApplication.java @@ -27,7 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.ApplicationPidFileWriter; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ImportResource; import com.fasterxml.jackson.databind.ObjectMapper; @@ -35,7 +37,7 @@ @ImportResource({ "classpath*:/applicationContext.xml" }) @SpringBootApplication -public class OpenHospitalApiApplication { +public class OpenHospitalApiApplication extends SpringBootServletInitializer { @Autowired private ObjectMapper objectMapper; @@ -52,4 +54,9 @@ public void setUp() { GeneralData.getGeneralData(); // initialize core settings } + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(OpenHospitalApiApplication.class); + } + } diff --git a/src/main/java/org/isf/medicalstockward/rest/MedicalStockWardController.java b/src/main/java/org/isf/medicalstockward/rest/MedicalStockWardController.java index 897334a4..0f8627b2 100644 --- a/src/main/java/org/isf/medicalstockward/rest/MedicalStockWardController.java +++ b/src/main/java/org/isf/medicalstockward/rest/MedicalStockWardController.java @@ -93,7 +93,7 @@ public MedicalStockWardController( * @throws OHServiceException When failed to get ward medicals */ @GetMapping(value = "/medicalstockward/{ward_code}") - public List getMedicalsWard(@PathVariable("ward_code") char wardId) throws OHServiceException { + public List getMedicalsWard(@PathVariable("ward_code") String wardId) throws OHServiceException { // FIXME: provide provision for boolean ,false? List medWards = movWardBrowserManager.getMedicalsWard(wardId, true);