Skip to content

Commit

Permalink
Merge branch 'develop' into mwithi_fix_worfklow_for_merges
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed Nov 21, 2024
2 parents 4800181 + 4511083 commit ff5c80b
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 12 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 (<artifactId>-<version>) or any <appname> that will match <appname>.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 `<appname>.war`:

```
mv /target/openhospital-api-0.1.0.war <appname>.war
```

## How to deploy backend in Docker environment

Make sure you have docker with docker-compose installed, then run the following commands:
Expand Down
40 changes: 31 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
<version>3.3.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>org.isf</groupId>
<artifactId>openhospital-api</artifactId>
<version>0.1.0</version>
<packaging>${packaging.type}</packaging>
<name>openhospital-api</name>
<description>Open Hospital Spring Boot REST API</description>

<properties>
<packaging.type>jar</packaging.type>
<oh-core.version>1.14.2-SNAPSHOT</oh-core.version>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -31,16 +34,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand Down Expand Up @@ -308,6 +304,32 @@
</plugins>
</build>
</profile>
<profile>
<id>war</id>
<properties>
<packaging.type>war</packaging.type>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>rsc</directory>
<includes>
<include>**/*.properties</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</profile>
</profiles>

</project>
9 changes: 8 additions & 1 deletion src/main/java/org/isf/OpenHospitalApiApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
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;
import com.fasterxml.jackson.databind.SerializationFeature;

@ImportResource({ "classpath*:/applicationContext.xml" })
@SpringBootApplication
public class OpenHospitalApiApplication {
public class OpenHospitalApiApplication extends SpringBootServletInitializer {

@Autowired
private ObjectMapper objectMapper;
Expand All @@ -52,4 +54,9 @@ public void setUp() {
GeneralData.getGeneralData(); // initialize core settings
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(OpenHospitalApiApplication.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public MedicalStockWardController(
* @throws OHServiceException When failed to get ward medicals
*/
@GetMapping(value = "/medicalstockward/{ward_code}")
public List<MedicalWardDTO> getMedicalsWard(@PathVariable("ward_code") char wardId) throws OHServiceException {
public List<MedicalWardDTO> getMedicalsWard(@PathVariable("ward_code") String wardId) throws OHServiceException {
// FIXME: provide provision for boolean ,false?
List<MedicalWard> medWards = movWardBrowserManager.getMedicalsWard(wardId, true);

Expand Down

0 comments on commit ff5c80b

Please sign in to comment.