Skip to content

Commit

Permalink
bug fix for export returning empty sequence(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
hplahar committed Sep 4, 2020
1 parent 3beb506 commit 2a44d01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jbei/ice/lib/entry/EntriesAsCSV.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void writeZip(Set<Long> sequenceSet) {
for (long entryId : sequenceSet) {
for (String format : formats) {
InputStreamWrapper wrapper = new PartSequence(userId, Long.toString(entryId))
.toFile(SequenceFormat.fromString(format), true);
.toFile(SequenceFormat.fromString(format), true, false);
putZipEntry(wrapper, zos);
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ public ByteArrayOutputStream customize(EntrySelection selection, SequenceFormat
}

// get the sequence
InputStreamWrapper wrapper = new PartSequence(userId, Long.toString(entryId)).toFile(format, onePerFolder);
InputStreamWrapper wrapper = new PartSequence(userId, Long.toString(entryId)).toFile(format, onePerFolder, false);
if (wrapper == null) {
Logger.error("ERROR : no sequence " + entryId);
continue;
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/jbei/ice/lib/entry/sequence/PartSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,19 +495,20 @@ private boolean checkSameFeature(SequenceFeature existingSequenceFeature, Sequen
/**
* Convert sequence to a byte array of the specified format with the intention of being written to a file
*
* @param format specified format for sequence conversion
* @param useFileName whether to use the original filename of the sequence if the original uploaded sequence is
* available
* @param format specified format for sequence conversion
* @param useFileName whether to use the original filename of the sequence if the original uploaded sequence is
* available
* @param useOriginalIfAvailable whether to use specified format if is it the same as the uploaded format
* @return wrapper around the outputstream for the converted format and name
*/
public InputStreamWrapper toFile(SequenceFormat format, boolean useFileName) {
public InputStreamWrapper toFile(SequenceFormat format, boolean useFileName, boolean useOriginalIfAvailable) {
entryAuthorization.expectRead(userId, entry);
Sequence sequence = sequenceDAO.getByEntry(entry);
if (sequence == null)
return null;

// if requested format is the same as the original format (if original exist) then get the original instead
if (sequence.getFormat() == format && DAOFactory.getSequenceDAO().hasOriginalSequence(entry.getId()))
if (useOriginalIfAvailable && sequence.getFormat() == format && DAOFactory.getSequenceDAO().hasOriginalSequence(entry.getId()))
format = SequenceFormat.ORIGINAL;

String name;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jbei/ice/services/rest/FileResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public Response downloadSequence(

return addHeaders(Response.ok(stream), wrapper.getName());
} else {
InputStreamWrapper wrapper = new PartSequence(userId, partId).toFile(SequenceFormat.fromString(downloadType), true);
InputStreamWrapper wrapper = new PartSequence(userId, partId).toFile(SequenceFormat.fromString(downloadType), true, true);
StreamingOutput stream = output -> IOUtils.copy(wrapper.getInputStream(), output);
return addHeaders(Response.ok(stream), wrapper.getName());
}
Expand Down

0 comments on commit 2a44d01

Please sign in to comment.