📄 mwfnode.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.wf;
import java.awt.*;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.compiere.model.*;
import org.compiere.util.*;
/**
* Workflow Node Model
*
* @author Jorg Janke
* @version $Id: MWFNode.java,v 1.30 2005/11/13 22:21:21 jjanke Exp $
*/
public class MWFNode extends X_AD_WF_Node
{
/**
* Get WF Node from Cache
* @param ctx context
* @param AD_WF_Node_ID id
* @return MWFNode
*/
public static MWFNode get (Properties ctx, int AD_WF_Node_ID)
{
Integer key = new Integer (AD_WF_Node_ID);
MWFNode retValue = (MWFNode) s_cache.get (key);
if (retValue != null)
return retValue;
retValue = new MWFNode (ctx, AD_WF_Node_ID, null);
if (retValue.get_ID () != 0)
s_cache.put (key, retValue);
return retValue;
} // get
/** Cache */
private static CCache<Integer,MWFNode> s_cache = new CCache<Integer,MWFNode> ("AD_WF_Node", 50);
/**************************************************************************
* Standard Constructor - save to cache
* @param ctx context
* @param AD_WF_Node_ID id
*/
public MWFNode (Properties ctx, int AD_WF_Node_ID, String trxName)
{
super (ctx, AD_WF_Node_ID, trxName);
if (AD_WF_Node_ID == 0)
{
// setAD_WF_Node_ID (0);
// setAD_Workflow_ID (0);
// setValue (null);
// setName (null);
setAction (ACTION_WaitSleep);
setCost (Env.ZERO);
setDuration (0);
setEntityType (ENTITYTYPE_UserMaintained); // U
setIsCentrallyMaintained (true); // Y
setJoinElement (JOINELEMENT_XOR); // X
setLimit (0);
setSplitElement (SPLITELEMENT_XOR); // X
setWaitingTime (0);
setXPosition (0);
setYPosition (0);
}
// Save to Cache
if (get_ID() != 0)
s_cache.put (new Integer(getAD_WF_Node_ID()), this);
} // MWFNode
/**
* Parent Constructor
* @param wf workflow (parent)
* @param Value value
* @param Name name
*/
public MWFNode (MWorkflow wf, String Value, String Name)
{
this (wf.getCtx(), 0, wf.get_TrxName());
setClientOrg(wf);
setAD_Workflow_ID (wf.getAD_Workflow_ID());
setValue (Value);
setName (Name);
m_durationBaseMS = wf.getDurationBaseSec() * 1000;
} // MWFNode
/**
* Load Constructor - save to cache
* @param ctx context
* @param rs result set to load info from
*/
public MWFNode (Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
loadNext();
loadTrl();
// Save to Cache
s_cache.put (new Integer(getAD_WF_Node_ID()), this);
} // MWFNode
/** Next Modes */
private ArrayList<MWFNodeNext> m_next = new ArrayList<MWFNodeNext>();
/** Translated Name */
private String m_name_trl = null;
/** Translated Description */
private String m_description_trl = null;
/** Translated Help */
private String m_help_trl = null;
/** Translation Flag */
private boolean m_translated = false;
/** Column */
private M_Column m_column = null;
/** Process Parameters */
private MWFNodePara[] m_paras = null;
/** Duration Base MS */
private long m_durationBaseMS = -1;
/**
* Set Client Org
* @param AD_Client_ID client
* @param AD_Org_ID org
*/
public void setClientOrg (int AD_Client_ID, int AD_Org_ID)
{
super.setClientOrg (AD_Client_ID, AD_Org_ID);
} // setClientOrg
/**
* Load Next
*/
private void loadNext()
{
String sql = "SELECT * FROM AD_WF_NodeNext WHERE AD_WF_Node_ID=? AND IsActive='Y' ORDER BY SeqNo";
boolean splitAnd = SPLITELEMENT_AND.equals(getSplitElement());
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, get_ID());
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
MWFNodeNext next = new MWFNodeNext (getCtx(), rs, get_TrxName());
next.setFromSplitAnd(splitAnd);
m_next.add(next);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
log.fine("#" + m_next.size());
} // loadNext
/**
* Load Translation
*/
private void loadTrl()
{
if (Env.isBaseLanguage(getCtx(), "AD_Workflow") || get_ID() == 0)
return;
String sql = "SELECT Name, Description, Help FROM AD_WF_Node_Trl WHERE AD_WF_Node_ID=? AND AD_Language=?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, get_ID());
pstmt.setString(2, Env.getAD_Language(getCtx()));
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
m_name_trl = rs.getString(1);
m_description_trl = rs.getString(2);
m_help_trl = rs.getString(3);
m_translated = true;
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
log.fine("Trl=" + m_translated);
} // loadTrl
/**
* Get Number of Next Nodes
* @return number of next nodes
*/
public int getNextNodeCount()
{
return m_next.size();
} // getNextNodeCount
/**
* Get the transitions
* @param AD_Client_ID for client
* @return array of next nodes
*/
public MWFNodeNext[] getTransitions(int AD_Client_ID)
{
ArrayList<MWFNodeNext> list = new ArrayList<MWFNodeNext>();
for (int i = 0; i < m_next.size(); i++)
{
MWFNodeNext next = m_next.get(i);
if (next.getAD_Client_ID() == 0 || next.getAD_Client_ID() == AD_Client_ID)
list.add(next);
}
MWFNodeNext[] retValue = new MWFNodeNext [list.size()];
list.toArray(retValue);
return retValue;
} // getNextNodes
/**************************************************************************
* Get Name
* @param translated translated
* @return Name
*/
public String getName(boolean translated)
{
if (translated && m_translated)
return m_name_trl;
return getName();
} // getName
/**
* Get Description
* @param translated translated
* @return Description
*/
public String getDescription(boolean translated)
{
if (translated && m_translated)
return m_description_trl;
return getDescription();
} // getDescription
/**
* Get Help
* @param translated translated
* @return Name
*/
public String getHelp(boolean translated)
{
if (translated && m_translated)
return m_help_trl;
return getHelp();
} // getHelp
/**
* Set Position
* @param position point
*/
public void setPosition (Point position)
{
setPosition(position.x, position.y);
} // setPosition
/**
* Set Position
* @param x x
* @param y y
*/
public void setPosition (int x, int y)
{
setXPosition(x);
setYPosition(y);
} // setPosition
/**
* Get Position
* @return position point
*/
public Point getPosition ()
{
return new Point (getXPosition(), getYPosition());
} // getPosition
/**
* Get Action Info
* @return info
*/
public String getActionInfo()
{
String action = getAction();
if (ACTION_AppsProcess.equals(action))
return "Process:AD_Process_ID=" + getAD_Process_ID();
else if (ACTION_DocumentAction.equals(action))
return "DocumentAction=" + getDocAction();
else if (ACTION_AppsReport.equals(action))
return "Report:AD_Process_ID=" + getAD_Process_ID();
else if (ACTION_AppsTask.equals(action))
return "Task:AD_Task_ID=" + getAD_Task_ID();
else if (ACTION_SetVariable.equals(action))
return "SetVariable:AD_Column_ID=" + getAD_Column_ID();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -