if (sourceDto == null || sourceDto.getId() == null) { throw new IllegalArgumentException("Cannot create connection without specifying source"); if (destinationDto == null || destinationDto.getId() == null) { throw new IllegalArgumentException("Cannot create connection without specifying destination"); final RemoteGroupPort sourceConnectable = remoteProcessGroup.getOutputPort(sourceDto.getId()); if (sourceConnectable == null) { throw new IllegalArgumentException("The specified source for the connection does not exist"); final Connectable sourceConnectable = sourceGroup.getConnectable(sourceDto.getId()); if (sourceConnectable == null) { throw new IllegalArgumentException("The specified source for the connection does not exist"); final RemoteGroupPort destinationConnectable = remoteProcessGroup.getInputPort(destinationDto.getId()); if (destinationConnectable == null) { throw new IllegalArgumentException("The specified destination for the connection does not exist"); final Connectable destinationConnectable = destinationGroup.getConnectable(destinationDto.getId()); if (destinationConnectable == null) { throw new IllegalArgumentException("The specified destination for the connection does not exist");
final RemoteGroupPort remoteInputPort = remoteProcessGroup.getInputPort(proposedDestination.getId()); if (remoteInputPort == null) { validationErrors.add("Unable to find the specified destination.");
if (isNotNull(connectionDTO.getSource()) && !existingSource.getIdentifier().equals(connectionDTO.getSource().getId())) { throw new IllegalStateException("Connection with ID " + connectionDTO.getId() + " has conflicting Source ID"); if (!proposedDestination.getId().equals(currentDestination.getIdentifier()) || isDifferentRemoteProcessGroup) { final ProcessGroup destinationParentGroup = locateProcessGroup(flowController, group.getIdentifier()); final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(proposedDestination.getGroupId()); final RemoteGroupPort remoteInputPort = remoteProcessGroup.getInputPort(proposedDestination.getId()); if (!proposedDestination.getId().equals(currentDestination.getIdentifier())) { newDestination = destinationGroup.getConnectable(proposedDestination.getId());
if (requestConnection.getDestination().getId() == null) { throw new IllegalArgumentException("When specifying a destination component, the destination id is required."); if (requestConnection.getDestination() != null && !currentDestination.getIdentifier().equals(requestConnection.getDestination().getId())) { try { final ConnectableType destinationConnectableType = ConnectableType.valueOf(requestConnection.getDestination().getType()); newDestinationAuthorizable = lookup.getRemoteProcessGroup(requestConnection.getDestination().getGroupId()); } else { newDestinationAuthorizable = lookup.getLocalConnectable(requestConnection.getDestination().getId());
if (requestConnection.getSource() == null || requestConnection.getSource().getId() == null) { throw new IllegalArgumentException("The source of the connection must be specified."); if (requestConnection.getDestination() == null || requestConnection.getDestination().getId() == null) { throw new IllegalArgumentException("The destination of the connection must be specified."); source = lookup.getRemoteProcessGroup(requestConnection.getSource().getGroupId()); } else { source = lookup.getLocalConnectable(requestConnection.getSource().getId()); throw new ResourceNotFoundException("Cannot find source component with ID [" + requestConnection.getSource().getId() + "]"); destination = lookup.getRemoteProcessGroup(requestConnection.getDestination().getGroupId()); } else { destination = lookup.getLocalConnectable(requestConnection.getDestination().getId()); throw new ResourceNotFoundException("Cannot find destination component with ID [" + requestConnection.getDestination().getId() + "]");
final ProcessGroup sourceParentGroup = locateProcessGroup(flowController, groupId); final RemoteProcessGroup remoteProcessGroup = sourceParentGroup.getRemoteProcessGroup(sourceConnectableDTO.getGroupId()); source = remoteProcessGroup.getOutputPort(sourceConnectableDTO.getId()); } else { final ProcessGroup sourceGroup = locateProcessGroup(flowController, sourceConnectableDTO.getGroupId()); source = sourceGroup.getConnectable(sourceConnectableDTO.getId()); final ProcessGroup destinationParentGroup = locateProcessGroup(flowController, groupId); final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(destinationConnectableDTO.getGroupId()); destination = remoteProcessGroup.getInputPort(destinationConnectableDTO.getId()); } else { final ProcessGroup destinationGroup = locateProcessGroup(flowController, destinationConnectableDTO.getGroupId()); destination = destinationGroup.getConnectable(destinationConnectableDTO.getId());
connectDetails.setSourceId(source.getId()); connectDetails.setSourceName(source.getName()); connectDetails.setSourceType(determineConnectableType(source)); connectDetails.setRelationship(relationships); connectDetails.setDestinationId(destination.getId()); connectDetails.setDestinationName(destination.getName()); connectDetails.setDestinationType(determineConnectableType(destination));
public ConnectionEntity createConnectionEntity(final ConnectionDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final ConnectionStatusDTO status) { final ConnectionEntity entity = new ConnectionEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(permissions); entity.setStatus(status); entity.setId(dto.getId()); entity.setPosition(dto.getPosition()); entity.setBends(dto.getBends()); entity.setLabelIndex(dto.getLabelIndex()); entity.setzIndex(dto.getzIndex()); entity.setSourceId(dto.getSource().getId()); entity.setSourceGroupId(dto.getSource().getGroupId()); entity.setSourceType(dto.getSource().getType()); entity.setDestinationId(dto.getDestination().getId()); entity.setDestinationGroupId(dto.getDestination().getGroupId()); entity.setDestinationType(dto.getDestination().getType()); if (permissions != null && permissions.getCanRead()) { entity.setComponent(dto); } } return entity; }
if (ConnectableType.REMOTE_OUTPUT_PORT.name().equals(sourceDto.getType())) { final RemoteProcessGroup remoteGroup = processGroup.getRemoteProcessGroup(sourceDto.getGroupId()); source = remoteGroup.getOutputPort(sourceDto.getId()); } else { final ProcessGroup sourceGroup = flowManager.getGroup(sourceDto.getGroupId()); source = sourceGroup.getConnectable(sourceDto.getId()); throw new RuntimeException("Found Invalid Connectable ID for Source: " + dto.getSource().getId()); if (ConnectableType.REMOTE_INPUT_PORT.name().equals(destinationDto.getType())) { final RemoteProcessGroup remoteGroup = processGroup.getRemoteProcessGroup(destinationDto.getGroupId()); destination = remoteGroup.getInputPort(destinationDto.getId()); } else { final ProcessGroup destinationGroup = flowManager.getGroup(destinationDto.getGroupId()); destination = destinationGroup.getConnectable(destinationDto.getId()); throw new RuntimeException("Found Invalid Connectable ID for Destination: " + dto.getDestination().getId());
source = remoteGroup.getOutputPort(sourceDTO.getId()); } else { final ProcessGroup sourceGroup = getConnectableParent(group, sourceDTO.getGroupId(), flowManager); source = sourceGroup.getConnectable(sourceDTO.getId()); destination = remoteGroup.getInputPort(destinationDTO.getId()); } else { final ProcessGroup destinationGroup = getConnectableParent(group, destinationDTO.getGroupId(), flowManager); destination = destinationGroup.getConnectable(destinationDTO.getId());
private static String determineValueForConnectable(ConnectableDTO connectable, Map<String, String> idOverrideMap) { String connectionName = ""; if (connectable != null) { connectionName = connectable.getName(); // If no name is specified, determine the appropriate id to use, preferring any overrides specified if (StringUtils.isBlank(connectionName)) { connectionName = idOverrideMap.containsKey(connectable.getId()) ? idOverrideMap.get(connectable.getId()) : connectable.getId(); } } return connectionName; }
private static String determineValueForConnectable(ConnectableDTO connectable, Map<String, String> idOverrideMap) { String connectionName = ""; if (connectable != null) { connectionName = connectable.getName(); // If no name is specified, determine the appropriate id to use, preferring any overrides specified if (StringUtils.isBlank(connectionName)) { connectionName = idOverrideMap.containsKey(connectable.getId()) ? idOverrideMap.get(connectable.getId()) : connectable.getId(); } } return connectionName; }
private static void setName(Map<String, String> connectableNameMap, ConnectableDTO connectableDTO, Map<String, String> nameOverrides) { if (connectableDTO != null) { final String name = connectableNameMap.get(connectableDTO.getId()); if (name != null) { connectableDTO.setName(Optional.ofNullable(nameOverrides.get(connectableDTO.getId())).orElse(name)); } } }
private static void setName(Map<String, String> connectableNameMap, ConnectableDTO connectableDTO, Map<String, String> nameOverrides) { if (connectableDTO != null) { final String name = connectableNameMap.get(connectableDTO.getId()); if (name != null) { connectableDTO.setName(Optional.ofNullable(nameOverrides.get(connectableDTO.getId())).orElse(name)); } } }
@Override public ConnectionSchema apply(ConnectionDTO connectionDTO) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, connectionDTO.getId()); map.put(NAME_KEY, connectionDTO.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, connectionDTO.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(connectionDTO.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, connectionDTO.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, connectionDTO.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, connectionDTO.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, connectionDTO.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(connectionDTO.getPrioritizers()); if (queuePrioritizers.size() > 0) { map.put(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizers.get(0)); } ConnectionSchema connectionSchema = new ConnectionSchema(map); if (ConnectableType.FUNNEL.name().equals(connectionDTO.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + connectionDTO.getName() + " has type " + ConnectableType.FUNNEL.name() + " which is not supported by MiNiFi"); } if (queuePrioritizers.size() > 1) { connectionSchema.addValidationIssue(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, CONNECTIONS_KEY, " has more than one queue prioritizer"); } return connectionSchema; } }
@Override public ConnectionSchema apply(ConnectionDTO connectionDTO) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, connectionDTO.getId()); map.put(NAME_KEY, connectionDTO.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, connectionDTO.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(connectionDTO.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, connectionDTO.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, connectionDTO.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, connectionDTO.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, connectionDTO.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(connectionDTO.getPrioritizers()); if (queuePrioritizers.size() > 0) { map.put(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizers.get(0)); } ConnectionSchema connectionSchema = new ConnectionSchema(map); if (ConnectableType.FUNNEL.name().equals(connectionDTO.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + connectionDTO.getName() + " has type " + ConnectableType.FUNNEL.name() + " which is not supported by MiNiFi"); } if (queuePrioritizers.size() > 1) { connectionSchema.addValidationIssue(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, CONNECTIONS_KEY, " has more than one queue prioritizer"); } return connectionSchema; } }
.flatMap(connectionDTO -> Stream.of(connectionDTO.getSource(), connectionDTO.getDestination())) .filter(connectable -> connectable.getType().equals(ConnectableType.REMOTE_OUTPUT_PORT.toString()) || connectable.getType().equals(ConnectableType.REMOTE_INPUT_PORT.toString())) .forEach(connectable -> connectable.setId(Optional.ofNullable(rpgIdToTargetIdMap.get(connectable.getId())).orElse(connectable.getId())));
.flatMap(connectionDTO -> Stream.of(connectionDTO.getSource(), connectionDTO.getDestination())) .filter(connectable -> connectable.getType().equals(ConnectableType.REMOTE_OUTPUT_PORT.toString()) || connectable.getType().equals(ConnectableType.REMOTE_INPUT_PORT.toString())) .forEach(connectable -> connectable.setId(Optional.ofNullable(rpgIdToTargetIdMap.get(connectable.getId())).orElse(connectable.getId())));