Skip to content

Commit

Permalink
Merge pull request #15 from hms-dbmi/QA
Browse files Browse the repository at this point in the history
1.2.2 Release
  • Loading branch information
JREastonMarks authored Oct 19, 2016
2 parents 0f67f3c + 6573ee1 commit 5ee6955
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 49 deletions.
50 changes: 24 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.harvard.hms.dbmi.bd2k.irct</groupId>
<artifactId>IRCT-EXT</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<name>INTER-RESOURCE COMMUNICATION TOOL : EXTENSION</name>

<dependencies>
<!-- Oracle -->

<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/ojdbc6.jar</systemPath>
</dependency>

<!-- AWS -->

<!-- <dependency> <groupId>com.oracle.jdbc</groupId> <artifactId>ojdbc6</artifactId>
<version>1.0</version> </dependency> -->

<!-- AWS -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
Expand Down Expand Up @@ -58,7 +64,7 @@
<dependency>
<groupId>edu.harvard.hms.dbmi.bd2k.irct</groupId>
<artifactId>IRCT-API</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
</dependency>
<!-- JAVA EE -->
<dependency>
Expand All @@ -67,32 +73,24 @@
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- Apache Commons CSV -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.1</version>
</dependency>
</dependencies>

<build>
<finalName>IRCT-EXT</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<file>${basedir}/src/main/resources/lib/ojdbc6.jar</file>
</configuration>
</execution>
</executions>
</plugin>

<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId>
<version>2.4</version> <executions> <execution> <phase>initialize</phase>
<goals> <goal>install-file</goal> </goals> <configuration> <groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc6</artifactId> <version>1.0</version> <packaging>jar</packaging>
<file>${basedir}/src/main/resources/lib/ojdbc6.jar</file> </configuration>
</execution> </executions> </plugin> -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
Expand Down Expand Up @@ -139,4 +137,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import edu.harvard.hms.dbmi.bd2k.irct.event.result.AfterGetResult;
import edu.harvard.hms.dbmi.bd2k.irct.model.result.Result;
import edu.harvard.hms.dbmi.bd2k.irct.model.result.ResultStatus;

