Skip to content

Commit

Permalink
Merge pull request #217 from broadinstitute/develop
Browse files Browse the repository at this point in the history
Patch Release 10/18
  • Loading branch information
rushtong authored Oct 18, 2016
2 parents cb3ceee + f261c9d commit 14a69d9
Show file tree
Hide file tree
Showing 102 changed files with 1,026 additions and 623 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import jersey.repackaged.com.google.common.collect.Lists;
import org.broadinstitute.consent.http.authentication.*;
import org.broadinstitute.consent.http.authentication.AbstractOAuthAuthenticator;
import org.broadinstitute.consent.http.authentication.BasicAuthenticator;
import org.broadinstitute.consent.http.authentication.BasicCustomAuthFilter;
import org.broadinstitute.consent.http.authentication.DefaultAuthFilter;
import org.broadinstitute.consent.http.authentication.DefaultAuthenticator;
import org.broadinstitute.consent.http.authentication.OAuthAuthenticator;
import org.broadinstitute.consent.http.authentication.OAuthCustomAuthFilter;
import org.broadinstitute.consent.http.cloudstore.GCSStore;
import org.broadinstitute.consent.http.configurations.ConsentConfiguration;
import org.broadinstitute.consent.http.configurations.ElasticSearchConfiguration;
import org.broadinstitute.consent.http.configurations.MongoConfiguration;
import org.broadinstitute.consent.http.configurations.StoreConfiguration;
import org.broadinstitute.consent.http.db.ApprovalExpirationTimeDAO;
import org.broadinstitute.consent.http.db.AssociationDAO;
import org.broadinstitute.consent.http.db.ConsentDAO;
import org.broadinstitute.consent.http.db.DACUserDAO;
import org.broadinstitute.consent.http.db.DACUserRoleDAO;
Expand All @@ -38,6 +45,7 @@
import org.broadinstitute.consent.http.db.MatchDAO;
import org.broadinstitute.consent.http.db.ResearcherPropertyDAO;
import org.broadinstitute.consent.http.db.VoteDAO;
import org.broadinstitute.consent.http.db.WorkspaceAuditDAO;
import org.broadinstitute.consent.http.db.mongo.MongoConsentDB;
import org.broadinstitute.consent.http.mail.AbstractMailServiceAPI;
import org.broadinstitute.consent.http.mail.MailService;
Expand Down Expand Up @@ -68,7 +76,9 @@
import org.broadinstitute.consent.http.resources.MatchResource;
import org.broadinstitute.consent.http.resources.ResearcherResource;
import org.broadinstitute.consent.http.resources.UserResource;
import org.broadinstitute.consent.http.resources.WorkspaceResource;
import org.broadinstitute.consent.http.service.AbstractApprovalExpirationTimeAPI;
import org.broadinstitute.consent.http.service.AbstractAuditServiceAPI;
import org.broadinstitute.consent.http.service.AbstractConsentAPI;
import org.broadinstitute.consent.http.service.AbstractDataAccessRequestAPI;
import org.broadinstitute.consent.http.service.AbstractDataSetAPI;
Expand All @@ -85,6 +95,7 @@
import org.broadinstitute.consent.http.service.AbstractTranslateServiceAPI;
import org.broadinstitute.consent.http.service.AbstractVoteAPI;
import org.broadinstitute.consent.http.service.DatabaseApprovalExpirationTimeAPI;
import org.broadinstitute.consent.http.service.DatabaseAuditServiceAPI;
import org.broadinstitute.consent.http.service.DatabaseConsentAPI;
import org.broadinstitute.consent.http.service.DatabaseDataAccessRequestAPI;
import org.broadinstitute.consent.http.service.DatabaseDataSetAPI;
Expand Down Expand Up @@ -187,11 +198,14 @@ public void run(ConsentConfiguration config, Environment env) {
final DataSetAuditDAO dataSetAuditDAO = jdbi.onDemand(DataSetAuditDAO.class);
final MailServiceDAO mailServiceDAO = jdbi.onDemand(MailServiceDAO.class);
final ResearcherPropertyDAO researcherPropertyDAO = jdbi.onDemand(ResearcherPropertyDAO.class);
final WorkspaceAuditDAO workspaceAuditDAO = jdbi.onDemand(WorkspaceAuditDAO.class);
final AssociationDAO associationDAO = jdbi.onDemand(AssociationDAO.class);

DatabaseAuditServiceAPI.initInstance(workspaceAuditDAO, dacUserDAO, associationDAO);
UseRestrictionConverter structResearchPurposeConv = new UseRestrictionConverter(config.getUseRestrictionConfiguration());
DatabaseDataAccessRequestAPI.initInstance(mongoInstance, structResearchPurposeConv, electionDAO, consentDAO, voteDAO, dacUserDAO, dataSetDAO);

DatabaseConsentAPI.initInstance(jdbi, consentDAO, electionDAO, mongoInstance);
DatabaseConsentAPI.initInstance(jdbi, consentDAO, electionDAO, associationDAO, mongoInstance);

DatabaseMatchAPI.initInstance(matchDAO, consentDAO);
DatabaseDataSetAPI.initInstance(dataSetDAO, dataSetAssociationDAO, dacUserRoleDAO, consentDAO, dataSetAuditDAO, electionDAO);
Expand Down Expand Up @@ -269,6 +283,7 @@ public void run(ConsentConfiguration config, Environment env) {
env.jersey().register(ApprovalExpirationTimeResource.class);
env.jersey().register(new UserResource(userAPI));
env.jersey().register(new ResearcherResource(researcherAPI));
env.jersey().register(WorkspaceResource.class);

//Authentication filters
AuthFilter defaultAuthFilter = new DefaultAuthFilter.Builder<User>()
Expand Down Expand Up @@ -310,6 +325,7 @@ public void lifeCycleStopped(LifeCycle event) {
AbstractUseRestrictionValidatorAPI.clearInstance();
AbstractUserRolesHandler.clearInstance();
AbstractOAuthAuthenticator.clearInstance();
AbstractAuditServiceAPI.clearInstance();
super.lifeCycleStopped(event);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import io.dropwizard.auth.basic.BasicCredentials;
import org.broadinstitute.consent.http.configurations.BasicAuthConfig;
import org.broadinstitute.consent.http.models.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
Expand All @@ -17,8 +14,6 @@ public class BasicAuthenticator implements Authenticator<BasicCredentials, User>

BasicAuthConfig basicAuthentication;

private static final Logger logger = LoggerFactory.getLogger(BasicAuthenticator.class);

public BasicAuthenticator(BasicAuthConfig basicAuthentication) {
this.basicAuthentication = basicAuthentication;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public interface CloudStore {

String postOntologyDocument(InputStream stream, String type, String fileName) throws IOException, GeneralSecurityException, URISyntaxException;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.broadinstitute.consent.http.db;


import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.SqlQuery;


public interface AssociationDAO {

@SqlQuery("select associationId from consentassociations where associationType = :associationType and objectId = :objectId")
Integer findAssociationIdByTypeAndObjectId(@Bind("associationType") String associationType,
@Bind("objectId") String objectId);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import org.broadinstitute.consent.http.models.ConsentManage;
import org.broadinstitute.consent.http.models.dto.UseRestrictionDTO;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.SqlBatch;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;
import org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator;
import org.skife.jdbi.v2.unstable.BindIn;

import java.util.Collection;
import java.util.Date;
import java.util.List;
Expand All @@ -34,11 +34,6 @@ public interface ConsentDAO extends Transactional<ConsentDAO> {
@SqlQuery("select * from consents where consentId in (<consentIds>)")
Collection<Consent> findConsentsFromConsentsIDs(@BindIn("consentIds") List<String> consentIds);

@SqlQuery("SELECT * " +
"FROM consents c INNER JOIN consentassociations cs ON c.consentId = cs.consentId "+
"WHERE cs.objectId IN (<datasetId>)")
Collection<Consent> findConsentsFromDatasetIDs(@BindIn("datasetId") List<String> datasetId);

@Mapper(ConsentDataSetMapper.class)
@SqlQuery("SELECT c.consentId, cs.objectId, ds.name " +
"FROM consents c INNER JOIN consentassociations cs ON c.consentId = cs.consentId " +
Expand Down Expand Up @@ -113,16 +108,6 @@ String findAssociationByTypeAndId(@Bind("consentId") String consentId,
@Bind("associationType") String associationType,
@Bind("objectId") String objectId);

@SqlBatch("insert into consentassociations (consentId, associationType, objectId) values (:consentId, :associationType, :objectId)")
void insertAssociations(@Bind("consentId") String consentId,
@Bind("associationType") String associationType,
@Bind("objectId") List<String> ids);

@SqlBatch("delete from consentassociations where consentId = :consentId and associationType = :associationType and objectId =: objectId")
void deleteAssociations(@Bind("consentId") String consentId,
@Bind("associationType") String associationType,
@Bind("objectId") List<String> ids);

@SqlUpdate("delete from consentassociations where consentId = :consentId and associationType = :associationType and objectId = :objectId")
void deleteOneAssociation(@Bind("consentId") String consentId,
@Bind("associationType") String associationType,
Expand All @@ -143,6 +128,9 @@ void deleteAllAssociationsForType(@Bind("consentId") String consentId,
List<String> findConsentsForAssociation(@Bind("associationType") String associationType,
@Bind("objectId") String objectId);

@SqlQuery("select c.* from consentassociations ca inner join consents c on c.consentId = ca.consentId where associationType = :associationType and objectId= :objectId")
Consent findConsentByAssociationAndObjectId(@Bind("associationType") String associationType,
@Bind("objectId") String objectId);

@SqlQuery("select * from consents where consentId not in (select c.consentId from consents c inner join election e on e.referenceId = c.consentId )")
List<Consent> findUnreviewedConsents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.broadinstitute.consent.http.db;

import org.broadinstitute.consent.http.enumeration.RoleStatus;
import org.broadinstitute.consent.http.models.DACUser;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.broadinstitute.consent.http.db;

import org.broadinstitute.consent.http.db.mongo.DatasetAssociationMapper;
import org.broadinstitute.consent.http.models.DataSet;
import org.broadinstitute.consent.http.models.DatasetAssociation;
import org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException;
import org.skife.jdbi.v2.sqlobject.*;
Expand Down Expand Up @@ -49,9 +48,5 @@ public interface DataSetAssociationDAO extends Transactional<DataSetAssociationD

@SqlUpdate("delete from dataset_user_association where dacuserId = :ownerId")
void deleteDatasetRelationshipsForUser(@Bind("ownerId") Integer ownerId);

@SqlBatch("update dataset_user_association set dacuserId = : toDataOwnerId, createDate = now() " +
" where dacUserId = :fromDataOwnerId")
void changeDatasetUserAssociation(@Bind("fromDataOwnerId") Integer fromDataOwnerId, @Bind("toDataOwnerId") Integer tDataOwnerId) throws UnableToExecuteStatementException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public interface DataSetDAO extends Transactional<DataSetDAO> {

String CHAIRPERSON = "CHAIRPERSON";

@SqlQuery("select dataSetId from dataset where dataSetId = :dataSetId")
Integer checkDataSetbyId(@Bind("dataSetId") Integer dataSetId);

@SqlQuery("select * from dataset where dataSetId = :dataSetId")
DataSet findDataSetById(@Bind("dataSetId") Integer dataSetId);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,9 @@ void updateElectionById(@Bind("electionId") Integer electionId,
" and e.status = '" + OPEN +"' and v.vote is null and v.dacUserId = :dacUserId")
List<Election> findAccessRpOpenElectionIds(@Bind("dacUserId")Integer dacUserId);

@SqlQuery("select e.electionId, e.datasetId, v.vote finalVote, e.status, e.createDate, e.referenceId, e.useRestriction, e.translatedUseRestriction, v.rationale finalRationale, v.createDate finalVoteDate, " +
"e.lastUpdate, e.finalAccessVote, e.electionType from election e inner join vote v on v.electionId = e.electionId where e.electionType = 'DataAccess' "+
" and v.type = 'FINAL' and e.referenceId in (<darIds>) order by e.createDate asc")
List<Election> findRequestElectionsByReferenceIds(@BindIn("darIds") List<String> darIds);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Objects;

public class ElectionMapper implements ResultSetMapper<Election> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.broadinstitute.consent.http.models.Vote;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.ResultSetMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
@RegisterMapper(MailMessageMapper.class)
public interface MailMessageDAO extends Transactional<MailMessageDAO> {

@SqlQuery("select e.*, et.type from email_entity inner join email_type et ON e.emailType = et.emailType e where emailEntityId = :emailEntityId")
MailMessage findEmailById(@Bind("emailEntityId") String consentId);

@SqlQuery("Select emailEntityId FROM email_entity e WHERE (e.entityReferenceId = :darElectionId or e.entityReferenceId = :rpElectionId) AND e.emailType = 1 LIMIT 1")
Integer existsCollectDAREmail(@Bind("darElectionId") Integer darElectionId, @Bind("rpElectionId") Integer rpElectionId);

Expand All @@ -30,16 +27,6 @@ void insertEmail(@Bind("voteId") Integer voteId,
@Bind("dateSent") Date dateSent,
@Bind("emailText") String emailText);

@SqlBatch("insert into email_entity " +
"(voteId, entityReferenceId, dacUserId, emailType, dateSent, emailText) values " +
"(:voteId, :entityReferenceId, :dacUserId, :emailType, :dateSent, :emailText)")
void insertBulkEmail(@Bind("voteId") List<Integer> voteIds,
@Bind("dacUserId") List<Integer> userIds,
@Bind("entityReferenceId") String entityReferenceId,
@Bind("emailType") Integer emailType,
@Bind("dateSent") Date dateSent,
@Bind("emailText") String emailText);

@SqlBatch("insert into email_entity " +
"(entityReferenceId, dacUserId, emailType, dateSent, emailText) values " +
"(:entityReferenceId, :dacUserId, :emailType, :dateSent, :emailText)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ void updateMatch(@BindIn("match") Boolean match,
@SqlUpdate("delete from match_entity where matchId = :id")
void deleteMatch(@Bind("id") Integer matchId);

@SqlQuery("delete match_entity where name in (<matchIds>)")
List<Integer> matchBulkDeleteByIds(@BindIn("matchIds") List<String> matchIds);

@SqlQuery("SELECT COUNT(*) FROM match_entity where matchEntity = :matchEntity and failed ='FALSE' ")
Integer countMatchesByResult(@Bind("matchEntity") Boolean matchEntity);


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.broadinstitute.consent.http.db;


import org.broadinstitute.consent.http.enumeration.ResearcherFields;
import org.broadinstitute.consent.http.models.ResearcherProperty;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.broadinstitute.consent.http.models.DACUserRole;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.ResultSetMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.broadinstitute.consent.http.db;

import org.broadinstitute.consent.http.models.WorkspaceAudit;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlBatch;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator;
import java.util.List;

@UseStringTemplate3StatementLocator
public interface WorkspaceAuditDAO {

@SqlUpdate("insert into workspace_audit (modifiedObjectId, modifiedTable, changeAction, modifiedByUserId, modificationDate) " +
" values (:modifiedObjectId, :modifiedTable, :changeAction, :modifiedByUserId, :modificationDate)")
void insertWorkspaceAudit(@BindBean WorkspaceAudit workspaceAudit);

@SqlBatch("insert into workspace_audit (modifiedObjectId, modifiedTable, changeAction, modifiedByUserId, modificationDate) " +
" values (:modifiedObjectId, :modifiedTable, :changeAction, :modifiedByUserId, :modificationDate)")
void batchInsertWorkspaceAudit(@BindBean List<WorkspaceAudit> workspaceAudits);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

public enum Actions {

REPLACE("replace"), ADD("add"), REMOVE("remove");
REPLACE("replace"), ADD("add"), REMOVE("remove"), CREATE("create");

private String value;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.broadinstitute.consent.http.enumeration;

public enum AssociationType {

SAMPLE("sample"), SAMPLESET("sampleSet"), WORKSPACE("workspace");

private String value;

AssociationType(String value) {
this.value = value;
}

public String getValue() {
return value;
}

}
Loading

0 comments on commit 14a69d9

Please sign in to comment.