Skip to content

Commit

Permalink
update function
Browse files Browse the repository at this point in the history
  • Loading branch information
dippindots committed Apr 30, 2020
1 parent 9c6c3f7 commit 33f9027
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
19 changes: 10 additions & 9 deletions core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("?")) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -110,4 +111,4 @@ public static boolean shouldGenericAssayMetaBeDeleted(int cancerStudyId) throws
// do not update if there is an error
return false;
}
}
}

0 comments on commit 33f9027

Please sign in to comment.