@Transactional public Set<DayGrid> getGridForPageProfilePeriod( Long siteId, Long pageId, Date dateDebut, Date dateFin, String profile, User user) throws ExecutionException { logger.debug( "###################getGridForPageProfilePeriod for site :{} , page :{} , dateDebut {}, datefin {}, profile {}", siteId, pageId, dateDebut, dateFin, profile); Set<DayGrid> grid = new LinkedHashSet<>(); Calendar startDateCalendar = GregorianCalendar.getInstance(); startDateCalendar.setTime(dateDebut); Calendar endDateCalendar = GregorianCalendar.getInstance(); endDateCalendar.setTime(dateFin); endDateCalendar.add(GregorianCalendar.DAY_OF_YEAR, 1); Date today = new Date(); while (startDateCalendar.before(endDateCalendar)) { logger.debug("###################startDateCalendar {}", startDateCalendar); DayGrid dayGrid = getDayGridForDay( startDateCalendar.getTime(), siteId, pageId, profile, user, (today.getTime() < startDateCalendar.getTimeInMillis())); // , validAnimationsByRubriques); grid.add(dayGrid); startDateCalendar.add(GregorianCalendar.DAY_OF_YEAR, 1); } return grid; }
@Transactional public DayGrid updateDayGid(DayGrid dayGrid, String profile) throws ParseException { Set<EmplacementDTO> blocs = dayGrid.getBlocs(); if (blocs != null) { for (Iterator<EmplacementDTO> iterator = blocs.iterator(); iterator.hasNext(); ) { EmplacementDTO emplacementDTO = iterator.next(); Set<RubriqueDTO> rubriqueDTOSet = emplacementDTO.getRubrique(); if (rubriqueDTOSet != null) { for (Iterator<RubriqueDTO> rubriqueDTOIterator = rubriqueDTOSet.iterator(); rubriqueDTOIterator.hasNext(); ) { RubriqueDTO rubriqueDTO = rubriqueDTOIterator.next(); rubriqueLoggingService.updateEmplacementRubriqueForDay( emplacementDTO.getId(), emplacementDTO.getName(), emplacementDTO.getPosition(), rubriqueDTO.getId(), profile, dayGrid.getId()); LinkedHashSet<CommunicationGroupDTO> communicationGroups = rubriqueDTO.getCommunicationGroups(); for (Iterator<CommunicationGroupDTO> communicationGroupDTOIterator = communicationGroups.iterator(); communicationGroupDTOIterator.hasNext(); ) { CommunicationGroupDTO communicationGroupDTO = communicationGroupDTOIterator.next(); LinkedHashSet<CommunicationDTO> communicationDTOs = communicationGroupDTO.getCommunications(); if (communicationDTOs != null && communicationDTOs.size() > 0) { List<String> communicationIdsToDeactivate = Lists.newArrayList(); List<String> communicationIdsToActivate = Lists.newArrayList(); for (Iterator<CommunicationDTO> communicationDTOIterator = communicationDTOs.iterator(); communicationDTOIterator.hasNext(); ) { CommunicationDTO communicationDTO = communicationDTOIterator.next(); if (isToday(dayGrid.getDate())) { if (communicationDTO.isDeactivated() && !communicationLoggingService.isDeactivatedCommunicationLogging( communicationDTO.getCommunicationLoggingId())) { communicationIdsToDeactivate.add(communicationDTO.getIdArrowCommunication()); } if (!communicationDTO.isDeactivated() && communicationLoggingService.isDeactivatedCommunicationLogging( communicationDTO.getCommunicationLoggingId())) { communicationIdsToActivate.add(communicationDTO.getIdArrowCommunication()); } } // update communicationLogging communicationLoggingService.updateCommunicationLoggingForCommunicationAndDay( communicationDTO.getIdCommunication(), dayGrid.getId(), communicationDTO.getPriority(), communicationGroupDTO.getId(), communicationGroupDTO.getLabel(), communicationDTO.getNbAffichageMax(), communicationDTO.getNbJourAffichageMax(), communicationDTO.getNbClicMax(), communicationDTO.getNbJourClicMax(), communicationDTO.isDeactivated()); } if (isToday(dayGrid.getDate())) { if (CollectionUtils.isNotEmpty(communicationIdsToDeactivate)) { deactivateCommunicationsInstantaneously( dayGrid.getDate(), communicationIdsToDeactivate); } if (CollectionUtils.isNotEmpty(communicationIdsToActivate)) { activateCommunicationsInstantaneously( dayGrid.getDate(), communicationIdsToActivate); } } } } } } } } return dayGrid; }