|
From: Michael K. <ko...@us...> - 2006-11-24 08:06:06
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/util/migration In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv375/src/org/cobricks/util/migration Modified Files: CourseMigration.java Log Message: Index: CourseMigration.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/util/migration/CourseMigration.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CourseMigration.java 18 Oct 2006 16:49:22 -0000 1.1 +++ CourseMigration.java 24 Nov 2006 08:06:00 -0000 1.2 @@ -39,6 +39,8 @@ import org.cobricks.course.Course; import org.cobricks.course.CourseManager; import org.cobricks.course.CourseModule; +import org.cobricks.course.CourseModuleProgramRel; +import org.cobricks.course.CourseProgram; import org.cobricks.course.CourseRoom; import org.cobricks.user.User; import org.cobricks.user.UserManager; @@ -151,6 +153,8 @@ tmps = (String)fromMap.get("vauntertitel_en"); if (tmps!=null && tmps.length()>0) attrs.put("cname_en", tmps); + + logger.info("createCourse "+cm.getName()+" - "+tmps); tmps = (String)fromMap.get("lang"); attrs.put("clang", tmps); @@ -281,7 +285,64 @@ } int cid = courseManager.createCourse(attrs, null); - + + // additional course programs? + + List result3 = fromDBAccess. + sqlQuery("SELECT * FROM veranstberzuordnung, " + +"veranstbereiche " + +"WHERE klid = " + fromMap.get("klid") + +" AND veranstberzuordnung.berid = " + +"veranstbereiche.berid"); + Iterator resIter3 = result3.iterator(); + while (resIter3.hasNext()) { + Map m = (Map)resIter3.next(); + String id = (String)m.get("berprogid"); + + // check if course program exists + CourseProgram cp = courseManager.getProgramForLabel(id); + if (cp == null) { + Map attrs2 = new HashMap(); + attrs2.put("cplabel", id); + String tmps3 = (String)m.get("bername"); + if (tmps3 == null) tmps3 = id; + attrs2.put("cpname", tmps3); + tmps3 = (String)m.get("bername_en"); + if (tmps3 == null) tmps3 = id; + attrs2.put("cpname_en", tmps3); + tmps3 = (String)m.get("bercomment"); + if (tmps3 != null) { + attrs2.put("cpcomment", tmps3); + } + int cpid = courseManager.createProgram(attrs2, null); + cp = courseManager.getProgramForLabel(id); + } + + // check if course program is assigned to module + boolean foundit = false; + List cprl = cm.getProgramRel(); + Iterator icprl = cprl.iterator(); + while (icprl.hasNext()) { + CourseModuleProgramRel cmpr = (CourseModuleProgramRel) + icprl.next(); + CourseProgram cp2 = cmpr.getProgram(); + String tmps3 = cp2.getLabel(); + if (tmps3.equals(id)) { + foundit = true; + break; + } + } + if (foundit == false) { + Map attrs2 = new HashMap(); + attrs2.put("cmid", new Integer(cm.getId())); + attrs2.put("cpid", new Integer(cp.getId())); + attrs2.put("cptype", m.get("type")); + attrs2.put("cpstartsem", m.get("startsem")); + attrs2.put("cpendsem", m.get("endsem")); + courseManager.addProgramToModule(attrs2); + } + } + } catch(Exception ex){ logger.error("Failed migrating course", ex); } |