Skip to content

Commit

Permalink
merging changes and fixing primitive type/nullable bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tburdett committed Feb 26, 2015
1 parent 1b73661 commit 8239711
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AssociationReport {
@GeneratedValue
private Long id;

private boolean snpPending;
private Boolean snpPending;

private Date lastUpdateDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,36 @@ public class CatalogImportRepository {
private SimpleJdbcInsert insertAssociationReport;
private AssociationReportUpdate updateAssociationReport;

private MappedDataUpdate mappedDataUpdate;

private static final String SELECT_STUDY_REPORTS =
"SELECT ID FROM STUDY_REPORT WHERE STUDY_ID = ?";

private static final String UPDATE_STUDY_REPORTS =
"UPDATE STUDY_REPORT SET " +
"PUBMED_ID_ERROR = ?, " +
"NCBI_PAPER_TITLE = ?, " +
"NCBI_FIRST_AUTHOR = ?, " +
"NCBI_NORMALIZED_FIRST_AUTHOR = ?, " +
"NCBI_FIRST_UPDATE_DATE = ? " +
"WHERE ID = ?";

private static final String SELECT_ASSOCIATION_REPORTS =
"SELECT ID FROM ASSOCIATION_REPORT WHERE ASSOCIATION_ID = ?";

private static final String UPDATE_MAPPED_DATA =
"UPDATE CATALOG_SUMMARY_VIEW SET " +
"REGION = ?, " +
"CHROMOSOME_NAME = ?, " +
"CHROMOSOME_POSITION = ?, " +
"UPSTREAM_MAPPED_GENE = ?, " +
"UPSTREAM_ENTREZ_GENE_ID = ?, " +
"UPSTREAM_GENE_DISTANCE = ?, " +
"DOWNSTREAM_MAPPED_GENE = ?, " +
"DOWNSTREAM_ENTREZ_GENE_ID = ?, " +
"DOWNSTREAM_GENE_DISTANCE = ?, " +
"IS_INTERGENIC = ? " +
"WHERE STUDY_ID = ? " +
"AND ASSOCIATION_ID = ?";

private final Logger log = LoggerFactory.getLogger(getClass());

protected Logger getLog() {
Expand Down Expand Up @@ -360,31 +382,28 @@ private void mapData(Map<CatalogHeaderBinding, Integer> headerColumnMap, String[
ncbiFirstAuthor,
ncbiNormalisedFirstAuthor,
ncbiFirstUpdateDate);
/* addAssociationReport(associationId,
lastUpdateDate,
geneError,
snpError,
snpGeneOnDiffChr,
noGeneForSymbol,
geneNotOnGenome);*/
/* addMappedData(studyId,
associationId,
region,
chromosomeName,
chromosomePosition,
upstreamMappedGene,
upstreamEntrezGeneId,
upstreamGeneDistance,
downstreamMappedGene,
downstreamEntrezGeneId,
downstreamGeneDistance,
isIntergenic);*/
addAssociationReport(associationId,
lastUpdateDate,
geneError,
snpError,
snpGeneOnDiffChr,
noGeneForSymbol,
geneNotOnGenome);
addMappedData(studyId,
associationId,
region,
chromosomeName,
chromosomePosition,
upstreamMappedGene,
upstreamEntrezGeneId,
upstreamGeneDistance,
downstreamMappedGene,
downstreamEntrezGeneId,
downstreamGeneDistance,
isIntergenic);
}


}


if (caughtErrors) {
throw new DataImportException("Caught errors whilst processing data import - " +
"please check the logs for more information");
Expand Down Expand Up @@ -419,11 +438,9 @@ private void addStudyReport(Long studyId,
// Check for an existing id in database
try {
Long studyReportIdInDatabase = jdbcTemplate.queryForObject(SELECT_STUDY_REPORTS, Long.class, studyId);
String updateSql =
"UPDATE STUDY_REPORT SET PUBMED_ID_ERROR = ?, NCBI_PAPER_TITLE = ?, NCBI_FIRST_AUTHOR = ?, NCBI_NORMALIZED_FIRST_AUTHOR = ?, NCBI_FIRST_UPDATE_DATE = ? WHERE ID = ?";
Object[] params = {pubmedIdError, ncbiPaperTitle, ncbiFirstAuthor, ncbiNormalisedFirstAuthor,
ncbiFirstUpdateDate, studyReportIdInDatabase};
jdbcTemplate.update(updateSql, params);
jdbcTemplate.update(UPDATE_STUDY_REPORTS, params);

}
catch (EmptyResultDataAccessException e) {
Expand Down Expand Up @@ -481,8 +498,20 @@ private void addMappedData(Long studyId,
String downstreamMappedGene,
String downstreamEntrezGeneId,
Integer downstreamGeneDistance, Boolean isIntergenic) {


int rows = jdbcTemplate.update(UPDATE_MAPPED_DATA,
region,
chromosomeName,
chromosomePosition,
upstreamMappedGene,
upstreamEntrezGeneId,
upstreamGeneDistance,
downstreamMappedGene,
downstreamEntrezGeneId,
downstreamGeneDistance,
isIntergenic,
studyId,
associationId);
System.out.println("Updated " + rows + " rows");
}

private static <T> T[] extractRange(T[] array, int startIndex) {
Expand Down

0 comments on commit 8239711

Please sign in to comment.