Search in sources :

Example 1 with PeriodTypeDTO

use of org.hisp.dhis.webapi.webdomain.PeriodTypeDTO in project dhis2-core by dhis2.

the class PeriodTypeController method getPeriodTypes.

@GetMapping
public RootNode getPeriodTypes() {
    List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
    List<PeriodTypeDTO> periodTypes = periodService.getAllPeriodTypes().stream().map(PeriodTypeDTO::new).collect(Collectors.toList());
    if (fields.isEmpty()) {
        fields.addAll(Preset.ALL.getFields());
    }
    RootNode rootNode = NodeUtils.createMetadata();
    rootNode.addChild(fieldFilterService.filter(PeriodTypeDTO.class, periodTypes, fields));
    return rootNode;
}
Also used : RootNode(org.hisp.dhis.node.types.RootNode) PeriodTypeDTO(org.hisp.dhis.webapi.webdomain.PeriodTypeDTO) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

RootNode (org.hisp.dhis.node.types.RootNode)1 PeriodTypeDTO (org.hisp.dhis.webapi.webdomain.PeriodTypeDTO)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1