KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > report > MReportLineSet


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.report;
15
16 import java.util.*;
17 import java.sql.*;
18 import java.math.*;
19 import java.io.Serializable JavaDoc;
20 import org.compiere.model.*;
21 import org.compiere.util.*;
22
23
24 /**
25  * Report Line Set Model
26  *
27  * @author Jorg Janke
28  * @version $Id: MReportLineSet.java,v 1.4 2003/07/05 06:06:49 jjanke Exp $
29  */

30 public class MReportLineSet extends X_PA_ReportLineSet
31 {
32     /**
33      * Constructor
34      * @param ctx context
35      * @param PA_ReportLineSet_ID id
36      */

37     public MReportLineSet (Properties ctx, int PA_ReportLineSet_ID)
38     {
39         super (ctx, PA_ReportLineSet_ID);
40         if (PA_ReportLineSet_ID == 0)
41         {
42         }
43         else
44             loadLines();
45     }
46
47     /** Contained Lines */
48     private MReportLine[] m_lines = null;
49
50     /**
51      * Load Lines
52      */

53     private void loadLines()
54     {
55         ArrayList list = new ArrayList();
56         String JavaDoc sql = "SELECT * FROM PA_ReportLine WHERE PA_ReportLineSet_ID=? AND IsActive='Y' ORDER BY SeqNo";
57         PreparedStatement pstmt = null;
58         try
59         {
60             pstmt = DB.prepareStatement(sql);
61             pstmt.setInt(1, getPA_ReportLineSet_ID());
62             ResultSet rs = pstmt.executeQuery();
63             while (rs.next())
64                 list.add(new MReportLine (getCtx(), rs));
65             rs.close();
66             pstmt.close();
67             pstmt = null;
68         }
69         catch (Exception JavaDoc e)
70         {
71             Log.error("MReportLineSet.loadLines", e);
72         }
73         finally
74         {
75             try
76             {
77                 if (pstmt != null)
78                     pstmt.close ();
79             }
80             catch (Exception JavaDoc e)
81             {}
82             pstmt = null;
83         }
84         //
85
m_lines = new MReportLine[list.size()];
86         list.toArray(m_lines);
87         Log.trace(8, "MReportLineSet.loadLines ID=" + getPA_ReportLineSet_ID(),
88           "Size=" + list.size());
89     } // loadColumns
90

91     public MReportLine[] getLiness()
92     {
93         return m_lines;
94     }
95
96     /**
97      * List Info
98      */

99     public void list()
100     {
101         System.out.println(toString());
102         if (m_lines == null)
103             return;
104         for (int i = 0; i < m_lines.length; i++)
105             m_lines[i].list();
106     } // list
107

108
109     public String JavaDoc toString ()
110     {
111         StringBuffer JavaDoc sb = new StringBuffer JavaDoc ("MReportLineSet[")
112             .append(getID()).append(" - ").append(getName())
113             .append ("]");
114         return sb.toString ();
115     }
116
117 } // MReportLineSet
118
Popular Tags