org.owasp
dependency-check-maven
diff --git a/src/main/java/org/broadinstitute/consent/http/ConsentApplication.java b/src/main/java/org/broadinstitute/consent/http/ConsentApplication.java
index 8c5fc7c8e7..d228286922 100644
--- a/src/main/java/org/broadinstitute/consent/http/ConsentApplication.java
+++ b/src/main/java/org/broadinstitute/consent/http/ConsentApplication.java
@@ -88,9 +88,9 @@
/**
* Top-level entry point to the entire application.
- *
- * See the Dropwizard docs here:
- * https://dropwizard.github.io
+ *
+ *
See the Dropwizard docs here: https://dropwizard.github.io
*/
public class ConsentApplication extends Application {
@@ -106,19 +106,21 @@ public static void main(String[] args) throws Exception {
try {
String dsn = System.getProperties().getProperty("sentry.dsn");
if (StringUtils.isNotBlank(dsn)) {
- Sentry.init(config -> {
- config.setDsn(dsn);
- config.setDiagnosticLevel(SentryLevel.ERROR);
- config.setServerName("Consent");
- config.addContextTag("Consent");
- config.addInAppInclude("org.broadinstitute");
- });
+ Sentry.init(
+ config -> {
+ config.setDsn(dsn);
+ config.setDiagnosticLevel(SentryLevel.ERROR);
+ config.setServerName("Consent");
+ config.addContextTag("Consent");
+ config.addInAppInclude("org.broadinstitute");
+ });
Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit());
} else {
LOGGER.error("Unable to bootstrap sentry logging.");
}
} catch (Exception e) {
- LOGGER.error(MessageFormat.format("Exception loading sentry properties: {0}", e.getMessage()));
+ LOGGER.error(
+ MessageFormat.format("Exception loading sentry properties: {0}", e.getMessage()));
}
new ConsentApplication().run(args);
LOGGER.info("Consent Application Started");
@@ -187,18 +189,24 @@ public void run(ConsentConfiguration config, Environment env) {
// Authentication filters
final OAuthAuthenticator authenticator = injector.getProvider(OAuthAuthenticator.class).get();
- final DuosUserAuthenticator duosUserAuthenticator = injector.getProvider(DuosUserAuthenticator.class).get();
- final AuthorizationHelper authorizationHelper = injector.getProvider(AuthorizationHelper.class).get();
+ final DuosUserAuthenticator duosUserAuthenticator =
+ injector.getProvider(DuosUserAuthenticator.class).get();
+ final AuthorizationHelper authorizationHelper =
+ injector.getProvider(AuthorizationHelper.class).get();
// Requests annotated with @Auth AuthUser will be authenticated through this filter
- final AuthFilter primaryAuthFilter = new OAuthCustomAuthFilter<>(authenticator, authorizationHelper);
- // Requests annotated with @Auth DuosUser will be authenticated through this filter and are guaranteed to have a populated User object
- final AuthFilter duosAuthUserFilter = new OAuthCustomAuthFilter<>(duosUserAuthenticator, authorizationHelper);
- final PolymorphicAuthDynamicFeature feature = new PolymorphicAuthDynamicFeature<>(
- Map.of(
- AuthUser.class, primaryAuthFilter,
- DuosUser.class, duosAuthUserFilter));
- final AbstractBinder binder = new PolymorphicAuthValueFactoryProvider.Binder<>(
- Set.of(AuthUser.class, DuosUser.class));
+ final AuthFilter primaryAuthFilter =
+ new OAuthCustomAuthFilter<>(authenticator, authorizationHelper);
+ // Requests annotated with @Auth DuosUser will be authenticated through this filter and are
+ // guaranteed to have a populated User object
+ final AuthFilter duosAuthUserFilter =
+ new OAuthCustomAuthFilter<>(duosUserAuthenticator, authorizationHelper);
+ final PolymorphicAuthDynamicFeature feature =
+ new PolymorphicAuthDynamicFeature<>(
+ Map.of(
+ AuthUser.class, primaryAuthFilter,
+ DuosUser.class, duosAuthUserFilter));
+ final AbstractBinder binder =
+ new PolymorphicAuthValueFactoryProvider.Binder<>(Set.of(AuthUser.class, DuosUser.class));
env.jersey().register(feature);
env.jersey().register(binder);
@@ -224,15 +232,16 @@ private void initializeLiquibase(ConsentConfiguration config)
values.set("ui", new LoggerUIService());
} catch (IllegalAccessException | NoSuchFieldException ignored) {
}
- Connection connection = DriverManager.getConnection(
- config.getDataSourceFactory().getUrl(),
- config.getDataSourceFactory().getUser(),
- config.getDataSourceFactory().getPassword()
- );
- Database database = DatabaseFactory.getInstance()
- .findCorrectDatabaseImplementation(new JdbcConnection(connection));
- Liquibase liquibase = new Liquibase(liquibaseFile(), new ClassLoaderResourceAccessor(),
- database);
+ Connection connection =
+ DriverManager.getConnection(
+ config.getDataSourceFactory().getUrl(),
+ config.getDataSourceFactory().getUser(),
+ config.getDataSourceFactory().getPassword());
+ Database database =
+ DatabaseFactory.getInstance()
+ .findCorrectDatabaseImplementation(new JdbcConnection(connection));
+ Liquibase liquibase =
+ new Liquibase(liquibaseFile(), new ClassLoaderResourceAccessor(), database);
liquibase.update(new Contexts(), new LabelExpression());
}
@@ -246,5 +255,4 @@ private String liquibaseFile() {
}
return changeLogFile;
}
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/ConsentModule.java b/src/main/java/org/broadinstitute/consent/http/ConsentModule.java
index 9542c332be..94dcf58842 100644
--- a/src/main/java/org/broadinstitute/consent/http/ConsentModule.java
+++ b/src/main/java/org/broadinstitute/consent/http/ConsentModule.java
@@ -67,7 +67,6 @@
import org.broadinstitute.consent.http.service.OntologyService;
import org.broadinstitute.consent.http.service.SupportRequestService;
import org.broadinstitute.consent.http.service.UseRestrictionConverter;
-import org.broadinstitute.consent.http.service.feature.InstitutionAndLibraryCardEnforcement;
import org.broadinstitute.consent.http.service.UserService;
import org.broadinstitute.consent.http.service.VoteService;
import org.broadinstitute.consent.http.service.dao.DaaServiceDAO;
@@ -80,6 +79,7 @@
import org.broadinstitute.consent.http.service.dao.NihServiceDAO;
import org.broadinstitute.consent.http.service.dao.UserServiceDAO;
import org.broadinstitute.consent.http.service.dao.VoteServiceDAO;
+import org.broadinstitute.consent.http.service.feature.InstitutionAndLibraryCardEnforcement;
import org.broadinstitute.consent.http.service.ontology.ElasticSearchSupport;
import org.broadinstitute.consent.http.service.sam.SamService;
import org.broadinstitute.consent.http.util.HttpClientUtil;
@@ -93,10 +93,8 @@
public class ConsentModule extends AbstractModule {
public static final String DB_ENV = "postgresql";
- @Inject
- private final ConsentConfiguration config;
- @Inject
- private final Environment environment;
+ @Inject private final ConsentConfiguration config;
+ @Inject private final Environment environment;
private final Client client;
private final Jdbi jdbi;
private final CounterDAO counterDAO;
@@ -125,9 +123,10 @@ public class ConsentModule extends AbstractModule {
ConsentModule(ConsentConfiguration consentConfiguration, Environment environment) {
this.config = consentConfiguration;
this.environment = environment;
- this.client = new JerseyClientBuilder(environment)
- .using(config.getJerseyClientConfiguration())
- .build(this.getClass().getName());
+ this.client =
+ new JerseyClientBuilder(environment)
+ .using(config.getJerseyClientConfiguration())
+ .build(this.getClass().getName());
this.jdbi = new JdbiFactory().build(environment, config.getDataSourceFactory(), DB_ENV);
jdbi.installPlugin(new SqlObjectPlugin());
@@ -256,16 +255,13 @@ DuosUserAuthenticator providesDuosUserOAuthAuthenticator() {
@Provides
DarCollectionService providesDarCollectionService() {
- return new DarCollectionService(providesJdbi(), providesDarCollectionServiceDAO(),
- providesEmailService());
+ return new DarCollectionService(
+ providesJdbi(), providesDarCollectionServiceDAO(), providesEmailService());
}
@Provides
FileStorageObjectService providesFileStorageObjectService() {
- return new FileStorageObjectService(
- providesFileStorageObjectDAO(),
- providesGCSService()
- );
+ return new FileStorageObjectService(providesFileStorageObjectDAO(), providesGCSService());
}
@Provides
@@ -293,8 +289,7 @@ DACAutomationRuleService providesRuleService() {
providesUserDAO(),
providesVoteDAO(),
providesVoteServiceDAO(),
- providesVoteService()
- );
+ providesVoteService());
}
@Provides
@@ -308,17 +303,13 @@ DataAccessRequestService providesDataAccessRequestService() {
providesInstitutionService(),
providesEmailService(),
providesRuleService(),
- config
- );
+ config);
}
@Provides
DatasetServiceDAO providesDatasetServiceDAO() {
return new DatasetServiceDAO(
- jdbi,
- providesDatasetDAO(),
- providesStudyDAO(),
- providesDatasetAuthorizationReaderDAO());
+ jdbi, providesDatasetDAO(), providesStudyDAO(), providesDatasetAuthorizationReaderDAO());
}
@Provides
@@ -338,9 +329,7 @@ DatasetService providesDatasetService() {
@Provides
ElectionService providesElectionService() {
- return new ElectionService(
- providesElectionDAO()
- );
+ return new ElectionService(providesElectionDAO());
}
@Provides
@@ -360,9 +349,7 @@ EmailService providesEmailService() {
@Provides
SendGridAPI providesSendGridAPI() {
- return new SendGridAPI(
- config.getMailConfiguration(),
- providesUserDAO());
+ return new SendGridAPI(config.getMailConfiguration(), providesUserDAO());
}
@Provides
@@ -383,19 +370,13 @@ DarCollectionSummaryDAO providesDarCollectionSummaryDAO() {
@Provides
DarCollectionServiceDAO providesDarCollectionServiceDAO() {
return new DarCollectionServiceDAO(
- providesDatasetDAO(),
- providesElectionDAO(),
- providesJdbi(),
- providesUserDAO());
+ providesDatasetDAO(), providesElectionDAO(), providesJdbi(), providesUserDAO());
}
@Provides
DataAccessRequestServiceDAO providesDataAccessRequestServiceDAO() {
return new DataAccessRequestServiceDAO(
- providesDataAccessRequestDAO(),
- providesJdbi(),
- providesDARCollectionDAO()
- );
+ providesDataAccessRequestDAO(), providesJdbi(), providesDARCollectionDAO());
}
@Provides
@@ -415,9 +396,7 @@ StudyDAO providesStudyDAO() {
@Provides
VoteServiceDAO providesVoteServiceDAO() {
- return new VoteServiceDAO(
- providesJdbi(),
- providesVoteDAO());
+ return new VoteServiceDAO(providesJdbi(), providesVoteDAO());
}
@Provides
@@ -447,16 +426,12 @@ DatasetDAO providesDatasetDAO() {
@Provides
DaaServiceDAO providesDaaServiceDAO() {
- return new DaaServiceDAO(
- providesJdbi(),
- providesDaaDAO(),
- providesFileStorageObjectDAO());
+ return new DaaServiceDAO(providesJdbi(), providesDaaDAO(), providesFileStorageObjectDAO());
}
@Provides
DacServiceDAO providesDacServiceDAO() {
- return new DacServiceDAO(
- providesJdbi());
+ return new DacServiceDAO(providesJdbi());
}
@Provides
@@ -491,7 +466,8 @@ DacService providesDacService() {
providesDataAccessRequestDAO(),
providesVoteService(),
providesDaaService(),
- providesDacServiceDAO(), providesDACAutomationRuleDAO());
+ providesDacServiceDAO(),
+ providesDACAutomationRuleDAO());
}
@Provides
@@ -505,8 +481,7 @@ ElasticSearchService providesElasticSearchService() {
providesInstitutionDAO(),
providesDatasetDAO(),
providesDatasetServiceDAO(),
- providesStudyDAO()
- );
+ providesStudyDAO());
}
@Provides
@@ -546,8 +521,7 @@ MetricsService providesMetricsService() {
providesDatasetDAO(),
providesDataAccessRequestDAO(),
providesDARCollectionDAO(),
- providesElectionDAO()
- );
+ providesElectionDAO());
}
@Provides
@@ -577,7 +551,10 @@ AcknowledgementDAO providesAcknowledgementDAO() {
@Provides
InstitutionService providesInstitutionService() {
- return new InstitutionService(providesInstitutionDAO(), providesUserDAO(), providesInstitutionAndLibraryCardEnforcement());
+ return new InstitutionService(
+ providesInstitutionDAO(),
+ providesUserDAO(),
+ providesInstitutionAndLibraryCardEnforcement());
}
@Provides
@@ -593,10 +570,7 @@ LibraryCardService providesLibraryCardService() {
@Provides
AcknowledgementService providesAcknowledgementService() {
return new AcknowledgementService(
- providesAcknowledgementDAO(),
- providesDataAccessRequestDAO(),
- providesEmailService()
- );
+ providesAcknowledgementDAO(), providesDataAccessRequestDAO(), providesEmailService());
}
@Provides
@@ -608,18 +582,13 @@ DatasetRegistrationService providesDatasetRegistrationService() {
providesGCSService(),
providesElasticSearchService(),
providesStudyDAO(),
- providesEmailService()
- );
+ providesEmailService());
}
@Provides
UserServiceDAO providesUserServiceDAO() {
return new UserServiceDAO(
- providesJdbi(),
- providesLibraryCardDAO(),
- providesUserDAO(),
- providesUserRoleDAO()
- );
+ providesJdbi(), providesLibraryCardDAO(), providesUserDAO(), providesUserRoleDAO());
}
@Provides
@@ -644,9 +613,7 @@ UserService providesUserService() {
@Provides
InstitutionAndLibraryCardEnforcement providesInstitutionAndLibraryCardEnforcement() {
- return new InstitutionAndLibraryCardEnforcement(
- providesJdbi(),
- providesUserServiceDAO());
+ return new InstitutionAndLibraryCardEnforcement(providesJdbi(), providesUserServiceDAO());
}
@Provides
@@ -695,14 +662,14 @@ DraftDAO providesDraftDAO() {
@Provides
DraftFileStorageServiceDAO providesDraftFileStorageService() {
- return new DraftFileStorageServiceDAO(providesJdbi(), providesGCSService(),
- providesFileStorageObjectDAO());
+ return new DraftFileStorageServiceDAO(
+ providesJdbi(), providesGCSService(), providesFileStorageObjectDAO());
}
@Provides
DraftServiceDAO providesDraftService() {
- return new DraftServiceDAO(providesJdbi(), providesDraftDAO(),
- providesDraftFileStorageService());
+ return new DraftServiceDAO(
+ providesJdbi(), providesDraftDAO(), providesDraftFileStorageService());
}
@Provides
diff --git a/src/main/java/org/broadinstitute/consent/http/authentication/AuthorizationHelper.java b/src/main/java/org/broadinstitute/consent/http/authentication/AuthorizationHelper.java
index 14de0afbfc..3eaebfab2e 100644
--- a/src/main/java/org/broadinstitute/consent/http/authentication/AuthorizationHelper.java
+++ b/src/main/java/org/broadinstitute/consent/http/authentication/AuthorizationHelper.java
@@ -27,8 +27,7 @@ public class AuthorizationHelper implements ConsentLogger {
protected final UserService userService;
@Inject
- public AuthorizationHelper(SamService samService,
- UserService userService) {
+ public AuthorizationHelper(SamService samService, UserService userService) {
this.claimsCache = ClaimsCache.getInstance();
this.samService = samService;
this.userService = userService;
@@ -48,10 +47,12 @@ protected AuthUser buildAuthUserFromHeaders(Map headers) {
name = email;
}
if (email == null) {
- logWarn(String.format(
- "Reading oauth2 claim headers: email is null, auth user is incomplete. Aud: %s Name: %s",
- aud, name));
- throw new NotAuthorizedException("You are not authorized to use this service without a valid email address.");
+ logWarn(
+ String.format(
+ "Reading oauth2 claim headers: email is null, auth user is incomplete. Aud: %s Name: %s",
+ aud, name));
+ throw new NotAuthorizedException(
+ "You are not authorized to use this service without a valid email address.");
} else {
try {
userService.enforceInstitutionAndLibraryCardRules(email);
@@ -96,7 +97,7 @@ protected UserStatusInfo getUserStatusInfo(DuosUser duosUser) {
* look for all roles they may have, returning true if any of them match the requested role.
*
* @param authUser AuthUser
- * @param role String role to check
+ * @param role String role to check
* @return True if the user has the role, false otherwise
*/
protected boolean authorize(AuthUser authUser, String role) {
@@ -109,5 +110,4 @@ protected boolean authorize(AuthUser authUser, String role) {
}
return authorize;
}
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/authentication/DuosUserAuthenticator.java b/src/main/java/org/broadinstitute/consent/http/authentication/DuosUserAuthenticator.java
index 6e48233b11..305290a75b 100644
--- a/src/main/java/org/broadinstitute/consent/http/authentication/DuosUserAuthenticator.java
+++ b/src/main/java/org/broadinstitute/consent/http/authentication/DuosUserAuthenticator.java
@@ -23,7 +23,8 @@ public Optional authenticate(String bearer) {
if (headers != null) {
AuthUser authUser = authorizationHelper.buildAuthUserFromHeaders(headers);
if (authUser.getEmail() != null) {
- authUser.setUserStatusInfo(authorizationHelper.getUserStatusInfo(new DuosUser(authUser, null)));
+ authUser.setUserStatusInfo(
+ authorizationHelper.getUserStatusInfo(new DuosUser(authUser, null)));
try {
User duosUser = authorizationHelper.userService.findUserByEmail(authUser.getEmail());
return Optional.of(new DuosUser(authUser, duosUser));
diff --git a/src/main/java/org/broadinstitute/consent/http/authentication/OAuthCustomAuthFilter.java b/src/main/java/org/broadinstitute/consent/http/authentication/OAuthCustomAuthFilter.java
index 8508b9b215..45995de7df 100644
--- a/src/main/java/org/broadinstitute/consent/http/authentication/OAuthCustomAuthFilter.java
+++ b/src/main/java/org/broadinstitute/consent/http/authentication/OAuthCustomAuthFilter.java
@@ -19,30 +19,34 @@ public class OAuthCustomAuthFilter extends AuthFilter()
- .setAuthenticator(authenticator)
- .setAuthorizer(new UserAuthorizer(authorizationHelper))
- .setPrefix("Bearer")
- .setRealm("OAUTH-AUTH")
- .buildAuthFilter();
+ public OAuthCustomAuthFilter(
+ OAuthAuthenticator authenticator, AuthorizationHelper authorizationHelper) {
+ filter =
+ new OAuthCredentialAuthFilter.Builder()
+ .setAuthenticator(authenticator)
+ .setAuthorizer(new UserAuthorizer(authorizationHelper))
+ .setPrefix("Bearer")
+ .setRealm("OAUTH-AUTH")
+ .buildAuthFilter();
}
/**
* Constructor for OAuthCustomAuthFilter intended to be used with DuosUsers.
*
* @param authenticator DuosUserAuthenticator
- * @param authorizationHelper AuthorizationHelper
+ * @param authorizationHelper AuthorizationHelper
*/
- public OAuthCustomAuthFilter(DuosUserAuthenticator authenticator, AuthorizationHelper authorizationHelper) {
- filter = new OAuthCredentialAuthFilter.Builder()
- .setAuthenticator(authenticator)
- .setAuthorizer(new DuosUserAuthorizer(authorizationHelper))
- .setPrefix("Bearer")
- .setRealm("OAUTH-AUTH")
- .buildAuthFilter();
+ public OAuthCustomAuthFilter(
+ DuosUserAuthenticator authenticator, AuthorizationHelper authorizationHelper) {
+ filter =
+ new OAuthCredentialAuthFilter.Builder()
+ .setAuthenticator(authenticator)
+ .setAuthorizer(new DuosUserAuthorizer(authorizationHelper))
+ .setPrefix("Bearer")
+ .setRealm("OAUTH-AUTH")
+ .buildAuthFilter();
}
@Override
diff --git a/src/main/java/org/broadinstitute/consent/http/cloudstore/GCSService.java b/src/main/java/org/broadinstitute/consent/http/cloudstore/GCSService.java
index 3c651bfe54..d6ad667a97 100644
--- a/src/main/java/org/broadinstitute/consent/http/cloudstore/GCSService.java
+++ b/src/main/java/org/broadinstitute/consent/http/cloudstore/GCSService.java
@@ -28,20 +28,20 @@ public class GCSService implements ConsentLogger {
private StoreConfiguration config;
private Storage storage;
- public GCSService() {
- }
+ public GCSService() {}
@Inject
public GCSService(StoreConfiguration config) {
this.config = config;
try {
- ServiceAccountCredentials credentials = ServiceAccountCredentials.
- fromStream(new FileInputStream(config.getPassword()));
- Storage storage = StorageOptions.newBuilder().
- setProjectId(credentials.getProjectId()).
- setCredentials(credentials).
- build().
- getService();
+ ServiceAccountCredentials credentials =
+ ServiceAccountCredentials.fromStream(new FileInputStream(config.getPassword()));
+ Storage storage =
+ StorageOptions.newBuilder()
+ .setProjectId(credentials.getProjectId())
+ .setCredentials(credentials)
+ .build()
+ .getService();
this.setStorage(storage);
} catch (Exception e) {
logException("Exception initializing GCSService: " + e.getMessage(), e);
@@ -65,21 +65,20 @@ protected void setConfig(StoreConfiguration config) {
* @return Bucket
*/
public Bucket getRootBucketWithMetadata() {
- return storage.get(config.getBucket(),
- Storage.BucketGetOption.fields(Storage.BucketField.values()));
+ return storage.get(
+ config.getBucket(), Storage.BucketGetOption.fields(Storage.BucketField.values()));
}
/**
* Store an input stream as a Blob
*
- * @param content InputStream content
+ * @param content InputStream content
* @param mediaType String media type
- * @param id String UUID of the file
+ * @param id String UUID of the file
* @return BlobId of the stored document
* @throws IOException Exception when storing document
*/
- public BlobId storeDocument(InputStream content, String mediaType, UUID id)
- throws IOException {
+ public BlobId storeDocument(InputStream content, String mediaType, UUID id) throws IOException {
byte[] bytes = IOUtils.toByteArray(content);
BlobId blobId = BlobId.of(config.getBucket(), id.toString());
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType(mediaType).build();
@@ -87,7 +86,6 @@ public BlobId storeDocument(InputStream content, String mediaType, UUID id)
return blob.getBlobId();
}
-
/**
* Delete a document by Blob Id Name
*
@@ -96,9 +94,7 @@ public BlobId storeDocument(InputStream content, String mediaType, UUID id)
*/
public boolean deleteDocument(String blobIdName) {
Optional blobOptional = getBlobFromUrl(blobIdName);
- return blobOptional
- .map(blob -> storage.delete(blob.getBlobId()))
- .orElse(false);
+ return blobOptional.map(blob -> storage.delete(blob.getBlobId())).orElse(false);
}
/**
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/ConsentConfiguration.java b/src/main/java/org/broadinstitute/consent/http/configurations/ConsentConfiguration.java
index d1dfc14ea6..53b0e6dba5 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/ConsentConfiguration.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/ConsentConfiguration.java
@@ -11,54 +11,34 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConsentConfiguration extends Configuration {
- public ConsentConfiguration() {
- }
+ public ConsentConfiguration() {}
- @Valid
- @NotNull
- @JsonProperty
- private final DataSourceFactory database = new DataSourceFactory();
+ @Valid @NotNull @JsonProperty private final DataSourceFactory database = new DataSourceFactory();
- @Valid
- @NotNull
- @JsonProperty
+ @Valid @NotNull @JsonProperty
private final StoreConfiguration googleStore = new StoreConfiguration();
- @Valid
- @NotNull
- @JsonProperty
+ @Valid @NotNull @JsonProperty
private final ServicesConfiguration services = new ServicesConfiguration();
- @Valid
- @NotNull
- private JerseyClientConfiguration httpClient = new JerseyClientConfiguration();
+ @Valid @NotNull private JerseyClientConfiguration httpClient = new JerseyClientConfiguration();
- @Valid
- @NotNull
- private MailConfiguration mailConfiguration = new MailConfiguration();
+ @Valid @NotNull private MailConfiguration mailConfiguration = new MailConfiguration();
- @Valid
- @NotNull
+ @Valid @NotNull
private FreeMarkerConfiguration freeMarkerConfiguration = new FreeMarkerConfiguration();
- @Valid
- @NotNull
- private GoogleOAuth2Config googleAuthentication = new GoogleOAuth2Config();
+ @Valid @NotNull private GoogleOAuth2Config googleAuthentication = new GoogleOAuth2Config();
@JsonProperty("httpClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
return httpClient;
}
-
- @Valid
- @NotNull
- @JsonProperty
+ @Valid @NotNull @JsonProperty
private final ElasticSearchConfiguration elasticSearch = new ElasticSearchConfiguration();
- @Valid
- @NotNull
- @JsonProperty
+ @Valid @NotNull @JsonProperty
private final OidcConfiguration oidcConfiguration = new OidcConfiguration();
public DataSourceFactory getDataSourceFactory() {
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/ElasticSearchConfiguration.java b/src/main/java/org/broadinstitute/consent/http/configurations/ElasticSearchConfiguration.java
index f2202be602..4beb8c82b9 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/ElasticSearchConfiguration.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/ElasticSearchConfiguration.java
@@ -7,18 +7,13 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class ElasticSearchConfiguration {
- @NotNull
- private String indexName;
+ @NotNull private String indexName;
- @NotNull
- private List servers;
+ @NotNull private List servers;
- @NotNull
- private String datasetIndexName;
+ @NotNull private String datasetIndexName;
- /**
- * This is configurable for testing purposes
- */
+ /** This is configurable for testing purposes */
private int port = 9200;
public List getServers() {
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/FreeMarkerConfiguration.java b/src/main/java/org/broadinstitute/consent/http/configurations/FreeMarkerConfiguration.java
index c529d7dd06..d63b957a50 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/FreeMarkerConfiguration.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/FreeMarkerConfiguration.java
@@ -6,11 +6,9 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class FreeMarkerConfiguration {
- @NotNull
- public String templateDirectory;
+ @NotNull public String templateDirectory;
- @NotNull
- public String defaultEncoding;
+ @NotNull public String defaultEncoding;
public String getTemplateDirectory() {
return templateDirectory;
@@ -27,5 +25,4 @@ public String getDefaultEncoding() {
public void setDefaultEncoding(String defaultEncoding) {
this.defaultEncoding = defaultEncoding;
}
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/GoogleOAuth2Config.java b/src/main/java/org/broadinstitute/consent/http/configurations/GoogleOAuth2Config.java
index ce1d4d1068..7ea044f074 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/GoogleOAuth2Config.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/GoogleOAuth2Config.java
@@ -6,8 +6,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class GoogleOAuth2Config {
- @NotNull
- public String clientId;
+ @NotNull public String clientId;
public String getClientId() {
return clientId;
@@ -16,5 +15,4 @@ public String getClientId() {
public void setClientId(String clientId) {
this.clientId = clientId;
}
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/MailConfiguration.java b/src/main/java/org/broadinstitute/consent/http/configurations/MailConfiguration.java
index f4125e8315..311ce970b7 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/MailConfiguration.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/MailConfiguration.java
@@ -6,17 +6,13 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class MailConfiguration {
- @NotNull
- private boolean activateEmailNotifications;
+ @NotNull private boolean activateEmailNotifications;
- @NotNull
- private String googleAccount;
+ @NotNull private String googleAccount;
- @NotNull
- private String sendGridApiKey;
+ @NotNull private String sendGridApiKey;
- @NotNull
- private String sendGridStatusUrl;
+ @NotNull private String sendGridStatusUrl;
public boolean isActivateEmailNotifications() {
return activateEmailNotifications;
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/OidcConfiguration.java b/src/main/java/org/broadinstitute/consent/http/configurations/OidcConfiguration.java
index 6163c8a532..68ba443a0d 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/OidcConfiguration.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/OidcConfiguration.java
@@ -3,8 +3,7 @@
import jakarta.validation.constraints.NotNull;
public class OidcConfiguration {
- @NotNull
- private String authorityEndpoint;
+ @NotNull private String authorityEndpoint;
private String extraAuthParams;
private boolean addClientIdToScope = false;
private String clientId;
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/ServicesConfiguration.java b/src/main/java/org/broadinstitute/consent/http/configurations/ServicesConfiguration.java
index a786edc2bf..b1c746b68f 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/ServicesConfiguration.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/ServicesConfiguration.java
@@ -21,17 +21,13 @@ public class ServicesConfiguration {
// nosemgrep
public static final String BROAD_ZENDESK_URL = "https://broadinstitute.zendesk.com";
- @NotNull
- private String ontologyURL;
+ @NotNull private String ontologyURL;
- @NotNull
- private String localURL;
+ @NotNull private String localURL;
- @NotNull
- private String samUrl;
+ @NotNull private String samUrl;
- @NotNull
- private String ecmUrl;
+ @NotNull private String ecmUrl;
/**
* This represents the max time we'll wait for an external status check to return. If it does not
@@ -57,7 +53,6 @@ public class ServicesConfiguration {
private boolean activateSupportNotifications = false;
-
public String getOntologyURL() {
return ontologyURL;
}
diff --git a/src/main/java/org/broadinstitute/consent/http/configurations/StoreConfiguration.java b/src/main/java/org/broadinstitute/consent/http/configurations/StoreConfiguration.java
index 87eb693fff..102ca51926 100644
--- a/src/main/java/org/broadinstitute/consent/http/configurations/StoreConfiguration.java
+++ b/src/main/java/org/broadinstitute/consent/http/configurations/StoreConfiguration.java
@@ -8,11 +8,9 @@ public class StoreConfiguration {
public String password;
- @NotNull
- public String endpoint;
+ @NotNull public String endpoint;
- @NotNull
- public String bucket;
+ @NotNull public String bucket;
public String getPassword() {
return password;
@@ -37,5 +35,4 @@ public String getBucket() {
public void setBucket(String bucket) {
this.bucket = bucket;
}
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/AcknowledgementDAO.java b/src/main/java/org/broadinstitute/consent/http/db/AcknowledgementDAO.java
index 167f6fa704..d9401d6028 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/AcknowledgementDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/AcknowledgementDAO.java
@@ -20,18 +20,22 @@ public interface AcknowledgementDAO extends Transactional {
+ " ON CONFLICT (ack_key, user_id) DO UPDATE SET last_acknowledged = current_timestamp ")
void upsertAcknowledgement(@Bind("key") String key, @Bind("userId") Integer userId);
- @SqlQuery("SELECT ack_key, user_id, first_acknowledged, last_acknowledged "
- + " FROM acknowledgement WHERE ack_key = :key and user_id = :userId")
- Acknowledgement findAcknowledgementsByKeyForUser(@Bind("key") String key,
- @Bind("userId") Integer userId);
-
- @SqlQuery("SELECT ack_key, user_id, first_acknowledged, last_acknowledged "
- + " FROM acknowledgement WHERE user_id = :userId")
+ @SqlQuery(
+ "SELECT ack_key, user_id, first_acknowledged, last_acknowledged "
+ + " FROM acknowledgement WHERE ack_key = :key and user_id = :userId")
+ Acknowledgement findAcknowledgementsByKeyForUser(
+ @Bind("key") String key, @Bind("userId") Integer userId);
+
+ @SqlQuery(
+ "SELECT ack_key, user_id, first_acknowledged, last_acknowledged "
+ + " FROM acknowledgement WHERE user_id = :userId")
List findAcknowledgementsForUser(@Bind("userId") Integer userId);
- @SqlQuery("SELECT ack_key, user_id, first_acknowledged, last_acknowledged "
- + " FROM acknowledgement WHERE user_id = :userId and ack_key IN ()")
- List findAcknowledgementsForUser(@BindList(value = "key_list", onEmpty = EmptyHandling.NULL_STRING) List keys,
+ @SqlQuery(
+ "SELECT ack_key, user_id, first_acknowledged, last_acknowledged "
+ + " FROM acknowledgement WHERE user_id = :userId and ack_key IN ()")
+ List findAcknowledgementsForUser(
+ @BindList(value = "key_list", onEmpty = EmptyHandling.NULL_STRING) List keys,
@Bind("userId") Integer userId);
@SqlUpdate("DELETE FROM acknowledgement where user_id = :userId AND ack_key = :key")
diff --git a/src/main/java/org/broadinstitute/consent/http/db/CounterDAO.java b/src/main/java/org/broadinstitute/consent/http/db/CounterDAO.java
index afe70dbc28..84e8e85344 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/CounterDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/CounterDAO.java
@@ -22,5 +22,4 @@ public interface CounterDAO extends Transactional {
+ " ) "
+ " SELECT MAX(count) FROM m WHERE name = :name ")
Integer incrementCountByName(@Bind("name") String name);
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DACAutomationRuleDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DACAutomationRuleDAO.java
index 78d36e9909..2e4ef320d0 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DACAutomationRuleDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DACAutomationRuleDAO.java
@@ -16,130 +16,147 @@
@RegisterRowMapper(DACAutomationRuleMapper.class)
public interface DACAutomationRuleDAO extends Transactional {
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT * FROM dac_automation_rules
""")
List findAll();
- default Integer auditedInsertDACRuleSetting(int dacId, int ruleId, int userId, Instant activationDate) {
- return inTransaction(d -> {
- Handle handle = getHandle();
- String auditSql = """
+ default Integer auditedInsertDACRuleSetting(
+ int dacId, int ruleId, int userId, Instant activationDate) {
+ return inTransaction(
+ d -> {
+ Handle handle = getHandle();
+ String auditSql =
+ """
INSERT INTO dac_rule_audit (action, dac_id, rule_id, user_id, action_date)
VALUES (:auditType::rule_audit_action, :dacId, :ruleId, :auditUserId, :actionDate)
""";
- String insertRuleSql = """
+ String insertRuleSql =
+ """
INSERT INTO dac_rule_settings (dac_id, rule_id, user_id, activation_date)
VALUES (:dacId, :ruleId, :userId, current_timestamp)
""";
- handle.createUpdate(auditSql)
- .bind("dacId", dacId)
- .bind("ruleId", ruleId)
- .bind("auditUserId", userId)
- .bind("auditType", RuleAuditAction.ADD)
- .bind("actionDate", activationDate)
- .execute();
+ handle
+ .createUpdate(auditSql)
+ .bind("dacId", dacId)
+ .bind("ruleId", ruleId)
+ .bind("auditUserId", userId)
+ .bind("auditType", RuleAuditAction.ADD)
+ .bind("actionDate", activationDate)
+ .execute();
- return handle.createUpdate(insertRuleSql)
- .bind("dacId", dacId)
- .bind("ruleId", ruleId)
- .bind("userId", userId)
- .executeAndReturnGeneratedKeys("id")
- .mapTo(Integer.class)
- .one();
- });
+ return handle
+ .createUpdate(insertRuleSql)
+ .bind("dacId", dacId)
+ .bind("ruleId", ruleId)
+ .bind("userId", userId)
+ .executeAndReturnGeneratedKeys("id")
+ .mapTo(Integer.class)
+ .one();
+ });
}
default void auditedDeleteDACRuleSetting(int dacId, int ruleId, int auditUserId) {
- useTransaction(d -> {
- Handle handle = getHandle();
- String auditSql = """
+ useTransaction(
+ d -> {
+ Handle handle = getHandle();
+ String auditSql =
+ """
INSERT INTO dac_rule_audit (action, dac_id, rule_id, user_id, action_date)
SELECT :auditType::rule_audit_action, s.dac_id, s.rule_id, :auditUserId, current_timestamp
FROM dac_rule_settings s
WHERE s.dac_id = :dacId AND s.rule_id = :ruleId
""";
- String deleteRuleSql = """
+ String deleteRuleSql =
+ """
DELETE FROM dac_rule_settings WHERE dac_id = :dacId AND rule_id = :ruleId
""";
- handle.createUpdate(auditSql)
- .bind("dacId", dacId)
- .bind("ruleId", ruleId)
- .bind("auditUserId", auditUserId)
- .bind("auditType", RuleAuditAction.REMOVE)
- .execute();
- handle.createUpdate(deleteRuleSql)
- .bind("dacId", dacId)
- .bind("ruleId", ruleId)
- .execute();
- handle.commit();
- });
+ handle
+ .createUpdate(auditSql)
+ .bind("dacId", dacId)
+ .bind("ruleId", ruleId)
+ .bind("auditUserId", auditUserId)
+ .bind("auditType", RuleAuditAction.REMOVE)
+ .execute();
+ handle.createUpdate(deleteRuleSql).bind("dacId", dacId).bind("ruleId", ruleId).execute();
+ handle.commit();
+ });
}
default Integer auditedDeleteDACRuleSettingByUser(int dacId, int userId, int auditUserId) {
- return inTransaction(d -> {
- Handle handle = getHandle();
- // Note that we're logging the audit user as the user for the audit record
- String auditSql = """
+ return inTransaction(
+ d -> {
+ Handle handle = getHandle();
+ // Note that we're logging the audit user as the user for the audit record
+ String auditSql =
+ """
INSERT INTO dac_rule_audit (action, dac_id, rule_id, user_id, action_date)
SELECT :auditType::rule_audit_action, s.dac_id, s.rule_id, :auditUserId, current_timestamp
FROM dac_rule_settings s
WHERE s.dac_id = :dacId AND s.user_id = :userId;
""";
- String deleteRuleSql = """
+ String deleteRuleSql =
+ """
DELETE FROM dac_rule_settings WHERE dac_id = :dacId AND user_id = :userId
""";
- handle.createUpdate(auditSql)
- .bind("dacId", dacId)
- .bind("userId", userId)
- .bind("auditUserId", auditUserId)
- .bind("auditType", RuleAuditAction.REMOVE)
- .execute();
- return handle.createUpdate(deleteRuleSql)
- .bind("dacId", dacId)
- .bind("userId", userId)
- .execute();
- });
+ handle
+ .createUpdate(auditSql)
+ .bind("dacId", dacId)
+ .bind("userId", userId)
+ .bind("auditUserId", auditUserId)
+ .bind("auditType", RuleAuditAction.REMOVE)
+ .execute();
+ return handle
+ .createUpdate(deleteRuleSql)
+ .bind("dacId", dacId)
+ .bind("userId", userId)
+ .execute();
+ });
}
default Integer auditedDeleteAllDACRuleSettingForUser(int userId, int auditUserId) {
- return inTransaction(d -> {
- Handle handle = getHandle();
- String auditSql = """
+ return inTransaction(
+ d -> {
+ Handle handle = getHandle();
+ String auditSql =
+ """
INSERT INTO dac_rule_audit (action, dac_id, rule_id, user_id, action_date)
SELECT :auditType::rule_audit_action, s.dac_id, s.rule_id, :auditUserId, current_timestamp
FROM dac_rule_settings s
WHERE s.user_id = :userId;
""";
- String deleteRulesSql = """
+ String deleteRulesSql =
+ """
DELETE FROM dac_rule_settings WHERE user_id = :userId
""";
- Integer count;
- handle.createUpdate(auditSql)
- .bind("auditUserId", auditUserId)
- .bind("userId", userId)
- .bind("auditType", RuleAuditAction.REMOVE)
- .execute();
- return handle.createUpdate(deleteRulesSql)
- .bind("userId", userId)
- .execute();
- });
+ Integer count;
+ handle
+ .createUpdate(auditSql)
+ .bind("auditUserId", auditUserId)
+ .bind("userId", userId)
+ .bind("auditType", RuleAuditAction.REMOVE)
+ .execute();
+ return handle.createUpdate(deleteRulesSql).bind("userId", userId).execute();
+ });
}
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT rules.*, settings.user_id, settings.activation_date, u.*
FROM dac_automation_rules rules
LEFT JOIN dac_rule_settings settings ON rules.id = settings.rule_id AND settings.dac_id = :dacId
- LEFT JOIN users u on settings.user_id = u.user_id
+ LEFT JOIN users u on settings.user_id = u.user_id
WHERE state = 'AVAILABLE'
""")
List findAllDACAutomationRulesByDACId(@Bind("dacId") int dacId);
@RegisterRowMapper(DACAutomationRuleAuditMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT a.action, a.action_date, r.rule, u.email, u.display_name from dac_rule_audit as a
LEFT JOIN dac_automation_rules as r on r.id = a.rule_id
LEFT JOIN users u on a.user_id = u.user_id
@@ -148,11 +165,11 @@ INSERT INTO dac_rule_audit (action, dac_id, rule_id, user_id, action_date)
LIMIT :limit
OFFSET :offset
""")
- List findAutomationAuditsForDac(@Bind("dacId") int dacId,
- @Bind("limit") int limit,
- @Bind("offset") int offset);
+ List findAutomationAuditsForDac(
+ @Bind("dacId") int dacId, @Bind("limit") int limit, @Bind("offset") int offset);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT count(*) from dac_rule_audit WHERE dac_id = :dacId
""")
Integer findCountOfAutomationAuditsForDac(@Bind("dacId") int dacId);
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DAOContainer.java b/src/main/java/org/broadinstitute/consent/http/db/DAOContainer.java
index a45febc154..71664d451e 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DAOContainer.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DAOContainer.java
@@ -2,9 +2,8 @@
/**
* Generic container class for DAOs that can be used in service constructors to simplify instance
- * creation.
- * Per feedback in https://github.com/DataBiosphere/consent/pull/2408
- * 'We should only expand this usage if necessary.'
+ * creation. Per feedback in https://github.com/DataBiosphere/consent/pull/2408 'We should only
+ * expand this usage if necessary.'
*/
@SuppressWarnings("unused")
public class DAOContainer {
@@ -48,8 +47,7 @@ public DataAccessRequestDAO getDataAccessRequestDAO() {
return dataAccessRequestDAO;
}
- public void setDataAccessRequestDAO(
- DataAccessRequestDAO dataAccessRequestDAO) {
+ public void setDataAccessRequestDAO(DataAccessRequestDAO dataAccessRequestDAO) {
this.dataAccessRequestDAO = dataAccessRequestDAO;
}
@@ -61,14 +59,11 @@ public DarCollectionSummaryDAO getDarCollectionSummaryDAO() {
return darCollectionSummaryDAO;
}
- public void setDarCollectionDAO(
- DarCollectionDAO darCollectionDAO) {
+ public void setDarCollectionDAO(DarCollectionDAO darCollectionDAO) {
this.darCollectionDAO = darCollectionDAO;
}
- public void setDarCollectionSummaryDAO(
- DarCollectionSummaryDAO darCollectionSummaryDAO
- ) {
+ public void setDarCollectionSummaryDAO(DarCollectionSummaryDAO darCollectionSummaryDAO) {
this.darCollectionSummaryDAO = darCollectionSummaryDAO;
}
@@ -80,7 +75,8 @@ public void setDatasetDAO(DatasetDAO datasetDAO) {
this.datasetDAO = datasetDAO;
}
- public void setDatasetAuthorizationReaderDAO(DatasetAuthorizationReaderDAO datasetAuthorizationReaderDAO) {
+ public void setDatasetAuthorizationReaderDAO(
+ DatasetAuthorizationReaderDAO datasetAuthorizationReaderDAO) {
this.datasetAuthorizationReaderDAO = datasetAuthorizationReaderDAO;
}
@@ -116,8 +112,7 @@ public UserPropertyDAO getUserPropertyDAO() {
return userPropertyDAO;
}
- public void setUserPropertyDAO(
- UserPropertyDAO userPropertyDAO) {
+ public void setUserPropertyDAO(UserPropertyDAO userPropertyDAO) {
this.userPropertyDAO = userPropertyDAO;
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DaaDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DaaDAO.java
index 42e4af9b75..5765da792e 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DaaDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DaaDAO.java
@@ -1,7 +1,6 @@
package org.broadinstitute.consent.http.db;
import java.time.Instant;
-import java.util.Date;
import java.util.List;
import org.broadinstitute.consent.http.db.mapper.DaaMapper;
import org.broadinstitute.consent.http.db.mapper.DataAccessAgreementReducer;
@@ -30,7 +29,8 @@ public interface DaaDAO extends Transactional {
@RegisterBeanMapper(value = Dac.class)
@RegisterBeanMapper(value = FileStorageObjectDAO.class)
@UseRowReducer(DataAccessAgreementReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT daa.daa_id as daa_daa_id,
daa.create_user_id as daa_create_user_id,
daa.create_date as daa_create_date,
@@ -60,7 +60,6 @@ public interface DaaDAO extends Transactional {
""")
List findAll();
-
/**
* Find a DAA by id
*
@@ -71,7 +70,8 @@ public interface DaaDAO extends Transactional {
@RegisterBeanMapper(value = Dac.class)
@RegisterBeanMapper(value = FileStorageObjectDAO.class)
@UseRowReducer(DataAccessAgreementReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT daa.daa_id as daa_daa_id,
daa.create_user_id as daa_create_user_id,
daa.create_date as daa_create_date,
@@ -112,11 +112,12 @@ public interface DaaDAO extends Transactional {
@RegisterBeanMapper(value = Dac.class)
@RegisterBeanMapper(value = FileStorageObjectDAO.class)
@UseRowReducer(DataAccessAgreementReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT daa.daa_id as daa_daa_id,
daa.create_user_id as daa_create_user_id,
daa.create_date as daa_create_date,
- daa.update_user_id as daa_update_user_id,
+ daa.update_user_id as daa_update_user_id,
daa.update_date as daa_update_date,
daa.initial_dac_id as daa_initial_dac_id,
fso.file_storage_object_id AS file_storage_object_id,
@@ -147,29 +148,35 @@ public interface DaaDAO extends Transactional {
* Create a Daa given name, description, and create date
*
* @param createUserId The id of the user who created this DAA
- * @param createDate The date this new DAA was created
+ * @param createDate The date this new DAA was created
* @param updateUserId The id of the user who updated this DAA
- * @param updateDate The date that this DAA was updated
+ * @param updateDate The date that this DAA was updated
* @param initialDacId The id for the initial DAC this DAA was created for
* @return Integer
*/
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO data_access_agreement (create_user_id, create_date, update_user_id, update_date, initial_dac_id)
VALUES (:createUserId, :createDate, :updateUserId, :updateDate, :initialDacId)
""")
@GetGeneratedKeys
- Integer createDaa(@Bind("createUserId") Integer createUserId,
- @Bind("createDate") Instant createDate, @Bind("updateUserId") Integer updateUserId,
- @Bind("updateDate") Instant updateDate, @Bind("initialDacId") Integer initialDacId);
+ Integer createDaa(
+ @Bind("createUserId") Integer createUserId,
+ @Bind("createDate") Instant createDate,
+ @Bind("updateUserId") Integer updateUserId,
+ @Bind("updateDate") Instant updateDate,
+ @Bind("initialDacId") Integer initialDacId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO dac_daa (dac_id, daa_id)
VALUES (:dacId, :daaId)
ON CONFLICT (dac_id) DO UPDATE SET daa_id = :daaId
""")
void createDacDaaRelation(@Bind("dacId") Integer dacId, @Bind("daaId") Integer daaId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
DELETE FROM dac_daa
WHERE dac_id = :dacId
AND daa_id = :daaId
@@ -177,8 +184,8 @@ ON CONFLICT (dac_id) DO UPDATE SET daa_id = :daaId
void deleteDacDaaRelation(@Bind("dacId") Integer dacId, @Bind("daaId") Integer daaId);
/**
- * Relationship chain:
- * User -> Library Card -> Data Access Agreement -> DAC -> Dataset
+ * Relationship chain: User -> Library Card -> Data Access Agreement -> DAC -> Dataset
+ *
* @param userId The requesting User ID
* @return List of Dataset Ids for which a user has DAA acceptances
*/
@@ -193,7 +200,8 @@ ON CONFLICT (dac_id) DO UPDATE SET daa_id = :daaId
""")
List findDaaDatasetIdsByUserId(@Bind("userId") Integer userId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
WITH lc_deletes AS (DELETE FROM lc_daa WHERE lc_daa.daa_id = :daaId),
dac_delete AS (DELETE FROM dac_daa WHERE dac_daa.daa_id = :daaId)
DELETE FROM data_access_agreement WHERE daa_id = :daaId
@@ -201,8 +209,8 @@ dac_delete AS (DELETE FROM dac_daa WHERE dac_daa.daa_id = :daaId)
void deleteDaa(@Bind("daaId") Integer daaId);
/**
- * Find all DAAs for a Data Access Request by Reference ID
- * DAR -> dar dataset join table -> Dataset -> DAC -> dac daa join table -> DAA
+ * Find all DAAs for a Data Access Request by Reference ID DAR -> dar dataset join table ->
+ * Dataset -> DAC -> dac daa join table -> DAA
*
* @param referenceId DAR Reference ID
* @return List of Data Access Agreements
@@ -211,11 +219,12 @@ dac_delete AS (DELETE FROM dac_daa WHERE dac_daa.daa_id = :daaId)
@RegisterBeanMapper(value = Dac.class)
@RegisterBeanMapper(value = FileStorageObjectDAO.class)
@UseRowReducer(DataAccessAgreementReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT daa.daa_id as daa_daa_id,
daa.create_user_id as daa_create_user_id,
daa.create_date as daa_create_date,
- daa.update_user_id as daa_update_user_id,
+ daa.update_user_id as daa_update_user_id,
daa.update_date as daa_update_date,
daa.initial_dac_id as daa_initial_dac_id,
fso.file_storage_object_id AS file_storage_object_id,
@@ -239,9 +248,8 @@ dac_delete AS (DELETE FROM dac_daa WHERE dac_daa.daa_id = :daaId)
INNER JOIN dac_daa ON daa.daa_id = dac_daa.daa_id
INNER JOIN dac ON dac.dac_id = dac_daa.dac_id
INNER JOIN dataset ON dataset.dac_id = dac.dac_id
- INNER JOIN dar_dataset dd on dd.dataset_id = dataset.dataset_id
+ INNER JOIN dar_dataset dd on dd.dataset_id = dataset.dataset_id
WHERE dd.reference_id = :referenceId
""")
List findByDarReferenceId(@Bind("referenceId") String referenceId);
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DacDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DacDAO.java
index bfd807facf..24b6deb295 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DacDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DacDAO.java
@@ -45,7 +45,8 @@ public interface DacDAO extends Transactional {
@RegisterBeanMapper(value = Dac.class)
@RegisterBeanMapper(value = Dataset.class)
@UseRowReducer(DacReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT
dac.dac_id,
dac.email,
@@ -98,7 +99,9 @@ public interface DacDAO extends Transactional {
@RegisterBeanMapper(value = UserRole.class)
@UseRowReducer(UserWithRolesReducer.class)
@SqlQuery(
- "SELECT " + User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR
+ "SELECT "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ " r.name, "
+ " ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id "
+ " FROM users u "
@@ -130,7 +133,8 @@ public interface DacDAO extends Transactional {
@RegisterBeanMapper(value = DataAccessAgreement.class, prefix = "daa")
@RegisterBeanMapper(value = FileStorageObjectDAO.class)
@UseRowReducer(DacReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT dac.*,
daa.daa_id as daa_daa_id,
daa.create_user_id as daa_create_user_id,
@@ -161,38 +165,47 @@ public interface DacDAO extends Transactional {
/**
* Create a Dac given name, description, and create date
*
- * @param name The name for the new DAC
+ * @param name The name for the new DAC
* @param description The description for the new DAC
- * @param createDate The date this new DAC was created
+ * @param createDate The date this new DAC was created
* @return Integer
*/
- @SqlUpdate("INSERT INTO dac (name, description, create_date) VALUES (:name, :description, :createDate)")
+ @SqlUpdate(
+ "INSERT INTO dac (name, description, create_date) VALUES (:name, :description, :createDate)")
@GetGeneratedKeys
- Integer createDac(@Bind("name") String name, @Bind("description") String description,
+ Integer createDac(
+ @Bind("name") String name,
+ @Bind("description") String description,
@Bind("createDate") Date createDate);
/**
* Create a Dac given name, description, and create date
*
- * @param name The name for the new DAC
+ * @param name The name for the new DAC
* @param description The description for the new DAC
- * @param email The email for the new DAC
- * @param createDate The date this new DAC was created
+ * @param email The email for the new DAC
+ * @param createDate The date this new DAC was created
* @return Integer
*/
- @SqlUpdate("INSERT INTO dac (name, description, email, create_date) VALUES (:name, :description, :email, :createDate)")
+ @SqlUpdate(
+ "INSERT INTO dac (name, description, email, create_date) VALUES (:name, :description, :email, :createDate)")
@GetGeneratedKeys
- Integer createDac(@Bind("name") String name, @Bind("description") String description,
- @Bind("email") String email, @Bind("createDate") Date createDate);
+ Integer createDac(
+ @Bind("name") String name,
+ @Bind("description") String description,
+ @Bind("email") String email,
+ @Bind("createDate") Date createDate);
- @SqlUpdate("UPDATE dac SET name = :name, description = :description, update_date = :updateDate WHERE dac_id = :dacId")
+ @SqlUpdate(
+ "UPDATE dac SET name = :name, description = :description, update_date = :updateDate WHERE dac_id = :dacId")
void updateDac(
@Bind("name") String name,
@Bind("description") String description,
@Bind("updateDate") Date updateDate,
@Bind("dacId") Integer dacId);
- @SqlUpdate("UPDATE dac SET name = :name, description = :description, email = :email, update_date = :updateDate WHERE dac_id = :dacId")
+ @SqlUpdate(
+ "UPDATE dac SET name = :name, description = :description, email = :email, update_date = :updateDate WHERE dac_id = :dacId")
void updateDac(
@Bind("name") String name,
@Bind("description") String description,
@@ -215,7 +228,9 @@ void updateDac(
@RegisterBeanMapper(value = UserRole.class)
@UseRowReducer(UserWithRolesReducer.class)
@SqlQuery(
- "SELECT " + User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR
+ "SELECT "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ " ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id, r.name "
+ " FROM users u "
+ " INNER JOIN user_role ur ON ur.user_id = u.user_id "
@@ -227,19 +242,21 @@ void updateDac(
@RegisterBeanMapper(value = UserRole.class)
@UseRowReducer(UserWithRolesReducer.class)
@SqlQuery(
- "SELECT " + User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR
+ "SELECT "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ " ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id, r.name "
+ " FROM users u "
+ " INNER JOIN user_role ur ON ur.user_id = u.user_id "
+ " INNER JOIN roles r ON r.role_id = ur.role_id "
+ " WHERE ur.dac_id = :dacId "
+ " AND ur.role_id = :roleId ")
- List findMembersByDacIdAndRoleId(@Bind("dacId") Integer dacId,
- @Bind("roleId") Integer roleId);
+ List findMembersByDacIdAndRoleId(
+ @Bind("dacId") Integer dacId, @Bind("roleId") Integer roleId);
@SqlUpdate("INSERT INTO user_role (role_id, user_id, dac_id) VALUES (:roleId, :userId, :dacId)")
- void addDacMember(@Bind("roleId") Integer roleId, @Bind("userId") Integer userId,
- @Bind("dacId") Integer dacId);
+ void addDacMember(
+ @Bind("roleId") Integer roleId, @Bind("userId") Integer userId, @Bind("dacId") Integer dacId);
@SqlUpdate("DELETE FROM user_role WHERE user_role_id = :userRoleId")
void removeDacMember(@Bind("userRoleId") Integer userRoleId);
@@ -252,7 +269,8 @@ void addDacMember(@Bind("roleId") Integer roleId, @Bind("userId") Integer userId
@SqlQuery(
"SELECT ur.*, r.name FROM user_role ur "
+ " INNER JOIN roles r ON ur.role_id = r.role_id WHERE ur.user_id IN ()")
- List findUserRolesForUsers(@BindList(value = "userIds", onEmpty = EmptyHandling.NULL_STRING) List userIds);
+ List findUserRolesForUsers(
+ @BindList(value = "userIds", onEmpty = EmptyHandling.NULL_STRING) List userIds);
/**
* Find the Dacs for these datasets.
@@ -261,16 +279,20 @@ void addDacMember(@Bind("roleId") Integer roleId, @Bind("userId") Integer userId
* @return All DACs that corresponds to the provided dataset ids
*/
@RegisterRowMapper(DacMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.*, ds.dataset_id
FROM dac d
INNER JOIN dataset ds ON d.dac_id = ds.dac_id
WHERE ds.dataset_id IN ()
""")
- Set findDacsForDatasetIds(@BindList(value = "datasetIds", onEmpty = EmptyHandling.NULL_STRING) List datasetIds);
+ Set findDacsForDatasetIds(
+ @BindList(value = "datasetIds", onEmpty = EmptyHandling.NULL_STRING)
+ List datasetIds);
@RegisterRowMapper(DacMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT dac.*
FROM dac
INNER JOIN dataset d ON d.dac_id = dac.dac_id
@@ -279,5 +301,4 @@ WHERE ds.dataset_id IN ()
WHERE dar.collection_id = :collectionId
""")
Collection findDacsForCollectionId(@Bind("collectionId") Integer collectionId);
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DarCollectionDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DarCollectionDAO.java
index 9ff70c12c8..72ca3e6a1b 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DarCollectionDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DarCollectionDAO.java
@@ -26,32 +26,34 @@ public interface DarCollectionDAO extends Transactional {
String QUERY_FIELD_SEPARATOR = ", ";
String getCollectionAndDars =
- " SELECT c.*, i.institution_name, u.display_name AS researcher, dd.dataset_id, " +
- User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR +
- Institution.QUERY_FIELDS_WITH_I_PREFIX + QUERY_FIELD_SEPARATOR +
- Election.QUERY_FIELDS_WITH_E_PREFIX + QUERY_FIELD_SEPARATOR +
- Vote.QUERY_FIELDS_WITH_V_PREFIX + QUERY_FIELD_SEPARATOR +
- UserProperty.QUERY_FIELDS_WITH_UP_PREFIX + QUERY_FIELD_SEPARATOR +
- DarCollection.DAR_FILTER_QUERY_COLUMNS +
- " FROM dar_collection c " +
- " INNER JOIN users u ON u.user_id = c.create_user_id " +
- " LEFT JOIN user_property up ON u.user_id = up.user_id AND up.property_key in ('isThePI', 'piName', 'havePI', 'piERACommonsID') "
- +
- " LEFT JOIN institution i ON i.institution_id = u.institution_id " +
- " INNER JOIN data_access_request dar ON c.collection_id = dar.collection_id " +
- " LEFT JOIN dar_dataset dd ON dd.reference_id = dar.reference_id " +
- " LEFT JOIN (" +
- " SELECT election.*, MAX(election.election_id) OVER (PARTITION BY election.reference_id, election.election_type, election.dataset_id) AS latest "
- +
- " FROM election " +
- " WHERE LOWER(election.election_type) = 'dataaccess' OR LOWER(election.election_type) = 'rp'"
- +
- " ) AS e " +
- " ON (dar.reference_id = e.reference_id AND dd.dataset_id = e.dataset_id) AND (e.latest = e.election_id OR e.latest IS NULL) "
- +
- " LEFT JOIN vote v ON v.election_id = e.election_id ";
+ " SELECT c.*, i.institution_name, u.display_name AS researcher, dd.dataset_id, "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + Institution.QUERY_FIELDS_WITH_I_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + Election.QUERY_FIELDS_WITH_E_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + Vote.QUERY_FIELDS_WITH_V_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + UserProperty.QUERY_FIELDS_WITH_UP_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + DarCollection.DAR_FILTER_QUERY_COLUMNS
+ + " FROM dar_collection c "
+ + " INNER JOIN users u ON u.user_id = c.create_user_id "
+ + " LEFT JOIN user_property up ON u.user_id = up.user_id AND up.property_key in ('isThePI', 'piName', 'havePI', 'piERACommonsID') "
+ + " LEFT JOIN institution i ON i.institution_id = u.institution_id "
+ + " INNER JOIN data_access_request dar ON c.collection_id = dar.collection_id "
+ + " LEFT JOIN dar_dataset dd ON dd.reference_id = dar.reference_id "
+ + " LEFT JOIN ("
+ + " SELECT election.*, MAX(election.election_id) OVER (PARTITION BY election.reference_id, election.election_type, election.dataset_id) AS latest "
+ + " FROM election "
+ + " WHERE LOWER(election.election_type) = 'dataaccess' OR LOWER(election.election_type) = 'rp'"
+ + " ) AS e "
+ + " ON (dar.reference_id = e.reference_id AND dd.dataset_id = e.dataset_id) AND (e.latest = e.election_id OR e.latest IS NULL) "
+ + " LEFT JOIN vote v ON v.election_id = e.election_id ";
- String archiveFilterQuery = " AND (LOWER(data->>'status') != 'archived' OR data->>'status' IS NULL) ";
+ String archiveFilterQuery =
+ " AND (LOWER(data->>'status') != 'archived' OR data->>'status' IS NULL) ";
@RegisterBeanMapper(value = User.class, prefix = "u")
@RegisterBeanMapper(value = Institution.class, prefix = "i")
@@ -64,7 +66,8 @@ public interface DarCollectionDAO extends Transactional {
@SqlQuery(
getCollectionAndDars + " WHERE c.collection_id in ()" + archiveFilterQuery)
List findDARCollectionByCollectionIds(
- @BindList(value = "collectionIds", onEmpty = EmptyHandling.NULL_STRING) List collectionIds);
+ @BindList(value = "collectionIds", onEmpty = EmptyHandling.NULL_STRING)
+ List collectionIds);
/**
* Find all DARCollections with their DataAccessRequests
@@ -79,35 +82,34 @@ List findDARCollectionByCollectionIds(
@RegisterBeanMapper(value = Election.class, prefix = "e")
@UseRowReducer(DarCollectionReducer.class)
@SqlQuery(
- " SELECT c.*, " +
- User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR +
- Institution.QUERY_FIELDS_WITH_I_PREFIX + QUERY_FIELD_SEPARATOR +
- UserProperty.QUERY_FIELDS_WITH_UP_PREFIX + QUERY_FIELD_SEPARATOR +
- Election.QUERY_FIELDS_WITH_E_PREFIX + QUERY_FIELD_SEPARATOR +
- "dd.dataset_id, " +
- "dar.id AS dar_id, dar.reference_id AS dar_reference_id, dar.collection_id AS dar_collection_id, "
- +
- "dar.parent_id AS dar_parent_id, dar.user_id AS dar_userId, " +
- "dar.create_date AS dar_create_date, dar.submission_date AS dar_submission_date, " +
- "dar.closeout_so_approval_timestamp AS dar_closeout_signing_official_approved_date, "+
- "dar.closeout_approving_so_id AS dar_closeout_signing_official_approved_user_id, " +
- "dar.update_date AS dar_update_date, (dar.data #>> '{}')::jsonb AS data " +
- "FROM dar_collection c " +
- "INNER JOIN users u ON c.create_user_id = u.user_id " +
- "LEFT JOIN user_property up ON u.user_id = up.user_id " +
- "INNER JOIN data_access_request dar on c.collection_id = dar.collection_id " +
- "LEFT JOIN dar_dataset dd on dd.reference_id = dar.reference_id " +
- "LEFT JOIN institution i ON i.institution_id = u.institution_id " +
- "LEFT JOIN (" +
- " SELECT election.*, MAX(election.election_id) OVER (PARTITION BY election.reference_id, election.election_type, election.dataset_id) AS latest FROM election "
- +
- " WHERE LOWER(election.election_type) = 'dataaccess' OR LOWER(election.election_type) = 'rp' "
- +
- ") AS e " +
- " ON (dar.reference_id = e.reference_id AND dd.dataset_id = e.dataset_id) AND (e.latest = e.election_id OR e.latest IS NULL) "
- +
- "WHERE (LOWER(data->>'status')!='archived' OR data->>'status' IS NULL) "
- )
+ " SELECT c.*, "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + Institution.QUERY_FIELDS_WITH_I_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + UserProperty.QUERY_FIELDS_WITH_UP_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + Election.QUERY_FIELDS_WITH_E_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + "dd.dataset_id, "
+ + "dar.id AS dar_id, dar.reference_id AS dar_reference_id, dar.collection_id AS dar_collection_id, "
+ + "dar.parent_id AS dar_parent_id, dar.user_id AS dar_userId, "
+ + "dar.create_date AS dar_create_date, dar.submission_date AS dar_submission_date, "
+ + "dar.closeout_so_approval_timestamp AS dar_closeout_signing_official_approved_date, "
+ + "dar.closeout_approving_so_id AS dar_closeout_signing_official_approved_user_id, "
+ + "dar.update_date AS dar_update_date, (dar.data #>> '{}')::jsonb AS data "
+ + "FROM dar_collection c "
+ + "INNER JOIN users u ON c.create_user_id = u.user_id "
+ + "LEFT JOIN user_property up ON u.user_id = up.user_id "
+ + "INNER JOIN data_access_request dar on c.collection_id = dar.collection_id "
+ + "LEFT JOIN dar_dataset dd on dd.reference_id = dar.reference_id "
+ + "LEFT JOIN institution i ON i.institution_id = u.institution_id "
+ + "LEFT JOIN ("
+ + " SELECT election.*, MAX(election.election_id) OVER (PARTITION BY election.reference_id, election.election_type, election.dataset_id) AS latest FROM election "
+ + " WHERE LOWER(election.election_type) = 'dataaccess' OR LOWER(election.election_type) = 'rp' "
+ + ") AS e "
+ + " ON (dar.reference_id = e.reference_id AND dd.dataset_id = e.dataset_id) AND (e.latest = e.election_id OR e.latest IS NULL) "
+ + "WHERE (LOWER(data->>'status')!='archived' OR data->>'status' IS NULL) ")
List findAllDARCollections();
/**
@@ -166,10 +168,14 @@ List findDARCollectionByCollectionIds(
@SqlQuery(
// nosemgrep
"SELECT c.*, "
- + User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR
- + Institution.QUERY_FIELDS_WITH_I_PREFIX + QUERY_FIELD_SEPARATOR
- + UserProperty.QUERY_FIELDS_WITH_UP_PREFIX + QUERY_FIELD_SEPARATOR
- + LibraryCard.QUERY_FIELDS_WITH_LC_PREFIX + QUERY_FIELD_SEPARATOR
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + Institution.QUERY_FIELDS_WITH_I_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + UserProperty.QUERY_FIELDS_WITH_UP_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + LibraryCard.QUERY_FIELDS_WITH_LC_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ "dd.dataset_id, "
+ "dar.id AS dar_id, dar.reference_id AS dar_reference_id, dar.collection_id AS dar_collection_id, "
+ "dar.parent_id AS dar_parent_id, dar.user_id AS dar_userId, dar.era_commons_id AS dar_era_commons_id, "
@@ -199,8 +205,7 @@ List findDARCollectionByCollectionIds(
+ "LEFT JOIN users du "
+ "ON du.user_id = v.user_id "
+ "WHERE c.collection_id = :collectionId "
- + "AND (LOWER(data->>'status') != 'archived' OR data->>'status' IS NULL )"
- )
+ + "AND (LOWER(data->>'status') != 'archived' OR data->>'status' IS NULL )")
DarCollection findDARCollectionByCollectionId(@Bind("collectionId") Integer collectionId);
/**
@@ -220,7 +225,7 @@ List findDARCollectionByCollectionIds(
@RegisterBeanMapper(value = LibraryCard.class, prefix = "lc")
@UseRowReducer(DarCollectionReducer.class)
@SqlQuery(
- """
+"""
SELECT c.*,
u.user_id as u_user_id, u.email as u_email, u.display_name as u_display_name, u.create_date as u_create_date, u.email_preference as u_email_preference, u.institution_id as u_institution_id, u.era_commons_id as u_era_commons_id,
i.institution_id as i_id, i.institution_name as i_name, i.it_director_name as i_it_director_name, i.it_director_email as i_it_director_email, i.create_date as i_create_date, i.update_date as i_update_date,
@@ -252,15 +257,15 @@ List findDARCollectionByCollectionIds(
ON du.user_id = v.user_id
WHERE c.collection_id = :collectionId
AND (LOWER(data->>'status') != 'archived' OR data->>'status' IS NULL )
-"""
- )
- DarCollection findCollectionWithAllElectionsByCollectionId(@Bind("collectionId") Integer collectionId);
-
+""")
+ DarCollection findCollectionWithAllElectionsByCollectionId(
+ @Bind("collectionId") Integer collectionId);
/**
* Find the DARCollection and all of its Data Access Requests that has the given collectionId
- * Instead of including all elections for each DAR like findCollectionWithAllElectionsByCollectionId
- * this query returns only elections for the datasets in the given datasetIds list
+ * Instead of including all elections for each DAR like
+ * findCollectionWithAllElectionsByCollectionId this query returns only elections for the datasets
+ * in the given datasetIds list
*
* @return DarCollection
*/
@@ -307,9 +312,10 @@ List findDARCollectionByCollectionIds(
ON du.user_id = v.user_id
WHERE c.collection_id = :collectionId
AND (LOWER(data->>'status') != 'archived' OR data->>'status' IS NULL )
- """
- )
- DarCollection findCollectionWithElectionsByCollectionIdAndDatasetIds(@BindList(value = "datasetIds", onEmpty = EmptyHandling.NULL_STRING) List datasetIds, @Bind("collectionId") Integer collectionId);
+ """)
+ DarCollection findCollectionWithElectionsByCollectionIdAndDatasetIds(
+ @BindList(value = "datasetIds", onEmpty = EmptyHandling.NULL_STRING) List datasetIds,
+ @Bind("collectionId") Integer collectionId);
/**
* Create a new DAR Collection with the given dar code, create user ID, and create date
@@ -323,22 +329,16 @@ List findDARCollectionByCollectionIds(
VALUES (:darCode, :createUserId, :createDate)
""")
@GetGeneratedKeys
- Integer insertDarCollection(@Bind("darCode") String darCode,
+ Integer insertDarCollection(
+ @Bind("darCode") String darCode,
@Bind("createUserId") Integer createUserId,
@Bind("createDate") Date createDate);
- /**
- * Update the update user and update date of the DAR Collection with the given collection ID
- */
- @SqlUpdate("UPDATE dar_collection SET update_user_id = :updateUserId, update_date = :updateDate WHERE collection_id = :collectionId")
- void updateDarCollection(@Bind("collectionId") Integer collectionId,
+ /** Update the update user and update date of the DAR Collection with the given collection ID */
+ @SqlUpdate(
+ "UPDATE dar_collection SET update_user_id = :updateUserId, update_date = :updateDate WHERE collection_id = :collectionId")
+ void updateDarCollection(
+ @Bind("collectionId") Integer collectionId,
@Bind("updateUserId") Integer updateUserId,
@Bind("updateDate") Date updateDate);
-
}
-
-
-
-
-
-
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DarCollectionSummaryDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DarCollectionSummaryDAO.java
index 219d4150c8..984f2edfb9 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DarCollectionSummaryDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DarCollectionSummaryDAO.java
@@ -21,7 +21,8 @@ public interface DarCollectionSummaryDAO extends Transactional getDarCollectionSummariesForDACRole(
@RegisterBeanMapper(value = DarCollection.class)
@RegisterBeanMapper(value = Election.class)
@UseRowReducer(DarCollectionSummaryReducer.class)
- @SqlQuery
- (
- """
+ @SqlQuery(
+ """
SELECT c.collection_id as dar_collection_id,
c.dar_code,
latest_dar.submission_date,
@@ -153,8 +153,7 @@ WHERE LOWER(election.election_type) = 'dataaccess'
latest_dar.closeout_approving_so_id, latest_dar.closeout_so_approval_timestamp,
u.display_name, i.institution_name, e.election_id, e.status,
e.reference_id, e.dataset_id, dd.dataset_id, latest_dar.data, dac.name
- """
- )
+ """)
List getDarCollectionSummariesForSO(
@Bind("institutionId") Integer institutionId);
@@ -162,7 +161,8 @@ List getDarCollectionSummariesForSO(
@RegisterBeanMapper(value = DarCollection.class)
@RegisterBeanMapper(value = Election.class)
@UseRowReducer(DarCollectionSummaryReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT
c.collection_id AS dar_collection_id,
c.dar_code,
@@ -217,7 +217,8 @@ WHERE LOWER(election.election_type) = 'dataaccess'
@RegisterBeanMapper(value = DarCollection.class)
@RegisterBeanMapper(value = Election.class)
@UseRowReducer(DarCollectionSummaryReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT
c.collection_id AS dar_collection_id,
c.dar_code,
@@ -280,7 +281,8 @@ WHERE LOWER(election.election_type) = 'dataaccess'
@RegisterBeanMapper(value = Vote.class, prefix = "v")
@RegisterBeanMapper(value = Election.class)
@UseRowReducer(DarCollectionSummaryReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT c.collection_id as dar_collection_id, c.dar_code, latest_dar.submission_date, latest_dar.reference_id AS latest_dar_reference_id,
latest_dar.parent_id AS latest_dar_parent_id,
latest_dar.closeout_approving_so_id as latest_dar_closeout_approving_so_id,
@@ -338,14 +340,12 @@ DarCollectionSummary getDarCollectionSummaryForDACByCollectionId(
@BindList(value = "datasetIds", onEmpty = EmptyHandling.NULL_STRING) List datasetIds,
@Bind("collectionId") Integer collectionId);
-
@RegisterBeanMapper(value = DarCollectionSummary.class)
@RegisterBeanMapper(value = DarCollection.class)
@RegisterBeanMapper(value = Election.class)
@UseRowReducer(DarCollectionSummaryReducer.class)
- @SqlQuery
- (
- """
+ @SqlQuery(
+ """
SELECT c.collection_id as dar_collection_id, c.dar_code, latest_dar.submission_date,
latest_dar.reference_id as latest_dar_reference_id, latest_dar.parent_id as latest_dar_parent_id,
latest_dar.closeout_approving_so_id as latest_dar_closeout_approving_so_id,
@@ -390,8 +390,7 @@ WHERE LOWER(election.election_type) = 'dataaccess'
latest_dar.closeout_approving_so_id, latest_dar.closeout_so_approval_timestamp,
u.display_name, u.user_id, i.institution_name,
i.institution_id, e.election_id, e.status, e.dataset_id, e.reference_id, dd.dataset_id, latest_dar.data, dac.name
- """
- )
+ """)
DarCollectionSummary getDarCollectionSummaryByCollectionId(
@Bind("collectionId") Integer collectionId);
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DataAccessRequestDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DataAccessRequestDAO.java
index a01d659027..9ed9255ff6 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DataAccessRequestDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DataAccessRequestDAO.java
@@ -24,8 +24,8 @@
import org.jdbi.v3.sqlobject.transaction.Transactional;
/**
- * For all json queries, note the double `??` for jdbi3 escaped jsonb operators:
- * ...
+ * For all json queries, note the double `??` for jdbi3 escaped jsonb operators: ...
*/
@RegisterRowMapper(DataAccessRequestMapper.class)
public interface DataAccessRequestDAO extends Transactional {
@@ -64,7 +64,8 @@ public interface DataAccessRequestDAO extends Transactional findDatasetApprovalsByDar(@Bind("darReferenceId") String darReferenceId);
/**
- * This query finds submitted DARs based on a date range. This would be useful if we wanted to
+ * This query finds submitted DARs based on a date range. This would be useful if we wanted to
* send notifications for "expiring" DARs 30 days before expiration and again at 7 days.
*
* @param emailType - Type of email message associated with a DAR
- * @param interval - The POSTGRESQL time interval. This value will be subtracted from now()
+ * @param interval - The POSTGRESQL time interval. This value will be subtracted from now()
* @return List of submitted DARs within the date range provided.
*/
@UseRowReducer(DataAccessRequestReducer.class)
@@ -167,10 +168,12 @@ AND dar.collection_id NOT IN (
WHERE dar.submission_date >= :notBefore
AND (dar.submission_date < now() - :interval ::interval)
AND (email.email_type IS NULL)
-
+
""")
- List findAgedDARsByEmailTypeOlderThanInterval(@Bind("emailType") Integer emailType,
- @Bind("interval") String interval, @Bind("notBefore") Timestamp notBefore);
+ List findAgedDARsByEmailTypeOlderThanInterval(
+ @Bind("emailType") Integer emailType,
+ @Bind("interval") String interval,
+ @Bind("notBefore") Timestamp notBefore);
/**
* Find all draft/partial DataAccessRequests, sorted descending order
@@ -256,17 +259,19 @@ List findAgedDARsByEmailTypeOlderThanInterval(@Bind("emailTyp
WHERE dar.reference_id IN ()
AND (LOWER(dar.data->>'status') != 'archived' OR dar.data->>'status' IS NULL)
""")
- List findByReferenceIds(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ List findByReferenceIds(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
/**
* Update DataAccessRequest properties by reference id.
*
- * @param referenceId String
- * @param userId Integer User
+ * @param referenceId String
+ * @param userId Integer User
* @param submissionDate Date Submission Date
- * @param updateDate Date Update Date
- * @param data DataAccessRequestData DAR Properties
- * @param eraCommonsId The user's era commons id at the time of update
+ * @param updateDate Date Update Date
+ * @param data DataAccessRequestData DAR Properties
+ * @param eraCommonsId The user's era commons id at the time of update
*/
@RegisterArgumentFactory(JsonArgumentFactory.class)
@SqlUpdate(
@@ -290,14 +295,15 @@ void updateDataByReferenceId(
* @param referenceId String
*/
@SqlUpdate(
- """
+ """
DELETE FROM data_access_request WHERE reference_id = :referenceId
""")
void deleteByReferenceId(@Bind("referenceId") String referenceId);
-
@SqlUpdate("DELETE FROM data_access_request WHERE reference_id IN ()")
- void deleteByReferenceIds(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ void deleteByReferenceIds(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
@SqlUpdate(
"""
@@ -305,7 +311,9 @@ void updateDataByReferenceId(
SET data = jsonb_set(data, '{status}', '"Canceled"'::jsonb)
WHERE reference_id IN ()
""")
- void cancelByReferenceIds(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ void cancelByReferenceIds(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
/**
* Delete all DataAccessRequests with the given collection id
@@ -313,7 +321,7 @@ WHERE reference_id IN ()
* @param collectionId Integer
*/
@SqlUpdate(
- """
+ """
DELETE FROM data_access_request WHERE collection_id = :collectionId
""")
void deleteByCollectionId(@Bind("collectionId") Integer collectionId);
@@ -322,10 +330,10 @@ WHERE reference_id IN ()
* Create new DataAccessRequest in draft status
*
* @param referenceId String
- * @param userId Integer User
- * @param createDate Date Creation Date
- * @param updateDate Date Update Date
- * @param data DataAccessRequestData DAR Properties
+ * @param userId Integer User
+ * @param createDate Date Creation Date
+ * @param updateDate Date Update Date
+ * @param data DataAccessRequestData DAR Properties
*/
@RegisterArgumentFactory(JsonArgumentFactory.class)
@SqlUpdate(
@@ -345,13 +353,13 @@ void insertDraftDataAccessRequest(
/**
* Create new DataAccessRequest. This version supersedes `insertV2`
*
- * @param collectionId Integer DarCollection
- * @param referenceId String
- * @param userId Integer User
- * @param createDate Date Creation Date
+ * @param collectionId Integer DarCollection
+ * @param referenceId String
+ * @param userId Integer User
+ * @param createDate Date Creation Date
* @param submissionDate Date Submission Date
- * @param updateDate Date Update Date
- * @param data DataAccessRequestData DAR Properties
+ * @param updateDate Date Update Date
+ * @param data DataAccessRequestData DAR Properties
*/
@RegisterArgumentFactory(JsonArgumentFactory.class)
@SqlUpdate(
@@ -374,11 +382,11 @@ void insertDataAccessRequest(
/**
* Create new Progress Report.
*
- * @param parentId String Parent ID
- * @param collectionId Integer DarCollection
- * @param referenceId String
- * @param userId Integer User
- * @param data DataAccessRequestData DAR Properties
+ * @param parentId String Parent ID
+ * @param collectionId Integer DarCollection
+ * @param referenceId String
+ * @param userId Integer User
+ * @param data DataAccessRequestData DAR Properties
*/
@RegisterArgumentFactory(JsonArgumentFactory.class)
@SqlUpdate(
@@ -395,7 +403,6 @@ void insertProgressReport(
@Bind("data") @Json DataAccessRequestData data,
@Bind("eraCommonsId") String eraCommonsId);
-
/**
* Converts a Draft DataAccessRequest into a non-draft DataAccessRequest
*
@@ -407,8 +414,8 @@ void insertProgressReport(
SET submission_date = now(), collection_id = :collectionId
WHERE reference_id = :referenceId
""")
- void updateDraftToSubmittedForCollection(@Bind("collectionId") Integer collectionId,
- @Bind("referenceId") String referenceId);
+ void updateDraftToSubmittedForCollection(
+ @Bind("collectionId") Integer collectionId, @Bind("referenceId") String referenceId);
@SqlUpdate(
"""
@@ -416,15 +423,18 @@ void updateDraftToSubmittedForCollection(@Bind("collectionId") Integer collectio
SET data = jsonb_set ((data #>> '{}')::jsonb, '{status}', '"Archived"', true)
WHERE reference_id IN ()
""")
- void archiveByReferenceIds(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ void archiveByReferenceIds(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
@SqlUpdate(
- """
+ """
UPDATE data_access_request
SET closeout_approving_so_id = :id, closeout_so_approval_timestamp = now()
WHERE reference_id = :referenceId
""")
- void updateDarCloseoutSO(@Bind("id") Integer signingOfficialUserId, @Bind("referenceId") String referenceId);
+ void updateDarCloseoutSO(
+ @Bind("id") Integer signingOfficialUserId, @Bind("referenceId") String referenceId);
/**
* Inserts into dar_dataset collection
@@ -466,7 +476,9 @@ INSERT INTO dar_dataset (reference_id, dataset_id)
* @param referenceIds List
*/
@SqlUpdate("DELETE FROM dar_dataset WHERE reference_id in ()")
- void deleteDARDatasetRelationByReferenceIds(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ void deleteDARDatasetRelationByReferenceIds(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
/**
* Returns all dataset_ids that match any of the referenceIds inside the "referenceIds" list
@@ -474,6 +486,7 @@ INSERT INTO dar_dataset (reference_id, dataset_id)
* @param referenceIds List
*/
@SqlQuery("SELECT distinct dataset_id FROM dar_dataset WHERE reference_id IN ()")
- List findAllDARDatasetRelations(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
-
+ List findAllDARDatasetRelations(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DatasetDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DatasetDAO.java
index c83c1784df..42aa637dce 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DatasetDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DatasetDAO.java
@@ -48,11 +48,13 @@ public interface DatasetDAO extends Transactional {
/**
* Find a Dataset by id.
+ *
* @param datasetId The dataset id
* @return Dataset
*/
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.dataset_id, d.name, d.create_date, d.create_user_id, d.update_date,
d.update_user_id, d.object_id, d.dac_id, d.alias, d.data_use, d.translated_data_use, d.dac_approval,
d.study_id, d.indexed_date,
@@ -90,11 +92,13 @@ public interface DatasetDAO extends Transactional {
/**
* Find a minimal version of a Dataset by alias. This query excludes file and study information
* which is often not necessary for many operations.
+ *
* @param alias The dataset alias
* @return Dataset
*/
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.dataset_id, d.name, d.create_date, d.create_user_id, d.update_date,
d.update_user_id, d.object_id, d.dac_id, d.alias, d.data_use, d.translated_data_use,
d.dac_approval, d.study_id, d.indexed_date,
@@ -140,7 +144,8 @@ Integer insertDataset(
@Bind("dataUse") String dataUse,
@Bind("dacId") Integer dacId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE dataset
SET name = :datasetName,
update_date = :updateDate,
@@ -156,7 +161,8 @@ void updateDatasetByDatasetId(
@Bind("dacId") Integer updatedDacId);
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.dataset_id, d.name, d.create_date, d.create_user_id, d.update_date,
d.update_user_id, d.object_id, d.dac_id, d.alias, d.data_use, d.translated_data_use, d.dac_approval,
dar_ds_ids.id AS in_use, d.study_id, d.indexed_date,
@@ -213,7 +219,8 @@ LEFT JOIN file_storage_object fso ON (fso.entity_id = d.dataset_id::text OR fso.
* @return List of datasets
*/
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.dataset_id, d.name, d.create_date, d.create_user_id, d.update_date,
d.update_user_id, d.object_id, d.dac_id, d.alias, d.data_use, d.translated_data_use, d.dac_approval,
dar_ds_ids.id AS in_use, d.study_id, d.indexed_date,
@@ -242,9 +249,12 @@ LEFT JOIN (SELECT DISTINCT dataset_id AS id FROM dar_dataset) dar_ds_ids ON dar_
WHERE d.dataset_id in ()
ORDER BY d.dataset_id
""")
- List findDatasetsByIdList(@BindList(value = "datasetIds", onEmpty = EmptyHandling.NULL_STRING) Collection datasetIds);
+ List findDatasetsByIdList(
+ @BindList(value = "datasetIds", onEmpty = EmptyHandling.NULL_STRING)
+ Collection datasetIds);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT dataset_id FROM dataset ORDER BY dataset_id
""")
List findAllDatasetIds();
@@ -255,7 +265,8 @@ WHERE d.dataset_id in ()
* @param userId User ID
* @return List of Dataset IDs that are visible to the user via DACs.
*/
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT distinct d.dataset_id
FROM dataset d
INNER JOIN user_role dac_role ON dac_role.dac_id = d.dac_id
@@ -272,7 +283,8 @@ WHERE d.dataset_id in ()
* @return all datasets associated with DAC
*/
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.dataset_id, d.name, d.create_date, d.create_user_id, d.update_date,
d.update_user_id, d.object_id, d.dac_id, d.alias, d.data_use, d.translated_data_use, d.dac_approval,
dar_ds_ids.id AS in_use, d.study_id, d.indexed_date,
@@ -290,7 +302,8 @@ LEFT JOIN (SELECT DISTINCT dataset_id AS id FROM dar_dataset) dar_ds_ids ON dar_
""")
List findDatasetsAssociatedWithDac(@Bind("dacId") Integer dacId);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT DISTINCT dp.property_value as name
FROM dataset_property dp
INNER JOIN dataset d ON dp.dataset_id = d.dataset_id
@@ -301,7 +314,8 @@ LEFT JOIN (SELECT DISTINCT dataset_id AS id FROM dar_dataset) dar_ds_ids ON dar_
""")
Set findAllStudyNames();
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT DISTINCT d.name
FROM dataset d
WHERE d.name IS NOT NULL
@@ -309,7 +323,8 @@ LEFT JOIN (SELECT DISTINCT dataset_id AS id FROM dar_dataset) dar_ds_ids ON dar_
List findAllDatasetNames();
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.dataset_id, d.name, d.create_date, d.create_user_id, d.update_date,
d.update_user_id, d.object_id, d.dac_id, d.alias, d.data_use, d.translated_data_use, d.dac_approval,
dar_ds_ids.id AS in_use, d.study_id, d.indexed_date,
@@ -366,7 +381,8 @@ LEFT JOIN file_storage_object fso ON (fso.entity_id = d.dataset_id::text OR fso.
* @return List of datasets
*/
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.dataset_id, d.name, d.create_date, d.create_user_id, d.update_date,
d.update_user_id, d.object_id, d.dac_id, d.alias, d.data_use, d.translated_data_use,
d.dac_approval, dar_ds_ids.id AS in_use, d.study_id, d.indexed_date,
@@ -394,21 +410,22 @@ LEFT JOIN (SELECT DISTINCT dataset_id AS id FROM dar_dataset) dar_ds_ids ON dar_
LEFT JOIN file_storage_object fso ON fso.entity_id = d.dataset_id::text AND fso.deleted = false
WHERE d.alias IN ()
""")
- List findDatasetsByAlias(@BindList(value = "aliases", onEmpty = EmptyHandling.NULL_STRING) List aliases);
+ List findDatasetsByAlias(
+ @BindList(value = "aliases", onEmpty = EmptyHandling.NULL_STRING) List aliases);
@SqlUpdate("UPDATE dataset SET dac_id = :dacId WHERE dataset_id = :datasetId")
void updateDatasetDacId(@Bind("datasetId") Integer datasetId, @Bind("dacId") Integer dacId);
-
- @SqlUpdate("UPDATE dataset SET translated_data_use = :translatedDataUse WHERE dataset_id = :datasetId")
- void updateDatasetTranslatedDataUse(@Bind("datasetId") Integer datasetId,
- @Bind("translatedDataUse") String translatedDataUse);
+ @SqlUpdate(
+ "UPDATE dataset SET translated_data_use = :translatedDataUse WHERE dataset_id = :datasetId")
+ void updateDatasetTranslatedDataUse(
+ @Bind("datasetId") Integer datasetId, @Bind("translatedDataUse") String translatedDataUse);
@SqlUpdate("UPDATE dataset SET name = :name WHERE dataset_id = :datasetId")
void updateDatasetName(@Bind("datasetId") Integer datasetId, @Bind("name") String name);
-
- @SqlBatch("""
+ @SqlBatch(
+ """
INSERT INTO dataset_property
(dataset_id, property_key, schema_property, property_value, property_type, create_date )
VALUES
@@ -419,7 +436,8 @@ void updateDatasetTranslatedDataUse(@Bind("datasetId") Integer datasetId,
@SqlUpdate("DELETE FROM dataset_property WHERE dataset_id = :datasetId")
void deleteDatasetPropertiesByDatasetId(@Bind("datasetId") Integer datasetId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO dataset_audit
(dataset_id, change_action, modified_by_user, modification_date, object_id, name)
VALUES
@@ -429,7 +447,8 @@ void updateDatasetTranslatedDataUse(@Bind("datasetId") Integer datasetId,
Integer insertDatasetAudit(@BindBean DatasetAudit dataSets);
@UseRowMapper(DatasetAuditMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT *
FROM dataset_audit
WHERE dataset_id = :datasetId
@@ -441,29 +460,31 @@ void updateDatasetTranslatedDataUse(@Bind("datasetId") Integer datasetId,
+ "SET property_value = :propertyValue "
+ "WHERE dataset_id = :datasetId "
+ "AND property_key = :propertyKey")
- void updateDatasetProperty(@Bind("datasetId") Integer datasetId,
- @Bind("propertyKey") Integer propertyKey, @Bind("propertyValue") String propertyValue);
+ void updateDatasetProperty(
+ @Bind("datasetId") Integer datasetId,
+ @Bind("propertyKey") Integer propertyKey,
+ @Bind("propertyValue") String propertyValue);
@SqlUpdate(
"""
UPDATE dataset
SET study_id = :studyId
WHERE dataset_id = :datasetId
- """
- )
+ """)
void updateStudyId(@Bind("datasetId") Integer datasetId, @Bind("studyId") Integer studyId);
@SqlUpdate(
"DELETE from dataset_property "
+ "WHERE dataset_id = :datasetId "
+ "AND property_key = :propertyKey")
- void deleteDatasetPropertyByKey(@Bind("datasetId") Integer datasetId,
- @Bind("propertyKey") Integer propertyKey);
+ void deleteDatasetPropertyByKey(
+ @Bind("datasetId") Integer datasetId, @Bind("propertyKey") Integer propertyKey);
@SqlUpdate("DELETE FROM dataset WHERE dataset_id = :datasetId")
void deleteDatasetById(@Bind("datasetId") Integer datasetId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE dataset
SET name = :datasetName,
update_date = :updateDate,
@@ -471,53 +492,61 @@ void deleteDatasetPropertyByKey(@Bind("datasetId") Integer datasetId,
dac_id = :dacId
WHERE dataset_id = :datasetId
""")
- void updateDataset(@Bind("datasetId") Integer datasetId,
- @Bind("datasetName") String datasetName, @Bind("updateDate") Timestamp updateDate,
+ void updateDataset(
+ @Bind("datasetId") Integer datasetId,
+ @Bind("datasetName") String datasetName,
+ @Bind("updateDate") Timestamp updateDate,
@Bind("updateUserId") Integer updateUserId,
@Bind("dacId") Integer updatedDacId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE dataset
SET data_use = :dataUse
WHERE dataset_id = :datasetId
""")
void updateDatasetDataUse(@Bind("datasetId") Integer datasetId, @Bind("dataUse") String dataUse);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE dataset
SET create_user_id = :createUserId
WHERE dataset_id = :datasetId
""")
- void updateDatasetCreateUserId(@Bind("datasetId") Integer datasetId,
- @Bind("createUserId") Integer createUserId);
+ void updateDatasetCreateUserId(
+ @Bind("datasetId") Integer datasetId, @Bind("createUserId") Integer createUserId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE dataset
SET name = :datasetName,
update_date = :updateDate,
update_user_id = :updateUserId
WHERE dataset_id = :datasetId
""")
- void updateDatasetNameWithUpdateUser(@Bind("datasetId") Integer datasetId,
+ void updateDatasetNameWithUpdateUser(
+ @Bind("datasetId") Integer datasetId,
@Bind("datasetName") String datasetName,
@Bind("updateDate") Timestamp updateDate,
@Bind("updateUserId") Integer updateUserId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE dataset
SET update_date = :updateDate,
update_user_id = :updateUserId
WHERE dataset_id = :datasetId
""")
- void updateDatasetUpdateUser(@Bind("datasetId") Integer datasetId,
+ void updateDatasetUpdateUser(
+ @Bind("datasetId") Integer datasetId,
@Bind("updateDate") Timestamp updateDate,
@Bind("updateUserId") Integer updateUserId);
@UseRowMapper(DatasetPropertyMapper.class)
@SqlQuery(
- " SELECT p.*, d.key FROM dataset_property p " +
- " INNER JOIN dictionary d ON p.property_key = d.key_id " +
- " WHERE p.dataset_id = :datasetId ")
+ " SELECT p.*, d.key FROM dataset_property p "
+ + " INNER JOIN dictionary d ON p.property_key = d.key_id "
+ + " WHERE p.dataset_id = :datasetId ")
Set findDatasetPropertiesByDatasetId(@Bind("datasetId") Integer datasetId);
@RegisterRowMapper(DictionaryMapper.class)
@@ -528,40 +557,44 @@ void updateDatasetUpdateUser(@Bind("datasetId") Integer datasetId,
Dataset getDatasetByName(@Bind("name") String name);
@UseRowReducer(DatasetReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT distinct d.*, k.key, p.property_value, d.dac_id
FROM dataset d
LEFT JOIN dataset_property p ON p.dataset_id = d.dataset_id
LEFT JOIN dictionary k ON k.key_id = p.property_key
WHERE d.dac_id IN ()
""")
- List findDatasetListByDacIds(@BindList(value = "dacIds", onEmpty = EmptyHandling.NULL_STRING) List dacIds);
+ List findDatasetListByDacIds(
+ @BindList(value = "dacIds", onEmpty = EmptyHandling.NULL_STRING) List dacIds);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT distinct d.dataset_id FROM dataset d WHERE d.dac_id IN ()
""")
- List findDatasetIdsByDacIds(@BindList(value = "dacIds", onEmpty = EmptyHandling.NULL_STRING) List dacIds);
+ List findDatasetIdsByDacIds(
+ @BindList(value = "dacIds", onEmpty = EmptyHandling.NULL_STRING) List dacIds);
@SqlUpdate(
- "UPDATE dataset " +
- "SET dac_approval = :dacApproval, " +
- "update_date = :updateDate, " +
- "update_user_id = :updateUserId " +
- "WHERE dataset_id = :datasetId"
- )
+ "UPDATE dataset "
+ + "SET dac_approval = :dacApproval, "
+ + "update_date = :updateDate, "
+ + "update_user_id = :updateUserId "
+ + "WHERE dataset_id = :datasetId")
void updateDatasetApproval(
@Bind("dacApproval") Boolean dacApproved,
@Bind("updateDate") Instant updateDate,
@Bind("updateUserId") Integer updateUserId,
- @Bind("datasetId") Integer datasetId
- );
+ @Bind("datasetId") Integer datasetId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE dataset
SET indexed_date = :indexedDate
WHERE dataset_id = :datasetId
""")
- void updateDatasetIndexedDate(@Bind("datasetId") Integer datasetId, @Bind("indexedDate") Instant indexedDate);
+ void updateDatasetIndexedDate(
+ @Bind("datasetId") Integer datasetId, @Bind("indexedDate") Instant indexedDate);
@RegisterRowMapper(ApprovedDatasetMapper.class)
@UseRowReducer(ApprovedDatasetReducer.class)
@@ -596,5 +629,4 @@ AND dar.collection_id NOT IN (
WHERE data ->> 'closeoutSupplement' IS NOT NULL)
""")
List getApprovedDatasets(@Bind("userId") Integer userId);
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/DraftDAO.java b/src/main/java/org/broadinstitute/consent/http/db/DraftDAO.java
index 7242f69230..452afb46dc 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/DraftDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/DraftDAO.java
@@ -27,14 +27,16 @@
@RegisterRowMapper(FileStorageObjectMapperWithFSOPrefix.class)
public interface DraftDAO extends Transactional {
- String DRAFT_SUMMARY = """
+ String DRAFT_SUMMARY =
+ """
SELECT ds.name, ds.create_date, ds.uuid, ds.update_date, ds.draft_type
FROM draft ds
WHERE ds.create_user_id = :createdUserId
ORDER BY ds.update_date DESC
""";
- String DRAFT_DETAILS = """
+ String DRAFT_DETAILS =
+ """
SELECT ds.name, ds.create_date, ds.create_user_id, ds.json,
ds.uuid, ds.update_date, ds.update_user_id, ds.draft_type,
uu.user_id AS uu_user_id, uu.email AS uu_email, uu.display_name AS uu_display_name,
@@ -42,8 +44,9 @@ public interface DraftDAO extends Transactional {
cu.user_id AS cu_user_id, cu.email AS cu_email, cu.display_name AS cu_display_name,
cu.create_date AS cu_create_date, cu.email_preference AS cu_email_preference,
"""
- + FileStorageObject.QUERY_FIELDS_WITH_FSO_PREFIX + " " +
- """
+ + FileStorageObject.QUERY_FIELDS_WITH_FSO_PREFIX
+ + " "
+ + """
FROM draft ds
LEFT JOIN users uu on ds.update_user_id = uu.user_id
LEFT JOIN users cu on ds.create_user_id = cu.user_id
@@ -56,8 +59,7 @@ public interface DraftDAO extends Transactional {
(name, create_date, create_user_id, update_date,
update_user_id, json, uuid, draft_type)
(SELECT :name, :createdDate, :createdUserId, :createdDate, :createdUserId, :json::jsonb, :uuid, :draftType)
- """
- )
+ """)
@GetGeneratedKeys
Integer insert(
@Bind("name") String name,
@@ -67,7 +69,8 @@ Integer insert(
@Bind("uuid") UUID uuid,
@Bind("draftType") String draftType);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE draft
SET name = :name,
update_date = :updateDate,
@@ -84,7 +87,8 @@ void updateDraftByDraftUUID(
@Bind("uuid") UUID uuid,
@Bind("draftType") String draftType);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE draft
SET
update_date = :updateDate,
@@ -98,23 +102,20 @@ void updateDraftByDraftUUID(
@UseRowReducer(DraftReducer.class)
@SqlQuery(
- DRAFT_DETAILS +
- """
+ DRAFT_DETAILS
+ + """
WHERE ds.create_user_id = :createdUserId
""")
- Collection findDraftsByUserId(
- @Bind("createdUserId") Integer createdUserId);
+ Collection findDraftsByUserId(@Bind("createdUserId") Integer createdUserId);
@UseRowMapper(DraftSummaryMapper.class)
- @SqlQuery(
- DRAFT_SUMMARY)
- Collection findDraftSummariesByUserId(
- @Bind("createdUserId") Integer createdUserId);
+ @SqlQuery(DRAFT_SUMMARY)
+ Collection findDraftSummariesByUserId(@Bind("createdUserId") Integer createdUserId);
@UseRowReducer(DraftReducer.class)
@SqlQuery(
- DRAFT_DETAILS +
- """
+ DRAFT_DETAILS
+ + """
WHERE uuid = :uuid
""")
DraftInterface findDraftById(@Bind("uuid") UUID uuid);
@@ -123,7 +124,7 @@ Collection findDraftSummariesByUserId(
"""
DELETE from draft
WHERE uuid IN ()
- """
- )
- void deleteDraftByUUIDList(@BindList(value = "uuid_list", onEmpty = EmptyHandling.NULL_STRING) List uuid);
+ """)
+ void deleteDraftByUUIDList(
+ @BindList(value = "uuid_list", onEmpty = EmptyHandling.NULL_STRING) List uuid);
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/ElectionDAO.java b/src/main/java/org/broadinstitute/consent/http/db/ElectionDAO.java
index b9f47ffc72..1659ebe0bf 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/ElectionDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/ElectionDAO.java
@@ -20,30 +20,38 @@
@RegisterRowMapper(ElectionMapper.class)
public interface ElectionDAO extends Transactional {
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT DISTINCT election_id
FROM election
WHERE reference_id IN ()
""")
- List getElectionIdsByReferenceIds(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ List getElectionIdsByReferenceIds(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
- @SqlUpdate("""
- INSERT INTO election (election_type, status, create_date, reference_id, dataset_id)
+ @SqlUpdate(
+ """
+ INSERT INTO election (election_type, status, create_date, reference_id, dataset_id)
VALUES (:electionType, :status, :createDate,:referenceId, :datasetId)
""")
@GetGeneratedKeys
- Integer insertElection(@Bind("electionType") String electionType,
+ Integer insertElection(
+ @Bind("electionType") String electionType,
@Bind("status") String status,
@Bind("createDate") Date createDate,
@Bind("referenceId") String referenceId,
@Bind("datasetId") Integer datasetId);
- @SqlUpdate("UPDATE election SET status = :status, last_update = :lastUpdate WHERE election_id = :electionId ")
- void updateElectionById(@Bind("electionId") Integer electionId,
+ @SqlUpdate(
+ "UPDATE election SET status = :status, last_update = :lastUpdate WHERE election_id = :electionId ")
+ void updateElectionById(
+ @Bind("electionId") Integer electionId,
@Bind("status") String status,
@Bind("lastUpdate") Date lastUpdate);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT DISTINCT
e.election_id, e.dataset_id, v.vote final_vote, e.status, e.create_date,
e.reference_id, v.rationale final_rationale, v.create_date final_vote_date,
@@ -61,7 +69,8 @@ WHEN LOWER(e.election_type) = 'dataset' THEN 'data_owner'
Election findElectionWithFinalVoteById(@Bind("electionId") Integer electionId);
@UseRowMapper(SimpleElectionMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT e.* FROM election e
INNER JOIN data_access_request dar ON dar.reference_id = e.reference_id
INNER JOIN users u ON u.user_id = dar.user_id
@@ -69,7 +78,8 @@ WHEN LOWER(e.election_type) = 'dataset' THEN 'data_owner'
WHERE e.election_id IN ()
""")
List findElectionsWithCardHoldingUsersByElectionIds(
- @BindList(value = "electionIds", onEmpty = EmptyHandling.NULL_STRING) List electionIds);
+ @BindList(value = "electionIds", onEmpty = EmptyHandling.NULL_STRING)
+ List electionIds);
@UseRowMapper(SimpleElectionMapper.class)
@SqlQuery("SELECT * FROM election WHERE reference_id = :referenceId")
@@ -77,10 +87,13 @@ List findElectionsWithCardHoldingUsersByElectionIds(
@UseRowMapper(SimpleElectionMapper.class)
@SqlQuery("SELECT * FROM election WHERE reference_id in ()")
- List findElectionsByReferenceIds(@BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ List findElectionsByReferenceIds(
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
@UseRowMapper(SimpleElectionMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT * FROM election e
INNER JOIN vote v ON v.election_id = e.election_id
WHERE LOWER(e.election_type) = :electionType
@@ -88,11 +101,10 @@ AND v.vote_id IN ()
""")
List findElectionsByVoteIdsAndType(
@BindList(value = "voteIds", onEmpty = EmptyHandling.NULL_STRING) List voteIds,
- @Bind("electionType") String electionType
- );
+ @Bind("electionType") String electionType);
-
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT * FROM (
SELECT e.*, v.vote final_vote,
CASE
@@ -119,9 +131,11 @@ WHERE e.reference_id IN ()
""")
@UseRowMapper(ElectionMapper.class)
List findLastElectionsByReferenceIds(
- @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT DISTINCT e.*
FROM election e
WHERE LOWER(e.status) = 'open'
@@ -129,9 +143,11 @@ AND e.reference_id IN ()
""")
@UseRowMapper(ElectionMapper.class)
List findOpenElectionsByReferenceIds(
- @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds);
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT distinct *
FROM election e
INNER JOIN
@@ -145,9 +161,12 @@ AND LOWER(e.election_type) = LOWER(:type)
""")
@UseRowMapper(SimpleElectionMapper.class)
List findLastElectionsByReferenceIdsAndType(
- @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING) List referenceIds, @Bind("type") String type);
+ @BindList(value = "referenceIds", onEmpty = EmptyHandling.NULL_STRING)
+ List referenceIds,
+ @Bind("type") String type);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT e.* FROM election e
INNER JOIN
(SELECT reference_id, dataset_id, MAX(create_date) max_date
@@ -162,39 +181,49 @@ WHERE LOWER(e.election_type) = lower(:type)
AND e.dataset_id = :datasetId
""")
@UseRowMapper(SimpleElectionMapper.class)
- Election findLastElectionByReferenceIdDatasetIdAndType(@Bind("referenceId") String referenceId,
- @Bind("datasetId") Integer datasetId, @Bind("type") String type);
+ Election findLastElectionByReferenceIdDatasetIdAndType(
+ @Bind("referenceId") String referenceId,
+ @Bind("datasetId") Integer datasetId,
+ @Bind("type") String type);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT e.*
FROM election e
WHERE e.reference_id = :referenceId
AND e.dataset_id = :datasetId
""")
@UseRowMapper(SimpleElectionMapper.class)
- List findElectionsByReferenceIdAndDatasetId(@Bind("referenceId") String referenceId,
- @Bind("datasetId") Integer datasetId);
+ List findElectionsByReferenceIdAndDatasetId(
+ @Bind("referenceId") String referenceId, @Bind("datasetId") Integer datasetId);
@UseRowMapper(SimpleElectionMapper.class)
@SqlQuery("SELECT DISTINCT * FROM election e WHERE e.election_id IN ()")
- List findElectionsByIds(@BindList(value = "electionIds", onEmpty = EmptyHandling.NULL_STRING) List electionIds);
+ List findElectionsByIds(
+ @BindList(value = "electionIds", onEmpty = EmptyHandling.NULL_STRING)
+ List electionIds);
@UseRowMapper(SimpleElectionMapper.class)
@SqlQuery("SELECT * FROM election e WHERE e.election_id = :electionId")
Election findElectionById(@Bind("electionId") Integer electionId);
- @SqlUpdate("UPDATE election SET status = :status, last_update = :lastUpdate, final_access_vote = :finalAccessVote WHERE election_id = :electionId ")
- void updateElectionById(@Bind("electionId") Integer electionId,
+ @SqlUpdate(
+ "UPDATE election SET status = :status, last_update = :lastUpdate, final_access_vote = :finalAccessVote WHERE election_id = :electionId ")
+ void updateElectionById(
+ @Bind("electionId") Integer electionId,
@Bind("status") String status,
@Bind("lastUpdate") Date lastUpdate,
@Bind("finalAccessVote") Boolean finalAccessVote);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE election
SET archived = true, last_update = :lastUpdate
WHERE election_id IN ()
""")
- void archiveElectionByIds(@BindList(value = "electionIds", onEmpty = EmptyHandling.NULL_STRING) List electionIds,
+ void archiveElectionByIds(
+ @BindList(value = "electionIds", onEmpty = EmptyHandling.NULL_STRING)
+ List electionIds,
@Bind("lastUpdate") Date lastUpdate);
/**
@@ -205,7 +234,8 @@ void archiveElectionByIds(@BindList(value = "electionIds", onEmpty = EmptyHandli
* @return Dac for this election
*/
@UseRowMapper(DacMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT d.* FROM dac d
INNER JOIN dataset ds on d.dac_id = ds.dac_id
INNER JOIN election e on ds.dataset_id = e.dataset_id
@@ -220,11 +250,11 @@ void archiveElectionByIds(@BindList(value = "electionIds", onEmpty = EmptyHandli
* @return List of elections associated to the Dac
*/
@UseRowMapper(SimpleElectionMapper.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT e1.* FROM election e1
INNER JOIN dataset ds1 on ds1.dac_id = :dacId AND ds1.dataset_id = e1.dataset_id
WHERE LOWER(e1.status) = 'open'
""")
List findOpenElectionsByDacId(@Bind("dacId") Integer dacId);
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/FileStorageObjectDAO.java b/src/main/java/org/broadinstitute/consent/http/db/FileStorageObjectDAO.java
index 9dc68b0d3e..1db868a611 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/FileStorageObjectDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/FileStorageObjectDAO.java
@@ -24,8 +24,7 @@ public interface FileStorageObjectDAO extends Transactional {
(:fileName, :category, :gcsFileUri,
:mediaType, :entityId, :createUserId,
:createDate, false)
- """
- )
+ """)
@GetGeneratedKeys
Integer insertNewFile(
@Bind("fileName") String fileName,
@@ -34,8 +33,7 @@ Integer insertNewFile(
@Bind("mediaType") String mediaType,
@Bind("entityId") String entityId,
@Bind("createUserId") Integer createUserId,
- @Bind("createDate") Instant createDate
- );
+ @Bind("createDate") Instant createDate);
@SqlUpdate(
"""
@@ -44,13 +42,12 @@ Integer insertNewFile(
delete_user_id=:deleteUserId,
delete_date=:deleteDate
WHERE file_storage_object_id = :fileStorageObjectId
- """
- )
- void deleteFileById(@Bind("fileStorageObjectId") Integer fileStorageObjectId,
+ """)
+ void deleteFileById(
+ @Bind("fileStorageObjectId") Integer fileStorageObjectId,
@Bind("deleteUserId") Integer deleteUserId,
@Bind("deleteDate") Instant deleteDate);
-
@SqlUpdate(
"""
UPDATE file_storage_object
@@ -59,8 +56,7 @@ void deleteFileById(@Bind("fileStorageObjectId") Integer fileStorageObjectId,
update_user_id=:updateUserId,
update_date=:updateDate
WHERE file_storage_object_id = :fileStorageObjectId
- """
- )
+ """)
void updateFileById(
@Bind("fileStorageObjectId") Integer fileStorageObjectId,
@Bind("gcsFileUri") String gcsFileUri,
@@ -75,20 +71,18 @@ void updateFileById(
delete_user_id=:deleteUserId,
delete_date=:deleteDate
WHERE entity_id = :entityId
- """
- )
- void deleteFilesByEntityId(@Bind("entityId") String entityId,
+ """)
+ void deleteFilesByEntityId(
+ @Bind("entityId") String entityId,
@Bind("deleteUserId") Integer deleteUserId,
@Bind("deleteDate") Instant deleteDate);
-
@SqlQuery(
"""
SELECT *
FROM file_storage_object
WHERE file_storage_object_id = :fileStorageObjectId
- """
- )
+ """)
FileStorageObject findFileById(@Bind("fileStorageObjectId") Integer fileStorageObjectId);
@SqlQuery(
@@ -97,8 +91,7 @@ void deleteFilesByEntityId(@Bind("entityId") String entityId,
FROM file_storage_object
WHERE entity_id = :entityId AND
deleted != true
- """
- )
+ """)
List findFilesByEntityId(@Bind("entityId") String entityId);
@SqlQuery(
@@ -108,11 +101,11 @@ void deleteFilesByEntityId(@Bind("entityId") String entityId,
WHERE entity_id = :entityId
AND category = :category
AND deleted != true
- """
- )
- List findFilesByEntityIdAndCategory(@Bind("entityId") String entityId,
- @Bind("category") String category);
+ """)
+ List findFilesByEntityIdAndCategory(
+ @Bind("entityId") String entityId, @Bind("category") String category);
- @SqlUpdate("DELETE FROM file_storage_object WHERE create_user_id = :userId OR update_user_id = :userId OR delete_user_id = :userId")
+ @SqlUpdate(
+ "DELETE FROM file_storage_object WHERE create_user_id = :userId OR update_user_id = :userId OR delete_user_id = :userId")
void deleteAllUserFiles(@Bind("userId") Integer userId);
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/InstitutionDAO.java b/src/main/java/org/broadinstitute/consent/http/db/InstitutionDAO.java
index 12f6e7b0b6..cd85c21bee 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/InstitutionDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/InstitutionDAO.java
@@ -23,7 +23,8 @@
@RegisterRowMapper(InstitutionMapper.class)
public interface InstitutionDAO extends Transactional {
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO institution
(institution_name, it_director_name, it_director_email, institution_url,
duns_number, org_chart_url, verification_url, verification_filename,
@@ -33,7 +34,8 @@ public interface InstitutionDAO extends Transactional {
:organizationType, :createUser, :createDate)
""")
@GetGeneratedKeys
- Integer insertInstitution(@Bind("institutionName") String institutionName,
+ Integer insertInstitution(
+ @Bind("institutionName") String institutionName,
@Bind("itDirectorName") String itDirectorName,
@Bind("itDirectorEmail") String itDirectorEmail,
@Bind("institutionUrl") String institutionUrl,
@@ -54,43 +56,55 @@ Integer insertInstitution(@Bind("institutionName") String institutionName,
* @return The inserted Institution object
* @throws SQLException The exception thrown if the insert fails.
*/
- default Institution insertFullInstitution(Institution institution, Integer userId) throws SQLException {
+ default Institution insertFullInstitution(Institution institution, Integer userId)
+ throws SQLException {
Date now = new Date();
AtomicReference institutionId = new AtomicReference<>();
- getHandle().useTransaction(handle -> {
- handle.getConnection().setAutoCommit(false);
- Integer id = insertInstitution(
- institution.getName(),
- institution.getItDirectorName(),
- institution.getItDirectorEmail(),
- institution.getInstitutionUrl(),
- institution.getDunsNumber(),
- institution.getOrgChartUrl(),
- institution.getVerificationUrl(),
- institution.getVerificationFilename(),
- (Objects.nonNull(institution.getOrganizationType()) ? institution.getOrganizationType()
- .getValue() : null),
- userId,
- now);
- if (institution.getDomains() != null) {
- String insertDomainQuery = """
+ getHandle()
+ .useTransaction(
+ handle -> {
+ handle.getConnection().setAutoCommit(false);
+ Integer id =
+ insertInstitution(
+ institution.getName(),
+ institution.getItDirectorName(),
+ institution.getItDirectorEmail(),
+ institution.getInstitutionUrl(),
+ institution.getDunsNumber(),
+ institution.getOrgChartUrl(),
+ institution.getVerificationUrl(),
+ institution.getVerificationFilename(),
+ (Objects.nonNull(institution.getOrganizationType())
+ ? institution.getOrganizationType().getValue()
+ : null),
+ userId,
+ now);
+ if (institution.getDomains() != null) {
+ String insertDomainQuery =
+ """
INSERT INTO institution_domains (institution_id, domain) VALUES (:institutionId, :domain)
""";
- institution.getDomains().forEach(domain -> handle.createUpdate(insertDomainQuery)
- .bind("institutionId", id)
- .bind("domain", domain)
- .execute());
- }
- handle.commit();
- institutionId.set(id);
- });
+ institution
+ .getDomains()
+ .forEach(
+ domain ->
+ handle
+ .createUpdate(insertDomainQuery)
+ .bind("institutionId", id)
+ .bind("domain", domain)
+ .execute());
+ }
+ handle.commit();
+ institutionId.set(id);
+ });
if (institutionId.get() != null) {
return findInstitutionById(institutionId.get());
}
throw new SQLException("Failed to insert institution");
}
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE institution
SET
institution_name = :institutionName,
@@ -106,7 +120,8 @@ INSERT INTO institution_domains (institution_id, domain) VALUES (:institutionId,
update_date = :updateDate
WHERE institution_id = :institutionId
""")
- void updateInstitutionById(@Bind("institutionId") Integer institutionId,
+ void updateInstitutionById(
+ @Bind("institutionId") Integer institutionId,
@Bind("institutionName") String institutionName,
@Bind("itDirectorName") String itDirectorName,
@Bind("itDirectorEmail") String itDirectorEmail,
@@ -131,48 +146,60 @@ default Institution updateFullInstitution(Institution institution, Integer userI
throws SQLException {
Date now = new Date();
Integer institutionId = institution.getId();
- getHandle().useTransaction(handle -> {
- handle.getConnection().setAutoCommit(false);
- updateInstitutionById(
- institution.getId(),
- institution.getName(),
- institution.getItDirectorName(),
- institution.getItDirectorEmail(),
- institution.getInstitutionUrl(),
- institution.getDunsNumber(),
- institution.getOrgChartUrl(),
- institution.getVerificationUrl(),
- institution.getVerificationFilename(),
- (Objects.nonNull(institution.getOrganizationType()) ? institution.getOrganizationType()
- .getValue() : null),
- userId,
- now);
- handle.createUpdate("DELETE FROM institution_domains WHERE institution_id = :institutionId")
- .bind("institutionId", institutionId)
- .execute();
- if (institution.getDomains() != null) {
- String insertDomainQuery = """
+ getHandle()
+ .useTransaction(
+ handle -> {
+ handle.getConnection().setAutoCommit(false);
+ updateInstitutionById(
+ institution.getId(),
+ institution.getName(),
+ institution.getItDirectorName(),
+ institution.getItDirectorEmail(),
+ institution.getInstitutionUrl(),
+ institution.getDunsNumber(),
+ institution.getOrgChartUrl(),
+ institution.getVerificationUrl(),
+ institution.getVerificationFilename(),
+ (Objects.nonNull(institution.getOrganizationType())
+ ? institution.getOrganizationType().getValue()
+ : null),
+ userId,
+ now);
+ handle
+ .createUpdate(
+ "DELETE FROM institution_domains WHERE institution_id = :institutionId")
+ .bind("institutionId", institutionId)
+ .execute();
+ if (institution.getDomains() != null) {
+ String insertDomainQuery =
+ """
INSERT INTO institution_domains (institution_id, domain) VALUES (:institutionId, :domain)
""";
- institution.getDomains().forEach(domain -> handle.createUpdate(insertDomainQuery)
- .bind("institutionId", institutionId)
- .bind("domain", domain)
- .execute());
- }
- handle.commit();
- });
+ institution
+ .getDomains()
+ .forEach(
+ domain ->
+ handle
+ .createUpdate(insertDomainQuery)
+ .bind("institutionId", institutionId)
+ .bind("domain", domain)
+ .execute());
+ }
+ handle.commit();
+ });
return findInstitutionById(institutionId);
}
@SqlUpdate(
- """
+ """
WITH domain_deletes AS (DELETE FROM institution_domains d WHERE d.institution_id = :institutionId)
DELETE FROM institution WHERE institution_id = :institutionId
""")
void deleteInstitutionById(@Bind("institutionId") Integer institutionId);
@UseRowReducer(InstitutionReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT i.*, d.domain
FROM institution i
LEFT JOIN institution_domains d on d.institution_id = i.institution_id
@@ -181,7 +208,8 @@ WITH domain_deletes AS (DELETE FROM institution_domains d WHERE d.institution_id
Institution findInstitutionById(@Bind("institutionId") Integer institutionId);
@UseRowReducer(InstitutionReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT i.*, d.domain
FROM institution i
LEFT JOIN institution_domains d on d.institution_id = i.institution_id
@@ -192,7 +220,8 @@ WHERE LOWER(TRIM(i.institution_name)) = LOWER(TRIM(:name))
@RegisterBeanMapper(value = User.class, prefix = "u")
@RegisterBeanMapper(value = SimplifiedUser.class, prefix = "so")
@UseRowReducer(InstitutionWithUsersReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT i.*,
d.domain,
u.user_id AS u_user_id, u.email AS u_email,
@@ -222,7 +251,8 @@ ORDER BY LOWER(i.institution_name)
@RegisterBeanMapper(value = User.class, prefix = "u")
@RegisterBeanMapper(value = SimplifiedUser.class, prefix = "so")
@UseRowReducer(InstitutionWithUsersReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT i.*,
d.domain,
u.user_id AS u_user_id,
@@ -252,25 +282,30 @@ ORDER BY LOWER(i.institution_name)
Institution findInstitutionWithSOById(@Bind("institutionId") Integer institutionId);
default void deleteAllInstitutionsByUser(@Bind("userId") Integer userId) throws SQLException {
- final String domainDeleteQuery = """
+ final String domainDeleteQuery =
+ """
DELETE FROM institution_domains
WHERE institution_id IN (SELECT institution_id FROM institution WHERE create_user = :userId OR update_user = :userId)
""";
- final String institutionDeleteQuery = """
+ final String institutionDeleteQuery =
+ """
DELETE FROM institution WHERE create_user = :userId OR update_user = :userId
""";
- getHandle().useTransaction(handle -> {
- handle.getConnection().setAutoCommit(false);
- handle.createUpdate(domainDeleteQuery).bind("userId", userId).execute();
- handle.createUpdate(institutionDeleteQuery).bind("userId", userId).execute();
- handle.commit();
- });
+ getHandle()
+ .useTransaction(
+ handle -> {
+ handle.getConnection().setAutoCommit(false);
+ handle.createUpdate(domainDeleteQuery).bind("userId", userId).execute();
+ handle.createUpdate(institutionDeleteQuery).bind("userId", userId).execute();
+ handle.commit();
+ });
}
@RegisterBeanMapper(value = User.class, prefix = "u")
@RegisterBeanMapper(value = SimplifiedUser.class, prefix = "so")
@UseRowReducer(InstitutionWithUsersReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT i.*,
d.domain,
u.user_id AS u_user_id,
@@ -299,7 +334,8 @@ WHERE LOWER(d.domain) = LOWER(:domain)
""")
Institution findInstitutionByDomain(@Bind("domain") String domain);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT distinct i.institution_id
FROM institution i
INNER JOIN institution_domains d ON d.institution_id = i.institution_id
diff --git a/src/main/java/org/broadinstitute/consent/http/db/LibraryCardDAO.java b/src/main/java/org/broadinstitute/consent/http/db/LibraryCardDAO.java
index 057a215d3d..2de8b489c9 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/LibraryCardDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/LibraryCardDAO.java
@@ -18,35 +18,40 @@
public interface LibraryCardDAO extends Transactional {
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO library_card (user_id, user_name, user_email, create_user_id, create_date)
VALUES (:userId, :userName, :userEmail, :createUserId, :createDate)
""")
@GetGeneratedKeys
- Integer insertLibraryCard(@Bind("userId") Integer userId,
+ Integer insertLibraryCard(
+ @Bind("userId") Integer userId,
@Bind("userName") String userName,
@Bind("userEmail") String userEmail,
@Bind("createUserId") Integer createUserId,
@Bind("createDate") Date createDate);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE library_card SET
- id = :libraryCardId,
- user_id = :userId,
- user_name = :userName,
- user_email = :userEmail,
- update_user_id = :updateUserId,
- update_date = :updateDate
+ id = :libraryCardId,
+ user_id = :userId,
+ user_name = :userName,
+ user_email = :userEmail,
+ update_user_id = :updateUserId,
+ update_date = :updateDate
WHERE id = :libraryCardId
""")
- void updateLibraryCardById(@Bind("libraryCardId") Integer libraryCardId,
+ void updateLibraryCardById(
+ @Bind("libraryCardId") Integer libraryCardId,
@Bind("userId") Integer userId,
@Bind("userName") String userName,
@Bind("userEmail") String userEmail,
@Bind("updateUserId") Integer updateUserId,
@Bind("updateDate") Date updateDate);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
WITH daa_deletes AS (DELETE FROM lc_daa lc_daa WHERE lc_daa.lc_id = :libraryCardId)
DELETE FROM library_card lc WHERE lc.id = :libraryCardId
""")
@@ -54,7 +59,8 @@ WITH daa_deletes AS (DELETE FROM lc_daa lc_daa WHERE lc_daa.lc_id = :libraryCard
@RegisterBeanMapper(value = LibraryCard.class)
@UseRowReducer(LibraryCardReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT lc.*,
ld.daa_id
FROM library_card AS lc
@@ -66,7 +72,8 @@ WITH daa_deletes AS (DELETE FROM lc_daa lc_daa WHERE lc_daa.lc_id = :libraryCard
@RegisterBeanMapper(value = LibraryCard.class)
@RegisterBeanMapper(value = DataAccessAgreement.class, prefix = "daa")
@UseRowReducer(LibraryCardWithDaaReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT lc.*,
ld.daa_id,
daa.daa_id as daa_daa_id,
@@ -84,7 +91,8 @@ WITH daa_deletes AS (DELETE FROM lc_daa lc_daa WHERE lc_daa.lc_id = :libraryCard
@RegisterBeanMapper(value = LibraryCard.class)
@UseRowReducer(LibraryCardReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT lc.*,
ld.daa_id
FROM library_card AS lc
@@ -95,7 +103,8 @@ WITH daa_deletes AS (DELETE FROM lc_daa lc_daa WHERE lc_daa.lc_id = :libraryCard
@RegisterBeanMapper(value = LibraryCard.class)
@UseRowReducer(LibraryCardReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT library_card.*, ld.daa_id
FROM library_card
LEFT JOIN lc_daa ld ON library_card.id = ld.lc_id
@@ -105,7 +114,8 @@ WITH daa_deletes AS (DELETE FROM lc_daa lc_daa WHERE lc_daa.lc_id = :libraryCard
@RegisterBeanMapper(value = LibraryCard.class)
@UseRowReducer(LibraryCardReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT lc.*,
ld.daa_id
FROM library_card AS lc
@@ -115,21 +125,23 @@ WITH daa_deletes AS (DELETE FROM lc_daa lc_daa WHERE lc_daa.lc_id = :libraryCard
@RegisterBeanMapper(value = LibraryCard.class)
@UseRowReducer(LibraryCardReducer.class)
- @SqlQuery("SELECT * FROM library_card " +
- "WHERE user_email = :email")
+ @SqlQuery("SELECT * FROM library_card " + "WHERE user_email = :email")
LibraryCard findLibraryCardByUserEmail(@Bind("email") String email);
- @SqlUpdate("DELETE FROM library_card WHERE user_id = :userId OR create_user_id = :userId OR update_user_id = :userId")
+ @SqlUpdate(
+ "DELETE FROM library_card WHERE user_id = :userId OR create_user_id = :userId OR update_user_id = :userId")
void deleteAllLibraryCardsByUser(@Bind("userId") Integer userId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO lc_daa (lc_id, daa_id)
VALUES (:lcId, :daaId)
ON CONFLICT DO NOTHING
""")
void createLibraryCardDaaRelation(@Bind("lcId") Integer lcId, @Bind("daaId") Integer daaId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
DELETE FROM lc_daa
WHERE lc_id = :lcId
AND daa_id = :daaId
@@ -144,7 +156,8 @@ INSERT INTO lc_daa (lc_id, daa_id)
*/
@RegisterBeanMapper(value = LibraryCard.class)
@UseRowReducer(LibraryCardReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT *
FROM library_card
WHERE LOWER(user_email) = ANY(ARRAY(SELECT LOWER(UNNEST(ARRAY[]))))
@@ -160,12 +173,12 @@ List findByUserEmails(
*/
@RegisterBeanMapper(value = LibraryCard.class)
@UseRowReducer(LibraryCardReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT *
FROM library_card
WHERE user_id in ()
""")
List findLibraryCardsByUserIds(
@BindList(value = "userIds", onEmpty = EmptyHandling.NULL_STRING) List userIds);
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/MailMessageDAO.java b/src/main/java/org/broadinstitute/consent/http/db/MailMessageDAO.java
index 43da5eac1b..36af2eef8a 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/MailMessageDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/MailMessageDAO.java
@@ -16,12 +16,13 @@
@RegisterRowMapper(MailMessageMapper.class)
public interface MailMessageDAO extends Transactional {
- @SqlUpdate("INSERT INTO email_entity " +
- "(entity_reference_id, vote_id, user_id, email_type, date_sent, email_text, sendgrid_response, sendgrid_status, create_date) VALUES "
- +
- "(:entityReferenceId, :voteId, :userId, :emailType, :dateSent, :emailText, :sendGridResponse, :sendGridStatus, :createDate)")
+ @SqlUpdate(
+ "INSERT INTO email_entity "
+ + "(entity_reference_id, vote_id, user_id, email_type, date_sent, email_text, sendgrid_response, sendgrid_status, create_date) VALUES "
+ + "(:entityReferenceId, :voteId, :userId, :emailType, :dateSent, :emailText, :sendGridResponse, :sendGridStatus, :createDate)")
@GetGeneratedKeys
- Integer insert(@Nullable @Bind("entityReferenceId") String entityReferenceId,
+ Integer insert(
+ @Nullable @Bind("entityReferenceId") String entityReferenceId,
@Nullable @Bind("voteId") Integer voteId,
@Bind("userId") Integer userId,
@Bind("emailType") Integer emailType,
@@ -31,37 +32,46 @@ Integer insert(@Nullable @Bind("entityReferenceId") String entityReferenceId,
@Nullable @Bind("sendGridStatus") Integer sendGridStatus,
@Bind("createDate") Instant createDate);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT entity_reference_id, email_entity_id, vote_id, user_id, email_type, date_sent, email_text, sendgrid_response, sendgrid_status, create_date FROM email_entity e
WHERE email_type = :emailType
ORDER BY create_date DESC
OFFSET :offset
LIMIT :limit
""")
- List fetchMessagesByType(@Bind("emailType") Integer emailType,
- @Bind("limit") Integer limit, @Bind("offset") Integer offset);
+ List fetchMessagesByType(
+ @Bind("emailType") Integer emailType,
+ @Bind("limit") Integer limit,
+ @Bind("offset") Integer offset);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT entity_reference_id, email_entity_id, vote_id, user_id, email_type, date_sent, email_text, sendgrid_response, sendgrid_status, create_date FROM email_entity e
WHERE user_id = :userId
ORDER BY create_date DESC
OFFSET :offset
LIMIT :limit
""")
- List fetchMessagesByUserId(@Bind("userId") Integer userId,
- @Bind("limit") Integer limit, @Bind("offset") Integer offset);
+ List fetchMessagesByUserId(
+ @Bind("userId") Integer userId, @Bind("limit") Integer limit, @Bind("offset") Integer offset);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT entity_reference_id, email_entity_id, vote_id, user_id, email_type, date_sent, email_text, sendgrid_response, sendgrid_status, create_date FROM email_entity e
WHERE create_date BETWEEN SYMMETRIC :start AND :end
ORDER BY create_date DESC
OFFSET :offset
LIMIT :limit
""")
- List fetchMessagesByCreateDate(@Bind("start") Date start, @Bind("end") Date end,
- @Bind("limit") Integer limit, @Bind("offset") Integer offset);
+ List fetchMessagesByCreateDate(
+ @Bind("start") Date start,
+ @Bind("end") Date end,
+ @Bind("limit") Integer limit,
+ @Bind("offset") Integer offset);
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT entity_reference_id, email_entity_id, vote_id, user_id, email_type, date_sent, email_text, sendgrid_response, sendgrid_status, create_date FROM email_entity e
WHERE email_entity_id = :emailId
""")
diff --git a/src/main/java/org/broadinstitute/consent/http/db/MatchDAO.java b/src/main/java/org/broadinstitute/consent/http/db/MatchDAO.java
index f2ef02403a..d8d3171d48 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/MatchDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/MatchDAO.java
@@ -19,7 +19,8 @@
public interface MatchDAO extends Transactional {
@UseRowReducer(MatchReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT m.*, r.*
FROM match_entity m
LEFT JOIN match_rationale r on r.match_entity_id = m.match_id
@@ -28,7 +29,8 @@ public interface MatchDAO extends Transactional {
List findMatchesByPurposeId(@Bind("purposeId") String purposeId);
@UseRowReducer(MatchReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT m.*, r.*
FROM match_entity m
LEFT JOIN match_rationale r on r.match_entity_id = m.match_id
@@ -37,7 +39,8 @@ public interface MatchDAO extends Transactional {
Match findMatchById(@Bind("id") Integer id);
@UseRowReducer(MatchReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT match_entity.*, r.* FROM match_entity
LEFT JOIN match_rationale r on r.match_entity_id = match_entity.match_id
INNER JOIN (
@@ -50,14 +53,16 @@ WHERE match_entity.purpose IN () AND e.election_id = latest
List findMatchesForLatestDataAccessElectionsByPurposeIds(
@BindList(value = "purposeIds", onEmpty = EmptyHandling.NULL_STRING) List purposeIds);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO match_entity
(consent, purpose, match_entity, failed, create_date, algorithm_version, abstain)
VALUES
(:consentId, :purposeId, :match, :failed, :createDate, :algorithmVersion, :abstain)
""")
@GetGeneratedKeys
- Integer insertMatch(@Bind("consentId") String consentId,
+ Integer insertMatch(
+ @Bind("consentId") String consentId,
@Bind("purposeId") String purposeId,
@Bind("match") Boolean match,
@Bind("failed") Boolean failed,
@@ -65,15 +70,19 @@ Integer insertMatch(@Bind("consentId") String consentId,
@Bind("algorithmVersion") String algorithmVersion,
@Bind("abstain") Boolean abstain);
- @SqlUpdate("INSERT INTO match_rationale (match_entity_id, rationale) VALUES (:matchId, :rationale) ")
+ @SqlUpdate(
+ "INSERT INTO match_rationale (match_entity_id, rationale) VALUES (:matchId, :rationale) ")
void insertRationale(@Bind("matchId") Integer matchId, @Bind("rationale") String rationale);
@SqlUpdate("DELETE FROM match_entity WHERE purpose = :purposeId")
void deleteMatchesByPurposeId(@Bind("purposeId") String purposeId);
- @SqlUpdate("DELETE FROM match_rationale WHERE match_entity_id in (SELECT match_id FROM match_entity WHERE purpose IN ()) ")
- void deleteRationalesByPurposeIds(@BindList(value = "purposeIds", onEmpty = EmptyHandling.NULL_STRING) List purposeIds);
+ @SqlUpdate(
+ "DELETE FROM match_rationale WHERE match_entity_id in (SELECT match_id FROM match_entity WHERE purpose IN ()) ")
+ void deleteRationalesByPurposeIds(
+ @BindList(value = "purposeIds", onEmpty = EmptyHandling.NULL_STRING) List purposeIds);
- @SqlQuery("SELECT COUNT(*) FROM match_entity WHERE match_entity = :matchEntity AND failed = 'FALSE' ")
+ @SqlQuery(
+ "SELECT COUNT(*) FROM match_entity WHERE match_entity = :matchEntity AND failed = 'FALSE' ")
Integer countMatchesByResult(@Bind("matchEntity") Boolean matchEntity);
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/OidcAuthorityDAO.java b/src/main/java/org/broadinstitute/consent/http/db/OidcAuthorityDAO.java
index bccd193162..3224259ff6 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/OidcAuthorityDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/OidcAuthorityDAO.java
@@ -36,21 +36,27 @@ public OidcAuthorityConfiguration getOidcAuthorityConfiguration() {
}
@VisibleForTesting
- protected void setOidcAuthorityConfiguration(OidcAuthorityConfiguration oidcAuthorityConfiguration) {
+ protected void setOidcAuthorityConfiguration(
+ OidcAuthorityConfiguration oidcAuthorityConfiguration) {
this.oidcAuthorityConfiguration = oidcAuthorityConfiguration;
}
- public String oauthTokenPost(MultivaluedMap formParameters, MultivaluedMap queryParameters) {
+ public String oauthTokenPost(
+ MultivaluedMap formParameters,
+ MultivaluedMap queryParameters) {
try {
var uriBuilder = UriBuilder.fromUri(getOidcAuthorityConfiguration().token_endpoint());
- queryParameters.forEach((key, values) -> values.forEach(value -> uriBuilder.queryParam(key, value)));
+ queryParameters.forEach(
+ (key, values) -> values.forEach(value -> uriBuilder.queryParam(key, value)));
GenericUrl genericUrl = new GenericUrl(uriBuilder.build());
- HttpRequest request = clientUtil.buildUnAuthedPostRequest(genericUrl, new UrlEncodedContent(formParameters));
+ HttpRequest request =
+ clientUtil.buildUnAuthedPostRequest(genericUrl, new UrlEncodedContent(formParameters));
HttpResponse response = clientUtil.handleHttpRequest(request);
if (!response.isSuccessStatusCode()) {
- String message = String.format(
- "Error getting OIDC token from authority %s, response code %d, response body %s",
- genericUrl, response.getStatusCode(), response.parseAsString());
+ String message =
+ String.format(
+ "Error getting OIDC token from authority %s, response code %d, response body %s",
+ genericUrl, response.getStatusCode(), response.parseAsString());
var exception = new ServerErrorException(message, Response.Status.INTERNAL_SERVER_ERROR);
logException(exception);
throw exception;
@@ -64,15 +70,19 @@ public String oauthTokenPost(MultivaluedMap formParameters, Mult
private OidcAuthorityConfiguration loadOidcAuthorityConfiguration() {
try {
- URI oidcMetadataUri = UriBuilder.fromUri(configuration.getAuthorityEndpoint()).path(OIDC_METADATA_URL_SUFFIX).build();
+ URI oidcMetadataUri =
+ UriBuilder.fromUri(configuration.getAuthorityEndpoint())
+ .path(OIDC_METADATA_URL_SUFFIX)
+ .build();
GenericUrl genericUrl = new GenericUrl(oidcMetadataUri);
HttpRequest request = clientUtil.buildUnAuthedGetRequest(genericUrl);
HttpResponse response = clientUtil.handleHttpRequest(request);
String body = response.parseAsString();
if (!response.isSuccessStatusCode()) {
- String message = String.format(
- "Error getting OIDC configuration from authority %s, response code %d, response body %s",
- genericUrl, response.getStatusCode(), body);
+ String message =
+ String.format(
+ "Error getting OIDC configuration from authority %s, response code %d, response body %s",
+ genericUrl, response.getStatusCode(), body);
var exception = new ServerErrorException(message, Response.Status.INTERNAL_SERVER_ERROR);
logException(exception);
throw exception;
diff --git a/src/main/java/org/broadinstitute/consent/http/db/SamDAO.java b/src/main/java/org/broadinstitute/consent/http/db/SamDAO.java
index b0a16b9910..db66705fda 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/SamDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/SamDAO.java
@@ -38,8 +38,8 @@
public class SamDAO implements ConsentLogger {
- private final ExecutorService executorService = new ThreadUtils().getExecutorService(
- SamDAO.class);
+ private final ExecutorService executorService =
+ new ThreadUtils().getExecutorService(SamDAO.class);
private final HttpClientUtil clientUtil;
private final ServicesConfiguration configuration;
private final Integer connectTimeoutMilliseconds;
@@ -59,12 +59,12 @@ public List getResourceTypes(DuosUser authUser) throws Exception {
HttpRequest request = clientUtil.buildGetRequest(genericUrl, authUser);
HttpResponse response = executeRequest(request);
if (!response.isSuccessStatusCode()) {
- logException("Error getting resource types from Sam: " + response.getStatusMessage(),
+ logException(
+ "Error getting resource types from Sam: " + response.getStatusMessage(),
new ServerErrorException(response.getStatusMessage(), response.getStatusCode()));
}
String body = response.parseAsString();
- Type resourceTypesListType = new TypeToken>() {
- }.getType();
+ Type resourceTypesListType = new TypeToken>() {}.getType();
return new Gson().fromJson(body, resourceTypesListType);
}
@@ -109,8 +109,9 @@ public UserStatus postRegistrationInfo(DuosUser duosUser) throws Exception {
}
public static String getErrorMessage(DuosUser duosUser, String body) {
- var errorMsg = String.format("Error posting user registration information. Email: %s.",
- duosUser.getEmail());
+ var errorMsg =
+ String.format(
+ "Error posting user registration information. Email: %s.", duosUser.getEmail());
if (body == null || body.isEmpty()) {
return errorMsg;
}
@@ -123,14 +124,14 @@ public static String getErrorMessage(DuosUser duosUser, String body) {
duosUser.getEmail());
}
return String.format(errorMsg + " %s.", message);
- } catch (JsonSyntaxException e) { // If the body is not a valid JSON
+ } catch (JsonSyntaxException e) { // If the body is not a valid JSON
return String.format(errorMsg + " %s.", body);
}
}
public void asyncPostRegistrationInfo(DuosUser duosUser) {
- ListeningExecutorService listeningExecutorService = MoreExecutors.listeningDecorator(
- executorService);
+ ListeningExecutorService listeningExecutorService =
+ MoreExecutors.listeningDecorator(executorService);
ListenableFuture userStatusFuture =
listeningExecutorService.submit(() -> postRegistrationInfo(duosUser));
Futures.addCallback(
@@ -143,8 +144,11 @@ public void onSuccess(@Nullable UserStatus userStatus) {
@Override
public void onFailure(@NonNull Throwable throwable) {
- logWarn("Async Post Registration Failure for user: " + duosUser.getEmail() + "; "
- + throwable.getMessage());
+ logWarn(
+ "Async Post Registration Failure for user: "
+ + duosUser.getEmail()
+ + "; "
+ + throwable.getMessage());
}
},
listeningExecutorService);
@@ -156,7 +160,8 @@ public String getToSText() throws Exception {
request.getHeaders().setAccept(MediaType.TEXT_PLAIN);
HttpResponse response = executeRequest(request);
if (!response.isSuccessStatusCode()) {
- logException("Error getting Terms of Service text from Sam: " + response.getStatusMessage(),
+ logException(
+ "Error getting Terms of Service text from Sam: " + response.getStatusMessage(),
new ServerErrorException(response.getStatusMessage(), response.getStatusCode()));
}
return response.parseAsString();
@@ -167,7 +172,9 @@ public TosResponse getTosResponse(DuosUser duosUser) throws Exception {
HttpRequest request = clientUtil.buildGetRequest(genericUrl, duosUser);
HttpResponse response = executeRequest(request);
if (!response.isSuccessStatusCode()) {
- logException(String.format("Error getting Terms of Service: %s for user %s",
+ logException(
+ String.format(
+ "Error getting Terms of Service: %s for user %s",
response.getStatusMessage(), duosUser.getEmail()),
new ServerErrorException(response.getStatusMessage(), response.getStatusCode()));
}
@@ -180,7 +187,9 @@ public int acceptTosStatus(DuosUser duosUser) throws Exception {
HttpRequest request = clientUtil.buildPutRequest(genericUrl, new EmptyContent(), duosUser);
HttpResponse response = executeRequest(request);
if (!response.isSuccessStatusCode()) {
- logException(String.format("Error accepting Terms of Service: %s for user %s",
+ logException(
+ String.format(
+ "Error accepting Terms of Service: %s for user %s",
response.getStatusMessage(), duosUser.getEmail()),
new ServerErrorException(response.getStatusMessage(), response.getStatusCode()));
}
@@ -193,7 +202,8 @@ public int rejectTosStatus(DuosUser duosUser) throws Exception {
HttpResponse response = executeRequest(request);
if (!response.isSuccessStatusCode()) {
logException(
- String.format("Error removing Terms of Service: %s for user %s",
+ String.format(
+ "Error removing Terms of Service: %s for user %s",
response.getStatusMessage(), duosUser.getEmail()),
new ServerErrorException(response.getStatusMessage(), response.getStatusCode()));
}
@@ -226,5 +236,4 @@ private HttpResponse executeRequest(HttpRequest request) {
request.setReadTimeout(readTimeoutMilliseconds);
return clientUtil.handleHttpRequest(request);
}
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/StudyDAO.java b/src/main/java/org/broadinstitute/consent/http/db/StudyDAO.java
index 4212c4844d..2944f7ba3b 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/StudyDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/StudyDAO.java
@@ -20,9 +20,9 @@
@RegisterRowMapper(FileStorageObjectMapperWithFSOPrefix.class)
public interface StudyDAO extends Transactional {
-
@UseRowReducer(StudyReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT
s.*,
sp.study_property_id AS sp_study_property_id,
@@ -32,8 +32,9 @@ public interface StudyDAO extends Transactional {
sp.type AS sp_type,
d.dataset_id AS s_dataset_id,
"""
- + FileStorageObject.QUERY_FIELDS_WITH_FSO_PREFIX + " " +
- """
+ + FileStorageObject.QUERY_FIELDS_WITH_FSO_PREFIX
+ + " "
+ + """
FROM
study s
LEFT JOIN study_property sp ON sp.study_id = s.study_id
@@ -43,7 +44,8 @@ public interface StudyDAO extends Transactional {
""")
Study findStudyById(@Bind("studyId") Integer studyId);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO study (
name, description,
pi_name, data_types,
@@ -59,7 +61,8 @@ INSERT INTO study (
)
""")
@GetGeneratedKeys
- Integer insertStudy(@Bind("name") String name,
+ Integer insertStudy(
+ @Bind("name") String name,
@Bind("description") String description,
@Bind("piName") String piName,
@Bind("dataTypes") List dataTypes,
@@ -68,7 +71,8 @@ Integer insertStudy(@Bind("name") String name,
@Bind("createDate") Instant createDate,
@Bind("uuid") UUID uuid);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE study
SET name = :name,
description = :description,
@@ -79,7 +83,8 @@ Integer insertStudy(@Bind("name") String name,
update_date = :updateDate
WHERE study_id = :studyId
""")
- void updateStudy(@Bind("studyId") Integer studyId,
+ void updateStudy(
+ @Bind("studyId") Integer studyId,
@Bind("name") String name,
@Bind("description") String description,
@Bind("piName") String piName,
@@ -88,7 +93,8 @@ void updateStudy(@Bind("studyId") Integer studyId,
@Bind("updateUserId") Integer updateUserId,
@Bind("updateDate") Instant updateDate);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
INSERT INTO study_property (
study_id, key,
type, value
@@ -102,10 +108,10 @@ Integer insertStudyProperty(
@Bind("studyId") Integer studyId,
@Bind("key") String key,
@Bind("type") String type,
- @Bind("value") String value
- );
+ @Bind("value") String value);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
UPDATE study_property
SET value = :value
WHERE study_id = :studyId
@@ -116,10 +122,10 @@ void updateStudyProperty(
@Bind("studyId") Integer studyId,
@Bind("key") String key,
@Bind("type") String type,
- @Bind("value") String value
- );
+ @Bind("value") String value);
- @SqlUpdate("""
+ @SqlUpdate(
+ """
WITH property_deletes AS (
DELETE from study_property where study_id = :studyId returning study_id
)
@@ -128,9 +134,9 @@ DELETE FROM study WHERE study_id in (select study_id from property_deletes)
void deleteStudyByStudyId(@Bind("studyId") Integer studyId);
@UseRowReducer(StudyReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT * FROM study WHERE name = :name
""")
Study findStudyByName(@Bind("name") String name);
-
}
diff --git a/src/main/java/org/broadinstitute/consent/http/db/UserDAO.java b/src/main/java/org/broadinstitute/consent/http/db/UserDAO.java
index 8ecaf17f47..4202c62629 100644
--- a/src/main/java/org/broadinstitute/consent/http/db/UserDAO.java
+++ b/src/main/java/org/broadinstitute/consent/http/db/UserDAO.java
@@ -31,7 +31,8 @@ public interface UserDAO extends Transactional {
@RegisterBeanMapper(value = Institution.class, prefix = "i")
@RegisterBeanMapper(value = LibraryCard.class, prefix = "lc")
@UseRowReducer(UserWithRolesReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT
u.user_id as u_user_id,
u.email as u_email,
@@ -69,7 +70,8 @@ public interface UserDAO extends Transactional {
@RegisterBeanMapper(value = LibraryCard.class, prefix = "lc")
@RegisterBeanMapper(value = UserProperty.class, prefix = "up")
@UseRowReducer(UserWithRolesReducer.class)
- @SqlQuery("""
+ @SqlQuery(
+ """
SELECT
u.user_id as u_user_id,
u.email as u_email,
@@ -102,64 +104,78 @@ public interface UserDAO extends Transactional {
LEFT JOIN user_property up ON up.user_id = u.user_id AND up.property_key IN ()
WHERE u.user_id = :userId
""")
- User findUserWithPropertiesById(@Bind("userId") Integer userId, @BindList(value = "keys", onEmpty = EmptyHandling.NULL_STRING) List keys);
+ User findUserWithPropertiesById(
+ @Bind("userId") Integer userId,
+ @BindList(value = "keys", onEmpty = EmptyHandling.NULL_STRING) List keys);
@RegisterBeanMapper(value = User.class, prefix = "u")
@UseRowReducer(UserWithRolesReducer.class)
- @SqlQuery("SELECT "
- + User.QUERY_FIELDS_WITH_U_PREFIX
- + " FROM users u WHERE u.user_id IN ()")
- Collection findUsers(@BindList(value = "userIds", onEmpty = EmptyHandling.NULL_STRING) Collection userIds);
+ @SqlQuery(
+ "SELECT " + User.QUERY_FIELDS_WITH_U_PREFIX + " FROM users u WHERE u.user_id IN ()")
+ Collection findUsers(
+ @BindList(value = "userIds", onEmpty = EmptyHandling.NULL_STRING)
+ Collection userIds);
@RegisterBeanMapper(value = User.class, prefix = "u")
@RegisterBeanMapper(value = UserRole.class)
@UseRowReducer(UserWithRolesReducer.class)
- @SqlQuery("SELECT "
- + User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR
- + " ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id, r.name "
- + " FROM users u "
- + " LEFT JOIN user_role ur ON ur.user_id = u.user_id "
- + " LEFT JOIN roles r ON r.role_id = ur.role_id "
- + " WHERE r.name = :name")
+ @SqlQuery(
+ "SELECT "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + " ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id, r.name "
+ + " FROM users u "
+ + " LEFT JOIN user_role ur ON ur.user_id = u.user_id "
+ + " LEFT JOIN roles r ON r.role_id = ur.role_id "
+ + " WHERE r.name = :name")
List describeUsersByRole(@Bind("name") String name);
- @SqlQuery("select du.user_id from users du inner join user_role ur on ur.user_id = du.user_id inner join roles r on r.role_id = ur.role_id where du.user_id = :userId and r.name = 'Chairperson'")
+ @SqlQuery(
+ "select du.user_id from users du inner join user_role ur on ur.user_id = du.user_id inner join roles r on r.role_id = ur.role_id where du.user_id = :userId and r.name = 'Chairperson'")
Integer checkChairpersonUser(@Bind("userId") Integer userId);
@RegisterBeanMapper(value = User.class, prefix = "u")
@RegisterBeanMapper(value = UserRole.class)
@UseRowReducer(UserWithRolesReducer.class)
- @SqlQuery("SELECT "
- + User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR
- + " r.name, ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id "
- + " FROM users u "
- + " INNER JOIN user_role ur ON ur.user_id = u.user_id AND ur.dac_id = :dacId "
- + " INNER JOIN roles r ON r.role_id = ur.role_id "
- + " WHERE r.name = 'Chairperson' OR r.name = 'Member'")
+ @SqlQuery(
+ "SELECT "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + " r.name, ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id "
+ + " FROM users u "
+ + " INNER JOIN user_role ur ON ur.user_id = u.user_id AND ur.dac_id = :dacId "
+ + " INNER JOIN roles r ON r.role_id = ur.role_id "
+ + " WHERE r.name = 'Chairperson' OR r.name = 'Member'")
Set findUsersEnabledToVoteByDAC(@Bind("dacId") Integer dacId);
@RegisterBeanMapper(value = User.class, prefix = "u")
@RegisterBeanMapper(value = UserRole.class)
@UseRowReducer(UserWithRolesReducer.class)
- @SqlQuery("select "
- + User.QUERY_FIELDS_WITH_U_PREFIX + QUERY_FIELD_SEPARATOR
- + " r.name, ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id "
- + " FROM users u "
- + " INNER JOIN user_role ur ON ur.user_id = u.user_id AND ur.dac_id is null "
- + " INNER JOIN roles r on r.role_id = ur.role_id "
- + " WHERE r.name = 'Chairperson' OR r.name = 'Member'")
+ @SqlQuery(
+ "select "
+ + User.QUERY_FIELDS_WITH_U_PREFIX
+ + QUERY_FIELD_SEPARATOR
+ + " r.name, ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id "
+ + " FROM users u "
+ + " INNER JOIN user_role ur ON ur.user_id = u.user_id AND ur.dac_id is null "
+ + " INNER JOIN roles r on r.role_id = ur.role_id "
+ + " WHERE r.name = 'Chairperson' OR r.name = 'Member'")
Set findNonDacUsersEnabledToVote();
@UseRowMapper(UserWithRolesMapper.class)
- @SqlQuery("select du.*, r.role_id, r.name, ur.user_role_id, ur.user_id, ur.role_id, ur.dac_id from users du inner join user_role ur on ur.user_id = du.user_id inner join roles r on r.role_id = ur.role_id where du.user_id IN ()")
- Set