Browse Source

feature/TbSaveToCustomCassandraTable

pull/1589/head
ShvaykaD 8 years ago
parent
commit
37a52d4471
  1. 10
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbSaveToCustomCassandraTableNode.java
  2. 6
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbSaveToCustomCassandraTableNodeConfiguration.java

10
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbSaveToCustomCassandraTable.java → rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbSaveToCustomCassandraTableNode.java

@ -53,8 +53,6 @@ import org.thingsboard.server.dao.model.type.JsonCodec;
import org.thingsboard.server.dao.nosql.CassandraStatementTask;
import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -69,7 +67,7 @@ import static org.thingsboard.rule.engine.api.util.DonAsynchron.withCallback;
@Slf4j
@RuleNode(type = ComponentType.ACTION,
name = "save to custom table",
configClazz = TbSaveToCustomCassandraTableConfiguration.class,
configClazz = TbSaveToCustomCassandraTableNodeConfiguration.class,
nodeDescription = "Node stores data from incoming Message payload to the Cassandra database into the predefined custom table" +
" that should have <b>cs_tb_</b> prefix, to avoid the data insertion to the common TB tables.<br>" +
"<b>Note:</b> rule node can be used only for Cassandra DB.",
@ -81,12 +79,12 @@ import static org.thingsboard.rule.engine.api.util.DonAsynchron.withCallback;
uiResources = {"static/rulenode/rulenode-core-config.js"},
configDirective = "tbActionNodeCustomTableConfig",
icon = "file_upload")
public class TbSaveToCustomCassandraTable implements TbNode {
public class TbSaveToCustomCassandraTableNode implements TbNode {
private static final String TABLE_PREFIX = "cs_tb_";
private static final JsonParser parser = new JsonParser();
private TbSaveToCustomCassandraTableConfiguration config;
private TbSaveToCustomCassandraTableNodeConfiguration config;
private Session session;
private CassandraCluster cassandraCluster;
private ConsistencyLevel defaultWriteLevel;
@ -96,7 +94,7 @@ public class TbSaveToCustomCassandraTable implements TbNode {
@Override
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
config = TbNodeUtils.convert(configuration, TbSaveToCustomCassandraTableConfiguration.class);
config = TbNodeUtils.convert(configuration, TbSaveToCustomCassandraTableNodeConfiguration.class);
cassandraCluster = ctx.getCassandraCluster();
if (cassandraCluster == null) {
throw new RuntimeException("Unable to connect to Cassandra database");

6
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbSaveToCustomCassandraTableConfiguration.java → rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbSaveToCustomCassandraTableNodeConfiguration.java

@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map;
@Data
public class TbSaveToCustomCassandraTableConfiguration implements NodeConfiguration<TbSaveToCustomCassandraTableConfiguration> {
public class TbSaveToCustomCassandraTableNodeConfiguration implements NodeConfiguration<TbSaveToCustomCassandraTableNodeConfiguration> {
private String tableName;
@ -30,8 +30,8 @@ public class TbSaveToCustomCassandraTableConfiguration implements NodeConfigurat
@Override
public TbSaveToCustomCassandraTableConfiguration defaultConfiguration() {
TbSaveToCustomCassandraTableConfiguration configuration = new TbSaveToCustomCassandraTableConfiguration();
public TbSaveToCustomCassandraTableNodeConfiguration defaultConfiguration() {
TbSaveToCustomCassandraTableNodeConfiguration configuration = new TbSaveToCustomCassandraTableNodeConfiguration();
configuration.setTableName("");
Map<String, String> map = new HashMap<>();
map.put("", "");
Loading…
Cancel
Save