Class SnippetUtils

java.lang.Object
org.apache.nifi.util.SnippetUtils

public final class SnippetUtils extends Object
Utility class for moving Snippets.
  • Constructor Details

    • SnippetUtils

      public SnippetUtils()
  • Method Details

    • moveSnippet

      public static void moveSnippet(FlowSnippetDTO snippet, Double x, Double y)
      Moves the content of the specified snippet around the specified location. Does not scale components in child process groups.
      Parameters:
      snippet - snippet
      x - x location
      y - y location
    • moveAndScaleSnippet

      public static void moveAndScaleSnippet(FlowSnippetDTO snippet, Double x, Double y, double factorX, double factorY)
      Moves the content of the specified snippet around the specified location and scales the placement of individual components of the template by the given factorX and factorY. Does not scale components in child process groups.
      Parameters:
      snippet - snippet
      x - x location
      y - y location
      factorX - x location scaling factor
      factorY - y location scaling factor
    • scaleSnippet

      public static void scaleSnippet(FlowSnippetDTO snippet, double factorX, double factorY)
      Scales the placement of individual components of the snippet by the given factorX and factorY. Does not scale components in child process groups.
      Parameters:
      snippet - snippet
      factorX - x location scaling factor
      factorY - y location scaling factor
    • findAllProcessGroups

      public static List<ProcessGroupDTO> findAllProcessGroups(FlowSnippetDTO snippet)
      Finds all ProcessGroupDTOs in the given FlowSnippetDTO.
      Parameters:
      snippet - containing the child ProcessGroupDTOs to be returned
      Returns:
      List of child ProcessGroupDTOs found in the given FlowSnippetDTO.
    • getConnections

      private static Collection<ConnectionDTO> getConnections(FlowSnippetDTO contents)
      Gets all connections that are part of the specified template.
      Parameters:
      contents - snippet content
      Returns:
      connection dtos
    • getComponents

      private static Collection<ComponentDTO> getComponents(FlowSnippetDTO contents)
      Gets all components, but not connections, that are part of the specified template.
      Parameters:
      contents - snippet
      Returns:
      component dtos
    • getPositionLookup

      private static Map<ComponentDTO,PositionDTO> getPositionLookup(Collection<ComponentDTO> components)
      Builds a mapping of components to PositionDTO's.
      Parameters:
      components - components
      Returns:
      component and position map
    • getConnectionPositionLookup

      private static Map<ConnectionDTO,List<PositionDTO>> getConnectionPositionLookup(Collection<ConnectionDTO> connections)
      Builds a mapping of components to PositionDTO's.
      Parameters:
      connections - connections
      Returns:
      position of connections map
    • getOrigin

      private static PositionDTO getOrigin(Collection<PositionDTO> componentPositions, Collection<List<PositionDTO>> connectionPositions)
      Gets the origin of the bounding box of all specified component positions
      Parameters:
      componentPositions - position list for components
      connectionPositions - position list for connections
      Returns:
      position
    • applyUpdatedPositions

      private static void applyUpdatedPositions(Map<ComponentDTO,PositionDTO> componentPositionLookup, Map<ConnectionDTO,List<PositionDTO>> connectionPositionLookup)
      Applies the updated positions to the corresponding components.
      Parameters:
      componentPositionLookup - lookup
      connectionPositionLookup - lookup
    • verifyNoVersionControlConflicts

      public static void verifyNoVersionControlConflicts(Snippet snippet, ProcessGroup parentGroup, ProcessGroup destination)
    • verifyNoVersionControlConflicts

      public static void verifyNoVersionControlConflicts(FlowSnippetDTO snippetContents, ProcessGroup destination)
    • verifyNoDuplicateVersionControlInfoDtos

      private static void verifyNoDuplicateVersionControlInfoDtos(ProcessGroup group, Collection<VersionControlInformationDTO> snippetVcis)
    • verifyNoDuplicateVersionControlInfo

      private static void verifyNoDuplicateVersionControlInfo(ProcessGroup group, Collection<VersionControlInformation> snippetVcis)
    • findAllVersionControlInfo

      private static void findAllVersionControlInfo(ProcessGroupDTO dto, List<VersionControlInformationDTO> found)
    • findAllVersionControlInfo

      private static void findAllVersionControlInfo(ProcessGroup group, List<VersionControlInformation> found)