1 14 package org.compiere.model; 15 16 import java.util.*; 17 import java.sql.*; 18 import org.compiere.util.*; 19 20 26 public class MSystem extends X_AD_System 27 { 28 33 public static MSystem get (Properties ctx) 34 { 35 MSystem system = null; 36 String 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 } 64 69 public MSystem (Properties ctx, ResultSet rs) 70 { 71 super (ctx, rs); 72 } 74 private static Logger s_log = Logger.getCLogger (MSystem.class); 75 76 80 public boolean save() 81 { 82 return saveUpdate(); 83 } 85 89 public String toString() 90 { 91 return "MSystem[" + getName() 92 + ",User=" + getUserName() 93 + "]"; 94 } 96 97 98 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 } 122 } | Popular Tags |