Package com.apps.datastore.dao

Examples of com.apps.datastore.dao.SectionInformationObject


    return startEnd;
  }
 
  public SectionInformationObject findMin(
      List<SectionInformationObject> courses) {
    SectionInformationObject min;

    if (courses == null || courses.size() == 0) {
      return null;
    } else if (courses.size() == 1) {
      return courses.get(0);
    } else {
      min = courses.get(0);
      for (int i = 1; i < courses.size(); i++) {

        // Parse the courses' time, only needs to check the first
        // because the start is always lesser than the end.
        String[] t_start = courses.get(i).getStart().split(":");
        int t_start_hour = Integer.parseInt(t_start[0]);
        int t_start_min = Integer.parseInt(t_start[1]);

        // Parse the min's time
        String[] m_start = min.getStart().split(":");
        int m_start_hour = Integer.parseInt(m_start[0]);
        int m_start_min = Integer.parseInt(m_start[1]);

        // Now compare the hours, if == then compare the min
        if (t_start_hour < m_start_hour) {
View Full Code Here


  // Exactly the same as the findMin but the sign are changed.
  // Instead of getting Start, we get End
  public SectionInformationObject findMax(
      List<SectionInformationObject> courses) {
    SectionInformationObject max;

    if (courses == null || courses.size() == 0) {
      return null;
    } else if (courses.size() == 1) {
      return courses.get(0);
    } else {
      max = courses.get(0);
      for (int i = 1; i < courses.size(); i++) {

        // Parse the courses' time, only needs to check the first
        // because the start is always lesser than the end.
        String[] t_start = courses.get(i).getEnd().split(":");
        int t_start_hour = Integer.parseInt(t_start[0]);
        int t_start_min = Integer.parseInt(t_start[1]);

        // Parse the min's time
        String[] m_start = max.getEnd().split(":");
        int m_start_hour = Integer.parseInt(m_start[0]);
        int m_start_min = Integer.parseInt(m_start[1]);

        // Now compare the hours, if == then compare the min
        if (t_start_hour > m_start_hour) {
View Full Code Here

          else
            prefix = "";
          List<SectionInformationObject> siol = d.querySectionByPrefix(dept, course, prefix);
          if(!siol.isEmpty()){
            for(Iterator<SectionInformationObject> i = siol.iterator(); i.hasNext();) {
              SectionInformationObject sio = i.next();
              String deptId = "<b>"+sio.getDepartmentId()+"</b>";
              String courseId = "<b>"+sio.getCourseId()+"</b>";
              String sectionId = sio.getSectionId();
              String activity ="<i>"+ sio.getActivity()+"</i>";
              sectionId = "<b>"+prefix+"</b>" +sectionId.substring(prefix.length());
              String out= deptId +" " + courseId +" "+ sectionId+ " "+activity+"\n";
              if(!response.contains(out))
                response += out;
            }
View Full Code Here

        String dept = req.getParameter("dept");
        String course = req.getParameter("course");
        String section = req.getParameter("section");
        WorklistItemObject wio = new WorklistItemObject(dept, course,
            section);
        SectionInformationObject sio = spiderDatastore
            .querySectionFromId(dept, course, section);
        List<SectionInformationObject> siol = d.getWorklistAsSIO(user);
        boolean conflict = isInConflict(siol, sio);
        boolean success = false;
        if (!conflict)
          success = d.addWorklistItem(user, wio);
        if (success)
          xmlout += "\t<message>Item was successfully added to worklist</message>\n";
        else if (conflict)
          xmlout += "\t<message>Unable to add to worklist, due to schedule conflict</message>\n";
        else
          xmlout += "\t<message>Item already exists in worklist</message>\n";
      } else if (action.equals("remove")) {
        String dept = req.getParameter("dept");
        String course = req.getParameter("course");
        String section = req.getParameter("section");
        String start = req.getParameter("start");
        // String end = req.getParameter("end");
        WorklistItemObject wio = new WorklistItemObject(dept, course,
            section);
        boolean success = d.deleteWorklistItem(user, wio);
        if (success) {
          xmlout += "\t<message>Item was successfully removed from worklist</message>\n";
        } else
          xmlout += "\t<message>Item failed to remove from worklist</message>\n";
      } else if (action.equals("get")) {
        List<SectionInformationObject> siol = d.getWorklistAsSIO(user);
        for (Iterator<SectionInformationObject> i = siol.iterator(); i
            .hasNext();) {
          SectionInformationObject sio = i.next();
          xmlout += "\t<item>\n";
          xmlout += "\t\t<dept>" + sio.getDepartmentId()
              + "</dept>\n";
          xmlout += "\t\t<course>" + sio.getCourseId()
              + "</course>\n";
          xmlout += "\t\t<section>" + sio.getSectionId()
              + "</section>\n";
          xmlout += "\t\t<start>" + sio.getStart() + "</start>\n";
          xmlout += "\t\t<end>" + sio.getEnd() + "</end>\n";
          xmlout += "\t\t<day>" + sio.getDay() + "</day>\n";
          xmlout += "\t\t<term>" + sio.getTerm() + "</term>\n";
          xmlout += "\t\t<building>" + sio.getBuilding()
              + "</building>\n";
          xmlout += "\t\t<room>" + sio.getRoom() + "</room>\n";
          xmlout += "\t</item>\n";
        }
      } else if (action.equals("view")) {
        String email = req.getParameter("email");
        if (d.checkSubscriptionExists(email, user)) {
          List<SectionInformationObject> siol = d
              .getWorklistAsSIO(email);
          for (Iterator<SectionInformationObject> i = siol.iterator(); i
              .hasNext();) {
            SectionInformationObject sio = i.next();
            xmlout += "\t<item>\n";
            xmlout += "\t\t<dept>" + sio.getDepartmentId()
                + "</dept>\n";
            xmlout += "\t\t<course>" + sio.getCourseId()
                + "</course>\n";
            xmlout += "\t\t<section>" + sio.getSectionId()
                + "</section>\n";
            xmlout += "\t\t<start>" + sio.getStart() + "</start>\n";
            xmlout += "\t\t<end>" + sio.getEnd() + "</end>\n";
            xmlout += "\t\t<day>" + sio.getDay() + "</day>\n";
            xmlout += "\t\t<term>" + sio.getTerm() + "</term>\n";
            xmlout += "\t\t<building>" + sio.getBuilding()
                + "</building>\n";
            xmlout += "\t\t<room>" + sio.getRoom() + "</room>\n";
            xmlout += "\t</item>\n";
          }
        }
      } else if (action.equals("check")) {
        String dept = req.getParameter("dept");
View Full Code Here

  }
 
  private SectionModel getSectionModel(String d, String c, String s){
    UBCCourseSpiderDatastore sd = new UBCCourseSpiderDatastore();
    SectionInformationObject sio = sd.querySectionFromId(d, c, s);
    CourseInformationObject cio = sd.queryCourseFromId(d, c);
   
    UBCWayfindingService uws = UBCWayfindingServiceFactory.getUBCWayfindingService();
    BuildingModel blo = uws.search(sio.getBuilding());
   
    String lat = "";
    String lng = "";
    if (blo != null) {
      lat = blo.getLatitude();
      lng = blo.getLongitude();
    }
   
    String dept = sio.getDepartmentId();
    String course = sio.getCourseId();
    String section = sio.getSectionId();
    String day = sio.getDay();
    String term = sio.getTerm();
    String building = sio.getBuilding();
    String room = sio.getRoom();
    String activity = sio.getActivity();
    String title = cio.getCourseTitle();
    String instructor = sio.getInstructor();
    String drop = sio.getDropNoWDate();
    String withdraw = sio.getDropWDate();
    String start = sio.getStart();
    String cdf = "No";
    if(sio.isCdf())
      cdf = "Yes";
    String end = sio.getEnd();
    String location = sio.getLocation();
    SectionModel sm = new SectionModel( dept,  course,  section,
         activity,  term,  day,  location,
         start,  end,  instructor,  building,
         room,  cdf,  drop,  withdraw,
         title,  lat,  lng);
View Full Code Here

  }
 
  public String getSectionInformation(String dID, String cID, String sID){
    UBCCourseSpiderDatastore sd = new UBCCourseSpiderDatastore();
    UBCWayfindingService uws = UBCWayfindingServiceFactory.getUBCWayfindingService();
    SectionInformationObject sio = sd.querySectionFromId(dID, cID, sID);
   
    String out = "";   
   
    String dept = sio.getDepartmentId();
    String course = sio.getCourseId();
    String section = sio.getSectionId();
    String day = sio.getDay();
    String term = sio.getTerm();
    BuildingModel blo = uws.search(sio.getBuilding());
    UBCSectionDetailService w = new UBCSectionDetailService();
    w.initContent(new UniqueCourseObject(dept,course,section));
    List<BookInformation> biol = w.getBookList();
   
    out += "<table>";
    out += "<tr>\n";
    out += "<td>"+dept+"&nbsp;"+course+"&nbsp;"+section+"</td>\n";
    out += "</tr>\n";
    out += "<tr>\n";
    out += "<td><b>Activity: </b>"+sio.getActivity()+"</td>\n";
    out += "<td><b>Term: </b>"+term+"</td>\n";
    out += "</tr>\n";
    out += "<tr>\n";
    out += "<td><b>Day: </b>"+day+"</td>\n";
    out += "<td><b>Time: </b>"+sio.getStart()+" - "+sio.getEnd()+"</td>\n";
    out += "</tr>\n";
    if(!sio.getInstructor().isEmpty()){
      out += "<tr>\n";
      out += "<td><b>Instructor: </b>"+sio.getInstructor()+"</td>\n";
      out += "</tr>\n";
    }
    if(blo != null) {
    out += "<tr>\n";
    out += "<td><b>Building: </b>"+sio.getBuilding()+"</td>\n";
    out += "<td><b>Room: </b>"+sio.getRoom()+"</td>\n";
    if(blo.getLatitude() != "" && blo.getLongitude() != "")
      out += "<td>"+"<img src=\"http://maps.googleapis.com/maps/api/staticmap?center="+blo.getLatitude()+","+blo.getLongitude()+"&zoom=17&size=320x320&markers=color:blue%7Clabel:S%7C"+blo.getLatitude()+","+blo.getLongitude()+"&maptype=hybrid&sensor=false\"  width=\"320\" height=\"320\">"+"</td>";
    out += "</tr>\n";
    }
    if(!biol.isEmpty()){
View Full Code Here

    String course = req.getParameter("course");
    String section = req.getParameter("section");
    String xmlout = "<searchresults>\n";
   
    if (dept != null && course != null && section != null && !dept.isEmpty()&& !course.isEmpty()&& !section.isEmpty()) {
      SectionInformationObject sio = d.querySectionFromId(dept.toUpperCase(),
          course.toUpperCase(), section.toUpperCase());
      if (sio != null) {
        xmlout += "<type>section</type>\n";
        xmlout += "\t<item>\n";
        xmlout += "\t\t<dept>"+StringEscapeUtils.escapeXml(sio.getDepartmentId())+"</dept>\n";
        xmlout += "\t\t<course>"+StringEscapeUtils.escapeXml(sio.getCourseId())+"</course>\n";
        xmlout += "\t\t<section>"+StringEscapeUtils.escapeXml(sio.getSectionId())+"</section>\n";
        xmlout += "\t</item>\n";
      }
      else {
        xmlout += "<type>none</type>\n";
      }
View Full Code Here

      String departmentId = req.getParameter("departmentId");
      String courseId = req.getParameter("courseId");
      CourseInformationObject cio = d.queryCourseFromId(departmentId, courseId);
      List<SectionInformationObject> siol = spider.getSections(cio);
      for(Iterator k = siol.iterator(); k.hasNext();){
        SectionInformationObject sio = (SectionInformationObject) k.next();
        d.addSection(sio);
      }
    }   
   
  }
View Full Code Here

TOP

Related Classes of com.apps.datastore.dao.SectionInformationObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.