public ProcessGroupDTO copy(final ProcessGroupDTO original, final boolean deep) { final ProcessGroupDTO copy = new ProcessGroupDTO(); copy.setComments(original.getComments()); copy.setContents(copy(original.getContents(), deep)); copy.setPosition(original.getPosition()); copy.setId(original.getId()); copy.setInputPortCount(original.getInputPortCount()); copy.setInvalidCount(original.getInvalidCount()); copy.setName(original.getName()); copy.setVersionControlInformation(copy(original.getVersionControlInformation())); copy.setOutputPortCount(original.getOutputPortCount()); copy.setParentGroupId(original.getParentGroupId()); copy.setVersionedComponentId(original.getVersionedComponentId()); copy.setRunningCount(original.getRunningCount()); copy.setStoppedCount(original.getStoppedCount()); copy.setDisabledCount(original.getDisabledCount()); copy.setActiveRemotePortCount(original.getActiveRemotePortCount()); copy.setInactiveRemotePortCount(original.getInactiveRemotePortCount()); copy.setUpToDateCount(original.getUpToDateCount()); copy.setLocallyModifiedCount(original.getLocallyModifiedCount()); copy.setStaleCount(original.getStaleCount()); copy.setLocallyModifiedAndStaleCount(original.getLocallyModifiedAndStaleCount()); copy.setSyncFailureCount(original.getSyncFailureCount()); if (original.getVariables() != null) { copy.setVariables(new HashMap<>(original.getVariables())); } return copy; }
/** * Scrubs process groups prior to saving. * * @param processGroups groups */ private static void scrubProcessGroups(final Set<ProcessGroupDTO> processGroups) { // go through each process group for (final ProcessGroupDTO processGroupDTO : processGroups) { processGroupDTO.setActiveRemotePortCount(null); processGroupDTO.setDisabledCount(null); processGroupDTO.setInactiveRemotePortCount(null); processGroupDTO.setInputPortCount(null); processGroupDTO.setInvalidCount(null); processGroupDTO.setOutputPortCount(null); processGroupDTO.setRunningCount(null); processGroupDTO.setStoppedCount(null); processGroupDTO.setUpToDateCount(null); processGroupDTO.setLocallyModifiedCount(null); processGroupDTO.setStaleCount(null); processGroupDTO.setLocallyModifiedAndStaleCount(null); processGroupDTO.setSyncFailureCount(null); processGroupDTO.setVersionControlInformation(null); scrubSnippet(processGroupDTO.getContents()); } }
final ProcessGroupDTO dto = new ProcessGroupDTO(); dto.setId(group.getIdentifier()); dto.setPosition(createPositionDto(group.getPosition())); dto.setComments(group.getComments()); dto.setName(group.getName()); dto.setVersionedComponentId(group.getVersionedComponentId().orElse(null)); dto.setVersionControlInformation(createVersionControlInformationDto(group)); dto.setVariables(variables); dto.setParentGroupId(parentGroup.getIdentifier()); dto.setRunningCount(counts.getRunningCount()); dto.setStoppedCount(counts.getStoppedCount()); dto.setInvalidCount(counts.getInvalidCount()); dto.setDisabledCount(counts.getDisabledCount()); dto.setInputPortCount(counts.getInputPortCount()); dto.setOutputPortCount(counts.getOutputPortCount()); dto.setActiveRemotePortCount(counts.getActiveRemotePortCount()); dto.setInactiveRemotePortCount(counts.getInactiveRemotePortCount()); dto.setUpToDateCount(counts.getUpToDateCount()); dto.setLocallyModifiedCount(counts.getLocallyModifiedCount()); dto.setStaleCount(counts.getStaleCount()); dto.setLocallyModifiedAndStaleCount(counts.getLocallyModifiedAndStaleCount()); dto.setSyncFailureCount(counts.getSyncFailureCount());
entity.setPermissions(permissions); entity.setStatus(status); entity.setId(dto.getId()); entity.setPosition(dto.getPosition()); entity.setInputPortCount(dto.getInputPortCount()); entity.setOutputPortCount(dto.getOutputPortCount()); entity.setRunningCount(dto.getRunningCount()); entity.setStoppedCount(dto.getStoppedCount()); entity.setInvalidCount(dto.getInvalidCount()); entity.setDisabledCount(dto.getDisabledCount()); entity.setActiveRemotePortCount(dto.getActiveRemotePortCount()); entity.setInactiveRemotePortCount(dto.getInactiveRemotePortCount()); entity.setUpToDateCount(dto.getUpToDateCount()); entity.setLocallyModifiedCount(dto.getLocallyModifiedCount()); entity.setStaleCount(dto.getStaleCount()); entity.setLocallyModifiedAndStaleCount(dto.getLocallyModifiedAndStaleCount()); entity.setSyncFailureCount(dto.getSyncFailureCount()); if (dto.getVersionControlInformation() != null) { entity.setVersionedFlowState(dto.getVersionControlInformation().getState());
public static ProcessGroupDTO getProcessGroup(final String parentId, final Element element, final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) { final ProcessGroupDTO dto = new ProcessGroupDTO(); final String groupId = getString(element, "id"); dto.setId(groupId); dto.setVersionedComponentId(getString(element, "versionedComponentId")); dto.setParentGroupId(parentId); dto.setName(getString(element, "name")); dto.setPosition(getPosition(DomUtils.getChild(element, "position"))); dto.setComments(getString(element, "comment")); variables.put(name, value); dto.setVariables(variables); dto.setVersionControlInformation(getVersionControlInformation(versionControlInfoElement)); groupContents.setRemoteProcessGroups(remoteProcessGroups); dto.setContents(groupContents); return dto;
final ProcessGroup childGroup = flowManager.createProcessGroup(groupDTO.getId()); childGroup.setParent(group); childGroup.setPosition(toPosition(groupDTO.getPosition())); childGroup.setComments(groupDTO.getComments()); childGroup.setName(groupDTO.getName()); if (groupDTO.getVariables() != null) { childGroup.setVariables(groupDTO.getVariables()); childGroup.setVersionedComponentId(groupDTO.getVersionedComponentId()); final FlowSnippetDTO contents = groupDTO.getContents(); childSnippet.instantiate(flowManager, childGroup, false); if (groupDTO.getVersionControlInformation() != null) { final VersionControlInformation vci = StandardVersionControlInformation.Builder .fromDto(groupDTO.getVersionControlInformation()) .build(); childGroup.setVersionControlInformation(vci, Collections.emptyMap());
if (requestProcessGroupEntity.getComponent().getId() != null) { throw new IllegalArgumentException("Process group ID cannot be specified."); final PositionDTO proposedPosition = requestProcessGroupEntity.getComponent().getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { if (StringUtils.isBlank(requestProcessGroupEntity.getComponent().getName()) && requestProcessGroupEntity.getComponent().getVersionControlInformation() == null) { throw new IllegalArgumentException("The group name is required when the group is not imported from version control."); if (requestProcessGroupEntity.getComponent().getParentGroupId() != null && !groupId.equals(requestProcessGroupEntity.getComponent().getParentGroupId())) { throw new IllegalArgumentException(String.format("If specified, the parent process group id %s must be the same as specified in the URI %s", requestProcessGroupEntity.getComponent().getParentGroupId(), groupId)); requestProcessGroupEntity.getComponent().setParentGroupId(groupId); final VersionControlInformationDTO versionControlInfo = requestProcessGroupEntity.getComponent().getVersionControlInformation(); if (versionControlInfo != null && requestProcessGroupEntity.getVersionedFlowSnapshot() == null) { processGroup.setId(generateUuid()); if (flowSnapshot != null && StringUtils.isNotBlank(flowSnapshot.getFlowContents().getName()) && StringUtils.isBlank(processGroup.getName())) { processGroup.setName(flowSnapshot.getFlowContents().getName()); final Revision revision = getRevision(processGroupEntity, processGroup.getId()); ProcessGroupEntity entity = serviceFacade.createProcessGroup(revision, groupId, processGroup); final String newGroupId = entity.getComponent().getId(); final Revision newGroupRevision = new Revision(revisionDto.getVersion(), revisionDto.getClientId(), newGroupId);
}); snippet.getProcessGroups().forEach(processGroupDTO -> { rollbackClonedPolicy(ResourceFactory.getComponentResource(ResourceType.ProcessGroup, processGroupDTO.getId(), processGroupDTO.getName())); if (processGroupDTO.getContents() != null) { rollbackClonedPolicies(processGroupDTO.getContents());
@Override protected void writeSimpleResult(final PrintStream output) { final Table table = new Table.Builder() .column("#", 3, 3, false) .column("Name", 20, 36, true) .column("Id", 36, 36, false) .column("Running", 7, 7, false) .column("Stopped", 7, 7, false) .column("Disabled", 8, 8, false) .column("Invalid", 7, 7, false) .build(); for (int i=0; i < processGroups.size(); i++) { final ProcessGroupDTO dto = processGroups.get(i); table.addRow( String.valueOf(i+1), dto.getName(), dto.getId(), String.valueOf(dto.getRunningCount()), String.valueOf(dto.getStoppedCount()), String.valueOf(dto.getDisabledCount()), String.valueOf(dto.getInvalidCount()) ); } final TableWriter tableWriter = new DynamicTableWriter(); tableWriter.write(table, output); }
for (final ProcessGroupDTO groupDTO : snippetContents.getProcessGroups()) { final ProcessGroupDTO cp = dtoFactory.copy(groupDTO, false); cp.setId(generateId(groupDTO.getId(), idGenerationSeed, isCopy)); cp.setParentGroupId(groupId); final FlowSnippetDTO contentsCopy = copyContentsForGroup(groupDTO.getContents(), cp.getId(), connectableMap, serviceIdMap, idGenerationSeed, isCopy); cp.setContents(contentsCopy); groups.add(cp); ResourceFactory.getComponentResource(ResourceType.ProcessGroup, groupDTO.getId(), groupDTO.getName()), ResourceFactory.getComponentResource(ResourceType.ProcessGroup, cp.getId(), cp.getName()), idGenerationSeed);
final ProcessGroup processGroup = flowManager.createProcessGroup(processGroupDTO.getId()); processGroup.setComments(processGroupDTO.getComments()); processGroup.setVersionedComponentId(processGroupDTO.getVersionedComponentId()); processGroup.setPosition(toPosition(processGroupDTO.getPosition())); processGroup.setName(processGroupDTO.getName()); processGroup.setParent(parentGroup); if (parentGroup == null) { final VersionControlInformationDTO versionControlInfoDto = processGroupDTO.getVersionControlInformation(); if (versionControlInfoDto != null) { final FlowRegistry flowRegistry = controller.getFlowRegistryClient().getFlowRegistry(versionControlInfoDto.getRegistryId());
@Override public ProcessGroup updateProcessGroup(ProcessGroupDTO processGroupDTO) { final ProcessGroup group = locateProcessGroup(flowController, processGroupDTO.getId()); final String name = processGroupDTO.getName(); final String comments = processGroupDTO.getComments(); if (isNotNull(name)) { group.setName(name); } if (isNotNull(processGroupDTO.getPosition())) { group.setPosition(new Position(processGroupDTO.getPosition().getX(), processGroupDTO.getPosition().getY())); final ProcessGroup parent = group.getParent(); if (parent != null) { parent.onComponentModified(); } } if (isNotNull(comments)) { group.setComments(comments); } group.onComponentModified(); return group; }
/** * Recursively finds all ConnectionDTO's * * @param group group * @return connection dtos */ private Set<ConnectionDTO> findAllConnections(final ProcessGroupDTO group) { final Set<ConnectionDTO> conns = new HashSet<>(); conns.addAll(group.getContents().getConnections()); for (final ProcessGroupDTO childGroup : group.getContents().getProcessGroups()) { conns.addAll(findAllConnections(childGroup)); } return conns; }
@Override public ProcessGroup createProcessGroup(String parentGroupId, ProcessGroupDTO processGroup) { final FlowManager flowManager = flowController.getFlowManager(); if (processGroup.getParentGroupId() != null && !flowManager.areGroupsSame(processGroup.getParentGroupId(), parentGroupId)) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Process Group is being added."); } // get the parent group ProcessGroup parentGroup = locateProcessGroup(flowController, parentGroupId); // create the process group ProcessGroup group = flowManager.createProcessGroup(processGroup.getId()); if (processGroup.getName() != null) { group.setName(processGroup.getName()); } if (processGroup.getPosition() != null) { group.setPosition(new Position(processGroup.getPosition().getX(), processGroup.getPosition().getY())); } // add the process group group.setParent(parentGroup); parentGroup.addProcessGroup(group); return group; }
posDto.setY(Integer.valueOf(pgBox.getY()).doubleValue()); final ProcessGroupDTO pgDto = new ProcessGroupDTO(); pgDto.setVersionControlInformation(versionControlInfo); pgDto.setPosition(posDto);
@Override public void verifyUpdateProcessGroup(ProcessGroupDTO processGroupDTO) { if (processGroupDAO.hasProcessGroup(processGroupDTO.getId())) { processGroupDAO.verifyUpdate(processGroupDTO); } }
if (groupDTO.getVersionControlInformation() == null) { String groupName = groupDTO.getName(); while (groupNames.contains(groupName)) { groupName = "Copy of " + groupName; groupDTO.setName(groupName); groupNames.add(groupDTO.getName());
/** * Updates the process group corresponding to the specified DTO. Any field * in DTO that is <code>null</code> (with the exception of the required ID) * will be ignored. * * @throws IllegalStateException if no process group can be found with the * ID of DTO or with the ID of the DTO's parentGroupId, if the template ID * specified is invalid, or if the DTO's Parent Group ID changes but the * parent group has incoming or outgoing connections * * @throws NullPointerException if the DTO or its ID is null */ private void updateProcessGroup(final ProcessGroup group, final ProcessGroupDTO dto) { final String name = dto.getName(); final PositionDTO position = dto.getPosition(); final String comments = dto.getComments(); if (name != null) { group.setName(name); } if (position != null) { group.setPosition(toPosition(position)); } if (comments != null) { group.setComments(comments); } }
private void mergeVersionControlInformation(ProcessGroupEntity targetGroup, ProcessGroupEntity toMerge) { final ProcessGroupDTO targetGroupDto = targetGroup.getComponent(); final ProcessGroupDTO toMergeGroupDto = toMerge.getComponent(); if (targetGroupDto == null || toMergeGroupDto == null) { return; } final VersionControlInformationDTO targetVersionControl = targetGroupDto.getVersionControlInformation(); final VersionControlInformationDTO toMergeVersionControl = toMergeGroupDto.getVersionControlInformation(); if (targetVersionControl == null) { targetGroupDto.setVersionControlInformation(toMergeGroupDto.getVersionControlInformation()); } else if (toMergeVersionControl != null) { VersionControlInformationEntityMerger.updateFlowState(targetVersionControl, toMergeVersionControl); } } }