Search in sources :

Example 6 with ExecuteOn

use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.

the class OwnerResource method updateOwner.

/**
 * {@code PUT  /owners} : Updates an existing owner.
 *
 * @param ownerDTO the ownerDTO to update.
 * @return the {@link HttpResponse} with status {@code 200 (OK)} and with body the updated ownerDTO,
 * or with status {@code 400 (Bad Request)} if the ownerDTO is not valid,
 * or with status {@code 500 (Internal Server Error)} if the ownerDTO couldn't be updated.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@Put("/owners")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<OwnerDTO> updateOwner(@Body OwnerDTO ownerDTO) throws URISyntaxException {
    log.debug("REST request to update Owner : {}", ownerDTO);
    if (ownerDTO.getId() == null) {
        throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
    }
    OwnerDTO result = ownerService.save(ownerDTO);
    return HttpResponse.ok(result).headers(headers -> HeaderUtil.createEntityUpdateAlert(headers, applicationName, true, ENTITY_NAME, ownerDTO.getId().toString()));
}
Also used : BadRequestAlertException(com.packtpub.micronaut.web.rest.errors.BadRequestAlertException) OwnerDTO(com.packtpub.micronaut.service.dto.OwnerDTO) ContinueSpan(io.micronaut.tracing.annotation.ContinueSpan) ExecuteOn(io.micronaut.scheduling.annotation.ExecuteOn)

Example 7 with ExecuteOn

use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.

the class PetResource method updatePet.

/**
 * {@code PUT  /pets} : Updates an existing pet.
 *
 * @param petDTO the petDTO to update.
 * @return the {@link HttpResponse} with status {@code 200 (OK)} and with body the updated petDTO,
 * or with status {@code 400 (Bad Request)} if the petDTO is not valid,
 * or with status {@code 500 (Internal Server Error)} if the petDTO couldn't be updated.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@Put("/pets")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<PetDTO> updatePet(@Body PetDTO petDTO) throws URISyntaxException {
    log.debug("REST request to update Pet : {}", petDTO);
    if (petDTO.getId() == null) {
        throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
    }
    PetDTO result = petService.save(petDTO);
    return HttpResponse.ok(result).headers(headers -> HeaderUtil.createEntityUpdateAlert(headers, applicationName, true, ENTITY_NAME, petDTO.getId().toString()));
}
Also used : BadRequestAlertException(com.packtpub.micronaut.web.rest.errors.BadRequestAlertException) PetDTO(com.packtpub.micronaut.service.dto.PetDTO) ContinueSpan(io.micronaut.tracing.annotation.ContinueSpan) ExecuteOn(io.micronaut.scheduling.annotation.ExecuteOn)

Example 8 with ExecuteOn

use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.

the class PetResource method createPet.

/**
 * {@code POST  /pets} : Create a new pet.
 *
 * @param petDTO the petDTO to create.
 * @return the {@link HttpResponse} with status {@code 201 (Created)} and with body the new petDTO, or with status {@code 400 (Bad Request)} if the pet has already an ID.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@Post("/pets")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<PetDTO> createPet(@Body PetDTO petDTO) throws URISyntaxException {
    log.debug("REST request to save Pet : {}", petDTO);
    if (petDTO.getId() != null) {
        throw new BadRequestAlertException("A new pet cannot already have an ID", ENTITY_NAME, "idexists");
    }
    PetDTO result = petService.save(petDTO);
    URI location = new URI("/api/pets/" + result.getId());
    return HttpResponse.created(result).headers(headers -> {
        headers.location(location);
        HeaderUtil.createEntityCreationAlert(headers, applicationName, true, ENTITY_NAME, result.getId().toString());
    });
}
Also used : BadRequestAlertException(com.packtpub.micronaut.web.rest.errors.BadRequestAlertException) PetDTO(com.packtpub.micronaut.service.dto.PetDTO) URI(java.net.URI) ContinueSpan(io.micronaut.tracing.annotation.ContinueSpan) ExecuteOn(io.micronaut.scheduling.annotation.ExecuteOn)

Example 9 with ExecuteOn

use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.

the class PetTypeResource method createPetType.

/**
 * {@code POST  /pet-types} : Create a new petType.
 *
 * @param petTypeDTO the petTypeDTO to create.
 * @return the {@link HttpResponse} with status {@code 201 (Created)} and with body the new petTypeDTO, or with status {@code 400 (Bad Request)} if the petType has already an ID.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@Post("/pet-types")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<PetTypeDTO> createPetType(@Body PetTypeDTO petTypeDTO) throws URISyntaxException {
    log.debug("REST request to save PetType : {}", petTypeDTO);
    if (petTypeDTO.getId() != null) {
        throw new BadRequestAlertException("A new petType cannot already have an ID", ENTITY_NAME, "idexists");
    }
    PetTypeDTO result = petTypeService.save(petTypeDTO);
    URI location = new URI("/api/pet-types/" + result.getId());
    return HttpResponse.created(result).headers(headers -> {
        headers.location(location);
        HeaderUtil.createEntityCreationAlert(headers, applicationName, true, ENTITY_NAME, result.getId().toString());
    });
}
Also used : BadRequestAlertException(com.packtpub.micronaut.web.rest.errors.BadRequestAlertException) PetTypeDTO(com.packtpub.micronaut.service.dto.PetTypeDTO) URI(java.net.URI) ContinueSpan(io.micronaut.tracing.annotation.ContinueSpan) ExecuteOn(io.micronaut.scheduling.annotation.ExecuteOn)

Example 10 with ExecuteOn

use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.

the class VisitResource method createVisit.

/**
 * {@code POST  /visits} : Create a new visit.
 *
 * @param visitDTO the visitDTO to create.
 * @return the {@link HttpResponse} with status {@code 201 (Created)} and with body the new visitDTO, or with status {@code 400 (Bad Request)} if the visit has already an ID.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@Post("/visits")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<VisitDTO> createVisit(@Body VisitDTO visitDTO) throws URISyntaxException {
    log.debug("REST request to save Visit : {}", visitDTO);
    if (visitDTO.getId() != null) {
        throw new BadRequestAlertException("A new visit cannot already have an ID", ENTITY_NAME, "idexists");
    }
    VisitDTO result = visitService.save(visitDTO);
    URI location = new URI("/api/visits/" + result.getId());
    return HttpResponse.created(result).headers(headers -> {
        headers.location(location);
        HeaderUtil.createEntityCreationAlert(headers, applicationName, true, ENTITY_NAME, result.getId().toString());
    });
}
Also used : BadRequestAlertException(com.packtpub.micronaut.web.rest.errors.BadRequestAlertException) VisitDTO(com.packtpub.micronaut.service.dto.VisitDTO) URI(java.net.URI) ContinueSpan(io.micronaut.tracing.annotation.ContinueSpan) ExecuteOn(io.micronaut.scheduling.annotation.ExecuteOn)

Aggregations

ExecuteOn (io.micronaut.scheduling.annotation.ExecuteOn)21 BadRequestAlertException (com.packtpub.micronaut.web.rest.errors.BadRequestAlertException)14 ContinueSpan (io.micronaut.tracing.annotation.ContinueSpan)8 URI (java.net.URI)7 Execution (io.kestra.core.models.executions.Execution)5 Flow (io.kestra.core.models.flows.Flow)3 OwnerDTO (com.packtpub.micronaut.service.dto.OwnerDTO)2 PetDTO (com.packtpub.micronaut.service.dto.PetDTO)2 PetTypeDTO (com.packtpub.micronaut.service.dto.PetTypeDTO)2 SpecialtyDTO (com.packtpub.micronaut.service.dto.SpecialtyDTO)2 VetDTO (com.packtpub.micronaut.service.dto.VetDTO)2 VetReviewDTO (com.packtpub.micronaut.service.dto.VetReviewDTO)2 VisitDTO (com.packtpub.micronaut.service.dto.VisitDTO)2 CrudEvent (io.kestra.core.events.CrudEvent)1 InternalException (io.kestra.core.exceptions.InternalException)1 StreamedFile (io.micronaut.http.server.types.files.StreamedFile)1 Event (io.micronaut.http.sse.Event)1 InputStream (java.io.InputStream)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1