001: package com.knowgate.training;
002:
003: /*
004: Copyright (C) 2003-2006cx Know Gate S.L. All rights reserved.
005: C/Oņa, 107 1š2 28050 Madrid (Spain)
006:
007: Redistribution and use in source and binary forms, with or without
008: modification, are permitted provided that the following conditions
009: are met:
010:
011: 1. Redistributions of source code must retain the above copyright
012: notice, this list of conditions and the following disclaimer.
013:
014: 2. The end-user documentation included with the redistribution,
015: if any, must include the following acknowledgment:
016: "This product includes software parts from hipergate
017: (http://www.hipergate.org/)."
018: Alternately, this acknowledgment may appear in the software itself,
019: if and wherever such third-party acknowledgments normally appear.
020:
021: 3. The name hipergate must not be used to endorse or promote products
022: derived from this software without prior written permission.
023: Products derived from this software may not be called hipergate,
024: nor may hipergate appear in their name, without prior written
025: permission.
026:
027: This library is distributed in the hope that it will be useful,
028: but WITHOUT ANY WARRANTY; without even the implied warranty of
029: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
030:
031: You should have received a copy of hipergate License with this code;
032: if not, visit http://www.hipergate.org or mail to info@hipergate.org
033: */
034:
035: import java.util.Date;
036: import java.sql.SQLException;
037: import java.sql.PreparedStatement;
038: import java.sql.CallableStatement;
039: import java.sql.ResultSet;
040:
041: import com.knowgate.jdc.JDCConnection;
042: import com.knowgate.acl.ACLUser;
043: import com.knowgate.dataobjs.DB;
044: import com.knowgate.dataobjs.DBPersist;
045: import com.knowgate.crm.Contact;
046: import com.knowgate.misc.Gadgets;
047:
048: /**
049: * Academic Course Absentism
050: * @author Sergio Montoro Ten
051: * @version 1.0
052: */
053:
054: public class Absentism extends DBPersist {
055:
056: public Absentism() {
057: super (DB.k_absentisms, "Absentism");
058: }
059:
060: public Absentism(String sGuAbsentism) {
061: super (DB.k_absentisms, "Absentism");
062: put(DB.gu_absentism, sGuAbsentism);
063: }
064:
065: public Absentism(JDCConnection oConn, String sGuAbsentism)
066: throws SQLException {
067: super (DB.k_absentisms, "Absentism");
068: load(oConn, new Object[] { sGuAbsentism });
069: }
070:
071: // ---------------------------------------------------------------------------
072:
073: public AcademicCourseAlumni getAlumni(JDCConnection oConn)
074: throws SQLException {
075: AcademicCourseAlumni oAlmn;
076: if (isNull(DB.gu_alumni) || isNull(DB.gu_acourse)) {
077: oAlmn = null;
078: } else {
079: oAlmn = new AcademicCourseAlumni();
080: if (!oAlmn.load(oConn, new Object[] { get(DB.gu_acourse),
081: get(DB.gu_alumni) }))
082: oAlmn = null;
083: } // fi
084: return oAlmn;
085: } // getAlumni
086:
087: // ---------------------------------------------------------------------------
088:
089: public Contact getContact(JDCConnection oConn) throws SQLException {
090: AcademicCourseAlumni oAlmn = getAlumni(oConn);
091: if (null == oAlmn)
092: return null;
093: else
094: return oAlmn.getContact(oConn);
095: } // getContact
096:
097: // ---------------------------------------------------------------------------
098:
099: public AcademicCourse getAcademicCourse(JDCConnection oConn)
100: throws SQLException {
101: AcademicCourse oAcrs;
102: if (isNull(DB.gu_acourse)) {
103: oAcrs = null;
104: } else {
105: oAcrs = new AcademicCourse();
106: if (!oAcrs.load(oConn, new Object[] { get(DB.gu_acourse) }))
107: oAcrs = null;
108: } // fi
109: return oAcrs;
110: } // getAcademicCourse
111:
112: // ---------------------------------------------------------------------------
113:
114: public Subject getSubject(JDCConnection oConn) throws SQLException {
115: Subject oSbjct;
116: if (isNull(DB.gu_subject)) {
117: oSbjct = null;
118: } else {
119: oSbjct = new Subject();
120: if (!oSbjct
121: .load(oConn, new Object[] { get(DB.gu_subject) }))
122: oSbjct = null;
123: } // fi
124: return oSbjct;
125: } // getSubject
126:
127: // ---------------------------------------------------------------------------
128:
129: public ACLUser getWriter(JDCConnection oConn) throws SQLException {
130: ACLUser oUsr = new ACLUser();
131: if (!oUsr.load(oConn, new Object[] { get(DB.gu_writer) }))
132: oUsr = null;
133: return oUsr;
134: } // getWriter
135:
136: // ---------------------------------------------------------------------------
137:
138: public boolean store(JDCConnection oConn) throws SQLException {
139: if (!AllVals.containsKey(DB.dt_modified))
140: AllVals.put(DB.dt_modified, new Date());
141: if (!AllVals.containsKey(DB.gu_absentism))
142: AllVals.put(DB.gu_absentism, Gadgets.generateUUID());
143: return super .store(oConn);
144: }
145:
146: // ---------------------------------------------------------------------------
147:
148: public boolean delete(JDCConnection oConn) throws SQLException {
149: return Absentism.delete(oConn, getString(DB.gu_absentism));
150: }
151:
152: // ---------------------------------------------------------------------------
153:
154: public static boolean delete(JDCConnection oConn,
155: String sGuAbsentism) throws SQLException {
156: PreparedStatement oStmt = oConn.prepareStatement("DELETE FROM "
157: + DB.k_absentisms + " WHERE " + DB.gu_absentism + "=?");
158: oStmt.setString(1, sGuAbsentism);
159: int iAffected = oStmt.executeUpdate();
160: oStmt.close();
161: return (iAffected != 0);
162: }
163:
164: // **********************************************************
165: // Public Constants
166:
167: public static final short ClassId = 64;
168:
169: }
|