public EnrollmentSet getEnrollmentSet(String enrollmentSetEid) throws IdNotFoundException { for(Iterator implIter = implList.iterator(); implIter.hasNext();) { CourseManagementService cm = (CourseManagementService)implIter.next(); try { log.debug("{} found enrollmentSet {}", cm, enrollmentSetEid); return cm.getEnrollmentSet(enrollmentSetEid); } catch (IdNotFoundException ide) { if(log.isDebugEnabled()) log.debug(cm + " could not locate enrollmentSet " + enrollmentSetEid); } } throw new IdNotFoundException(enrollmentSetEid, EnrollmentSet.class.getName()); }
public void postProcess(ProcessorState state) throws Exception { Map<String, Set<String>> instructorMap = getInstructorMap(state); for (String enrollmentSetEid : instructorMap.keySet()) { if (!cmService.isEnrollmentSetDefined(enrollmentSetEid)) { log.error("can't sync instructors no enrollment set exists with eid: {}", enrollmentSetEid); continue; } Set<String> newInstructorElements = instructorMap.get(enrollmentSetEid); Set<String> newUserEids = new HashSet<>(); newUserEids.addAll(newInstructorElements); EnrollmentSet enrollmentSet = cmService.getEnrollmentSet(enrollmentSetEid); Set<String> officialInstructors = enrollmentSet.getOfficialInstructors(); if (officialInstructors == null) { officialInstructors = new HashSet<>(); enrollmentSet.setOfficialInstructors(officialInstructors); } officialInstructors.clear(); officialInstructors.addAll(newUserEids); try { cmAdmin.updateEnrollmentSet(enrollmentSet); } catch (Exception e) { log.error("can't save instructor enrollment set", e); } } }
public void postProcess(ProcessorState state) throws Exception { Map<String, Set<String>> instructorMap = getInstructorMap(state); for (String enrollmentSetEid : instructorMap.keySet()) { if (!cmService.isEnrollmentSetDefined(enrollmentSetEid)) { log.error("can't sync instructors no enrollment set exists with eid: {}", enrollmentSetEid); continue; } Set<String> newInstructorElements = instructorMap.get(enrollmentSetEid); Set<String> newUserEids = new HashSet<>(); newUserEids.addAll(newInstructorElements); EnrollmentSet enrollmentSet = cmService.getEnrollmentSet(enrollmentSetEid); Set<String> officialInstructors = enrollmentSet.getOfficialInstructors(); if (officialInstructors == null) { officialInstructors = new HashSet<>(); enrollmentSet.setOfficialInstructors(officialInstructors); } officialInstructors.clear(); officialInstructors.addAll(newUserEids); try { cmAdmin.updateEnrollmentSet(enrollmentSet); } catch (Exception e) { log.error("can't save instructor enrollment set", e); } } }
protected void reconcileEnrollmentSets(Document doc) { long start = System.currentTimeMillis(); if(log.isInfoEnabled()) log.info("Reconciling EnrollmentSets"); try { XPath docsPath = XPath.newInstance("/cm-data/enrollment-sets/enrollment-set"); List items = docsPath.selectNodes(doc); if(log.isDebugEnabled()) log.debug("Found " + items.size() + " enrollment sets to reconcile"); // Add or update each of the enrollment sets specified in the xml for(Iterator iter = items.iterator(); iter.hasNext();) { Element element = (Element)iter.next(); String eid = element.getChildText("eid"); if(log.isDebugEnabled()) log.debug("Reconciling enrollment set " + eid); EnrollmentSet enr = null; if(cmService.isEnrollmentSetDefined(eid)) { enr = updateEnrollmentSet(cmService.getEnrollmentSet(eid), element); } else { enr = addEnrollmentSet(element); } reconcileEnrollments(element.getChild("enrollments"), enr); reconcileOfficialInstructors(element, enr); } } catch (JDOMException jde) { log.error(jde.getMessage()); } if(log.isInfoEnabled()) log.info("Finished reconciling EnrollmentSets in " + (System.currentTimeMillis()-start) + " ms"); }
public void processRow(String[] data, ProcessorState state) throws Exception { log.debug("Reconciling enrollment set {}", data[0]); if (cmService.isEnrollmentSetDefined(data[0])) { EnrollmentSet enrollmentSet = cmService.getEnrollmentSet(data[0]); log.debug("Updating EnrollmentSet {}", enrollmentSet.getEid()); enrollmentSet.setTitle(data[1]); enrollmentSet.setDescription(data[2]); enrollmentSet.setCategory(data[3]); enrollmentSet.setDefaultEnrollmentCredits(data[5]); cmAdmin.updateEnrollmentSet(enrollmentSet); } else { log.debug("Adding EnrollmentSet {}", data[0]); cmAdmin.createEnrollmentSet(data[0], data[1], data[2], data[3], data[5], data[4], null); } }
public void processRow(String[] data, ProcessorState state) throws Exception { log.debug("Reconciling enrollment set {}", data[0]); if (cmService.isEnrollmentSetDefined(data[0])) { EnrollmentSet enrollmentSet = cmService.getEnrollmentSet(data[0]); log.debug("Updating EnrollmentSet {}", enrollmentSet.getEid()); enrollmentSet.setTitle(data[1]); enrollmentSet.setDescription(data[2]); enrollmentSet.setCategory(data[3]); enrollmentSet.setDefaultEnrollmentCredits(data[5]); cmAdmin.updateEnrollmentSet(enrollmentSet); } else { log.debug("Adding EnrollmentSet {}", data[0]); cmAdmin.createEnrollmentSet(data[0], data[1], data[2], data[3], data[5], data[4], null); } }
EnrollmentSet enrollmentSet = cmService.getEnrollmentSet(enrollmentSetEid); enrollmentSet.setOfficialInstructors(new HashSet<>(newInstructorElements));
EnrollmentSet enrollmentSet = cmService.getEnrollmentSet(enrollmentSetEid); enrollmentSet.setOfficialInstructors(new HashSet<>(newInstructorElements));
public Section updateSection(Section section, String[] data) { log.debug("Updating Section {}", section.getEid()); section.setTitle(data[1]); section.setDescription(data[2]); section.setCategory(data[3]); if (StringUtils.isNotBlank(data[4]) && cmService.isSectionDefined(data[4])) { section.setParent(cmService.getSection(data[4])); } // Note: There's no way to change the course offering. This makes sense, though. if (cmService.isEnrollmentSetDefined(data[5])) { section.setEnrollmentSet(cmService.getEnrollmentSet(data[5])); } cmAdmin.updateSection(section); return section; }
public Section updateSection(Section section, String[] data) { log.debug("Updating Section {}", section.getEid()); section.setTitle(data[1]); section.setDescription(data[2]); section.setCategory(data[3]); if (StringUtils.isNotBlank(data[4]) && cmService.isSectionDefined(data[4])) { section.setParent(cmService.getSection(data[4])); } // Note: There's no way to change the course offering. This makes sense, though. if (cmService.isEnrollmentSetDefined(data[5])) { section.setEnrollmentSet(cmService.getEnrollmentSet(data[5])); } cmAdmin.updateSection(section); return section; }
protected Section updateSection(Section section, Element element) { if(log.isDebugEnabled()) log.debug("Updating Section + " + section.getEid()); section.setTitle(element.getChildText("title")); section.setDescription(element.getChildText("description")); section.setCategory(element.getChildText("category")); if(cmService.isSectionDefined(element.getChildText("parent-section-eid"))) { section.setParent(cmService.getSection(element.getChildText("parent-section-eid"))); } // Note: There's no way to change the course offering. This makes sense, though. if(cmService.isEnrollmentSetDefined(element.getChildText("enrollment-set-eid"))) { section.setEnrollmentSet(cmService.getEnrollmentSet(element.getChildText("enrollment-set-eid"))); } cmAdmin.updateSection(section); return section; }