use of org.apache.nifi.web.api.dto.ProcessorDTO in project kylo by Teradata.
the class NifiProcessUtil method getInputProcessors.
/**
* Return a list of all the first level input/source processors in a process group. These processors dont have any connection incoming to them
*
* @param group a process group
* @return a list of input processors
*/
public static List<ProcessorDTO> getInputProcessors(ProcessGroupDTO group) {
List<ProcessorDTO> processors = new ArrayList<>();
List<String> processorIds = NifiConnectionUtil.getInputProcessorIds(group.getContents().getConnections());
Map<String, ProcessorDTO> map = new HashMap<>();
if (group.getContents() != null && group.getContents().getProcessors() != null) {
for (ProcessorDTO processor : group.getContents().getProcessors()) {
map.put(processor.getId(), processor);
}
}
for (String processorId : processorIds) {
if (map.containsKey(processorId)) {
processors.add(map.get(processorId));
}
}
return processors;
}
use of org.apache.nifi.web.api.dto.ProcessorDTO in project kylo by Teradata.
the class NifiPropertyUtil method getPropertiesForTemplate.
/**
* For a given template object return the list of properties. optionally choose to exclude any input processors from the property list
*
* @param parentProcessGroup the parent process group associated wiht the template
* @param dto the template
* @param propertyDescriptorTransform transformation utility
* @param excludeInputProcessors {@code true} removes the properties part of the input processors, {@code false} will include all properties in all processors of the template
*/
public static List<NifiProperty> getPropertiesForTemplate(ProcessGroupDTO parentProcessGroup, TemplateDTO dto, NiFiPropertyDescriptorTransform propertyDescriptorTransform, boolean excludeInputProcessors) {
List<NifiProperty> properties = new ArrayList<NifiProperty>();
if (dto != null) {
List<ProcessorDTO> inputs = NifiTemplateUtil.getInputProcessorsForTemplate(dto);
Set<ProcessorDTO> processorDTOSet = NifiProcessUtil.getProcessors(dto, excludeInputProcessors);
Map<String, ProcessGroupDTO> groupMap = NifiProcessUtil.getProcessGroupsMap(dto);
for (ProcessorDTO processor : processorDTOSet) {
ProcessGroupDTO group = groupMap.get(processor.getParentGroupId());
if (group == null) {
group = parentProcessGroup;
}
List<NifiProperty> propertyList = getPropertiesForProcessor(group, processor, propertyDescriptorTransform);
// assign the property as an input property if it is one
if (NifiProcessUtil.findFirstProcessorsById(inputs, processor.getId()) != null) {
for (NifiProperty property : propertyList) {
property.setInputProperty(true);
}
}
properties.addAll(propertyList);
}
}
return properties;
}
use of org.apache.nifi.web.api.dto.ProcessorDTO in project nifi by apache.
the class StandardNiFiServiceFacade method deleteProcessor.
@Override
public ProcessorEntity deleteProcessor(final Revision revision, final String processorId) {
final ProcessorNode processor = processorDAO.getProcessor(processorId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processor);
final ProcessorDTO snapshot = deleteComponent(revision, processor.getResource(), () -> processorDAO.deleteProcessor(processorId), true, dtoFactory.createProcessorDto(processor));
return entityFactory.createProcessorEntity(snapshot, null, permissions, null, null);
}
use of org.apache.nifi.web.api.dto.ProcessorDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createProcessor.
@Override
public ProcessorEntity createProcessor(final Revision revision, final String groupId, final ProcessorDTO processorDTO) {
final RevisionUpdate<ProcessorDTO> snapshot = createComponent(revision, processorDTO, () -> processorDAO.createProcessor(groupId, processorDTO), processor -> dtoFactory.createProcessorDto(processor));
final ProcessorNode processor = processorDAO.getProcessor(processorDTO.getId());
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processor);
final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorDTO.getId()));
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processorDTO.getId()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
}
use of org.apache.nifi.web.api.dto.ProcessorDTO in project nifi by apache.
the class StandardNiFiServiceFacade method validateSnippetContents.
private void validateSnippetContents(final FlowSnippetDTO flow) {
// validate any processors
if (flow.getProcessors() != null) {
for (final ProcessorDTO processorDTO : flow.getProcessors()) {
final ProcessorNode processorNode = processorDAO.getProcessor(processorDTO.getId());
final Collection<ValidationResult> validationErrors = processorNode.getValidationErrors();
if (validationErrors != null && !validationErrors.isEmpty()) {
final List<String> errors = new ArrayList<>();
for (final ValidationResult validationResult : validationErrors) {
errors.add(validationResult.toString());
}
processorDTO.setValidationErrors(errors);
}
}
}
if (flow.getInputPorts() != null) {
for (final PortDTO portDTO : flow.getInputPorts()) {
final Port port = inputPortDAO.getPort(portDTO.getId());
final Collection<ValidationResult> validationErrors = port.getValidationErrors();
if (validationErrors != null && !validationErrors.isEmpty()) {
final List<String> errors = new ArrayList<>();
for (final ValidationResult validationResult : validationErrors) {
errors.add(validationResult.toString());
}
portDTO.setValidationErrors(errors);
}
}
}
if (flow.getOutputPorts() != null) {
for (final PortDTO portDTO : flow.getOutputPorts()) {
final Port port = outputPortDAO.getPort(portDTO.getId());
final Collection<ValidationResult> validationErrors = port.getValidationErrors();
if (validationErrors != null && !validationErrors.isEmpty()) {
final List<String> errors = new ArrayList<>();
for (final ValidationResult validationResult : validationErrors) {
errors.add(validationResult.toString());
}
portDTO.setValidationErrors(errors);
}
}
}
// get any remote process group issues
if (flow.getRemoteProcessGroups() != null) {
for (final RemoteProcessGroupDTO remoteProcessGroupDTO : flow.getRemoteProcessGroups()) {
final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupDTO.getId());
if (remoteProcessGroup.getAuthorizationIssue() != null) {
remoteProcessGroupDTO.setAuthorizationIssues(Arrays.asList(remoteProcessGroup.getAuthorizationIssue()));
}
}
}
}
Aggregations