Пример #1
0
 @Transactional
 public List<Review> saveReviews(String userLogin, String id, List<Review> reviews) {
   Movie movie = movieRepository.findById(id);
   User user = userRepository.findByLogin(userLogin);
   Review review = template.save(reviews.get(0));
   user.addReview(review);
   review.reviewed(movie);
   template.save(review);
   template.save(user);
   ;
   return new ArrayList<Review>() {
     {
       add(review);
     }
   };
 }
Пример #2
0
 @Transactional
 public List<Director> addCrew(String id, List<Director> crew) throws Exception {
   List<Director> savedDirectors = new ArrayList<>();
   for (Director director : crew) {
     director.setId("" + new Random().nextInt(Integer.MAX_VALUE));
     template.save(director);
     Movie movie = movieRepository.findById(id);
     LOG.info("Movie {} = {} ", id, movie);
     director.directed(movie);
     savedDirectors.add(directorRepository.save(director));
   }
   return savedDirectors;
 }
Пример #3
0
  @Transactional
  public List<Actor> addCast(String id, List<Actor> cast) throws Exception {
    List<Actor> savedActors = new ArrayList<>();
    Movie movie = movieRepository.findById(id);
    LOG.info("Movie {} = {} ", id, movie);

    for (Actor actor : cast) {
      Actor repoActor = actorRepository.findByName(actor.getName());
      String role = cast.get(0).getRoles().iterator().next().getName();
      if (repoActor == null) {
        actor.setId("" + new Random().nextInt(Integer.MAX_VALUE));
        actor.setRoles(new HashSet<>());
        template.save(actor);
        actor.playedIn(movie, role);
        savedActors.add(actorRepository.save(actor));
      } else {
        repoActor.playedIn(movie, role);
        Actor a = actorRepository.save(repoActor);
        LOG.info("actor saved is {}", a, a.getRoles());
        savedActors.add(a);
      }
    }
    return savedActors;
  }
Пример #4
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;
  }