Search in sources :

Example 21 with DataTablesResponse

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.

the class SequencingRunController method listSequencingRuns.

/**
 * Get a list of all the sequencing runs
 *
 * @param params a {@link DataTablesParams} of the sort and paging options
 * @param locale the locale used by the browser for the current request.
 * @return A DatatablesResponse of DTSequencingRun of the runs
 */
@RequestMapping(value = "/ajax/list")
@ResponseBody
public DataTablesResponse listSequencingRuns(@DataTablesRequest DataTablesParams params, Locale locale) {
    Sort sort = params.getSort();
    Page<SequencingRun> list = sequencingRunService.list(params.getCurrentPage(), params.getLength(), sort);
    List<DTSequencingRun> runs = list.getContent().stream().map(s -> new DTSequencingRun(s, messageSource.getMessage(UPLOAD_STATUS_MESSAGE_BASE + s.getUploadStatus().toString(), null, locale))).collect(Collectors.toList());
    return new DataTablesResponse(params, list, runs);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) java.util(java.util) SequencingObjectService(ca.corefacility.bioinformatics.irida.service.SequencingObjectService) ImmutableMap(com.google.common.collect.ImmutableMap) DataTablesRequest(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) DTSequencingRun(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTSequencingRun) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Controller(org.springframework.stereotype.Controller) SequencingRunService(ca.corefacility.bioinformatics.irida.service.SequencingRunService) Page(org.springframework.data.domain.Page) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) Collectors(java.util.stream.Collectors) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) Model(org.springframework.ui.Model) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) User(ca.corefacility.bioinformatics.irida.model.user.User) Sort(org.springframework.data.domain.Sort) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) MessageSource(org.springframework.context.MessageSource) DTSequencingRun(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTSequencingRun) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) DTSequencingRun(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTSequencingRun) Sort(org.springframework.data.domain.Sort) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 22 with DataTablesResponse

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.

the class ClientsController method getAjaxClientsList.

/**
 * Get a {@link DataTablesResponse} for the Clients page.
 *
 * @param params
 * 		{@link DataTablesParams} for the current DataTable.
 *
 * @return {@link DataTablesResponse}
 */
@RequestMapping(value = "/ajax/list", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public DataTablesResponse getAjaxClientsList(@DataTablesRequest DataTablesParams params) {
    Specification<IridaClientDetails> specification = IridaClientDetailsSpecification.searchClient(params.getSearchValue());
    Page<IridaClientDetails> page = clientDetailsService.search(specification, new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort()));
    List<DataTablesResponseModel> models = new ArrayList<>();
    for (IridaClientDetails client : page.getContent()) {
        models.add(new DTClient(client, clientDetailsService.countActiveTokensForClient(client)));
    }
    return new DataTablesResponse(params, page, models);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DTClient(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTClient) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) IridaClientDetails(ca.corefacility.bioinformatics.irida.model.IridaClientDetails) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

DataTablesResponse (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)22 DataTablesResponseModel (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel)16 DataTablesParams (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams)13 Sort (org.springframework.data.domain.Sort)11 Project (ca.corefacility.bioinformatics.irida.model.project.Project)8 Test (org.junit.Test)8 PageRequest (org.springframework.data.domain.PageRequest)8 User (ca.corefacility.bioinformatics.irida.model.user.User)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 DataTablesRequest (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)3 UserService (ca.corefacility.bioinformatics.irida.service.user.UserService)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Page (org.springframework.data.domain.Page)3 Controller (org.springframework.stereotype.Controller)3 Model (org.springframework.ui.Model)3