diff --git a/CHANGELOG.md b/CHANGELOG.md index 523269684..612bd6623 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Internal changes & Bugfixes** * [HELM] Added option to specify image pull secret name. * Fixed #1948: Sanitise user input in error output. +* Fixed MultiDatastream not picking up ID type of Thing and Sensor. ## Release version 2.3.2 diff --git a/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/PluginMultiDatastream.java b/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/PluginMultiDatastream.java index 6dff57e9c..fa8e698f3 100644 --- a/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/PluginMultiDatastream.java +++ b/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/PluginMultiDatastream.java @@ -32,6 +32,7 @@ import de.fraunhofer.iosb.ilt.frostserver.persistence.PersistenceManagerFactory; import de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.JooqPersistenceManager; import de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.tables.TableCollection; +import de.fraunhofer.iosb.ilt.frostserver.plugin.coremodel.CoreModelSettings; import de.fraunhofer.iosb.ilt.frostserver.plugin.coremodel.PluginCoreModel; import de.fraunhofer.iosb.ilt.frostserver.property.EntityPropertyMain; import de.fraunhofer.iosb.ilt.frostserver.property.NavigationPropertyMain.NavigationPropertyEntity; @@ -94,6 +95,7 @@ public class PluginMultiDatastream implements PluginRootDocument, PluginModel, C private CoreSettings settings; private MdsModelSettings modelSettings; + private CoreModelSettings coreModelSettings; private boolean enabled; private boolean fullyInitialised; @@ -108,6 +110,7 @@ public void init(CoreSettings settings) { enabled = pluginSettings.getBoolean(MdsModelSettings.TAG_ENABLE_MDS_MODEL, MdsModelSettings.class); if (enabled) { modelSettings = new MdsModelSettings(settings); + coreModelSettings = new CoreModelSettings(settings); settings.getPluginManager().registerPlugin(this); } } @@ -224,9 +227,11 @@ public boolean linkEntityTypes(PersistenceManager pm) { if (pm instanceof JooqPersistenceManager ppm) { final TableCollection tableCollection = ppm.getTableCollection(); + final DataType dataTypeSnsr = ppm.getDataTypeFor(coreModelSettings.idTypeSensor); + final DataType dataTypeThng = ppm.getDataTypeFor(coreModelSettings.idTypeThing); final DataType dataTypeMds = ppm.getDataTypeFor(modelSettings.idTypeMultiDatastream); final DataType dataTypeObsProp = tableCollection.getTableForType(pluginCoreModel.etObservedProperty).getId().getDataType(); - tableCollection.registerTable(etMultiDatastream, new TableImpMultiDatastreams(dataTypeMds, this, pluginCoreModel)); + tableCollection.registerTable(etMultiDatastream, new TableImpMultiDatastreams(dataTypeMds, dataTypeSnsr, dataTypeThng, this, pluginCoreModel)); tableCollection.registerTable(new TableImpMultiDatastreamsObsProperties(dataTypeMds, dataTypeObsProp)); } fullyInitialised = true; diff --git a/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/TableImpMultiDatastreams.java b/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/TableImpMultiDatastreams.java index 6c287080f..2dd9af970 100644 --- a/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/TableImpMultiDatastreams.java +++ b/Plugins/MultiDatastream/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/multidatastream/TableImpMultiDatastreams.java @@ -137,17 +137,17 @@ public class TableImpMultiDatastreams extends StaTableAbstractpublic.MULTI_DATASTREAMS.ID. */ - public final TableField colId = createField(DSL.name("ID"), getIdType(), this); + public final TableField colId = createField(DSL.name("ID"), getIdType().nullable(false), this); /** * The column public.MULTI_DATASTREAMS.SENSOR_ID. */ - public final TableField colSensorId = createField(DSL.name("SENSOR_ID"), getIdType(), this); + public final TableField colSensorId; /** * The column public.MULTI_DATASTREAMS.THING_ID. */ - public final TableField colThingId = createField(DSL.name("THING_ID"), getIdType(), this); + public final TableField colThingId; private final transient PluginMultiDatastream pluginMultiDatastream; private final transient PluginCoreModel pluginCoreModel; @@ -157,13 +157,19 @@ public class TableImpMultiDatastreams extends StaTableAbstract idType, PluginMultiDatastream pMultiDs, PluginCoreModel pCoreModel) { + public TableImpMultiDatastreams(DataType idType, DataType idTypeSnsr, DataType idTypeTng, PluginMultiDatastream pMultiDs, PluginCoreModel pCoreModel) { super(idType, DSL.name("MULTI_DATASTREAMS"), null, null); this.pluginMultiDatastream = pMultiDs; this.pluginCoreModel = pCoreModel; + colSensorId = createField(DSL.name("SENSOR_ID"), idTypeSnsr.nullable(false)); + colThingId = createField(DSL.name("THING_ID"), idTypeTng.nullable(false)); } private TableImpMultiDatastreams(Name alias, TableImpMultiDatastreams aliased, PluginMultiDatastream pMultiDs, PluginCoreModel pCoreModel) { @@ -174,6 +180,8 @@ private TableImpMultiDatastreams(Name alias, TableImpMultiDatastreams aliased, T super(aliased.getIdType(), alias, aliased, updatedSql); this.pluginMultiDatastream = pMultiDs; this.pluginCoreModel = pCoreModel; + colSensorId = createField(DSL.name("SENSOR_ID"), aliased.colSensorId.getDataType().nullable(false)); + colThingId = createField(DSL.name("THING_ID"), aliased.colThingId.getDataType().nullable(false)); } @Override