Skip to content

Commit

Permalink
Merge b91805f into 8149ca4
Browse files Browse the repository at this point in the history
  • Loading branch information
cozej4 committed Jan 28, 2021
2 parents 8149ca4 + b91805f commit fcc81ad
Show file tree
Hide file tree
Showing 24 changed files with 183 additions and 29 deletions.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
<metadata modelVersion="1.1.0">
<groupId>tz.go.moh.him</groupId>
<artifactId>mediator-core</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.2-SNAPSHOT</version>
<versioning>
<snapshot>
<localCopy>true</localCopy>
</snapshot>
<lastUpdated>20210111094800</lastUpdated>
<lastUpdated>20210122114729</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<extension>jar</extension>
<value>0.1.1-SNAPSHOT</value>
<updated>20210111094800</updated>
<value>0.1.2-SNAPSHOT</value>
<updated>20210122114729</updated>
</snapshotVersion>
<snapshotVersion>
<extension>pom</extension>
<value>0.1.1-SNAPSHOT</value>
<updated>20210111094800</updated>
<value>0.1.2-SNAPSHOT</value>
<updated>20210122114729</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d789e94c51a4ca8a3f7936480dfc0cde
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
48c7c5dcee00cac7d4043ef8b0832d75a79b8bf2
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
154ec91f846cad7389133c00d14d3273
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1ce612f36f5d76556d7017ef9e12467ca41da3a1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>tz.go.moh.him</groupId>
<artifactId>mediator-core</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.2-SNAPSHOT</version>

<name>mediator-core</name>
<url>https://github.com/SoftmedTanzania/mediator-core</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2751f3c0e247b9b934b5e5b45b42e0de
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6c9b5fc5edc5082fea8f770c0a3790adc8c8e34c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<artifactId>mediator-core</artifactId>
<versioning>
<versions>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.2-SNAPSHOT</version>
</versions>
<lastUpdated>20210111094800</lastUpdated>
<lastUpdated>20210122114729</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aabc792574f8589705fab8da342912ca
c1068916a0c36591226dbfe166e35f82
Original file line number Diff line number Diff line change
@@ -1 +1 @@
94ac9d4b741b86bdfd6e00604dad85e9d56cfb08
eead6d04b0ec1f0f1796334cb05c1190d4da0a58
49 changes: 48 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<version>0.1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<akka.version>2.3.7</akka.version>
<scala.binary.version>2.10</scala.binary.version>
</properties>
<repositories>
<repository>
Expand Down Expand Up @@ -114,11 +116,56 @@
<artifactId>maven-model</artifactId>
<version>3.3.9</version>
</dependency>

