コード例 #1
0
  /**
   * Suppression d'une talk
   *
   * @param event
   * @return
   */
  @Override
  public DeletedEvent<Talk> deleteTalk(Talk event) {
    Preconditions.checkNotNull(event);
    Preconditions.checkNotNull(event.getId(), "talk is required to delete talk");

    // Recherche de l'element par l'id
    Talk talk = talkRepository.findOne(event.getId());
    DeletedEvent<Talk> eventReturned = null;

    if (talk != null) {
      talkRepository.delete(talk);
      eventReturned = new DeletedEvent(true, new TalkDetail(talk));
      LOG.debug(
          String.format(
              "Suppression du talk ayant id=[%s] UUID:%s",
              event.getId(), eventReturned.getKey().toString()));
    } else {
      eventReturned = new DeletedEvent(false, null);
      LOG.debug(
          String.format(
              "Le talk ayant id=[%s] n'existe pas UUID:%s",
              event.getId(), eventReturned.getKey().toString()));
    }
    return eventReturned;
  }
コード例 #2
0
  /**
   * Recuperation d'un talk vi a son ID
   *
   * @param event
   * @return
   */
  @Override
  public Talk getTalk(Talk event) {
    Preconditions.checkNotNull(event);
    Preconditions.checkNotNull(event.getId(), "id is required for search talk");

    // Recherche de l'element par l'id
    return talkRepository.findOne(event.getId());
  }
コード例 #3
0
 /**
  * Permet de convertir la donnée reçue
  *
  * @param talk
  * @return
  */
 private Talk transformAndSaveTalkDetailToTalk(Talk talk, boolean creation) {
   // Si pas en creation on regarde si enreg existe
   if (!creation) {
     Talk talkToPersist = talkRepository.findOne(talk.getId());
     if (talkToPersist == null) {
       return null;
     }
     talkToPersist.setLevel(talk.getLevel());
     talkToPersist.setNbpeoplemax(talk.getNbpeoplemax());
     talkToPersist.setPlace(talk.getPlace());
     talkToPersist.setDescription(talk.getDescription());
     talkToPersist.setName(talk.getName());
     return talkToPersist;
   } else {
     // On enregistre
     return talkRepository.save(talk);
   }
 }
コード例 #4
0
 /**
  * Recuperation de la liste des talks
  *
  * @return
  */
 @Override
 public List<Talk> getAllTalk() {
   return talkRepository.findAll(sortByNameAsc());
 }