Skip to content

Commit

Permalink
Issue #731 Metabolic pathways fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
okolesn committed Feb 2, 2022
1 parent 354dbf9 commit 4cde879
Showing 1 changed file with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.SimpleFSDirectory;
import org.apache.lucene.util.BytesRef;
Expand Down Expand Up @@ -119,9 +112,15 @@ public Pathway createPathway(final PathwayRegistrationRequest request) throws IO
} catch (JAXBException e) {
throw new SbgnFileParsingException(getMessage(MessagesConstants.ERROR_FILE_PARSING, SBGN), e);
}
biologicalDataItemManager.createBiologicalDataItem(pathway);
pathway.setBioDataItemId(pathway.getId());
pathwayDao.savePathway(pathway);
try {
biologicalDataItemManager.createBiologicalDataItem(pathway);
pathway.setBioDataItemId(pathway.getId());
pathwayDao.savePathway(pathway);
} finally {
if (pathway.getBioDataItemId() == null) {
deleteDocument(pathway.getPathwayId());
}
}
return pathway;
}

Expand Down Expand Up @@ -287,7 +286,7 @@ private Query buildPathwaySearchQuery(final String term) throws ParseException {
BooleanClause.Occur.SHOULD);
builder.add(buildQuery(PathwayIndexFields.DESCRIPTION.getFieldName(), term, analyzer),
BooleanClause.Occur.SHOULD);
builder.add(buildPhraseQuery(PathwayIndexFields.CONTENT.getFieldName(), term, analyzer),
builder.add(buildQuery(PathwayIndexFields.CONTENT.getFieldName(), term, analyzer),
BooleanClause.Occur.SHOULD);
return builder.build();
}
Expand All @@ -297,11 +296,6 @@ private Query buildQuery(final String fieldName, final String fieldValue, final
return new QueryParser(fieldName, analyzer).parse(fieldValue);
}

private Query buildPhraseQuery(final String fieldName, final String fieldValue, final StandardAnalyzer analyzer) {
final QueryParser parser = new QueryParser(fieldName, analyzer);
return parser.createPhraseQuery(fieldName, fieldValue);
}

@NotNull
private Pathway getPathway(final PathwayRegistrationRequest request) {
final Pathway pathway = Pathway.builder()
Expand Down

0 comments on commit 4cde879

Please sign in to comment.