KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > model > MWFNode


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.model;
15
16 import java.util.*;
17 import java.sql.*;
18 import java.awt.Point JavaDoc;
19
20 import org.compiere.util.*;
21
22 /**
23  * Workflow Node
24  *
25  * @author Jorg Janke
26  * @version $Id: MWFNode.java,v 1.2 2003/07/06 18:39:44 jjanke Exp $
27  */

28 public class MWFNode extends X_AD_WF_Node
29 {
30     /**
31      * Constructor
32      * @param ctx context
33      * @param rs result set to load info from
34      */

35     public MWFNode(Properties ctx, ResultSet rs)
36     {
37         super (ctx, rs);
38         Log.trace(Log.l5_DData, "MWFNode " + getAD_WF_Node_ID());
39         loadNext();
40         loadTrl();
41     } // MWFNode
42

43     /** Next Modes */
44     private ArrayList m_next = new ArrayList();
45     /** Translated Name */
46     private String JavaDoc m_name_trl = null;
47     /** Translated Description */
48     private String JavaDoc m_description_trl = null;
49     /** Translated Help */
50     private String JavaDoc m_help_trl = null;
51     /** Translation Flag */
52     private boolean m_translated = false;
53
54     /**
55      * Load Next
56      */

57     private void loadNext()
58     {
59         String JavaDoc sql = "SELECT * FROM AD_WF_NodeNext WHERE AD_WF_Node_ID=? AND IsActive='Y'";
60         try
61         {
62             PreparedStatement pstmt = DB.prepareStatement(sql);
63             pstmt.setInt(1, getID());
64             ResultSet rs = pstmt.executeQuery();
65             while (rs.next())
66                 m_next.add(new MWFNodeNext (getCtx(), rs));
67             rs.close();
68             pstmt.close();
69         }
70         catch (SQLException e)
71         {
72             Log.error("M_WorkFlow.loadNext", e);
73         }
74         Log.trace(Log.l6_Database, "MWFNode.loadNext #" + m_next.size());
75     } // loadNext
76

77     /**
78      * Load Translation
79      */

80     private void loadTrl()
81     {
82         if (Env.isBaseLanguage(getCtx(), "AD_Workflow") || getID() == 0)
83             return;
84         String JavaDoc sql = "SELECT Name, Description, Help FROM AD_WF_Node_Trl WHERE AD_WF_Node_ID=? AND AD_Language=?";
85         try
86         {
87             PreparedStatement pstmt = DB.prepareStatement(sql);
88             pstmt.setInt(1, getID());
89             pstmt.setString(2, Env.getAD_Language(getCtx()));
90             ResultSet rs = pstmt.executeQuery();
91             if (rs.next())
92             {
93                 m_name_trl = rs.getString(1);
94                 m_description_trl = rs.getString(2);
95                 m_help_trl = rs.getString(3);
96                 m_translated = true;
97             }
98             rs.close();
99             pstmt.close();
100         }
101         catch (SQLException e)
102         {
103             Log.error("MWFNode.loadTrl", e);
104         }
105         Log.trace(Log.l6_Database, "MWFNode.loadTrl " + m_translated);
106     } // loadTrl
107

108     /**
109      * Get Number of Next Nodes
110      * @return number of next nodes
111      */

112     public int getNextNodeCount()
113     {
114         return m_next.size();
115     } // getNextNodeCount
116

117     /**
118      * Get the next nodes
119      * @return array of next nodes
120      */

121     public MWFNodeNext[] getNextNodes()
122     {
123         MWFNodeNext[] retValue = new MWFNodeNext [m_next.size()];
124         m_next.toArray(retValue);
125         return retValue;
126     } // getNextNodes
127

128     /*************************************************************************/
129
130     /**
131      * Get Name
132      * @param translated translated
133      * @return Name
134      */

135     public String JavaDoc getName(boolean translated)
136     {
137         if (translated && m_translated)
138             return m_name_trl;
139         return getName();
140     } // getName
141

142     /**
143      * Get Description
144      * @param translated translated
145      * @return Description
146      */

147     public String JavaDoc getDescription(boolean translated)
148     {
149         if (translated && m_translated)
150             return m_description_trl;
151         return getDescription();
152     } // getDescription
153

154     /**
155      * Get Help
156      * @param translated translated
157      * @return Name
158      */

159     public String JavaDoc getHelp(boolean translated)
160     {
161         if (translated && m_translated)
162             return m_help_trl;
163         return getHelp();
164     } // getHelp
165

166     /**
167      * Set Position
168      * @param position point
169      */

170     public void setPosition (Point JavaDoc position)
171     {
172         setXposition(position.x);
173         setYposition(position.y);
174     } // setPosition
175

176     /**
177      * Get Position
178      * @return position point
179      */

180     public Point JavaDoc getPosition ()
181     {
182         return new Point JavaDoc (getXposition(), getYposition());
183     } // getPosition
184

185 } // M_WFNext
186
Popular Tags