📄 casehandler.java
字号:
Object[] obj = {a_CaseID, a_NodeID};
try
{
BICase selectedCase = getCase(a_CaseID, false);
selectedCase.removeNode(NodeFactory.OPERATOR, a_NodeID);
setCase(selectedCase);
}
catch (AppException ae)
{
throw new AppException(ae, obj);
}
catch (Exception e)
{
throw new SysException(e, obj);
}
}
/**
* Sets status of a case.
* @param a_CaseID ID of the case to be set.
* @param a_Status status of the case
*/
public void setCaseStatus(String a_CaseID, String a_Status)
throws BaseException {
Object[] obj = {a_CaseID, a_Status};
try
{
CommunicationHandlerBridge.getInstance().setCaseStatus(a_CaseID, a_Status);
BICase selectedCase = getCase(a_CaseID, false);
selectedCase.setStatus(a_Status);
setCase(selectedCase);
}
catch (AppException ae)
{
throw new AppException(ae, obj);
}
catch (Exception e)
{
throw new SysException(e, obj);
}
}
/**
* Stores the local copy of case into the server.
* @param a_CaseID ID of the case to be stored.
*/
public String storeCase(String a_CaseID) throws BaseException {
Object[] obj = {a_CaseID};
try
{
BICase selectedCase = getCase(a_CaseID, false);
String newCaseID = CommunicationHandlerBridge.getInstance().storeCase(selectedCase);
//System.out.println("new case id: " + newCaseID);
if (newCaseID == null)
{
throw new SysException("Fail to save case: "+newCaseID);
}else if (!newCaseID.equals(a_CaseID))
{
BICase storedCase = (BICase) m_CaseList.get(a_CaseID);
CaseDiagramPanel selectedCaseDiagram = CaseDiagramPanel.getCaseDiagramPanel(a_CaseID);
if (selectedCaseDiagram!=null)
{
selectedCaseDiagram.setCaseID(newCaseID);
}
storedCase.setCaseID(newCaseID);
storedCase.setCaseIDForNodes(newCaseID);
setCase(storedCase);
m_CaseList.remove(a_CaseID);
//System.out.println("save succeed");
if (storedCase.getStatus().equals(BICase.NEW))
{
setCaseStatus(newCaseID, BICase.DEACTIVATE);
}
File f = new File(SysConfig.getProperty("TEMP_CASES"), "case_"+a_CaseID);
if (f.exists())
{
f.renameTo(new File(SysConfig.getProperty("TEMP_CASES"), "case_"+newCaseID));
Node[] nodes = storedCase.getOperatorNodeListArray();
if (nodes!=null)
{
OperatorNode node = null;
String tempLocation = null;
for (int i=0; i<nodes.length; i++)
{
node = (OperatorNode) nodes[i];
tempLocation = (String) node.getParameterValue("Temporary data");
if (tempLocation!=null)
{
tempLocation = tempLocation.replaceFirst(a_CaseID, newCaseID);
node.setParameterValue("Temporary data", tempLocation);
}
tempLocation = (String) node.getParameterValue("Temporary model");
if (tempLocation!=null)
{
tempLocation = tempLocation.replaceFirst(a_CaseID, newCaseID);
node.setParameterValue("Temporary model", tempLocation);
}
}
CommunicationHandlerBridge.getInstance().storeCase(
getCase(newCaseID, false));
}
}
}
else
{
//System.out.println("save succeed");
}
return newCaseID;
}
catch (AppException ae)
{
throw new AppException(ae, obj);
}
catch (Exception e)
{
throw new SysException(e, obj);
}
}
/**
* Updates a node of a local case.
* @param a_Node a Node instance with updated properties.
*/
public void updateNode(INode a_Node) throws BaseException {
Object[] obj = {a_Node};
try
{
BICase selectedCase = getCase(a_Node.getCaseID(), false);
selectedCase.setNode(a_Node);
setCase(selectedCase);
}
catch (AppException ae)
{
throw new AppException(ae, obj);
}
catch (Exception e)
{
throw new SysException(e, obj);
}
}
/**
* Updates a node of a local case.
* @param a_Node a Node instance with updated properties.
*/
public void updateOperatorNode(IOperatorNode a_Node) throws BaseException {
Object[] obj = {a_Node};
try
{
BICase selectedCase = getCase(a_Node.getCaseID(), false);
selectedCase.setOperatorNode(a_Node);
setCase(selectedCase);
}
catch (AppException ae)
{
throw new AppException(ae, obj);
}
catch (Exception e)
{
throw new SysException(e, obj);
}
}
/**
* Registers an observer for CaseHandler instance.
* @param a_Observer object that is interested on changes occurred in the
* CaseHandler instance.
*/
@SuppressWarnings("unchecked")
public void registerInterest(Observer a_Observer) {
m_Observers.add(a_Observer);
//System.out.println("register " + ((CaseWindow) a_Observer).getCaseID());
}
/**
* Unregisters an observer for CaseHandler instance.
* @param a_Observer object to be unregistered in the
* CaseHandler instance.
*/
public void unregisterInterest(Observer a_Observer)
{
m_Observers.remove(a_Observer);
//System.out.println("unregister " + m_Observers.remove(a_Observer));
}
/**
* Frees the resources hold by the CaseHandler instance.
*/
/*
protected void finalize() {
m_CaseHandler = null;
}
*/
/**
* Excutes a Node and return the result obtained after execution.
* @param a_Case ID the case containing the node.
* @param a_NodeID ID of the node being executed.
* @param a_Window the case window to be notified.
* @param a_Set hash table storing the ID of nodes executed so far.
* @throws AppException
* @throws MiningException
* @throws kbbiapplication.exception.SysException
* @throws Exception
*/
@SuppressWarnings("unchecked")
private void executeNode (
BICase a_Case,
Vector<String> NodeIDs,
CaseWindow a_Window,
HashSet a_Set) throws SysException, AppException, MiningException {
Operator operator = ((CaseDiagramPanel) a_Window.getDiagramDrawingPanel()).getOperator(NodeIDs.elementAt(0));
CaseHelpToolBarHandler caseHelpToolBarHandler = a_Window.getCaseHelpToolBarHandler();
if(caseHelpToolBarHandler!=null) {
caseHelpToolBarHandler.selectOperatorProgress();
caseHelpToolBarHandler.setProgress(operator.hasResult());
if(caseHelpToolBarHandler.hasThread()) {
m_MessageDialog.showWarning(Resource.srcStr("operatorrunning"), Resource.srcStr("NodeMessage"));
return;
}
}
OperatorProcessThread operatorthread = new OperatorProcessThread(a_Case, NodeIDs, a_Window, a_Set,this);
if(caseHelpToolBarHandler!=null) {
caseHelpToolBarHandler.setOperatorThread(operatorthread);
}
operatorthread.start();
operatorthread = null;
//((SystemMessagePanel) a_Window.getSystemMessagePanel()).appendSystemMessage("()");
//return nodeResult;
}
/**
* Shows clusters.
*
* @param clustModel clustering model to show
* @throws MiningException cannot show clusters
*/
@SuppressWarnings("unused")
private void showClusters(ClusteringMiningModel clustModel,SystemMessagePanel systemMessage)
throws MiningException {
// SystemMessagePanel.appendMessage(m_CaseID,"number of clusters: " + clustModel.getNumberOfClusters());
Cluster[] clust = clustModel.getClusters();
/* for (int i = 0; i < clust.length; i++)
SystemMessagePanel.appendMessage("clust"+i+": " + clust[i].toString() );*/
}
private void processApplyTree(OperatorNode a_OperatorNode, CaseWindow a_Window, BICase a_Case)
throws MiningException
{
/* Vector parentNodes = a_Case.getParentOfNodes(a_OperatorNode.getNodeID());
Operator operator = null;
InputDataOperator inputOp = null;
for (int i = 0; i < parentNodes.size(); i++) {
operator = ((CaseDiagramPanel) a_Window.getDiagramDrawingPanel()).getOperatorNode((String) parentNodes.elementAt(i));
if (operator instanceof InputDataOperator)
{
//inputNode = (OperatorNode)a_Case.getNode(NodeFactory.OPERATOR, operator.getNodeID());
inputOp = (InputDataOperator) operator;
break;
}
else
continue;
}
if (inputOp==null)
throw new MiningException("Please specify Input Data for applying the Decision Tree Model.");
else if (!inputOp.hasResult())
executeNode(a_Case, inputOp.getNodeID(), a_Window, null);
a_Window.sendNotify("run node|" + a_OperatorNode.getNodeID());
try
{
Operator op = ((CaseDiagramPanel) a_Window.getDiagramDrawingPanel()).getOperatorNode(a_OperatorNode.getNodeID());
Vector parent = new Vector();
operator = inputOp;
parent.add(operator);
op.apply(null, parent);
} catch (MiningException me)
{
a_Window.sendNotify("error node|" + a_OperatorNode.getNodeID());
throw me;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
a_Window.sendNotify("finish node|" + a_OperatorNode.getNodeID());
System.out.println("Finish applying tree");*/
}
/**
* Initalizes members of the CaseHandler class.
*/
private void initialization() {
m_CaseList = new Hashtable();
m_Observers = new Vector();
}
/**
* Inserts a case into the local case list. If the case is already exists,
* the new case instance overwrites the existing one; else the case instance
* is added in the case list.
* @param a_Case a Case to be inserted.
*/
@SuppressWarnings("unchecked")
public void setCase(BICase a_Case) {
//System.out.print("add case to local:");
m_CaseList.put(a_Case.getCaseID(), a_Case);
}
/* To be deleted*/
@SuppressWarnings("unused")
private void printDebug() {
Object[] keys = m_CaseList.keySet().toArray();
for (int i = 0; i < keys.length; i++) {
System.out.println(
(String) keys[i]
+ " "
+ ((BICase) m_CaseList.get(keys[i])).getCaseID());
}
}
/* (non-Javadoc)
* @see eti.bi.alphaminer.core.handler.ICaseHandler#getCaseDiagram(java.lang.String)
*/
public ICaseDiagram getCaseDiagram(String m_CaseID) {
return CaseDiagramPanel.getCaseDiagramPanel(m_CaseID);
}
/* (non-Javadoc)
* @see eti.bi.alphaminer.core.handler.ICaseHandler#getSystemMessageHandler()
*/
public ISystemMessageHandler getSystemMessageHandler(String a_CaseID)
{
return SystemMessagePanel.getInstance(a_CaseID);
}
/* (non-Javadoc)
* @see eti.bi.alphaminer.core.handler.ICaseHandler#removeSystemMessageHandler(String)
*/
public void removeSystemMessageHandler(String a_CaseID) {
SystemMessagePanel.removeInstance(a_CaseID);
}
public IMessageDialog getMessageDialog()
{
return m_MessageDialog;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -