⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operatornode.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 * $Author$
 * $Date$
 * $Revision$
 *
 */
package eti.bi.alphaminer.vo; 


import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import eti.bi.alphaminer.operation.operator.NodeInfo;

 
/**
 * OperatorNode is a kind of Node and contains additional node information.
 */
public class OperatorNode extends Node implements IOperatorNode{

	//<<Frank J. Xu, 19/01/2005
	//Refactored to adapt to different data mining engine.
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * OperatorNode details
	 */
	//private int m_OperatorNodeType;
	private String m_Path;
	private String m_Name;
	private String m_Category;
	private String m_Function;
	private String m_Algorithm;
	private Vector<String> m_InputTables;
	private Hashtable<String, String> m_Parameters;
	private Hashtable<String, Object> m_TempParameters;
	private Vector<String> m_OutputTables;
	private String m_Guideline;

	private String m_OperatorDefinitionID;
	
	/**
	 * Constructs an OperatorNode
	 */
	public OperatorNode() {
		super();
	}

	/**
	 * Constructs an OperatorNode for a specific Case.
	 * @param a_CaseID ID of the case of the operator node.
	 */
	public OperatorNode(String a_CaseID) {
		super(a_CaseID, NodeFactory.OPERATOR);
		m_Parameters = new Hashtable<String, String>();
		m_TempParameters = new Hashtable<String, Object>();
		m_InputTables = new Vector<String>();
		m_OutputTables = new Vector<String>();
		m_OperatorDefinitionID="";
	}

	/**
	 * Constructs an OperatorNode for a specific Case.
	 * @param a_CaseID ID of the case of the operator node.
	 */
	public OperatorNode(String a_CaseID, NodeInfo aNodeInfo) {
		super(a_CaseID, NodeFactory.OPERATOR);
		m_Parameters = new Hashtable<String, String>();
		m_TempParameters = new Hashtable<String, Object>();
		m_InputTables = new Vector<String>();
		m_OutputTables = new Vector<String>();
		m_OperatorDefinitionID = aNodeInfo.getDefinitionID();
		setNodeInfo(aNodeInfo);
	}

	/**
	 * Constructs an OperatorNode of a specific type for a Case.
	 * @param a_CaseID ID of the case containing this OperatorNode.
	 * @param a_OperatorNode type of this operator node.
	 */
	public OperatorNode(String a_CaseID, OperatorNode a_OperatorNode) {
		super(a_CaseID, NodeFactory.OPERATOR);
		copyNodeProperty(a_OperatorNode);

		m_OperatorDefinitionID = a_OperatorNode.getOperatorDefinitionID();
//		setOperatorNodeType(a_OperatorNode.getOperatorNodeType());
		setPath(a_OperatorNode.getPath());
		setName(a_OperatorNode.getName());
		setCategory(a_OperatorNode.getCategory());
		setFunction(a_OperatorNode.getFunction());
		setAlgorithm(a_OperatorNode.getAlgorithm());
		setGuideline(a_OperatorNode.getGuideline());

		m_Parameters = new Hashtable<String, String>();
		m_TempParameters = new Hashtable<String, Object>();
		String[][] parameters = a_OperatorNode.getParametersArray();
		for (int i = 0; parameters != null && i < parameters.length; i++)
			setParameterValue(
				parameters[i][0],
				parameters[i][1]);

		m_InputTables = new Vector<String>();
		for (int i = 0; i < m_InputTables.size(); i++)
			addInputTable(
				m_InputTables.elementAt(i));

		m_OutputTables = new Vector<String>();
		for (int i = 0; i < m_OutputTables.size(); i++)
			addOutputTable(
				m_OutputTables.elementAt(i));
	}

	/**
	 * Gets the OperatorDefinition ID.
	 * @return OperatorDefinitionID.
	 */
	public String getOperatorDefinitionID()
	{
		return m_OperatorDefinitionID;
	}

