コード例 #1
0
  private void reload() {
    UltimateFestivalOrganizerSoap ufo = UFOService.getInstance();

    venues = ufo.getAllVenues().getVenue();
    artists = ufo.getAllButDeletedArtists().getArtist();

    // Performances
    performances.clear();

    if (performancesSessionBean.getSelectedDate() == null) {
      return;
    }

    // fill with new
    for (Venue v : venues) {
      performances.put(v.getId(), new HashMap<>());

      for (int hour = 14; hour <= 23; ++hour) {
        Performance p = new Performance();
        p.setVenue(v);

        Calendar c = new GregorianCalendar();
        c.setTime(performancesSessionBean.getSelectedDate());
        c.add(Calendar.HOUR_OF_DAY, hour);
        p.setDateTime(dateToGregorian(c.getTime()));

        Artist a = new Artist();
        a.setId(0);
        p.setArtist(a);

        performances.get(v.getId()).put(hour, p);
      }
    }

    // fill with existing
    List<Performance> allPerformances =
        ufo.getPerformancesByDate(dateToGregorian(performancesSessionBean.getSelectedDate()))
            .getPerformance();
    for (Performance p : allPerformances) {
      int venueId = p.getVenue().getId();
      int hour = p.getDateTime().getHour();

      performances.get(venueId).put(hour, p);
    }
  }
コード例 #2
0
  public void onSelectedArtistChange(int viewId, int time) {
    // check login
    if (!userBean.getLoggedIn()) {
      return;
    }

    // execute action
    Performance p = performances.get(viewId).get(time);

    UltimateFestivalOrganizerSoap ufo = UFOService.getInstance();

    if (p.getId() == 0 && p.getArtist().getId() == 0) {
      return;
    }

    // send to server
    boolean success = true;
    if (p.getId() == 0 && p.getArtist().getId() != 0) {
      success = ufo.addPerformance(p);
    } else if (p.getId() != 0 && p.getArtist().getId() == 0) {
      ufo.deletePerformance(p);
      success = true;
    } else if (p.getId() != 0 && p.getArtist().getId() != 0) {
      success = ufo.updatePerformance(p);
    }

    // message
    FacesContext facesContext = FacesContext.getCurrentInstance();
    FacesMessage facesMessage;
    if (success) {
      facesMessage =
          new FacesMessage(FacesMessage.SEVERITY_INFO, "Saved", "Data was saved on the server.");
    } else {
      facesMessage =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR,
              "Error",
              "The selected artist was invalid. The item will be reset.");
      reload();
    }
    facesContext.addMessage(null, facesMessage);
  }