Skip to content
Snippets Groups Projects
Commit 17669612 authored by Martin's avatar Martin
Browse files

OZG-7872 revert switch case

parent 28a05fb3
No related branches found
No related tags found
1 merge request!26OZG-7872 OZG-8039 add related resource link on postfach
......@@ -34,6 +34,7 @@ import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
import org.springframework.stereotype.Component;
import de.ozgcloud.alfa.bescheid.BescheidController;
......@@ -86,31 +87,19 @@ class CommandModelAssembler implements RepresentationModelAssembler<Command, Ent
Link effectedResourceLinkByOrderType(Command entity) {
var type = entity.getCommandOrder().getType();
if (type == CommandOrder.Type.FORWARDING) {
return linkTo(methodOn(ForwardingController.class).findByVorgangId(entity.getVorgangId())).withRel(REL_EFFECTED_RESOURCE);
}
if (type == CommandOrder.Type.KOMMENTAR) {
return linkTo(KommentarController.class).slash(entity.getRelationId()).withRel(REL_EFFECTED_RESOURCE);
}
if (type == CommandOrder.Type.VORGANG) {
return linkTo(VorgangController.class).slash(entity.getRelationId()).withRel(REL_EFFECTED_RESOURCE);
}
if (type == CommandOrder.Type.VORGANG_LIST) {
return linkTo(VorgangController.class).withRel(REL_EFFECTED_RESOURCE);
}
if (type == CommandOrder.Type.WIEDERVORLAGE) {
return linkTo(WiedervorlageController.class).slash(entity.getRelationId()).withRel(REL_EFFECTED_RESOURCE);
}
if (type == CommandOrder.Type.BESCHEID) {
return linkTo(methodOn(BescheidController.class).getDraft(entity.getVorgangId())).withRel(REL_EFFECTED_RESOURCE);
}
if (type == CommandOrder.Type.DOCUMENT) {
return linkTo(DocumentController.class).slash(entity.getCreatedResource()).withRel(REL_EFFECTED_RESOURCE);
}
if (type == CommandOrder.Type.COLLABORATION) {
return linkTo(methodOn(CollaborationByVorgangController.class).getAllByVorgangId(entity.getVorgangId())).withRel(REL_EFFECTED_RESOURCE);
}
throw new IllegalArgumentException("Unknown CommandOrder: " + entity.getOrder());
WebMvcLinkBuilder linkBuilder = switch (type) {
case FORWARDING -> linkTo(methodOn(ForwardingController.class).findByVorgangId(entity.getVorgangId()));
case KOMMENTAR -> linkTo(KommentarController.class).slash(entity.getRelationId());
case VORGANG -> linkTo(VorgangController.class).slash(entity.getRelationId());
case VORGANG_LIST -> linkTo(VorgangController.class);
case WIEDERVORLAGE -> linkTo(WiedervorlageController.class).slash(entity.getRelationId());
case BESCHEID -> linkTo(methodOn(BescheidController.class).getDraft(entity.getVorgangId()));
case DOCUMENT -> linkTo(DocumentController.class).slash(entity.getCreatedResource());
case COLLABORATION -> linkTo(methodOn(CollaborationByVorgangController.class).getAllByVorgangId(entity.getVorgangId()));
default -> throw new IllegalArgumentException("Unknown CommandOrder: " + entity.getOrder());
};
return linkBuilder.withRel(REL_EFFECTED_RESOURCE);
}
public CollectionModel<EntityModel<Command>> toCollectionModel(Stream<Command> entities) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment