Search in sources :

Example 1 with Path

use of br.com.caelum.vraptor.Path in project agiletickets by caelum.

the class EspetaculosController method adiciona.

@Post
@Path("/espetaculos")
public void adiciona(Espetaculo espetaculo) {
    // se nao tiver descricao, avisa o usuario
    if (Strings.isNullOrEmpty(espetaculo.getNome())) {
        validator.add(new ValidationMessage("Nome do espetáculo não pode estar em branco", ""));
    }
    if (Strings.isNullOrEmpty(espetaculo.getDescricao())) {
        validator.add(new ValidationMessage("Descrição do espetáculo não pode estar em branco", ""));
    }
    validator.onErrorRedirectTo(this).lista();
    agenda.cadastra(espetaculo);
    result.redirectTo(this).lista();
}
Also used : ValidationMessage(br.com.caelum.vraptor.validator.ValidationMessage) Path(br.com.caelum.vraptor.Path) Post(br.com.caelum.vraptor.Post)

Example 2 with Path

use of br.com.caelum.vraptor.Path in project agiletickets by caelum.

the class EspetaculosController method cadastraSessoes.

@Post
@Path("/espetaculo/{espetaculoId}/sessoes")
public void cadastraSessoes(Long espetaculoId, LocalDate inicio, LocalDate fim, LocalTime horario, Periodicidade periodicidade) {
    Espetaculo espetaculo = carregaEspetaculo(espetaculoId);
    // aqui faz a magica!
    // cria sessoes baseado no periodo de inicio e fim passados pelo usuario
    List<Sessao> sessoes = espetaculo.criaSessoes(inicio, fim, horario, periodicidade);
    agenda.agende(sessoes);
    result.include("message", sessoes.size() + " sessões criadas com sucesso");
    result.redirectTo(this).lista();
}
Also used : Sessao(br.com.caelum.agiletickets.models.Sessao) Espetaculo(br.com.caelum.agiletickets.models.Espetaculo) Path(br.com.caelum.vraptor.Path) Post(br.com.caelum.vraptor.Post)

Example 3 with Path

use of br.com.caelum.vraptor.Path in project restfulie-java by caelum.

the class ItemsController method list.

@Get
@Path("/items")
public void list() {
    ConfigurableHypermediaResource resource = restfulie.enhance(database.lista());
    resource.relation("basket").uses(BasketsController.class).create(null);
    result.use(representation()).from(resource, "items").serialize();
}
Also used : ConfigurableHypermediaResource(br.com.caelum.vraptor.restfulie.hypermedia.ConfigurableHypermediaResource) Path(br.com.caelum.vraptor.Path) Get(br.com.caelum.vraptor.Get)

Example 4 with Path

use of br.com.caelum.vraptor.Path in project restfulie-java by caelum.

the class OrderingController method get.

@Get
@Path("/orders/{order.id}")
public void get(Order order) {
    order = database.getOrder(order.getId());
    if (order != null) {
        Serializer serializer = result.use(representation()).from(order);
        serializer.include("items").include("location");
        serializer.include("payment").serialize();
    } else {
        status.notFound();
    }
}
Also used : Serializer(br.com.caelum.vraptor.serialization.Serializer) Path(br.com.caelum.vraptor.Path) Get(br.com.caelum.vraptor.Get)

Example 5 with Path

use of br.com.caelum.vraptor.Path in project restfulie-java by caelum.

the class OrderingController method add.

@Post
@Path("/orders")
@Consumes
public void add(Order order) {
    int id = 0;
    for (Item i : order.getItems()) {
        i.use(order, ++id);
    }
    database.save(order);
    routes.uriFor(OrderingController.class).get(order);
    status.created(routes.getUri());
}
Also used : Item(br.com.caelum.vraptor.restbucks.Item) Path(br.com.caelum.vraptor.Path) Consumes(br.com.caelum.vraptor.Consumes) Post(br.com.caelum.vraptor.Post)

Aggregations

Path (br.com.caelum.vraptor.Path)10 Get (br.com.caelum.vraptor.Get)5 Post (br.com.caelum.vraptor.Post)5 Sessao (br.com.caelum.agiletickets.models.Sessao)3 Espetaculo (br.com.caelum.agiletickets.models.Espetaculo)2 ValidationMessage (br.com.caelum.vraptor.validator.ValidationMessage)2 Item (br.com.caelum.example.model.Item)1 Consumes (br.com.caelum.vraptor.Consumes)1 Item (br.com.caelum.vraptor.restbucks.Item)1 ConfigurableHypermediaResource (br.com.caelum.vraptor.restfulie.hypermedia.ConfigurableHypermediaResource)1 Serializer (br.com.caelum.vraptor.serialization.Serializer)1 Validations (br.com.caelum.vraptor.validator.Validations)1 BigDecimal (java.math.BigDecimal)1