Search in sources :

Example 1 with DataResponse

use of org.breedinginsight.api.model.v1.response.DataResponse in project bi-api by Breeding-Insight.

the class MetadataFilterIntegrationTest method getDataResponseMock.

public Response<DataResponse<User>> getDataResponseMock() {
    User mockedUser = User.builder().name("Test User").email("test@user.com").id(UUID.randomUUID()).orcid("testorcid").build();
    List<User> users = new ArrayList<>();
    users.add(mockedUser);
    users.add(mockedUser);
    DataResponse<User> dataResponse = new DataResponse<User>().setData(users);
    Response mockedResponse = new Response().setResult(dataResponse);
    return mockedResponse;
}
Also used : Response(org.breedinginsight.api.model.v1.response.Response) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) HttpResponse(io.micronaut.http.HttpResponse) User(org.breedinginsight.model.User) ArrayList(java.util.ArrayList)

Example 2 with DataResponse

use of org.breedinginsight.api.model.v1.response.DataResponse in project bi-api by Breeding-Insight.

the class ProgramController method getProgramObservationLevels.

@Get("/programs/{programId}/observation-levels")
@Produces(MediaType.APPLICATION_JSON)
@ProgramSecured(roleGroups = { ProgramSecuredRoleGroup.ALL })
public HttpResponse<Response<DataResponse<ProgramObservationLevel>>> getProgramObservationLevels(@PathVariable UUID programId) throws DoesNotExistException {
    List<ProgramObservationLevel> programObservationLevels = programObservationLevelService.getByProgramId(programId);
    List<Status> metadataStatus = new ArrayList<>();
    metadataStatus.add(new Status(StatusCode.INFO, "Successful Query"));
    Pagination pagination = new Pagination(programObservationLevels.size(), 1, 1, 0);
    Metadata metadata = new Metadata(pagination, metadataStatus);
    Response<DataResponse<ProgramObservationLevel>> response = new Response(metadata, new DataResponse<>(programObservationLevels));
    return HttpResponse.ok(response);
}
Also used : HttpStatus(io.micronaut.http.HttpStatus) Status(org.breedinginsight.api.model.v1.response.metadata.Status) Response(org.breedinginsight.api.model.v1.response.Response) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) HttpResponse(io.micronaut.http.HttpResponse) Pagination(org.breedinginsight.api.model.v1.response.metadata.Pagination) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) ArrayList(java.util.ArrayList) Metadata(org.breedinginsight.api.model.v1.response.metadata.Metadata) AddMetadata(org.breedinginsight.api.v1.controller.metadata.AddMetadata)

Example 3 with DataResponse

use of org.breedinginsight.api.model.v1.response.DataResponse in project bi-api by Breeding-Insight.

the class RoleController method getSystemRoles.

@Get("/roles")
@Produces(MediaType.APPLICATION_JSON)
@Secured(SecurityRule.IS_AUTHENTICATED)
public HttpResponse<Response<DataResponse<SystemRole>>> getSystemRoles() {
    List<SystemRole> roles = systemRoleService.getAll();
    List<Status> metadataStatus = new ArrayList<>();
    metadataStatus.add(new Status(StatusCode.INFO, "Successful Query"));
    // TODO: Put in the actual page size
    Pagination pagination = new Pagination(roles.size(), 1, 1, 0);
    Metadata metadata = new Metadata(pagination, metadataStatus);
    Response<DataResponse<SystemRole>> response = new Response(metadata, new DataResponse<>(roles));
    return HttpResponse.ok(response);
}
Also used : Status(org.breedinginsight.api.model.v1.response.metadata.Status) Response(org.breedinginsight.api.model.v1.response.Response) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) HttpResponse(io.micronaut.http.HttpResponse) Pagination(org.breedinginsight.api.model.v1.response.metadata.Pagination) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) SystemRole(org.breedinginsight.model.SystemRole) ArrayList(java.util.ArrayList) Metadata(org.breedinginsight.api.model.v1.response.metadata.Metadata) AddMetadata(org.breedinginsight.api.v1.controller.metadata.AddMetadata) Produces(io.micronaut.http.annotation.Produces) Secured(io.micronaut.security.annotation.Secured) Get(io.micronaut.http.annotation.Get)

Example 4 with DataResponse

use of org.breedinginsight.api.model.v1.response.DataResponse in project bi-api by Breeding-Insight.

the class RoleController method getRoles.

