NIFI-2150:

Cleanse more values from templates that are not necessary. Additionally, updated javadocs in ProcessorConfigDTO to provide further explanation of the getAutoTerminatedRelationships() method, since this was confusing
Removed additional unused fields from templates
Populating snippet response using actual components rather than the snippet contents.
This closes #593
This commit is contained in:
Mark Payne 2016-06-29 15:12:50 -04:00 committed by Matt Gilman
parent ae9e2fdf0b
commit 8eb0a3882c
4 changed files with 118 additions and 46 deletions

View File

@ -237,7 +237,9 @@ public class ProcessorConfigDTO {
* @return the names of all processor relationships that cause a flow file to be terminated if the relationship is not connected to anything * @return the names of all processor relationships that cause a flow file to be terminated if the relationship is not connected to anything
*/ */
@ApiModelProperty( @ApiModelProperty(
value = "The names of all relationships that cause a flow file to be terminated if the relationship is not connected elsewhere." value = "The names of all relationships that cause a flow file to be terminated if the relationship is not connected elsewhere. This property differs "
+ "from the 'isAutoTerminate' property of the RelationshipDTO in that the RelationshipDTO is meant to depict the current configuration, whereas this "
+ "property can be set in a DTO when updating a Processor in order to change which Relationships should be auto-terminated."
) )
public Set<String> getAutoTerminatedRelationships() { public Set<String> getAutoTerminatedRelationships() {
return autoTerminatedRelationships; return autoTerminatedRelationships;

View File

@ -130,7 +130,7 @@ public class Template implements Authorizable {
for (final ProcessGroupDTO groupDto : snippet.getProcessGroups()) { for (final ProcessGroupDTO groupDto : snippet.getProcessGroups()) {
final ProcessGroup group = processGroup.getProcessGroup(groupDto.getId()); final ProcessGroup group = processGroup.getProcessGroup(groupDto.getId());
if (group != null) { if (group != null) {
authComponents.addAll(getAuthorizableComponents(processGroup)); authComponents.addAll(getAuthorizableComponents(group));
} }
} }

View File

@ -42,6 +42,7 @@ import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO; import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO; import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO; import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
import org.apache.nifi.web.api.dto.RelationshipDTO;
import org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO;
import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO;
import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO;
@ -147,6 +148,15 @@ public class TemplateUtils {
private static void scrubProcessGroups(final Set<ProcessGroupDTO> processGroups) { private static void scrubProcessGroups(final Set<ProcessGroupDTO> processGroups) {
// go through each process group // go through each process group
for (final ProcessGroupDTO processGroupDTO : processGroups) { 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);
scrubSnippet(processGroupDTO.getContents()); scrubSnippet(processGroupDTO.getContents());
} }
} }
@ -179,11 +189,25 @@ public class TemplateUtils {
} }
processorConfig.setCustomUiUrl(null); processorConfig.setCustomUiUrl(null);
processorConfig.setDefaultConcurrentTasks(null);
processorConfig.setDefaultSchedulingPeriod(null);
processorConfig.setDescriptors(null);
processorConfig.setAutoTerminatedRelationships(null);
}
for (final RelationshipDTO relationship : processorDTO.getRelationships()) {
relationship.setDescription(null);
} }
// remove validation errors
processorDTO.setValidationErrors(null); processorDTO.setValidationErrors(null);
processorDTO.setInputRequirement(null); processorDTO.setInputRequirement(null);
processorDTO.setDescription(null);
processorDTO.setInputRequirement(null);
processorDTO.setPersistsState(null);
processorDTO.setState(null);
processorDTO.setSupportsBatching(null);
processorDTO.setSupportsEventDriven(null);
processorDTO.setSupportsParallelProcessing(null);
} }
} }
@ -200,6 +224,7 @@ public class TemplateUtils {
} }
} }
serviceDTO.setDescriptors(null);
serviceDTO.setCustomUiUrl(null); serviceDTO.setCustomUiUrl(null);
serviceDTO.setValidationErrors(null); serviceDTO.setValidationErrors(null);
} }
@ -248,6 +273,15 @@ public class TemplateUtils {
remoteProcessGroupDTO.setOutputPortCount(null); remoteProcessGroupDTO.setOutputPortCount(null);
remoteProcessGroupDTO.setTransmitting(null); remoteProcessGroupDTO.setTransmitting(null);
remoteProcessGroupDTO.setProxyPassword(null); remoteProcessGroupDTO.setProxyPassword(null);
remoteProcessGroupDTO.setActiveRemoteInputPortCount(null);
remoteProcessGroupDTO.setInactiveRemoteInputPortCount(null);
remoteProcessGroupDTO.setActiveRemoteOutputPortCount(null);
remoteProcessGroupDTO.setInactiveRemoteOutputPortCount(null);
remoteProcessGroupDTO.setAuthorizationIssues(null);
remoteProcessGroupDTO.setFlowRefreshed(null);
remoteProcessGroupDTO.setName(null);
remoteProcessGroupDTO.setTargetSecure(null);
remoteProcessGroupDTO.setTransmitting(null);
// if this remote process group has contents // if this remote process group has contents
if (remoteProcessGroupDTO.getContents() != null) { if (remoteProcessGroupDTO.getContents() != null) {
@ -283,6 +317,10 @@ public class TemplateUtils {
remotePortDTO.setExists(null); remotePortDTO.setExists(null);
remotePortDTO.setTargetRunning(null); remotePortDTO.setTargetRunning(null);
remotePortDTO.setConnected(null);
remotePortDTO.setExists(null);
remotePortDTO.setTargetRunning(null);
remotePortDTO.setTransmitting(null);
} }
} }
} }

