Skip to content

Commit

Permalink
- Added a generic data source
Browse files Browse the repository at this point in the history
- Added the capability to execute a script in the Tester application
- Documented an Apache RocketMQ example of a generic data source
- Updated RabbitMQ to 5.25.0
  • Loading branch information
point85 committed Mar 2, 2025
1 parent 5513473 commit b5ae1e8
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 24 deletions.
2 changes: 1 addition & 1 deletion install-oee-domain-jar.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ rem Maven install script for OEE Domain jar
call mvn -v
call mvn clean package
rem install jar in local repo
call mvn install:install-file -Dfile=./target/OEE-Domain-3.12.0.jar -DgroupId=org.point85 -DartifactId=oee-domain -Dversion=3.12.0 -Dpackaging=jar
call mvn install:install-file -Dfile=./target/OEE-Domain-3.12.1.jar -DgroupId=org.point85 -DartifactId=oee-domain -Dversion=3.12.1 -Dpackaging=jar
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.point85</groupId>
<artifactId>oee-domain</artifactId>
<version>3.12.0</version>
<version>3.12.1</version>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>

Expand Down Expand Up @@ -124,7 +124,7 @@
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>5.24.0</version>
<version>5.25.0</version>
</dependency>

<!-- ACTIVEMQ -->
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/org/point85/domain/DomainUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.eclipse.paho.client.mqttv3.MqttException;
import org.jinterop.dcom.common.JIException;
import org.openscada.opc.dcom.common.FILETIME;
import org.point85.domain.generic.GenericSource;
import org.point85.domain.i18n.DomainLocalizer;
import org.point85.domain.persistence.PersistenceService;

public final class DomainUtils {
// ISO 8601 datetime format, yyyy-mm-ddThh:mm:ss.nnnnnn+|-hh:mm
Expand All @@ -48,8 +50,8 @@ private DomainUtils() {
}

public static String getVersionInfo() {
return DomainLocalizer.instance().getLangString("version") + " 3.12.0, "
+ LocalDate.of(2025, 2, 4).format(DateTimeFormatter.ISO_DATE);
return DomainLocalizer.instance().getLangString("version") + " 3.12.1, "
+ LocalDate.of(2025, 3, 3).format(DateTimeFormatter.ISO_DATE);
}

// format a Duration
Expand Down Expand Up @@ -259,4 +261,14 @@ public static String byteArrayToHex(byte[] byteArray) {
}
return sb.toString();
}