@Get("programs/roles")
@Produces(MediaType.APPLICATION_JSON)
@Secured(SecurityRule.IS_AUTHENTICATED)
public HttpResponse<Response<DataResponse<Role>>> getRoles() {
    List<Role> roles = roleService.getAll();
    List<Status> metadataStatus = new ArrayList<>();
    metadataStatus.add(new Status(StatusCode.INFO, "Successful Query"));
    // TODO: Put in the actual page size
    Pagination pagination = new Pagination(roles.size(), 1, 1, 0);
    Metadata metadata = new Metadata(pagination, metadataStatus);
    Response<DataResponse<Role>> response = new Response(metadata, new DataResponse<>(roles));
    return HttpResponse.ok(response);
}
Also used : Role(org.breedinginsight.model.Role) SystemRole(org.breedinginsight.model.SystemRole) Status(org.breedinginsight.api.model.v1.response.metadata.Status) Response(org.breedinginsight.api.model.v1.response.Response) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) HttpResponse(io.micronaut.http.HttpResponse) Pagination(org.breedinginsight.api.model.v1.response.metadata.Pagination) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) ArrayList(java.util.ArrayList) Metadata(org.breedinginsight.api.model.v1.response.metadata.Metadata) AddMetadata(org.breedinginsight.api.v1.controller.metadata.AddMetadata) Produces(io.micronaut.http.annotation.Produces) Secured(io.micronaut.security.annotation.Secured) Get(io.micronaut.http.annotation.Get)

Example 5 with DataResponse

use of org.breedinginsight.api.model.v1.response.DataResponse in project bi-api by Breeding-Insight.

the class SpeciesController method getSpecies.

@Get("/species")
@Produces(MediaType.APPLICATION_JSON)
@Secured(SecurityRule.IS_AUTHENTICATED)
public HttpResponse<Response<DataResponse<Species>>> getSpecies() {
    List<Species> species = speciesService.getAll();
    List<Status> metadataStatus = new ArrayList<>();
    metadataStatus.add(new Status(StatusCode.INFO, "Successful Query"));
    // TODO: Put in the actual page size
    Pagination pagination = new Pagination(species.size(), 1, 1, 0);
    Metadata metadata = new Metadata(pagination, metadataStatus);
    Response response = new Response(metadata, new DataResponse<>(species));
    return HttpResponse.ok(response);
}
Also used : Status(org.breedinginsight.api.model.v1.response.metadata.Status) Response(org.breedinginsight.api.model.v1.response.Response) DataResponse(org.breedinginsight.api.model.v1.response.DataResponse) HttpResponse(io.micronaut.http.HttpResponse) Pagination(org.breedinginsight.api.model.v1.response.metadata.Pagination) ArrayList(java.util.ArrayList) Metadata(org.breedinginsight.api.model.v1.response.metadata.Metadata) AddMetadata(org.breedinginsight.api.v1.controller.metadata.AddMetadata) Species(org.breedinginsight.model.Species) Produces(io.micronaut.http.annotation.Produces) Secured(io.micronaut.security.annotation.Secured) Get(io.micronaut.http.annotation.Get)

Aggregations

DataResponse (org.breedinginsight.api.model.v1.response.DataResponse)17 Response (org.breedinginsight.api.model.v1.response.Response)17 HttpResponse (io.micronaut.http.HttpResponse)16 ArrayList (java.util.ArrayList)16 Pagination (org.breedinginsight.api.model.v1.response.metadata.Pagination)16 Metadata (org.breedinginsight.api.model.v1.response.metadata.Metadata)14 Status (org.breedinginsight.api.model.v1.response.metadata.Status)14 AddMetadata (org.breedinginsight.api.v1.controller.metadata.AddMetadata)13 Secured (io.micronaut.security.annotation.Secured)9 Get (io.micronaut.http.annotation.Get)7 Produces (io.micronaut.http.annotation.Produces)7 HttpStatus (io.micronaut.http.HttpStatus)6 DoesNotExistException (org.breedinginsight.services.exceptions.DoesNotExistException)3 AuthenticatedUser (org.breedinginsight.api.auth.AuthenticatedUser)2 ProgramSecured (org.breedinginsight.api.auth.ProgramSecured)2 ImportConfigResponse (org.breedinginsight.brapps.importer.model.config.ImportConfigResponse)2 SystemRole (org.breedinginsight.model.SystemRole)2 Trait (org.breedinginsight.model.Trait)2 ValidatorException (org.breedinginsight.services.exceptions.ValidatorException)2 FilterRequest (org.breedinginsight.api.model.v1.request.query.FilterRequest)1