View File

@ -1617,81 +1617,113 @@ public final class DtoFactory {
final FlowDTO flow = new FlowDTO(); final FlowDTO flow = new FlowDTO();
for (final ConnectionDTO connection : snippet.getConnections()) { for (final ConnectionDTO snippetConnection : snippet.getConnections()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(connection.getId())); final Connection connection = group.getConnection(snippetConnection.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getConnection(connection.getId()));
// marshal the actual connection as the snippet is pruned
final ConnectionDTO dto = createConnectionDto(connection);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(connection.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(connection);
final ConnectionStatusDTO status = getComponentStatus( final ConnectionStatusDTO status = getComponentStatus(
() -> groupStatus.getConnectionStatus().stream().filter(connectionStatus -> connection.getId().equals(connectionStatus.getId())).findFirst().orElse(null), () -> groupStatus.getConnectionStatus().stream().filter(connectionStatus -> connection.getIdentifier().equals(connectionStatus.getId())).findFirst().orElse(null),
connectionStatus -> createConnectionStatusDto(connectionStatus) connectionStatus -> createConnectionStatusDto(connectionStatus)
); );
flow.getConnections().add(entityFactory.createConnectionEntity(connection, revision, accessPolicy, status)); flow.getConnections().add(entityFactory.createConnectionEntity(dto, revision, accessPolicy, status));
} }
for (final FunnelDTO funnel : snippet.getFunnels()) { for (final FunnelDTO snippetFunnel : snippet.getFunnels()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(funnel.getId())); final Funnel funnel = group.getFunnel(snippetFunnel.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getFunnel(funnel.getId()));
flow.getFunnels().add(entityFactory.createFunnelEntity(funnel, revision, accessPolicy)); // marshal the actual funnel as the snippet is pruned
final FunnelDTO dto = createFunnelDto(funnel);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(funnel.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(funnel);
flow.getFunnels().add(entityFactory.createFunnelEntity(dto, revision, accessPolicy));
} }
for (final PortDTO inputPort : snippet.getInputPorts()) { for (final PortDTO snippetInputPort : snippet.getInputPorts()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(inputPort.getId())); final Port inputPort = group.getInputPort(snippetInputPort.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getInputPort(inputPort.getId()));
// marshal the actual port as the snippet is pruned
final PortDTO dto = createPortDto(inputPort);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(inputPort.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(inputPort);
final PortStatusDTO status = getComponentStatus( final PortStatusDTO status = getComponentStatus(
() -> groupStatus.getInputPortStatus().stream().filter(inputPortStatus -> inputPort.getId().equals(inputPortStatus.getId())).findFirst().orElse(null), () -> groupStatus.getInputPortStatus().stream().filter(inputPortStatus -> inputPort.getIdentifier().equals(inputPortStatus.getId())).findFirst().orElse(null),
inputPortStatus -> createPortStatusDto(inputPortStatus) inputPortStatus -> createPortStatusDto(inputPortStatus)
); );
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getId())); final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getIdentifier()));
flow.getInputPorts().add(entityFactory.createPortEntity(inputPort, revision, accessPolicy, status, bulletins)); flow.getInputPorts().add(entityFactory.createPortEntity(dto, revision, accessPolicy, status, bulletins));
} }
for (final PortDTO outputPort : snippet.getOutputPorts()) { for (final PortDTO snippetOutputPort : snippet.getOutputPorts()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(outputPort.getId())); final Port outputPort = group.getOutputPort(snippetOutputPort.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getOutputPort(outputPort.getId()));
// marshal the actual port as the snippet is pruned
final PortDTO dto = createPortDto(outputPort);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(outputPort.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(outputPort);
final PortStatusDTO status = getComponentStatus( final PortStatusDTO status = getComponentStatus(
() -> groupStatus.getOutputPortStatus().stream().filter(outputPortStatus -> outputPort.getId().equals(outputPortStatus.getId())).findFirst().orElse(null), () -> groupStatus.getOutputPortStatus().stream().filter(outputPortStatus -> outputPort.getIdentifier().equals(outputPortStatus.getId())).findFirst().orElse(null),
outputPortStatus -> createPortStatusDto(outputPortStatus) outputPortStatus -> createPortStatusDto(outputPortStatus)
); );
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getId())); final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getIdentifier()));
flow.getOutputPorts().add(entityFactory.createPortEntity(outputPort, revision, accessPolicy, status, bulletins)); flow.getOutputPorts().add(entityFactory.createPortEntity(dto, revision, accessPolicy, status, bulletins));
} }
for (final LabelDTO label : snippet.getLabels()) { for (final LabelDTO snippetLabel : snippet.getLabels()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(label.getId())); final Label label = group.getLabel(snippetLabel.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getLabel(label.getId()));
flow.getLabels().add(entityFactory.createLabelEntity(label, revision, accessPolicy)); // marshal the actual label as the snippet is pruned
final LabelDTO dto = createLabelDto(label);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(label.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(label);
flow.getLabels().add(entityFactory.createLabelEntity(dto, revision, accessPolicy));
} }
for (final ProcessGroupDTO processGroup : snippet.getProcessGroups()) { for (final ProcessGroupDTO snippetProcessGroup : snippet.getProcessGroups()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processGroup.getId())); final ProcessGroup processGroup = group.getProcessGroup(snippetProcessGroup.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getProcessGroup(processGroup.getId()));
// marshal the actual group as the snippet is pruned
final ProcessGroupDTO dto = createProcessGroupDto(processGroup);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processGroup.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(processGroup);
final ProcessGroupStatusDTO status = getComponentStatus( final ProcessGroupStatusDTO status = getComponentStatus(
() -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> processGroup.getId().equals(processGroupStatus.getId())).findFirst().orElse(null), () -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> processGroup.getIdentifier().equals(processGroupStatus.getId())).findFirst().orElse(null),
processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus) processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus)
); );
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroup.getId())); final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroup.getIdentifier()));
flow.getProcessGroups().add(entityFactory.createProcessGroupEntity(processGroup, revision, accessPolicy, status, bulletins)); flow.getProcessGroups().add(entityFactory.createProcessGroupEntity(dto, revision, accessPolicy, status, bulletins));
} }
for (final ProcessorDTO processor : snippet.getProcessors()) { for (final ProcessorDTO snippetProcessor : snippet.getProcessors()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processor.getId())); final ProcessorNode processor = group.getProcessor(snippetProcessor.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getProcessor(processor.getId()));
// marshal the actual processor as the snippet is pruned
final ProcessorDTO dto = createProcessorDto(processor);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processor.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(processor);
final ProcessorStatusDTO status = getComponentStatus( final ProcessorStatusDTO status = getComponentStatus(
() -> groupStatus.getProcessorStatus().stream().filter(processorStatus -> processor.getId().equals(processorStatus.getId())).findFirst().orElse(null), () -> groupStatus.getProcessorStatus().stream().filter(processorStatus -> processor.getIdentifier().equals(processorStatus.getId())).findFirst().orElse(null),
processorStatus -> createProcessorStatusDto(processorStatus) processorStatus -> createProcessorStatusDto(processorStatus)
); );
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(processor.getId())); final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(processor.getIdentifier()));
flow.getProcessors().add(entityFactory.createProcessorEntity(processor, revision, accessPolicy, status, bulletins)); flow.getProcessors().add(entityFactory.createProcessorEntity(dto, revision, accessPolicy, status, bulletins));
} }
for (final RemoteProcessGroupDTO remoteProcessGroup : snippet.getRemoteProcessGroups()) { for (final RemoteProcessGroupDTO snippetRemoteProcessGroup : snippet.getRemoteProcessGroups()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(remoteProcessGroup.getId())); final RemoteProcessGroup remoteProcessGroup = group.getRemoteProcessGroup(snippetRemoteProcessGroup.getId());
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getRemoteProcessGroup(remoteProcessGroup.getId()));
// marshal the actual rpm as the snippet is pruned
final RemoteProcessGroupDTO dto = createRemoteProcessGroupDto(remoteProcessGroup);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(remoteProcessGroup.getIdentifier()));
final AccessPolicyDTO accessPolicy = createAccessPolicyDto(remoteProcessGroup);
final RemoteProcessGroupStatusDTO status = getComponentStatus( final RemoteProcessGroupStatusDTO status = getComponentStatus(
() -> groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroup.getId().equals(rpgStatus.getId())).findFirst().orElse(null), () -> groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroup.getIdentifier().equals(rpgStatus.getId())).findFirst().orElse(null),
remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus) remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus)
); );
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(remoteProcessGroup.getId())); final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(remoteProcessGroup.getIdentifier()));
flow.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(remoteProcessGroup, revision, accessPolicy, status, bulletins)); flow.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(dto, revision, accessPolicy, status, bulletins));
} }
return flow; return flow;