diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java index 45d1e57c050..4c13e621311 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java @@ -575,7 +575,10 @@ public static void deleteCancerStudy(int internalCancerStudyId) throws DaoExcept ResultSet rs = null; try { con = JdbcUtil.getDbConnection(DaoCancerStudy.class); - deleteGenericAssayMeta(internalCancerStudyId); + // check whether should delete generic assay meta + if (DaoGenericAssay.geneticEntitiesOnlyExistInSingleStudy(internalCancerStudyId)) { + deleteGenericAssayMeta(internalCancerStudyId); + } for (String statementString : deleteStudyStatements) { pstmt = con.prepareStatement(statementString); if (statementString.contains("?")) { @@ -635,15 +638,13 @@ public static void deleteGenericAssayMeta(int internalCancerStudyId) throws DaoE ResultSet rs = null; try { con = JdbcUtil.getDbConnection(DaoCancerStudy.class); - if (DaoGenericAssay.shouldGenericAssayMetaBeDeleted(internalCancerStudyId)) { - for (String statementString : deleteGenericAssayStatements) { - pstmt = con.prepareStatement(statementString); - if (statementString.contains("?")) { - pstmt.setInt(1, internalCancerStudyId); - } - pstmt.executeUpdate(); - pstmt.close(); + for (String statementString : deleteGenericAssayStatements) { + pstmt = con.prepareStatement(statementString); + if (statementString.contains("?")) { + pstmt.setInt(1, internalCancerStudyId); } + pstmt.executeUpdate(); + pstmt.close(); } } catch (SQLException e) { throw new DaoException(e); diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGenericAssay.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGenericAssay.java index b87385808ae..0a319d9d8cd 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGenericAssay.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGenericAssay.java @@ -86,7 +86,7 @@ public static void deleteGenericEntityPropertiesByStableId(String stableId) thro } } - public static boolean shouldGenericAssayMetaBeDeleted(int cancerStudyId) throws DaoException { + public static boolean geneticEntitiesOnlyExistInSingleStudy(int cancerStudyId) throws DaoException { Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; @@ -101,6 +101,7 @@ public static boolean shouldGenericAssayMetaBeDeleted(int cancerStudyId) throws while(rs.next()) { studies.add(rs.getInt("CANCER_STUDY_ID")); } + // check if entities only exist in single study return studies.size() == 1; } catch (SQLException e) { e.printStackTrace(); @@ -110,4 +111,4 @@ public static boolean shouldGenericAssayMetaBeDeleted(int cancerStudyId) throws // do not update if there is an error return false; } -} \ No newline at end of file +}