1 package com.knowgate.training; 2 3 34 35 import java.util.Date ; 36 import java.util.HashMap ; 37 import java.sql.SQLException ; 38 import java.sql.PreparedStatement ; 39 import java.sql.CallableStatement ; 40 import java.sql.ResultSet ; 41 42 import com.knowgate.debug.DebugFile; 43 import com.knowgate.jdc.JDCConnection; 44 import com.knowgate.dataobjs.DB; 45 import com.knowgate.dataobjs.DBPersist; 46 47 import com.knowgate.misc.Gadgets; 48 49 53 54 public class Subject extends DBPersist { 55 56 58 private class SubjectCourse extends DBPersist { 59 public SubjectCourse() { 60 super(DB.k_x_course_subject, "SubjectCourse"); 61 } 62 63 public boolean store(JDCConnection oConn, HashMap oValues) throws SQLException { 64 boolean bRetVal; 65 if (DebugFile.trace) { 66 DebugFile.writeln("Begin SubjectCourse.store([JDCConnection],[HashMap])"); 67 DebugFile.incIdent(); 68 } 69 AllVals.putAll(oValues); 70 bRetVal = super.store(oConn); 71 if (DebugFile.trace) { 72 DebugFile.decIdent(); 73 DebugFile.writeln("End SubjectCourse.store()"); 74 } 75 return bRetVal; 76 } 77 } 79 81 public Subject() { 82 super(DB.k_subjects, "Subject"); 83 } 84 85 87 public boolean store(JDCConnection oConn) throws SQLException { 88 boolean bRetVal; 89 90 if (DebugFile.trace) { 91 DebugFile.writeln("Begin Subject.store([JDCConnection])"); 92 DebugFile.incIdent(); 93 } 94 95 if (!AllVals.containsKey(DB.dt_modified)) 96 AllVals.put(DB.dt_modified, new Date ()); 97 if (!AllVals.containsKey(DB.gu_subject)) 98 AllVals.put(DB.gu_subject, Gadgets.generateUUID()); 99 bRetVal = super.store(oConn); 100 101 if (AllVals.containsKey(DB.gu_course)) { 102 bRetVal = new SubjectCourse().store(oConn, AllVals); 103 } 104 105 if (DebugFile.trace) { 106 DebugFile.decIdent(); 107 DebugFile.writeln("End Subject.store() : " + AllVals.get(DB.gu_subject)); 108 } 109 110 return bRetVal; 111 } 113 115 public boolean delete (JDCConnection oConn) throws SQLException { 116 return Subject.delete(oConn, getString(DB.gu_acourse)); 117 } 118 119 121 public static boolean delete (JDCConnection oConn, String sGuACourse) throws SQLException { 122 if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) { 123 PreparedStatement oStmt = oConn.prepareStatement("SELECT k_sp_del_subject(?)"); 124 oStmt.setString(1, sGuACourse); 125 oStmt.executeQuery(); 126 oStmt.close(); 127 } 128 else { 129 CallableStatement oCall = oConn.prepareCall("{ call k_sp_del_subject(?) }"); 130 oCall.setString(1, sGuACourse); 131 oCall.execute(); 132 oCall.close(); 133 } 134 return true; 135 } 136 137 140 public static final short ClassId = 62; 141 142 } 143
| Popular Tags
|