private void createMissingIndividual(Individual individual, Map<String, Individual> individualMap, Study study, String sessionId)
throws CatalogException {
if (individual == null || individual.getUid() > 0) {
return;
}
if (individual.getFather() != null && StringUtils.isNotEmpty(individual.getFather().getId())) {
createMissingIndividual(individual.getFather(), individualMap, study, sessionId);
individual.setFather(individualMap.get(individual.getFather().getId()));
}
if (individual.getMother() != null && StringUtils.isNotEmpty(individual.getMother().getId())) {
createMissingIndividual(individual.getMother(), individualMap, study, sessionId);
individual.setMother(individualMap.get(individual.getMother().getId()));
}
QueryResult<Individual> individualQueryResult = catalogManager.getIndividualManager().create(study.getFqn(), individual,
QueryOptions.empty(), sessionId);
if (individualQueryResult.getNumResults() == 0) {
throw new CatalogException("Unexpected error when trying to create individual " + individual.getId());
}
individualMap.put(individual.getId(), individualQueryResult.first());
}