|
|
@ -47,6 +47,8 @@ import java.util.List; |
|
|
) |
|
|
) |
|
|
public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteRelationNodeConfiguration> { |
|
|
public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteRelationNodeConfiguration> { |
|
|
|
|
|
|
|
|
|
|
|
private String relationType; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected TbDeleteRelationNodeConfiguration loadEntityNodeActionConfig(TbNodeConfiguration configuration) throws TbNodeException { |
|
|
protected TbDeleteRelationNodeConfiguration loadEntityNodeActionConfig(TbNodeConfiguration configuration) throws TbNodeException { |
|
|
return TbNodeUtils.convert(configuration, TbDeleteRelationNodeConfiguration.class); |
|
|
return TbNodeUtils.convert(configuration, TbDeleteRelationNodeConfiguration.class); |
|
|
@ -62,19 +64,19 @@ public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteR |
|
|
return getRelationContainerListenableFuture(ctx, msg); |
|
|
return getRelationContainerListenableFuture(ctx, msg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entityContainer) { |
|
|
|
|
|
return Futures.transform(processSingle(ctx, msg, entityContainer), result -> new RelationContainer(msg, result)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private ListenableFuture<RelationContainer> getRelationContainerListenableFuture(TbContext ctx, TbMsg msg) { |
|
|
private ListenableFuture<RelationContainer> getRelationContainerListenableFuture(TbContext ctx, TbMsg msg) { |
|
|
|
|
|
relationType = processPattern(msg, config.getRelationTypePattern()); |
|
|
if (config.isDeleteForSingleEntity()) { |
|
|
if (config.isDeleteForSingleEntity()) { |
|
|
return Futures.transformAsync(getEntity(ctx, msg), entityContainer -> doProcessEntityRelationAction(ctx, msg, entityContainer)); |
|
|
return Futures.transformAsync(getEntity(ctx, msg), entityContainer -> doProcessEntityRelationAction(ctx, msg, entityContainer)); |
|
|
} else { |
|
|
} else { |
|
|
return Futures.transform(processList(ctx, msg), result -> new RelationContainer(msg, result)); |
|
|
return Futures.transform(processList(ctx, msg), result -> new RelationContainer(msg, result)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entityContainer) { |
|
|
|
|
|
return Futures.transform(processSingle(ctx, msg, entityContainer), result -> new RelationContainer(msg, result)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ListenableFuture<Boolean> processList(TbContext ctx, TbMsg msg) { |
|
|
private ListenableFuture<Boolean> processList(TbContext ctx, TbMsg msg) { |
|
|
return Futures.transformAsync(processListSearchDirection(ctx, msg), entityRelations -> { |
|
|
return Futures.transformAsync(processListSearchDirection(ctx, msg), entityRelations -> { |
|
|
if (entityRelations.isEmpty()) { |
|
|
if (entityRelations.isEmpty()) { |
|
|
@ -98,8 +100,7 @@ public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteR |
|
|
|
|
|
|
|
|
private ListenableFuture<Boolean> processSingle(TbContext ctx, TbMsg msg, EntityContainer entityContainer) { |
|
|
private ListenableFuture<Boolean> processSingle(TbContext ctx, TbMsg msg, EntityContainer entityContainer) { |
|
|
SearchDirectionIds sdId = processSingleSearchDirection(msg, entityContainer); |
|
|
SearchDirectionIds sdId = processSingleSearchDirection(msg, entityContainer); |
|
|
return Futures.transformAsync(ctx.getRelationService().checkRelation(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), config.getRelationType(), RelationTypeGroup.COMMON), |
|
|
return Futures.transformAsync(ctx.getRelationService().checkRelation(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), relationType, RelationTypeGroup.COMMON), |
|
|
|
|
|
|
|
|
result -> { |
|
|
result -> { |
|
|
if (result) { |
|
|
if (result) { |
|
|
return processSingleDeleteRelation(ctx, sdId); |
|
|
return processSingleDeleteRelation(ctx, sdId); |
|
|
@ -109,7 +110,7 @@ public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteR |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ListenableFuture<Boolean> processSingleDeleteRelation(TbContext ctx, SearchDirectionIds sdId) { |
|
|
private ListenableFuture<Boolean> processSingleDeleteRelation(TbContext ctx, SearchDirectionIds sdId) { |
|
|
return ctx.getRelationService().deleteRelationAsync(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), config.getRelationType(), RelationTypeGroup.COMMON); |
|
|
return ctx.getRelationService().deleteRelationAsync(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), relationType, RelationTypeGroup.COMMON); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|