Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion services/sensorhub-service-discovery/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
description = 'Discovery Service'
ext.details = 'Service providing discovery based on defineable rulesets'

version= '1.1.0'
version= '2.0.0'

dependencies {
implementation 'org.sensorhub:sensorhub-core:' + oshCoreVersion
implementation 'org.sensorhub:sensorhub-service-consys:' + oshCoreVersion
implementation project(':sensorhub-lib-rules-engine')
embeddedImpl 'com.j2html:j2html:1.5.0'
embeddedImpl 'com.google.code.gson:gson:2.9.0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
******************************* END LICENSE BLOCK ***************************/
package com.botts.impl.service.discovery;

import com.botts.impl.service.discovery.engine.RulesEngine;
import com.botts.impl.service.discovery.engine.facts.DataStreamFact;
import com.botts.impl.service.discovery.engine.rules.RuleManager;
import com.botts.impl.service.discovery.engine.rules.Rules;
import com.botts.impl.service.discovery.engine.RulesEngineWrapper;
import com.botts.impl.service.discovery.engine.visualizations.VisualizationMapper;
import com.georobotix.ai.impl.rulesengine.facts.DataStreamFact;
import com.georobotix.ai.impl.rulesengine.rules.RuleManager;
import com.georobotix.ai.impl.rulesengine.rules.Rules;
import org.sensorhub.api.common.SensorHubException;
import org.sensorhub.api.data.DataStreamAddedEvent;
import org.sensorhub.api.data.DataStreamEvent;
Expand Down Expand Up @@ -57,11 +57,6 @@ public class DiscoveryService extends AbstractHttpServiceModule<DiscoveryService
*/
private Flow.Subscription dataStreamSubscription = null;

/**
* Subscription used by the service to be notified in changes to modules
*/
private Flow.Subscription moduleEventSubscription = null;

/**
* A thread pool controlling the maximum number of concurrent requests processed by the service
*/
Expand Down Expand Up @@ -113,12 +108,12 @@ public void onNext(SystemEvent systemEvent) {
if (dataStreamEvent instanceof DataStreamAddedEvent) {

logger.debug("Adding new fact to knowledge base");
RulesEngine.getInstance().addFact(new DataStreamFact(systemId, dataStreamId, dataStreamInfo));
RulesEngineWrapper.getInstance().addFact(new DataStreamFact(systemId, dataStreamId, dataStreamInfo));

} else if (dataStreamEvent instanceof DataStreamRemovedEvent) {

logger.debug("Removing fact from knowledge base");
RulesEngine.getInstance().removeFact(systemId, dataStreamId);
RulesEngineWrapper.getInstance().removeFact(systemId, dataStreamId);
}
}
}
Expand All @@ -140,7 +135,6 @@ public void onComplete() {
initializeFacts();
VisualizationMapper visualizationMapper = VisualizationMapper.getInstance();
visualizationMapper.setFile(config.visRulesFilePath);
// visualizationMapper.setEncoder(idEncoder);
visualizationMapper.setParentHub(this.getParentHub());
// set federatedDB for visualization mapper
visualizationMapper.setFederatedDB(getParentHub().getDatabaseRegistry().getFederatedDatabase().getDataStreamStore());
Expand Down Expand Up @@ -195,7 +189,7 @@ public void doStop() {

initialized.set(false);

RulesEngine.getInstance().reset();
RulesEngineWrapper.getInstance().reset();
}

@Override
Expand Down Expand Up @@ -246,7 +240,7 @@ private void undeploy() {
}

/**
* Loads the rules to be used by the internal rules based engine
* Loads the rules to be used by the internal rule engine
*
* @throws SensorHubException if rules could not be loaded or are missing
*/
Expand All @@ -265,7 +259,7 @@ private void loadRules() throws SensorHubException {

RuleManager.loadRules(configRules, rules);

RulesEngine.getInstance().setRules(rules);
RulesEngineWrapper.getInstance().setRules(rules);

} catch (IOException e) {

Expand All @@ -285,7 +279,7 @@ private void initializeFacts() {
IDataStreamInfo dataStreamInfo = dataStreamEntry.getValue();
String systemId = getParentHub().getIdEncoders().getSystemIdEncoder().encodeID(dataStreamInfo.getSystemID().getInternalID());
String dataStreamId = getParentHub().getIdEncoders().getDataStreamIdEncoder().encodeID(dataStreamEntry.getKey().getInternalID());
RulesEngine.getInstance().addFact(new DataStreamFact(systemId, dataStreamId, dataStreamInfo));
RulesEngineWrapper.getInstance().addFact(new DataStreamFact(systemId, dataStreamId, dataStreamInfo));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
******************************* END LICENSE BLOCK ***************************/
package com.botts.impl.service.discovery;

import com.georobotix.ai.impl.rulesengine.config.RuleEditor;
import org.sensorhub.api.config.DisplayInfo;
import org.sensorhub.api.security.SecurityConfig;
import org.sensorhub.api.service.HttpServiceConfig;
Expand All @@ -25,6 +26,9 @@ public class DiscoveryServiceConfig extends HttpServiceConfig {
@DisplayInfo(label = "Visualization Map File", desc = "Visualization Map File")
public String visRulesFilePath = "./config/rules/visrules-update.json";

@DisplayInfo(label = "Rules Editor", desc = "Build rules to apply for data mapping according to field definitions")
public RuleEditor ruleEditor = new RuleEditor();

public DiscoveryServiceConfig() {

this.moduleClass = DiscoveryService.class.getCanonicalName();
Expand Down

This file was deleted.

Loading
Loading