processors = getOptionalKeyAsList(map, PROCESSORS_KEY, ProcessorSchema::new, wrapperName); controllerServiceSchemas = getOptionalKeyAsList(map, CONTROLLER_SERVICES_KEY, ControllerServiceSchema::new, wrapperName); funnels = getOptionalKeyAsList(map, FUNNELS_KEY, FunnelSchema::new, wrapperName); remoteProcessGroups = getOptionalKeyAsList(map, REMOTE_PROCESS_GROUPS_KEY, RemoteProcessGroupSchema::new, wrapperName); connections = getOptionalKeyAsList(map, CONNECTIONS_KEY, ConnectionSchema::new, wrapperName); inputPortSchemas = getOptionalKeyAsList(map, INPUT_PORTS_KEY, m -> new PortSchema(m, "InputPort(id: {id}, name: {name})"), wrapperName); outputPortSchemas = getOptionalKeyAsList(map, OUTPUT_PORTS_KEY, m -> new PortSchema(m, "OutputPort(id: {id}, name: {name})"), wrapperName); processGroupSchemas = getOptionalKeyAsList(map, PROCESS_GROUPS_KEY, m -> new ProcessGroupSchema(m, "ProcessGroup(id: {id}, name: {name})"), wrapperName); addValidationIssue(INPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported"); addValidationIssue(OUTPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported"); } else if (ID_DEFAULT.equals(getId())) { addValidationIssue(ID_KEY, wrapperName, "must be set to a value not " + ID_DEFAULT + " if not in root group"); Set<String> portIds = getPortIds(); connections.stream().filter(c -> portIds.contains(c.getSourceId())).forEachOrdered(c -> c.setNeedsSourceRelationships(false)); connections.stream().filter(c -> funnelIds.contains(c.getSourceId())).forEachOrdered(c -> c.setNeedsSourceRelationships(false)); addIssuesIfNotNull(processors); addIssuesIfNotNull(controllerServiceSchemas); addIssuesIfNotNull(remoteProcessGroups); addIssuesIfNotNull(processGroupSchemas); addIssuesIfNotNull(funnels); addIssuesIfNotNull(connections);
public Map<String, Object> toMap() { Map<String, Object> result = mapSupplier.get(); String id = getId(); if (!ID_DEFAULT.equals(id)) { result.put(ID_KEY, id); } StringUtil.doIfNotNullOrEmpty(getName(), name -> result.put(NAME_KEY, name)); putListIfNotNull(result, PROCESSORS_KEY, processors); putListIfNotNull(result, CONTROLLER_SERVICES_KEY, controllerServiceSchemas); putListIfNotNull(result, PROCESS_GROUPS_KEY, processGroupSchemas); putListIfNotNull(result, INPUT_PORTS_KEY, inputPortSchemas); putListIfNotNull(result, OUTPUT_PORTS_KEY, outputPortSchemas); putListIfNotNull(result, FUNNELS_KEY, funnels); putListIfNotNull(result, CONNECTIONS_KEY, connections); putListIfNotNull(result, REMOTE_PROCESS_GROUPS_KEY, remoteProcessGroups); return result; }
protected static void getParentIdMap(ProcessGroupSchema processGroupSchema, Map<String, String> output, Function<ProcessGroupSchema, Collection<? extends BaseSchemaWithId>> schemaAccessor) { schemaAccessor.apply(processGroupSchema).forEach(p -> output.put(p.getId(), processGroupSchema.getId())); processGroupSchema.getProcessGroupSchemas().forEach(p -> getParentIdMap(p, output, schemaAccessor)); }
protected static void addProcessGroup(Document doc, Element element, ProcessGroupSchema processGroupSchema, ParentGroupIdResolver parentGroupIdResolver) throws ConfigurationChangeException { try { String processGroupId = processGroupSchema.getId(); addTextElement(element, "id", processGroupId); addTextElement(element, "name", processGroupSchema.getName()); addPosition(element); addTextElement(element, "comment", processGroupSchema.getComment()); for (ProcessorSchema processorConfig : processGroupSchema.getProcessors()) { addProcessor(element, processorConfig); for (PortSchema portSchema : processGroupSchema.getInputPortSchemas()) { addPort(doc, element, portSchema, "inputPort"); for (PortSchema portSchema : processGroupSchema.getOutputPortSchemas()) { addPort(doc, element, portSchema, "outputPort"); for (FunnelSchema funnelSchema : processGroupSchema.getFunnels()) { addFunnel(element, funnelSchema); for (ProcessGroupSchema child : processGroupSchema.getProcessGroupSchemas()) { Element processGroups = doc.createElement("processGroup"); element.appendChild(processGroups); for (RemoteProcessGroupSchema remoteProcessGroupSchema : processGroupSchema.getRemoteProcessGroups()) { addRemoteProcessGroup(element, remoteProcessGroupSchema); for (ConnectionSchema connectionConfig : processGroupSchema.getConnections()) { addConnection(element, connectionConfig, parentGroupIdResolver);
securityProperties = getMapAsType(map, SECURITY_PROPS_KEY, SecurityPropertiesSchema.class, TOP_LEVEL_NAME, false); processGroupSchema = new ProcessGroupSchema(map, TOP_LEVEL_NAME); List<ConnectionSchema> allConnectionSchemas = allProcessGroups.stream().flatMap(p -> p.getConnections().stream()).collect(Collectors.toList()); List<RemoteProcessGroupSchema> allRemoteProcessGroups = allProcessGroups.stream().flatMap(p -> p.getRemoteProcessGroups().stream()).collect(Collectors.toList()); List<String> allProcessorIds = allProcessGroups.stream().flatMap(p -> p.getProcessors().stream()).map(ProcessorSchema::getId).collect(Collectors.toList()); List<String> allControllerServiceIds = allProcessGroups.stream().flatMap(p -> p.getControllerServices().stream()).map(ControllerServiceSchema::getId).collect(Collectors.toList()); List<String> allFunnelIds = allProcessGroups.stream().flatMap(p -> p.getFunnels().stream()).map(FunnelSchema::getId).collect(Collectors.toList()); List<String> allConnectionIds = allConnectionSchemas.stream().map(ConnectionSchema::getId).collect(Collectors.toList()); List<String> allRemoteProcessGroupNames = allRemoteProcessGroups.stream().map(RemoteProcessGroupSchema::getName).collect(Collectors.toList()); List<String> allRemoteOutputPortIds = allRemoteProcessGroups.stream().filter(r -> r.getOutputPorts() != null) .flatMap(r -> r.getOutputPorts().stream()).map(RemotePortSchema::getId).collect(Collectors.toList()); List<String> allInputPortIds = allProcessGroups.stream().flatMap(p -> p.getInputPortSchemas().stream()).map(PortSchema::getId).collect(Collectors.toList()); List<String> allOutputPortIds = allProcessGroups.stream().flatMap(p -> p.getOutputPortSchemas().stream()).map(PortSchema::getId).collect(Collectors.toList());
protected static void getRemotePortParentIdMap(ProcessGroupSchema processGroupSchema, Map<String, String> output, Function<RemoteProcessGroupSchema, List<RemotePortSchema>> getPortsFunction) { for (RemoteProcessGroupSchema remoteProcessGroupSchema : processGroupSchema.getRemoteProcessGroups()) { for (RemotePortSchema remotePortSchema : getPortsFunction.apply(remoteProcessGroupSchema)) { output.put(remotePortSchema.getId(), remoteProcessGroupSchema.getId()); } } processGroupSchema.getProcessGroupSchemas().forEach(p -> getRemotePortParentIdMap(p, output, getPortsFunction)); }
private static void addProcessGroups(ProcessGroupSchema processGroupSchema, List<ProcessGroupSchema> result) { result.add(processGroupSchema); processGroupSchema.getProcessGroupSchemas().forEach(p -> addProcessGroups(p, result)); }