List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.lockss.crawler.CrawlManagerImpl.java
public Collection<CrawlReq> getPendingQueue() { Collection runKeys = copyRunKeys(); TreeSet<CrawlReq> finalSort = new TreeSet(CPC); synchronized (queueLock) { for (Iterator iter = sharedRateReqs.entrySet().iterator(); iter.hasNext();) { Map.Entry ent = (Map.Entry) iter.next(); Object rateKey = ent.getKey(); if (runKeys.contains(rateKey)) { // mark it somehow }/* w w w. j a v a 2s .com*/ finalSort.addAll((TreeSet) ent.getValue()); } finalSort.addAll(unsharedRateReqs); } return finalSort; }
From source file:net.sourceforge.fenixedu.domain.student.Student.java
final public TreeSet<Enrolment> getDissertationEnrolments(DegreeCurricularPlan degreeCurricularPlan) { final TreeSet<Enrolment> enrolments = new TreeSet<Enrolment>( Enrolment.COMPARATOR_BY_EXECUTION_PERIOD_AND_NAME_AND_ID); for (final Registration registration : getRegistrationsSet()) { enrolments.addAll(registration.getDissertationEnrolments(degreeCurricularPlan)); }//from w w w .j a v a 2s.com return enrolments; }
From source file:org.unitime.timetable.solver.course.ui.ClassInfoModel.java
public TreeSet<StudentConflict> getStudentConflicts() { TreeSet<StudentConflict> ret = new TreeSet(); if (iChange != null) { HashSet<String> ids = new HashSet(); for (ClassAssignmentInfo assignment : iChange.getAssignments()) { for (StudentConflict conf : assignment.getStudentConflicts()) { String id = (assignment.getClassId().compareTo(conf.getOtherClass().getClassId()) < 0 ? assignment.getClassId() + ":" + conf.getOtherClass().getClassId() : conf.getOtherClass().getClassId() + ":" + assignment.getClassId()); if (ids.add(id)) ret.add(conf);//from ww w.ja v a2 s . c o m } } } else if (getClassAssignment() != null) { ret.addAll(getClassAssignment().getStudentConflicts()); } return ret; }
From source file:org.apache.axis2.jaxws.runtime.description.marshal.impl.PackageSetBuilder.java
/** * Update the package set with the packages referenced by this OperationDesc * * @param opDesc OperationDescription/*from w w w . ja v a2s.c o m*/ * @param set Set<Package> that is updated */ private static void getPackagesFromAnnotations(EndpointDescription ed, OperationDescription opDesc, TreeSet<String> set, MarshalServiceRuntimeDescription msrd) { // Walk the parameter information ParameterDescription[] parameterDescs = opDesc.getParameterDescriptions(); if (parameterDescs != null) { for (int i = 0; i < parameterDescs.length; i++) { getPackagesFromAnnotations(parameterDescs[i], set, msrd); } } // Walk the fault information FaultDescription[] faultDescs = opDesc.getFaultDescriptions(); if (faultDescs != null) { for (int i = 0; i < faultDescs.length; i++) { getPackagesFromAnnotations(ed, faultDescs[i], set, msrd); } } // Also consider the request and response wrappers String requestWrapperName = msrd.getRequestWrapperClassName(opDesc); String requestWrapperPkg = getPackageFromClassName(requestWrapperName); if (log.isDebugEnabled()) { log.debug("Package from Request Wrapper annotation = " + requestWrapperPkg); } if (requestWrapperPkg != null) { set.add(requestWrapperPkg); set.add("@" + requestWrapperPkg); // Indicates a package from an actual class reference (versus namespace) set.add("[" + requestWrapperName + "]"); // Indicates a actual class reference } String responseWrapperName = msrd.getResponseWrapperClassName(opDesc); String responseWrapperPkg = getPackageFromClassName(responseWrapperName); if (log.isDebugEnabled()) { log.debug("Package from Response Wrapper annotation = " + responseWrapperPkg); } if (responseWrapperPkg != null) { set.add(responseWrapperPkg); set.add("@" + responseWrapperPkg); // Indicates a package from an actual class reference (versus namespace) set.add("[" + responseWrapperName + "]"); // Indicates a actual class reference } // The wrapper class and the element defining the wrapper may be // in different namespaces and packages. So also look at the namespaces. String ns = opDesc.getRequestWrapperTargetNamespace(); if (ns != null && ns.length() > 0) { if (log.isDebugEnabled()) { log.debug("TargetNamespace from Request Wrapper annotation = " + ns); } List packages = makePackages(ns); set.addAll(packages); } ns = opDesc.getResponseWrapperTargetNamespace(); if (ns != null && ns.length() > 0) { if (log.isDebugEnabled()) { log.debug("TargetNamespace from Response Wrapper annotation = " + ns); } List packages = makePackages(ns); set.addAll(packages); } // See if the Method is available. If so, additional reflection // can be performed to obtain the generic references Method m = getMethod(opDesc, msrd); if (log.isDebugEnabled()) { log.debug("Method obtained:" + m); } // Examine the parameters if (log.isDebugEnabled()) { log.debug("Collect the packages of the parameters"); } addPackagesFromParameters(set, opDesc); if (m != null) { addPackagesFromParameters(set, m); } // Finally consider the result type Class cls = opDesc.getResultActualType(); if (cls != null && cls != void.class && cls != Void.class) { String pkg = getPackageFromClass(cls); if (log.isDebugEnabled()) { log.debug("Package from Return Type = " + pkg); } if (pkg != null) { set.add(pkg); set.add("@" + pkg); // Indicates a package from an actual class reference (versus namespace) set.add("[" + cls.getCanonicalName() + "]"); // Indicates a actual class reference } if (m != null) { addPackagesFromReturn(set, m); } } }
From source file:net.spfbl.core.User.java
public synchronized static TreeSet<User> getSet() { TreeSet<User> userSet = new TreeSet<User>(); userSet.addAll(MAP.values()); return userSet; }
From source file:org.unitime.timetable.action.PersonalizedExamReportAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PersonalizedExamReportForm myForm = (PersonalizedExamReportForm) form; String back = (String) request.getSession().getAttribute("loginPage"); if (back == null) back = "back"; try {// w ww . j av a 2s.c o m sessionContext.checkPermission(Right.PersonalSchedule); } catch (AccessDeniedException e) { request.setAttribute("message", e.getMessage()); return mapping.findForward(back); } if (request.getParameter("q") != null) { String[] params = QueryEncoderBackend.decode(request.getParameter("q")).split(":"); if (params != null && params.length == 2) { myForm.setUid(params[0]); myForm.setSessionId(Long.valueOf(params[1])); } } String externalId = sessionContext.getUser().getExternalUserId(); String userName = sessionContext.getUser().getName(); myForm.setAdmin(sessionContext.hasPermission(Right.PersonalScheduleLookup)); myForm.setLogout(!"back".equals(back)); if (sessionContext.hasPermission(Right.PersonalScheduleLookup) && myForm.getUid() != null && !myForm.getUid().isEmpty()) { externalId = myForm.getUid(); userName = (myForm.getLname() == null || myForm.getLname().length() == 0 ? "" : " " + Constants.toInitialCase(myForm.getLname())) + (myForm.getFname() == null || myForm.getFname().length() == 0 ? "" : " " + myForm.getFname().substring(0, 1).toUpperCase()) + (myForm.getMname() == null || myForm.getMname().length() == 0 ? "" : " " + myForm.getMname().substring(0, 1).toUpperCase()); } if (externalId == null || externalId.length() == 0) { request.setAttribute("message", "No user id provided."); return mapping.findForward(back); } if ("Log Out".equals(myForm.getOp())) { SecurityContextHolder.getContext().setAuthentication(null); return mapping.findForward(back); } if ("classes".equals(back)) { if (myForm.getSessionId() == null) { myForm.setSessionId((Long) request.getSession().getAttribute("Classes.session")); } else { request.getSession().setAttribute("Classes.session", myForm.getSessionId()); } } else if ("exams".equals(back)) { if (myForm.getSessionId() == null) { myForm.setSessionId((Long) request.getSession().getAttribute("Exams.session")); } else { request.getSession().setAttribute("Exams.session", myForm.getSessionId()); } } HashSet<Session> sessions = new HashSet(); DepartmentalInstructor instructor = null; for (Iterator i = new DepartmentalInstructorDAO().getSession() .createQuery("select i from DepartmentalInstructor i where i.externalUniqueId=:externalId") .setString("externalId", translate(externalId, Source.Staff)).setCacheable(true).list() .iterator(); i.hasNext();) { DepartmentalInstructor s = (DepartmentalInstructor) i.next(); if (!canDisplay(s.getDepartment().getSession())) continue; sessions.add(s.getDepartment().getSession()); if (myForm.getSessionId() == null) { if (instructor == null || instructor.getDepartment().getSession().compareTo(s.getDepartment().getSession()) < 0) instructor = s; } else if (myForm.getSessionId().equals(s.getDepartment().getSession().getUniqueId())) { instructor = s; } } Student student = null; for (Iterator i = new StudentDAO().getSession() .createQuery("select s from Student s where s.externalUniqueId=:externalId") .setString("externalId", translate(externalId, Source.Student)).setCacheable(true).list() .iterator(); i.hasNext();) { Student s = (Student) i.next(); if (!canDisplay(s.getSession())) continue; sessions.add(s.getSession()); if (myForm.getSessionId() == null) { if (student == null || student.getSession().compareTo(s.getSession()) < 0) student = s; } else if (myForm.getSessionId().equals(s.getSession().getUniqueId())) student = s; } if (instructor == null && student == null) { if (myForm.getAdmin()) { back = "back"; myForm.setLogout(false); } else { if ("classes".equals(back)) request.setAttribute("message", "No classes found."); else if ("exams".equals(back)) request.setAttribute("message", "No examinations found."); else request.setAttribute("message", "No schedule found."); sLog.info("No matching instructor or student found for " + userName + " (" + translate(externalId, Source.Student) + "), forwarding back (" + back + ")."); return mapping.findForward(back); } } myForm.setCanExport(false); if (instructor != null && student != null && !instructor.getDepartment().getSession().equals(student.getSession())) { if (instructor.getDepartment().getSession().compareTo(student.getSession()) < 0) instructor = null; else student = null; } long t0 = System.currentTimeMillis(); if (instructor != null) { sLog.info("Requesting schedule for " + instructor.getName(DepartmentalInstructor.sNameFormatShort) + " (instructor)"); } else if (student != null) { sLog.info("Requesting schedule for " + student.getName(DepartmentalInstructor.sNameFormatShort) + " (student)"); } HashSet<ExamOwner> studentExams = new HashSet<ExamOwner>(); if (student != null) { /* for (Iterator i=student.getClassEnrollments().iterator();i.hasNext();) { StudentClassEnrollment sce = (StudentClassEnrollment)i.next(); studentExams.addAll(Exam.findAllRelated("Class_", sce.getClazz().getUniqueId())); } */ studentExams.addAll(new ExamDAO().getSession().createQuery( "select distinct o from Student s inner join s.classEnrollments ce, ExamOwner o inner join o.course co " + "inner join co.instructionalOffering io " + "inner join io.instrOfferingConfigs ioc " + "inner join ioc.schedulingSubparts ss " + "inner join ss.classes c where " + "s.uniqueId=:studentId and c=ce.clazz and (" + "(o.ownerType=" + ExamOwner.sOwnerTypeCourse + " and o.ownerId=co.uniqueId) or " + "(o.ownerType=" + ExamOwner.sOwnerTypeOffering + " and o.ownerId=io.uniqueId) or " + "(o.ownerType=" + ExamOwner.sOwnerTypeConfig + " and o.ownerId=ioc.uniqueId) or " + "(o.ownerType=" + ExamOwner.sOwnerTypeClass + " and o.ownerId=c.uniqueId) " + ")") .setLong("studentId", student.getUniqueId()).setCacheable(true).list()); for (Iterator<ExamOwner> i = studentExams.iterator(); i.hasNext();) { Exam exam = i.next().getExam(); DepartmentStatusType type = exam.effectiveStatusType(); if (type == null || !type.can(exam.getExamType().getType() == ExamType.sExamTypeFinal ? DepartmentStatusType.Status.ReportExamsFinal : DepartmentStatusType.Status.ReportExamsMidterm)) i.remove(); } } HashSet<Exam> instructorExams = new HashSet<Exam>(); if (instructor != null) { instructorExams.addAll(instructor.getAllExams()); for (Iterator<Exam> i = instructorExams.iterator(); i.hasNext();) { Exam exam = i.next(); DepartmentStatusType type = exam.effectiveStatusType(); if (type == null || !type.can(exam.getExamType().getType() == ExamType.sExamTypeFinal ? DepartmentStatusType.Status.ReportExamsFinal : DepartmentStatusType.Status.ReportExamsMidterm)) i.remove(); } } WebTable.setOrder(sessionContext, "exams.o0", request.getParameter("o0"), 1); WebTable.setOrder(sessionContext, "exams.o1", request.getParameter("o1"), 1); WebTable.setOrder(sessionContext, "exams.o2", request.getParameter("o2"), 1); WebTable.setOrder(sessionContext, "exams.o3", request.getParameter("o3"), 1); WebTable.setOrder(sessionContext, "exams.o4", request.getParameter("o4"), 1); WebTable.setOrder(sessionContext, "exams.o5", request.getParameter("o5"), 1); WebTable.setOrder(sessionContext, "exams.o6", request.getParameter("o6"), 1); WebTable.setOrder(sessionContext, "exams.o7", request.getParameter("o7"), 1); boolean hasClasses = false; if (student != null && student.getSession().canNoRoleReportClass() && !student.getClassEnrollments().isEmpty()) { PdfWebTable table = getStudentClassSchedule(true, student); if (!table.getLines().isEmpty()) { request.setAttribute("clsschd", table.printTable(WebTable.getOrder(sessionContext, "exams.o6"))); hasClasses = true; myForm.setCanExport(true); } } if (instructor != null && instructor.getDepartment().getSession().canNoRoleReportClass()) { PdfWebTable table = getInstructorClassSchedule(true, instructor); if (!table.getLines().isEmpty()) { request.setAttribute("iclsschd", table.printTable(Math.abs(WebTable.getOrder(sessionContext, "exams.o7")))); hasClasses = true; myForm.setCanExport(true); } } if (instructor != null && sessions.size() > 1) { PdfWebTable table = getSessions(true, sessions, instructor.getName(DepartmentalInstructor.sNameFormatLastFist), instructor.getDepartment().getSession().getUniqueId()); request.setAttribute("sessions", table.printTable(WebTable.getOrder(sessionContext, "exams.o0"))); } else if (student != null && sessions.size() > 1) { PdfWebTable table = getSessions(true, sessions, student.getName(DepartmentalInstructor.sNameFormatLastFist), student.getSession().getUniqueId()); request.setAttribute("sessions", table.printTable(WebTable.getOrder(sessionContext, "exams.o0"))); } if (!hasClasses && instructorExams.isEmpty() && studentExams.isEmpty()) { if ("classes".equals(back)) myForm.setMessage("No classes found in " + (instructor != null ? instructor.getDepartment().getSession() : student.getSession()) .getLabel() + "."); else if ("exams".equals(back)) myForm.setMessage("No examinations found in " + (instructor != null ? instructor.getDepartment().getSession() : student.getSession()) .getLabel() + "."); else if (student != null || instructor != null) myForm.setMessage("No classes or examinations found in " + (instructor != null ? instructor.getDepartment().getSession() : student.getSession()) .getLabel() + "."); else if (sessionContext.hasPermission(Right.PersonalScheduleLookup)) myForm.setMessage( "No classes or examinations found in " + SessionDAO.getInstance() .get(sessionContext.getUser().getCurrentAcademicSessionId()).getLabel() + "."); else myForm.setMessage("No classes or examinations found for " + userName + "."); sLog.info("No classes or exams found for " + (instructor != null ? instructor.getName(DepartmentalInstructor.sNameFormatShort) : student != null ? student.getName(DepartmentalInstructor.sNameFormatShort) : userName)); } boolean useCache = ApplicationProperty.ExaminationCacheConflicts.isTrue(); if ("Export PDF".equals(myForm.getOp())) { sLog.info(" Generating PDF for " + (instructor != null ? instructor.getName(DepartmentalInstructor.sNameFormatShort) : student.getName(DepartmentalInstructor.sNameFormatShort))); OutputStream out = ExportUtils.getPdfOutputStream(response, "schedule"); if (!instructorExams.isEmpty()) { TreeSet<ExamAssignmentInfo> exams = new TreeSet<ExamAssignmentInfo>(); for (Exam exam : instructorExams) { if (exam.getAssignedPeriod() == null) continue; exams.add(new ExamAssignmentInfo(exam, useCache)); } InstructorExamReport ir = new InstructorExamReport(InstructorExamReport.sModeNormal, out, instructor.getDepartment().getSession(), null, null, exams); ir.setM2d(true); ir.setDirect(true); ir.setClassSchedule(instructor.getDepartment().getSession().canNoRoleReportClass()); ir.printHeader(); ir.printReport(ExamInfo.createInstructorInfo(instructor), exams); ir.lastPage(); ir.close(); } else if (!studentExams.isEmpty()) { TreeSet<ExamAssignmentInfo> exams = new TreeSet<ExamAssignmentInfo>(); TreeSet<ExamSectionInfo> sections = new TreeSet<ExamSectionInfo>(); for (ExamOwner examOwner : studentExams) { if (examOwner.getExam().getAssignedPeriod() == null) continue; ExamAssignmentInfo x = new ExamAssignmentInfo(examOwner, student, studentExams); exams.add(x); sections.addAll(x.getSectionsIncludeCrosslistedDummies()); } StudentExamReport sr = new StudentExamReport(StudentExamReport.sModeNormal, out, student.getSession(), null, null, exams); sr.setM2d(true); sr.setBtb(true); sr.setDirect(true); sr.setClassSchedule(student.getSession().canNoRoleReportClass()); sr.printHeader(); sr.printReport(student, sections); sr.lastPage(); sr.close(); } else if (hasClasses) { if (instructor != null) { InstructorExamReport ir = new InstructorExamReport(InstructorExamReport.sModeNormal, out, instructor.getDepartment().getSession(), null, null, new TreeSet<ExamAssignmentInfo>()); ir.setM2d(true); ir.setDirect(true); ir.setClassSchedule(instructor.getDepartment().getSession().canNoRoleReportClass()); ir.printHeader(); ir.printReport(ExamInfo.createInstructorInfo(instructor), new TreeSet<ExamAssignmentInfo>()); ir.lastPage(); ir.close(); } else if (student != null) { StudentExamReport sr = new StudentExamReport(StudentExamReport.sModeNormal, out, student.getSession(), null, null, new TreeSet<ExamAssignmentInfo>()); sr.setM2d(true); sr.setBtb(true); sr.setDirect(true); sr.setClassSchedule(student.getSession().canNoRoleReportClass()); sr.printHeader(); sr.printReport(student, new TreeSet<ExamSectionInfo>()); sr.lastPage(); sr.close(); } } out.flush(); out.close(); return null; } if ("iCalendar".equals(myForm.getOp())) { Long sid = (instructor != null ? instructor.getDepartment().getSession().getUniqueId() : student.getSession().getUniqueId()); response.sendRedirect(response.encodeURL("export?q=" + QueryEncoderBackend.encode( "output=events.ics&type=person&ext=" + externalId + (sid == null ? "" : "&sid=" + sid)))); return null; } /* if ("iCalendar".equals(myForm.getOp())) { sLog.info(" Generating calendar for "+(instructor!=null?instructor.getName(DepartmentalInstructor.sNameFormatShort):student.getName(DepartmentalInstructor.sNameFormatShort))); try { File file = ApplicationProperties.getTempFile("schedule", "ics"); if (instructor!=null) { printInstructorSchedule(file, instructor, instructorExams); } else { printStudentSchedule(file, student, studentExams); } request.setAttribute(Constants.REQUEST_OPEN_URL, "temp/"+file.getName()); } catch (Exception e) { sLog.error("Unable to generate calendar for "+(instructor!=null?instructor.getName(DepartmentalInstructor.sNameFormatShort):student.getName(DepartmentalInstructor.sNameFormatShort)),e); } } */ if (!studentExams.isEmpty()) { myForm.setCanExport(true); TreeSet<ExamAssignmentInfo> exams = new TreeSet<ExamAssignmentInfo>(); for (ExamOwner examOwner : studentExams) exams.add(new ExamAssignmentInfo(examOwner, student, studentExams)); PdfWebTable table = getStudentExamSchedule(true, exams, student); request.setAttribute("schedule", table.printTable(WebTable.getOrder(sessionContext, "exams.o1"))); table = getStudentConflits(true, exams, student); if (!table.getLines().isEmpty()) request.setAttribute("conf", table.printTable(WebTable.getOrder(sessionContext, "exams.o3"))); } if (!instructorExams.isEmpty()) { myForm.setCanExport(true); TreeSet<ExamAssignmentInfo> exams = new TreeSet<ExamAssignmentInfo>(); for (Exam exam : instructorExams) exams.add(new ExamAssignmentInfo(exam, useCache)); PdfWebTable table = getInstructorExamSchedule(true, exams, instructor); request.setAttribute("ischedule", table.printTable(WebTable.getOrder(sessionContext, "exams.o2"))); table = getInstructorConflits(true, exams, instructor); if (!table.getLines().isEmpty()) request.setAttribute("iconf", table.printTable(WebTable.getOrder(sessionContext, "exams.o4"))); table = getStudentConflits(true, exams, instructor); if (!table.getLines().isEmpty()) request.setAttribute("sconf", table.printTable(WebTable.getOrder(sessionContext, "exams.o5"))); } long t1 = System.currentTimeMillis(); sLog.info("Request processed in " + new DecimalFormat("0.00").format(((double) (t1 - t0)) / 1000.0) + " s for " + (instructor != null ? instructor.getName(DepartmentalInstructor.sNameFormatShort) : student != null ? student.getName(DepartmentalInstructor.sNameFormatShort) : userName)); return mapping.findForward("show"); }
From source file:au.org.ala.biocache.web.WMSController.java
private void writeOccurrencesCsvToStream(SpatialSearchRequestParams requestParams, OutputStream stream) throws Exception { SolrDocumentList sdl = searchDAO.findByFulltext(requestParams); byte[] bComma = ",".getBytes("UTF-8"); byte[] bNewLine = "\n".getBytes("UTF-8"); byte[] bDblQuote = "\"".getBytes("UTF-8"); if (sdl != null && sdl.size() > 0) { //header field identification ArrayList<String> header = new ArrayList<String>(); if (requestParams.getFl() == null || requestParams.getFl().isEmpty()) { TreeSet<String> unique = new TreeSet<String>(); for (int i = 0; i < sdl.size(); i++) { unique.addAll(sdl.get(i).getFieldNames()); }// ww w.j a v a2 s .co m header = new ArrayList<String>(unique); } else { String[] fields = requestParams.getFl().split(","); for (int i = 0; i < fields.length; i++) { if (fields[i].length() > 0) { header.add(fields[i]); } } } //write header for (int i = 0; i < header.size(); i++) { if (i > 0) { stream.write(bComma); } stream.write(header.get(i).getBytes("UTF-8")); } //write records for (int i = 0; i < sdl.size(); i++) { stream.write(bNewLine); for (int j = 0; j < header.size(); j++) { if (j > 0) { stream.write(bComma); } if (sdl.get(i).containsKey(header.get(j))) { stream.write(bDblQuote); stream.write(String.valueOf(sdl.get(i).getFieldValue(header.get(j))).replace("\"", "\"\"") .getBytes("UTF-8")); stream.write(bDblQuote); } } } } }
From source file:org.jahia.services.importexport.ImportExportBaseService.java
private void exportNodesWithBinaries(JCRNodeWrapper rootNode, Set<JCRNodeWrapper> nodes, ZipOutputStream zout, Set<String> typesToIgnore, Set<String> externalReferences, Map<String, Object> params, boolean logProgress) throws SAXException, IOException, RepositoryException, TransformerException { TreeSet<JCRNodeWrapper> liveSortedNodes = new TreeSet<JCRNodeWrapper>(new Comparator<JCRNodeWrapper>() { @Override/*from w w w.j a va 2s . c o m*/ public int compare(JCRNodeWrapper o1, JCRNodeWrapper o2) { return o1.getPath().compareTo(o2.getPath()); } }); // final String xsl = (String) params.get(XSL_PATH); if (params.containsKey(INCLUDE_LIVE_EXPORT)) { final JCRSessionWrapper liveSession = jcrStoreService.getSessionFactory().getCurrentUserSession("live"); JCRNodeWrapper liveRootNode = null; try { liveRootNode = liveSession.getNodeByIdentifier(rootNode.getIdentifier()); } catch (RepositoryException e) { } if (liveRootNode != null) { for (JCRNodeWrapper node : nodes) { try { liveSortedNodes.add(liveSession.getNodeByIdentifier(node.getIdentifier())); } catch (ItemNotFoundException e) { } } if (!liveSortedNodes.isEmpty()) { zout.putNextEntry(new ZipEntry(LIVE_REPOSITORY_XML)); logger.info("Exporting live workspace for nodes {} ...", nodes); exportNodes(liveRootNode, liveSortedNodes, zout, typesToIgnore, externalReferences, params, logProgress); zout.closeEntry(); exportNodesBinary(liveRootNode, liveSortedNodes, zout, typesToIgnore, "/live-content"); logger.info("Live workspace exported for nodes {}", nodes); } } } TreeSet<JCRNodeWrapper> sortedNodes = new TreeSet<JCRNodeWrapper>(new Comparator<JCRNodeWrapper>() { @Override public int compare(JCRNodeWrapper o1, JCRNodeWrapper o2) { return o1.getPath().compareTo(o2.getPath()); } }); sortedNodes.addAll(nodes); for (JCRNodeWrapper liveSortedNode : liveSortedNodes) { try { sortedNodes.add(rootNode.getSession().getNodeByIdentifier(liveSortedNode.getIdentifier())); } catch (ItemNotFoundException e) { // Node does not exist in default do nothing } } zout.putNextEntry(new ZipEntry(REPOSITORY_XML)); logger.info("Exporting default workspace for nodes {} ...", nodes); exportNodes(rootNode, sortedNodes, zout, typesToIgnore, externalReferences, params, logProgress); zout.closeEntry(); exportNodesBinary(rootNode, sortedNodes, zout, typesToIgnore, "/content"); logger.info("Default workspace exported for nodes {}", nodes); }
From source file:org.unitime.timetable.solver.studentsct.StudentSectioningDatabaseLoader.java
public Student loadStudent(org.unitime.timetable.model.Student s, Hashtable<Long, Course> courseTable, Hashtable<Long, Section> classTable) { // Check for nobatch sectioning status if (iCheckForNoBatchStatus && s.hasSectioningStatusOption(StudentSectioningStatus.Option.nobatch)) { skipStudent(s, courseTable, classTable); return null; }//from www.j a v a 2 s. c o m // Check student query, if present if (iStudentQuery != null && !iStudentQuery.match(new DbStudentMatcher(s))) { skipStudent(s, courseTable, classTable); return null; } NameFormat nameFormat = NameFormat .fromReference(ApplicationProperty.OnlineSchedulingStudentNameFormat.value()); iProgress.debug("Loading student " + s.getUniqueId() + " (id=" + s.getExternalUniqueId() + ", name=" + nameFormat.format(s) + ")"); Student student = new Student(s.getUniqueId().longValue()); student.setExternalId(s.getExternalUniqueId()); student.setName(nameFormat.format(s)); student.setStatus(s.getSectioningStatus() == null ? null : s.getSectioningStatus().getReference()); if (iLoadStudentInfo) loadStudentInfo(student, s); TreeSet<CourseDemand> demands = new TreeSet<CourseDemand>(new Comparator<CourseDemand>() { public int compare(CourseDemand d1, CourseDemand d2) { if (d1.isAlternative() && !d2.isAlternative()) return 1; if (!d1.isAlternative() && d2.isAlternative()) return -1; int cmp = d1.getPriority().compareTo(d2.getPriority()); if (cmp != 0) return cmp; return d1.getUniqueId().compareTo(d2.getUniqueId()); } }); demands.addAll(s.getCourseDemands()); for (CourseDemand cd : demands) { if (cd.getFreeTime() != null) { TimeLocation ft = new TimeLocation(cd.getFreeTime().getDayCode(), cd.getFreeTime().getStartSlot(), cd.getFreeTime().getLength(), 0, 0, -1l, "", iFreeTimePattern, 0); new FreeTimeRequest(cd.getUniqueId(), cd.getPriority(), cd.isAlternative(), student, ft); } else if (!cd.getCourseRequests().isEmpty()) { Vector<Course> courses = new Vector<Course>(); HashSet<Choice> selChoices = new HashSet<Choice>(); HashSet<Choice> wlChoices = new HashSet<Choice>(); HashSet<Section> assignedSections = new HashSet<Section>(); Config assignedConfig = null; TreeSet<org.unitime.timetable.model.CourseRequest> crs = new TreeSet<org.unitime.timetable.model.CourseRequest>( new Comparator<org.unitime.timetable.model.CourseRequest>() { public int compare(org.unitime.timetable.model.CourseRequest r1, org.unitime.timetable.model.CourseRequest r2) { return r1.getOrder().compareTo(r2.getOrder()); } }); crs.addAll(cd.getCourseRequests()); for (org.unitime.timetable.model.CourseRequest cr : crs) { Course course = courseTable.get(cr.getCourseOffering().getUniqueId()); if (course == null) { iProgress.warn("Student " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + ") requests course " + cr.getCourseOffering().getCourseName() + " that is not loaded."); continue; } for (Iterator k = cr.getClassWaitLists().iterator(); k.hasNext();) { ClassWaitList cwl = (ClassWaitList) k.next(); Section section = course.getOffering().getSection(cwl.getClazz().getUniqueId().longValue()); if (section != null) { if (cwl.getType().equals(ClassWaitList.TYPE_SELECTION)) selChoices.add(section.getChoice()); else if (cwl.getType().equals(ClassWaitList.TYPE_WAITLIST)) wlChoices.add(section.getChoice()); } } if (assignedConfig == null) { HashSet<Long> subparts = new HashSet<Long>(); for (Iterator<StudentClassEnrollment> i = cr.getClassEnrollments().iterator(); i .hasNext();) { StudentClassEnrollment enrl = i.next(); Section section = course.getOffering().getSection(enrl.getClazz().getUniqueId()); if (section != null) { if (getModel().isMPP()) selChoices.add(section.getChoice()); assignedSections.add(section); if (assignedConfig != null && assignedConfig.getId() != section.getSubpart().getConfig().getId()) { iProgress.error("There is a problem assigning " + course.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + "): classes from different configurations."); } assignedConfig = section.getSubpart().getConfig(); if (!subparts.add(section.getSubpart().getId())) { iProgress.error("There is a problem assigning " + course.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + "): two or more classes of the same subpart."); } } else { iProgress.error("There is a problem assigning " + course.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + "): class " + enrl.getClazz().getClassLabel() + " not known."); } } } courses.addElement(course); } if (courses.isEmpty()) continue; CourseRequest request = new CourseRequest(cd.getUniqueId(), cd.getPriority(), cd.isAlternative(), student, courses, cd.isWaitlist(), cd.getTimestamp().getTime()); request.getSelectedChoices().addAll(selChoices); request.getWaitlistedChoices().addAll(wlChoices); if (assignedConfig != null && assignedSections.size() == assignedConfig.getSubparts().size()) { Enrollment enrollment = new Enrollment(request, 0, assignedConfig, assignedSections, getAssignment()); request.setInitialAssignment(enrollment); } if (assignedConfig != null && assignedSections.size() != assignedConfig.getSubparts().size()) { iProgress.error("There is a problem assigning " + request.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + ") wrong number of classes (" + "has " + assignedSections.size() + ", expected " + assignedConfig.getSubparts().size() + ")."); } } } if (!s.getClassEnrollments().isEmpty() || !s.getWaitlists().isEmpty()) { TreeSet<Course> courses = new TreeSet<Course>(new Comparator<Course>() { public int compare(Course c1, Course c2) { return (c1.getSubjectArea() + " " + c1.getCourseNumber()) .compareTo(c2.getSubjectArea() + " " + c2.getCourseNumber()); } }); Map<Long, Long> timeStamp = new Hashtable<Long, Long>(); for (StudentClassEnrollment enrl : s.getClassEnrollments()) { if (enrl.getCourseRequest() != null) continue; // already loaded Course course = courseTable.get(enrl.getCourseOffering().getUniqueId()); if (course == null) { iProgress.warn("Student " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + ") requests course " + enrl.getCourseOffering().getCourseName() + " that is not loaded."); continue; } if (enrl.getTimestamp() != null) timeStamp.put(enrl.getCourseOffering().getUniqueId(), enrl.getTimestamp().getTime()); courses.add(course); } for (WaitList w : s.getWaitlists()) { Course course = courseTable.get(w.getCourseOffering().getUniqueId()); if (course == null) { iProgress.warn("Student " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + ") requests course " + w.getCourseOffering().getCourseName() + " that is not loaded."); continue; } if (w.getTimestamp() != null) timeStamp.put(w.getCourseOffering().getUniqueId(), w.getTimestamp().getTime()); courses.add(course); } int priority = 0; courses: for (Course course : courses) { Vector<Course> cx = new Vector<Course>(); cx.add(course); CourseRequest request = null; for (Request r : student.getRequests()) { if (r instanceof CourseRequest && getAssignment().getValue(r) == null && ((CourseRequest) r).getCourses().contains(course)) { request = (CourseRequest) r; break; } } if (request == null) { request = new CourseRequest(course.getId(), priority++, false, student, cx, true, timeStamp.get(course.getId())); } HashSet<Section> assignedSections = new HashSet<Section>(); Config assignedConfig = null; HashSet<Long> subparts = new HashSet<Long>(); for (Iterator<StudentClassEnrollment> i = s.getClassEnrollments().iterator(); i.hasNext();) { StudentClassEnrollment enrl = i.next(); if (course.getId() != enrl.getCourseOffering().getUniqueId()) continue; Section section = course.getOffering().getSection(enrl.getClazz().getUniqueId()); if (section != null) { assignedSections.add(section); if (assignedConfig != null && assignedConfig.getId() != section.getSubpart().getConfig().getId()) { iProgress.error("There is a problem assigning " + request.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + "): classes from different configurations."); continue courses; } assignedConfig = section.getSubpart().getConfig(); if (!subparts.add(section.getSubpart().getId())) { iProgress.error("There is a problem assigning " + request.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + "): two or more classes of the same subpart."); continue courses; } } else { iProgress.error("There is a problem assigning " + request.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + "): class " + enrl.getClazz().getClassLabel() + " not known."); Section x = classTable.get(enrl.getClazz().getUniqueId()); if (x != null) { iProgress.info(" but a class with the same id is loaded, but under offering " + x.getSubpart().getConfig().getOffering().getName() + " (id is " + x.getSubpart().getConfig().getOffering().getId() + ", expected " + course.getOffering().getId() + ")"); } continue courses; } } if (assignedConfig != null && assignedSections.size() == assignedConfig.getSubparts().size()) { Enrollment enrollment = new Enrollment(request, 0, assignedConfig, assignedSections, getAssignment()); request.setInitialAssignment(enrollment); } if (assignedConfig != null && assignedSections.size() != assignedConfig.getSubparts().size()) { iProgress.error("There is a problem assigning " + request.getName() + " to " + nameFormat.format(s) + " (" + s.getExternalUniqueId() + "): wrong number of classes (" + "has " + assignedSections.size() + ", expected " + assignedConfig.getSubparts().size() + ")."); } } } return student; }
From source file:org.apache.axis2.jaxws.runtime.description.marshal.impl.PackageSetBuilder.java
/** * For each data element, we need the package for both the element and its type. * * @param cls Class representing element, type or both * @param namespace of the element//w w w . jav a 2 s. c o m * @param localPart of the element * @param set with both type and element packages set */ private static void setTypeAndElementPackages(Class cls, String namespace, String localPart, TreeSet<String> set, MarshalServiceRuntimeDescription msrd) { // Get the element and type classes Class eClass = getElement(cls, msrd); Class tClass = getType(cls); // Set the package for the type if (tClass != null) { Package typePkg = tClass.getPackage(); //For primitive types there is no package String pkg = (typePkg != null) ? typePkg.getName() : null; if (pkg != null) { set.add(pkg); set.add("@" + pkg); // Indicates a package from an actual class reference (versus namespace) set.add("[" + tClass.getCanonicalName() + "]"); // Indicates a actual class reference } // If there is an xmlType, and it maps to a package then add // an override if the package is different. if (pkg != null) { AnnotationDesc ad = msrd.getAnnotationDesc(tClass); if (ad != null && ad.hasXmlType()) { String ns = ad.getXmlTypeNamespace(); if (ns != null && ns.length() > 0) { List pkgs = makePackages(ns); if (pkgs != null) { for (int i = 0; i < pkgs.size(); i++) { String pkg2 = (String) pkgs.get(i); if (!pkg.equals(pkg2)) { String override = pkg + " > " + pkg2; if (!set.contains(override)) { set.add(override); if (log.isDebugEnabled()) { log.debug("Adding override=" + override); } } } } } } } } addXmlSeeAlsoPackages(tClass, msrd, set); } // Set the package for the element if (tClass != eClass) { if (eClass == null) { // A null or empty namespace indicates that the element is // unqualified. This can occur if the parameter is represented as a child element // in doc/lit wrapped. The package is determined from the wrapper element in such casses. if (namespace != null && namespace.length() > 0) { // Use default namespace to package algorithm List pkgs = makePackages(namespace); if (pkgs != null) { set.addAll(pkgs); } } } else { Package elementPkg = eClass.getPackage(); String pkg = (elementPkg != null) ? elementPkg.getName() : null; if (pkg != null) { set.add(pkg); set.add("@" + pkg); // Indicates a package from an actual class reference (versus namespace) set.add("[" + eClass.getCanonicalName() + "]"); // Indicates a actual class reference } if (pkg != null) { AnnotationDesc ad = msrd.getAnnotationDesc(tClass); if (ad != null && ad.hasXmlRootElement()) { String ns = ad.getXmlRootElementNamespace(); if (ns != null && ns.length() > 0) { List pkgs = makePackages(ns); if (pkgs != null) { for (int i = 0; i < pkgs.size(); i++) { String pkg2 = (String) pkgs.get(i); if (!pkg.equals(pkg2)) { String override = pkg + " > " + pkg2; if (!set.contains(override)) { set.add(override); if (log.isDebugEnabled()) { log.debug("Adding override=" + override); } } } } } } } } addXmlSeeAlsoPackages(tClass, msrd, set); } } }