---
# System prepended metadata

title: Wille - Poa
tags: [wille]

---

# Wille - Poa
###### tags: `wille`

## Domenski model

```plantuml

PrincipalBusinessEntity "*" -up-> "0..1" NaturalPerson: representative
PrincipalBusinessEntity "*" --> "1" BusinessEntity: principal

LegalTransaction "*" <-- "*" PoaDocument
PoaDocument "1" -up-> "0..1" Attachment: poaFile
PoaDocument "1" -up-> "*" Attachment: history
PoaDocument "1" -up-> "0..1" PoaCancellation: cancellationDocument
PoaDocument "1" --> "*" PrincipalBusinessEntity: principals
PoaDocument "*" --> "*" BusinessEntity: attorneys
PoaDocument "*" --> "1" Institution: notary

PoaModification "1" --> "1" Attachment: attachment
PoaModification "*" --> "1" Institution: institution
PoaModification "*" --> "1" PoaDocument: poaDocument

PoaCancellation -up-|> PoaModification
PoaConstriction -up-|> PoaModification
PoaPartialCancellation -up-|> PoaModification
PoaPartialCancellation "1" --> "*" PoaPartialRelation: relations
PoaPartialRelation "*" --> "1" PrincipalBusinessEntity: principal
PoaPartialRelation "1" --> "*" BusinessEntity: attorneys


class PoaDocument << SearchableAndAuditable >> {
    number: string
    depositedDate: Date
    state: DepositedState
    poaType: PoaType
    status: DocumentStatus
    durabilityType: DurabilityType
    expirationDate: Date
    creationType: CreationType
    certificationType: CertificationType
    details: Map
    contexts: List<PoaDocumentContext>
}

abstract class PoaModification << SearchableAndAuditable >> {
    number: Stirng
    note: String
    poaModifyDate: DateTime
}

class PoaCancellation {

}

class PoaConstriction {
    
}

class PoaPartialCancellation {
    
}

class PoaPartialRelation << SearchableAndAuditable >>{
    
}

class PrincipalBusinessEntity {
    email: String
}

class LegalTransaction << SearchableAndAuditable >> {
    uuid: string
    name: string
    requiredCertification: boolean
    status: LegalTransactionStatus
}

class DocumentPreviewAction << SearchableAndAuditable >> {
    ownerUuid: String
    institutionUuid: String
    actionReason: String
    attachmentUuid: String
}

class Attachment {
    
}

enum PoaState {
    NEW,
    SUBMITTED,
    CONFIRMED,
    REJECTED,
    CANCELLED,
    OUT_OF_SYSTEM
}

enum  PoaType {
    INDIVIDUAL,
    JOINT,
    UNKNOWN
}

enum DurabilityType {
    DURABLE,
    NONDURABLE,
    UNKNOWN
}

enum CreationType {
    PERSONALLY_UNREGISTERED,
    PERSONALLY_REGISTERED,
    INSTITUTION,
    REMOTE,
    SYSTEM
}

enum CertificationType {
    NONE,
    REQUIRED,
    UNKNOWN
}
```

## Kreiranje patch-eva i changelog-ova
1. Potrebno je da postoji kreiran **poa** psql user
```sql=
psql postgres -U postgres -c "create USER poa with PASSWORD 'poa'";
```
2.  Kreiramo **poa_prod_schema** bazu podataka u kojoj će biti kreirana šema sa produkcije
```sql=
psql postgres -U postgres -c "select pg_terminate_backend(pid) from pg_stat_activity where datname = 'poa_prod_schema'"
psql postgres -U postgres -c "drop database if exists poa_prod_schema"
psql postgres -U postgres -c "create database poa_prod_schema"
psql postgres -U postgres -c "grant all privileges on database poa_prod_schema to poa"
```
3. Kreiramo tabele (šemu) sa produkcije
**Na poapriv**:
- docker exec -it poa_db_1 /bin/bash
- pg_dump -U poa -s > poa_prod_schema.sql
- exit
- docker cp poa_db_1:poa_prod_schema.sql poa_prod_schema.sql
- exit
- rsync -avc poapriv:poa_prod_schema.sql .
```sql=
psql poa_prod_schema -U poa < poa_prod_schema.sql
```

4. Kreiramo **poa_dev_schema** bazu podataka u kojoj će biti kreirana trenutna šema podataka
```sql=
psql postgres -U postgres -c "select pg_terminate_backend(pid) from pg_stat_activity where datname = 'poa_dev_schema'"
psql postgres -U postgres -c "drop database if exists poa_dev_schema"
psql postgres -U postgres -c "create database poa_dev_schema"
psql postgres -U postgres -c "grant all privileges on database poa_dev_schema to poa"
```

