diff --git a/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/AssociationReport.java b/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/AssociationReport.java index 4cbd7ebb5a..82c6aae9fc 100644 --- a/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/AssociationReport.java +++ b/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/AssociationReport.java @@ -18,7 +18,7 @@ public class AssociationReport { @GeneratedValue private Long id; - private boolean snpPending; + private Boolean snpPending; private Date lastUpdateDate; diff --git a/goci-tools/goci-catalog-io/src/main/java/uk/ac/ebi/spot/goci/repository/CatalogImportRepository.java b/goci-tools/goci-catalog-io/src/main/java/uk/ac/ebi/spot/goci/repository/CatalogImportRepository.java index 6a2bd26298..0bf9b5c702 100644 --- a/goci-tools/goci-catalog-io/src/main/java/uk/ac/ebi/spot/goci/repository/CatalogImportRepository.java +++ b/goci-tools/goci-catalog-io/src/main/java/uk/ac/ebi/spot/goci/repository/CatalogImportRepository.java @@ -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() { @@ -360,31 +382,28 @@ private void mapData(Map 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"); @@ -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) { @@ -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[] extractRange(T[] array, int startIndex) {