예제 #1
0
 @Transactional
 public boolean activateCommunicationsInstantaneously(String day, List<String> communicationIds) {
   List<String> ids = arrowService.pushActivation(communicationIds);
   if (CollectionUtils.isEmpty(ids)) {
     return false;
   }
   return true;
 }
예제 #2
0
  @Transactional
  public DayGrid getDayGridForDay(
      Date date, Long siteId, Long pageId, String profile, User user, boolean future)
      throws ExecutionException { // , Map<Long,Set<AnimationDTO>> validAnimationsByRubriques) {
    logger.debug(
        "getDayGridForDay for date {}, site {}, page {} and profile {}",
        date,
        siteId,
        pageId,
        profile);
    Day day = periodService.getDay(date);

    List<CommunicationGroup> communicationGroups = arrowService.getCommunicationGroups();

    // recuperer liste des emplacements avec rubriques attaches pour le profile
    // commencer par chercher la liste des rubriques, et voir si y a des rubriqueLogging pour ce
    // jour et ce profil
    // si la liste est vide créer les rubriqueLogging avec les emplaceemnts par défaut (le test pour
    // création est fait dans le service)
    LinkedHashSet<RubriqueLogging> emplacementsRubriqueForThisDay =
        rubriqueLoggingService.getRubriqueLoggingForSiteProfileAndDay(
            siteId, pageId, profile, day.getId());

    LinkedHashSet<EmplacementDTO> blocs = new LinkedHashSet<>();
    for (Iterator<RubriqueLogging> iterator = emplacementsRubriqueForThisDay.iterator();
        iterator.hasNext(); ) {
      EmplacementDTO emplacementDTO = new EmplacementDTO();

      RubriqueLogging rubriqueLogging = iterator.next();
      emplacementDTO.setId(rubriqueLogging.getIdEmplacement());
      emplacementDTO.setName(rubriqueLogging.getEmplacement());
      emplacementDTO.setPosition(rubriqueLogging.getPosition());
      LinkedHashSet<RubriqueDTO> rubriquesDTO = new LinkedHashSet<>();
      Rubrique rubrique = neo4jOperations.fetch(rubriqueLogging.getRubrique());

      // NEW CODE
      LinkedHashSet<CommunicationQueryResult> communications =
          dayRepository.findCommunicationForGridDayAndRubrique(
              rubrique.getId(), day.getId(), profile, !future);
      LinkedHashMap<String, LinkedHashSet<CommunicationDTO>> tempCommunicationGroup =
          new LinkedHashMap<>();
      for (Iterator<CommunicationQueryResult> communicationQueryResultIterator =
              communications.iterator();
          communicationQueryResultIterator.hasNext(); ) {
        CommunicationQueryResult communicationQueryResult = communicationQueryResultIterator.next();
        CommunicationDTO communicationDTO = communicationDTOAdapter.adapt(communicationQueryResult);
        LinkedHashSet<CommunicationDTO> communicationDTOListForThisGroup =
            tempCommunicationGroup.get(communicationDTO.getCommunicationGroupId());
        if (communicationDTOListForThisGroup == null) {
          communicationDTOListForThisGroup = new LinkedHashSet<>();
        }
        communicationDTOListForThisGroup.add(communicationDTO);
        tempCommunicationGroup.put(
            communicationDTO.getCommunicationGroupId(), communicationDTOListForThisGroup);
      }

      LinkedHashSet<CommunicationGroupDTO> communicationGroupDTOs = new LinkedHashSet<>();

      for (Iterator<CommunicationGroup> communicationGroupsIterator =
              communicationGroups.iterator();
          communicationGroupsIterator.hasNext(); ) {
        CommunicationGroup communicationGroup = communicationGroupsIterator.next();
        LinkedHashSet<CommunicationDTO> communicationDTOListForThisGroup =
            tempCommunicationGroup.get(communicationGroup.getId());
        if (communicationDTOListForThisGroup == null) {
          communicationDTOListForThisGroup = new LinkedHashSet<>();
        }
        communicationGroupDTOs.add(
            new CommunicationGroupDTO(
                communicationGroup.getId(),
                communicationGroup.getLabel(),
                communicationDTOListForThisGroup));
      }

      // END NEW CODE

      /*Set<AnimationDTO> animations = validAnimationsByRubriques.get(rubrique.getId());
      // rubrique.getAnimations();
      Set<AnimationDTO> animationsDTO = new LinkedHashSet<>();
      for (Iterator<AnimationDTO> animationIterator = animations.iterator(); animationIterator.hasNext(); ) {
          AnimationDTO animation = animationIterator.next();
          //vérifier si l'animation est valide ce jour là
          Calendar endDateCalendar = GregorianCalendar.getInstance();
          endDateCalendar.setTime( animation.getDateFin());
          endDateCalendar.add(GregorianCalendar.DAY_OF_YEAR, 1);

          Interval interval = new Interval( animation.getDateDebut().getTime(), endDateCalendar.getTime().getTime() );
          boolean intervalContainsThisDay = interval.contains( date.getTime() );
          if(intervalContainsThisDay){
              //mettre à jour les créas pour ce jour là
              animationsDTO.add(animation);
          }
      }*/
      RubriqueDTO rubriqueDTO =
          new RubriqueDTO(
              rubrique.getId(),
              rubrique.getNom(),
              rubrique.getManagedByCooper(),
              communicationGroupDTOs);
      rubriquesDTO.add(rubriqueDTO);
      emplacementDTO.setRubrique(rubriquesDTO);
      blocs.add(emplacementDTO);
    }
    DayGrid dayGrid = new DayGrid(day.getId(), day.getName(), blocs);

    String formattedDate = new SimpleDateFormat(Day.dateFormat).format(date);

    DayGridLock lockForDayAndProfile =
        gridLockManager.getLockStatusForDayAndProfile(siteId, pageId, formattedDate, profile, user);
    dayGrid.setDayGridLockDTO(new DayGridLockDTO(lockForDayAndProfile, user));

    return dayGrid;
  }