= openKonsequenz - How to build the module "gridFailureInformation@openK"

:Date: 2020-03-24
:Revision: 1

:icons:
:source-highlighter: highlightjs
:highlightjs-theme: solarized_dark

:imagesdir: ../img
:iconsdir: ../img/icons

:lang: en
:encoding: utf-8
:sectanchors:
:numbered:
<<<

IMPORTANT: Please be sure that you have first *Portal (Auth n Auth)* and *ContactBaseData* installed and configured!

== Requirements
* Node.js 12.14.0
* Angular-CLI
* Java 1.8
* Apache Maven

== Chekout the project
To get started with the project you have to clone gridFailureInformation backend and frontend projects.

Backend repository url <project_url>: +
https://git.eclipse.org/r/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.backend.git +
Frontend repository url <project_url>: +
https://git.eclipse.org/r/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.frontend.git +

- Create a folder and do following for each of them
- Open a cmd and navigate to the folder
- use the command to create a clone of each project +
§ git clone <project_url>

.Developing only:
If you are going to develop, important is a switch to the develop branch.

- Navigate in the folder with the clone and switch to develop branch: +
----
$ git checkout <branch>
----
- At the end just pull the actual version of the code: +
----
$ git pull origin <branch>
----

Active Develop Branches: +
Backend -> DEVELOP +
Frontend -> DEVELOP +
Stable Branches -> master


== How to build the Backend

The backend repository consists of several subprojects. The main backend is the
"gfsBackendService". Depending on the interfaces and the features you want to use, you
need to build other subprojects as well:

[horizontal]
addressImport:: Importing addresses from csv-files
mailExport:: Publish messages via e-mail
stoerungsauskundtInteraces:: Export and import messages from the site "stoerungsauskunft.de"
SARIS-Interface:: Import messages from SARIS
SAMO-Interface:: Import messages from SAMO
other interfaces in future:: ...


Building such a maven project, will produce a <project_name>.jar file, which is needed to run the project.

- Open a command line and navigate to the root folder of the backend project
- Use the following call to cleanly build and install artifacts into the local repository: +
----
$ mvn clean install
----

== How to build the Frontend

=== Install Node.js

Node.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript (also Typescript which is a strongly typed form of JavaScript) code server-side.

* Download Node.js 12.14.0 from https://nodejs.org/download/release/v12.14.0/ by clicking on a xxx.msi image for windows.
* Run the downloaded Node.js .msi Installer - including accepting the license, selecting the destination, and authenticating for the install.
This requires Administrator privileges, and you may need to authenticate
* To ensure Node.js has been installed, run the following in your terminal - you should get something like 12.14.0

[source,command]
----
    $ node -v
----
{blank}

=== Update the npm Angular-CLI client
This package manager comes bundled with Node.js and its good to have the latest version.

* Open a command line and navigate to the root folder of the frontend project
* Run the following commands (the version is defined in the package.json file):

[source,command]
----
    $ npm install --save-dev @angular/cli
----
{blank}

[source,command]
----
    $ npm install
----
{blank}

TIP: Next Step -> Read the *howtoRun* file!

== How to build the SIT-Web-FE (Map- and Table-Component)
=== Prerequirements

* Open a command line and make sure that nest-cli is installed:
+
[source,command]
----
    $ nest -version
----
{blank} 
=> This should show the version number. 

* If you miss the version number or get an error then install the nest-cli with the following command:
+
[source,command]
----
    $ npm install -g @nestjs/cli
----
{blank} 

=== Build and run the SIT-Web-Cache-Service

* Open a command line and navigate to the folder of the service project
(_grid-failure-information-web-cache_).

* To build the service run the commands:
+
[source,command]
----
   $  npm install
   $  nest build
----
{blank} 
=> A folder named '_dist_' should be created in the project folder containing *.js and *.ts files.

* Start the service with the following command for testing:
+
[source,command]
----
   $  npm run start
----
{blank} 
=> After the nest service is started you can test the service within your browser by calling the following address: http://localhost:3000/public-sit. (You should replace _localhost_ with your own network address.) 

=== Build the SIT-Web-FE

* Open a command line and navigate to the root folder of the project. +
=> The project.json file should be in the same folder.

* Install the required dependencies with the following command:
+
[source,command]
----
    $ npm install
----
{blank}

* Build the map and table component:
+
[source,command]
----
    $ npm install
    $ npm run build-comp-full
----
{blank}
=> A folder named '_dist/grid-failure-information-web-comp_' should be created in the project root folder.

TIP: Next Step -> Read the *howtoRun* file!
