<commit_before>/*
 *
 * 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.airavata.xbaya.graph.impl;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import javax.swing.JOptionPane;

import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.xbaya.XBayaEngine;
import org.apache.airavata.xbaya.XBayaException;
import org.apache.airavata.xbaya.XBayaRuntimeException;
import org.apache.airavata.xbaya.XBayaVersion;
import org.apache.airavata.xbaya.graph.ControlPort;
import org.apache.airavata.xbaya.graph.DataEdge;
import org.apache.airavata.xbaya.graph.DataPort;
import org.apache.airavata.xbaya.graph.Edge;
import org.apache.airavata.xbaya.graph.Graph;
import org.apache.airavata.xbaya.graph.GraphException;
import org.apache.airavata.xbaya.graph.GraphFactory;
import org.apache.airavata.xbaya.graph.GraphSchema;
import org.apache.airavata.xbaya.graph.Node;
import org.apache.airavata.xbaya.graph.Port;
import org.apache.airavata.xbaya.graph.Port.Kind;
import org.apache.airavata.xbaya.graph.gui.GraphGUI;
import org.apache.airavata.xbaya.graph.system.InputNode;
import org.apache.airavata.xbaya.graph.system.OutputNode;
import org.apache.airavata.xbaya.graph.system.SystemDataPort;
import org.apache.airavata.xbaya.graph.system.gui.StreamSourceNode;
import org.apache.airavata.xbaya.graph.util.GraphUtil;
import org.apache.airavata.xbaya.graph.ws.WSPort;
import org.apache.airavata.xbaya.streaming.StreamTableModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmlpull.infoset.XmlElement;

public abstract class GraphImpl implements Graph {

    private static final Logger logger = LoggerFactory.getLogger(GraphImpl.class);

    /**
     * Unique ID of this workflow
     */
    private String id;

    /**
     * Name of the workflow. It has to have one.
     */
    private String name = "Workflow";

    /**
     * Default to empty string to avoid null check.
     */
    private String description = "";

    private List<NodeImpl> nodes = new LinkedList<NodeImpl>();

    private List<PortImpl> ports = new LinkedList<PortImpl>();

    private List<EdgeImpl> edges = new LinkedList<EdgeImpl>();

    private GraphFactory factory;

    private GraphGUI gui;

    private StreamTableModel streamModel;

    /**
     * @param factory
     */
    public GraphImpl(GraphFactory factory) {
        this.factory = factory;
        this.gui = new GraphGUI(this);
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getGUI()
     */
    public GraphGUI getGUI() {
        return this.gui;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getID()
     */
    public String gtID() throws XBayaException{
        if (this.id == null) {
            this.id = this.name;
            // If its still null
            if (null == this.id) {
                throw new XBayaException("The workflow ID is null");
            }
        }
        return this.id;
    }

    /**
     * This will only be done for the ODE
     * 
     * @param id
     */
    public void setID(String id) {
        this.id = id;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#setName(java.lang.String)
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getName()
     */
    public String getName() {
        return this.name;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getDescription()<commit_msg>fixing build error.<commit_after>/*
 *
 * 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.airavata.xbaya.graph.impl;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import javax.swing.JOptionPane;

import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.xbaya.XBayaEngine;
import org.apache.airavata.xbaya.XBayaException;
import org.apache.airavata.xbaya.XBayaRuntimeException;
import org.apache.airavata.xbaya.XBayaVersion;
import org.apache.airavata.xbaya.graph.ControlPort;
import org.apache.airavata.xbaya.graph.DataEdge;
import org.apache.airavata.xbaya.graph.DataPort;
import org.apache.airavata.xbaya.graph.Edge;
import org.apache.airavata.xbaya.graph.Graph;
import org.apache.airavata.xbaya.graph.GraphException;
import org.apache.airavata.xbaya.graph.GraphFactory;
import org.apache.airavata.xbaya.graph.GraphSchema;
import org.apache.airavata.xbaya.graph.Node;
import org.apache.airavata.xbaya.graph.Port;
import org.apache.airavata.xbaya.graph.Port.Kind;
import org.apache.airavata.xbaya.graph.gui.GraphGUI;
import org.apache.airavata.xbaya.graph.system.InputNode;
import org.apache.airavata.xbaya.graph.system.OutputNode;
import org.apache.airavata.xbaya.graph.system.SystemDataPort;
import org.apache.airavata.xbaya.graph.system.gui.StreamSourceNode;
import org.apache.airavata.xbaya.graph.util.GraphUtil;
import org.apache.airavata.xbaya.graph.ws.WSPort;
import org.apache.airavata.xbaya.streaming.StreamTableModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmlpull.infoset.XmlElement;

public abstract class GraphImpl implements Graph {

    private static final Logger logger = LoggerFactory.getLogger(GraphImpl.class);

    /**
     * Unique ID of this workflow
     */
    private String id;

    /**
     * Name of the workflow. It has to have one.
     */
    private String name = "Workflow";

    /**
     * Default to empty string to avoid null check.
     */
    private String description = "";

    private List<NodeImpl> nodes = new LinkedList<NodeImpl>();

    private List<PortImpl> ports = new LinkedList<PortImpl>();

    private List<EdgeImpl> edges = new LinkedList<EdgeImpl>();

    private GraphFactory factory;

    private GraphGUI gui;

    private StreamTableModel streamModel;

    /**
     * @param factory
     */
    public GraphImpl(GraphFactory factory) {
        this.factory = factory;
        this.gui = new GraphGUI(this);
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getGUI()
     */
    public GraphGUI getGUI() {
        return this.gui;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getID()
    */
        public String getID() {
             if (this.id == null) {
                // No other choice but to prompt
                // the user to pick an id
                final XBayaEngine engine = XBayaEngine.getInstance();
    //            JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Provide a relatively unique workflow name",
    //                    "Workflow Name", JOptionPane.OK_OPTION);
                engine.getWorkflowPropertyWindow().show();
                 this.id = this.name;
                 // If its still null
                 if (null == this.id) {
                    throw new XBayaRuntimeException("The workflow ID is null");
                 }
             }
            return this.id;
        }


    /**
     * This will only be done for the ODE
     * 
     * @param id
     */
    public void setID(String id) {
        this.id = id;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#setName(java.lang.String)
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getName()
     */
    public String getName() {
        return this.name;
    }

    /**
     * @see org.apache.airavata.xbaya.graph.Graph#getDescription()
{'fraction_non_alphanumeric': 0.10552214324767632, 'fraction_numerical': 0.0013121924548933845, 'mean_word_length': 2.9558823529411766, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4251450', 'n_tokens_mistral': 2804, 'n_tokens_neox': 2749, 'n_words': 684}