/**
* Fetch the named generic data source
* @param name Name of source
* @return {@link GenericSource}
* @throws Exception Exception
*/
public static GenericSource getGenericSource(String name) throws Exception {
return (GenericSource)PersistenceService.instance().fetchDataSourceByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.point85.domain.i18n.DomainLocalizer;

public enum DataSourceType {
CRON, DATABASE, EMAIL, FILE, HTTP, JMS, KAFKA, MODBUS, MQTT, OPC_DA, OPC_UA, PROFICY, RMQ, WEB_SOCKET;
CRON, DATABASE, EMAIL, FILE, HTTP, JMS, KAFKA, MODBUS, MQTT, OPC_DA, OPC_UA, PROFICY, RMQ, WEB_SOCKET, GENERIC;

public static final String OPC_DA_VALUE = "OPC_DA";
public static final String OPC_UA_VALUE = "OPC_UA";
Expand All @@ -19,6 +19,7 @@ public enum DataSourceType {
public static final String EMAIL_VALUE = "EMAIL";
public static final String PROFICY_VALUE = "PROFICY";
public static final String WEB_SOCKET_VALUE = "WEB_SOCKET";
public static final String GENERIC_VALUE = "GENERIC";

@Override
public String toString() {
Expand Down Expand Up @@ -67,6 +68,9 @@ public String toString() {
case WEB_SOCKET:
key = "web.socket.type";
break;
case GENERIC:
key = "generic.type";
break;
default:
break;
}
Expand Down
61 changes: 61 additions & 0 deletions src/main/java/org/point85/domain/dto/GenericSourceDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.point85.domain.dto;

import org.point85.domain.generic.GenericSource;

public class GenericSourceDto extends CollectorDataSourceDto {
private String attribute1;
private String attribute2;
private String attribute3;
private String attribute4;
private String attribute5;

public GenericSourceDto(GenericSource source) {
super(source);

this.setAttribute1(source.getAttribute1());
this.setAttribute2(source.getAttribute2());
this.setAttribute3(source.getAttribute3());
this.setAttribute4(source.getAttribute4());
this.setAttribute5(source.getAttribute5());
}

public String getAttribute1() {
return attribute1;
}

public void setAttribute1(String attribute) {
this.attribute1 = attribute;
}

public String getAttribute2() {
return attribute2;
}

public void setAttribute2(String attribute) {
this.attribute2 = attribute;
}

public String getAttribute3() {
return attribute3;
}

public void setAttribute3(String attribute) {
this.attribute3 = attribute;
}

public String getAttribute4() {
return attribute4;
}

public void setAttribute4(String attribute) {
this.attribute4 = attribute;
}

public String getAttribute5() {
return attribute5;
}

public void setAttribute5(String attribute) {
this.attribute5 = attribute;
}
}
17 changes: 12 additions & 5 deletions src/main/java/org/point85/domain/exim/ExportImportContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.point85.domain.dto.EnterpriseDto;
import org.point85.domain.dto.EquipmentDto;
import org.point85.domain.dto.FileSourceDto;
import org.point85.domain.dto.GenericSourceDto;
import org.point85.domain.dto.HttpSourceDto;
import org.point85.domain.dto.JmsSourceDto;
import org.point85.domain.dto.KafkaSourceDto;
Expand Down Expand Up @@ -59,18 +60,19 @@ public class ExportImportContent {
private List<ProficySourceDto> proficySources = new ArrayList<>();
private List<RmqSourceDto> rmqSources = new ArrayList<>();
private List<WebSocketSourceDto> webSocketSources = new ArrayList<>();

private List<GenericSourceDto> genericSources = new ArrayList<>();

// create or update flag
private Boolean forCreate;

public ExportImportContent() {

}

public ExportImportContent(Boolean forCreate) {
this.forCreate = forCreate;
}

public Boolean isForCreate() {
return this.forCreate;
}
Expand Down Expand Up @@ -103,6 +105,7 @@ public void clear() {
this.proficySources.clear();
this.rmqSources.clear();
this.webSocketSources.clear();
this.genericSources.clear();
}

public List<MaterialDto> getMaterials() {
Expand Down Expand Up @@ -229,6 +232,10 @@ List<WebSocketSourceDto> getWebSocketSources() {
return webSocketSources;
}

List<GenericSourceDto> getGenericSources() {
return genericSources;
}

List<DataCollectorDto> getDataCollectors() {
return dataCollectors;
}
Expand Down
44 changes: 32 additions & 12 deletions src/main/java/org/point85/domain/exim/Exporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.point85.domain.dto.EnterpriseDto;
import org.point85.domain.dto.EquipmentDto;
import org.point85.domain.dto.FileSourceDto;
import org.point85.domain.dto.GenericSourceDto;
import org.point85.domain.dto.HttpSourceDto;
import org.point85.domain.dto.JmsSourceDto;
import org.point85.domain.dto.KafkaSourceDto;
Expand All @@ -39,6 +40,7 @@
import org.point85.domain.dto.WorkScheduleDto;
import org.point85.domain.email.EmailSource;
import org.point85.domain.file.FileEventSource;
import org.point85.domain.generic.GenericSource;
import org.point85.domain.http.HttpSource;
import org.point85.domain.jms.JmsSource;
import org.point85.domain.kafka.KafkaSource;
Expand Down Expand Up @@ -159,6 +161,8 @@ public synchronized ExportImportContent backup(Class<?> clazz, File file) throws
prepareRmqDataSources(PersistenceService.instance().fetchDataSources(DataSourceType.RMQ));
} else if (clazz.equals(WebSocketSource.class)) {
prepareWebSocketDataSources(PersistenceService.instance().fetchDataSources(DataSourceType.WEB_SOCKET));
} else if (clazz.equals(GenericSource.class)) {
prepareGenericDataSources(PersistenceService.instance().fetchDataSources(DataSourceType.GENERIC));
} else {
logger.error("Unknown backup class: " + clazz.getSimpleName());
}
Expand Down Expand Up @@ -220,35 +224,35 @@ public synchronized ExportImportContent backupHttpSources(List<CollectorDataSour
backup(file);
return content;
}

public synchronized ExportImportContent backupCronSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareCronDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupDatabaseSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareDatabaseDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupEmailSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareEmailDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupFileSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareFileDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupJmsSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareJmsDataSources(sources);
Expand All @@ -262,49 +266,56 @@ public synchronized ExportImportContent backupKafkaSources(List<CollectorDataSou
backup(file);
return content;
}

public synchronized ExportImportContent backupModbusSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareModbusDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupMqttSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareMqttDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupOpcDaSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareOpcDaDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupProficySources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareProficyDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupRmqSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareRmqDataSources(sources);
backup(file);
return content;
}

public synchronized ExportImportContent backupWebSocketSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareWebSocketDataSources(sources);
backup(file);
return content;
}


public synchronized ExportImportContent backupGenericSources(List<CollectorDataSource> sources, File file)
throws Exception {
prepareGenericDataSources(sources);
backup(file);
return content;
}

/**
* Serialize the objects of this class prior to writing them to a file
*
Expand Down Expand Up @@ -675,4 +686,13 @@ private void prepareWebSocketDataSources(List<CollectorDataSource> sources) {
content.getWebSocketSources().add(dto);
}
}

private void prepareGenericDataSources(List<CollectorDataSource> sources) {
content.getGenericSources().clear();

for (CollectorDataSource source : sources) {
GenericSourceDto dto = new GenericSourceDto((GenericSource) source);
content.getGenericSources().add(dto);
}
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/point85/domain/exim/Importer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.point85.domain.dto.EnterpriseDto;
import org.point85.domain.dto.EquipmentDto;
import org.point85.domain.dto.FileSourceDto;
import org.point85.domain.dto.GenericSourceDto;
import org.point85.domain.dto.HttpSourceDto;
import org.point85.domain.dto.JmsSourceDto;
import org.point85.domain.dto.KafkaSourceDto;
Expand All @@ -42,6 +43,7 @@
import org.point85.domain.dto.WorkScheduleDto;
import org.point85.domain.email.EmailSource;
import org.point85.domain.file.FileEventSource;
import org.point85.domain.generic.GenericSource;
import org.point85.domain.http.HttpSource;
import org.point85.domain.i18n.DomainLocalizer;
import org.point85.domain.jms.JmsSource;
Expand Down Expand Up @@ -1011,6 +1013,21 @@ private void restoreDataSources(ExportImportContent content) throws Exception {
}
break;
}
case GENERIC: {
for (GenericSourceDto dto : content.getGenericSources()) {
CollectorDataSource source = PersistenceService.instance().fetchDataSourceByName(dto.getName());

if (source == null) {
source = new GenericSource(dto);
toSaveSources.add(source);

if (logger.isInfoEnabled()) {
logger.info("Imported Generic source: " + dto.getName());
}
}
}
break;
}
default:
if (logger.isWarnEnabled()) {
logger.warn("Unknown import type: " + type.name());
Expand Down
Loading

0 comments on commit b5ae1e8

Please sign in to comment.