Commit 05b9344d authored by Matija Obreza's avatar Matija Obreza
Browse files

Subrequest's body needs to have new PID when updated

parent b5eb2daa
......@@ -247,7 +247,18 @@ public class RequestServiceImpl implements RequestService {
RequestBody rb = mapper.readValue(materialRequest.getBody(), RequestBody.class);
rb.pid = pid;
materialRequest.setBody(serialize(rb));
// Need to update all subrequests
for (MaterialSubRequest subrequest : materialRequest.getSubRequests()) {
RequestBody rbs = mapper.readValue(subrequest.getBody(), RequestBody.class);
rbs.pid = pid;
subrequest.setBody(serialize(rb));
LOG.info("Updating subrequest: " + subrequest);
subRequestRepository.save(subrequest);
}
return requestRepository.save(materialRequest);
} catch (IOException e) {
// FIXME Some other exception?
throw new RuntimeException("Could not handle request JSON", e);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment