Package org.apache.oodt.cas.workflow.gui.model

Examples of org.apache.oodt.cas.workflow.gui.model.ModelGraph


        if (rootChildren.item(i).getNodeType() == Node.ELEMENT_NODE
            && !rootChildren.item(i).getNodeName().equals("configuration")
            && !rootChildren.item(i).getNodeName().equals("event")) {
          System.out.println("node name: ["
              + rootChildren.item(i).getNodeName() + "]");
          ModelGraph graph = this.loadGraph(rootElements, new FileBasedElement(
              root.getFile(), (Element) rootChildren.item(i)), new Metadata(),
              globalConfGroups, supportedProcessorIds);
          this.graphs.add(graph);
        }
    }
View Full Code Here


    for (ModelGraph graph : graphs) {
      HashSet<String> names = new HashSet<String>();
      Vector<ModelGraph> stack = new Vector<ModelGraph>();
      stack.add(graph);
      while (!stack.isEmpty()) {
        ModelGraph currentGraph = stack.remove(0);
        String currentId = currentGraph.getId();
        for (int i = 1; names.contains(currentId); i++)
          currentId = currentGraph.getId() + "-" + i;
        names.add(currentId);
        if (!currentId.equals(currentGraph.getId()))
          currentGraph.getModel().setModelId(currentId);
        stack.addAll(currentGraph.getChildren());
      }
    }
  }
View Full Code Here

    }

    if (modelId == null && modelIdRef == null)
      modelId = UUID.randomUUID().toString();

    ModelGraph graph = null;
    if (modelId != null) {

      if (workflowNode.getElement().getNodeName().equals("workflow")
          || workflowNode.getElement().getNodeName().equals("conditions")
          || workflowNode.getElement().getNodeName().equals("tasks")) {
        if (executionType == null) {
          LOG.log(Level.WARNING, "workflow model '"
              + workflowNode.getElement().getNodeName()
              + "' missing execution type: assuming sequential");
          executionType = "sequential";
        }
      } else {
        executionType = workflowNode.getElement().getNodeName();
      }

      if (!supportedProcessorIds.contains(executionType))
        LOG.log(Level.WARNING, "Unsupported execution type id '"
            + executionType + "'");

      ModelNode modelNode = new ModelNode(workflowNode.getFile());
      modelNode.setModelId(modelId);
      modelNode.setModelName(modelName);
      modelNode.setExecutionType(executionType);
      modelNode.setStaticMetadata(staticMetadata);
      modelNode.setExcusedSubProcessorIds(excused);
      modelNode.setInstanceClass(clazz);
      modelNode.setEntryPoint(entryPoint);
      modelNode.setTimeout(timeout);
      modelNode.setOptional(optional);

      loadConfiguration(rootElements, workflowNode, modelNode, globalConfGroups);

      graph = new ModelGraph(modelNode);

      boolean loadedPreConditions = false;
      NodeList children = workflowNode.getElement().getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        Node curChild = children.item(i);
        if (curChild.getNodeType() == Node.ELEMENT_NODE) {
          if (curChild.getNodeName().equals("conditions")) {
            boolean isPreCondition = !loadedPreConditions;
            String type = ((Element) curChild).getAttribute("type");
            if (type.length() > 0)
              isPreCondition = type.toLowerCase().equals("pre");
            if (isPreCondition)
              graph.setPreConditions(this.loadGraph(rootElements,
                  new FileBasedElement(workflowNode.getFile(),
                      (Element) curChild), new Metadata(staticMetadata),
                  globalConfGroups, supportedProcessorIds));
            else
              graph.setPostConditions(this.loadGraph(rootElements,
                  new FileBasedElement(workflowNode.getFile(),
                      (Element) curChild), new Metadata(staticMetadata),
                  globalConfGroups, supportedProcessorIds));
            loadedPreConditions = true;
          } else if (!curChild.getNodeName().equals("configuration")
              && !curChild.getNodeName().equals("requiredMetFields")) {
            graph.addChild(this.loadGraph(rootElements, new FileBasedElement(
                workflowNode.getFile(), (Element) curChild), new Metadata(
                staticMetadata), globalConfGroups, supportedProcessorIds));

          }
        }
      }

    } else if (modelIdRef != null) {
      graph = this.findGraph(rootElements, modelIdRef, new Metadata(
          staticMetadata), globalConfGroups, supportedProcessorIds);
      if (graph == null)
        throw new Exception("Workflow '" + modelIdRef
            + "' has not been defined in this context");
      graph.setIsRef(true);
      graph.getModel().setStaticMetadata(new Metadata());
      loadConfiguration(rootElements, workflowNode, graph.getModel(),
          globalConfGroups);
      graph.getModel().setAlias(alias);
    }

    if (entryPoint && graph.getParent() != null) {
      this.graphs.add(graph);
    }

    return graph;
  }
View Full Code Here

    return false;
  }

  public static void updateGraphModelId(ViewState state, String id,
      String newModelId) {
    ModelGraph graph = find(state.getGraphs(), id);
    if (graph.getParent() != null
        && graph.getParent().getModel().getExcusedSubProcessorIds()
            .contains(graph.getModel().getModelId())) {
      graph.getParent().getModel().getExcusedSubProcessorIds()
          .remove(graph.getModel().getModelId());
      graph.getParent().getModel().getExcusedSubProcessorIds().add(newModelId);
    }
    graph.getModel().setModelId(newModelId);
  }
View Full Code Here

    graph.getModel().setModelId(newModelId);
  }

  public static void addChild(List<ModelGraph> graphs, String parentId,
      ModelGraph child) {
    ModelGraph parent = find(graphs, parentId);
    if (parent != null)
      parent.addChild(child);
  }
View Full Code Here

          rootGraphs.add(graph);
        }
      }
    }
    for (int i = 0; i < rootGraphs.size(); i++) {
      ModelGraph rootGraph = rootGraphs.get(i);
      for (int j = 0; j < rootGraphs.size(); j++) {
        if (i != j
            && rootGraphs.get(j).recursiveFind(
                rootGraph.getModel().getModelId()) != null) {
          rootGraphs.remove(i--);
          break;
        }
      }
View Full Code Here

      ModelGraph graph) {
    for (ModelGraph rootGraph : rootGraphs) {
      if (graph.equals(rootGraph)) {
        return rootGraph;
      } else if (graph.getParent() != null) {
        ModelGraph root = findRoot(rootGraphs, graph.getParent());
        if (root != null)
          return root;
      }
    }
    return null;
View Full Code Here

  }

  public static List<ModelGraph> find(List<ModelGraph> graphs, Set<String> ids) {
    Vector<ModelGraph> foundGraphs = new Vector<ModelGraph>();
    for (String id : ids) {
      ModelGraph graph = find(graphs, id);
      if (graph != null)
        foundGraphs.add(graph);
    }
    return foundGraphs;
  }
View Full Code Here

    return foundGraphs;
  }

  public static ModelGraph find(List<ModelGraph> graphs, String id) {
    for (ModelGraph graph : graphs) {
      ModelGraph found = graph.recursiveFind(id);
      if (found != null)
        return found;
    }
    return null;
  }
View Full Code Here

  public static ModelGraph removeNode(List<ModelGraph> graphs, ModelNode node) {
    for (int i = 0; i < graphs.size(); i++) {
      if (graphs.get(i).getModel().equals(node)) {
        return graphs.remove(i);
      } else {
        ModelGraph graph = removeNode(graphs.get(i), node);
        if (graph != null)
          return graph;
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.workflow.gui.model.ModelGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.