You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2017/07/17 23:06:04 UTC
[49/88] [abbrv] [partial] oodt git commit: Record change for OODT-836,
OODT-837.
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java
deleted file mode 100644
index 3305763..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.model;
-
-//OODT imports
-import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
-import org.apache.oodt.cas.workflow.gui.util.GuiUtils;
-
-//JDK imports
-import java.util.List;
-import java.util.Stack;
-import java.util.Vector;
-
-/**
- *
- *
- * The graph to display per workflow in the Workflow Editor GUI.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public class ModelGraph {
-
- private ModelGraph parent;
- private ModelNode model;
- private ModelGraph preConditions;
- private Vector<ModelGraph> children;
- private ModelGraph postConditions;
- private boolean isPreCondition;
- private boolean isPostCondition;
-
- public ModelGraph(ModelNode model) {
- this.isPreCondition = isPostCondition = false;
- this.model = model;
- this.children = new Vector<ModelGraph>();
- if (this.model.isParentType()) {
- this.addChild(new ModelGraph(GuiUtils.createDummyNode()));
- }
- }
-
- public void setIsRef(boolean isRef) {
- Stack<ModelGraph> stack = new Stack<ModelGraph>();
- stack.add(this);
- while (!stack.empty()) {
- ModelGraph curGraph = stack.pop();
- curGraph.getModel().setIsRef(isRef);
- stack.addAll(curGraph.getChildren());
- if (curGraph.getPreConditions() != null) {
- stack.add(curGraph.getPreConditions());
- }
- if (curGraph.getPostConditions() != null) {
- stack.add(curGraph.getPostConditions());
- }
- }
- }
-
- public boolean isCondition() {
- return this.isPreCondition || this.isPostCondition;
- }
-
- public boolean isExcused() {
- return this.parent != null
- && this.parent.getModel().getExcusedSubProcessorIds()
- .contains(this.getModel().getModelId());
- }
-
- public String getId() {
- return model.getId();
- }
-
- public void setParent(ModelGraph parent) {
- if (this.parent != null) {
- if (this.isCondition() && !this.parent.isCondition()) {
- if (this.isPreCondition) {
- this.parent.preConditions = null;
- } else {
- this.parent.postConditions = null;
- }
- } else {
- this.parent.removeChild(this);
- }
- }
- this.parent = parent;
- if (!this.getModel().isRef() && parent != null && parent.getModel().isRef()) {
- this.getModel().setIsRef(true);
- }
- }
-
- public ModelGraph getParent() {
- return this.parent;
- }
-
- public ModelGraph getRootParent() {
- if (this.parent == null) {
- return this;
- } else {
- return this.parent.getRootParent();
- }
- }
-
- public List<ModelGraph> getPathFromRootParent() {
- Vector<ModelGraph> path = new Vector<ModelGraph>();
- ModelGraph curGraph = this;
- while (curGraph != null) {
- path.add(0, curGraph);
- curGraph = this.parent;
- }
- return path;
- }
-
- public void addChild(ModelGraph graph) {
- if (this.children.size() == 1
- && GuiUtils.isDummyNode(this.children.get(0).getModel())) {
- this.children.clear();
- }
- this.children.add(graph);
- graph.setParent(this);
- }
-
- public void removeChild(ModelGraph graph) {
- this.children.remove(graph);
- this.getModel().getExcusedSubProcessorIds()
- .remove(graph.getModel().getModelId());
- graph.parent = null;
- if (this.children.size() == 0) {
- this.addChild(new ModelGraph(GuiUtils.createDummyNode()));
- }
- }
-
- public List<ModelGraph> getChildren() {
- if (this.getModel().isParentType() && children.size() == 0) {
- this.addChild(new ModelGraph(GuiUtils.createDummyNode()));
- }
- return children;
- }
-
- public boolean hasChildren() {
- if (this.children.size() == 1
- && GuiUtils.isDummyNode(this.children.get(0).getModel())) {
- return false;
- } else {
- return this.children.size() > 0;
- }
- }
-
- public ModelNode getModel() {
- return model;
- }
-
- public void setModel(ModelNode model) {
- this.model = model;
- }
-
- public Metadata getInheritedStaticMetadata(ViewState state) {
- Metadata m = new Metadata();
- if (this.parent != null) {
- m.replaceMetadata(this.parent.getInheritedStaticMetadata(state));
- if (this.parent.getModel().getStaticMetadata() != null) {
- m.replaceMetadata(this.parent.getModel().getStaticMetadata());
- }
- if (this.parent.getModel().getExtendsConfig() != null) {
- for (String configGroup : this.parent.getModel().getExtendsConfig()) {
- m.replaceMetadata(state.getGlobalConfigGroups().get(configGroup)
- .getMetadata());
- }
- }
- }
- return m;
- }
-
- public ModelGraph getPreConditions() {
- return preConditions;
- }
-
- public void setPreConditions(ModelGraph preConditions) {
- if (this.preConditions != null) {
- this.preConditions.setParent(null);
- }
- Stack<ModelGraph> stack = new Stack<ModelGraph>();
- stack.add(preConditions);
- while (!stack.empty()) {
- ModelGraph graph = stack.pop();
- graph.isPreCondition = true;
- stack.addAll(graph.getChildren());
- }
- (this.preConditions = preConditions).setParent(this);
- }
-
- public ModelGraph getPostConditions() {
- return postConditions;
- }
-
- public void setPostConditions(ModelGraph postConditions) {
- if (this.postConditions != null) {
- this.postConditions.setParent(null);
- }
- Stack<ModelGraph> stack = new Stack<ModelGraph>();
- stack.add(postConditions);
- while (!stack.empty()) {
- ModelGraph graph = stack.pop();
- graph.isPostCondition = true;
- stack.addAll(graph.getChildren());
- }
- (this.postConditions = postConditions).setParent(this);
- }
-
- public ModelGraph recursiveFind(String id) {
- Stack<ModelGraph> stack = new Stack<ModelGraph>();
- stack.add(this);
- while (!stack.empty()) {
- ModelGraph curGraph = stack.pop();
- if (curGraph.getId().equals(id)) {
- return curGraph;
- }
- stack.addAll(curGraph.getChildren());
- if (curGraph.getPreConditions() != null) {
- stack.add(curGraph.getPreConditions());
- }
- if (curGraph.getPostConditions() != null) {
- stack.add(curGraph.getPostConditions());
- }
- }
- return null;
- }
-
- public ModelGraph recursiveFindByModelId(String modelId) {
- Stack<ModelGraph> stack = new Stack<ModelGraph>();
- stack.add(this);
- while (!stack.empty()) {
- ModelGraph curGraph = stack.pop();
- if (curGraph.getModel().getModelId().equals(modelId)) {
- return curGraph;
- }
- stack.addAll(curGraph.getChildren());
- if (curGraph.getPreConditions() != null) {
- stack.add(curGraph.getPreConditions());
- }
- if (curGraph.getPostConditions() != null) {
- stack.add(curGraph.getPostConditions());
- }
- }
- return null;
- }
-
- public List<ModelGraph> getLeafNodes() {
- Vector<ModelGraph> leafNodes = new Vector<ModelGraph>();
- Stack<ModelGraph> stack = new Stack<ModelGraph>();
- stack.add(this);
- while (!stack.empty()) {
- ModelGraph curGraph = stack.pop();
- if (curGraph.getChildren().size() == 0) {
- leafNodes.add(curGraph);
- } else {
- stack.addAll(curGraph.getChildren());
- }
- }
- return leafNodes;
- }
-
- public int hashCode() {
- return this.getId().hashCode();
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof ModelGraph) {
- return this.getId().equals(((ModelGraph) obj).getId());
- } else {
- return false;
- }
- }
-
- public String toString() {
- return this.getModel().getModelId();
- }
-
- public ModelGraph clone() {
- ModelNode cloneNode = this.model.clone();
- ModelGraph clone = new ModelGraph(cloneNode);
- for (ModelGraph child : this.children) {
- clone.addChild(child.clone());
- }
- if (this.preConditions != null) {
- clone.setPreConditions(this.preConditions.clone());
- }
- if (this.postConditions != null) {
- clone.setPostConditions(this.postConditions.clone());
- }
- return clone;
- }
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java
deleted file mode 100644
index 20a4562..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.model;
-
-//JDK imports
-import java.awt.Color;
-import java.io.File;
-import java.util.List;
-import java.util.UUID;
-import java.util.Vector;
-
-//OODT imports
-import org.apache.oodt.cas.metadata.Metadata;
-
-/**
- *
- *
- * Represents a node in the Workflow Model graph.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public class ModelNode {
-
- private String id;
- private String alias;
- private boolean isRef;
- private File file;
- private boolean textVisible;
- private boolean entryPoint;
- private List<String> configGroups;
- private String executionType;
- private String modelId;
- private String modelName;
- private String instanceClass;
- private List<String> excusedSubProcessorIds;
- private Metadata staticMetadata;
- private long timeout;
- private boolean optional;
-
- public ModelNode(File file) {
- super();
- this.file = file;
- this.id = UUID.randomUUID().toString();
- this.isRef = false;
- this.executionType = "task";
- this.textVisible = true;
- this.entryPoint = false;
- this.configGroups = new Vector<String>();
- this.modelId = null;
- this.modelName = null;
- this.instanceClass = null;
- this.excusedSubProcessorIds = new Vector<String>();
- this.staticMetadata = new Metadata();
- this.timeout = -1;
- this.optional = false;
- }
-
- public ModelNode(File file, String modelId) {
- this(file);
- this.setModelId(modelId);
- this.setModelName(modelId);
- }
-
- public ModelNode(File file, String modelId, boolean isRef) {
- this(file, modelId);
- this.isRef = isRef;
- }
-
- public String getId() {
- return this.id;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public String getAlias() {
- return alias;
- }
-
- public void setIsRef(boolean isRef) {
- this.isRef = isRef;
- }
-
- public boolean isRef() {
- return this.isRef;
- }
-
- public File getFile() {
- return this.file;
- }
-
- public void setExtendsConfig(List<String> configGroups) {
- this.configGroups.clear();
- this.configGroups.addAll(configGroups);
- }
-
- public List<String> getExtendsConfig() {
- return this.configGroups;
- }
-
- public void setTextVisible(boolean textVisible) {
- this.textVisible = textVisible;
- }
-
- public void setEntryPoint(boolean entryPoint) {
- this.entryPoint = entryPoint;
- }
-
- public boolean isEntryPoint() {
- return this.entryPoint;
- }
-
- public boolean isParentType() {
- return !(this.getExecutionType().equals("task") || this.getExecutionType()
- .equals("condition"));
- }
-
- public Color getColor() {
- if (this.isParentType()) {
- if (this.getExecutionType().equals("sequential")) {
- return new Color(100, 149, 237);
- } else if (this.getExecutionType().equals("parallel")) {
- return new Color(143, 188, 143);
- } else {
- return Color.darkGray;
- }
- } else {
- if (this.getExecutionType().equals("task")) {
- return Color.orange;
- } else {
- return Color.cyan;
- }
- }
- }
-
- public Color getGradientColor() {
- if (this.isParentType()) {
- if (this.getExecutionType().equals("sequential")) {
- return new Color(200, 200, 200);
- } else if (this.getExecutionType().equals("parallel")) {
- return new Color(200, 200, 200);
- } else {
- return Color.white;
- }
- } else {
- return Color.darkGray;
- }
- }
-
- public String getModelId() {
- return modelId;
- }
-
- public String getModelName() {
- if (modelName == null) {
- return modelId;
- } else {
- return modelName;
- }
- }
-
- public String getExecutionType() {
- return executionType;
- }
-
- public String getInstanceClass() {
- return instanceClass;
- }
-
- public List<String> getExcusedSubProcessorIds() {
- if (this.excusedSubProcessorIds == null) {
- this.excusedSubProcessorIds = new Vector<String>();
- }
- return this.excusedSubProcessorIds;
- }
-
- public Metadata getStaticMetadata() {
- return staticMetadata != null ? this.staticMetadata
- : (this.staticMetadata = new Metadata());
- }
-
- public int hashCode() {
- return this.getId().hashCode();
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof ModelNode) {
- return this.getId().equals(((ModelNode) obj).getId());
- } else {
- return false;
- }
- }
-
- public String toString() {
- if (this.textVisible) {
- if (this.isParentType()) {
- return this.getModelName() + " : " + this.getExecutionType();
- } else {
- return this.getModelName();
- }
- } else {
- return null;
- }
- }
-
- public ModelNode clone() {
- ModelNode clone = new ModelNode(this.file);
- clone.id = this.id;
- if (this.excusedSubProcessorIds != null) {
- clone.excusedSubProcessorIds = new Vector<String>(
- this.excusedSubProcessorIds);
- }
- clone.executionType = this.executionType;
- clone.instanceClass = this.instanceClass;
- clone.modelId = this.modelId;
- clone.modelName = this.modelName;
- clone.staticMetadata = null;
- clone.textVisible = this.textVisible;
- if (this.staticMetadata != null) {
- clone.staticMetadata = new Metadata(this.staticMetadata);
- }
- return clone;
- }
-
- /**
- * @param modelId
- * the modelId to set
- */
- public void setModelId(String modelId) {
- this.modelId = modelId;
- }
-
- /**
- * @param modelName
- * the modelName to set
- */
- public void setModelName(String modelName) {
- this.modelName = modelName;
- }
-
- /**
- * @param instanceClass
- * the instanceClass to set
- */
- public void setInstanceClass(String instanceClass) {
- this.instanceClass = instanceClass;
- }
-
- /**
- * @param excusedSubProcessorIds
- * the excusedSubProcessorIds to set
- */
- public void setExcusedSubProcessorIds(List<String> excusedSubProcessorIds) {
- this.excusedSubProcessorIds = excusedSubProcessorIds;
- }
-
-
-
- /**
- * @return the configGroups
- */
- public List<String> getConfigGroups() {
- return configGroups;
- }
-
-
-
- /**
- * @param configGroups the configGroups to set
- */
- public void setConfigGroups(List<String> configGroups) {
- this.configGroups = configGroups;
- }
-
-
-
- /**
- * @return the textVisible
- */
- public boolean isTextVisible() {
- return textVisible;
- }
-
-
-
- /**
- * @param id the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
-
-
-
- /**
- * @param isRef the isRef to set
- */
- public void setRef(boolean isRef) {
- this.isRef = isRef;
- }
-
-
-
- /**
- * @param file the file to set
- */
- public void setFile(File file) {
- this.file = file;
- }
-
-
-
- /**
- * @param executionType the executionType to set
- */
- public void setExecutionType(String executionType) {
- this.executionType = executionType;
- }
-
-
-
- /**
- * @param staticMetadata the staticMetadata to set
- */
- public void setStaticMetadata(Metadata staticMetadata) {
- this.staticMetadata = staticMetadata;
- }
-
- /**
- * @return the timeout
- */
- public long getTimeout() {
- return timeout;
- }
-
- /**
- * @param timeout the timeout to set
- */
- public void setTimeout(long timeout) {
- this.timeout = timeout;
- }
-
- /**
- * @return the optional
- */
- public boolean isOptional() {
- return optional;
- }
-
- /**
- * @param optional the optional to set
- */
- public void setOptional(boolean optional) {
- this.optional = optional;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java
deleted file mode 100644
index 70d54aa..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java
+++ /dev/null
@@ -1,614 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.model.repo;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
-import org.apache.oodt.cas.workflow.gui.model.ModelNode;
-import org.apache.oodt.cas.workflow.gui.util.exceptions.WorkflowException;
-import org.apache.oodt.commons.xml.XMLUtils;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-/**
- *
- * Model Repository which stores models in xml files
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public class XmlWorkflowModelRepository {
-
- private File workspace;
- private List<File> files;
- private Set<ModelGraph> graphs;
- private Map<String, ConfigGroup> globalConfigGroups;
- private static final Logger LOG = Logger
- .getLogger(XmlWorkflowModelRepository.class.getName());
-
- public XmlWorkflowModelRepository(File workspace) {
- this.files = new Vector<File>();
- if(workspace!=null) {
- for (File file : (this.workspace = workspace).listFiles()) {
- if (!file.isDirectory()) {
- this.files.add(file);
- }
- }
- }
- }
-
- public void loadGraphs(Set<String> supportedProcessorIds)
- throws XPathExpressionException, WorkflowException, IOException, SAXException, ParserConfigurationException {
- this.graphs = new HashSet<ModelGraph>();
- ConcurrentHashMap<String, ConfigGroup> globalConfGroups = new ConcurrentHashMap<String, ConfigGroup>();
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- DocumentBuilder parser = factory.newDocumentBuilder();
- List<FileBasedElement> rootElements = new Vector<FileBasedElement>();
- for (File file : files) {
- System.out.println("Loading: " + file);
- rootElements.add(new FileBasedElement(file, parser.parse(file)
- .getDocumentElement()));
- }
- for (FileBasedElement root : rootElements) {
- loadConfiguration(rootElements, root, null, globalConfGroups);
- NodeList rootChildren = root.getElement().getChildNodes();
- for (int i = 0; i < rootChildren.getLength(); i++) {
- 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);
- }
- }
- }
- ensureUniqueIds(graphs);
- this.globalConfigGroups = globalConfGroups;
- System.out.println(this.globalConfigGroups.keySet());
- }
-
- public Set<ModelGraph> getGraphs() {
- return this.graphs;
- }
-
- public Map<String, ConfigGroup> getGlobalConfigGroups() {
- return this.globalConfigGroups;
- }
-
- public void setGlobalConfigGroups(Map<String, ConfigGroup> globalConfigGroups) {
- this.globalConfigGroups = new ConcurrentHashMap<String, ConfigGroup>(
- globalConfigGroups);
- }
-
- public List<File> getFiles() {
- return this.files;
- }
-
- public void save() throws IOException, ParserConfigurationException {
- this.backupCurrentFiles();
- this.saveGraphs();
- }
-
- private void backupCurrentFiles() throws IOException {
- File backupDir = new File(this.workspace, ".backup");
- for (File file : this.files) {
- FileUtils.copyFile(file, new File(backupDir, file.getName()));
- file.delete();
- }
- this.files.clear();
- }
-
- private void saveGraphs() throws
- ParserConfigurationException {
- Map<File, Document> documents = new ConcurrentHashMap<File, Document>();
- for (ModelGraph graph : this.graphs) {
- Document document = documents.get(graph.getModel().getFile());
- if (document == null) {
- document = createDocument();
- document.appendChild(document.createElement("workflows"));
- documents.put(graph.getModel().getFile(), document);
- }
- saveGraph(graph, document.getDocumentElement(), document);
- }
- saveGlobalConfigGroups(documents);
- writeOutDocuments(documents);
- this.files = new ArrayList<File>(documents.keySet());
- }
-
- private void writeOutDocuments(Map<File, Document> documents) {
- for (Map.Entry<File, Document> file : documents.entrySet()) {
- XMLUtils.writeXmlFile(documents.get(file.getKey()), file.getKey().getAbsolutePath());
- }
- }
-
- private void saveGlobalConfigGroups(Map<File, Document> documents)
- throws ParserConfigurationException {
- File globalConfigGroupsFile = new File(workspace,
- "shared-configuration.xml");
- Document document = documents.get(globalConfigGroupsFile);
- if (document == null) {
- document = createDocument();
- document.appendChild(document.createElement("workflows"));
- documents.put(globalConfigGroupsFile, document);
- }
- for (Map.Entry<String, ConfigGroup> configName : this.globalConfigGroups.entrySet()) {
- ConfigGroup globalConfig = configName.getValue();
- Element configElem = document.createElement("configuration");
- document.getDocumentElement().appendChild(configElem);
- configElem.setAttribute("name", globalConfig.getName());
- if (!globalConfig.getExtends().isEmpty()) {
- configElem.setAttribute("extends",
- StringUtils.join(globalConfig.getExtends(), ", "));
- }
-
- String[] properties = globalConfig.getMetadata().getAllKeys()
- .toArray(new String[globalConfig.getMetadata().getAllKeys().size()]);
- Arrays.sort(properties);
- for (String property : properties) {
- Element propElem = document.createElement("property");
- configElem.appendChild(propElem);
- propElem.setAttribute("name", property);
- propElem.setAttribute("value",
- globalConfig.getMetadata().getMetadata(property));
- }
- }
- }
-
- private void saveGraph(ModelGraph graph, Element parentElem, Document document) {
- ModelNode node = graph.getModel();
-
- Element workflowElem = document.createElement(node.getExecutionType());
- parentElem.appendChild(workflowElem);
-
- if (node.isRef()) {
- workflowElem.setAttribute("id-ref", node.getModelId());
- if (node.getAlias() != null) {
- workflowElem.setAttribute("alias", node.getAlias());
- }
- saveConfiguration(node, workflowElem, document);
- } else {
- workflowElem.setAttribute("id", node.getModelId());
- workflowElem.setAttribute("name", node.getModelName());
- if (node.getInstanceClass() != null) {
- workflowElem.setAttribute("class", node.getInstanceClass());
- }
-
- saveConfiguration(node, workflowElem, document);
-
- // handle preconditions
- if (graph.getPreConditions() != null) {
- Element preConditions = document.createElement("conditions");
- workflowElem.appendChild(preConditions);
- preConditions.setAttribute("type", "pre");
- preConditions.setAttribute("execution", graph.getPreConditions()
- .getModel().getExecutionType());
- preConditions.setAttribute("timeout", String.valueOf(graph.getModel().getTimeout()));
- preConditions.setAttribute("optional", String.valueOf(graph.getModel().isOptional()));
- for (ModelGraph preCondition : graph.getPreConditions().getChildren()) {
- saveGraph(preCondition, preConditions, document);
- }
- }
-
- // handle subprocessors
- for (ModelGraph subProcessor : graph.getChildren()) {
- saveGraph(subProcessor, workflowElem, document);
- }
-
- // handle postconditions
- if (graph.getPostConditions() != null) {
- Element postConditions = document.createElement("conditions");
- workflowElem.appendChild(postConditions);
- postConditions.setAttribute("type", "post");
- postConditions.setAttribute("execution", graph.getPostConditions()
- .getModel().getExecutionType());
- postConditions.setAttribute("timeout", String.valueOf(graph.getModel().getTimeout()));
- postConditions.setAttribute("optional", String.valueOf(graph.getModel().isOptional()));
- for (ModelGraph postCondition : graph.getPostConditions().getChildren()) {
- saveGraph(postCondition, postConditions, document);
- }
- }
- }
- if (!node.getExcusedSubProcessorIds().isEmpty()) {
- workflowElem.setAttribute("excused",
- StringUtils.join(node.getExcusedSubProcessorIds(), ","));
- }
- if (node.isEntryPoint()) {
- workflowElem.setAttribute("entryPoint", "true");
- }
- }
-
- private void saveConfiguration(ModelNode node, Element workflowElem,
- Document document) {
- if (!node.getStaticMetadata().getAllKeys().isEmpty()) {
- Element configElem = document.createElement("configuration");
- workflowElem.appendChild(configElem);
- if (!node.getExtendsConfig().isEmpty()) {
- configElem.setAttribute("extends",
- StringUtils.join(node.getExtendsConfig(), ", "));
- }
- String[] properties = node.getStaticMetadata().getAllKeys()
- .toArray(new String[node.getStaticMetadata().getAllKeys().size()]);
- Arrays.sort(properties);
- for (String property : properties) {
- Element propElem = document.createElement("property");
- configElem.appendChild(propElem);
- propElem.setAttribute("name", property);
- propElem.setAttribute("value",
- node.getStaticMetadata().getMetadata(property));
- }
- }
- }
-
- private Document createDocument() throws ParserConfigurationException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- return factory.newDocumentBuilder().newDocument();
- }
-
- private void ensureUniqueIds(Set<ModelGraph> graphs) {
- 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());
- }
- }
- }
-
- private ModelGraph loadGraph(List<FileBasedElement> rootElements,
- FileBasedElement workflowNode, Metadata staticMetadata,
- ConcurrentHashMap<String, ConfigGroup> globalConfGroups,
- Set<String> supportedProcessorIds) throws XPathExpressionException, WorkflowException {
-
- String modelIdRef = null;
- String modelId = null;
- String modelName = null;
- String alias = null;
- String executionType = null;
- List<String> excused = new Vector<String>();
- String clazz = null;
- long timeout = -1;
- boolean optional = false;
- boolean entryPoint = false;
-
- NamedNodeMap attributes = workflowNode.getElement().getAttributes();
- for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
- Node node = workflowNode.getElement().getAttributes().item(i);
- if (node.getNodeName().equals("id")) {
- modelId = node.getNodeValue();
- } else if (node.getNodeName().equals("name")) {
- modelName = node.getNodeValue();
- } else if (node.getNodeName().equals("class")) {
- clazz = node.getNodeValue();
- } else if (node.getNodeName().equals("id-ref")) {
- modelIdRef = node.getNodeValue();
- } else if (node.getNodeName().equals("excused")) {
- excused.addAll(Arrays.asList(node.getNodeValue().split(",")));
- } else if (node.getNodeName().equals("entryPoint")) {
- entryPoint = Boolean.parseBoolean(node.getNodeValue());
- } else if (node.getNodeName().equals("alias")) {
- alias = node.getNodeValue();
- } else if (node.getNodeName().equals("execution")) {
- executionType = node.getNodeValue();
- } else if (node.getNodeName().equals("timeout")) {
- timeout = node.getNodeValue() != null
- && !node.getNodeValue().equals("") ? Long.valueOf(node
- .getNodeValue()) : -1;
- }
- else if(node.getNodeName().equals("optional")){
- optional = Boolean.valueOf(node.getNodeValue());
- }
- else if (node.getNodeName().startsWith("p:")) {
- staticMetadata.replaceMetadata(node.getNodeName().substring(2),
- node.getNodeValue());
- }
- }
-
- 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 WorkflowException("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;
- }
-
- protected ModelGraph findGraph(List<FileBasedElement> rootElements,
- String modelIdRef, Metadata staticMetadata,
- ConcurrentHashMap<String, ConfigGroup> globalConfGroups,
- Set<String> supportedProcessorIds) throws XPathExpressionException, WorkflowException {
- XPath xpath = XPathFactory.newInstance().newXPath();
- XPathExpression expr = xpath.compile("//*[@id = '" + modelIdRef + "']");
- for (FileBasedElement rootElement : rootElements) {
- Node node = (Node) expr.evaluate(rootElement.getElement(),
- XPathConstants.NODE);
- if (node != null) {
- return this.loadGraph(rootElements,
- new FileBasedElement(rootElement.getFile(), (Element) node),
- staticMetadata, globalConfGroups, supportedProcessorIds);
- }
- }
- return null;
- }
-
- private void loadConfiguration(List<FileBasedElement> rootElements,
- FileBasedElement workflowNode, ModelNode modelNode,
- ConcurrentHashMap<String, ConfigGroup> globalConfGroups) {
- NodeList children = workflowNode.getElement().getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node curChild = children.item(i);
- if (curChild.getNodeName().equals("configuration")) {
- Metadata curMetadata = new Metadata();
- if (modelNode != null
- && !((Element) curChild).getAttribute("extends").equals("")) {
- modelNode.setExtendsConfig(Arrays.asList(((Element) curChild)
- .getAttribute("extends").split(",")));
- }
- curMetadata.replaceMetadata(this.loadConfiguration(rootElements,
- curChild, globalConfGroups));
- if (!((Element) curChild).getAttribute("name").equals("")) {
- ConfigGroup configGroup = new ConfigGroup(
- ((Element) curChild).getAttribute("name"), curMetadata);
- if (modelNode != null) {
- List<String> extendsConfig = new Vector<String>(
- modelNode.getExtendsConfig());
- configGroup.addAllExtends(extendsConfig);
- extendsConfig.add(configGroup.getName());
- modelNode.setExtendsConfig(extendsConfig);
- }
- globalConfGroups.put(((Element) curChild).getAttribute("name"),
- configGroup);
- } else if (modelNode != null) {
- modelNode.setStaticMetadata(curMetadata);
- }
- }
- }
- }
-
- private Metadata loadConfiguration(List<FileBasedElement> rootElements,
- Node configNode, ConcurrentHashMap<String, ConfigGroup> globalConfGroups) {
- Metadata curMetadata = new Metadata();
- NodeList curGrandChildren = configNode.getChildNodes();
- for (int k = 0; k < curGrandChildren.getLength(); k++) {
- if (curGrandChildren.item(k).getNodeName().equals("property")) {
- Element property = (Element) curGrandChildren.item(k);
- String delim = property.getAttribute("delim");
- String envReplace = property.getAttribute("envReplace");
- String name = property.getAttribute("name");
- String value = property.getAttribute("value");
- if (Boolean.parseBoolean(envReplace)) {
- curMetadata.replaceMetadata(name + "/envReplace", "true");
- }
- List<String> values = new Vector<String>();
- if (delim.length() > 0) {
- values.addAll(Arrays.asList(value.split("\\" + delim)));
- } else {
- values.add(value);
- }
- curMetadata.replaceMetadata(name, values);
- }
- }
- return curMetadata;
- }
-
- private class FileBasedElement {
-
- private File file;
- private Element element;
-
- public FileBasedElement(File file, Element element) {
- this.file = file;
- this.element = element;
- }
-
- public File getFile() {
- return this.file;
- }
-
- public Element getElement() {
- return this.element;
- }
-
- }
-
- public class ConfigGroup {
-
- private String name;
- private Metadata metadata;
- private List<String> extendsConfig;
-
- public ConfigGroup(String name, Metadata metadata) {
- this.name = name;
- this.metadata = metadata;
- this.extendsConfig = new Vector<String>();
- }
-
- public String getName() {
- return this.name;
- }
-
- public Metadata getMetadata() {
- return this.metadata;
- }
-
- public void addExtends(String child) {
- this.extendsConfig.add(child);
- }
-
- public void addAllExtends(List<String> children) {
- this.extendsConfig.addAll(children);
- }
-
- public void removeExtends(String child) {
- this.extendsConfig.remove(child);
- }
-
- public List<String> getExtends() {
- return this.extendsConfig;
- }
-
- public int hashCode() {
- return this.name.hashCode();
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof ConfigGroup) {
- ConfigGroup comp = (ConfigGroup) obj;
- return comp.name.equals(this.name);
- } else {
- return false;
- }
- }
-
- public String toString() {
- return this.name;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java
deleted file mode 100644
index 8cf683f..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.model.repo;
-
-//JDK imports
-import java.io.File;
-
-/**
- *
- * Factory for creating xml model repositories
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public class XmlWorkflowModelRepositoryFactory {
-
- private String workspace;
-
- public XmlWorkflowModelRepository createModelRepository() {
- if (workspace == null) {
- return null;
- }
- if (!new File(workspace).exists()) {
- new File(workspace).mkdirs();
- }
- return new XmlWorkflowModelRepository(new File(workspace));
- }
-
- public void setWorkspace(String workspace) {
- this.workspace = workspace;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java
deleted file mode 100644
index bb2ca24..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective;
-
-//JDK imports
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-//OODT imports
-import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
-import org.apache.oodt.cas.workflow.gui.perspective.view.View.Mode;
-
-/**
- *
- * A multi-state display perspective.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public abstract class MultiStatePerspective extends Perspective {
-
- private static final long serialVersionUID = -6410768713084872977L;
-
- private final Map<String, ViewState> states = new ConcurrentHashMap<String, ViewState>();
-
- private Mode mode;
-
- public MultiStatePerspective(String name) {
- super(name);
- this.mode = Mode.EDIT;
- }
-
- public void addState(ViewState state) {
- this.setState(state);
- }
-
- public void setState(ViewState state) {
- super.setState(state);
- state.setMode(this.mode);
- if (!this.states.containsKey(state.getId())) {
- this.states.put(state.getId(), state);
- this.handleAddState(state);
- }
- }
-
- public void removeState(ViewState state) {
- this.states.remove(state);
- this.handleRemoveState(state);
- super.setState(this.getActiveState());
- }
-
- public ViewState getState(String stateId) {
- return this.states.get(stateId);
- }
-
- public List<ViewState> getStates() {
- return new Vector<ViewState>(this.states.values());
- }
-
- public Set<String> getStateIds() {
- return this.states.keySet();
- }
-
- public void setMode(Mode mode) {
- this.mode = mode;
- for (ViewState state : states.values()) {
- state.setMode(mode);
- }
- this.refresh();
- }
-
- public void reset() {
- super.reset();
- this.mode = Mode.EDIT;
- states.clear();
- }
-
- public abstract void handleAddState(ViewState state);
-
- public abstract void handleRemoveState(ViewState state);
-
- public abstract ViewState getActiveState();
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java
deleted file mode 100644
index 0df667a..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective;
-
-//JDK imports
-import javax.swing.JPanel;
-
-//OODT imports
-import org.apache.oodt.cas.workflow.gui.perspective.view.View;
-import org.apache.oodt.cas.workflow.gui.perspective.view.ViewListener;
-import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
-import org.apache.oodt.cas.workflow.gui.perspective.view.View.Mode;
-
-/**
- *
- *
- * A view listener and jpanel for keeping the Workflow perspective in sync.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public abstract class Perspective extends JPanel implements ViewListener {
-
- private static final long serialVersionUID = -3343805159396435882L;
-
- private ViewState state;
- private String name;
-
- public Perspective(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public ViewState getState() {
- return this.state;
- }
-
- public void setState(ViewState state) {
- this.state = state;
- }
-
- public void setMode(Mode mode) {
- this.state.setMode(mode);
- this.refresh();
- }
-
- public void save() {
- if (this.state != null) {
- this.state.save();
- }
- }
-
- public void undo() {
- if (this.state != null) {
- this.state.undo();
- this.refresh();
- }
- }
-
- public void reset() {
- this.state = null;
- }
-
- public abstract void refresh();
-
- public abstract View getActiveView();
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java
deleted file mode 100644
index 67a6146..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective.build;
-
-//JDK imports
-
-import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
-import org.apache.oodt.cas.workflow.gui.perspective.MultiStatePerspective;
-import org.apache.oodt.cas.workflow.gui.perspective.view.MultiStateView;
-import org.apache.oodt.cas.workflow.gui.perspective.view.View;
-import org.apache.oodt.cas.workflow.gui.perspective.view.ViewChange;
-import org.apache.oodt.cas.workflow.gui.perspective.view.ViewListener;
-import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
-import org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView;
-import org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView;
-import org.apache.oodt.cas.workflow.gui.perspective.view.impl.GlobalConfigView;
-import org.apache.oodt.cas.workflow.gui.perspective.view.impl.GraphView;
-import org.apache.oodt.cas.workflow.gui.perspective.view.impl.TreeProjectView;
-import org.apache.oodt.cas.workflow.gui.util.GuiUtils;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.util.Collections;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JSplitPane;
-import javax.swing.JTabbedPane;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-//OODT imports
-
-/**
- *
- * The default build perspective.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public class BuildPerspective extends MultiStatePerspective {
-
- private static final long serialVersionUID = 3387632819576057527L;
-
- private View projectView;
- private View globalConfigView;
- private Class<? extends View> projectViewClass;
- private Class<? extends View> mainViewClass;
- private Class<? extends View> treeViewClass;
- private Class<? extends View> propViewClass;
- private Class<? extends View> globalViewClass;
-
- private ConcurrentHashMap<ViewState, BuildPanel> stateViews;
- private ViewState activeState;
-
- public static final int MAIN_VIEW = 1;
- private static Logger LOG = Logger.getLogger(BuildPerspective.class.getName());
- private static final int WIDTH = 1000;
- private static final int HEIGHT = 700;
-
- private JSplitPane projectSplitPane;
-
- private boolean findSelectedInTab = false;
-
- public BuildPerspective() {
- this(TreeProjectView.class, GraphView.class, DefaultTreeView.class,
- DefaultPropView.class, GlobalConfigView.class);
- }
-
- public BuildPerspective(Class<? extends View> projectViewClass,
- Class<? extends View> mainViewClass, Class<? extends View> treeViewClass,
- Class<? extends View> propViewClass, Class<? extends View> globalViewClass) {
- super("Build");
- this.projectViewClass = projectViewClass;
- this.mainViewClass = mainViewClass;
- this.treeViewClass = treeViewClass;
- this.propViewClass = propViewClass;
- this.globalViewClass = globalViewClass;
- this.stateViews = new ConcurrentHashMap<ViewState, BuildPanel>();
- this.projectView = this.createProjectView();
- this.projectView.setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
- this.globalConfigView = this.createGlobalConfigView();
- this.globalConfigView
- .setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
- }
-
- public void reset() {
- super.reset();
- this.activeState = null;
- this.stateViews.clear();
- this.projectView = this.createProjectView();
- this.globalConfigView = this.createGlobalConfigView();
- }
-
- public void stateChangeNotify(ViewChange<?> change) {
- if (change instanceof ViewChange.NEW_ACTIVE_STATE) {
- this.activeState = ((ViewChange.NEW_ACTIVE_STATE) change).getObject();
- this.refresh();
- } else if (change instanceof ViewChange.REFRESH_VIEW) {
- this.refresh();
- } else if (change instanceof ViewChange.STATE_NAME_CHANGE) {
- this.refresh();
- } else if (change instanceof ViewChange.VIEW_MODEL) {
- String modelId = ((ViewChange.VIEW_MODEL) change).getObject();
- for (ViewState state : this.stateViews.keySet()) {
- for (ModelGraph graph : state.getGraphs()) {
- ModelGraph found = graph.recursiveFindByModelId(modelId);
- if (found != null && !found.getModel().isRef()) {
- this.activeState = state;
- this.activeState.setSelected(found);
- break;
- }
- }
- }
- this.findSelectedInTab = true;
- this.refresh();
- this.findSelectedInTab = false;
- }
- }
-
- @Override
- public ViewState getActiveState() {
- return this.activeState;
- }
-
- public View getActiveView() {
- if (this.getActiveState() != null) {
- return this.stateViews.get(this.getActiveState()).getActiveView();
- } else {
- return null;
- }
- }
-
- @Override
- public void handleAddState(final ViewState state) {
- this.activeState = state;
- BuildPanel buildPanel = new BuildPanel(state);
- this.stateViews.put(state, buildPanel);
- this.refresh();
- }
-
- @Override
- public void handleRemoveState(ViewState state) {
- this.stateViews.remove(state);
- if (this.stateViews.size() > 0) {
- this.activeState = this.stateViews.keySet().iterator().next();
- } else {
- this.activeState = null;
- }
- this.refresh();
- }
-
- @Override
- public void refresh() {
- this.save();
- this.removeAll();
- this.setLayout(new BorderLayout());
- JPanel panel;
- if (this.activeState != null) {
- BuildPanel buildPanel = this.stateViews.get(this.activeState);
- buildPanel.refresh();
- panel = buildPanel;
- } else {
- panel = new JPanel();
- }
-
- if (this.projectView instanceof MultiStateView) {
- ((MultiStateView) this.projectView).refreshView(this.activeState,
- this.getStates());
- } else {
- this.projectView.refreshView(this.activeState);
- }
-
- this.globalConfigView.refreshView(this.activeState);
-
- JPanel globalPanel = new JPanel();
- globalPanel.setLayout(new BorderLayout());
- globalPanel.add(this.projectView, BorderLayout.CENTER);
- globalPanel.add(this.globalConfigView, BorderLayout.SOUTH);
-
- int dividerLocation = -1;
- if (projectSplitPane != null) {
- dividerLocation = projectSplitPane.getDividerLocation();
- }
- projectSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, globalPanel,
- panel);
- if (dividerLocation != -1) {
- projectSplitPane.setDividerLocation(dividerLocation);
- }
- this.add(projectSplitPane, BorderLayout.CENTER);
-
- this.revalidate();
-
- }
-
- private View createMainView(String name) {
- try {
- return this.mainViewClass.getConstructor(String.class).newInstance(name);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage());
- return null;
- }
- }
-
- private View createTreeView() {
- try {
- return this.treeViewClass.getConstructor(String.class).newInstance(
- this.treeViewClass.getSimpleName());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage());
- return null;
- }
- }
-
- private View createGlobalConfigView() {
- try {
- return this.globalViewClass.getConstructor(String.class).newInstance(
- this.globalViewClass.getSimpleName());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage());
- return null;
- }
- }
-
- private View createProjectView() {
- try {
- View view = this.projectViewClass.getConstructor(String.class)
- .newInstance(this.projectViewClass.getSimpleName());
- view.registerListener(this);
- return view;
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage());
- return null;
- }
- }
-
- private View createPropView() {
- try {
- return this.propViewClass.getConstructor(String.class).newInstance(
- this.propViewClass.getSimpleName());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage());
- return null;
- }
- }
-
- private class BuildPanel extends JPanel implements ViewListener {
-
- private static final long serialVersionUID = -6120047959962567963L;
-
- private JTabbedPane tabbedPane;
- private Map<View, ViewState> mainViews;
- private View propView;
- private View treeView;
-
- private View primaryMainView;
-
- private JPopupMenu closeTabPopup;
-
- private ViewState state;
-
- public BuildPanel(ViewState state) {
- this.state = state;
-
- mainViews = new ConcurrentHashMap<View, ViewState>();
-
- propView = createPropView();
- if (propView != null) {
- propView.registerListener(this);
- }
-
- treeView = createTreeView();
- if (treeView != null) {
- treeView.registerListener(this);
- }
-
- tabbedPane = new JTabbedPane();
-
- this.addMainView(createMainView(state.getFile().getName()), state);
-
- closeTabPopup = new JPopupMenu();
- JMenuItem closeItem = new JMenuItem("Close");
- closeItem.addActionListener(new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- View mainView = (View) BuildPanel.this.tabbedPane
- .getSelectedComponent();
- BuildPanel.this.removeMainView(mainView);
- }
-
- });
- closeTabPopup.add(closeItem);
-
- this.tabbedPane.addMouseListener(new MouseListener() {
-
- public void mouseClicked(MouseEvent e) {
- if (e.getButton() == MouseEvent.BUTTON3
- && !BuildPanel.this.tabbedPane.getSelectedComponent().equals(
- BuildPanel.this.primaryMainView)) {
- closeTabPopup.show(BuildPanel.this.tabbedPane, e.getX(), e.getY());
- }
- }
-
- public void mouseEntered(MouseEvent e) {
- }
-
- public void mouseExited(MouseEvent e) {
- }
-
- public void mousePressed(MouseEvent e) {
- }
-
- public void mouseReleased(MouseEvent e) {
- }
-
- });
-
- this.tabbedPane.addChangeListener(new ChangeListener() {
-
- public void stateChanged(ChangeEvent e) {
- View activeView = (View) BuildPanel.this.tabbedPane
- .getSelectedComponent();
- activeView.notifyListeners();
- }
-
- });
-
- treeView.setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
- propView.setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
- JSplitPane treePropPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- treeView, propView);
- treePropPane.setResizeWeight(.25);
- tabbedPane.setPreferredSize(new Dimension(WIDTH, HEIGHT));
- JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
- tabbedPane, treePropPane);
- mainSplitPane.setResizeWeight(.75);
- this.setLayout(new BorderLayout());
- this.add(mainSplitPane, BorderLayout.CENTER);
- }
-
- public void addMainView(View mainView, ViewState state) {
- if (this.mainViews.size() == 0) {
- this.primaryMainView = mainView;
- mainView.setPrimary(true);
- }
- this.mainViews.put(mainView, state);
- this.tabbedPane.addTab(mainView.getName(), mainView);
- this.tabbedPane.setSelectedComponent(mainView);
- mainView.registerListener(this);
- }
-
- public void removeMainView(View mainView) {
- if (!this.primaryMainView.equals(mainView)) {
- for (int i = 0; i < this.tabbedPane.getTabCount(); i++) {
- if (mainView.getName().equals(this.tabbedPane.getTitleAt(i))) {
- this.tabbedPane.removeTabAt(i);
- this.mainViews.remove(mainView);
- return;
- }
- }
- }
- }
-
- public View getActiveView() {
- return (View) this.tabbedPane.getSelectedComponent();
- }
-
- public void refresh() {
- if (this.getActiveView() != null) {
- ViewState viewState = null;
- if (this.state.getSelected() != null && findSelectedInTab) {
- TOP: for (Entry<View, ViewState> entry : this.mainViews.entrySet()) {
- for (ModelGraph graph : entry.getValue().getGraphs()) {
- ModelGraph found = graph.recursiveFindByModelId(this.state
- .getSelected().getModel().getModelId());
- if (found != null && !found.getModel().isRef()) {
- viewState = entry.getValue();
- viewState.setSelected(found);
- this.tabbedPane.setSelectedComponent(entry.getKey());
- break TOP;
- }
- }
- }
- } else {
- viewState = this.mainViews.get(this.getActiveView());
- }
- this.getActiveView().refreshView(viewState);
- this.propView.refreshView(viewState);
- this.treeView.refreshView(viewState);
- }
- this.revalidate();
- }
-
- public void stateChangeNotify(ViewChange<?> change) {
- if (change instanceof ViewChange.NEW_VIEW) {
- this.addMainView(
- createMainView(((ViewChange.NEW_VIEW) change).getObject()
- .getModel().getModelId()),
- new ViewState(this.state.getFile(), null, Collections
- .singletonList(GuiUtils.find(this.state.getGraphs(),
- ((ViewChange.NEW_VIEW) change).getObject().getModel()
- .getId())), this.state.getGlobalConfigGroups()));
- this.refresh();
- }
- BuildPerspective.this.stateChangeNotify(change);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java
deleted file mode 100644
index ae34285..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective.view;
-
-//JDK imports
-import java.util.List;
-
-/**
- *
- * A multi-state view.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public abstract class MultiStateView extends View {
-
- public MultiStateView(String name) {
- super(name);
- }
-
- private static final long serialVersionUID = -6968627851727698540L;
-
- public void refreshView(ViewState state) {
- throw new RuntimeException(
- "This is a mutli-state view -- call multi-state view refreshView method!");
- }
-
- public abstract void refreshView(ViewState activeState, List<ViewState> states);
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java
deleted file mode 100644
index b8341e1..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective.view;
-
-//JDK imports
-import java.util.UUID;
-import java.util.Vector;
-import javax.swing.JPanel;
-
-/**
- *
- *
- * View abstract base class.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public abstract class View extends JPanel {
-
- private static final long serialVersionUID = -708692459667309413L;
-
- public enum Mode {
- DELETE, EDIT, MOVE, ZOOM_IN, ZOOM_OUT
- }
-
- private Vector<ViewListener> listeners;
- private String id;
- private boolean isPrimary;
-
- public static final String DISPLAY_GRAPH_IDS = "DisplayGraphIds";
-
- public View(String name) {
- super();
- this.id = UUID.randomUUID().toString();
- if (name != null) {
- this.setName(name);
- }
- this.listeners = new Vector<ViewListener>();
- }
-
- public void setPrimary(boolean isPrimary) {
- this.isPrimary = isPrimary;
- }
-
- public boolean isPrimary() {
- return this.isPrimary;
- }
-
- public String getId() {
- return this.id;
- }
-
- public void registerListener(ViewListener listener) {
- listeners.add(listener);
- }
-
- public void deregisterListener(ViewListener listener) {
- this.listeners.remove(listener);
- }
-
- public void notifyListeners(ViewChange<?> change) {
- for (ViewListener listener : listeners) {
- listener.stateChangeNotify(change);
- }
- }
-
- public void notifyListeners() {
- this.notifyListeners(new ViewChange.REFRESH_VIEW(this, this));
- }
-
- public int hashCode() {
- return this.id.hashCode();
- }
-
- public boolean equals(Object obj) {
- return obj instanceof View && ((View) obj).id.equals(this.id);
- }
-
- public abstract void refreshView(ViewState state);
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java
deleted file mode 100644
index 5fd2a15..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective.view;
-
-//OODT imports
-import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
-
-/**
- *
- * Represents a change in the Workflow GUI model view.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public abstract class ViewChange<T> {
-
- private T object;
- private View source;
-
- protected ViewChange(T object, View source) {
- this.object = object;
- this.source = source;
- }
-
- public T getObject() {
- return this.object;
- }
-
- public View getSource() {
- return this.source;
- }
-
- public static final class NEW_VIEW extends ViewChange<ModelGraph> {
- public NEW_VIEW(ModelGraph object, View source) {
- super(object, source);
- }
- }
-
- public static final class DELETE_VIEW extends ViewChange<View> {
- public DELETE_VIEW(View object, View source) {
- super(object, source);
- }
- }
-
- public static final class REFRESH_VIEW extends ViewChange<View> {
- public REFRESH_VIEW(View object, View source) {
- super(object, source);
- }
- }
-
- public static final class NEW_STATE extends ViewChange<ViewState> {
- public NEW_STATE(ViewState object, View source) {
- super(object, source);
- }
- }
-
- public static final class REMOVE_STATE extends ViewChange<ViewState> {
- public REMOVE_STATE(ViewState object, View source) {
- super(object, source);
- }
- }
-
- public static final class NEW_ACTIVE_STATE extends ViewChange<ViewState> {
- public NEW_ACTIVE_STATE(ViewState object, View source) {
- super(object, source);
- }
- }
-
- public static final class STATE_NAME_CHANGE extends ViewChange<ViewState> {
- public STATE_NAME_CHANGE(ViewState object, View source) {
- super(object, source);
- }
- }
-
- public static final class VIEW_MODEL extends ViewChange<String> {
- public VIEW_MODEL(String modelId, View source) {
- super(modelId, source);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java
deleted file mode 100644
index 29f855a..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective.view;
-
-/**
- *
- * Interface for listening/notifying about Workflow View state changes.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public interface ViewListener {
-
- void stateChangeNotify(ViewChange<?> change);
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewState.java
----------------------------------------------------------------------
diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewState.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewState.java
deleted file mode 100644
index 3ffc1fe..0000000
--- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewState.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.cas.workflow.gui.perspective.view;
-
-//OODT imports
-import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
-import org.apache.oodt.cas.workflow.gui.model.repo.XmlWorkflowModelRepository.ConfigGroup;
-import org.apache.oodt.cas.workflow.gui.perspective.view.View.Mode;
-import org.apache.oodt.cas.workflow.gui.util.GuiUtils;
-
-//JDK imports
-import java.io.File;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-import java.util.UUID;
-import java.util.Vector;
-
-/**
- *
- * The current state of a particular Workflow GUI editor view.
- *
- * @author bfoster
- * @author mattmann
- *
- */
-public class ViewState {
-
- private static final ConcurrentHashMap<String, Stack<ViewState>> undoHistory = new ConcurrentHashMap<String, Stack<ViewState>>();
-
- private ModelGraph selected;
- private List<ModelGraph> graphs;
- private String id;
- private String currentMetGroup;
- private Metadata properties;
- private Mode mode;
- private File file;
- private boolean change = false;
- private Map<String, ConfigGroup> globalConfigGroups;
-
- public ViewState(File file, ModelGraph selected, List<ModelGraph> graphs,
- Map<String, ConfigGroup> globalConfigGroups) {
- this.selected = selected;
- this.graphs = new Vector<ModelGraph>(graphs);
- this.id = UUID.randomUUID().toString();
- this.currentMetGroup = null;
- this.properties = new Metadata();
- this.mode = Mode.EDIT;
- this.file = file;
- this.globalConfigGroups = globalConfigGroups;
- }
-
- public Map<String, ConfigGroup> getGlobalConfigGroups() {
- return this.globalConfigGroups;
- }
-
- public void addGlobalConfigGroup(String groupName, ConfigGroup configGroup) {
- this.globalConfigGroups.put(groupName, configGroup);
- }
-
- public void removeGlobalConfigGroup(String groupName) {
- this.globalConfigGroups.remove(groupName);
- }
-
- public File getFile() {
- return this.file;
- }
-
- public String getId() {
- return this.id;
- }
-
- public boolean containsProperty(String key) {
- return this.properties.containsGroup(key);
- }
-
- public void setProperty(String key, String value) {
- Vector<String> values = new Vector<String>();
- values.add(value);
- this.setProperty(key, values);
- }
-
- public void setProperty(String key, List<String> values) {
- this.properties.replaceMetadata(key, values);
- this.change = true;
- }
-
- public String getFirstPropertyValue(String key) {
- List<String> values = this.getProperty(key);
- if (values == null || values.size() == 0) {
- return null;
- }
- return values.get(0);
- }
-
- public List<String> getProperty(String key) {
- return this.properties.getAllMetadata(key);
- }
-
- public void removeProperty(String key) {
- this.properties.removeMetadata(key);
- this.change = true;
- }
-
- public List<String> getKeysRecur(String subGroup) {
- Vector<String> keys = new Vector<String>();
- for (String key : this.properties.getAllKeys()) {
- if (key.contains(subGroup)) {
- keys.add(key);
- }
- }
- return keys;
- }
-
- public void setSelected(ModelGraph selected) {
- if (this.selected == null || selected == null
- || !this.selected.equals(selected)) {
- this.currentMetGroup = null;
- this.selected = selected;
- this.change = true;
- }
- }
-
- public ModelGraph getSelected() {
- if (this.mode.equals(Mode.EDIT)) {
- return this.selected;
- } else {
- return null;
- }
- }
-
- public Set<String> getGraphIds() {
- HashSet<String> graphIds = new HashSet<String>();
- for (ModelGraph graph : this.getGraphs()) {
- graphIds.add(graph.getModel().getModelId());
- }
- return graphIds;
- }
-
- public List<ModelGraph> getGraphs() {
- return this.graphs;
- }
-
- public void removeGraph(ModelGraph graph) {
- this.graphs.remove(graph);
- }
-
- public void addGraph(ModelGraph graph) {
- this.graphs.add(graph);
- }
-
- public void setMode(Mode mode) {
- this.mode = mode;
- this.change = true;
- }
-
- public Mode getMode() {
- return this.mode;
- }
-
- public void setCurrentMetGroup(String currentMetGroup) {
- this.currentMetGroup = currentMetGroup;
- this.change = true;
- }
-
- public String getCurrentMetGroup() {
- return this.currentMetGroup;
- }
-
- public boolean hasChanged() {
- return this.change;
- }
-
- public void save() {
- if (this.change) {
- Stack<ViewState> stack = undoHistory.get(this.id);
- if (stack == null) {
- stack = new Stack<ViewState>();
- }
- if (stack.size() >= 100) {
- stack.remove(stack.size() - 1);
- }
- stack.push(this.clone());
- undoHistory.put(this.id, stack);
- this.change = false;
- }
- }
-
- public void undo() {
- Stack<ViewState> stack = undoHistory.get(this.id);
- if (stack != null && !stack.empty()) {
- this.clone(stack.pop());
- System.out.println(this.getGraphIds());
- this.change = false;
- }
- }
-
- public void clone(ViewState state) {
- this.graphs = null;
- this.selected = null;
- if (state.graphs != null) {
- this.graphs = new Vector<ModelGraph>();
- for (ModelGraph graph : state.graphs) {
- this.graphs.add(graph.clone());
- }
- if (state.selected != null) {
- this.selected = GuiUtils.find(this.graphs, state.selected.getModel()
- .getModelId());
- }
- }
- this.properties = new Metadata(state.properties);
- this.id = state.id;
- this.currentMetGroup = state.currentMetGroup;
- this.mode = state.mode;
- }
-
- public ViewState clone() {
- List<ModelGraph> cloneGraphs = null;
- ModelGraph selected = null;
- if (this.graphs != null) {
- cloneGraphs = new Vector<ModelGraph>();
- for (ModelGraph graph : this.graphs) {
- cloneGraphs.add(graph.clone());
- }
- if (this.selected != null) {
- selected = GuiUtils.find(cloneGraphs, this.selected.getModel()
- .getModelId());
- }
- }
- ViewState clone = new ViewState(this.file, selected, cloneGraphs,
- this.globalConfigGroups);
- clone.id = this.id;
- clone.file = this.file;
- clone.currentMetGroup = this.currentMetGroup;
- clone.properties = new Metadata(this.properties);
- clone.mode = this.mode;
- return clone;
- }
-
- public int hashCode() {
- return this.id.hashCode();
- }
-
- public boolean equals(Object obj) {
- return obj instanceof ViewState && this.id.equals(((ViewState) obj).id);
- }
-
- public String toString() {
- return this.getId();
- }
-
-}