NIFI-2425 fixed ControllerService referebcing in DTOs/Templates. This closes #770

This commit is contained in:
Oleg Zhurakousky 2016-08-02 07:03:14 -04:00 committed by Matt Gilman
parent c10d11d378
commit df11e1d2c0
2 changed files with 30 additions and 5 deletions

View File

@ -18,6 +18,8 @@ package org.apache.nifi.web.api.dto;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.UUID; import java.util.UUID;
@ -207,8 +209,33 @@ public class FlowSnippetDTO {
id = UUID.fromString(componentDto.getParentGroupId()); id = UUID.fromString(componentDto.getParentGroupId());
id = new UUID(id.getMostSignificantBits(), 0); id = new UUID(id.getMostSignificantBits(), 0);
componentDto.setParentGroupId(id.toString()); componentDto.setParentGroupId(id.toString());
if (componentDto instanceof ControllerServiceDTO) {
if (componentDto instanceof ConnectionDTO) { ControllerServiceDTO csDTO = (ControllerServiceDTO) componentDto;
Map<String, PropertyDescriptorDTO> map = csDTO.getDescriptors();
Map<String, String> props = csDTO.getProperties();
for (Entry<String, PropertyDescriptorDTO> entry : map.entrySet()) {
if (entry.getValue().getIdentifiesControllerService() != null) {
String key = entry.getKey();
String value = props.get(key);
id = UUID.fromString(value);
id = new UUID(id.getMostSignificantBits(), 0);
props.put(key, id.toString());
}
}
} else if (componentDto instanceof ProcessorDTO) {
ProcessorDTO processorDTO = (ProcessorDTO) componentDto;
Map<String, PropertyDescriptorDTO> map = processorDTO.getConfig().getDescriptors();
Map<String, String> props = processorDTO.getConfig().getProperties();
for (Entry<String, PropertyDescriptorDTO> entry : map.entrySet()) {
if (entry.getValue().getIdentifiesControllerService() != null) {
String key = entry.getKey();
String value = props.get(key);
id = UUID.fromString(value);
id = new UUID(id.getMostSignificantBits(), 0);
props.put(key, id.toString());
}
}
} else if (componentDto instanceof ConnectionDTO) {
ConnectionDTO connectionDTO = (ConnectionDTO) componentDto; ConnectionDTO connectionDTO = (ConnectionDTO) componentDto;
ConnectableDTO cdto = connectionDTO.getSource(); ConnectableDTO cdto = connectionDTO.getSource();
@ -228,8 +255,7 @@ public class FlowSnippetDTO {
id = UUID.fromString(cdto.getGroupId()); id = UUID.fromString(cdto.getGroupId());
id = new UUID(id.getMostSignificantBits(), 0); id = new UUID(id.getMostSignificantBits(), 0);
cdto.setGroupId(id.toString()); cdto.setGroupId(id.toString());
} } else if (componentDto instanceof ProcessGroupDTO) {
if (componentDto instanceof ProcessGroupDTO) {
FlowSnippetDTO fsDTO = ((ProcessGroupDTO) componentDto).getContents(); FlowSnippetDTO fsDTO = ((ProcessGroupDTO) componentDto).getContents();
this.removeInstanceIdentifierIfNecessary(fsDTO.getConnections()); this.removeInstanceIdentifierIfNecessary(fsDTO.getConnections());

View File

@ -188,7 +188,6 @@ public class TemplateUtils {
processorConfig.setCustomUiUrl(null); processorConfig.setCustomUiUrl(null);
processorConfig.setDefaultConcurrentTasks(null); processorConfig.setDefaultConcurrentTasks(null);
processorConfig.setDefaultSchedulingPeriod(null); processorConfig.setDefaultSchedulingPeriod(null);
processorConfig.setDescriptors(null);
processorConfig.setAutoTerminatedRelationships(null); processorConfig.setAutoTerminatedRelationships(null);
} }