Skip to content

Commit

Permalink
Fixed NullPointerException during saving of a cohort characterization…
Browse files Browse the repository at this point in the history
… with missing design
  • Loading branch information
oleg-odysseus committed Sep 4, 2024
1 parent accf315 commit 7f7f196
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.ohdsi.analysis.cohortcharacterization.design.FeatureAnalysisAggregate;
import org.ohdsi.webapi.feanalysis.domain.*;
import org.ohdsi.webapi.feanalysis.dto.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -52,6 +54,9 @@ private Object convertDesignToJson(final FeAnalysisEntity source) {
switch (type) {
case CRITERIA_SET:
FeAnalysisWithCriteriaEntity<?> sourceWithCriteria = (FeAnalysisWithCriteriaEntity<?>) source;
if (CollectionUtils.isEmpty(sourceWithCriteria.getDesign())) {
return Collections.emptyList();
}
return sourceWithCriteria.getDesign()
.stream()
.map(this::convertCriteria)
Expand Down

0 comments on commit 7f7f196

Please sign in to comment.