KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.*;
17 import java.sql.*;
18
19 import javax.mail.internet.*;
20
21 /**
22  * User Model
23  *
24  * @author Jorg Janke
25  * @version $Id: MUser.java,v 1.3 2003/08/08 16:14:35 jjanke Exp $
26  */

27 public class MUser extends X_AD_User
28 {
29     /**
30      * Default Constructor
31      * @param ctx context
32      * @param AD_User_ID id
33      */

34     public MUser (Properties ctx, int AD_User_ID)
35     {
36         this (ctx, AD_User_ID, 0);
37     } // MUser
38

39     /**
40      * Default Constructor
41      * @param ctx context
42      * @param AD_User_ID id
43      * @param C_BPartner_ID parent
44      */

45     public MUser (Properties ctx, int AD_User_ID, int C_BPartner_ID)
46     {
47         super (ctx, AD_User_ID);
48         if (AD_User_ID == 0)
49         {
50             if (C_BPartner_ID != 0)
51                 setC_BPartner_ID (C_BPartner_ID);
52
53         // setName (".");
54
}
55     } // MUser
56

57     /**
58      * Constructor from ResultSet row
59      *
60      * @param ctx context
61      * @param rs current row of result set to be loaded
62      */

63     public MUser (Properties ctx, ResultSet rs)
64     {
65         super (ctx, rs);
66     } // MUser
67

68     /**
69      * String Representation
70      * @return Info
71      */

72     public String JavaDoc toString ()
73     {
74         StringBuffer JavaDoc sb = new StringBuffer JavaDoc ("MUser[ID=")
75             .append(getID())
76             .append(",Name=").append(getName())
77             .append ("]");
78         return sb.toString ();
79     } // toString
80

81     /**
82      * Is it an Online Access User
83      * @return true if it has an email and password
84      */

85     public boolean isOnline ()
86     {
87         if (getEmail() == null || getPassword() == null)
88             return false;
89         return true;
90     } // isOnline
91

92     /**
93      * Convert EMail
94      * @return Valid Internet Address
95      */

96     public InternetAddress getInternetAddress ()
97     {
98         String JavaDoc email = getEmail();
99         if (email == null || email.length() == 0)
100             return null;
101         try
102         {
103             return new InternetAddress (email, true);
104         }
105         catch (AddressException ex)
106         {
107             log.warn("getInternetAddress - " + email + " - " + ex.getLocalizedMessage());
108         }
109         return null;
110     } // getInternetAddress
111

112     /**
113      * Return Email Validation.
114      * @return return true if email is valid
115      */

116     public boolean isEMailValid()
117     {
118         return getInternetAddress() != null;
119     } // isEMaulValid
120

121     /**
122      * Set Client/Org
123      * @param AD_Client_ID client
124      * @param AD_Org_ID org
125      */

126     public void setClientOrg (int AD_Client_ID, int AD_Org_ID)
127     {
128         setAD_Client_ID(AD_Client_ID);
129         setAD_Org_ID(AD_Org_ID);
130     } // setClientOrg
131

132 } // MUser
133
Popular Tags