	/**
	 * Sets the type of the OperatorNode.
	 * @param a_Type type of the OperatorNode.
	 */
	public void setNodeInfo(NodeInfo aNodeInfo) {
		//m_OperatorNodeType = a_Type;

		/*
		 * Specify the numbers of each node type if it is different from the detault values:
		 * 
		 * Default maximum number of parents: 4
		 * Default maximum number of children: 4
		 * Default minumum number of parents: 0
		 * Default minumum number of children: 0
		 * 
		 * */
		setMaxNumParent(aNodeInfo.getMaxNumParent());
		setMinNumParent(aNodeInfo.getMinNumParent());
		setMaxNumChild(aNodeInfo.getMaxNumChild());
		setMinNumChild(aNodeInfo.getMinNumChild());
/*		switch(m_OperatorNodeType)
		{
			/////////////////////////////////////////////////////////////////
			//SAS OPERATOR TYPE.
		    case SAS_INPUT_DATA:
		    	setMaxNumParent(0);
		    	break;
		    case SAS_INSIGHT:
		    	setMaxNumParent(1);
		    	setMinNumParent(1);
		    	break;
		    case SAS_DATA_SET_ATTRIBUTES:	
		    	setMaxNumParent(1);
				setMinNumParent(1);
		    	break;
		    case SAS_TREE:
		    	setMaxNumParent(2);
		    	setMinNumParent(1);
		    	break;
		    case ASSESSMENT:
		    	setMinNumParent(1);
		    	break;
		    case SAS_TRANSFORM_VARIABLES:
		    	setMaxNumParent(1);
		    	break;
            case SAS_CLUSTERING:
            	setMaxNumParent(1);
            	setMinNumParent(1);
    			setMaxNumChild(0);
				setMinNumChild(0);
				break;
			///////////////////////////////////////////////////////////////////
			//ETI Operator Type.
			case ETI_INPUT_DATA:
				// Should not have no parent
				setMaxNumParent(0);
				break;
			case ETI_INPUT_FILE_DATA :
				// Should not have no parent
				setMaxNumParent(0);
				break;	
			case ETI_INPUT_DB_DATA 	:
				// Should not have no parent
				setMaxNumParent(0);
				break;	
				
			case ETI_INSIGHT:
				// One and only one parent
				setMaxNumParent(1);
				setMinNumParent(1);
				break;
			
		    //<<edited by dai
			case ETI_DATA_SET_ATTRIBUTES:
			case ETI_ADD_EXPRESSION:
			case ETI_OUTLIER_TREATMENT:
	        case ETI_MISSING_VALUES:
	        case ETI_NORMALIZATION:
			case ETI_DATA_SAMPLING:
			case ETI_BINERIZATION:
			case ETI_SELECT:
			case ETI_CATEGORICAL_TRANSFORMATION:
			case ETI_NUMERIC_TRANSFORMATION:
			case ETI_TRANSACTIONALIZATION:
			    setMaxNumParent(1);
				setMinNumParent(1);
				setMaxNumChild(4);
				break;
			//4/2/2005>>	
				
			case ETI_ASSOCIATION:
				setMaxNumParent(1);
				setMinNumParent(1);
				setMaxNumChild(0);
				setMinNumChild(0);
				break;
			case ETI_DECISION_TREE:
				// One and only one parent
				setMaxNumParent(1);
				setMinNumParent(1);
				break;				
			case ETI_DECISION_GENTREE:
				// One and only one parent
				setMaxNumParent(1);
				setMinNumParent(1);
				break;
			case ETI_CLUSTERING:
				// One and only one parent
				setMaxNumParent(1);
				setMinNumParent(1);
				setMaxNumChild(0);
				setMinNumChild(0);
				break;
			case ETI_LOGISTIC_REGRESSION:
				// One and only one parent
				setMaxNumParent(1);
				setMinNumParent(1);
				break;	
				
			case ETI_ASSESSMENT:
				// Could have many data source nodes
				setMinNumParent(1);
				setMaxNumParent(4);
				setMaxNumChild(0);
				setMinNumChild(0);				
				break;
			case ETI_SCORE:
				// Minimum One Modeling node and One Data Source Node 
				setMaxNumParent(4);
				setMinNumParent(2);
				setMaxNumChild(0);
				setMinNumChild(0);
				break;
			default:
				setMaxNumParent(4);
				setMinNumParent(0);
				setMaxNumChild(4);
				setMinNumChild(0);
				break;
		}*/
	}

	/**
	 * Gets the path.
	 * @return the path.
	 */
	public String getPath() {
		return m_Path;
	}

	/**
	 * Sets the path.
	 * @param a_Path path to be set.
	 */
	public void setPath(String a_Path) {
		m_Path = a_Path;
	}

	/**
	 * Gets the name.
	 * @return the name.
	 */
	public String getName() {
		return m_Name;
	}

	/**
	 * Sets the name.
	 * @param a_Name name to be set.
	 */
	public void setName(String a_Name) {
		m_Name = a_Name;
	}

	/**
	 * Gets the category.
	 * @return the category.
	 */
	public String getCategory() {
		return m_Category;
	}

	/**
	 * Sets the category.
	 * @param a_Category category to be set.
	 */
	public void setCategory(String a_Category) {
		m_Category = a_Category;
	}

	/**
	 * Gets the function used in this node.
	 * @return the function.
	 */
	public String getFunction() {
		return m_Function;
	}

	/**
	 * Sets the function used in this node.
	 * @param a_Function the function used.
	 */
	public void setFunction(String a_Function) {
		m_Function = a_Function;
	}

	/**
	 * Sets the algorithm used by this node.
	 * @return name of algorithm used.
	 */
	public String getAlgorithm() {
		return m_Algorithm;
	}

	/**
	 * Set the algorithm used by this node.
	 * @param a_Algorithm name of the algorithm used.
	 */
	public void setAlgorithm(String a_Algorithm) {
		m_Algorithm = a_Algorithm;
	}

	/**
	 * Gets a collection of parameters.
	 * @return a collection of parameters in a Hashtable.
	 */
	public Hashtable<String, String> getParameters() {
		return m_Parameters;
	}

