KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > training > Absentism


1 package com.knowgate.training;
2
3 /*
4   Copyright (C) 2003-2006cx Know Gate S.L. All rights reserved.
5                            C/Oņa, 107 1š2 28050 Madrid (Spain)
6
7   Redistribution and use in source and binary forms, with or without
8   modification, are permitted provided that the following conditions
9   are met:
10
11   1. Redistributions of source code must retain the above copyright
12      notice, this list of conditions and the following disclaimer.
13
14   2. The end-user documentation included with the redistribution,
15      if any, must include the following acknowledgment:
16      "This product includes software parts from hipergate
17      (http://www.hipergate.org/)."
18      Alternately, this acknowledgment may appear in the software itself,
19      if and wherever such third-party acknowledgments normally appear.
20
21   3. The name hipergate must not be used to endorse or promote products
22      derived from this software without prior written permission.
23      Products derived from this software may not be called hipergate,
24      nor may hipergate appear in their name, without prior written
25      permission.
26
27   This library is distributed in the hope that it will be useful,
28   but WITHOUT ANY WARRANTY; without even the implied warranty of
29   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30
31   You should have received a copy of hipergate License with this code;
32   if not, visit http://www.hipergate.org or mail to info@hipergate.org
33 */

34
35 import java.util.Date JavaDoc;
36 import java.sql.SQLException JavaDoc;
37 import java.sql.PreparedStatement JavaDoc;
38 import java.sql.CallableStatement JavaDoc;
39 import java.sql.ResultSet JavaDoc;
40
41 import com.knowgate.jdc.JDCConnection;
42 import com.knowgate.acl.ACLUser;
43 import com.knowgate.dataobjs.DB;
44 import com.knowgate.dataobjs.DBPersist;
45 import com.knowgate.crm.Contact;
46 import com.knowgate.misc.Gadgets;
47
48 /**
49  * Academic Course Absentism
50  * @author Sergio Montoro Ten
51  * @version 1.0
52  */

53
54 public class Absentism extends DBPersist {
55
56   public Absentism() {
57     super(DB.k_absentisms, "Absentism");
58   }
59
60   public Absentism(String JavaDoc sGuAbsentism) {
61     super(DB.k_absentisms, "Absentism");
62     put(DB.gu_absentism, sGuAbsentism);
63   }
64
65   public Absentism(JDCConnection oConn, String JavaDoc sGuAbsentism)
66     throws SQLException JavaDoc {
67     super(DB.k_absentisms, "Absentism");
68     load(oConn, new Object JavaDoc[]{sGuAbsentism});
69   }
70
71   // ---------------------------------------------------------------------------
72

73   public AcademicCourseAlumni getAlumni(JDCConnection oConn) throws SQLException JavaDoc {
74     AcademicCourseAlumni oAlmn;
75     if (isNull(DB.gu_alumni) || isNull(DB.gu_acourse)) {
76       oAlmn = null;
77     } else {
78       oAlmn = new AcademicCourseAlumni();
79       if (!oAlmn.load(oConn, new Object JavaDoc[]{get(DB.gu_acourse),get(DB.gu_alumni)}))
80         oAlmn = null;
81     } // fi
82
return oAlmn;
83   } // getAlumni
84

85   // ---------------------------------------------------------------------------
86

87   public Contact getContact(JDCConnection oConn) throws SQLException JavaDoc {
88     AcademicCourseAlumni oAlmn = getAlumni(oConn);
89     if (null==oAlmn)
90       return null;
91     else
92       return oAlmn.getContact(oConn);
93   } // getContact
94

95   // ---------------------------------------------------------------------------
96

97   public AcademicCourse getAcademicCourse(JDCConnection oConn) throws SQLException JavaDoc {
98     AcademicCourse oAcrs;
99     if (isNull(DB.gu_acourse)) {
100       oAcrs = null;
101     } else {
102       oAcrs = new AcademicCourse();
103       if (!oAcrs.load(oConn, new Object JavaDoc[]{get(DB.gu_acourse)}))
104         oAcrs = null;
105     } // fi
106
return oAcrs;
107   } // getAcademicCourse
108

109   // ---------------------------------------------------------------------------
110

111   public Subject getSubject(JDCConnection oConn) throws SQLException JavaDoc {
112     Subject oSbjct;
113     if (isNull(DB.gu_subject)) {
114       oSbjct = null;
115     } else {
116       oSbjct = new Subject();
117       if (!oSbjct.load(oConn, new Object JavaDoc[]{get(DB.gu_subject)}))
118         oSbjct = null;
119     } // fi
120
return oSbjct;
121   } // getSubject
122

123   // ---------------------------------------------------------------------------
124

125   public ACLUser getWriter(JDCConnection oConn) throws SQLException JavaDoc {
126     ACLUser oUsr = new ACLUser();
127     if (!oUsr.load(oConn, new Object JavaDoc[]{get(DB.gu_writer)}))
128       oUsr = null;
129     return oUsr;
130   } // getWriter
131

132   // ---------------------------------------------------------------------------
133

134   public boolean store(JDCConnection oConn) throws SQLException JavaDoc{
135     if (!AllVals.containsKey(DB.dt_modified))
136       AllVals.put(DB.dt_modified, new Date JavaDoc());
137     if (!AllVals.containsKey(DB.gu_absentism))
138       AllVals.put(DB.gu_absentism, Gadgets.generateUUID());
139     return super.store(oConn);
140   }
141
142   // ---------------------------------------------------------------------------
143

144   public boolean delete(JDCConnection oConn) throws SQLException JavaDoc{
145     return Absentism.delete(oConn, getString(DB.gu_absentism));
146   }
147
148   // ---------------------------------------------------------------------------
149

150   public static boolean delete (JDCConnection oConn, String JavaDoc sGuAbsentism)
151     throws SQLException JavaDoc {
152     PreparedStatement JavaDoc oStmt = oConn.prepareStatement("DELETE FROM "+DB.k_absentisms+" WHERE "+DB.gu_absentism+"=?");
153     oStmt.setString(1, sGuAbsentism);
154     int iAffected = oStmt.executeUpdate();
155     oStmt.close();
156     return (iAffected!=0);
157   }
158
159   // **********************************************************
160
// Public Constants
161

162   public static final short ClassId = 64;
163
164 }
165
Popular Tags