Skip to content

Commit

Permalink
Fixed MultiDatastream not picking up ID type of Thing and Sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
hylkevds committed Jul 10, 2024
1 parent cd9b926 commit 6c80d1f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ public class TableImpMultiDatastreams extends StaTableAbstract<TableImpMultiData
/**
* The column <code>public.MULTI_DATASTREAMS.ID</code>.
*/
public final TableField<Record, ?> colId = createField(DSL.name("ID"), getIdType(), this);
public final TableField<Record, ?> colId = createField(DSL.name("ID"), getIdType().nullable(false), this);

/**
* The column <code>public.MULTI_DATASTREAMS.SENSOR_ID</code>.
*/
public final TableField<Record, ?> colSensorId = createField(DSL.name("SENSOR_ID"), getIdType(), this);
public final TableField<Record, ?> colSensorId;

/**
* The column <code>public.MULTI_DATASTREAMS.THING_ID</code>.
*/
public final TableField<Record, ?> colThingId = createField(DSL.name("THING_ID"), getIdType(), this);
public final TableField<Record, ?> colThingId;

private final transient PluginMultiDatastream pluginMultiDatastream;
private final transient PluginCoreModel pluginCoreModel;
Expand All @@ -157,13 +157,19 @@ public class TableImpMultiDatastreams extends StaTableAbstract<TableImpMultiData
*
* @param idType The (SQL)DataType of the Id columns used in the actual
* database.
* @param idTypeSnsr The (SQL)DataType of the SENSOR_ID column used in the
* database.
* @param idTypeTng The (SQL)DataType of the THING_ID column used in the
* database.
* @param pMultiDs the multiDatastream plugin this table belongs to.
* @param pCoreModel the coreModel plugin that this data model links to.
*/
public TableImpMultiDatastreams(DataType<?> 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) {
Expand All @@ -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
Expand Down

0 comments on commit 6c80d1f

Please sign in to comment.