Source:
protected void writeConfiguration(ObjectMapper mapper, ObjectNode config) throws IOException { if (aliquotClass != null) { config.putPOJO("targetSampleClass", Dtos.asDto(aliquotClass)); config.put("dnaseTreatable", aliquotClass.hasPathToDnaseTreatable(sampleValidRelationshipService.getAll())); } config.put("create", true); config.put("hasProject", project != null); Map<Long, List<LibraryTemplateDto>> templatesByProjectId = new HashMap<>(); if (project == null) { projectService.listAllProjects().stream().map(Dtos::asDto).forEach(config.putArray("projects")::addPOJO); List<LibraryTemplate> templates = libraryTemplateService.list(); for (LibraryTemplate template : templates) { LibraryTemplateDto dto = Dtos.asDto(template); for (Project project : template.getProjects()) { if (!templatesByProjectId.containsKey(project.getId())) { templatesByProjectId.put(project.getId(), new ArrayList<>()); } templatesByProjectId.get(project.getId()).add(dto); } } } else { config.putPOJO("project", Dtos.asDto(project)); templatesByProjectId.put(project.getId(), Dtos.asLibraryTemplateDtos(libraryTemplateService.listLibraryTemplatesForProject(project.getId()))); } config.put(Config.DEFAULT_SCI_NAME, defaultSciName); config.put(Config.SHOW_DESCRIPTION, showDescription); config.put(Config.SHOW_VOLUME, showVolume); config.put(Config.SHOW_LIBRARY_ALIAS, showLibraryAlias); config.put(Config.SORTABLE_LOCATION, false); config.put(Config.PROPAGATE, false); config.put(Config.IS_LIBRARY_RECEIPT, true); config.putPOJO(Config.BOX, newBox); config.putPOJO(Config.TEMPLATES, templatesByProjectId); }

Target:
protected void writeConfiguration(ObjectMapper mapper, ObjectNode config) throws IOException { if (aliquotClass != null) { config.putPOJO("targetSampleClass", Dtos.asDto(aliquotClass)); config.put("dnaseTreatable", aliquotClass.hasPathToDnaseTreatable(sampleValidRelationshipService.getAll())); } config.put("create", true); config.put("hasProject", project != null); Map<Long, List<LibraryTemplateDto>> templatesByProjectId = new HashMap<>(); if (project == null) { projectService.listAllProjects().stream().map(Dtos::asDto).forEach(config.putArray("projects")::addPOJO); List<LibraryTemplate> templates = libraryTemplateService.list(); for (LibraryTemplate template : templates) { LibraryTemplateDto dto = Dtos.asDto(template); for (Project tempProject : template.getProjects()) { if (!templatesByProjectId.containsKey(tempProject.getId())) { templatesByProjectId.put(tempProject.getId(), new ArrayList<>()); } templatesByProjectId.get(tempProject.getId()).add(dto); } } } else { config.putPOJO("project", Dtos.asDto(project)); templatesByProjectId.put(project.getId(), Dtos.asLibraryTemplateDtos(libraryTemplateService.listLibraryTemplatesForProject(project.getId()))); } config.put(Config.DEFAULT_SCI_NAME, defaultSciName); config.put(Config.SHOW_DESCRIPTION, showDescription); config.put(Config.SHOW_VOLUME, showVolume); config.put(Config.SHOW_LIBRARY_ALIAS, showLibraryAlias); config.put(Config.SORTABLE_LOCATION, false); config.put(Config.PROPAGATE, false); config.put(Config.IS_LIBRARY_RECEIPT, true); config.putPOJO(Config.BOX, newBox); config.putPOJO(Config.TEMPLATES, templatesByProjectId); }