if (sourceConnectableDTO.getGroupId() == null) { sourceConnectableDTO.setGroupId(groupId); if (destinationConnectableDTO.getGroupId() == null) { destinationConnectableDTO.setGroupId(groupId); if (ConnectableType.REMOTE_OUTPUT_PORT.name().equals(sourceConnectableDTO.getType())) { 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()); if (ConnectableType.REMOTE_INPUT_PORT.name().equals(destinationConnectableDTO.getType())) { 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());
public ConnectableDTO createConnectableDto(final RemoteProcessGroupPortDTO remoteGroupPort, final ConnectableType type) { final ConnectableDTO connectable = new ConnectableDTO(); connectable.setGroupId(remoteGroupPort.getGroupId()); connectable.setId(remoteGroupPort.getId()); connectable.setName(remoteGroupPort.getName()); connectable.setType(type.name()); connectable.setVersionedComponentId(connectable.getVersionedComponentId()); return connectable; }
final ConnectableDTO dto = new ConnectableDTO(); dto.setId(connectable.getIdentifier()); dto.setName(isAuthorized ? connectable.getName() : connectable.getIdentifier()); dto.setType(connectable.getConnectableType().name()); dto.setVersionedComponentId(connectable.getVersionedComponentId().orElse(null)); dto.setGroupId(remoteGroup.getIdentifier()); dto.setRunning(remoteGroupPort.isTargetRunning()); dto.setTransmitting(remoteGroupPort.isRunning()); dto.setExists(remoteGroupPort.getTargetExists()); if (isAuthorized) { dto.setComments(remoteGroup.getComments()); dto.setGroupId(connectable.getProcessGroup().getIdentifier()); dto.setRunning(connectable.isRunning()); if (isAuthorized) { dto.setComments(connectable.getComments());
/** * Remove unnecessary fields in connectables prior to saving. * * @param connectable connectable */ private static void scrubConnectable(final ConnectableDTO connectable) { if (connectable != null) { connectable.setComments(null); connectable.setExists(null); connectable.setRunning(null); connectable.setTransmitting(null); connectable.setName(null); } }
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"); if (ConnectableType.REMOTE_OUTPUT_PORT.name().equals(sourceDto.getType())) { final ProcessGroup sourceParentGroup = locateProcessGroup(flowController, groupId); final RemoteProcessGroup remoteProcessGroup = sourceParentGroup.getRemoteProcessGroup(sourceDto.getGroupId()); if (remoteProcessGroup == null) { throw new IllegalArgumentException("Unable to find the specified remote process group."); final RemoteGroupPort sourceConnectable = remoteProcessGroup.getOutputPort(sourceDto.getId()); if (sourceConnectable == null) { throw new IllegalArgumentException("The specified source for the connection does not exist"); final ProcessGroup sourceGroup = locateProcessGroup(flowController, sourceDto.getGroupId()); final Connectable sourceConnectable = sourceGroup.getConnectable(sourceDto.getId()); if (sourceConnectable == null) { throw new IllegalArgumentException("The specified source for the connection does not exist"); if (ConnectableType.REMOTE_INPUT_PORT.name().equals(destinationDto.getType())) { final ProcessGroup destinationParentGroup = locateProcessGroup(flowController, groupId); final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(destinationDto.getGroupId()); if (remoteProcessGroup == null) { throw new IllegalArgumentException("Unable to find the specified remote process group.");
.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())));
@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; } }
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));
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)); } } }
final ConnectionDTO cp = dtoFactory.copy(connectionDTO); final ConnectableDTO source = connectableMap.get(cp.getSource().getGroupId() + "-" + cp.getSource().getId()); final ConnectableDTO destination = connectableMap.get(cp.getDestination().getGroupId() + "-" + cp.getDestination().getId());
/** * Determines the type of component the specified connectable is. */ private Component determineConnectableType(ConnectableDTO connectable) { Component component = Component.Controller; final String connectableType = connectable.getType(); if (ConnectableType.PROCESSOR.name().equals(connectableType)) { component = Component.Processor; } else if (ConnectableType.INPUT_PORT.name().equals(connectableType)) { component = Component.InputPort; } else if (ConnectableType.OUTPUT_PORT.name().equals(connectableType)) { component = Component.OutputPort; } else if (ConnectableType.FUNNEL.name().equals(connectableType)) { component = Component.Funnel; } else { component = Component.RemoteProcessGroup; } return component; }
if (proposedDestination != null && ConnectableType.REMOTE_INPUT_PORT.name().equals(proposedDestination.getType())) { if (proposedDestination.getGroupId() == null) { validationErrors.add("When the destination is a remote input port its group id is required."); return validationErrors; final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(proposedDestination.getGroupId()); if (remoteProcessGroup == null) { validationErrors.add("Unable to find the specified remote process group."); final RemoteGroupPort remoteInputPort = remoteProcessGroup.getInputPort(proposedDestination.getId()); if (remoteInputPort == null) { validationErrors.add("Unable to find the specified destination.");
.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())));
@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; } }
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)); } } }
public ConnectableDTO createConnectableDto(final FunnelDTO funnel) { final ConnectableDTO connectable = new ConnectableDTO(); connectable.setGroupId(funnel.getParentGroupId()); connectable.setId(funnel.getId()); connectable.setType(ConnectableType.FUNNEL.name()); connectable.setVersionedComponentId(funnel.getVersionedComponentId()); return connectable; }
if (isNotNull(connectionDTO.getSource()) && !existingSource.getIdentifier().equals(connectionDTO.getSource().getId())) { throw new IllegalStateException("Connection with ID " + connectionDTO.getId() + " has conflicting Source ID"); if (ConnectableType.REMOTE_INPUT_PORT.name().equals(proposedDestination.getType())) { if (proposedDestination.getGroupId() == null) { throw new IllegalArgumentException("When the destination is a remote input port its group id is required."); if (currentDestination.getConnectableType() == ConnectableType.REMOTE_INPUT_PORT) { RemoteGroupPort remotePort = (RemoteGroupPort) currentDestination; if (!proposedDestination.getGroupId().equals(remotePort.getRemoteProcessGroup().getIdentifier())) { isDifferentRemoteProcessGroup = true; 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())) { if (proposedDestination.getGroupId() == null) { proposedDestination.setGroupId(group.getIdentifier()); final ProcessGroup destinationGroup = locateProcessGroup(flowController, proposedDestination.getGroupId()); newDestination = destinationGroup.getConnectable(proposedDestination.getId());
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; }
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; }