////
******************************************************************************
* Copyright 2018 Mettenmeier GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
*
*     http://www.eclipse.org/legal/epl-v10.html
*
******************************************************************************
////
= openKonsequenz "StandbyPlanning" - How to configure the module
:Date: 2018-06-07
:Revision: 1

== Keycloak
Define the following client(s), roles and users. 

.create keycloak client
[source]
	standbyplanning

.create keycloak client roles
[source]
	BP_Admin
	BP_Gruppenleiter
	BP_Leseberechtigte
	BP_Sachbearbeiter

.create keycloak user
[source]	
	user=   bp_leser       pwd= mm
	user=   bp_leiter      pwd= mm
	user=   bp_bearbeiter  pwd= mm
	user=   bp_admin       pwd= mm
	
== Datenbank (Postgres)
A postgres database and a user have to be created. After that all the needed tables and sequences will be genreated bei the "Standby Planning" backend (spbe).

.user
[source]
-- Role: bp
-- DROP ROLE bp;
CREATE ROLE bp LOGIN
  ENCRYPTED PASSWORD 'md5b03632e190331f379668603ee46d4772'
  NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;

.database
[source]
--CREATE DATABASE "BP"
  WITH OWNER = bp
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'en_US.UTF-8'
       LC_CTYPE = 'en_US.UTF-8'
       CONNECTION LIMIT = -1;

== oK auth&auth core module

The frontend and backend of the auth&auth modul have to be put into the webapps folder to allow the use of the module.
[source]
    webapps/portal.war
    webapps/portalFE

Configure the portalFE url to your local environment. For more details see the documentation of the auth&auth core-module. 

[source]
    webapps/portal/WEB-INF/classes/backendConfigProduction.json     // URL to keycloak
    webapps/portal/WEB-INF/classes/moduleConfigDevLocal.json        // Modulconfiguration Dev
    webapps/portal/WEB-INF/classes/moduleConfigProduction.json      // Modulconfiguration Prod

In moduleConfigProduction.json is the following module entry needed: 

[source]
  {
    "name": "Bereitschaftsplanung",
    "cols": 1,
    "rows": 1,
    "color": "#ffffff",
    "link": "https://localhost:8080/spfe",
    "pictureLink": "https://www.openkonsequenz.de/medien/cache/main_image/l_bereitschaftsplan_57882047.jpg",
    "requiredRole": "planning-access"
  }

=== server.xml
The following Resources have added to the *<GlobalNamingResources>* section of the tomcat server.xml.
[source, xml]

    <!--BP resource-->
	<Resource auth="Container"
		driverClassName="org.postgresql.Driver"
		factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" maxActive="20"
		minIdle="5" name="jdbc/BP" password="bp" type="javax.sql.DataSource"
		uniqueResourceName="bp" url="jdbc:postgresql://localhost:5432/BP"
		username="bp" />
		

== Setup the Application Standbyplanning
You need to build the standbyplanning frontend and backend. Then you will get two *.war files. 
[source]
    spfe.war
    spbe.war
    
Both war files should be placed into the webapps folder of the application server. 
[source]
    webapps/spfe.war
    webapps/spbe.war
    
=== Define frontend auth&auth URL 
Define the URL to your openkonsequenz auth&auth modul. For your local development you can use http instead of https. 

.change url in spfe/main*.js
[source]
	loginPage:"https://localhost:8080/portalFE/#/login"
	
=== Define application backend URL.

.change url in spfe/main*.js
[source]
	basePath:"https://localhost:8080/spbe/webapi"
