-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reworked the method definition for pollutants to make the method its …
…own column. Added support for all of the speciation integrated datasets: CARB, IC, ICPMS, NA, NH4, SPEC, WICPMS, and LEV.
- Loading branch information
1 parent
a046166
commit 0761070
Showing
13 changed files
with
183 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/com/dbf/naps/data/loader/integrated/runner/SpeciationFileLoadRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.dbf.naps.data.loader.integrated.runner; | ||
|
||
import java.io.File; | ||
import java.math.BigDecimal; | ||
import java.util.Date; | ||
import java.util.List; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import com.dbf.naps.data.loader.LoaderOptions; | ||
import com.dbf.naps.data.loader.integrated.IntegratedDataRecord; | ||
import com.dbf.naps.data.utilities.DataCleaner; | ||
|
||
/** | ||
* Extends the base IntegratedFileLoadRunner class to add support for speciation metadata. | ||
*/ | ||
public class SpeciationFileLoadRunner extends IntegratedFileLoadRunner { | ||
|
||
public SpeciationFileLoadRunner(int threadId, LoaderOptions config, SqlSessionFactory sqlSessionFactory, File rawFile, String method) { | ||
super(threadId, config, sqlSessionFactory, rawFile, method); | ||
} | ||
|
||
//Store these column indexes so we only have to look them up once for the entire sheet | ||
private Integer massCol; | ||
private Integer speciationMassCol; | ||
private Integer startTimeCol; | ||
private Integer endTimeCol; | ||
private Integer cartridgeCol; | ||
private Integer mediaCol; | ||
|
||
@Override | ||
protected void preProcessRow() { | ||
//The column indexes for the speciation metadata are different for every sheet. | ||
//Look them up only once and store the result. | ||
//These columns are not guaranteed to be present in every sheet. | ||
//getColumnIndex() will not throw an exception if the column doesn't exist. | ||
if (null == massCol) massCol = getColumnIndex("Mass"); | ||
if (null == speciationMassCol) speciationMassCol = getColumnIndex("Speciation Mass"); | ||
if (null == startTimeCol) startTimeCol = getColumnIndex("Start"); //Some are "Start_time", some are "Start Time" | ||
if (null == endTimeCol) endTimeCol = getColumnIndex("End"); | ||
if (null == cartridgeCol) cartridgeCol = getColumnIndex("Cart"); //Some are "Cart", some are "Cartridge" | ||
if (null == mediaCol) mediaCol = getColumnIndex("Media"); | ||
} | ||
|
||
@Override | ||
protected List<IntegratedDataRecord> processRow(int row, Date date) { | ||
|
||
BigDecimal mass = DataCleaner.extractDecimalData(getSheet().getCellContents(massCol, row), true); | ||
|
||
//TODO: This is separate from sample mass and should be its own column | ||
BigDecimal speciationMass = DataCleaner.extractDecimalData(getSheet().getCellContents(speciationMassCol, row), true); | ||
|
||
//TODO: Handle the "Dich/Partisol Mass (ug/m3)" column? | ||
|
||
Double startTime = DataCleaner.extractDoubleData(getSheet().getCellContents(startTimeCol, row), true); | ||
Double endTime = DataCleaner.extractDoubleData(getSheet().getCellContents(endTimeCol, row), true); | ||
Double duration = (startTime != null && endTime != null) ? (endTime - startTime) : null; | ||
|
||
String cartridge = getSheet().getCellContents(cartridgeCol, row); | ||
if("".equals(cartridge)) cartridge = null; | ||
|
||
String media = getSheet().getCellContents(mediaCol, row); | ||
if("".equals(media)) media = null; | ||
|
||
List<IntegratedDataRecord> records = super.processRow(row, date); | ||
for(IntegratedDataRecord record : records) { | ||
//Enhance the data with metadata specific to this dataset | ||
record.setDuration(duration); | ||
record.setMedia(media); | ||
record.setCartridge(cartridge); | ||
record.setMass(mass); | ||
} | ||
return records; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.