Example #1
0
  @Override
  public Template createTemplate(TemplateDTO templateDTO, String groupId) {
    final ProcessGroup processGroup = flowController.getGroup(groupId);
    if (processGroup == null) {
      throw new ResourceNotFoundException("Could not find Process Group with ID " + groupId);
    }

    TemplateUtils.scrubTemplate(templateDTO);
    final Template template = new Template(templateDTO);
    processGroup.addTemplate(template);

    return template;
  }
  private void addProcessGroup(
      final Element parentElement, final ProcessGroup group, final String elementName) {
    final Document doc = parentElement.getOwnerDocument();
    final Element element = doc.createElement(elementName);
    parentElement.appendChild(element);
    addTextElement(element, "id", group.getIdentifier());
    addTextElement(element, "name", group.getName());
    addPosition(element, group.getPosition());
    addTextElement(element, "comment", group.getComments());

    for (final ProcessorNode processor : group.getProcessors()) {
      addProcessor(element, processor);
    }

    if (group.isRootGroup()) {
      for (final Port port : group.getInputPorts()) {
        addRootGroupPort(element, (RootGroupPort) port, "inputPort");
      }

      for (final Port port : group.getOutputPorts()) {
        addRootGroupPort(element, (RootGroupPort) port, "outputPort");
      }
    } else {
      for (final Port port : group.getInputPorts()) {
        addPort(element, port, "inputPort");
      }

      for (final Port port : group.getOutputPorts()) {
        addPort(element, port, "outputPort");
      }
    }

    for (final Label label : group.getLabels()) {
      addLabel(element, label);
    }

    for (final Funnel funnel : group.getFunnels()) {
      addFunnel(element, funnel);
    }

    for (final ProcessGroup childGroup : group.getProcessGroups()) {
      addProcessGroup(element, childGroup, "processGroup");
    }

    for (final RemoteProcessGroup remoteRef : group.getRemoteProcessGroups()) {
      addRemoteProcessGroup(element, remoteRef);
    }

    for (final Connection connection : group.getConnections()) {
      addConnection(element, connection);
    }
  }