use of uk.ac.bbsrc.tgac.miso.core.data.VolumeUnit in project miso-lims by miso-lims.
the class Dtos method to.
public static LibraryTemplate to(@Nonnull LibraryTemplateDto from) {
LibraryTemplate to = null;
if (from instanceof DetailedLibraryTemplateDto) {
to = toDetailedLibraryTemplate((DetailedLibraryTemplateDto) from);
} else {
to = new LibraryTemplate();
}
if (from.getId() != null)
to.setId(from.getId());
to.setAlias(from.getAlias());
setObject(to::setPlatformType, from.getPlatformType(), PlatformType::valueOf);
setBigDecimal(to::setDefaultVolume, from.getDefaultVolume());
setObject(to::setVolumeUnits, from.getVolumeUnits(), VolumeUnit::valueOf);
if (from.getProjectIds() != null) {
List<Project> projects = new ArrayList<>();
from.getProjectIds().stream().forEach(id -> {
Project project = new ProjectImpl();
project.setId(id);
projects.add(project);
});
to.getProjects().addAll(projects);
}
if (from.getLibraryTypeId() != null) {
LibraryType libraryType = new LibraryType();
libraryType.setId(from.getLibraryTypeId());
to.setLibraryType(libraryType);
}
setObject(to::setLibrarySelectionType, LibrarySelectionType::new, from.getSelectionId());
if (from.getStrategyId() != null) {
LibraryStrategyType libraryStrategyType = new LibraryStrategyType();
libraryStrategyType.setId(from.getStrategyId());
to.setLibraryStrategyType(libraryStrategyType);
}
if (from.getKitDescriptorId() != null) {
KitDescriptor kitDescriptor = new KitDescriptor();
kitDescriptor.setId(from.getKitDescriptorId());
to.setKitDescriptor(kitDescriptor);
}
if (from.getIndexFamilyId() != null) {
IndexFamily indexFamily = new IndexFamily();
indexFamily.setId(from.getIndexFamilyId());
to.setIndexFamily(indexFamily);
}
if (from.getIndexOneIds() != null) {
to.getIndexOnes().putAll(from.getIndexOneIds().entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> {
Index index = new Index();
index.setId(entry.getValue());
return index;
})));
}
if (from.getIndexTwoIds() != null) {
to.getIndexTwos().putAll(from.getIndexTwoIds().entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> {
Index index = new Index();
index.setId(entry.getValue());
return index;
})));
}
return to;
}
Aggregations