<!-- Local -->
<dependency>
<groupId>tz.go.moh.him</groupId>
<artifactId>mediator-core</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.2-SNAPSHOT</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.maven/maven-model -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.6.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-slf4j -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_${scala.binary.version}</artifactId>
<version>${akka.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>

<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<!-- https://mvnrepository.com/artifact/log4j/apache-log4j-extras -->
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>1.2.17</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.30</version>
</dependency>

<!-- Testing dependencies -->
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,34 @@ private void sendDataToElmis(String msg) {
headers.put("Content-Type", "application/json");

String scheme;
if (config.getProperty("elmis.secure").equals("true")) {
scheme = "https";
String host;
String path;
int portNumber;

if (config.getDynamicConfig().isEmpty()) {
if (config.getProperty("elmis.secure").equals("true")) {
scheme = "https";
} else {
scheme = "http";
}

host = config.getProperty("elmis.host");
portNumber = Integer.parseInt(config.getProperty("elmis.api.port"));
path = config.getProperty("elmis.api.daily_stock_status.path");
} else {
scheme = "http";
JSONObject connectionProperties = new JSONObject(config.getDynamicConfig()).getJSONObject("elmisConnectionProperties");

host = connectionProperties.getString("elmisHost");
portNumber = connectionProperties.getInt("elmisPort");
path = connectionProperties.getString("elmisDailyStockStatusPath");
scheme = connectionProperties.getString("elmisScheme");
}

List<Pair<String, String>> params = new ArrayList<>();

MediatorHTTPRequest forwardToElmisRequest = new MediatorHTTPRequest(
(originalRequest).getRequestHandler(), getSelf(), "Sending Diaily Stock Status to eLMIS", "POST", scheme,
config.getProperty("elmis.host"), Integer.parseInt(config.getProperty("elmis.api.port")), config.getProperty("elmis.api.daily_stock_status.path"),
msg, headers, params
host, portNumber, path, msg, headers, params
);

ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,28 @@ protected boolean validateOutOfStockNotification(OutOfStockNotification outOfSto
* @param msg body to be sent
*/
private void sendDataToElmis(String msg) {
String path;
String host;
String scheme;
if (config.getProperty("elmis.secure").equals("true")) {
scheme = "https";
int portNumber;

if (config.getDynamicConfig().isEmpty()) {
if (config.getProperty("elmis.secure").equals("true")) {
scheme = "https";
} else {
scheme = "http";
}

host = config.getProperty("elmis.host");
portNumber = Integer.parseInt(config.getProperty("elmis.api.port"));
path = config.getProperty("elmis.api.out_of_stock_notification.path");
} else {
scheme = "http";
JSONObject connectionProperties = new JSONObject(config.getDynamicConfig()).getJSONObject("elmisConnectionProperties");

host = connectionProperties.getString("elmisHost");
portNumber = connectionProperties.getInt("elmisPort");
path = connectionProperties.getString("elmisOutOfStockNotificationPath");
scheme = connectionProperties.getString("elmisScheme");
}

Map<String, String> headers = new HashMap<>();
Expand All @@ -294,8 +311,7 @@ private void sendDataToElmis(String msg) {

MediatorHTTPRequest forwardToElmisRequest = new MediatorHTTPRequest(
(originalRequest).getRequestHandler(), getSelf(), "Sending Out of Stock Notification to eLMIS", "POST", scheme,
config.getProperty("elmis.host"), Integer.parseInt(config.getProperty("elmis.api.port")), config.getProperty("elmis.api.out_of_stock_notification.path"),
msg, headers, params
host, portNumber, path, msg, headers, params
);

ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Expand Down
31 changes: 31 additions & 0 deletions src/main/resources/log4j.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="ActiveFileName" value="elmis-mediator-e9.log"/>
<param name="FileNamePattern" value="elmis-mediator-e9.%d{yyyy-MM-dd}.log.gz"/>
</rollingPolicy>
<triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="MaxFileSize" value="5000"/>
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
<param name="blocking" value="false"/>
<appender-ref ref="FILE"/>
</appender>

<root>
<priority value="DEBUG"/>
<appender-ref ref="ASYNC"/>
<appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>
46 changes: 45 additions & 1 deletion src/main/resources/mediator-registration-info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"urn": "urn:uuid:bb49a1b0-4ad0-11eb-833f-a1f936ef8af5",
"version": "0.1.0",
"name": "eLMIS Mediator",
"name": "MSD Epicor 9 to eLMIS Mediator",
"description": "An openHIM mediator for handling sharing out of stock notification and daily stock status from MSD Epicor 9 to eLMIS.",
"endpoints": [
{
Expand Down Expand Up @@ -76,5 +76,49 @@
}
]
}
],
"configDefs": [
{
"param": "elmisConnectionProperties",
"displayName": "eLMIS Connection Properties",
"description": "Configuration to set the hostname, port and path for the eLMIS server",
"type": "struct",
"template": [
{
"param": "elmisHost",
"displayName": "eLMIS Server Host Name",
"description": "IP address/hostname of the eLMIS server. e.g 192.168.1.1",
"type": "string"
},
{
"param": "elmisPort",
"displayName": "eLMIS Port Number",
"description": "The port number of that the eLMIS server is running on. e.g 8080",
"type": "number"
},
{
"param": "elmisDailyStockStatusPath",
"displayName": "eLMIS Daily Stock Status API Path",
"description": "The path to the endpoint for receiving daily stock status data from the HIM. eg /elmis/daily-stock-status",
"type": "string"
},
{
"param": "elmisOutOfStockNotificationPath",
"displayName": "eLMIS Out of Stock Notification API Path",
"description": "The path to the endpoint for receiving Out of Stock Notification data from the HIM. eg /elmis/out-of-stock-notification",
"type": "string"
},
{
"param": "elmisScheme",
"displayName": "eLMIS Scheme",
"description": "Whether the eLMIS server is using HTTP or HTTPS requests",
"type": "option",
"values": [
"http",
"https"
]
}
]
}
]
}

0 comments on commit fcc81ad

Please sign in to comment.