NIFI-7762 - support copy-paste on Disabled ports

This commit is contained in:
jmconte 2020-08-25 17:06:43 +02:00 committed by markap14
parent 87685dd4e1
commit bdead4d040
4 changed files with 19 additions and 2 deletions

View File

@ -28,4 +28,6 @@ public interface Port extends Connectable {
* Port a chance to initialize any resources needed.</p>
*/
void onSchedulingStart();
void disable();
}

View File

@ -423,6 +423,7 @@ public abstract class AbstractPort implements Port {
scheduledState.set(ScheduledState.RUNNING);
}
@Override
public void disable() {
final boolean updated = scheduledState.compareAndSet(ScheduledState.STOPPED, ScheduledState.DISABLED);
if (!updated) {

View File

@ -308,6 +308,9 @@ public class StandardFlowSnippet implements FlowSnippet {
inputPort.setProcessGroup(group);
inputPort.setMaxConcurrentTasks(portDTO.getConcurrentlySchedulableTaskCount());
inputPort.setComments(portDTO.getComments());
if (portDTO.getState().equals(ScheduledState.DISABLED.toString())) {
inputPort.disable();
}
group.addInputPort(inputPort);
}
@ -333,6 +336,9 @@ public class StandardFlowSnippet implements FlowSnippet {
outputPort.setProcessGroup(group);
outputPort.setMaxConcurrentTasks(portDTO.getConcurrentlySchedulableTaskCount());
outputPort.setComments(portDTO.getComments());
if (portDTO.getState().equals(ScheduledState.DISABLED.toString())) {
outputPort.disable();
}
group.addOutputPort(outputPort);
}

View File

@ -551,7 +551,11 @@ public final class SnippetUtils {
final PortDTO cp = dtoFactory.copy(portDTO);
cp.setId(generateId(portDTO.getId(), idGenerationSeed, isCopy));
cp.setParentGroupId(groupId);
if (portDTO.getState() != null && portDTO.getState().equals(ScheduledState.DISABLED.toString())) {
cp.setState(ScheduledState.DISABLED.toString());
} else {
cp.setState(ScheduledState.STOPPED.toString());
}
inputPorts.add(cp);
final ConnectableDTO portConnectable = dtoFactory.createConnectableDto(cp, ConnectableType.INPUT_PORT);
@ -576,7 +580,11 @@ public final class SnippetUtils {
final PortDTO cp = dtoFactory.copy(portDTO);
cp.setId(generateId(portDTO.getId(), idGenerationSeed, isCopy));
cp.setParentGroupId(groupId);
if (portDTO.getState() != null && portDTO.getState().equals(ScheduledState.DISABLED.toString())) {
cp.setState(ScheduledState.DISABLED.toString());
} else {
cp.setState(ScheduledState.STOPPED.toString());
}
outputPorts.add(cp);
final ConnectableDTO portConnectable = dtoFactory.createConnectableDto(cp, ConnectableType.OUTPUT_PORT);