Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/course In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/src/org/cobricks/course Modified Files: Course.java CourseDate.java CourseManager.java CourseManagerImpl.java Added Files: CourseRoom.java Log Message: --- NEW FILE: CourseRoom.java --- /* * Copyright (c) 2004 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software * License, either version 1.0 of the License, or (at your option) any * later version (see www.cobricks.de). * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. */ package org.cobricks.course; import java.util.*; import org.apache.log4j.*; /** * * @author mic...@ac... * @version $Date: 2004/03/01 07:09:04 $ */ public class CourseRoom { static Logger logger = Logger.getLogger(CourseRoom.class); int crid; String crname; String crinfo; String crgroup; String crcontact; String crextid; int crhidden; /** * */ public CourseRoom() { } public int getId() { return crid; } public String getName() { return crname; } public String getInfo() { return crinfo; } public String getGroup() { return crgroup; } public String getContact() { return crcontact; } public String getExtId() { return crextid; } public int getHidden() { return crhidden; } public void loadFromMap(Map map, CourseManager courseManager) { Integer tmpi = (Integer)map.get("crid"); crid = tmpi.intValue(); crname = (String)map.get("crname"); crinfo = (String)map.get("crinfo"); crgroup = (String)map.get("crgroup"); crcontact = (String)map.get("crcontact"); crextid = (String)map.get("crextid"); tmpi = (Integer)map.get("crhidden"); if (tmpi != null) crhidden = tmpi.intValue(); } } Index: Course.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/Course.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Course.java 26 Feb 2004 16:27:22 -0000 1.4 --- Course.java 1 Mar 2004 07:09:04 -0000 1.5 *************** *** 26,29 **** --- 26,32 ---- * @author mic...@ac... * @version $Date$ + * + * @see org.cobricks.course.CourseDate + * @see org.cobricks.course.CourseRoom */ *************** *** 239,242 **** --- 242,255 ---- /** + * Return the date/room information about the course + * @return set of CourseDate objects + */ + public Set getDates() + { + return courseDates; + } + + + /** * Load course attributes from a Map object - e.g. one retrieved * from a database *************** *** 310,313 **** --- 323,330 ---- if (tmpd != null) cextlastrep = tmpd; + + try { + courseDates = courseManager.getCourseDates(cid); + } catch (Exception e) { } } Index: CourseDate.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/CourseDate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CourseDate.java 24 Feb 2004 14:25:13 -0000 1.1 --- CourseDate.java 1 Mar 2004 07:09:04 -0000 1.2 *************** *** 42,45 **** --- 42,47 ---- int dcrid; + CourseRoom droom; + /** *************** *** 50,53 **** --- 52,115 ---- } + public int getId() + { + return did; + } + + public int getCourseId() + { + return cid; + } + + public int getCycle() + { + return dcycle; + } + + public Date getStartDate() + { + return dstartdate; + } + + public Date getEndDate() + { + return denddate; + } + + public int getWeekday() + { + return dweekday; + } + + public int getStartHour() + { + return dstarthour; + } + + public int getStartMin() + { + return dstartmin; + } + + public int getEndHour() + { + return dendhour; + } + + public int getEndMin() + { + return dendmin; + } + + public int getRoomId() + { + return dcrid; + } + + public CourseRoom getRoom() + { + return droom; + } + public void loadFromMap(Map map, CourseManager courseManager) { *************** *** 56,61 **** tmpi = (Integer)map.get("cid"); cid = tmpi.intValue(); ! // tbd } } --- 118,173 ---- tmpi = (Integer)map.get("cid"); cid = tmpi.intValue(); ! Character tmpc = (Character)map.get("dtype"); ! if (tmpc != null) ! dtype = tmpc.charValue(); ! tmpi = (Integer)map.get("dcycle"); ! if (tmpi != null) ! dcycle = tmpi.intValue(); ! else ! dcycle = 0; ! dstartdate = (Date)map.get("dstartdate"); ! denddate = (Date)map.get("denddate"); ! tmpi = (Integer)map.get("dweekday"); ! if (tmpi != null) ! dweekday = tmpi.intValue(); ! tmpi = (Integer)map.get("dstarthour"); ! if (tmpi != null) ! dstarthour = tmpi.intValue(); ! tmpi = (Integer)map.get("dstartmin"); ! if (tmpi != null) ! dstartmin = tmpi.intValue(); ! tmpi = (Integer)map.get("dendhour"); ! if (tmpi != null) ! dendhour = tmpi.intValue(); ! tmpi = (Integer)map.get("dendmin"); ! if (tmpi != null) ! dendmin = tmpi.intValue(); ! tmpi = (Integer)map.get("dcrid"); ! if (tmpi != null) { ! dcrid = tmpi.intValue(); ! try { ! droom = courseManager.getCourseRoom(dcrid); ! } catch (Exception e) { } ! } ! } ! ! ! public Map getAttrs() ! { ! Map result = new HashMap(); ! result.put("did", new Integer(did)); ! result.put("cid", new Integer(cid)); ! result.put("dtype", new Character(dtype)); ! result.put("dweekday", new Integer(dweekday)); ! result.put("dstarthour", new Integer(dstarthour)); ! result.put("dstartmin", new Integer(dstartmin)); ! result.put("dendhour", new Integer(dendhour)); ! result.put("dendmin", new Integer(dendmin)); ! result.put("dcrid", new Integer(dcrid)); ! if (dstartdate != null) result.put("dstartdate", dstartdate); ! if (denddate != null) result.put("denddate", denddate); ! return result; } + } Index: CourseManager.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/CourseManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CourseManager.java 26 Feb 2004 08:12:58 -0000 1.3 --- CourseManager.java 1 Mar 2004 07:09:04 -0000 1.4 *************** *** 56,58 **** --- 56,64 ---- public void deleteCourseTemplate(int ctid, User user) throws CobricksException; + + public Set getCourseDates(int cid) + throws CobricksException; + public CourseRoom getCourseRoom(int crid) + throws CobricksException; + } Index: CourseManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/CourseManagerImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CourseManagerImpl.java 26 Feb 2004 08:12:58 -0000 1.4 --- CourseManagerImpl.java 1 Mar 2004 07:09:04 -0000 1.5 *************** *** 55,58 **** --- 55,59 ---- Map courseCache; Map courseTemplateCache; + Map courseRoomCache; *************** *** 104,107 **** --- 105,109 ---- courseCache = new HashMap(); courseTemplateCache = new HashMap(); + courseRoomCache = new HashMap(); // and finally initialize the access handler *************** *** 235,238 **** --- 237,263 ---- * */ + public void updateCourseDates(int cid, Set cdates) + { + String sql = "delete from course_date where cid = " + +Integer.toString(cid); + Iterator i = cdates.iterator(); + while (i.hasNext()) { + Object o = i.next(); + Map attrs = null; + if (o instanceof CourseDate) { + attrs = ((CourseDate)o).getAttrs(); + } else { + attrs = (Map)o; + } + attrs.remove("did"); + attrs.put("cid", new Integer(cid)); + int did = dbAccess.sqlInsert("course_date", attrs); + } + } + + + /** + * + */ public void updateCourse(int cid, Map attrs, User user) throws CobricksException *************** *** 353,355 **** --- 378,409 ---- + /** + * + */ + public Set getCourseDates(int cid) + throws CobricksException + { + // tbd + return null; + } + + + /** + * + */ + public CourseRoom getCourseRoom(int crid) + throws CobricksException + { + CourseRoom result = (CourseRoom)courseRoomCache.get(new Integer(crid)); + if (result != null) return result; + // load from database + Map dbres = dbAccess. + sqlQuerySingleRow("select * from course_room where crid = " + +Integer.toString(crid)); + result = new CourseRoom(); + result.loadFromMap(dbres, this); + courseRoomCache.put(new Integer(crid), result); + return result; + } + } |