# Welcome to PDX Data Portal

Here's description how to run PDX Portal application.

### Prerequisites

 * [Java SDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html), version 1.8 (some tests fail on a higher version).
 * [Gradle](https://gradle.org/install/), 4.x or higher.
 * [Node.js](https://nodejs.org/en/download/current/), 8.x or higher.
 * [Bower](https://bower.io/), version 1.8.x or higher (installation: npm i bower).
 * [MySQL](https://dev.mysql.com/downloads/mysql/5.5.html), version 8.x.x, or [MariaDB](https://mariadb.org/download/), version 10.x.x.
 
 ### Idea Project Setup
 
  * Import project settings using Gradle wrapper (`Use gradle 'wrapper' task configuration` on project open).
  * Install Lombok plugin and enable `Annotation processors` option in Idea settings (`Settings > Build, Execution, Deployment > Compiler > Annotation Processors`).

### To run the PDX Portal application:

 * Copy `flyway.conf` file from the `src/main/resources` to the user home folder.
 * Fill the copied file with real values about local DB.
 * Add `pdx-idp.xml` and `pdx-keystore.jks` files to user home directory to enable user login with SSO.
 For development and test purposes use files from `src/main/resources/sso/template` folder.
 * Set environment variables with required values:
    - `PDX_PORTAL_DB_HOST` - DB host;
    - `PDX_PORTAL_SCHEMA_NAME` - DB schema name;
    - `PDX_PORTAL_DB_USER` - DB user;
    - `PDX_PORTAL_DB_PASS` - DB password;
    - `PDX_PORTAL_SMTP_HOST` - SMTP host;
    - `PDX_PORTAL_SMTP_PORT` - SMTP port;
    - `AWS_ACCESS_KEY` - access key for AWS services;
    - `AWS_ACCESS_SECRET` - secret key for AWS services;
    - `AWS_IAM_USE_ROLES` - indicated if IAM roles should be used;
    - `AWS_REGION` - used AWS region;
    - `AWS_S3_BUCKET` - AWS S3 bucket name to store portal data;
    - `PDX_SAML_ENTITY_ID` - entity ID for SAML SSO authentication;
    - `PDX_SAML_ENTITY_URL` - base entity URL for SAML SSO authentication (base application URL);
    - `PDX_SAML_SERVER_NAME` - SAML server name (`localhost` for test purposes);
    - `PDX_PORTAL_SSO_KEY` - default key of SSO keystore (for development and test purposes - `apollo`);
    - `PDX_PORTAL_KEYSTORE_PASS` - SSO keystore password (for development and test purposes - `nalle123`).
    - `PDX_FEEDBACK_EMAIL` - an email to which user feedback will be sent.
 * Run `./gradlew clean build` to build `.war` file.
 * Deploy created `.war` file on Tomcat root.
 
### To run the PDX Portal using Spring Boot built-in Tomcat [Simplified]:

 * Execute first 3 paragraphs from the previous section.
 * Run `./gradlew flywayMigrate` to update DB schema.
 * Go to `SinglePageAppConfig.java`.
 * Change the resource location from `classpath:/ui/build/default/` to `classpath:/ui/`(spike for development).
 * Run `PdxPortalApplication.java`.
