package uk.ac.ebi.subs.api.processors;

import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.stereotype.Component;
import uk.ac.ebi.subs.api.controllers.StatusDescriptionController;
import uk.ac.ebi.subs.repository.model.ProcessingStatus;

import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;

@Component
public class ProcessingStatusResourceProcessor implements ResourceProcessor<Resource<ProcessingStatus>> {

    @Override
    public Resource<ProcessingStatus> process(Resource<ProcessingStatus> resource) {

        addStatusDescriptionRel(resource);

        return resource;
    }

    private void addStatusDescriptionRel(Resource<ProcessingStatus> resource) {
        resource.add(
                linkTo(
                        methodOn(StatusDescriptionController.class)
                                .processingStatus(resource.getContent().getStatus()))
                        .withRel("statusDescription")
        );
    }
}

@@ -737,21 +737,231 @@
   re
-turn resource
+dactIds(resource);%0A%0A        return resource;%0A    %7D%0A%0A    private void redactIds(Resource%3CProcessingStatus%3E resource) %7B%0A        resource.getContent().setSubmissionId(null);%0A        resource.getContent().setSubmittableId(null)
 ;%0A  

redact IDs from status