KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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

43     public String JavaDoc toString()
44     {
45         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("MRoleOrgAccess[");
46         sb.append("AD_Role_ID=").append(getAD_Role_ID())
47             .append(",AD_Client_ID=").append(getAD_Client_ID())
48             .append(",AD_Org_ID=").append(getAD_Org_ID());
49         sb.append("]");
50         return sb.toString();
51     } // toString
52

53     /**
54      * Extended String Representation
55      * @return extended info
56      */

57     public String JavaDoc toStringX (Properties ctx)
58     {
59         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
60         sb.append(Msg.translate(ctx, "AD_Client_ID")).append("=").append(getClientName()).append(" - ")
61             .append(Msg.translate(ctx, "AD_Org_ID")).append("=").append(getOrgName());
62         return sb.toString();
63     } // toStringX
64

65     private String JavaDoc m_clientName;
66     private String JavaDoc m_orgName;
67     
68     /**
69      * Get Client Name
70      * @return name
71      */

72     public String JavaDoc getClientName()
73     {
74         if (m_clientName == null)
75         {
76             String JavaDoc sql = "SELECT c.Name, o.Name "
77                 + "FROM AD_Client c INNER JOIN AD_Org o ON (c.AD_Client_ID=o.AD_Client_ID) "
78                 + "WHERE o.AD_Org_ID=?";
79             PreparedStatement pstmt = null;
80             try
81             {
82                 pstmt = DB.prepareCall(sql);
83                 pstmt.setInt(1, getAD_Org_ID());
84                 ResultSet rs = pstmt.executeQuery();
85                 if (rs.next())
86                 {
87                     m_clientName = rs.getString(1);
88                     m_orgName = rs.getString(2);
89                 }
90                 rs.close();
91                 pstmt.close();
92                 pstmt = null;
93             }
94             catch (Exception JavaDoc e)
95             {
96                 log.error("getClientName", e);
97             }
98             try
99             {
100                 if (pstmt != null)
101                     pstmt.close();
102                 pstmt = null;
103             }
104             catch (Exception JavaDoc e)
105             {
106                 pstmt = null;
107             }
108         }
109         return m_clientName;
110     } // getClientName
111

112     /**
113      * Get Client Name
114      * @return name
115      */

116     public String JavaDoc getOrgName()
117     {
118         if (m_orgName == null)
119             getClientName();
120         return m_orgName;
121     } // getOrgName
122

123 } // MRoleOrgAccess
124
Free Books   Free Magazines  
Popular Tags