-
Notifications
You must be signed in to change notification settings - Fork 23
bootstrap
git - Mac: There's already a git executable in /usr/bin. You'll need to run git once to initialize git and all the developer tools you'll need. Linux: ???
JDK 8 - This is pretty much required for all Java development.
On a Mac, if you use Oracle Java, you need to install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.
You need to install these JARs to $JAVA_HOME/jre/lib/security/ If that doesn't work for you, you can search for the existing files at the root of your file system:
find . -name local_policy.jar
You're replacing local_policy.jar
and US_export_policy.jar
in these folders.
IDE of your choice - I like IntelliJ. Note: To get IntelliJ and Play to play nicely together, you'll need sbt-idea. Follow the instructions on this page to get things working.
Another popular choice is Eclipse.
Play Framework - Currently needed to run Bridge Server. There is no installer. You just download the ZIP file and unzip it to wherever you want to install it. Also add it to your PATH so you can run activator from the command-line and add the following to your env vars
SBT_OPTS="-Xmx2000M -Xss2M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"
Redis - Used by Bridge Server as a cache. Mac: "sudo port install redis". Type "redis-server" to start.
MySQL Server - For local testing of SQL stuff. The alternative is to spin up an Amazon RDS instance.
- Note the username and password on install.
- To launch on OS X, go to System Preferences, MySQL, click Start MySQL Server. (Optionally, check/uncheck Automatically Start MySQL Server on Startup.)
- MySQL CLI comes with MySQL Server. To use, add /usr/local/mysql/bin to path. To connect, run "mysql -u (username) -p".
- On your first connect, you'll need to reset your password with "SET PASSWORD FOR '(username)'@'localhost' = PASSWORD('(new password)');"
- Optionally install MySQL Workbench, a GUI for MySQL.
Checkout the BridgePF project from GitHub, either using "git clone" or by going through your IDE.
Before Bridge will run, you will need a local ~/.bridge/bridge-server.conf
file with the passwords to the services the application uses (AWS, Stormpath, etc.). This is not in version control. If you work for Sage, contact a team member to get the contents of this file. If you are developing externally, you will need to create accounts and API keys with these external services in order for Bridge to work. See the conf/bridge.conf
file for all the properties that are going to need to be created and set.
You'll also need to add the following 3 config lines:
hibernate.connection.password = your password here
hibernate.connection.url = jdbc:mysql://localhost:3306/your-db-name-here
hibernate.connection.username = your username here
Run the following queries:
CREATE TABLE `SharedModuleMetadata` (
`id` VARCHAR(60) NOT NULL,
`licenseRestricted` TINYINT NOT NULL DEFAULT 0,
`name` VARCHAR(255) NULL,
`notes` TEXT NULL,
`os` VARCHAR(60) NULL,
`published` TINYINT NOT NULL DEFAULT 0,
`schemaId` VARCHAR(60) NULL,
`schemaRevision` INT UNSIGNED NULL,
`surveyCreatedOn` BIGINT UNSIGNED NULL,
`surveyGuid` VARCHAR(36) NULL,
`version` INT UNSIGNED NOT NULL,
`deleted` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (`id`, `version`));
CREATE TABLE `SharedModuleTags` (
`id` VARCHAR(60) NOT NULL,
`tag` VARCHAR(255) NOT NULL,
`version` INT UNSIGNED NOT NULL,
INDEX `MetadataKey_idx` (`id` ASC, `version` ASC),
CONSTRAINT `MetadataKey`
FOREIGN KEY (`id` , `version`)
REFERENCES `SharedModuleMetadata` (`id` , `version`)
ON DELETE CASCADE
ON UPDATE CASCADE);
To use MySQL auth locally, you'll need to create the following tables in your DB:
CREATE TABLE `Accounts` (
`id` VARCHAR(255) NOT NULL,
`studyId` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NULL,
`phone` VARCHAR(20) NULL,
`phoneRegion` VARCHAR(2) NULL,
`phoneVerified` BOOLEAN NULL,
`emailVerified` BOOLEAN NULL,
`createdOn` BIGINT NOT NULL,
`healthCode` VARCHAR(255) NULL,
`healthId` VARCHAR(255) NULL,
`modifiedOn` BIGINT NOT NULL,
`firstName` VARCHAR(255) NULL,
`lastName` VARCHAR(255) NULL,
`passwordAlgorithm` ENUM('STORMPATH_HMAC_SHA_256', 'BCRYPT', 'PBKDF2_HMAC_SHA_256') NULL,
`passwordHash` VARCHAR(255) NULL,
`passwordModifiedOn` BIGINT NOT NULL,
`status` ENUM('DISABLED', 'ENABLED', 'UNVERIFIED') NOT NULL DEFAULT 'UNVERIFIED',
`version` INT UNSIGNED NOT NULL DEFAULT 0,
`clientData` MEDIUMTEXT NULL,
`reauthTokenAlgorithm` ENUM('STORMPATH_HMAC_SHA_256', 'BCRYPT', 'PBKDF2_HMAC_SHA_256') NULL,
`reauthTokenHash` VARCHAR(255) NULL,
`reauthTokenModifiedOn` BIGINT NULL,
`timeZone` varchar(6) NULL,
`sharingScope` ENUM('NO_SHARING', 'SPONSORS_AND_PARTNERS', 'ALL_QUALIFIED_RESEARCHERS') NULL,
`notifyByEmail` BOOLEAN NULL DEFAULT 1,
`externalId` VARCHAR(255) NULL,
`migrationVersion` INT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE INDEX `Accounts-StudyId-Email-Index` (`studyId` ASC, `email` ASC),
UNIQUE INDEX `Accounts-StudyId-Phone-Index` (`studyId` ASC, `phone` ASC),
UNIQUE INDEX `Accounts-StudyId-HealthCode-Index` (`studyId` ASC, `healthCode` ASC),
UNIQUE INDEX `Accounts-StudyId-ExternalId-Index` ON Accounts (`studyId` ASC, `externalId` ASC),
INDEX `Accounts-StudyId-Index` (`studyId` ASC),
INDEX `Accounts-HealthCode-Index` (`healthCode` ASC))
CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `AccountAttributes` (
`accountId` VARCHAR(255) NOT NULL,
`attributeKey` VARCHAR(255) NOT NULL,
`attributeValue` VARCHAR(255) NOT NULL,
PRIMARY KEY (`accountId`, `attributeKey`),
INDEX `AccountAttributes-AccountId-Index` (`accountId` ASC),
CONSTRAINT `AccountAttributes-Id-Constraint`
FOREIGN KEY (`accountId`)
REFERENCES `Accounts` (`id`)
ON DELETE CASCADE
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `AccountConsents` (
`accountId` VARCHAR(255) NOT NULL,
`subpopulationGuid` VARCHAR(255) NOT NULL,
`signedOn` BIGINT NOT NULL,
`birthdate` VARCHAR(255) NULL,
`consentCreatedOn` BIGINT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`signatureImageData` MEDIUMTEXT NULL,
`signatureImageMimeType` VARCHAR(255) NULL,
`withdrewOn` BIGINT NULL,
PRIMARY KEY (`accountId`, `subpopulationGuid`, `signedOn`),
INDEX `AccountConsents-AccountId-SubpopGuid-Index` (`accountId` ASC, `subpopulationGuid` ASC),
INDEX `AccountConsents-AccountId-Index` (`accountId` ASC),
CONSTRAINT `AccountConsents-Id-Constrant`
FOREIGN KEY (`accountId`)
REFERENCES `Accounts` (`id`)
ON DELETE CASCADE
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `AccountRoles` (
`accountId` VARCHAR(255) NOT NULL,
`role` ENUM('DEVELOPER', 'RESEARCHER', 'ADMIN', 'TEST_USERS', 'WORKER') NOT NULL,
PRIMARY KEY (`accountId`, `role`),
INDEX `AccountRoles-AccountId-Index` (`accountId` ASC),
CONSTRAINT `AccountRoles-Id-Constraint`
FOREIGN KEY (`accountId`)
REFERENCES `Accounts` (`id`)
ON DELETE CASCADE
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `AccountDataGroups` (
`accountId` VARCHAR(255) NOT NULL,
`dataGroup` VARCHAR(255) NOT NULL,
PRIMARY KEY (`accountId`, `dataGroup`),
INDEX `AccountDataGroups-AccountId-Index` (`accountId` ASC),
CONSTRAINT `AccountDataGroups-Id-Constraint`
FOREIGN KEY (`accountId`)
REFERENCES `Accounts` (`id`)
ON DELETE CASCADE
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `AccountLanguages` (
`accountId` VARCHAR(255) NOT NULL,
`language` VARCHAR(255) NOT NULL,
PRIMARY KEY (`accountId`, `language`),
INDEX `AccountLanguages-AccountId-Index` (`accountId` ASC),
CONSTRAINT `AccountLanguages-Id-Constraint`
FOREIGN KEY (`accountId`)
REFERENCES `Accounts` (`id`)
ON DELETE CASCADE
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `Substudies` (
`id` VARCHAR(60) NOT NULL,
`studyId` VARCHAR(60) NOT NULL,
`name` VARCHAR(255) NULL,
`version` int(10) unsigned NOT NULL DEFAULT '0',
`deleted` tinyint(1) DEFAULT 0,
`createdOn` bigint(20) NOT NULL,
`modifiedOn` bigint(20) NOT NULL,
PRIMARY KEY (`id`, `studyId`)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `AccountsSubstudies` (
`studyId` varchar(60) NOT NULL,
`substudyId` varchar(60) NOT NULL,
`accountId` varchar(255) NOT NULL,
`externalId` varchar(255) DEFAULT NULL,
PRIMARY KEY (`studyId`,`substudyId`,`accountId`),
KEY `fk_substudy` (`substudyId`,`studyId`),
KEY `fk_account` (`accountId`),
CONSTRAINT `fk_substudy` FOREIGN KEY (`substudyId`, `studyId`) REFERENCES `Substudies` (`id`, `studyId`),
CONSTRAINT `fk_account` FOREIGN KEY (`accountId`) REFERENCES `Accounts` (`id`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `AccountSecrets` (
`accountId` VARCHAR(255) NOT NULL,
`hash` VARCHAR(255) NOT NULL,
`type` ENUM('REAUTH') DEFAULT 'REAUTH',
`algorithm` ENUM('STORMPATH_HMAC_SHA_256', 'BCRYPT', 'PBKDF2_HMAC_SHA_256') NOT NULL,
`createdOn` BIGINT NOT NULL,
PRIMARY KEY (`accountId`,`hash`),
CONSTRAINT `fk_account_secrets` FOREIGN KEY (`accountId`) REFERENCES `Accounts` (`id`) ON DELETE CASCADE,
INDEX `secrets_idx` (`accountId`, `type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Go to your BridgePF directory and run "activator compile" to make sure everything is set up properly. To run unit tests, "activator test" (this will take 20-30 min).
Before running Bridge Server, make sure redis is running (see section above). Then, run "activator run", then browse to http://localhost:9000/ to load the server.
NOTE: "activator test" is needed to bootstrap your DynamoDB tables. For whatever reason, "activator run" won't do this. See https://sagebionetworks.jira.com/browse/BRIDGE-1646 Workaround: You can run "activator test" just until all DDB tables are created, then stop the tests. (Or just wait until the tests are finished.)
NOTE: The DDB bootstrapper will by default create your DynamoDB tables (and all other AWS resources) in US West (N Virginia).
Run "activator -jvm-debug 9999 run"
This will start the Bridge server running on port 9000 with remote debugging on port 9999. For examples of requests to send, see our API docs. To send raw HTTP requests, use curl, wget, or a tool like Postman.
For more information see: http://sagebase.org/bridge/