KickJava   Java API By Example, From Geeks To Geeks.

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


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
21 import org.compiere.model.*;
22 import org.compiere.util.*;
23
24
25 /**
26  * Report Column Set Model
27  *
28  * @author Jorg Janke
29  * @version $Id: MReportColumnSet.java,v 1.4 2003/07/05 06:06:49 jjanke Exp $
30  */

31 public class MReportColumnSet extends X_PA_ReportColumnSet
32 {
33     /**
34      * Constructor
35      * @param ctx context
36      * @param PA_ReportColumnSet_ID id
37      */

38     public MReportColumnSet (Properties ctx, int PA_ReportColumnSet_ID)
39     {
40         super (ctx, PA_ReportColumnSet_ID);
41         if (PA_ReportColumnSet_ID == 0)
42         {
43         }
44         else
45             loadColumns();
46     } // MReportColumnSet
47

48     /** Contained Columns */
49     private MReportColumn[] m_columns = null;
50
51     /**
52      * Load contained columns
53      */

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

92     public MReportColumn[] getColumns()
93     {
94         return m_columns;
95     }
96
97     /**
98      * List Info
99      */

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

109     /*************************************************************************/
110
111     /**
112      * String Representation
113      * @return info
114      */

115     public String JavaDoc toString ()
116     {
117         StringBuffer JavaDoc sb = new StringBuffer JavaDoc ("MReportColumnSet[")
118             .append(getID()).append(" - ").append(getName())
119             .append ("]");
120         return sb.toString ();
121     }
122
123 } // MReportColumnSet
124
Popular Tags