Example #1
0
  void update(java.util.Map<String, TemplateDescriptor> descriptors, String[] removeTemplates)
      throws UpdateFailedException {
    //
    // Note: _descriptors is updated by Application
    //

    //
    // One big set of removes
    //
    removeChildren(removeTemplates);

    //
    // One big set of updates, followed by inserts
    //
    java.util.List<TreeNodeBase> newChildren = new java.util.ArrayList<>();
    java.util.List<TreeNodeBase> updatedChildren = new java.util.LinkedList<>();

    for (java.util.Map.Entry<String, TemplateDescriptor> p : descriptors.entrySet()) {
      String name = p.getKey();
      TemplateDescriptor templateDescriptor = p.getValue();
      ServiceTemplate child = (ServiceTemplate) findChild(name);
      if (child == null) {
        newChildren.add(new ServiceTemplate(false, this, name, templateDescriptor));
      } else {
        child.rebuild(templateDescriptor);
        updatedChildren.add(child);
      }
    }

    childrenChanged(updatedChildren);
    insertChildren(newChildren, true);
  }
Example #2
0
 public static java.util.Map<String, TemplateDescriptor> copyDescriptors(
     java.util.Map<String, TemplateDescriptor> descriptors) {
   java.util.Map<String, TemplateDescriptor> copy = new java.util.HashMap<>();
   for (java.util.Map.Entry<String, TemplateDescriptor> p : descriptors.entrySet()) {
     copy.put(p.getKey(), ServiceTemplate.copyDescriptor(p.getValue()));
   }
   return copy;
 }