	/**
	 * Sets the collection of parameters.
	 * @param a_Parameters a collection of parameters, in the form of
	 * Hashtable, to be set.
	 */
	public void setParameters(Hashtable<String, String> a_Parameters) {
		m_Parameters = a_Parameters;
	}

	/**
	 * Gets an array of all parameters. Each parameter is an array containing two
	 * String, with the first array entry stores the parameter name, while the
	 * second array entry stores the parameter value.
	 * @return a two-dimensional array storing all parameters and the corresponding
	 * parameter values.
	 */
	public String[][] getParametersArray() {
		if (m_Parameters.isEmpty())
			return null;
		String[][] parameters = new String[m_Parameters.size()][2];
		Enumeration<String> em = m_Parameters.keys();
		String parameter = null;
		String value = null;
		int i = 0;
		while (em.hasMoreElements()) {
			parameter = em.nextElement();
			parameters[i][0] = parameter;
			
			value = (String) m_Parameters.get(parameter);
			parameters[i][1] = value;
			i++;
			
		}
		return parameters;
	}

	/**
	 * Gets the value of a parameter.
	 * @param a_Para name of the parameter.
	 * @return value of this parameter.
	 */
	public String getParameterValue(String a_Para) {
		return (String)m_Parameters.get(a_Para);
	}

	/**
	 * Sets the value of a parameter.
	 * @param a_Para name of the parameter to be set.
	 * @param a_Value value of the parameter.
	 */
	public void setParameterValue(String a_Para, String a_Value) {
		m_Parameters.put(a_Para, a_Value);
	}
	
	public Object getTempParameterValue(String a_Para) {
		return m_TempParameters.get(a_Para);
	}

	public void setTempParameterValue(String a_Para, Object a_Value) {
		m_TempParameters.put(a_Para, a_Value);
	}
	
	//Frank J. Xu, 28/01/2005>>

	public void removeParameterValue(String a_Para) {
		m_Parameters.remove(a_Para);
	}
	
	/**
	 * Get total number of parameters.
	 * @return total number of parameters.
	 */
	public int getParametersSize() {
		return m_Parameters.size();
	}

	/**
	 * Gets all InputTables.
	 * @return all InputTables in the form of a Vector.
	 */
	public Vector<String> getInputTables() {
		return m_InputTables;
	}

	/**
	 * Set all InputTables.
	 * @param a_Tables a Vector of InputTables to be set.
	 */
	public void setInputTables(Vector<String> a_Tables) {
		m_InputTables = a_Tables;
	}

	/**
	 * Adds an InputTable into the OperatorNode.
	 * @param a_Table the InputTable to be added.
	 */
	public void addInputTable(String a_Table /*DataTable a_Table*/
	) {
		m_InputTables.add(a_Table);
	}

	/**
	 * Removes a specific InputTable from the OperatorNode.
	 * @param a_Table the InputTable to be removed.
	 */
	public void removeInputTable(String a_Table /*DataTable a_Table*/
	) {
		m_InputTables.remove(a_Table);
	}

	/**
	 * Gets total number of InputTables.
	 * @return total number of InputTables.
	 */
	public int getInputTablesSize() {
		return m_InputTables.size();
	}

	/**
	 * Gets all OutputTables.
	 * @return all OutputTables in the form of a Vector.
	 */
	public Vector<String> getOutputTables() {
		return m_OutputTables;
	}

	/**
	 * Set all OutputTables.
	 * @param a_Tables a Vector of OutputTables to be set.
	 */
	public void setOutputTables(Vector<String> aTables) {
		m_OutputTables = aTables;
	}

	/**
	 * Adds an OutputTable into the OperatorNode.
	 * @param a_Table the OutputTable to be added.
	 */
	public void addOutputTable(String a_Table /*DataTable a_Table*/
	) {
		m_OutputTables.add(a_Table);
	}
	
	/**
	 * Removes a specific OutputTable from the OperatorNode.
	 * @param a_Table the OutputTable to be removed.
	 */
	public void removeOutputTable(String a_Table /*DataTable a_Table*/
	) {
		m_OutputTables.remove(a_Table);
	}
	
	public void clearParameters(){
		m_Parameters.clear();
	}
	
	public void clearTempParameters() {
		m_TempParameters.clear();
	}
	
	/**
	 * Gets total number of OutputTables.
	 * @return total number of OutputTables.
	 */
	public int getOutputTablesSize() {
		return m_OutputTables.size();
	}
	
	/**
	 * Gets the guideline.
	 * @return the guideline
	 */
	public String getGuideline() {
		return m_Guideline;
	}

	/**
	 * Sets the guideline.
	 * @param a_Guideline the guildline to be set.
	 */
	public void setGuideline(String a_Guideline) {
		m_Guideline = a_Guideline;
	}

	/**
	 * @param operatorDefinitionID The m_OperatorDefinitionID to set.
	 */
	public void setOperatorDefinitionID(String operatorDefinitionID) {
		m_OperatorDefinitionID = operatorDefinitionID;
	}

	public void removeTempParameterValue(String a_Para) {
		m_TempParameters.remove(a_Para);
	}

	public void removeAllTempParameterValue() {
		m_TempParameters.clear();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -