Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix #280

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/broadinstitute/dsm/db/InstanceSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public boolean getHideSamplesTabByStudyGuid(String studyGuid) {
}

public InstanceSettingsDto getInstanceSettings(String realm) {
return instanceSettingsDao.getByStudyGuid(Objects.requireNonNull(realm))
return instanceSettingsDao.getByInstanceName(Objects.requireNonNull(realm))
.orElse(new InstanceSettingsDto.Builder().build());
}

//used ONLY for google cloud function
public InstanceSettingsDto getInstanceSettings(Connection conn, String realm) {
return instanceSettingsDao.getByStudyGuid(Objects.requireNonNull(conn), Objects.requireNonNull(realm))
return instanceSettingsDao.getByInstanceName(Objects.requireNonNull(conn), Objects.requireNonNull(realm))
.orElse(new InstanceSettingsDto.Builder().build());
}

Expand Down Expand Up @@ -242,7 +242,7 @@ public Map<String, Object> getInstanceSettingsAsMap(InstanceSettingsDto instance
.map(Field::getName)
.collect(Collectors.toList());
List<Method> methods = Arrays.stream(clazz.getMethods())
.filter(method -> method.getName().startsWith("get") || method.getName().startsWith("is"))
.filter(method -> method.getName().startsWith("get") || method.getName().startsWith("is") || method.getName().startsWith("has"))
.collect(Collectors.toList());
fieldNames.forEach(fieldName -> {
Optional<Method> methodByFieldName = methods.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class InstanceSettingsDao implements Dao<InstanceSettingsDto> {
"FROM instance_settings " +
"WHERE ddp_instance_id = (SELECT ddp_instance_id FROM ddp_instance WHERE study_guid = ?)";

private static final String SQL_GET_BY_STUDY_GUID = "SELECT " +
private static final String SQL_GET_BY_INSTANCE_NAME = "SELECT " +
"instance_settings_id, " +
"ddp_instance_id, " +
"mr_cover_pdf, " +
Expand All @@ -39,7 +39,7 @@ public class InstanceSettingsDao implements Dao<InstanceSettingsDto> {
"has_invitations, " +
"GBF_SHIPPED_DSS_DELIVERED " +
"FROM instance_settings " +
"WHERE ddp_instance_id = (SELECT ddp_instance_id FROM ddp_instance WHERE study_guid = ?)";
"WHERE ddp_instance_id = (SELECT ddp_instance_id FROM ddp_instance WHERE instance_name = ?)";

public static final String HIDE_SAMPLES_TAB = "hide_samples_tab";
public static final String INSTANCE_SETTINGS_ID = "instance_settings_id";
Expand Down Expand Up @@ -92,30 +92,30 @@ public Optional<Boolean> getHideSamplesTabByStudyGuid(String studyGuid) {
return Optional.ofNullable((Boolean) results.resultValue);
}

public Optional<InstanceSettingsDto> getByStudyGuid(String studyGuid) {
SimpleResult results = inTransaction((conn) -> getInstanceSettingsByStudyGuid(studyGuid, conn));
public Optional<InstanceSettingsDto> getByInstanceName(String instanceName) {
SimpleResult results = inTransaction((conn) -> getInstanceSettingsByInstanceName(instanceName, conn));
if (results.resultException != null) {
throw new RuntimeException("Error getting instance settings for study guid: "
+ studyGuid, results.resultException);
+ instanceName, results.resultException);
}
return Optional.ofNullable((InstanceSettingsDto) results.resultValue);
}

//used ONLY for google cloud function
public Optional<InstanceSettingsDto> getByStudyGuid(Connection conn, String studyGuid) {
SimpleResult results = getInstanceSettingsByStudyGuid(studyGuid, conn);
public Optional<InstanceSettingsDto> getByInstanceName(Connection conn, String instanceName) {
SimpleResult results = getInstanceSettingsByInstanceName(instanceName, conn);
if (results.resultException != null) {
throw new RuntimeException("Error getting instance settings for study guid: "
+ studyGuid, results.resultException);
+ instanceName, results.resultException);
}
return Optional.ofNullable((InstanceSettingsDto) results.resultValue);
}


private SimpleResult getInstanceSettingsByStudyGuid(String studyGuid, Connection conn) {
private SimpleResult getInstanceSettingsByInstanceName(String instanceName, Connection conn) {
SimpleResult execResult = new SimpleResult();
try (PreparedStatement stmt = conn.prepareStatement(SQL_GET_BY_STUDY_GUID)) {
stmt.setString(1, studyGuid);
try (PreparedStatement stmt = conn.prepareStatement(SQL_GET_BY_INSTANCE_NAME)) {
stmt.setString(1, instanceName);
try(ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
execResult.resultValue = new InstanceSettingsDto.Builder()
Expand Down