diff --git a/web-interface/src/main/java/org/reparationservice/rest/controllers/GetAllWorkersController.java b/web-interface/src/main/java/org/reparationservice/rest/controllers/GetAllWorkersController.java index 59d6bf9..da4bc30 100644 --- a/web-interface/src/main/java/org/reparationservice/rest/controllers/GetAllWorkersController.java +++ b/web-interface/src/main/java/org/reparationservice/rest/controllers/GetAllWorkersController.java @@ -19,12 +19,10 @@ @Controller @RequestMapping(value = "/workers", produces = "application/hal+json") -public final class GetAllWorkersController implements GetAllWorkersResponder { +public final class GetAllWorkersController { private final UseCaseActivator interactor; private final GetAllWorkersRequestBuilder requestBuilder; - private Iterable workerList = Collections.emptyList(); - @Autowired public GetAllWorkersController(@Qualifier("GetAllWorkersInteractor") UseCaseActivator interactor, GetAllWorkersRequestBuilder requestBuilder) { @@ -32,15 +30,25 @@ public GetAllWorkersController(@Qualifier("GetAllWorkersInteractor") UseCaseActi this.requestBuilder = requestBuilder; } - @RequestMapping(method = RequestMethod.GET) ResponseEntity> getWorkers() { - UseCaseRequest request = requestBuilder.buildGetAllWorkersRequest(this); + @RequestMapping(method = RequestMethod.GET) ResponseEntity getWorkers() { + GetAllWorkersResponder presenter = new ResponsePresenter(); + UseCaseRequest request = requestBuilder.buildGetAllWorkersRequest(presenter); + interactor.execute(request); - Resources res = new Resources<>(this.workerList); - return new ResponseEntity<>(res, HttpStatus.OK); + + return ((ResponsePresenter) presenter).getResponse(); } - @Override - public void bindModel(Collection workerList) { - this.workerList = workerList; + private class ResponsePresenter implements GetAllWorkersResponder { + private Collection workerList = Collections.emptyList(); + + @Override public void bindModel(Collection workerList) { + this.workerList = workerList; + } + + public ResponseEntity getResponse() { + Resources res = new Resources<>(this.workerList); + return new ResponseEntity<>(res, HttpStatus.OK); + } } }