Package org.olat.commons.calendar

Examples of org.olat.commons.calendar.CalendarManager


      String calendarID = st.nextToken();
      String eventID = st.nextToken();
      KalendarRenderWrapper kalendarWrapper = (KalendarRenderWrapper)kalendars.get(calendarID);
      KalendarEvent event = kalendarWrapper.getKalendar().getEvent(eventID);
      KalendarEvent recurEvent = null;
      CalendarManager cm = CalendarManagerFactory.getInstance().getCalendarManager();
      Long time = Long.parseLong(st.nextToken());
      Date dateStart = new Date(time);
      Calendar cal = CalendarUtils.createCalendarInstance(ureq.getLocale());
      cal.setTime(dateStart);
      cal.add(Calendar.DAY_OF_YEAR, 1);
      Date dateEnd = cal.getTime();
      recurEvent = cm.getRecurringInPeriod(dateStart, dateEnd, event);
      setDirty(true);
      fireEvent(ureq, new KalendarGUIEditEvent(recurEvent != null ? recurEvent : event, kalendarWrapper));
    } else if (command.equals(CMD_ADD)) {
      // this will get us the day of the year
      String sDate = ureq.getParameter(ID_PARAM);
View Full Code Here


      TreeEvent te = (TreeEvent) event;
      if (event.getCommand().equals(TreeEvent.COMMAND_TREENODES_SELECTED)) {
        // rebuild kalendar event links
        List selectedNodesIDS = te.getNodeIds();
        TreeModel model = calendarSelectionTree.getTreeModel();
        CalendarManager calendarManager = CalendarManagerFactory.getInstance().getCalendarManager();
        for (Iterator iter = selectedNodesIDS.iterator(); iter.hasNext();) {
          String nodeId = (String)iter.next();
          GenericTreeNode node = (GenericTreeNode)model.getNodeById(nodeId);
          KalendarRenderWrapper calendarWrapper = (KalendarRenderWrapper)node.getUserObject();
          Kalendar cal = calendarWrapper.getKalendar();
          KalendarEvent clonedKalendarEvent = (KalendarEvent)XStreamHelper.xstreamClone(kalendarEvent);
          if (clonedKalendarEvent.getKalendarEventLinks().size() != 0)
            clonedKalendarEvent.setKalendarEventLinks(new ArrayList());
          calendarManager.addEventTo(cal, clonedKalendarEvent);
//          calendarManager.persistCalendar(cal);     
        }
        fireEvent(ureq, Event.DONE_EVENT);
      } else {
        fireEvent(ureq, Event.CANCELLED_EVENT);
View Full Code Here

    setInitialComponent(calendarController.getInitialComponent());
  }

  private List getListOfCalendarWrappers(UserRequest ureq) {
    List calendars = new ArrayList();
    CalendarManager calendarManager = CalendarManagerFactory.getInstance().getCalendarManager();
    // add course calendar
    ICourse course = CourseFactory.loadCourse(ores);
    courseKalendarWrapper = calendarManager.getCourseCalendar(course);
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    Identity identity = ureq.getIdentity();
    boolean isPrivileged = cgm.isIdentityCourseAdministrator(identity) || cgm.hasRight(identity, CourseRights.RIGHT_COURSEEDITOR) || RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(RepositoryManager.getInstance().lookupRepositoryEntry(course, false), identity);
    if (isPrivileged) {
      courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
    } else {
      courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
    }
    KalendarConfig config = calendarManager.findKalendarConfigForIdentity(courseKalendarWrapper.getKalendar(), ureq);
    if (config != null) {
      courseKalendarWrapper.getKalendarConfig().setCss(config.getCss());
      courseKalendarWrapper.getKalendarConfig().setVis(config.isVis());
    }
    // add link provider
View Full Code Here

    return calendars;
  }
 
  private void addCalendars(UserRequest ureq, List groups, boolean isOwner, LinkProvider linkProvider, List calendars) {
    CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
    CalendarManager calendarManager = CalendarManagerFactory.getInstance().getCalendarManager();
    for (Iterator iter = groups.iterator(); iter.hasNext();) {
      BusinessGroup bGroup = (BusinessGroup) iter.next();
      CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
      if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) continue;
      KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
      // set calendar access
      int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
      Long lCalAccess = collabTools.lookupCalendarAccess();
      if (lCalAccess != null) iCalAccess = lCalAccess.intValue();
      if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
      } else {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
      }
      KalendarConfig config = calendarManager.findKalendarConfigForIdentity(groupCalendarWrapper.getKalendar(), ureq);
      if (config != null) {
        groupCalendarWrapper.getKalendarConfig().setCss(config.getCss());
        groupCalendarWrapper.getKalendarConfig().setVis(config.isVis());
      }
      groupCalendarWrapper.setLinkProvider(linkProvider);
View Full Code Here

    if (!checkPathAuthenticity(calendarType, userName, authToken, calendarID)) {
      Tracing.logWarn("Authenticity Check failed for the ical feed path: " + pathInfo, this.getClass());
      return null;
    }

    CalendarManager calendarManager = CalendarManagerFactory.getInstance().getCalendarManager();
   
    // check if the calendar exists (calendars are only persisted when an event is created)
    if (calendarManager.calendarExists(calendarType, calendarID)) {
      // read and return the calendar file
      return calendarManager.readCalendar(calendarType, calendarID);
    } else {
      // return an empty calendar file
      return new Calendar();
    }
     
View Full Code Here

  public static List<KalendarRenderWrapper> getListOfCalendarWrappers(UserRequest ureq, WindowControl wControl) {
    List<KalendarRenderWrapper> calendars = new ArrayList<KalendarRenderWrapper>();
   
    // get the personal calendar
    CalendarManager calendarManager = CalendarManagerFactory.getInstance().getCalendarManager();
    KalendarRenderWrapper calendarWrapper = calendarManager.getPersonalCalendar(ureq.getIdentity());
    calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
    KalendarConfig personalKalendarConfig = calendarManager.findKalendarConfigForIdentity(
        calendarWrapper.getKalendar(), ureq);
    if (personalKalendarConfig != null) {
      calendarWrapper.getKalendarConfig().setCss(personalKalendarConfig.getCss());
      calendarWrapper.getKalendarConfig().setVis(personalKalendarConfig.isVis());
    }
    calendars.add(calendarWrapper);
   
    // get group calendars
    BusinessGroupManager bgManager = BusinessGroupManagerImpl.getInstance();
    List<BusinessGroup> ownerGroups = bgManager.findBusinessGroupsOwnedBy(null, ureq.getIdentity(), null);
    addCalendars(ureq, ownerGroups, true, calendars);
    List<BusinessGroup> attendedGroups = bgManager.findBusinessGroupsAttendedBy(null, ureq.getIdentity(), null);
    for (Iterator<BusinessGroup> ownerGroupsIterator = ownerGroups.iterator(); ownerGroupsIterator.hasNext();) {
      BusinessGroup ownerGroup = ownerGroupsIterator.next();
      if (attendedGroups.contains(ownerGroup))
        attendedGroups.remove(ownerGroup);
    }
    addCalendars(ureq, attendedGroups, false, calendars);
   
    // add course calendars
    List<String> subscribedCourseCalendarIDs = CourseCalendarSubscription.getSubscribedCourseCalendarIDs(
        ureq.getUserSession().getGuiPreferences());
   
    RepositoryManager repoManager = RepositoryManager.getInstance();
    List<String> calendarIDsToBeRemoved = new ArrayList<String>();
    for (Iterator<String> iter = subscribedCourseCalendarIDs.iterator(); iter.hasNext();) {
      String courseCalendarID = iter.next();
      final long courseResourceableID = Long.parseLong(courseCalendarID);
     
      RepositoryEntry repoEntry = repoManager.lookupRepositoryEntry(new OLATResourceable() {

        public Long getResourceableId() { return new Long(courseResourceableID); }
        public String getResourceableTypeName() { return CourseModule.getCourseTypeName(); }
      }, false);
      if (repoEntry == null) {
        // mark calendar ID for cleanup
        calendarIDsToBeRemoved.add(courseCalendarID);
        continue;
      }
      ICourse course = CourseFactory.loadCourse(new Long(courseResourceableID));
      //calendar course aren't enabled per default but course node of type calendar are always possible
      //REVIEW if (!course.getCourseEnvironment().getCourseConfig().isCalendarEnabled()) continue;
      // add course calendar
      KalendarRenderWrapper courseCalendarWrapper = calendarManager.getCourseCalendar(course);
      CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
      boolean isPrivileged = cgm.isIdentityCourseAdministrator(ureq.getIdentity())
        || cgm.hasRight(ureq.getIdentity(), CourseRights.RIGHT_COURSEEDITOR);
      if (isPrivileged) {
        courseCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
      } else {
        courseCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
      }
      KalendarConfig courseKalendarConfig = calendarManager.findKalendarConfigForIdentity(courseCalendarWrapper.getKalendar(), ureq);
      if (courseKalendarConfig != null) {
        courseCalendarWrapper.getKalendarConfig().setCss(courseKalendarConfig.getCss());
        courseCalendarWrapper.getKalendarConfig().setVis(courseKalendarConfig.isVis());
      }
      courseCalendarWrapper.setLinkProvider(new CourseLinkProviderController(course, ureq, wControl));
View Full Code Here

    return ImportCalendarManager.getImportedCalendarsForIdentity(ureq);
  }
 
  private static void addCalendars(UserRequest ureq, List<BusinessGroup> groups, boolean isOwner, List<KalendarRenderWrapper> calendars) {
    CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
    CalendarManager calendarManager = CalendarManagerFactory.getInstance().getCalendarManager();
    for (Iterator<BusinessGroup> iter = groups.iterator(); iter.hasNext();) {
      BusinessGroup bGroup = iter.next();
      CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
      if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) continue;
      KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
      // set calendar access
      int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
      Long lCalAccess = collabTools.lookupCalendarAccess();
      if (lCalAccess != null) iCalAccess = lCalAccess.intValue();
      if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
      } else {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
      }
      KalendarConfig groupKalendarConfig = calendarManager.findKalendarConfigForIdentity(groupCalendarWrapper.getKalendar(), ureq);
      if (groupKalendarConfig != null) {
        groupCalendarWrapper.getKalendarConfig().setCss(groupKalendarConfig.getCss());
        groupCalendarWrapper.getKalendarConfig().setVis(groupKalendarConfig.isVis());
      }
      calendars.add(groupCalendarWrapper);
View Full Code Here

    // delete course group- and rightmanagement
    course.getCourseEnvironment().getCourseGroupManager().deleteCourseGroupmanagement();
    // delete all remaining course properties
    course.getCourseEnvironment().getCoursePropertyManager().deleteAllCourseProperties();
    // delete course calendar
    CalendarManager calManager = CalendarManagerFactory.getInstance().getCalendarManager();
    calManager.deleteCourseCalendar(course);
    // cleanup cache
    removeFromCache(res.getResourceableId());
    loadedCourseStatistics.remove(res.getResourceableId());     
    //TODO: ld: broadcast event: DeleteCourseEvent
View Full Code Here

   * Checks all learning group calendars and the course calendar for publishers (of subscriptions)
   * and sets their state to "1" which indicates that the ressource is deleted.
   */
  private static void clearCalenderSubscriptions(ICourse course) {
    //set Publisher state to 1 (= ressource is deleted) for all calendars of the course
    CalendarManager calMan = CalendarManagerFactory.getInstance().getCalendarManager();
    NotificationsManager nfm = NotificationsManager.getInstance();
    List<BusinessGroup> learningGroups = course.getCourseEnvironment().getCourseGroupManager()
      .getAllLearningGroupsFromAllContexts();
    List<BusinessGroup> rightGroups = course.getCourseEnvironment().getCourseGroupManager()
    .getAllRightGroupsFromAllContexts();
    learningGroups.addAll(rightGroups);
    //all learning and right group calendars
    for (BusinessGroup bg : learningGroups) {
      KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(bg);
      SubscriptionProvider subProvider = new SubscriptionProviderImpl(calRenderWrapper);
      SubscriptionContext subsContext = subProvider.getSubscriptionContext();
      Publisher pub = nfm.getPublisher(subsContext);
      if (pub != null) {
        pub.setState(1); //int 0 is OK -> all other is not OK
      }
    }
    //the course calendar
    try {
      /**
       * TODO:gs 2010-01-26
       * OLAT-4947: if we do not have an repo entry we get an exception here.
       * This is normal in the case of courseimport and click canceling.
       */
      course.getCourseTitle();
      KalendarRenderWrapper courseCalendar = calMan.getCourseCalendar(course);
      SubscriptionProvider subProvider = new SubscriptionProviderImpl(courseCalendar, course);
      Publisher pub = nfm.getPublisher(subProvider.getSubscriptionContext());
      if (pub != null) {
        pub.setState(1);
      }
View Full Code Here

TOP

Related Classes of org.olat.commons.calendar.CalendarManager

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.