KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.compiere.util.*;
19
20 /**
21  * System
22  *
23  * @author Jorg Janke
24  * @version $Id: MSystem.java,v 1.4 2003/10/04 03:55:45 jjanke Exp $
25  */

26 public class MSystem extends X_AD_System
27 {
28     /**
29      * Load System Record
30      * @param ctx context
31      * @return System
32      */

33     public static MSystem get (Properties ctx)
34     {
35         MSystem system = null;
36         String JavaDoc sql = "SELECT * FROM AD_System";
37         PreparedStatement pstmt = null;
38         try
39         {
40             pstmt = DB.prepareStatement(sql);
41             ResultSet rs = pstmt.executeQuery();
42             if (rs.next())
43                 system = new MSystem (ctx, rs);
44             rs.close();
45             pstmt.close();
46             pstmt = null;
47         }
48         catch (SQLException ex)
49         {
50             s_log.error("get", ex);
51         }
52         try
53         {
54             if (pstmt != null)
55                 pstmt.close();
56         }
57         catch (SQLException ex1)
58         {
59         }
60         pstmt = null;
61         return system;
62     } // get
63

64     /**
65      * Constructor
66      * @param ctx context
67      * @param rs result set
68      */

69     public MSystem (Properties ctx, ResultSet rs)
70     {
71         super (ctx, rs);
72     } // MSystem
73

74     private static Logger s_log = Logger.getCLogger (MSystem.class);
75
76     /**
77      * Save Record (ID=0)
78      * @return true if saved
79      */

80     public boolean save()
81     {
82         return saveUpdate();
83     } // save
84

85     /**
86      * String Representation
87      * @return info
88      */

89     public String JavaDoc toString()
90     {
91         return "MSystem[" + getName()
92             + ",User=" + getUserName()
93             + "]";
94     } // toString
95

96     /*************************************************************************/
97
98     /**
99      * Check valididity
100      * @return true if valid
101      */

102     public boolean isValid()
103     {
104         if (getName() == null || getName().length() < 2)
105         {
106             log.warn("Name not valid: " + getName());
107             return false;
108         }
109         if (getPassword() == null || getPassword().length() < 2)
110         {
111             log.warn("Password not valid: " + getPassword());
112             return false;
113         }
114         if (getInfo() == null || getInfo().length() < 2)
115         {
116             log.warn("Need to run Migration");
117             return false;
118         }
119         return true;
120     } // isValid
121

122 } // MSystem
123
Popular Tags