Skip to content

Commit

Permalink
Minor updates (possibility to specify custom server port and temporar…
Browse files Browse the repository at this point in the history
…y result folder) > Version 3.4
  • Loading branch information
fra82 committed May 4, 2020
1 parent 8e1fe3f commit 2508256
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,5 @@
</dependencies>


<version>3.3</version>
<version>3.4</version>
</project>
37 changes: 33 additions & 4 deletions rtdoc/LocalExecution.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
Comorbidity4j has to be executed by Java 1.8 or newer. As a consequence, as a prerequisite for the execution of Comorbidity4j you need to have <a href="https://www.java.com/en/download/" target="_blank">Java</a> installed.

## Download the JAR package
The compressed archive (comorbidity4j-3.3-bin.zip) that contains the latest version (LATEST_VERS = 3.3) of comorbidity4j can be downloaded at the following URL:
The compressed archive (comorbidity4j-3.4-bin.zip) that contains the latest version (LATEST_VERS = 3.4) of comorbidity4j can be downloaded at the following URL:

<a href="https://github.com/fra82/comorbidity4j/releases/tag/3.3" target="_blank">https://github.com/fra82/comorbidity4j/releases/tag/3.3</a>
<a href="https://github.com/fra82/comorbidity4j/releases/tag/3.4" target="_blank">https://github.com/fra82/comorbidity4j/releases/tag/3.4</a>


## Comorbidity4j Execution
Expand All @@ -18,14 +18,43 @@ The compressed archive (comorbidity4j-3.3-bin.zip) that contains the latest vers

```
// Linux users:
java -cp './comorbidity4j-LATEST-VERS.jar:./lib/*' es.imim.ibi.comorbidity4j.server.StartComorbidity4j
java -cp '/local/path/to/comorbidity4j-LATEST-VERS/comorbidity4j-LATEST-VERS.jar:/local/path/to/comorbidity4j-LATEST-VERS/lib/*' es.imim.ibi.comorbidity4j.server.StartComorbidity4j
// Windows users:
java -cp "c:\Full\Local\Path\To\comorbidity4j-LATEST-VERS\comorbidity4j-LATEST-VERS.jar;c:\Full\Local\Path\To\comorbidity4j-LATEST-VERS\lib\*" es.imim.ibi.comorbidity4j.server.StartComorbidity4j
java -cp "c:\Local\Path\To\comorbidity4j-LATEST-VERS\comorbidity4j-LATEST-VERS.jar;c:\Local\Path\To\comorbidity4j-LATEST-VERS\lib\*" es.imim.ibi.comorbidity4j.server.StartComorbidity4j
```

+ Open by your favorite Web browser the URL: <a href="http://localhost:8181/comorbidity4web/" target="_blank">http://localhost:8181/comorbidity4web/</a>. Here you can access the Web interface that will drive you throughout the different step and the exploration of results of a comorbidity analysis. The same Web interface can be accessed at <a href="http://comorbidity.eu/comorbidity4web/" target="_blank">http://comorbidity.eu/comorbidity4web/</a> as the COmorbidity4web service, for online execution of comorbidity analyses.

+ Specify custom server port and temporary files directory path:
To change default server port (8181), when starting comorbidity4j local service (server), specify the following program parameter:

```
--server.port=8585
```

To change the temporary files directory path (the local directory where Comorbidity4web writes partial and final resulta of comorbidity analyses), when starting comorbidity4j local service (server), specify the following program parameter:

```
// Linux users:
--spring.servlet.multipart.location=/path/to/temporary/files/directory/
// Windows users:
--spring.servlet.multipart.location=c:\local\path\to\temporary\files\directory\
```


To specify a custom server port or temporary files directory path, start the server with the following program parameters:
```
// Linux users:
java -cp '/local/path/to/comorbidity4j-LATEST-VERS/comorbidity4j-LATEST-VERS.jar:/local/path/to/comorbidity4j-LATEST-VERS/lib/*' es.imim.ibi.comorbidity4j.server.StartComorbidity4j
--server.port=PORT_NUMBER --spring.servlet.multipart.location=/path/to/temporary/files/directory/
// Windows users:
java -cp "c:\Local\Path\To\comorbidity4j-LATEST-VERS\comorbidity4j-LATEST-VERS.jar;c:\Local\Path\To\comorbidity4j-LATEST-VERS\lib\*" es.imim.ibi.comorbidity4j.server.StartComorbidity4j
--server.port=PORT_NUMBER --spring.servlet.multipart.location=c:\local\path\to\temporary\files\directory\
```


