# orgsync

orgsync is a tool for synchronizing two organizations.
You can use it to synchronize people, articles, files, and their dependencies.
If a record doesn't exist, it will be created. If a record exists, it will be updated, and the last updated record is used as the source.
It is worth noting that if you synchronize people or articles, some other data is synchronized as well.

Requirement: JDK 17

## Dependencies overview

Files
- categories

Person
- titles
- categories
- attachments

Article
- units
- currencies
- categories
- attachments

## Examples

Synchronize people:
java -jar orgsync.jar -p -orga mariamuster -keya b01abF843240uUbdb4Eed4dBbf20Ff87 -orgb hansmuster -keyb aF3cb2Uu9f304dD3f8o5ce81Oo28Pe1E

Synchronize articles:
java -jar orgsync.jar -a -orga mariamuster -keya b01abF843240uUbdb4Eed4dBbf20Ff87 -orgb hansmuster -keyb aF3cb2Uu9f304dD3f8o5ce81Oo28Pe1E

Synchronize only active persons:
java -jar orgsync.jar -p -orga mariamuster -keya b01abF843240uUbdb4Eed4dBbf20Ff87 -orgb hansmuster -keyb aF3cb2Uu9f304dD3f8o5ce81Oo28Pe1E -pf onlyActive=true

Synchronize items and only active people that belong to the "employee" category:
java -jar orgsync.jar -p -a -orga mariamuster -keya b01abF843240uUbdb4Eed4dBbf20Ff87 -orgb hansmuster -keyb aF3cb2Uu9f304dD3f8o5ce81Oo28Pe1E -pf "category=Employees onlyActive=true"

Synchronize articles, people and all files:
java -jar orgsync.jar -a -orga mariamuster -keya b01abF843240uUbdb4Eed4dBbf20Ff87 -orgb hansmuster -keyb aF3cb2Uu9f304dD3f8o5ce81Oo28Pe1E -fsm all

## Command line options

-p
-a
-orga   <alpha organization>
-keya   <alpha key>
-orgb   <beta organization>
-keyb   <beta key>
-pf     <person filter>
-af     <article filter>
-fsm    <file synchronisation mode>
-lsd    <last synchronize delta>

### -p (Optional)
Use it if you would like to synchronize People, note that either this or -a must be present.

### -a (Optional)
Use it if you would like to synchronize Articles, note that either this or -p must be present.

### -orga (Mandatory)
The alpha organization you would like to synchronize with beta.

### -orgb (Mandatory)
The beta organization you would like to synchronize with alpha.

### -keya (Mandatory)
The API key to access organization alpha.

### -keyb (Mandatory)
The API key to access organization beta.

### -pf (Optional)
Person filter key/value separator = and filter separator is blank space e.g. "category=Employee onlyActive=true".

category - The name of the root category to synchronize. This category must exist in both organizations.
onlyActive - Flag to include only active people. Possible values: true, false (boolean).
onlyNotes - Flag to only include entries with notes. Possible values: true, false (boolean).
onlyWithImages - Flag to include only people with images. Possible values: true, false (boolean).
onlyWithoutCategory - Flag to include only people without a category. Possible values: true, false (boolean).
query - Fulltext search query (text).

### -af (Optional)
Article filter key/value separator = and filter separator is blank space e.g. "category=Services onlyActive=true".

category - The name of the root category to synchronize. This category must exist in both organizations.
onlyActive - Flag to include only active articles. Possible values: true, false (boolean).
onlyCostCenters - Flag to only include entries with cost centers. Possible values: true, false (boolean).
onlyNotes - Flag to only include entries with notes. Possible values: true, false (boolean).
onlyRestock - Flag to include only articles that need to be restocked. Possible values: true, false (boolean).
onlyWithImages - Flag to include only articles with images. Possible values: true, false (boolean).
onlyWithoutCategory - Flag to include only articles without a category. Possible values: true, false (boolean).
query - Fulltext search query (text).

### -fsm (Optional)
File synchronization mode: possible values 'none', 'all' or 'onlyAttached', defaults to 'onlyAttached'.

### -lsd (Optional)
Last synchronization delta - the time, in milliseconds, that must elapse since the last synchronization and last edited record before it is synchronized again, defaults to 10 seconds.