public static boolean isAddedOrRemovedRemotePort(final FlowDifference fd) { if (fd.getDifferenceType() == DifferenceType.COMPONENT_ADDED || fd.getDifferenceType() == DifferenceType.COMPONENT_REMOVED) { VersionedComponent component = fd.getComponentA(); if (component == null || fd.getComponentB() instanceof InstantiatedVersionedComponent) { component = fd.getComponentB(); } if (component.getComponentType() == ComponentType.REMOTE_INPUT_PORT || component.getComponentType() == ComponentType.REMOTE_OUTPUT_PORT) { return true; } } return false; }
if (ComponentType.CONTROLLER_SERVICE == component.getComponentType()) { final ControllerServiceNode serviceNode = getVersionedControllerService(this, component.getIdentifier()); if (serviceNode != null) { updatedVersionedComponentIds.add(component.getIdentifier()); if (component.getComponentType() == ComponentType.REMOTE_INPUT_PORT || component.getComponentType() == ComponentType.REMOTE_OUTPUT_PORT) { final String remoteGroupId = ((VersionedRemoteGroupPort) component).getRemoteGroupId(); updatedVersionedComponentIds.add(remoteGroupId);
switch (localComponent.getComponentType()) { case CONTROLLER_SERVICE: final String serviceId = ((InstantiatedVersionedControllerService) localComponent).getInstanceId(); return createAffectedComponentEntity((InstantiatedVersionedComponent) localComponent, localComponent.getComponentType().name(), state); }) .collect(Collectors.toCollection(HashSet::new)); if (difference.getDifferenceType() == DifferenceType.COMPONENT_REMOVED && localComponent.getComponentType() == org.apache.nifi.registry.flow.ComponentType.PROCESS_GROUP) { final String localGroupId = ((InstantiatedVersionedProcessGroup) localComponent).getInstanceId(); final ProcessGroup localGroup = processGroupDAO.getProcessGroup(localGroupId); if (localComponent.getComponentType() == org.apache.nifi.registry.flow.ComponentType.CONTROLLER_SERVICE) { final String serviceId = ((InstantiatedVersionedControllerService) localComponent).getInstanceId(); final ControllerServiceNode serviceNode = controllerServiceDAO.getControllerService(serviceId); if (component.getComponentType() != org.apache.nifi.registry.flow.ComponentType.CONNECTION) { continue;
private ComponentDifferenceDTO createComponentDifference(final FlowDifference difference) { VersionedComponent component = difference.getComponentA(); if (component == null || difference.getComponentB() instanceof InstantiatedVersionedComponent) { component = difference.getComponentB(); } final ComponentDifferenceDTO dto = new ComponentDifferenceDTO(); dto.setComponentName(component.getName()); dto.setComponentType(component.getComponentType().toString()); if (component instanceof InstantiatedVersionedComponent) { final InstantiatedVersionedComponent instantiatedComponent = (InstantiatedVersionedComponent) component; dto.setComponentId(instantiatedComponent.getInstanceId()); dto.setProcessGroupId(instantiatedComponent.getInstanceGroupId()); } else { dto.setComponentId(component.getIdentifier()); dto.setProcessGroupId(dto.getProcessGroupId()); } return dto; }
@Override public String describeDifference(final DifferenceType type, final String flowAName, final String flowBName, final VersionedComponent componentA, final VersionedComponent componentB, final String fieldName, final Object valueA, final Object valueB) { final String description; switch (type) { case COMPONENT_ADDED: description = String.format("%s with ID %s was added to flow", componentB.getComponentType().getTypeName(), componentB.getIdentifier()); break; case COMPONENT_REMOVED: description = String.format("%s with ID %s was removed from flow", componentA.getComponentType().getTypeName(), componentA.getIdentifier()); break; case PROPERTY_ADDED: description = String.format("Property '%s' was added to %s with ID %s", fieldName, componentB.getComponentType().getTypeName(), componentB.getIdentifier()); break; case PROPERTY_REMOVED: description = String.format("Property '%s' was removed from %s with ID %s", fieldName, componentA.getComponentType().getTypeName(), componentA.getIdentifier()); break; case VARIABLE_ADDED: description = String.format("Variable '%s' was added to Process Group with ID %s", fieldName, componentB.getIdentifier()); break; case VARIABLE_REMOVED: description = String.format("Variable '%s' was removed from Process Group with ID %s", fieldName, componentA.getIdentifier()); break; default: description = String.format("%s for %s with ID %s from '%s' to '%s'", type.getDescription(), componentA.getComponentType().getTypeName(), componentA.getIdentifier(), valueA, valueB); break; } return description; }
switch (type) { case COMPONENT_ADDED: description = String.format("%s was added", componentB.getComponentType().getTypeName()); break; case COMPONENT_REMOVED: description = String.format("%s was removed", componentA.getComponentType().getTypeName()); break; case PROPERTY_ADDED:
case COMPONENT_ADDED: description = String.format("%s with ID %s exists in %s but not in %s", componentB.getComponentType().getTypeName(), componentB.getIdentifier(), flowBName, flowAName); break; case COMPONENT_REMOVED: description = String.format("%s with ID %s exists in %s but not in %s", componentA.getComponentType().getTypeName(), componentA.getIdentifier(), flowAName, flowBName); break; case PROPERTY_ADDED: description = String.format("Property '%s' exists for %s with ID %s in %s but not in %s", fieldName, componentB.getComponentType().getTypeName(), componentB.getIdentifier(), flowBName, flowAName); break; case PROPERTY_REMOVED: description = String.format("Property '%s' exists for %s with ID %s in %s but not in %s", fieldName, componentA.getComponentType().getTypeName(), componentA.getIdentifier(), flowAName, flowBName); break; case VARIABLE_ADDED: type.getDescription(), componentA.getComponentType().getTypeName(), componentA.getIdentifier(), flowAName, valueA, flowBName, valueB); break; default: description = String.format("%s for %s with ID %s; flow '%s' has value %s; flow '%s' has value %s", type.getDescription(), componentA.getComponentType().getTypeName(), componentA.getIdentifier(), flowAName, valueA, flowBName, valueB); break;
public static ComponentDifferenceGroup map(VersionedComponent versionedComponent){ ComponentDifferenceGroup grouping = new ComponentDifferenceGroup(); grouping.setComponentId(versionedComponent.getIdentifier()); grouping.setComponentName(versionedComponent.getName()); grouping.setProcessGroupId(versionedComponent.getGroupIdentifier()); grouping.setComponentType(versionedComponent.getComponentType().getTypeName()); return grouping; }