Merge branch 'master' of github.com:thingsboard/thingsboard
This commit is contained in:
commit
66a453749e
@ -103,6 +103,7 @@ public class AlarmController extends BaseController {
|
||||
checkParameter(ALARM_ID, strAlarmId);
|
||||
try {
|
||||
AlarmId alarmId = new AlarmId(toUUID(strAlarmId));
|
||||
checkAlarmId(alarmId, Operation.WRITE);
|
||||
return alarmService.deleteAlarm(getTenantId(), alarmId);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
|
||||
@ -131,9 +131,9 @@ public abstract class TbAbstractRelationActionNode<C extends TbAbstractRelationA
|
||||
|
||||
protected ListenableFuture<List<EntityRelation>> processListSearchDirection(TbContext ctx, TbMsg msg) {
|
||||
if (EntitySearchDirection.FROM.name().equals(this.config.getDirection())) {
|
||||
return ctx.getRelationService().findByToAndTypeAsync(ctx.getTenantId(), msg.getOriginator(), processPattern(msg, this.config.getRelationTypePattern()), RelationTypeGroup.COMMON);
|
||||
return ctx.getRelationService().findByToAndTypeAsync(ctx.getTenantId(), msg.getOriginator(), processPattern(msg, this.config.getRelationType()), RelationTypeGroup.COMMON);
|
||||
} else {
|
||||
return ctx.getRelationService().findByFromAndTypeAsync(ctx.getTenantId(), msg.getOriginator(), processPattern(msg, this.config.getRelationTypePattern()), RelationTypeGroup.COMMON);
|
||||
return ctx.getRelationService().findByFromAndTypeAsync(ctx.getTenantId(), msg.getOriginator(), processPattern(msg, this.config.getRelationType()), RelationTypeGroup.COMMON);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import lombok.Data;
|
||||
public abstract class TbAbstractRelationActionNodeConfiguration {
|
||||
|
||||
private String direction;
|
||||
private String relationTypePattern;
|
||||
private String relationType;
|
||||
|
||||
private String entityType;
|
||||
private String entityNamePattern;
|
||||
|
||||
@ -69,8 +69,7 @@ public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConf
|
||||
msgAlarm = null;
|
||||
} else {
|
||||
try {
|
||||
msgAlarm = mapper.readValue(msg.getData(), Alarm.class);
|
||||
msgAlarm.setTenantId(ctx.getTenantId());
|
||||
msgAlarm = getAlarmFromMessage(ctx, msg);
|
||||
alarmType = msgAlarm.getType();
|
||||
} catch (IOException e) {
|
||||
ctx.tellFailure(msg, e);
|
||||
@ -89,6 +88,19 @@ public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConf
|
||||
|
||||
}
|
||||
|
||||
private Alarm getAlarmFromMessage(TbContext ctx, TbMsg msg) throws IOException {
|
||||
Alarm msgAlarm;
|
||||
msgAlarm = mapper.readValue(msg.getData(), Alarm.class);
|
||||
msgAlarm.setTenantId(ctx.getTenantId());
|
||||
if (msgAlarm.getOriginator() == null) {
|
||||
msgAlarm.setOriginator(msg.getOriginator());
|
||||
}
|
||||
if (msgAlarm.getStatus() == null) {
|
||||
msgAlarm.setStatus(AlarmStatus.ACTIVE_UNACK);
|
||||
}
|
||||
return msgAlarm;
|
||||
}
|
||||
|
||||
private ListenableFuture<AlarmResult> createNewAlarm(TbContext ctx, TbMsg msg, Alarm msgAlarm) {
|
||||
ListenableFuture<Alarm> asyncAlarm;
|
||||
if (msgAlarm != null ) {
|
||||
|
||||
@ -85,7 +85,7 @@ public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateR
|
||||
}
|
||||
|
||||
private ListenableFuture<Boolean> createIfAbsent(TbContext ctx, TbMsg msg, EntityContainer entityContainer) {
|
||||
relationType = processPattern(msg, config.getRelationTypePattern());
|
||||
relationType = processPattern(msg, config.getRelationType());
|
||||
SearchDirectionIds sdId = processSingleSearchDirection(msg, entityContainer);
|
||||
ListenableFuture<Boolean> checkRelationFuture = Futures.transformAsync(ctx.getRelationService().checkRelation(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), relationType, RelationTypeGroup.COMMON), result -> {
|
||||
if (!result) {
|
||||
|
||||
@ -30,7 +30,7 @@ public class TbCreateRelationNodeConfiguration extends TbAbstractRelationActionN
|
||||
public TbCreateRelationNodeConfiguration defaultConfiguration() {
|
||||
TbCreateRelationNodeConfiguration configuration = new TbCreateRelationNodeConfiguration();
|
||||
configuration.setDirection(EntitySearchDirection.FROM.name());
|
||||
configuration.setRelationTypePattern("Contains");
|
||||
configuration.setRelationType("Contains");
|
||||
configuration.setEntityNamePattern("");
|
||||
configuration.setEntityCacheExpiration(300);
|
||||
configuration.setCreateEntityIfNotExists(false);
|
||||
|
||||
@ -70,7 +70,7 @@ public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteR
|
||||
}
|
||||
|
||||
private ListenableFuture<RelationContainer> getRelationContainerListenableFuture(TbContext ctx, TbMsg msg) {
|
||||
relationType = processPattern(msg, config.getRelationTypePattern());
|
||||
relationType = processPattern(msg, config.getRelationType());
|
||||
if (config.isDeleteForSingleEntity()) {
|
||||
return Futures.transformAsync(getEntity(ctx, msg), entityContainer -> doProcessEntityRelationAction(ctx, msg, entityContainer));
|
||||
} else {
|
||||
|
||||
@ -29,7 +29,7 @@ public class TbDeleteRelationNodeConfiguration extends TbAbstractRelationActionN
|
||||
TbDeleteRelationNodeConfiguration configuration = new TbDeleteRelationNodeConfiguration();
|
||||
configuration.setDeleteForSingleEntity(true);
|
||||
configuration.setDirection(EntitySearchDirection.FROM.name());
|
||||
configuration.setRelationTypePattern("Contains");
|
||||
configuration.setRelationType("Contains");
|
||||
configuration.setEntityNamePattern("");
|
||||
configuration.setEntityCacheExpiration(300);
|
||||
return configuration;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user