Exemplo n.º 1
0
  private void appendGroupCalendars(
      Identity identity,
      List<KalendarRenderWrapper> calendars,
      Map<CalendarKey, CalendarUserConfiguration> configMap) {
    // get group calendars
    if (calendarModule.isEnableGroupCalendar()) {
      SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, false);
      groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
      List<BusinessGroup> ownerGroups =
          businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
      addCalendars(ownerGroups, true, false, calendars, configMap);

      SearchBusinessGroupParams groupParams2 = new SearchBusinessGroupParams(identity, false, true);
      groupParams2.addTools(CollaborationTools.TOOL_CALENDAR);
      List<BusinessGroup> attendedGroups =
          businessGroupService.findBusinessGroups(groupParams2, null, 0, -1);
      attendedGroups.removeAll(ownerGroups);
      addCalendars(attendedGroups, false, true, calendars, configMap);
    }
  }
  /**
   * Perform a search for the given search value in the search result providers and clear any GUI
   * errors that might be on the page
   *
   * @param searchValue
   * @param ureq
   */
  private void doSearchGroups(String searchValue, UserRequest ureq) {
    if (StringHelper.containsNonWhitespace(searchValue)) {
      SearchBusinessGroupParams param1s = new SearchBusinessGroupParams();
      param1s.setNameOrDesc(searchValue);
      List<BusinessGroup> group1s = businessGroupService.findBusinessGroups(param1s, null, 0, -1);
      filterGroups(group1s);

      SearchBusinessGroupParams param2s = new SearchBusinessGroupParams();
      param2s.setCourseTitle(searchValue);
      List<BusinessGroup> group2s = businessGroupService.findBusinessGroups(param2s, null, 0, -1);
      filterGroups(group2s);

      List<BusinessGroup> groups = new ArrayList<BusinessGroup>(group1s.size() + group2s.size());
      groups.addAll(group1s);
      groups.addAll(group2s);

      List<Long> groupKeysWithRelations = PersistenceHelper.toKeys(groups);
      List<BGRepositoryEntryRelation> resources =
          businessGroupService.findRelationToRepositoryEntries(groupKeysWithRelations, 0, -1);

      List<GroupWrapper> groupWrappers = new ArrayList<GroupWrapper>();
      for (BusinessGroup group : groups) {
        StringBuilder sb = new StringBuilder();
        for (BGRepositoryEntryRelation resource : resources) {
          if (resource.getGroupKey().equals(group.getKey())) {
            if (sb.length() > 0) sb.append(", ");
            sb.append(resource.getRepositoryEntryDisplayName());
          }
        }

        GroupWrapper wrapper = new GroupWrapper(group, sb.toString());
        wrapper.setTutor(createSelection("tutor_" + group.getKey()));
        wrapper.setParticipant(createSelection("participant_" + group.getKey()));
        groupWrappers.add(wrapper);
      }

      table.reset();
      tableDataModel.setObjects(groupWrappers);
      errorComp.clearError();
    }
  }
 protected boolean updateMarkedGroups() {
   SearchBusinessGroupParams params = new SearchBusinessGroupParams();
   params.setMarked(Boolean.TRUE);
   params.setAttendee(true);
   params.setOwner(true);
   params.setWaiting(true);
   params.setIdentity(getIdentity());
   return !updateTableModel(params, true).isEmpty();
 }
Exemplo n.º 4
0
  @Override
  public List<CalendarFileInfos> getListOfCalendarsFiles(Identity identity) {
    List<CalendarFileInfos> aggregatedFiles = new ArrayList<>();

    Map<CalendarKey, CalendarUserConfiguration> configMap =
        calendarManager.getCalendarUserConfigurationsMap(identity);

    // personal calendar
    CalendarKey personalCalendarKey =
        new CalendarKey(identity.getName(), CalendarManager.TYPE_USER);
    CalendarUserConfiguration personalCalendarConfig = configMap.get(personalCalendarKey);
    if (calendarModule.isEnablePersonalCalendar()
        && (personalCalendarConfig == null || personalCalendarConfig.isInAggregatedFeed())) {
      File iCalFile =
          calendarManager.getCalendarICalFile(CalendarManager.TYPE_USER, identity.getName());
      if (iCalFile != null) {
        aggregatedFiles.add(
            new CalendarFileInfos(identity.getName(), CalendarManager.TYPE_USER, iCalFile));
      }

      // reload every hour
      List<CalendarFileInfos> importedCalendars =
          importCalendarManager.getImportedCalendarInfosForIdentity(identity, true);
      aggregatedFiles.addAll(importedCalendars);
    }

    // group calendars
    if (calendarModule.isEnableGroupCalendar()) {
      SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, true);
      groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
      List<BusinessGroup> groups =
          businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
      for (BusinessGroup group : groups) {
        String calendarId = group.getKey().toString();
        CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_GROUP);
        CalendarUserConfiguration calendarConfig = configMap.get(key);
        if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
          File iCalFile =
              calendarManager.getCalendarICalFile(CalendarManager.TYPE_GROUP, calendarId);
          if (iCalFile != null) {
            aggregatedFiles.add(
                new CalendarFileInfos(calendarId, CalendarManager.TYPE_GROUP, iCalFile));
          }
        }
      }
    }

    if (calendarModule.isEnableCourseElementCalendar()
        || calendarModule.isEnableCourseToolCalendar()) {
      List<Object[]> resources = getCourses(identity);
      for (Object[] resource : resources) {
        RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
        String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
        CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_COURSE);
        CalendarUserConfiguration calendarConfig = configMap.get(key);
        if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
          File iCalFile =
              calendarManager.getCalendarICalFile(CalendarManager.TYPE_COURSE, calendarId);
          if (iCalFile != null) {
            aggregatedFiles.add(
                new CalendarFileInfos(calendarId, CalendarManager.TYPE_COURSE, iCalFile));
          }
        }
      }
    }

    return aggregatedFiles;
  }