KickJava   Java API By Example, From Geeks To Geeks.

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


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-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  *
23  *
24  * @author Jorg Janke
25  * @version $Id: MTableAccess.java,v 1.1 2003/11/01 02:33:35 jjanke Exp $
26  */

27 public class MTableAccess extends X_AD_Table_Access
28 {
29     /**
30      * Load Constructor
31      * @param ctx context
32      * @param rs result set
33      */

34     public MTableAccess(Properties ctx, ResultSet rs)
35     {
36         super(ctx, rs);
37     } // MTableAccess
38

39     /**
40      * String Representation
41      * @return info
42      */

43     public String JavaDoc toString()
44     {
45         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("MTableAccess[");
46         sb.append("AD_Role_ID=").append(getAD_Role_ID())
47             .append(",AD_Table_ID=").append(getAD_Table_ID())
48             .append(",Exclude=").append(isExclude())
49             .append(",Type=").append(getAccessTypeRule());
50         if (ACCESSTYPERULE_Accessing.equals(getAccessTypeRule()))
51             sb.append("-ReadOnly=").append(isReadOnly());
52         else if (ACCESSTYPERULE_Exporting.equals(getAccessTypeRule()))
53             sb.append("-CanExport=").append(isCanExport());
54         else if (ACCESSTYPERULE_Reporting.equals(getAccessTypeRule()))
55             sb.append("-CanReport=").append(isCanReport());
56         sb.append("]");
57         return sb.toString();
58     } // toString
59

60     /**
61      * Extended String Representation
62      * @return extended info
63      */

64     public String JavaDoc toStringX (Properties ctx)
65     {
66         String JavaDoc in = Msg.getMsg(ctx, "Include");
67         String JavaDoc ex = Msg.getMsg(ctx, "Exclude");
68         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
69         sb.append(Msg.translate(ctx, "AD_Table_ID"))
70             .append("=").append(getTableName(ctx));
71         if (ACCESSTYPERULE_Accessing.equals(getAccessTypeRule()))
72             sb.append(" - ").append(Msg.translate(ctx, "IsReadOnly")).append("=").append(isReadOnly());
73         else if (ACCESSTYPERULE_Exporting.equals(getAccessTypeRule()))
74             sb.append(" - ").append(Msg.translate(ctx, "IsCanExport")).append("=").append(isCanExport());
75         else if (ACCESSTYPERULE_Reporting.equals(getAccessTypeRule()))
76             sb.append(" - ").append(Msg.translate(ctx, "IsCanReport")).append("=").append(isCanReport());
77         sb.append(" - ").append(isExclude() ? ex : in);
78         return sb.toString();
79     } // toStringX
80

81     /** TableName */
82     private String JavaDoc m_tableName;
83
84     /**
85      * Get Table Name
86      * @param ctx context
87      * @return table name
88      */

89     public String JavaDoc getTableName (Properties ctx)
90     {
91         if (m_tableName == null)
92         {
93             String JavaDoc sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
94             PreparedStatement pstmt = null;
95             try
96             {
97                 pstmt = DB.prepareCall(sql);
98                 pstmt.setInt(1, getAD_Table_ID());
99                 ResultSet rs = pstmt.executeQuery();
100                 if (rs.next())
101                     m_tableName = rs.getString(1);
102                 rs.close();
103                 pstmt.close();
104                 pstmt = null;
105             }
106             catch (Exception JavaDoc e)
107             {
108                 log.error("getTableName", e);
109             }
110             try
111             {
112                 if (pstmt != null)
113                     pstmt.close();
114                 pstmt = null;
115             }
116             catch (Exception JavaDoc e)
117             {
118                 pstmt = null;
119             }
120             // Get Clear Text
121
String JavaDoc realName = Msg.translate(ctx, m_tableName + "_ID");
122             if (!realName.equals(m_tableName + "_ID"))
123                 m_tableName = realName;
124         }
125         return m_tableName;
126     } // getTableName
127

128 } // MTableAccess
129
Popular Tags