Package org.apache.nifi.util
Class SnippetUtils
java.lang.Object
org.apache.nifi.util.SnippetUtils
Utility class for moving Snippets.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidapplyUpdatedPositions(Map<ComponentDTO, PositionDTO> componentPositionLookup, Map<ConnectionDTO, List<PositionDTO>> connectionPositionLookup) Applies the updated positions to the corresponding components.static List<ProcessGroupDTO> findAllProcessGroups(FlowSnippetDTO snippet) Finds allProcessGroupDTOs in the givenFlowSnippetDTO.private static voidfindAllVersionControlInfo(ProcessGroup group, List<VersionControlInformation> found) private static voidprivate static Collection<ComponentDTO> getComponents(FlowSnippetDTO contents) Gets all components, but not connections, that are part of the specified template.private static Map<ConnectionDTO, List<PositionDTO>> getConnectionPositionLookup(Collection<ConnectionDTO> connections) Builds a mapping of components to PositionDTO's.private static Collection<ConnectionDTO> getConnections(FlowSnippetDTO contents) Gets all connections that are part of the specified template.private static PositionDTOgetOrigin(Collection<PositionDTO> componentPositions, Collection<List<PositionDTO>> connectionPositions) Gets the origin of the bounding box of all specified component positionsprivate static Map<ComponentDTO, PositionDTO> getPositionLookup(Collection<ComponentDTO> components) Builds a mapping of components to PositionDTO's.static voidmoveAndScaleSnippet(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.static voidmoveSnippet(FlowSnippetDTO snippet, Double x, Double y) Moves the content of the specified snippet around the specified location.static voidscaleSnippet(FlowSnippetDTO snippet, double factorX, double factorY) Scales the placement of individual components of the snippet by the given factorX and factorY.private static voidverifyNoDuplicateVersionControlInfo(ProcessGroup group, Collection<VersionControlInformation> snippetVcis) private static voidverifyNoDuplicateVersionControlInfoDtos(ProcessGroup group, Collection<VersionControlInformationDTO> snippetVcis) static voidverifyNoVersionControlConflicts(Snippet snippet, ProcessGroup parentGroup, ProcessGroup destination) static voidverifyNoVersionControlConflicts(FlowSnippetDTO snippetContents, ProcessGroup destination)
-
Constructor Details
-
SnippetUtils
public SnippetUtils()
-
-
Method Details
-
moveSnippet
Moves the content of the specified snippet around the specified location. Does not scale components in child process groups.- Parameters:
snippet- snippetx- x locationy- 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- snippetx- x locationy- y locationfactorX- x location scaling factorfactorY- y location scaling factor
-
scaleSnippet
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- snippetfactorX- x location scaling factorfactorY- y location scaling factor
-
findAllProcessGroups
Finds allProcessGroupDTOs in the givenFlowSnippetDTO.- Parameters:
snippet- containing the childProcessGroupDTOs to be returned- Returns:
- List of child
ProcessGroupDTOs found in the givenFlowSnippetDTO.
-
getConnections
Gets all connections that are part of the specified template.- Parameters:
contents- snippet content- Returns:
- connection dtos
-
getComponents
Gets all components, but not connections, that are part of the specified template.- Parameters:
contents- snippet- Returns:
- component dtos
-
getPositionLookup
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 componentsconnectionPositions- 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- lookupconnectionPositionLookup- 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)
-