KickJava   Java API By Example, From Geeks To Geeks.

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


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 Smart 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-2003 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.sql.*;
17 import java.util.*;
18
19 import org.compiere.util.*;
20
21 /**
22  * Time + Expense Model
23  *
24  * @author Jorg Janke
25  * @version $Id: MTimeExpense.java,v 1.1 2003/09/05 04:59:48 jjanke Exp $
26  */

27 public class MTimeExpense extends X_S_TimeExpense
28 {
29     public MTimeExpense (Properties ctx, int S_TimeExpense_ID)
30     {
31         super (ctx, S_TimeExpense_ID);
32         if (S_TimeExpense_ID == 0)
33         {
34             setC_BPartner_ID (0);
35             setDateReport (new Timestamp (System.currentTimeMillis ()));
36             setDocumentNo (null);
37             setIsApproved (false);
38             setM_PriceList_ID (0);
39             setM_Warehouse_ID (0);
40             setProcessed (false);
41             setS_TimeExpense_ID (0);
42         }
43     } // MTimeExpense
44

45     public MTimeExpense (Properties ctx, ResultSet rs)
46     {
47         super (ctx, rs);
48     } // MTimeExpense
49

50     /** Default Locator */
51     private int m_M_Locator_ID = 0;
52
53
54     public MTimeExpenseLine[] getLines()
55     {
56         ArrayList list = new ArrayList();
57         //
58
String JavaDoc sql = "SELECT * FROM S_TimeExpenseLine WHERE S_TimeExpense_ID=? ORDER BY Line";
59         PreparedStatement pstmt = null;
60         try
61         {
62             pstmt = DB.prepareStatement (sql);
63             pstmt.setInt (1, getS_TimeExpense_ID());
64             ResultSet rs = pstmt.executeQuery ();
65             while (rs.next ())
66                 list.add(new MTimeExpenseLine(getCtx(), rs));
67             rs.close ();
68             pstmt.close ();
69             pstmt = null;
70         }
71         catch (SQLException ex)
72         {
73             log.error ("getLines", ex);
74         }
75         try
76         {
77             if (pstmt != null)
78                 pstmt.close ();
79         }
80         catch (SQLException ex1)
81         {
82         }
83         pstmt = null;
84         //
85
MTimeExpenseLine[] retValue = new MTimeExpenseLine[list.size()];
86         list.toArray(retValue);
87         return retValue;
88     } // getLines
89

90     /**
91      * Get Default Locator (from Warehouse)
92      * @return locator
93      */

94     public int getM_Locator_ID()
95     {
96         if (m_M_Locator_ID != 0)
97             return m_M_Locator_ID;
98         //
99
String JavaDoc sql = "SELECT M_Locator_ID FROM M_Locator "
100             + "WHERE M_Warehouse_ID=? AND IsActive='Y' ORDER BY IsDefault DESC, Created";
101         PreparedStatement pstmt = null;
102         try
103         {
104             pstmt = DB.prepareStatement (sql);
105             pstmt.setInt (1, getM_Warehouse_ID());
106             ResultSet rs = pstmt.executeQuery ();
107             if (rs.next ())
108                 m_M_Locator_ID = rs.getInt(1);
109             rs.close ();
110             pstmt.close ();
111             pstmt = null;
112         }
113         catch (SQLException ex)
114         {
115             log.error ("getM_Locator_ID", ex);
116         }
117         try
118         {
119             if (pstmt != null)
120                 pstmt.close ();
121         }
122         catch (SQLException ex1)
123         {
124         }
125         pstmt = null;
126         //
127
return m_M_Locator_ID;
128     } // getM_Locator_ID
129

130 } // MTimeExpense
131
Popular Tags