/**
* The S3 After Get Result checks to see if a result is available localy and if
Expand Down Expand Up @@ -55,6 +56,9 @@ public void init(Map<String, String> parameters) {

@Override
public void fire(Result result) {
if(result.getResultStatus() != ResultStatus.AVAILABLE) {
return;
}
if (!result.getResultSetLocation().startsWith("S3://")) {
File temp = new File(result.getResultSetLocation());
if (temp.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ public StreamingOutput createStream(final Result result) {
@Override
public void write(OutputStream outputStream) throws IOException,
WebApplicationException {
ResultSet rs = null;
CSVPrinter printer = null;
try {
ResultSet rs = (ResultSet) result.getData();
rs = (ResultSet) result.getData();
rs.load(result.getResultSetLocation());

CSVPrinter printer = new CSVPrinter(new OutputStreamWriter(
printer = new CSVPrinter(new OutputStreamWriter(
outputStream), CSVFormat.DEFAULT);

String[] columnHeaders = new String[rs.getColumnSize()];
Expand All @@ -83,14 +85,27 @@ public void write(OutputStream outputStream) throws IOException,
}
printer.printRecord((Object[]) row);
}

printer.flush();
printer.close();

} catch (ResultSetException | PersistableException e) {
log.info("Error creating CSV Stream: " + e.getMessage());
} finally {
if(printer != null) {
printer.close();
}

if(rs != null) {
try {
rs.close();
} catch (ResultSetException e) {
e.printStackTrace();
}
}
if(outputStream != null) {
outputStream.close();
}
}
outputStream.close();

}
};
return stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ public StreamingOutput createStream(final Result result) {
@Override
public void write(OutputStream outputStream) throws IOException,
WebApplicationException {
JsonGenerator jg = null;
ResultSet rs = null;
try {
ResultSet rs = (ResultSet) result.getData();
rs = (ResultSet) result.getData();
rs.load(result.getResultSetLocation());
Map<String, Object> properties = new HashMap<String, Object>(
1);
JsonGeneratorFactory jgf = Json.createGeneratorFactory(properties);
JsonGenerator jg = jgf.createGenerator(outputStream);
jg = jgf.createGenerator(outputStream);

jg.writeStartObject(); //Start Object
jg.writeStartArray("columns");
Expand Down Expand Up @@ -102,11 +104,27 @@ public void write(OutputStream outputStream) throws IOException,

jg.writeEnd(); //End data
jg.writeEnd(); //End Full Object
jg.close();

} catch (ResultSetException | PersistableException e) {
log.info("Error creating JSON Stream: " + e.getMessage());
} finally {

if(jg != null) {
jg.close();
}
if(rs != null) {
try {
rs.close();
} catch (ResultSetException e) {
e.printStackTrace();
}
}

if(outputStream != null) {
outputStream.close();
}
}
outputStream.close();

}
};
return stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ public StreamingOutput createStream(final Result result) {
@Override
public void write(OutputStream outputStream) throws IOException,
WebApplicationException {
ResultSet rs = null;
XMLStreamWriter xtw = null;
try {
ResultSet rs = (ResultSet) result.getData();
rs = (ResultSet) result.getData();
rs.load(result.getResultSetLocation());
XMLOutputFactory xof = XMLOutputFactory.newInstance();
XMLStreamWriter xtw = xof.createXMLStreamWriter(new OutputStreamWriter(outputStream));
xtw = xof.createXMLStreamWriter(new OutputStreamWriter(outputStream));
xtw.writeStartDocument("utf-8", "1.0");
xtw.writeStartElement("results");
rs.beforeFirst();
Expand All @@ -85,11 +87,28 @@ public void write(OutputStream outputStream) throws IOException,
xtw.writeEndDocument();

xtw.flush();
xtw.close();

} catch (ResultSetException | PersistableException | XMLStreamException e) {
log.info("Error creating XML Stream: " + e.getMessage());
} finally {
if(xtw != null) {
try {
xtw.close();
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
if(rs != null) {
try {
rs.close();
} catch (ResultSetException e) {
e.printStackTrace();
}
} if(outputStream != null) {
outputStream.close();
}
}
outputStream.close();

}
};
return stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
public class XSLXTabularDataConverter implements ResultDataConverter {

private Log log;

public XSLXTabularDataConverter() {
log = LogFactory.getLog("XSLX Tabular Data Converter");
}

@Override
public ResultDataType getResultDataType() {
return ResultDataType.TABULAR;
}

@Override
public String getFileExtension() {
return ".xlsx";
Expand All @@ -65,11 +65,13 @@ public StreamingOutput createStream(final Result result) {
@Override
public void write(OutputStream outputStream) throws IOException,
WebApplicationException {
ResultSet rs = null;
SXSSFWorkbook wb = null;
try {
ResultSet rs = (ResultSet) result.getData();
rs = (ResultSet) result.getData();
rs.load(result.getResultSetLocation());
SXSSFWorkbook wb = new SXSSFWorkbook(100);

wb = new SXSSFWorkbook(100);
// Create Sheet
Sheet sh = wb.createSheet("Results");

Expand All @@ -94,19 +96,31 @@ public void write(OutputStream outputStream) throws IOException,
for (int i = 0; i < rs.getColumnSize(); i++) {
String value = rs.getString(i);
Cell cell = row.createCell(i);
if(value != null) {
if (value != null) {
cell.setCellValue(rs.getString(i));
}
}
rowNum++;
}
wb.write(outputStream);
wb.close();


} catch (ResultSetException | PersistableException e) {
log.info("Error creating XSLX Stream: " + e.getMessage());
} finally {
if (wb != null) {
wb.close();
}
if (rs != null) {
try {
rs.close();
} catch (ResultSetException e) {
e.printStackTrace();
}
}
if (outputStream != null) {
outputStream.close();
}
}
outputStream.close();
}
};
return stream;
Expand Down

0 comments on commit 5ee6955

Please sign in to comment.