use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.
the class NiFiProcessGroupsRestClientV1 method create.
@Nonnull
@Override
public ProcessGroupDTO create(@Nonnull String parentProcessGroupId, @Nonnull String name) {
final ProcessGroupEntity entity = new ProcessGroupEntity();
final ProcessGroupDTO processGroup = new ProcessGroupDTO();
processGroup.setName(name);
entity.setComponent(processGroup);
final RevisionDTO revision = new RevisionDTO();
revision.setVersion(0L);
entity.setRevision(revision);
try {
return client.post(BASE_PATH + parentProcessGroupId + "/process-groups", entity, ProcessGroupEntity.class).getComponent();
} catch (final NotFoundException e) {
throw new NifiComponentNotFoundException(parentProcessGroupId, NifiConstants.NIFI_COMPONENT_TYPE.PROCESS_GROUP, e);
}
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project nifi by apache.
the class StandardNiFiServiceFacade method deleteProcessGroup.
@Override
public ProcessGroupEntity deleteProcessGroup(final Revision revision, final String groupId) {
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
// grab the resources in the snippet so we can delete the policies afterwards
final Set<Resource> groupResources = new HashSet<>();
processGroup.findAllProcessors().forEach(processor -> groupResources.add(processor.getResource()));
processGroup.findAllInputPorts().forEach(inputPort -> groupResources.add(inputPort.getResource()));
processGroup.findAllOutputPorts().forEach(outputPort -> groupResources.add(outputPort.getResource()));
processGroup.findAllFunnels().forEach(funnel -> groupResources.add(funnel.getResource()));
processGroup.findAllLabels().forEach(label -> groupResources.add(label.getResource()));
processGroup.findAllProcessGroups().forEach(childGroup -> groupResources.add(childGroup.getResource()));
processGroup.findAllRemoteProcessGroups().forEach(remoteProcessGroup -> groupResources.add(remoteProcessGroup.getResource()));
processGroup.findAllTemplates().forEach(template -> groupResources.add(template.getResource()));
processGroup.findAllControllerServices().forEach(controllerService -> groupResources.add(controllerService.getResource()));
final ProcessGroupDTO snapshot = deleteComponent(revision, processGroup.getResource(), () -> processGroupDAO.deleteProcessGroup(groupId), true, dtoFactory.createProcessGroupDto(processGroup));
// delete all applicable component policies
groupResources.forEach(groupResource -> cleanUpPolicies(groupResource));
return entityFactory.createProcessGroupEntity(snapshot, null, permissions, null, null);
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createProcessGroup.
@Override
public ProcessGroupEntity createProcessGroup(final Revision revision, final String parentGroupId, final ProcessGroupDTO processGroupDTO) {
final RevisionUpdate<ProcessGroupDTO> snapshot = createComponent(revision, processGroupDTO, () -> processGroupDAO.createProcessGroup(parentGroupId, processGroupDTO), processGroup -> dtoFactory.createProcessGroupDto(processGroup));
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(processGroupDTO.getId());
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(processGroup.getIdentifier()));
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroup.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
return entityFactory.createProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project nifi by apache.
the class StandardNiFiServiceFacade method updateProcessGroupContents.
@Override
public ProcessGroupEntity updateProcessGroupContents(final NiFiUser user, final Revision revision, final String groupId, final VersionControlInformationDTO versionControlInfo, final VersionedFlowSnapshot proposedFlowSnapshot, final String componentIdSeed, final boolean verifyNotModified, final boolean updateSettings, final boolean updateDescendantVersionedFlows) {
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
final List<Revision> revisions = getComponentRevisions(processGroup, false);
revisions.add(revision);
final RevisionClaim revisionClaim = new StandardRevisionClaim(revisions);
final RevisionUpdate<ProcessGroupDTO> revisionUpdate = revisionManager.updateRevision(revisionClaim, user, new UpdateRevisionTask<ProcessGroupDTO>() {
@Override
public RevisionUpdate<ProcessGroupDTO> update() {
// update the Process Group
processGroupDAO.updateProcessGroupFlow(groupId, user, proposedFlowSnapshot, versionControlInfo, componentIdSeed, verifyNotModified, updateSettings, updateDescendantVersionedFlows);
// update the revisions
final Set<Revision> updatedRevisions = revisions.stream().map(rev -> revisionManager.getRevision(rev.getComponentId()).incrementRevision(revision.getClientId())).collect(Collectors.toSet());
// save
controllerFacade.save();
// gather details for response
final ProcessGroupDTO dto = dtoFactory.createProcessGroupDto(processGroup);
final Revision updatedRevision = revisionManager.getRevision(groupId).incrementRevision(revision.getClientId());
final FlowModification lastModification = new FlowModification(updatedRevision, user.getIdentity());
return new StandardRevisionUpdate<>(dto, lastModification, updatedRevisions);
}
});
final FlowModification lastModification = revisionUpdate.getLastModification();
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
final RevisionDTO updatedRevision = dtoFactory.createRevisionDTO(lastModification);
final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(processGroup.getIdentifier()));
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroup.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
return entityFactory.createProcessGroupEntity(revisionUpdate.getComponent(), updatedRevision, permissions, status, bulletinEntities);
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project nifi by apache.
the class FlowResource method populateRemainingFlowStructure.
/**
* Populates the remaining content of the specified snippet.
*/
private FlowDTO populateRemainingFlowStructure(FlowDTO flowStructure) {
processorResource.populateRemainingProcessorEntitiesContent(flowStructure.getProcessors());
connectionResource.populateRemainingConnectionEntitiesContent(flowStructure.getConnections());
inputPortResource.populateRemainingInputPortEntitiesContent(flowStructure.getInputPorts());
outputPortResource.populateRemainingOutputPortEntitiesContent(flowStructure.getOutputPorts());
remoteProcessGroupResource.populateRemainingRemoteProcessGroupEntitiesContent(flowStructure.getRemoteProcessGroups());
funnelResource.populateRemainingFunnelEntitiesContent(flowStructure.getFunnels());
labelResource.populateRemainingLabelEntitiesContent(flowStructure.getLabels());
processGroupResource.populateRemainingProcessGroupEntitiesContent(flowStructure.getProcessGroups());
// go through each process group child and populate its uri
for (final ProcessGroupEntity processGroupEntity : flowStructure.getProcessGroups()) {
final ProcessGroupDTO processGroup = processGroupEntity.getComponent();
if (processGroup != null) {
processGroup.setContents(null);
}
}
return flowStructure;
}
Aggregations