|
From: Michael K. <ko...@us...> - 2006-05-30 14:32:04
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19207/src/de/tum/cobricks/univis Modified Files: UnivIS.java UnivISParser.java Log Message: Index: UnivISParser.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivISParser.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- UnivISParser.java 8 Dec 2004 21:33:18 -0000 1.15 +++ UnivISParser.java 30 May 2006 14:32:00 -0000 1.16 @@ -71,10 +71,10 @@ } else { - // check if the version = 1.3 + // check if the version = 1.5 String version = ((Element)univISNode).getAttribute("version"); - if(!version.equals("1.3")) { - logger.error("univIS version conflict, version not equal 1.3"); + if(!version.equals("1.5")) { + logger.error("univIS version conflict, version not equal 1.5"); } else { Node node = univISNode.getFirstChild(); Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- UnivIS.java 22 Aug 2005 13:52:06 -0000 1.54 +++ UnivIS.java 30 May 2006 14:32:00 -0000 1.55 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 Cobricks Group. All rights reserved. + * Copyright (c) 2004-2006 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 @@ -146,15 +146,15 @@ logger.info("Deleting course from Cobricks ..."); int cid = c.getId(); - CourseModule ctp = c.getCourseModule(); - int ctplid = ctp.getId(); + CourseModule cm = c.getCourseModule(); + int cmid = cm.getId(); if(univISSync.shouldLog("change")){ univISSync.log("Deleting course \""+c.getName()+"" + "\" from Cobricks..."); } courseManager.deleteCourse(cid, new User()); courseManager.deleteLecturersFromCourse(cid, new User()); - courseManager.deleteCoursePrograms(ctplid); + courseManager.deleteCourseProgramsForModule(cmid); } } } @@ -323,15 +323,15 @@ logger.info("Deleting lecture from Cobricks ..."); int cid = c1.getId(); - CourseModule ctp = c1.getCourseModule(); - int ctplid = ctp.getId(); + CourseModule cm = c1.getCourseModule(); + int cmid = cm.getId(); if(univISSync.shouldLog("change")){ univISSync.log("Deleting course \""+c1.getName()+"" + "\" from Cobricks..."); } courseManager.deleteCourse(cid, new User()); courseManager.deleteLecturersFromCourse(cid, new User()); - courseManager.deleteCoursePrograms(ctplid); + courseManager.deleteCourseProgramsForModule(cmid); }else if (ul != null && cextlastrep != null && (cextlastrep.before(cextastupdate))){ // course has been changed after the last replication, // so update UnivIS @@ -539,11 +539,11 @@ * @return int cid : the id for the cobricks lecture */ public int insertLectureIntoCobricks(UnivISLecture ul, String term, - UnivISSyncParameters univISSync) + UnivISSyncParameters univISSync) { logger.info("inserting lecture into Cobricks ..."); int cid = 0; - int ctplid = 0; + int cmid = 0; int cparentid = 0; Map attrs = new HashMap(); // get course template for imported course @@ -554,11 +554,10 @@ else if (cname.indexOf(" - ")>0) ctname = ctname.substring(0, ctname.indexOf(" - ")); ctname = ctname.trim(); - CourseModule ctp = courseManager.getCourseModuleForName(ctname); - if(ctp != null){ - ctplid = ctp.getId(); - cparentid = ctp.getParentId(); - }else { + CourseModule cm = courseManager.getCourseModuleForName(ctname); + if (cm != null){ + cmid = cm.getId(); + } else { // create new course template Map ctAttrs = new HashMap(); //get parent extid @@ -588,7 +587,7 @@ ctAttrs.put("ctprerequ", ul.getOrganizational()); if(ul.getEctsOrganizational() != null) ctAttrs.put("ctprerequ_en", ul.getEctsOrganizational()); - ctplid = courseManager.createCourseModule(ctAttrs, new User()); + cmid = courseManager.createCourseModule(ctAttrs, new User()); }catch(Exception e){ logger.error(LogUtil.ex("Failed creating courseModule.",e)); if(univISSync.shouldLog("error")){ @@ -599,7 +598,7 @@ } // and now prepare the course attrs - attrs.put("ctplid", new Integer(ctplid)); + attrs.put("cmid", new Integer(cmid)); attrs.put("cparentid", new Integer(cparentid)); String cterm; if(term.length()== 5){ @@ -619,8 +618,8 @@ attrs.put("curl", ul.getURL()); // get the integer value form the teilno String if(ul.getParticipants() != null){ - int cparticipants = Integer.parseInt(ul.getParticipants()); - attrs.put("cparticipants", new Integer(cparticipants)); + int ccapacity = Integer.parseInt(ul.getParticipants()); + attrs.put("ccapacity", new Integer(ccapacity)); } // get the big decimal value from the ects string if(ul.getEctsCred() != null){ @@ -1106,7 +1105,7 @@ attrs.put("cpendsem", new Integer(cpendsem)); } // and now add program to course - courseManager.addProgramToCourse(attrs); + courseManager.addProgramToModule(attrs); }catch(Exception e){ e.printStackTrace(); @@ -1138,8 +1137,8 @@ map.put("curl", ul.getURL()); // get the integer value form the teilno String if(ul.getParticipants()!= null){ - int cparticipants = Integer.parseInt(ul.getParticipants()); - map.put("cparticipants", new Integer(cparticipants)); + int ccapacity = Integer.parseInt(ul.getParticipants()); + map.put("ccapacity", new Integer(ccapacity)); } // get the big decimal value from the ects string if(ul.getEctsCred()!= null){ @@ -1267,9 +1266,9 @@ { try { Course c = courseManager.getCourse(cid); - CourseModule ctp = c.getCourseModule(); - int ctplid = ctp.getId(); - courseManager.deleteCoursePrograms(ctplid); + CourseModule cm = c.getCourseModule(); + int cmid = cm.getId(); + courseManager.deleteCourseProgramsForModule(cmid); insertProgramsIntoCobricks(programs, cid, univISSync); }catch (Exception e) { logger.error(LogUtil.ex("Failed updating course programs.",e)); @@ -1295,7 +1294,7 @@ post1.addParameter("__s", "1"); post1.addParameter("donedef", "1"); post1.addParameter("lcreate" , "1"); - post1.addParameter("dir", course.getChair()); + post1.addParameter("dir", getChair(course)); post1.addParameter("sem", course.getTerm()); post1.addParameter("showhow", "short"); long time = (new Date()).getTime(); @@ -1328,10 +1327,11 @@ post2.addParameter("__s", "1"); post2.addParameter("dsc", "lecture/edit"); post2.addParameter("donedef", "1"); - post2.addParameter("done-lecture/edit:ignore", " Warnung ignorieren "); + post2.addParameter("done-lecture/edit:ignore", + " Warnung ignorieren "); post2.addParameter("lcreate", "1"); - post2.addParameter("dir", course.getChair()); + post2.addParameter("dir", getChair(course)); post2.addParameter("sem", course.getTerm()); addCourseParameters(course, post2); @@ -1387,7 +1387,7 @@ post3.addParameter("done-doit", " Einordnen "); post3.addParameter("lv", lv); - post3.addParameter("dir", course.getChair()); + post3.addParameter("dir", getChair(course)); post3.addParameter("sem", course.getTerm()); post3.addParameter("__e", Integer.toString(evalue)); logger.info("univisid = "+lv); @@ -1429,18 +1429,18 @@ { logger.info("getUnivISEinordnung ...."); String title = "in/_lehrv"; - CourseModule ctp = course.getCourseModule(); - int ctplid = ctp.getId(); - String ctype = ctp.getType(); - String cname = ctp.getName(); - List list = courseManager.getProgramsForCourse(ctplid); + CourseModule cm = course.getCourseModule(); + int cmid = cm.getId(); + String ctype = cm.getType(); + String cname = cm.getName(); + List list = courseManager.getProgramsForModule(cmid); if(list != null){ Iterator it = list.listIterator(); while(it.hasNext()){ CourseProgram cp = (CourseProgram)it.next(); String label = cp.getLabel(); int cpid = cp.getId(); - int startsem = courseManager.getStartSemForCourse(cpid, ctplid); + int startsem = courseManager.getStartSemForModule(cpid, cmid); if(label == null || label.length()<1){ continue; }else if(!(label.startsWith("INF")) || !(label.endsWith("INF"))){ @@ -1479,8 +1479,8 @@ { logger.info("addCourseParameters ..."); - CourseModule ctp = course.getCourseModule(); - String ctname = ctp.getName(); + CourseModule cm = course.getCourseModule(); + String cmname = cm.getName(); String cname = course.getName(); post.addParameter("lname", cname); @@ -1489,13 +1489,13 @@ } else{ post.addParameter("ects_lname", ""); } - if(ctp.getShortName() != null){ - post.addParameter("short", ctp.getShortName()); + if(cm.getShortName() != null){ + post.addParameter("short", cm.getShortName()); }else{ post.addParameter("short", ""); } // get teilno - int teilnoval = course.getParticipants(); + int teilnoval = course.getCapacity(); Integer val = new Integer(teilnoval); String teilno = val.toString(); if(teilno != null && teilnoval != 0){ @@ -1504,7 +1504,7 @@ post.addParameter("teilno", ""); } // get type - String ctype = ctp.getType(); + String ctype = cm.getType(); String univIStype = ""; if(ctype == null || ctype.length()< 1 ||ctype.equalsIgnoreCase("Vorlesung")){ @@ -1614,7 +1614,7 @@ post.addParameter("url_description", ""); } // get studs - List programs = courseManager.getProgramsForCourse(ctp.getId()); + List programs = courseManager.getProgramsForModule(cm.getId()); if(programs != null){ Iterator it1 = programs.listIterator(); int counter1 = 0; @@ -1622,9 +1622,9 @@ CourseProgram cp = (CourseProgram)it1.next(); String richt = cp.getLabel(); int cpid = cp.getId(); - String pflicht = courseManager.getProgramType(cpid, ctp.getId()); - int startsem = courseManager.getStartSemForCourse(cpid, ctp.getId()); - int endsem = courseManager.getEndSemForCourse(cpid, ctp.getId()); + String pflicht = courseManager.getProgramType(cpid, cm.getId()); + int startsem = courseManager.getStartSemForModule(cpid, cm.getId()); + int endsem = courseManager.getEndSemForModule(cpid, cm.getId()); if(pflicht != null && pflicht.length() > 0){ post.addParameter("stud"+counter1+"::pflicht", pflicht); } @@ -1908,7 +1908,7 @@ post1.addParameter("lvs", lv); post1.addParameter("lv", lv); - post1.addParameter("dir", course.getChair()); + post1.addParameter("dir", getChair(course)); post1.addParameter("sem", course.getTerm()); long time = (new Date()).getTime(); int evalue = (int)((time - 1007506796106L)/86400000L)+661; @@ -1942,7 +1942,7 @@ post2.addParameter("classification", getUnivISEinordnung(course)); post2.addParameter("reedit", "1"); post2.addParameter("rtag", "save"); - post2.addParameter("dir", course.getChair()); + post2.addParameter("dir", getChair(course)); post2.addParameter("sem", course.getTerm()); time = (new Date()).getTime(); evalue = (int)((time - 1007506796106L)/86400000L)+661; @@ -2023,16 +2023,31 @@ } } -} - - - - - - - - - + /** + * @return String chair e.g in/infor/infor11 + */ + public String getChair(Course course) + { + String chair = ""; + String cextid = course.getExtId(); + // e.g cextid = Lecture/in/infor/infor11/vean + if (cextid == null) return "in/infor/infor11"; + else { + int pos = cextid.indexOf("/"); + cextid = cextid.substring(pos+1);// cextid = in/infor/infor11/vean + for(int i=0; i<3; i++){ + pos = cextid.indexOf("/"); + String tmp = ""; + if(i == 2){ + tmp = cextid.substring(0, pos);// tmp = in + }else{ + tmp = cextid.substring(0, pos+1);// tmp = in/ + } + cextid = cextid.substring(pos+1); + chair = chair+tmp; + } + } + return chair.trim(); + } - - +} |