📄 sampleoperator.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.operation.operator;
import java.util.Vector;
import eti.bi.alphaminer.core.handler.ICaseHandler;
import eti.bi.alphaminer.operation.operator.Operator;
import eti.bi.alphaminer.vo.BIData;
import eti.bi.alphaminer.vo.BIModel;
import eti.bi.alphaminer.vo.BIObject;
import eti.bi.alphaminer.vo.IBIData;
import eti.bi.alphaminer.vo.IBIModel;
import eti.bi.alphaminer.vo.IOperatorNode;
import eti.bi.exception.SysException;
/**
* SampleOperator is a kind of Operator.
* This is a sample operator
*/
public class SampleOperator extends ModelOperator {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* @param a_CaseID
* @param a_CaseWindow
* @param aOperatorInfo
*/
public SampleOperator(String a_CaseID, INodeInfo aNodeInfo, ICaseHandler aCaseHandler) {
super(a_CaseID, aNodeInfo, aCaseHandler);
// TODO Auto-generated constructor stub
}
/**
* Called to determine if the node was executed and the temporary results are available.
* return true if the temp results are available and no need to execute it. Otherwise, return false.
*/
public boolean hasResult()
{
/* Normally the operator has to check if the output data object and/or the output
* model object are exist by calling m_OutputBIObject.hasResult(int) by passing BIObject.DATA
* and BIObject.MODEL respectively. You may check both existance or either one by simple modifying
* the logic below.
*/
if (m_OutputBIObject != null)
{
// return (m_OutputBIObject.hasResult(BIObject.DATA) &&
// m_OutputBIObject.hasResult(BIObject.MODEL));
return (m_OutputBIObject.hasResult(BIObject.DATA));
}else
{
return false;
}
}
/**
* Execute. Called when the user try to run the node. Noted that the number of
* parent nodes are assumed to checked by the caller. The input parameters are check as not null.
*
* @param a_OperatorNode OperatorNode. The executing operator node.
* @param a_Parents Vector of Operator. The parent operators connected to this operator
*
*/
public void execute(IOperatorNode a_OperatorNode, Vector a_Parents)
throws SysException
{
/* You may get the system message panel and append messages during the execution.
* systemMessage.nextLine(); or
* systemMessage.appendSystemMessage("Your Message Here.");
*/
//SystemMessagePanel systemMessage = (SystemMessagePanel) m_CaseWindow.getSystemMessagePanel();
/* Get parameter from user input
* String value = a_OperatorNode.getParameterValue("param");
* Handle the situation of null parameter. i.e. set default value or throw exception, etc...
*/
String value = (String) a_OperatorNode.getParameterValue("param");
if (value==null)
{
value = "0";
}
/* Get input mining object from the Vector of parent Operators
* If only one parent is allowed, it should be at the element zero.
* If multiple parents are allowed, the parents could be determined by the operator type. (getNodeType())
* */
Operator parentOp = (Operator)a_Parents.elementAt(0);
setInputBIObject(parentOp.getOutputBIObject());
IBIData aInputBIData = getInputBIObject().getBIData();
/* Prepare output data model
* Initial the output BIData and/or BIModel before doing the execution
* */
BIData aOutputBIData = new BIData(getCaseID(), getNodeID());
BIModel aOutputBIModel = new BIModel(getCaseID(), getNodeID(), IBIModel.TYPE_CLASSIFIER);
/* Execute model building
*
* Put the execution code here
*
* */
/* set output mining data and model to the output mining object
*
* After the execution finished, pack the output BIData and/or BIModel.
*
* */
aOutputBIData.setTargetAttribute(aInputBIData.getTargetAttribute());
aOutputBIData.setTransformActionHistory(aInputBIData.getTransformActionHistory());
aOutputBIData.setTargetAttribute(aInputBIData.getTargetAttribute());
aOutputBIData.setMiningStoredData(aInputBIData.getMiningStoredData());
m_OutputBIObject.setBIData(aOutputBIData);
m_OutputBIObject.setBIModel(aOutputBIModel);
/* Set run time parameter value to the node object,
* and it would be saved to the BIML for later retrival
*
*/
a_OperatorNode.setParameterValue("Temporary model", aOutputBIModel.getTempBIModelPath());
/* Write the output BIData or BIModel to temp space for operations to retrieve */
aOutputBIData.writeTempBIData();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -