final VersionedComponent component = diff.getComponentA() == null ? diff.getComponentB() : diff.getComponentA(); if (ComponentType.CONTROLLER_SERVICE == component.getComponentType()) { final ControllerServiceNode serviceNode = getVersionedControllerService(this, component.getIdentifier()); if (serviceNode != null) { final VersionedControllerService versionedService = mapper.mapControllerService(serviceNode, controllerServiceProvider); updatedVersionedComponentIds.add(component.getIdentifier()); updatedVersionedComponentIds.add(component.getIdentifier());
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; }
private static String getValueDescription(Object valueA){ if(valueA instanceof VersionedComponent){ return ((VersionedComponent) valueA).getIdentifier(); } if(valueA!= null){ return valueA.toString(); } return null; }
@Override public int hashCode() { return 31 + 17 * (componentA == null ? 0 : componentA.getIdentifier().hashCode()) + 17 * (componentB == null ? 0 : componentB.getIdentifier().hashCode()) + Objects.hash(description, type, valueA, valueB); }
@Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof StandardFlowDifference)) { return false; } final StandardFlowDifference other = (StandardFlowDifference) obj; final String componentAId = componentA == null ? null : componentA.getIdentifier(); final String otherComponentAId = other.componentA == null ? null : other.componentA.getIdentifier(); final String componentBId = componentB == null ? null : componentB.getIdentifier(); final String otherComponentBId = other.componentB == null ? null : other.componentB.getIdentifier(); return Objects.equals(componentAId, otherComponentAId) && Objects.equals(componentBId, otherComponentBId) && Objects.equals(description, other.description) && Objects.equals(type, other.type) && Objects.equals(valueA, other.valueA) && Objects.equals(valueB, other.valueB); } }
/** * Group the differences in the comparison by component * @param flowDifferences The differences to group together by component * @return A set of componentDifferenceGroups where each entry contains a set of differences specific to that group */ private Set<ComponentDifferenceGroup> getStringComponentDifferenceGroupMap(Set<FlowDifference> flowDifferences) { Map<String, ComponentDifferenceGroup> differenceGroups = new HashMap<>(); for (FlowDifference diff : flowDifferences) { ComponentDifferenceGroup group; // A component may only exist on only one version for new/removed components VersionedComponent component = ObjectUtils.firstNonNull(diff.getComponentA(), diff.getComponentB()); if(differenceGroups.containsKey(component.getIdentifier())){ group = differenceGroups.get(component.getIdentifier()); }else{ group = DataModelMapper.map(component); differenceGroups.put(component.getIdentifier(), group); } group.getDifferences().add(DataModelMapper.map(diff)); } return differenceGroups.values().stream().collect(Collectors.toSet()); }
@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; }
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: description = String.format("Variable '%s' exists for Process Group with ID %s in %s but not in %s", fieldName, componentB.getIdentifier(), flowBName, flowAName); break; case VARIABLE_REMOVED: description = String.format("Variable '%s' exists for Process Group with ID %s in %s but not in %s", fieldName, componentA.getIdentifier(), flowAName, flowBName); break; case VERSIONED_FLOW_COORDINATES_CHANGED: 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; }