## SISPBO-importing-linking Project

The purpose of this project is to provide mechanism for importing files to Backoffice and linking them to dossiers.
This project is similar to uil-migration process, and it can be used anytime after migration. 


### Building project
Firstly open **pom.xml** file and set property **distribution.dir** to folder where you want the result files to be placed:
```
<properties>
    <distribution.dir>YOUR_DIR_LOCATION</distribution.dir>
</properties>
```
Then build project with command:
```
mvn clean install
```

After build your distribution folder should contain one new folder named *importing-linking-package* which should contain .jar file and .properties files.
 - YOUR_DIR_LOCATION
  - importing-linking-package
    - SISPBO-importing-linking-1.0.jar
    - importing-linking-application.properties
    - log4j.properties

### Running project

First set properties in file **YOUR_DIR_LOCATION/importing-linking-package/importing-linking-application.properties**.

####Add file as annotation

To add file to dossier as annotation, run command:

```
java -jar SISPBO-importing-linking-1.0.jar --spring.config.location=importing-linking-application.properties TYPE=ADD_FILE_AS_ANNOTATION CSV_FILE=xxxx/input.csv
```

CSV_FILE should point to csv file with annotation and file information which will be imported to Backoffice. 
CSV delimeter is ';' and it should contain the following fields:

| Field             | Description                                                                                                 | Mandatory |
|-------            |-------------------------------------------------------------------------------------------------------------|-----------|
|Application_Number | Application number of dossier to which annotation is added                                                  | YES       |
|File_Path          | Full file path of file which will be imported to Backoffice                                                 | YES       |
|Title              | Title of annotation                                                                                         | YES       |
|Kind               | Kind/Status of annotation. Possible values are INTERNAL or PUBLIC                                           | YES       |
|Content            | Content of annotation                                                                                       | YES       |
|Author             | Annotation author                                                                                           | YES       |
|Status             | Status of record, should be TODO. Process will only take records with status TODO or ERROR.                 | YES       |
|Msg                | Error message. It will be set by importing process. For input csv should be empty                           | NO        |
|Alfresco_Id        | Id of Alfresco file. If this field is not empty, file will not be imported to Alfresco                      | NO        |
|Database_Id        | Id of database file. If this field is not empty, file will no be saved to database and imported to Alfresco | NO        |


Example input csv file:

```
Application_Number;File_Path;Title;Kind;Content;Author;Status;Msg;Alfresco_Id;Database_Id
202270018;/Users/marko/Projects/UIL_2022/ImportingAndLinking/ime_datoteke_2.jpeg;Naziv;Internal;Vsebina zaznamka;manager_slovenia_rettro;TODO;;;
202270018;/Users/marko/Projects/UIL_2022/ImportingAndLinking/ime_datoteke_2.jpeg;Naziv;Internal;Vsebina zaznamka;manager_slovenia_rettro;TODO;;;2153
202270018;/Users/marko/Projects/UIL_2022/ImportingAndLinking/ime_datoteke_2.jpeg;Naziv;Internal;Vsebina zaznamka;manager_slovenia_rettro;TODO;;workspace://SpacesStore/457e6c5f-5dfa-435d-9cd1-f11d77de464a;
```



After running the process two new files should appear in **YOUR_DIR_LOCATION/importing-linking-package/** folder:
- **Annotation_result_TIMESTAMP.csv**: It's a CSV file of all processed records, it is in the same format as input csv file with added information about process (status, error message, Alfresco id and database id).
- **Annotation_statistic_TIMESTAMP.txt**: Count of processed files.



#### Logging

For logging properties, set the **log4j.properties** file.



