Ejemplo n.º 1
0
  @POST
  @UnitOfWork
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Path("/{name}/remove")
  public Response deleteMusic(@PathParam("name") String name, @FormParam("number") IntParam number)
      throws URISyntaxException {

    if (number == null || number.get() < 1) {
      Response.status(Response.Status.BAD_REQUEST).build();
    }
    final List<PlayList> playLists = playListDAO.findByName(name);
    if (!playLists.isEmpty()) {
      Response.status(Response.Status.NOT_FOUND).build();
    }

    List<PlayListDetail> list = playListDetailDAO.findByName(name);
    int num = 1;
    for (PlayListDetail d : list) {
      if (number.get().equals(d.getNumber())) {
        playListDetailDAO.deleteByPk(d.getPlaylist_name(), d.getNumber());
      } else {
        d.setNumber(num);
        playListDetailDAO.create(d);
        num++;
      }
    }

    return Response.status(Response.Status.NO_CONTENT).build();
  }
Ejemplo n.º 2
0
 @GET
 @Timed
 @Path("/index")
 public Person getPersonWithIndex(
     @Min(0) @QueryParam("ind") IntParam index, @PathParam("name") String name) {
   return getPersonList(name).get(index.get());
 }
Ejemplo n.º 3
0
  @POST
  @UnitOfWork
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Path("/{name}/add")
  public Response addMusic(
      @PathParam("name") String name,
      @FormParam("music_id") IntParam musicId,
      @FormParam("number") IntParam number)
      throws URISyntaxException {

    if (musicId == null || number == null || number.get() < 1) {
      Response.status(Response.Status.BAD_REQUEST).build();
    }
    final List<PlayList> playLists = playListDAO.findByName(name);
    if (!playLists.isEmpty()) {
      Response.status(Response.Status.NOT_FOUND).build();
    }
    Optional<Music> m = musicDAO.findById(musicId.get());
    if (m.get() == null) {
      Response.status(Response.Status.BAD_REQUEST).build();
    }
    List<PlayListDetail> list = playListDetailDAO.findByName(name);
    int num = 1;
    for (PlayListDetail d : list) {
      if (number.get().equals(num)) {
        PlayListDetail nd = new PlayListDetail();
        nd.setMusic_id(musicId.get());
        nd.setPlaylist_name(name);
        nd.setNumber(num);
        playListDetailDAO.create(nd);
        num++;
      }
      d.setNumber(num);
      playListDetailDAO.create(d);
      num++;
    }

    return Response.status(Response.Status.NO_CONTENT).build();
  }
Ejemplo n.º 4
0
 @GET
 @Path("{id}/revisions/{revisionId}")
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public Orchestration getRevision(
     @PathParam("id") LongParam id, @PathParam("revisionId") IntParam revisionId) {
   Orchestration orchestration = dao.getRevision(id.get(), revisionId.get());
   // eagerly load the related objects
   for (OutboundEndpoint outboundEndpoint : orchestration.getOutboundEndpoints()) {
     Map<String, String> properties = outboundEndpoint.getProperties();
     for (Map.Entry<String, String> property : properties.entrySet()) {
       property.getValue();
     }
   }
   return orchestration;
 }