<a name="results"></a>

Expand Down
2 changes: 1 addition & 1 deletion rtdoc/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Comorbidity4j](/img/logo.png)
<h3>Open-source Java tool to analyze comorbidities over large datasets of patients</h3>

**Latest version: 3.3**
**Latest version: 3.4**

Comorbidity4j is an Open-source java tool tailored to easily perform <a href="https://en.wikipedia.org/wiki/Comorbidity" target="_blank">comorbidity analyses</a>, thus **supporting the analysis of significant cooccurrences of diseases over large datasets of patient data**.

Expand Down
106 changes: 104 additions & 2 deletions src/main/java/es/imim/ibi/comorbidity4j/server/StartComorbidity4j.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package es.imim.ibi.comorbidity4j.server;

import java.io.File;
import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import es.imim.ibi.comorbidity4j.server.reservlet.ComputeComorbidityServlet;
Expand All @@ -17,11 +21,109 @@
// @EnableAutoConfiguration
@EnableScheduling
public class StartComorbidity4j extends SpringBootServletInitializer {

public static void main(String[] args) {
SpringApplication.run(StartComorbidity4j.class, args);

final ConfigurableApplicationContext context = SpringApplication.run(StartComorbidity4j.class, args);
StartComorbidity4j c4j = context.getBean(StartComorbidity4j.class);

System.out.println("-------------------------------------------------");
System.out.println("\n--- SERVER STARTUP CONFIGURATION GUIDE ---");
System.out.println("- To change server port:\n- when you start Comorbidity4j server, specify the following program parameter: --server.port=8585");
System.out.println("- To change temporary files directory path:\n- when you start Comorbidity4j server, specify the following program parameter: --spring.servlet.multipart.location=/path/to/temporary/files/directory/");
System.out.println("-\n- To start the server:");
System.out.println("- > Linux users:");
System.out.println("- java -cp '/local/path/to/comorbidity4j-LATEST-VERS/comorbidity4j-LATEST-VERS.jar:/local/path/to/comorbidity4j-LATEST-VERS/lib/*' es.imim.ibi.comorbidity4j.server.StartComorbidity4j");
System.out.println("- > Windows users:");
System.out.println("- java -cp \"c:\\Local\\Path\\To\\comorbidity4j-LATEST-VERS\\comorbidity4j-LATEST-VERS.jar;c:\\Local\\Path\\To\\comorbidity4j-LATEST-VERS\\lib\\*\" es.imim.ibi.comorbidity4j.server.StartComorbidity4j");
System.out.println("-\n- To specify a custom server port or temporary files directory path, start the server with the following program parameters:");
System.out.println("- > Linux users:");
System.out.println("- java -cp '/local/path/to/comorbidity4j-LATEST-VERS/comorbidity4j-LATEST-VERS.jar:/local/path/to/comorbidity4j-LATEST-VERS/lib/*' es.imim.ibi.comorbidity4j.server.StartComorbidity4j");
System.out.println("- --server.port=PORT_NUMBER --spring.servlet.multipart.location=/path/to/temporary/files/directory/");
System.out.println("- > Windows users:");
System.out.println("- java -cp \"c:\\Local\\Path\\To\\comorbidity4j-LATEST-VERS\\comorbidity4j-LATEST-VERS.jar;c:\\Local\\Path\\To\\comorbidity4j-LATEST-VERS\\lib\\*\" es.imim.ibi.comorbidity4j.server.StartComorbidity4j");
System.out.println("- --server.port=PORT_NUMBER --spring.servlet.multipart.location=c:\\local\\path\\to\\temporary\\files\\directory\\");
System.out.println("-------------------------------------------------");

System.out.println("\n------------------- COMORBIDITY4WEB SERVER -------------------");
// Check if the temp directory exists and is writable
boolean startupCheckPassed = true;
try {
System.out.println(" --> Checking running port number:");
if(c4j.getEnv() == null || !c4j.getEnv().containsProperty("server.port") || c4j.getEnv().getProperty("server.port") == null) {
System.out.println(" >>> ATTENTION: wrongly specified server port number.");
startupCheckPassed = false;
}
else {
System.out.println(" Server port number equal to: " + c4j.getEnv().getProperty("server.port"));
}
}
catch(Exception e) {
e.printStackTrace();
}

try {
System.out.println(" --> Checking the validity of the temporary files directory path (the local directory where Comorbidity4web writes partial and final resulta of comorbidity analyses):");

if(c4j.getEnv() == null || !c4j.getEnv().containsProperty("spring.servlet.multipart.location") || c4j.getEnv().getProperty("spring.servlet.multipart.location") == null) {
System.out.println(" >>> ATTENTION: the temporary files to directory path property is not specified.");
startupCheckPassed = false;
}
else {
File tempDir = new File(c4j.getEnv().getProperty("spring.servlet.multipart.location"));
if(tempDir == null || !tempDir.exists()) {
System.out.println(" >>> ATTENTION: the temporary files to directory path points to a directory that does not exist.");
startupCheckPassed = false;
}
else if(!tempDir.isDirectory()) {
System.out.println(" >>> ATTENTION: the temporary files directory path points to local file system location that is not a directory.");
startupCheckPassed = false;
}
else if(!tempDir.canWrite()) {
System.out.println(" >>> ATTENTION: the server is not allowed to write files in the the temporary files directory path.");
startupCheckPassed = false;
}
else {
System.out.println(" Temporary files directory path correctly specified and equal to: " + c4j.getEnv().getProperty("spring.servlet.multipart.location"));
ComputeComorbidityServlet.basePathResultStorage = c4j.getEnv().getProperty("spring.servlet.multipart.location");
ComputeComorbidityServlet.basePathResultStorage = (ComputeComorbidityServlet.basePathResultStorage.endsWith(File.separator)) ? ComputeComorbidityServlet.basePathResultStorage : ComputeComorbidityServlet.basePathResultStorage + File.separator;
}
}
}
catch(Exception e) {
e.printStackTrace();
}

if(startupCheckPassed) {
System.out.println("\n--- SERVER CONFIGURATION ---");
System.out.println("- Server port: " + ((c4j.getEnv() != null && c4j.getEnv().containsProperty("server.port")
&& c4j.getEnv().getProperty("server.port") != null) ? c4j.getEnv().getProperty("server.port") : "UNAVAILABLE"));
System.out.println("- Temporary files directory path (local directory where Comorbidity4web writes partial and final resulta of comorbidity analyses): " + ((c4j.getEnv() != null && c4j.getEnv().containsProperty("spring.servlet.multipart.location") &&
c4j.getEnv().getProperty("spring.servlet.multipart.location") != null) ? c4j.getEnv().getProperty("spring.servlet.multipart.location") : "UNAVAILABLE"));

System.out.println("\nComorbidity4web server can be accessed at the following URL: http://localhost:" + c4j.getEnv().getProperty("server.port") + "/comorbidity4web/");
}
else {
System.out.println(" >>> Please, stop the server, solve this issue and restart the server.");
}

System.out.println("\n >>> Documentation: https://comorbidity4j.readthedocs.io/");
System.out.println("----------------------------------------------------------------");



}

@Autowired
private Environment env;

public Environment getEnv() {
return env;
}

public void setEnv(Environment env) {
this.env = env;
}

@Bean
ServletRegistrationBean<ComputeComorbidityServlet> computeComorbidityServletRegistration1() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/wtempl/,classpath:/retempl/

spring.servlet.multipart.enabled=true
spring.servlet.multipart.location=/home/ronzano/comorbidity4web/tmp
spring.servlet.multipart.location=/path/to/temporary/files/directory
spring.servlet.multipart.max-file-size=1000MB
spring.servlet.multipart.max-request-size=1000MB

Expand Down

0 comments on commit 2508256

Please sign in to comment.