Skip to content

Commit

Permalink
PEPPER-841 fix for tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
pegahtah committed Aug 22, 2023
1 parent 0f525b0 commit e69291f
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.broadinstitute.dsm.exception.DsmInternalError;
import org.broadinstitute.lddp.db.SimpleResult;

Expand Down Expand Up @@ -70,6 +71,9 @@ public JuniperSetupUtil(String instanceName, String studyGuid, String displayNam
}

private static String createDdpGroupForJuniper(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(ddpGroupId)) {
return ddpGroupId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_JUNIPER_GROUP, Statement.RETURN_GENERATED_KEYS);
int result = stmt.executeUpdate();
if (result != 1) {
Expand Down Expand Up @@ -181,7 +185,7 @@ public void setupJuniperInstanceAndSettings() {
kitDimensionId = createKitDimension(conn);
kitReturnId = createKitReturnInformation(conn);
carrierId = createCarrierInformation(conn);
ddpKitRequestSettingsId = createKitRequestSettingsInformations(conn);
ddpKitRequestSettingsId = createKitRequestSettingsInformation(conn);
} catch (SQLException e) {
simpleResult.resultException = e;
}
Expand All @@ -192,7 +196,10 @@ public void setupJuniperInstanceAndSettings() {
}
}

private String createKitRequestSettingsInformations(Connection conn) throws SQLException {
private String createKitRequestSettingsInformation(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(ddpKitRequestSettingsId)) {
return ddpKitRequestSettingsId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_DDP_KIT_REQUEST_SETTINGS, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, ddpInstanceId);
stmt.setString(2, kitTypeId);
Expand All @@ -206,41 +213,59 @@ private String createKitRequestSettingsInformations(Connection conn) throws SQLE
}

private String createCarrierInformation(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(carrierId)) {
return carrierId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_CARRIER, Statement.RETURN_GENERATED_KEYS);
stmt.executeUpdate();
ResultSet rs = stmt.getGeneratedKeys();
return getPrimaryKey(rs, "carrier_service");
}

private String createKitReturnInformation(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(kitReturnId)) {
return kitReturnId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_KIT_RETURN, Statement.RETURN_GENERATED_KEYS);
stmt.executeUpdate();
ResultSet rs = stmt.getGeneratedKeys();
return getPrimaryKey(rs, "kit_return_information");
}

private String createKitDimension(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(kitDimensionId)) {
return kitDimensionId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_KIT_DIMENSION, Statement.RETURN_GENERATED_KEYS);
stmt.executeUpdate();
ResultSet rs = stmt.getGeneratedKeys();
return getPrimaryKey(rs, "kit_dimension");
}

private String createKitType(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(kitTypeId)) {
return kitTypeId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_KIT_TYPE, Statement.RETURN_GENERATED_KEYS);
stmt.executeUpdate();
ResultSet rs = stmt.getGeneratedKeys();
return getPrimaryKey(rs, "kit_type");
}

private String createInstanceRole(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(instanceRoleId)) {
return instanceRoleId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_INSTANCE_ROLE, Statement.RETURN_GENERATED_KEYS);
stmt.executeUpdate();
ResultSet rs = stmt.getGeneratedKeys();
return getPrimaryKey(rs, "instance_role");
}

private String createDdpInstanceRole(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(ddpInstanceRoleId)) {
return ddpInstanceRoleId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_DDP_INSTANCE_ROLE, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, ddpInstanceId);
stmt.setString(2, instanceRoleId);
Expand All @@ -251,6 +276,9 @@ private String createDdpInstanceRole(Connection conn) throws SQLException {
}

private String createDdpInstanceGroup(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(ddpInstanceGroupId)) {
return ddpInstanceGroupId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_DDP_INSTANCE_GROUP, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, ddpInstanceId);
stmt.setString(2, ddpGroupId);
Expand All @@ -261,6 +289,9 @@ private String createDdpInstanceGroup(Connection conn) throws SQLException {
}

public String createDdpInstanceForJuniper(Connection conn) throws SQLException {
if (StringUtils.isNotBlank(ddpInstanceId)) {
return ddpGroupId;
}
PreparedStatement stmt = conn.prepareStatement(INSERT_JUNIPER_INSTANCE, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, instanceName);
stmt.setString(2, studyGuid);
Expand Down

0 comments on commit e69291f

Please sign in to comment.