Skip to content

Commit db46c3b

Browse files
STAND-119: Add Support for Reference Application 3.x in OpenMRS Standalone (openmrs#76)
* Replace the embedded mysql with mariadb4j in Ref App 2.x * removing nashorn-core * updating to the latest snapshot * resized MainFrame and updated readme * added unit tests * STAND-119: Support-reference-application-3-x-on-open-mrs-standalone
1 parent dc9a3cf commit db46c3b

File tree

8 files changed

+41
-88
lines changed

8 files changed

+41
-88
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
* Increase the maven memory: e.g. export MAVEN_OPTS="-Xms1012m -Xmx2024m"
44
* mvn clean
5-
* mvn package -Dopenmrs.version=2.8.0-SNAPSHOT -Drefapp.version=2.14.0-SNAPSHOT
6-
* You can also use mvn package to build the default version on openmrs.version=2.8.0-SNAPSHOT and refapp.version=2.14.0-SNAPSHOT
5+
* mvn package -Dopenmrs.version=2.7.4 -Drefapp.version=3.4.0
6+
* You can also use mvn package to build the default version on openmrs.version=2.7.4 and refapp.version=3.4.0
77
* If running a second time, ALWAYS check to make sure mysql processes on port 3326 and 3328 are stopped.
88
If you DON'T do that, then the "mvn clean" will not really clean.
99
A good command to use is: "pkill -f standalone" (kills anything with "standalone" in the path)
@@ -16,7 +16,7 @@
1616
- Copy your war file into the "tomcat/webapps" folder. Where the tomcat folder is at the root of the project.
1717

1818
If you already have openmrs installed and do not want to interfere with it, just rename
19-
your war file to something different from openmrs.war. Examples are openmrs-2.8.0-SNAPSHOT.war, etc which suppoort Java 17 and above.
19+
your war file to something different from openmrs.war. Examples are openmrs-2.7.4.war, etc which suppoort Java 17 and above.
2020

2121
- Right click on the project and select Run As -> Run Configurations
2222

@@ -73,7 +73,7 @@ The release/distribution (end user) folder structure should look like this:
7373
NOTE: Without this folder structure, you will get errors while trying to run the standalone application.
7474

7575
* contextname-runtime.properties
76-
* e.g openmrs-runtime.properties, openmrs-2.14.0-SNAPSHOT-runtime.properties, etc
76+
* e.g openmrs-runtime.properties, openmrs-3.4.0-runtime.properties, etc
7777
* If you want to use this runtime properties file, make sure that the web application context name does not match with any existing runtime properties file in say the user's home folder. This is because of the openmrs runtime properties file search order which will only look in the current application folder as the last resort if no runtime properties file has been found in any of the other possible locations.
7878
* standalone.jar
7979
* This is the output executable jar for this standalone project.
@@ -152,7 +152,7 @@ browser Use to launch a new browser instance.
152152
4- The application will start the tomcat server and then the mariadb4j database engine.
153153
5- Follow the steps in the openmrs setup wizard to select where you want the demo database distribution or ciel database distribution to be created.
154154
6- After the setup wizard is done, you will have a database created in the location you selected.
155-
7- Open your browser and go to the openmrs setup wizard at http://localhost:8080/openmrs
155+
7- Open your browser and go to the openmrs setup wizard at http://localhost:8080/openmrs/spa
156156
NOTE: The default location of the "database" folder is that where the standalone.jar file is.
157157
You should also add the application_data_directory key to the runtime properties file. Something like this:
158158
application_data_directory=appdata

pom-step-01.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
<groupId>org.openmrs</groupId>
66
<artifactId>referenceapplication-standalone-01</artifactId>
7-
<version>2.6.0-SNAPSHOT</version>
7+
<version>3.0.0-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>referenceapplication-standalone-01</name>
1111

1212
<parent>
1313
<groupId>org.openmrs</groupId>
1414
<artifactId>referenceapplication-standalone</artifactId>
15-
<version>2.6.0-SNAPSHOT</version>
15+
<version>3.0.0-SNAPSHOT</version>
1616
<relativePath>pom.xml</relativePath>
1717
</parent>
1818

pom-step-02.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
<groupId>org.openmrs</groupId>
66
<artifactId>referenceapplication-standalone-02</artifactId>
7-
<version>2.6.0-SNAPSHOT</version>
7+
<version>3.0.0-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>referenceapplication-standalone-02</name>
1111

1212
<parent>
1313
<groupId>org.openmrs</groupId>
1414
<artifactId>referenceapplication-standalone</artifactId>
15-
<version>2.6.0-SNAPSHOT</version>
15+
<version>3.0.0-SNAPSHOT</version>
1616
<relativePath>pom.xml</relativePath>
1717
</parent>
1818

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.openmrs</groupId>
66
<artifactId>referenceapplication-standalone</artifactId>
7-
<version>2.6.0-SNAPSHOT</version>
7+
<version>3.0.0-SNAPSHOT</version>
88

99
<name>referenceapplication-standalone</name>
1010
<url>https://github.com/openmrs/openmrs-standalone/</url>
@@ -22,8 +22,8 @@
2222
<liquibase.plugin.version>4.23.2</liquibase.plugin.version>
2323

2424
<tomcat.version>9.0.106</tomcat.version>
25-
<openmrs.version>2.8.0-SNAPSHOT</openmrs.version>
26-
<refapp.version>2.14.0-SNAPSHOT</refapp.version>
25+
<openmrs.version>2.7.4</openmrs.version>
26+
<refapp.version>3.4.0</refapp.version>
2727
<mariadb4jVersion>3.2.0</mariadb4jVersion>
2828
<junitVersion>5.12.2</junitVersion>
2929
<mockitoVersion>3.12.4</mockitoVersion>
@@ -125,14 +125,14 @@
125125
<requireProperty>
126126
<property>refapp.version</property>
127127
<message>refapp.version property is missing. This should be
128-
something like 2.4, 2.5 Add
129-
-Drefapp.version=2.5</message>
128+
something like 3.4, 3.5 Add
129+
-Drefapp.version=3.5</message>
130130
</requireProperty>
131131
<requireProperty>
132132
<property>openmrs.version</property>
133133
<message>openmrs.version property is missing. This should be
134-
something like 2.0.2, 2.0.5 Add
135-
-Dopenmrs.version=2.0.5</message>
134+
something like 3.4.0, 3.3.1 Add
135+
-Dopenmrs.version=3.4.1-SNAPSHOT</message>
136136
</requireProperty>
137137
</rules>
138138
<fail>true</fail>

readme.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
...............QUICK SUMMARY FOR BUILDING THE STANDALONE.....................
33
* Increase the maven memory: e.g. export MAVEN_OPTS="-Xms1012m -Xmx2024m"
44
* mvn clean
5-
* mvn package -Dopenmrs.version=2.8.0-SNAPSHOT -Drefapp.version=2.14.0-SNAPSHOT
6-
* You can also use mvn package to build the default version on openmrs.version=2.8.0-SNAPSHOT and refapp.version=2.14.0-SNAPSHOT
5+
* mvn package -Dopenmrs.version=2.7.4 -Drefapp.version=3.4.0
6+
* You can also use mvn package to build the default version on openmrs.version=2.7.4 and refapp.version=3.4.0
77
* If running a second time, ALWAYS check to make sure mysql processes on port 3326 and 3328 are stopped.
88
If you DON'T do that, then the "mvn clean" will not really clean.
99
A good command to use is: "pkill -f standalone" (kills anything with "standalone" in the path)
@@ -12,15 +12,15 @@
1212
-> the contents of that zip are in the similarly-named folder under /target, if you want to test in-place
1313

1414

15-
.......................OpenMRS Standalone README............................
15+
.......................OpenMRS Standalone 3.x README............................
1616

1717

1818

1919
........................HOW TO RUN FROM ECLIPSE.............................
2020

2121
- Copy your war file into the "tomcat/webapps" folder. Where the tomcat folder is at the root of the project.
2222
If you already have openmrs installed and do not want to interfere with it, just rename
23-
your war file to something different from openmrs.war. Examples are openmrs-2.8.0-SNAPSHOT.war, etc which suppoort Java 17 and above.
23+
your war file to something different from openmrs.war. Examples are openmrs-2.7.4.war, etc which suppoort Java 17 and above.
2424

2525
- Right click on the project and select Run As -> Run Configurations
2626

@@ -197,7 +197,7 @@ browser Use to launch a new browser instance.
197197
4- The application will start the tomcat server and then the mariadb4j database engine.
198198
5- Follow the steps in the openmrs setup wizard to select where you want the demo database distribution or ciel database distribution to be created.
199199
6- After the setup wizard is done, you will have a database created in the location you selected.
200-
7- Open your browser and go to the openmrs setup wizard at http://localhost:8080/openmrs
200+
7- Open your browser and go to the openmrs setup wizard at http://localhost:8080/openmrs/spa
201201
NOTE: The default location of the "database" folder is that where the standalone.jar file is.
202202
You should also add the application_data_directory key to the runtime properties file. Something like this:
203203
application_data_directory=appdata

src/main/assembly/zip-standalone.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
<outputDirectory>${project.build.finalName}/tomcat/webapps</outputDirectory>
1414
<destName>openmrs.war</destName>
1515
</file>
16+
<file>
17+
<source>${project.build.directory}/distro/web/spa-build-config.json</source>
18+
<outputDirectory>${project.build.finalName}/appdata/</outputDirectory>
19+
<destName>spa-build-config.json</destName>
20+
</file>
21+
<file>
22+
<source>${project.build.directory}/distro/web/openmrs-distro.properties</source>
23+
<outputDirectory>${project.build.finalName}/appdata/</outputDirectory>
24+
<destName>openmrs-distro.properties</destName>
25+
</file>
1626
</files>
1727
<fileSets>
1828
<fileSet>
@@ -36,5 +46,13 @@
3646
<directory>${project.build.directory}/distro/web/openmrs_owas</directory>
3747
<outputDirectory>${project.build.finalName}/appdata/owa</outputDirectory>
3848
</fileSet>
49+
<fileSet>
50+
<directory>${project.build.directory}/distro/web/openmrs_config</directory>
51+
<outputDirectory>${project.build.finalName}/appdata/configuration</outputDirectory>
52+
</fileSet>
53+
<fileSet>
54+
<directory>${project.build.directory}/distro/web/openmrs_spa</directory>
55+
<outputDirectory>${project.build.finalName}/appdata/frontend</outputDirectory>
56+
</fileSet>
3957
</fileSets>
4058
</assembly>

src/main/java/org/openmrs/standalone/OpenmrsUtil.java

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -128,68 +128,6 @@ public static Properties getRuntimeProperties(String applicationName) {
128128
System.out.println("Failed to get runtime properties file.");
129129

130130
return null;
131-
132-
/*if (applicationName == null)
133-
applicationName = "openmrs";
134-
135-
runtimePropertiesPathName = null;
136-
FileInputStream propertyStream = null;
137-
138-
// first look for an environment variable
139-
{
140-
String envVarName = applicationName.toUpperCase() + "_RUNTIME_PROPERTIES_FILE";
141-
runtimePropertiesPathName = System.getenv(envVarName);
142-
if (runtimePropertiesPathName != null) {
143-
try {
144-
propertyStream = new FileInputStream(runtimePropertiesPathName);
145-
}
146-
catch (IOException e) {
147-
}
148-
}
149-
}
150-
151-
String filename = applicationName + "-runtime.properties";
152-
153-
// next look in the OpenMRS application data directory
154-
if (propertyStream == null) {
155-
runtimePropertiesPathName = OpenmrsUtil.getApplicationDataDirectory() + filename;
156-
System.out.println("Attempting to load property file from: " + runtimePropertiesPathName);
157-
try {
158-
propertyStream = new FileInputStream(runtimePropertiesPathName);
159-
}
160-
catch (FileNotFoundException e) {
161-
}
162-
}
163-
164-
// last chance, look in the current directory (that java was started
165-
// from)
166-
if (propertyStream == null) {
167-
runtimePropertiesPathName = filename;
168-
System.out.println("Attempting to load properties file in current directory: " + runtimePropertiesPathName);
169-
try {
170-
propertyStream = new FileInputStream(runtimePropertiesPathName);
171-
}
172-
catch (FileNotFoundException e) {
173-
}
174-
}
175-
176-
try {
177-
if (propertyStream != null) {
178-
Properties props = new Properties();
179-
loadProperties(props, propertyStream);
180-
propertyStream.close();
181-
System.out.println("Using runtime properties file: " + runtimePropertiesPathName);
182-
return props;
183-
}
184-
}
185-
catch (Exception ex) {
186-
ex.printStackTrace();
187-
return null;
188-
}
189-
190-
System.out.println("Failed to get runtime properties file.");
191-
192-
return null;*/
193131
}
194132

195133
/**
@@ -227,7 +165,7 @@ private static String getApplicationDataDirectory() {
227165
* Convenience method used to load properties from the given file.
228166
*
229167
* @param props the properties object to be loaded into
230-
* @param propertyFile the properties file to read
168+
* @param inputStream the properties file to read
231169
*/
232170
private static void loadProperties(Properties props, InputStream inputStream) {
233171
try {

src/main/java/org/openmrs/standalone/StandaloneUtil.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ public static String setPortsAndMySqlPassword(String mariaDBPort, String tomcatP
176176
}
177177
}
178178

179-
//We change the mysql password only if it is test.
180-
//if (password != null && password.toLowerCase().equals("test")) {
181-
182179
//Change the mysql password if instructed to.
183180
if ("true".equalsIgnoreCase(resetConnectionPassword)) {
184181
String newPassword = generateSecurePassword();
@@ -278,7 +275,7 @@ public static boolean launchBrowser(int port, String contextName) {
278275
Desktop desktop = Desktop.getDesktop();
279276

280277
if (desktop.isSupported(Desktop.Action.BROWSE)) {
281-
desktop.browse(new URI("http://localhost:" + port + "/" + contextName));
278+
desktop.browse(new URI("http://localhost:" + port + "/" + contextName + "/spa"));
282279
return true;
283280
}
284281
}

0 commit comments

Comments
 (0)