5. Postavljamo prod konfiguraciju tako da kreira celokupnu šemu podataka u poa_dev_schema bazi podataka kako bi napravili **diff** trenutne i šeme sa produkcije
```java=
spring.jpa.hibernate.ddl-auto = create
spring.datasource.url=jdbc:postgresql://localhost:5432/poa_dev_schema
spring.liquibase.enabled=false
```

**cd wille-poa
mvn spring-boot:run -Dspring-boot.run.profiles=prod**

6. Krairamo diff trenutne i šeme sa produkcije u fajlu db.changelog-diff.postgresql.sql
```shell=
mvn liquibase:diff \
-Dliquibase.username=poa \
-Dliquibase.url=jdbc:postgresql://localhost:5432/poa_prod_schema \
-Dliquibase.referenceUsername=poa \
-Dliquibase.referenceUrl=jdbc:postgresql://localhost:5432/poa_dev_schema \
-Dliquibase.changeLogFile=src/main/resources/db/changelog/db.changelog-master.yaml \
-Dliquibase.diffChangeLogFile=src/main/resources/db/changelog/db.changelog-diff.postgresql.sql \
-Dliquibase.logging=DEBUG \
-Dliquibase.verbose=true
```

7. Obrisati sve act_ i jv_ changeset-ove iz db.changelog-diff.postgresql.sql

8.  Napraviti patch-eve i changelog fajlove pa ih zatim ukljuciti i u changelog-master (ostaviti db.changelog-diff.postgresql.sql cistim)

9. Vratiti prod konfiguraciju u prethodno stanje

10. Kreiramo poa bazu podataka u koju će biti spušten prod poa_prod.sql dump
```sql=
psql postgres -U postgres -c "select pg_terminate_backend(pid) from pg_stat_activity where datname = 'poa'"
psql postgres -U postgres -c "drop database if exists poa"
psql postgres -U postgres -c "create database poa"
psql postgres -U postgres -c "grant all privileges on database poa to poa"
```


11. Kreiramo tabele (šemu ukljucujuci i podatke) sa produkcije
**Na poapriv:**
- docker exec -it poa_db_1 /bin/bash
- pg_dump -U poa > poa_prod.sql
- exit
- docker cp poa_db_1:poa_prod.sql poa_prod.sql
- exit
- rsync -avc poapriv:poa_prod.sql .

```sql=
psql poa -U poa < poa_prod.sql
```

12. Pokrenemo aplikaciju i proverimo da li se changelog-ovi kreiraju uspešno, u suprotnom ponoviti postupak dok se ne kreira željena šema
**cd wille-poa
mvn spring-boot:run -Dspring-boot.run.profiles=prod**

## Testni korisnici


| Sud                       | username      | password   |
|:------------------------- |:------------- |:---------- |
| OSNOVNI SUD U PANCEVU     | prituzbetest1 | Pravda2022 |
| VISI SUD U PANCEVU        | prituzbetest2 | Pravda2022 |
| APELACIONI SUD U BEOGRADU | prituzbetest3 | Pravda2022 |
| VRHOVNI KASACIONI SUD     | prituzbetest4 | Pravda2022 |
| MINISTARSTVO PRAVDE       | prituzbetest5 | Pravda2022 |
| VISOKI SAVET SUDSTVA      | prituzbetest6 | Pravda2022 |


## Spisak veb notifikacija i email obaveštenja

#### Zahtev za prihvatanje uloge vlastodavca
|                  | Naslov                                            | Opis                                                                         |
| ---------------- | ------------------------------------------------- |:---------------------------------------------------------------------------- |
| **notifikacija** | Pristigao zahtev za prihvatanje uloge vlastodavca | Pristigao Vam je zahtev {link} za prihvatanje uloge vlastodavca na punomoćju |
| **email**        |                                                   |                                                                              |


#### Zahtev za overu punomoćja
|                  | Naslov                              | Opis                                              |
| ---------------- | ----------------------------------- |:------------------------------------------------- |
| **notifikacija** | Pristigao zahtev za overu punomoćja | Pristigao Vam je zahtev {link} za overu punomoćja |
| **email**        |                                     |                                                   |

#### Prihvaćena overa punomoćja
|                  | Naslov                     | Opis                                                      |
| ---------------- | -------------------------- |:--------------------------------------------------------- |
| **notifikacija** | Prihvaćena overa punomoćja | Uspešno zavedeno punomoćje {link} od strane notara {link} |
| **email**        |                            |                                                           |

#### Otkazano punomoćje 
|                  | Naslov             | Opis                                                  |
| ---------------- |:------------------ |:----------------------------------------------------- |
| **notifikacija** | Otkazano punomoćje | Punomoćje {link} je otkazano. Razlog otkazivanja: ... |
| **email**        |                    |                                                       |

