Search in sources :

Example 1 with ClassificationQuery

use of pro.taskana.ClassificationQuery in project taskana by Taskana.

the class ClassificationDefinitionController method getClassifications.

@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<List<ClassificationResource>> getClassifications(@RequestParam(required = false) String domain) throws ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, ConcurrencyException, DomainNotFoundException, InvalidArgumentException {
    ClassificationQuery query = classificationService.createClassificationQuery();
    List<ClassificationSummary> summaries = domain != null ? query.domainIn(domain).list() : query.list();
    List<ClassificationResource> export = new ArrayList<>();
    for (ClassificationSummary summary : summaries) {
        Classification classification = classificationService.getClassification(summary.getKey(), summary.getDomain());
        export.add(classificationMapper.toResource(classification));
    }
    return new ResponseEntity<>(export, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationResource(pro.taskana.rest.resource.ClassificationResource) Classification(pro.taskana.Classification) ArrayList(java.util.ArrayList) ClassificationQuery(pro.taskana.ClassificationQuery) GetMapping(org.springframework.web.bind.annotation.GetMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ArrayList (java.util.ArrayList)1 ResponseEntity (org.springframework.http.ResponseEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 Classification (pro.taskana.Classification)1 ClassificationQuery (pro.taskana.ClassificationQuery)1 ClassificationSummary (pro.taskana.ClassificationSummary)1 ClassificationResource (pro.taskana.rest.resource.ClassificationResource)1