mirror of https://github.com/apache/nifi.git
NIFI-1198: - Updating the connection source and destination when appropriate (deletion and (re)connection).
Signed-off-by: joewitt <joewitt@apache.org>
This commit is contained in:
parent
e1742c5a04
commit
0435911186
|
@ -768,34 +768,8 @@ nf.Actions = (function () {
|
||||||
// remove the component/connection in question
|
// remove the component/connection in question
|
||||||
nf[selectionData.type].remove(selectionData.component.id);
|
nf[selectionData.type].remove(selectionData.component.id);
|
||||||
|
|
||||||
// if the source processor is part of the response, we
|
// if the selection is a connection, reload the source and destination accordingly
|
||||||
// have just removed a relationship. must update the status
|
if (nf.CanvasUtils.isConnection(selection) === false) {
|
||||||
// of the source processor in case its validity has changed
|
|
||||||
if (nf.CanvasUtils.isConnection(selection)) {
|
|
||||||
var sourceComponentId = nf.CanvasUtils.getConnectionSourceComponentId(selectionData.component);
|
|
||||||
var source = d3.select('#id-' + sourceComponentId);
|
|
||||||
var sourceData = source.datum();
|
|
||||||
|
|
||||||
// update the source status if necessary
|
|
||||||
if (nf.CanvasUtils.isProcessor(source)) {
|
|
||||||
nf.Processor.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isInputPort(source)) {
|
|
||||||
nf.Port.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isRemoteProcessGroup(source)) {
|
|
||||||
nf.RemoteProcessGroup.reload(sourceData.component);
|
|
||||||
}
|
|
||||||
|
|
||||||
var destinationComponentId = nf.CanvasUtils.getConnectionDestinationComponentId(selectionData.component);
|
|
||||||
var destination = d3.select('#id-' + destinationComponentId);
|
|
||||||
var destinationData = destination.datum();
|
|
||||||
|
|
||||||
// update the destination component accordingly
|
|
||||||
if (nf.CanvasUtils.isProcessor(destination)) {
|
|
||||||
nf.Processor.reload(destinationData.component);
|
|
||||||
} else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
|
|
||||||
nf.RemoteProcessGroup.reload(destinationData.component);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var connections = nf.Connection.getComponentConnections(selectionData.component.id);
|
var connections = nf.Connection.getComponentConnections(selectionData.component.id);
|
||||||
if (connections.length > 0) {
|
if (connections.length > 0) {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
|
@ -846,40 +820,16 @@ nf.Actions = (function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// refresh all component types as necessary (handle components that have been removed)
|
// remove all the non connections in the snippet first
|
||||||
components.forEach(function (type, ids) {
|
components.forEach(function (type, ids) {
|
||||||
|
if (type !== 'Connection') {
|
||||||
nf[type].remove(ids);
|
nf[type].remove(ids);
|
||||||
});
|
|
||||||
|
|
||||||
// if some connections were removed
|
|
||||||
if (snippet.connections > 0) {
|
|
||||||
selection.filter(function (d) {
|
|
||||||
return d.type === 'Connection';
|
|
||||||
}).each(function (d) {
|
|
||||||
// add the source to refresh if its not already going to be refreshed
|
|
||||||
var sourceComponentId = nf.CanvasUtils.getConnectionSourceComponentId(d.component);
|
|
||||||
var source = d3.select('#id-' + sourceComponentId);
|
|
||||||
var sourceData = source.datum();
|
|
||||||
|
|
||||||
// update the source status if necessary - if the source was already removed
|
|
||||||
// as part of this operation the reloading has no affect
|
|
||||||
if (nf.CanvasUtils.isProcessor(source)) {
|
|
||||||
nf.Processor.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isInputPort(source)) {
|
|
||||||
nf.Port.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isRemoteProcessGroup(source)) {
|
|
||||||
nf.RemoteProcessGroup.reload(sourceData.component);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the destination to refresh if its not already going to be refreshed
|
|
||||||
var destinationComponentId = nf.CanvasUtils.getConnectionDestinationComponentId(d.component);
|
|
||||||
var destination = d3.select('#id-' + destinationComponentId);
|
|
||||||
var destinationData = destination.datum();
|
|
||||||
|
|
||||||
if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
|
|
||||||
nf.RemoteProcessGroup.reload(destinationData.component);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// then remove all the connections
|
||||||
|
if (components.has('Connection')) {
|
||||||
|
nf.Connection.remove(components.get('Connection'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh the birdseye/toolbar
|
// refresh the birdseye/toolbar
|
||||||
|
|
|
@ -955,6 +955,44 @@ nf.CanvasUtils = (function () {
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads a connection's source and destination.
|
||||||
|
*
|
||||||
|
* @param {string} sourceComponentId The connection source id
|
||||||
|
* @param {string} destinationComponentId The connection destination id
|
||||||
|
*/
|
||||||
|
reloadConnectionSourceAndDestination: function (sourceComponentId, destinationComponentId) {
|
||||||
|
if (nf.Common.isBlank(sourceComponentId) === false) {
|
||||||
|
var source = d3.select('#id-' + sourceComponentId);
|
||||||
|
if (source.empty() === false) {
|
||||||
|
var sourceData = source.datum();
|
||||||
|
|
||||||
|
// update the source status if necessary
|
||||||
|
if (nf.CanvasUtils.isProcessor(source)) {
|
||||||
|
nf.Processor.reload(sourceData.component);
|
||||||
|
} else if (nf.CanvasUtils.isInputPort(source)) {
|
||||||
|
nf.Port.reload(sourceData.component);
|
||||||
|
} else if (nf.CanvasUtils.isRemoteProcessGroup(source)) {
|
||||||
|
nf.RemoteProcessGroup.reload(sourceData.component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf.Common.isBlank(destinationComponentId) === false) {
|
||||||
|
var destination = d3.select('#id-' + destinationComponentId);
|
||||||
|
if (destination.empty() === false) {
|
||||||
|
var destinationData = destination.datum();
|
||||||
|
|
||||||
|
// update the destination component accordingly
|
||||||
|
if (nf.CanvasUtils.isProcessor(destination)) {
|
||||||
|
nf.Processor.reload(destinationData.component);
|
||||||
|
} else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
|
||||||
|
nf.RemoteProcessGroup.reload(destinationData.component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the component id of the source of this processor. If the connection is attached
|
* Returns the component id of the source of this processor. If the connection is attached
|
||||||
* to a port in a [sub|remote] group, the component id will be that of the group. Otherwise
|
* to a port in a [sub|remote] group, the component id will be that of the group. Otherwise
|
||||||
|
|
|
@ -860,21 +860,8 @@ nf.ConnectionConfiguration = (function () {
|
||||||
'connections': [response.connection]
|
'connections': [response.connection]
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// update the source component accordingly
|
// reload the connections source/destination components
|
||||||
if (nf.CanvasUtils.isProcessor(source)) {
|
nf.CanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
|
||||||
nf.Processor.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isInputPort(source)) {
|
|
||||||
nf.Port.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isRemoteProcessGroup(source)) {
|
|
||||||
nf.RemoteProcessGroup.reload(sourceData.component);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the destination component accordingly
|
|
||||||
if (nf.CanvasUtils.isProcessor(destination)) {
|
|
||||||
nf.Processor.reload(destinationData.component);
|
|
||||||
} else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
|
|
||||||
nf.RemoteProcessGroup.reload(destinationData.component);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update component visibility
|
// update component visibility
|
||||||
nf.Canvas.View.updateVisibility();
|
nf.Canvas.View.updateVisibility();
|
||||||
|
@ -899,13 +886,10 @@ nf.ConnectionConfiguration = (function () {
|
||||||
|
|
||||||
// get the source details
|
// get the source details
|
||||||
var sourceComponentId = $('#connection-source-component-id').val();
|
var sourceComponentId = $('#connection-source-component-id').val();
|
||||||
var source = d3.select('#id-' + sourceComponentId);
|
|
||||||
var sourceData = source.datum();
|
|
||||||
|
|
||||||
// get the destination details
|
// get the destination details
|
||||||
var destinationComponentId = $('#connection-destination-component-id').val();
|
var destinationComponentId = $('#connection-destination-component-id').val();
|
||||||
var destination = d3.select('#id-' + destinationComponentId);
|
var destination = d3.select('#id-' + destinationComponentId);
|
||||||
var destinationData = destination.datum();
|
|
||||||
var destinationType = nf.CanvasUtils.getConnectableTypeForDestination(destination);
|
var destinationType = nf.CanvasUtils.getConnectableTypeForDestination(destination);
|
||||||
|
|
||||||
// get the destination details
|
// get the destination details
|
||||||
|
@ -950,21 +934,8 @@ nf.ConnectionConfiguration = (function () {
|
||||||
// update this connection
|
// update this connection
|
||||||
nf.Connection.set(connection);
|
nf.Connection.set(connection);
|
||||||
|
|
||||||
// update the source component accordingly
|
// reload the connections source/destination components
|
||||||
if (nf.CanvasUtils.isProcessor(source)) {
|
nf.CanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
|
||||||
nf.Processor.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isInputPort(source)) {
|
|
||||||
nf.Port.reload(sourceData.component);
|
|
||||||
} else if (nf.CanvasUtils.isRemoteProcessGroup(source)) {
|
|
||||||
nf.RemoteProcessGroup.reload(sourceData.component);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the destination component accordingly
|
|
||||||
if (nf.CanvasUtils.isProcessor(destination)) {
|
|
||||||
nf.Processor.reload(destinationData.component);
|
|
||||||
} else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
|
|
||||||
nf.RemoteProcessGroup.reload(destinationData.component);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).fail(function (xhr, status, error) {
|
}).fail(function (xhr, status, error) {
|
||||||
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
||||||
|
|
|
@ -1033,6 +1033,12 @@ nf.Connection = (function () {
|
||||||
|
|
||||||
// removes the specified connections
|
// removes the specified connections
|
||||||
var removeConnections = function (removed) {
|
var removeConnections = function (removed) {
|
||||||
|
// consider reloading source/destination of connection being removed
|
||||||
|
removed.each(function (d) {
|
||||||
|
nf.CanvasUtils.reloadConnectionSourceAndDestination(d.component.source.id, d.component.destination.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove the connection
|
||||||
removed.remove();
|
removed.remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1142,6 +1148,7 @@ nf.Connection = (function () {
|
||||||
// get the corresponding connection
|
// get the corresponding connection
|
||||||
var connection = d3.select(this.parentNode);
|
var connection = d3.select(this.parentNode);
|
||||||
var connectionData = connection.datum();
|
var connectionData = connection.datum();
|
||||||
|
var previousDestinationId = connectionData.component.destination.id;
|
||||||
|
|
||||||
// attempt to select a new destination
|
// attempt to select a new destination
|
||||||
var destination = d3.select('g.connectable-destination');
|
var destination = d3.select('g.connectable-destination');
|
||||||
|
@ -1153,7 +1160,10 @@ nf.Connection = (function () {
|
||||||
// prompt for the new port if appropriate
|
// prompt for the new port if appropriate
|
||||||
if (nf.CanvasUtils.isProcessGroup(destination) || nf.CanvasUtils.isRemoteProcessGroup(destination)) {
|
if (nf.CanvasUtils.isProcessGroup(destination) || nf.CanvasUtils.isRemoteProcessGroup(destination)) {
|
||||||
// user will select new port and updated connect details will be set accordingly
|
// user will select new port and updated connect details will be set accordingly
|
||||||
nf.ConnectionConfiguration.showConfiguration(connection, destination).fail(function () {
|
nf.ConnectionConfiguration.showConfiguration(connection, destination).done(function () {
|
||||||
|
// reload the previous destination
|
||||||
|
nf.CanvasUtils.reloadConnectionSourceAndDestination(null, previousDestinationId);
|
||||||
|
}).fail(function () {
|
||||||
// reset the connection
|
// reset the connection
|
||||||
connection.call(updateConnections, true, false);
|
connection.call(updateConnections, true, false);
|
||||||
});
|
});
|
||||||
|
@ -1192,13 +1202,17 @@ nf.Connection = (function () {
|
||||||
data: updatedConnectionData,
|
data: updatedConnectionData,
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
}).done(function (response) {
|
}).done(function (response) {
|
||||||
var connectionData = response.connection;
|
var updatedConnectionData = response.connection;
|
||||||
|
|
||||||
// update the revision
|
// update the revision
|
||||||
nf.Client.setRevision(response.revision);
|
nf.Client.setRevision(response.revision);
|
||||||
|
|
||||||
// refresh to update the label
|
// refresh to update the label
|
||||||
nf.Connection.set(connectionData);
|
nf.Connection.set(updatedConnectionData);
|
||||||
|
|
||||||
|
// reload the previous destination and the new source/destination
|
||||||
|
nf.CanvasUtils.reloadConnectionSourceAndDestination(null, previousDestinationId);
|
||||||
|
nf.CanvasUtils.reloadConnectionSourceAndDestination(updatedConnectionData.source.id, updatedConnectionData.destination.id);
|
||||||
}).fail(function (xhr, status, error) {
|
}).fail(function (xhr, status, error) {
|
||||||
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
||||||
nf.Dialog.showOkDialog({
|
nf.Dialog.showOkDialog({
|
||||||
|
|
Loading…
Reference in New Issue