Skip to content

Commit

Permalink
remove model and send string only
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Pufler committed Nov 14, 2023
1 parent 5ce6ca6 commit fddbe8c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,18 @@
import com.mirth.connect.client.ui.PlatformUI;
import com.dedalus.versionplugin.shared.Constants;
import com.dedalus.versionplugin.shared.interfaces.VersionServletInterface;
import com.dedalus.versionplugin.shared.models.VersionModel;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@MirthClientClass
public class VersionPlugin extends ClientPlugin {

protected Frame frame = PlatformUI.MIRTH_FRAME;

private static final Logger logger = LogManager.getLogger(VersionPlugin.class);

private static final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();

private static VersionModel versionData;
private static String versionData;

public VersionPlugin(String name) {
super(name);
Expand All @@ -53,29 +47,25 @@ public String getPluginPointName() {

@Override
public void start() {
System.out.println("[" + Constants.POINT_NAME + "] Starting...");

try {
VersionServletInterface servlet = frame.mirthClient.getServlet(VersionServletInterface.class);
versionData = servlet.getVersionData();
} catch (Exception e) {
versionData = new VersionModel("N/A");
frame.alertThrowable(frame, e);
versionData = "N/A";
}

System.out.println("[" + Constants.POINT_NAME + "] Retrieved version " + versionData.getVersion());
System.out.println("[" + Constants.POINT_NAME + "] Retrieved version " + versionData);

Runnable updateTask = () -> {
if (frame.statusBar != null) {
String currentServerText = frame.statusBar.getServerText();
if (currentServerText.indexOf(versionData.getVersion()) == -1) {
System.out.println("[" + Constants.POINT_NAME + "] Updating StatusBar ServerText");
frame.statusBar
.setServerText(
currentServerText + " | Communication Platform Version: "
+ versionData.getVersion());
}
} else {
System.out.println("[" + Constants.POINT_NAME + "] StatusBar is null");
if (frame.statusBar == null)
return;

String currentServerText = frame.statusBar.getServerText();
if (currentServerText.indexOf(versionData) == -1) {
frame.statusBar
.setServerText(currentServerText + " | Communication Platform Version: " + versionData);

}
};

Expand All @@ -85,7 +75,6 @@ public void start() {

@Override
public void stop() {
System.out.println("[" + Constants.POINT_NAME + "] Stopping...");
executor.shutdownNow();
}

Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<mirth.version>4.4.0</mirth.version>
<mirth.version>4.4.1</mirth.version>

<maven-processor-plugin.version>4.5</maven-processor-plugin.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
Expand All @@ -57,7 +57,7 @@
<plugin.author>Julian Pufler</plugin.author>
<plugin.version>${project.version}</plugin.version>
<plugin.description>This plugin is used to display the communication platform version in the GUI</plugin.description>
<plugin.mirthVersion>4.4.0,4.3.0,4.2.0,4.1.1,4.1.0</plugin.mirthVersion>
<plugin.mirthVersion>4.4.1,4.4.0,4.3.0,4.2.0,4.1.1,4.1.0</plugin.mirthVersion>
<plugin.archive.name>versionplugin-${project.version}</plugin.archive.name>
</properties>

Expand Down Expand Up @@ -100,6 +100,12 @@
<version>${log4j.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-core</artifactId>
<version>1.6.5-1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
package com.dedalus.versionplugin.server;

import com.kaurpalang.mirth.annotationsplugin.annotation.MirthServerClass;
import com.dedalus.versionplugin.shared.interfaces.VersionServletInterface;
import com.dedalus.versionplugin.shared.Constants;
import com.mirth.connect.client.core.api.util.OperationUtil;
import com.mirth.connect.model.ExtensionPermission;
import com.mirth.connect.plugins.ServicePlugin;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.kaurpalang.mirth.annotationsplugin.type.ApiProviderType;
import com.dedalus.versionplugin.shared.Constants;
import com.dedalus.versionplugin.shared.interfaces.VersionServletInterface;
import com.dedalus.versionplugin.shared.models.VersionModel;
import com.mirth.connect.server.api.MirthServlet;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
Expand All @@ -35,8 +34,8 @@ public VersionServlet(@Context HttpServletRequest request, @Context SecurityCont
}

@Override
public VersionModel getVersionData() {
public String getVersionData() {
String version = System.getenv("COMPLATFORM_VERSION");
return new VersionModel(version);
return version;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@

import com.kaurpalang.mirth.annotationsplugin.annotation.MirthApiProvider;
import com.kaurpalang.mirth.annotationsplugin.type.ApiProviderType;
import com.dedalus.versionplugin.shared.models.VersionModel;
import com.mirth.connect.client.core.ClientException;
import com.mirth.connect.client.core.api.BaseServletInterface;
import com.mirth.connect.client.core.api.MirthOperation;
import com.mirth.connect.client.core.api.Param;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -44,9 +41,9 @@ public interface VersionServletInterface extends BaseServletInterface {
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiResponse(responseCode = "200", description = "Returns current CommunicationPlatform version data from ENV", content = {
@Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VersionModel.class)),
@Content(mediaType = MediaType.APPLICATION_XML, schema = @Schema(implementation = VersionModel.class))
@Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = String.class)),
@Content(mediaType = MediaType.APPLICATION_XML, schema = @Schema(implementation = String.class))
})
@MirthOperation(name = "getVersionData", display = "Get current CommunicationPlatform version data from ENV")
VersionModel getVersionData() throws ClientException;
String getVersionData() throws ClientException;
}

This file was deleted.

0 comments on commit fddbe8c

Please sign in to comment.