Skip to content

Commit

Permalink
ZFIN-9029 handle NPE on antibody page when expression result is null (Z…
Browse files Browse the repository at this point in the history
…FIN#937)

* ZFIN-9029 handle NPE on antibody page when expression result is null

* ZFIN-9029 refactor logic to handle nulls more elegantly

* ZFIN-9029 refactor logic to handle nulls more elegantly
  • Loading branch information
cmpich authored Jan 30, 2024
1 parent e6b8349 commit d6cdb4b
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions source/org/zfin/antibody/AntibodyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,33 +144,30 @@ public int getNumberOfDistinctComposedTerms() {
if (!(geno.isWildtype() && exp.isStandardOrGenericControl())) {
continue;
}
if (results != null) {
for (ExpressionResult2 result : results) {
if (!result.isExpressionFound()) {
continue;
}
Term term = result.getSuperTerm();
Term subterm = result.getSubTerm();
String composedTermName = term.getZdbID();
if (subterm != null) {
composedTermName += subterm.getZdbID();
}
distinctTerms.add(composedTermName);
for (ExpressionResult2 result : results) {
if (!result.isExpressionFound()) {
continue;
}
Term term = result.getSuperTerm();
Term subterm = result.getSubTerm();
String composedTermName = term.getZdbID();
if (subterm != null) {
composedTermName += subterm.getZdbID();
}
distinctTerms.add(composedTermName);
}
}
return distinctTerms.size();
}

private static Set<ExpressionResult2> getExpressionResult2s(ExpressionExperiment2 experiment) {
Set<ExpressionResult2> results = null;
if (CollectionUtils.isNotEmpty(experiment.getFigureStageSet())) {
results = experiment.getFigureStageSet().stream()
return experiment.getFigureStageSet().stream()
.map(ExpressionFigureStage::getExpressionResultSet)
.flatMap(Collection::stream)
.collect(Collectors.toSet());
}
return results;
return Collections.emptySet();
}

/**
Expand Down Expand Up @@ -509,7 +506,7 @@ private List<ExpressionStatement> getDistinctExpressionStatements(Set<Expression
.collect(Collectors.toSet());
}
if (results != null) {
for (ExpressionResult2 result :results) {
for (ExpressionResult2 result : results) {
if (result.isExpressionFound()) {
ExpressionStatement statement = new ExpressionStatement();
statement.setEntity(result.getEntity());
Expand Down

0 comments on commit d6cdb4b

Please sign in to comment.