Skip to content

Commit

Permalink
Merge pull request #244 from bioinformatics-ua/bug/export-to-csv
Browse files Browse the repository at this point in the history
Bug/export to csv
  • Loading branch information
bastiao authored Sep 29, 2016
2 parents 7aa5d66 + 4f4419a commit 6a916df
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ExportToCSVQueryTask(List<String> tagsOrder, OutputStream outputStream) {

@Override
public void onCompletion() {
// TODO Auto-generated method stub
log.debug("ExportToCSV task: completed");
writter.flush();
writter.close();
latch.countDown();
Expand All @@ -68,18 +68,15 @@ public void onCompletion() {

@Override
public void onReceive(Task<Iterable<SearchResult>> e) {
// TODO Auto-generated method stub

log.debug("ExportToCSV task: Received results");
try {
Iterable<SearchResult> it = e.get();
for (SearchResult result : it) {
printLine(result);
}
} catch (InterruptedException | ExecutionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}


}

Expand All @@ -103,12 +100,13 @@ private void printLine(SearchResult result){
StringBuilder builder = new StringBuilder();

HashMap<String, Object> extraFields = result.getExtraData();

for (String tag : tagsOrder) {
Object temp1 = extraFields.get(tag);

String s = (temp1 != null) ? StringUtils.trimToEmpty(temp1.toString()) : "";

final String s = (temp1 != null) ?
temp1.toString().trim() : "";

if (s.length() > 0) {
String temp = StringUtils.replaceEach(s, searchChars, replaceChars);
builder.append('\"').append(temp).append("\";");
Expand All @@ -117,17 +115,15 @@ private void printLine(SearchResult result){
}
}

log.debug("Printing Line: ", builder.toString());
log.trace("Printing Line: ", builder.toString());
nLines++;
this.writter.println(builder.toString());
}

public void await() {
// TODO Auto-generated method stub
try {
latch.await();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
}

for (Object f : jsonObj) {
System.out.println(f.toString());
fields.put(f.toString(), f.toString());
orderedFields.add(f.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ExportView = React.createClass({
<div className='modal-body'>
<textarea id="textFields" placeholder="Paste export fields here (one per line) ..." rows="10" className="exportlist form-control"></textarea>
</div>
<div className='modal-footer'>
<div id="hacked-modal-footer" className='modal-footer'>
<Button onClick={this.onExportClicked}>Export</Button>
</div>
</Modal>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ const ExportStore = Reflux.createStore({
providers: provider
}
}).then((data, status) => {
//Response
// create a download link and trigger it automatically
const response = JSON.parse(data);
console.log("UID:", response.uid);
const link = document.createElement("a");
const hacked_footer = document.getElementById("hacked-modal-footer");
link.style.visibility = "hidden";
link.download = "file";
link.href = Endpoints.base + "/exportFile?UID=" + response.uid;
hacked_footer.appendChild(link);
link.click();
hacked_footer.removeChild(link);
});

}
Expand Down
2 changes: 1 addition & 1 deletion sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
<version>3.4</version>
</dependency>

<dependency>
Expand Down

0 comments on commit 6a916df

Please sign in to comment.