BF [ 2041799 ] Can't delete PP_Order_Node (Not found=PP_Order_Node_Trl)

BF [ 1874419 ] JDBC Statement not close in a finally block
* organized imports
* removed not used methods and properties
* fixed some warnings
This commit is contained in:
teo_sarca 2008-08-07 15:54:17 +00:00
parent e456509bf4
commit 2566e3d814
1 changed files with 30 additions and 144 deletions

View File

@ -16,19 +16,26 @@
*****************************************************************************/ *****************************************************************************/
package org.eevolution.model; package org.eevolution.model;
import java.awt.*; import java.awt.Point;
import java.math.*; import java.sql.ResultSet;
import java.sql.*; import java.util.ArrayList;
import java.util.*; import java.util.List;
import java.util.logging.*; import java.util.Properties;
import org.compiere.model.*;
import org.compiere.util.*; import org.compiere.model.MColumn;
import org.compiere.model.Query;
import org.compiere.util.CCache;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/** /**
* Workflow Node Model * Workflow Node Model
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MWFNode.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $ * @version $Id: MWFNode.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
*
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 2041799 ] Can't delete PP_Order_Node (Not found=PP_Order_Node_Trl)
*/ */
public class MPPOrderNode extends X_PP_Order_Node public class MPPOrderNode extends X_PP_Order_Node
{ {
@ -40,18 +47,17 @@ public class MPPOrderNode extends X_PP_Order_Node
*/ */
public static MPPOrderNode get (Properties ctx, int PP_Order_Node_ID) public static MPPOrderNode get (Properties ctx, int PP_Order_Node_ID)
{ {
Integer key = new Integer (PP_Order_Node_ID); MPPOrderNode retValue = s_cache.get (PP_Order_Node_ID);
MPPOrderNode retValue = (MPPOrderNode) s_cache.get (key);
if (retValue != null) if (retValue != null)
return retValue; return retValue;
retValue = new MPPOrderNode (ctx, PP_Order_Node_ID, null); retValue = new MPPOrderNode (ctx, PP_Order_Node_ID, null);
if (retValue.get_ID () != 0) if (retValue.get_ID () != 0)
s_cache.put (key, retValue); s_cache.put (PP_Order_Node_ID, retValue);
return retValue; return retValue;
} // get } // get
/** Cache */ /** Cache */
private static CCache<Integer,MPPOrderNode> s_cache = new CCache<Integer,MPPOrderNode> ("PP_Order_Node", 50); private static CCache<Integer,MPPOrderNode> s_cache = new CCache<Integer,MPPOrderNode> (Table_Name, 50);
/************************************************************************** /**************************************************************************
@ -83,7 +89,7 @@ public class MPPOrderNode extends X_PP_Order_Node
} }
// Save to Cache // Save to Cache
if (get_ID() != 0) if (get_ID() != 0)
s_cache.put (new Integer(getPP_Order_Node_ID()), this); s_cache.put (getPP_Order_Node_ID(), this);
} // MPPOrderNode } // MPPOrderNode
/** /**
@ -112,28 +118,15 @@ public class MPPOrderNode extends X_PP_Order_Node
{ {
super(ctx, rs, trxName); super(ctx, rs, trxName);
loadNext(); loadNext();
//Tranlsation table for PP_Order_Node does not exist
//loadTrl();
// Save to Cache // Save to Cache
s_cache.put (new Integer(getPP_Order_Node_ID()), this); s_cache.put (getPP_Order_Node_ID(), this);
} // MPPOrderNode } // MPPOrderNode
/** Next Modes */ /** Next Modes */
private ArrayList<MPPOrderNodeNext> m_next = new ArrayList<MPPOrderNodeNext>(); private List<MPPOrderNodeNext> m_next = new ArrayList<MPPOrderNodeNext>();
/** 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 */ /** Column */
private MColumn m_column = null; private MColumn m_column = null;
/** Process Parameters */
//private MPPOrderNodePara[] m_paras = null;
/** Duration Base MS */ /** Duration Base MS */
private long m_durationBaseMS = -1; private long m_durationBaseMS = -1;
@ -152,60 +145,18 @@ public class MPPOrderNode extends X_PP_Order_Node
*/ */
private void loadNext() private void loadNext()
{ {
String sql = "SELECT * FROM PP_Order_NodeNext WHERE PP_Order_Node_ID=? AND IsActive='Y' ORDER BY SeqNo";
boolean splitAnd = SPLITELEMENT_AND.equals(getSplitElement()); boolean splitAnd = SPLITELEMENT_AND.equals(getSplitElement());
try String whereClause = "PP_Order_Node_ID=? AND IsActive='Y'";
{ m_next = new Query(getCtx(), MPPOrderNodeNext.Table_Name, whereClause, get_TrxName())
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName()); .setParameters(new Object[]{get_ID()})
pstmt.setInt(1, get_ID()); .setOrderBy(MPPOrderNodeNext.COLUMNNAME_SeqNo)
ResultSet rs = pstmt.executeQuery(); .list();
while (rs.next()) for (MPPOrderNodeNext next : m_next) {
{ next.setFromSplitAnd(splitAnd);
MPPOrderNodeNext next = new MPPOrderNodeNext (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()); log.fine("#" + m_next.size());
} // loadNext } // loadNext
/**
* Load Translation
*/
private void loadTrl()
{
if (Env.isBaseLanguage(getCtx(), "PP_Order_Workflow") || get_ID() == 0)
return;
String sql = "SELECT Name, Description, Help FROM PP_Order_Node_Trl WHERE PP_Order_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 * Get Number of Next Nodes
* @return number of next nodes * @return number of next nodes
@ -234,43 +185,6 @@ public class MPPOrderNode extends X_PP_Order_Node
return retValue; return retValue;
} // getNextNodes } // 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 * Set Position
* @param position point * @param position point
@ -338,6 +252,7 @@ public class MPPOrderNode extends X_PP_Order_Node
* @see org.compiere.model.X_PP_Order_Node#getAttributeName() * @see org.compiere.model.X_PP_Order_Node#getAttributeName()
* @return Attribute Name * @return Attribute Name
*/ */
@Override
public String getAttributeName () public String getAttributeName ()
{ {
if (getAD_Column_ID() == 0) if (getAD_Column_ID() == 0)
@ -434,10 +349,7 @@ public class MPPOrderNode extends X_PP_Order_Node
public int getDurationCalendarField() public int getDurationCalendarField()
{ {
return getWorkflow().getDurationCalendarField(); return getWorkflow().getDurationCalendarField();
} // getDirationCalendarField } // getDurationCalendarField
/** /**
* Get Workflow * Get Workflow
@ -480,6 +392,7 @@ public class MPPOrderNode extends X_PP_Order_Node
* @param newRecord new * @param newRecord new
* @return true if can be saved * @return true if can be saved
*/ */
@Override
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
String action = getAction(); String action = getAction();
@ -566,31 +479,4 @@ public class MPPOrderNode extends X_PP_Order_Node
return true; return true;
} // beforeSave } // beforeSave
/**
* After Save
* @param newRecord new
* @param success success
* @return saved
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
//TranslationTable.save(this, newRecord);
return true;
} // afterSave
/**
* After Delete
* @param success success
* @return deleted
*/
protected boolean afterDelete (boolean success)
{
if (TranslationTable.isActiveLanguages(false))
TranslationTable.delete(this);
return success;
} // afterDelete
} // M_WFNext } // M_WFNext