@Override public List<SpecimenRequirement> createSpecimenPoolReqs(SpecimenPoolRequirements req) { OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR); Long pooledSpmnReqId = req.getPooledSpecimenReqId(); if (pooledSpmnReqId == null) { ose.addError(POOLED_SPMN_REQ); throw ose; } SpecimenRequirement pooledSpecimenReq = daoFactory.getSpecimenRequirementDao().getById(pooledSpmnReqId); if (pooledSpecimenReq == null) { ose.addError(POOLED_SPMN_REQ_NOT_FOUND, pooledSpmnReqId); throw ose; } if (pooledSpecimenReq.getParentSpecimenRequirement() != null || pooledSpecimenReq.getPooledSpecimenRequirement() != null) { ose.addError(INVALID_POOLED_SPMN, pooledSpmnReqId); throw ose; } List<SpecimenRequirement> specimenPoolReqs = new ArrayList<SpecimenRequirement>(); for (SpecimenRequirementDetail detail : req.getSpecimenPoolReqs()) { specimenPoolReqs.add(createSpecimenPoolReq(pooledSpecimenReq, detail, ose)); ose.checkAndThrow(); } return specimenPoolReqs; }
private void setSpecimenPoolReqs( SpecimenRequirementDetail detail, SpecimenRequirement sr, OpenSpecimenException ose) { if (sr.getParentSpecimenRequirement() != null || sr.getPooledSpecimenRequirement() != null) { return; } if (CollectionUtils.isEmpty(detail.getSpecimensPool())) { return; } for (SpecimenRequirementDetail specimenPoolReqDetail : detail.getSpecimensPool()) { sr.getSpecimenPoolReqs().add(createSpecimenPoolReq(sr, specimenPoolReqDetail, ose)); ose.checkAndThrow(); } }