Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: mill/a3/Application.java


1   /**
2   Project millengine
3   Copyright Serg Maslyukov, 1999-2002
4   */
5   
6   package mill.a3;
7   
8   import java.sql.PreparedStatement;
9   import java.sql.ResultSet;
10  import java.util.Vector;
11  
12  import mill.tools.RsetTools;
13  import mill.tools.StringTools;
14  import mill.db.DBconnect;
15  
16  /**
17  Класс Application прденазначен для хранения описания приложений.
18  */
19  public class Application
20  {
21  
22  /**
23  название приложения
24  */
25    public String applicationName = "";
26  /**
27  url доступа к приложениям
28  */
29    public String url = "";
30  /**
31  значение для порядка вывода приложений
32  */
33    public int order = 0;
34  
35    public int applRecordNumber = 0;
36  
37    public Vector subMenu = new Vector(0);
38    public long applicationID;
39  
40    private final static String sql_ = 
41  "select distinct z.CODE_ARM, a.NAME_OBJECT_ARM, a.url, a.order_field, a.is_new "+
42  "from   AUTH_OBJECT_ARM a,"+
43  "("+
44  "select "+
45  "        a.user_login, "+
46  "        f.code_arm, "+
47  "        d.id_object_arm, "+
48  "   e.id_arm, "+
49  "   e.is_new "+
50  "from    auth_user a, "+
51  "        auth_relate_accgroup b, "+
52  "        auth_relate_right_arm d, "+
53  "        auth_object_arm e, "+
54  "        auth_arm f "+
55  "where   a.id_auth_user=b.id_auth_user and "+
56  "        b.id_access_group = d.id_access_group and "+
57  "        d.id_object_arm = e.id_object_arm and "+
58  "        e.id_arm = f.id_arm "+
59  "union "+
60  "select  a1.user_login, f1.code_arm, d1.id_object_arm, f1.id_arm, d1.is_new "+
61  "from    auth_user a1, auth_object_arm d1,  auth_arm f1 "+
62  "where   a1.is_root=1 and d1.id_arm = f1.id_arm "+
63  ") z "+
64  "where  z.user_login=? and "+
65  "       a.id_object_arm = z.id_object_arm and "+
66  "       z.id_arm=? and a.url is not null "+
67  "order by ORDER_FIELD ASC";
68  
69  
70    public Application( AuthInfo authInfo, ResultSet rs )
71      throws AuthException
72    {
73      this(authInfo, rs, 0);
74    }
75  
76    public Application( AuthInfo authInfo, ResultSet rs, int recordNumber_ )
77      throws AuthException
78    {
79        if (authInfo == null)
80      return;
81  
82        PreparedStatement ps = null;
83        ResultSet rset = null;
84        DBconnect db_ = null;
85        try 
86        {
87      applicationName = RsetTools.getRsetString(rs, "NAME_ARM");
88      url = RsetTools.getRsetString(rs, "JSP_METHOD");
89      order  = RsetTools.getRsetInt(rs, "ORDER_FIELD");;
90      applicationID  = RsetTools.getRsetLong(rs, "ID_ARM", -1);
91      applRecordNumber = recordNumber_;
92  
93      db_ = DBconnect.getInstance( false );
94      ps = db_.conn.prepareStatement( sql_ );
95  
96      ps.setString(1, StringTools.toDB( authInfo.userLogin ) );
97      ps.setLong(2, applicationID );
98  
99      rset = ps.executeQuery();
100     int moduleRecordNumber = 0;
101     while ( rset.next() )
102     {
103       Module mod = new Module(rset);
104       mod.modRecordNumber = moduleRecordNumber++;
105       mod.applRecordNumber = applRecordNumber;
106       subMenu.addElement( mod );
107     }
108       }
109       catch (Exception e1) 
110       {
111     throw new AuthException( e1.toString() );
112       }
113       finally
114       {
115     if (rset != null)
116     {
117        try{ 
118       rset.close();
119       rset = null;
120        }catch(Exception e01){}
121     }
122     if (ps != null)
123     {
124        try{ 
125       ps.close();
126       ps = null;
127        }catch(Exception e02){}
128     }
129       }
130   }
131 
132 }