#### Odbijeno punomoćje 
|                  | Naslov             | Opis                                                                 |
| ---------------- |:------------------ |:-------------------------------------------------------------------- |
| **notifikacija** | Odbijeno punomoćje | Punomoćje je odbijeno od strane notara {link}. Razlog odbijanja: ... |
| **email**        |                    |                                                                      |

#### Zavedeno punomoćje
|                  | Naslov             | Opis                                                                 |
| ---------------- |:------------------ |:-------------------------------------------------------------------- |
| **notifikacija** | Zavedeno punomoćje | Uspešno je zavedeno punomoćje {link} |
| **email**        |                    |                                                                      |

### Privilegije


| Authority                          | Role                                                                      |
| ---------------------------------- | ------------------------------------------------------------------------- |
| LEGAL-TRANSACTION_SAVE             | MINISTRY_CLERK                                                            |
| LEGAL-TRANSACTION_GET              | NATURAL_PERSON, LEGAL_PERSON, LAWYER, NOTARY, NOTARY_READ, MINISTRY_CLERK |
| LEGAL-TRANSACTION_UPDATE           | MINISTRY_CLERK                                                            |
| LEGAL-TRANSACTION_DELETE           | MINISTRY_CLERK                                                            |
| POA_INTERNAL_GET                   | NOTARY, NOTARY_READ, MINISTRY_CLERK                                       |
| POA_EXTERNAL_GET                   | NATURAL_PERSON, LEGAL_PERSON, LAWYER                                      |
| POA_EXTERNAL_GET_MY                | NATURAL_PERSON, LEGAL_PERSON, LAWYER                                      |
| POA_INTERNAL_GET_MY                | NOTARY, NOTARY_READ, MINISTRY_CLERK                                       |
| POA_HISTORY                        | NOTARY, NOTARY_READ, MINISTRY_CLERK                                       |
| POA_PERSONALLY_START-DEPOSITION    | NATURAL_PERSON, LEGAL_PERSON                                              |
| POA_REMOTE_START-DEPOSITION        | NATURAL_PERSON, LEGAL_PERSON                                              |
| POA_INSTITUTION_START-DEPOSITION   | NOTARY                                                                    |
| POA_REMOTE_ROLE-DECIDE             | NATURAL_PERSON, LEGAL_PERSON                                              |
| POA_ACCEPT                         | NOTARY                                                                    |
| POA_REJECT                         | NOTARY                                                                    |
| POA_UPDATE                         | NOTARY                                                                    |
| POA_FILE_GET                       | NATURAL_PERSON, LEGAL_PERSON, NOTARY, NOTARY_READ, MINISTRY_CLERK          |
| POA_CANCEL                         | NOTARY                                                                    |
| POA_VERIFICATION-OF-INSPECTION_GET | NOTARY, NOTARY_READ                                                       |
| POA_STATISTICS_MY                  | NATURAL_PERSON, LEGAL_PERSON, LAWYER, NOTARY, NOTARY_READ                 |
| POA_TASK_MY                        | NATURAL_PERSON, LEGAL_PERSON, LAWYER, NOTARY                              |
| POA_CANCELLATION_FILE-GET          | NATURAL_PERSON, LEGAL_PERSON, NOTARY, NOTARY_READ, MINISTRY_CLERK                         |
| POA_CANCELLATION_FILE-REQUEST      | NOTARY, NOTARY_READ                                                       |
| POA_CONSTRICTION_SAVE              | NOTARY                                                                    |
| POA_CONSTRICTION_GET               | NATURAL_PERSON, LEGAL_PERSON, LAWYER, NOTARY, NOTARY_READ, MINISTRY_CLERK |
| POA_CONSTRICTION_FILE-GET          | NATURAL_PERSON, LEGAL_PERSON, NOTARY, NOTARY_READ, MINISTRY_CLERK |
| POA_CONSTRICTION_FILE-REQUEST      | NOTARY, NOTARY_READ                                                       |
| POA_PARTIAL-CANCELLATION_SAVE      | NOTARY                                                                    |
| POA_PARTIAL-CANCELLATION_GET       | NATURAL_PERSON, LEGAL_PERSON, LAWYER, NOTARY, NOTARY_READ, MINISTRY_CLERK |
|         POA_PARTIAL-CANCELLATION_FILE-GET                           |              NATURAL_PERSON, LEGAL_PERSON, NOTARY, NOTARY_READ, MINISTRY_CLERK                                                             | 
|            POA_PARTIAL_CANCELLATION_FILE_REQUEST                        |                                                                  NOTARY, NOTARY_READ         |
 

