Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:adm:systems_db_treenodes [2018/03/05 09:14]
stloukalp
tutorial:adm:systems_db_treenodes [2021/03/22 15:41]
apeterova Fixed JDBC URL and hostname
Line 1: Line 1:
 +====== Systems - DB: TreeNodes (org. structure) synchronization ======
  
 +===== What do you need before you start =====
 +  * You need install **CzechIdM 7.7.0** (and higher).
 +  * You need be logged in as **admin**.
 +  * You need enable **ACC** module.
 +  * You must have database **jdbcTest** with table **organizations**:
 +<code>
 +CREATE DATABASE "jdbcTest"
 +  WITH OWNER = idmadmin
 +       ENCODING = 'UTF8'
 +       TABLESPACE = pg_default
 +       LC_COLLATE = 'cs_CZ.UTF-8'
 +       LC_CTYPE = 'cs_CZ.UTF-8'
 +       CONNECTION LIMIT = -1;
 +</code>
 +
 +<code>
 +\c jdbcTest;
 +</code>
 +<code>
 +CREATE TABLE public.organizations
 +(
 +  id character varying(255),
 +  code character varying(255),
 +  name character varying(255),
 +  parent character varying(255)
 +)
 +WITH (
 +  OIDS=FALSE
 +);
 +ALTER TABLE public.organizations
 +  OWNER TO idmadmin;
 +</code>
 +  * And add two records:
 +<code>
 +  INSERT INTO public.organizations(
 +            id, code, name, parent)
 +    VALUES ('11', 'rt', 'root', null);
 +
 +INSERT INTO public.organizations(
 +            id, code, name, parent)
 +    VALUES ('22', 'org1', 'organization1', '11');
 +</code>
 +
 +===== Create and edit DB system =====
 +We have completely empty organization's agenda.
 +{{ :tutorial:adm:sync_01.png |}}
 +Now we go into **Systems** agenda and add new system. Click on green button **Add**.
 +{{ :tutorial:adm:sync_02.png |}}
 +Fill **System name** and at bottom of page there is green button **Save and continue**, so click on it.
 +{{ :tutorial:adm:sync_03.png |}}
 +Go to **Configuration** tab and fill in information about your database. Ours are as such:
 +
 +
 +
 +^ Parameter            ^ Value                                      ^
 +| Host                 | localhost                                  |
 +| Port                 | 5432                                       |
 +| User                 | idmadmin                                   |
 +| User Password        | \*\*\*\*\*\*\*                             |
 +| Database             | jdbcTest                                   |
 +| Table                | organizations                              |
 +| Key Column           | id                                         |
 +| JDBC Driver          | org.postgresql.Driver                      |
 +| JDBC Connection URL  | ``jdbc:postgresql://%h:%p/%d``          |
 +
 +{{ :tutorial:adm:sync_04.png |}}
 +Then go to tab **Scheme** and generate scheme.
 +{{ :tutorial:adm:sync_05.png |}}
 +Then go to **Mapping** and click on **Add** button.
 +{{ :tutorial:adm:sync_06.png |}}
 +Now fill in information from picture bellow and click on **Save and continue**.
 +{{ :tutorial:adm:sync_07.png |}}
 +At the bottom of page, there are mapped attributes. We are going to add 4 attributes:
 +<code>
 +^ Attribute in schema ^ Name   ^ Identifier ^ Entity attr. ^ Extended attr. ^ Entity field    ^ IdM key    ^
 +| code                | code   | false      | true         | false          | Code (String)              |
 +| name                | name   | false      | true         | false          | Name (String)              |
 +| parent              | parent | false      | true         | false          | Parent (String) |            |
 +| id                  | id     | true       | false        | true                           | externalId |
 +</code>
 +
 +Fill "code, name, parent" as in the picture:
 +
 +<note warning>Attribute parent has to be type String in IDM! If it's e.g. java.lang.Integer or BigDecimal in the schema, use a transformation script from the system when mapping the attribute:
 +<code>if (attributeValue != null) {
 + return attributeValue.toString();
 +}
 +return attributeValue;</code></note>
 +
 +{{ :tutorial:adm:sync_08.png |}}
 +But "id" fill like this picture:
 +{{ :tutorial:adm:sync_09.png |}}
 +Now we have 4 mapped attributes:
 +{{ :tutorial:adm:sync_10.png |}}
 +Go to tab **Synchronization** and **Add** new synchronization.
 +{{ :tutorial:adm:sync_11.png |}}
 +Fill the form as in the picture below and click on **Save and continue**, then click on green **arrow** and option **Save and run sync** will show up, so click on it:
 +{{ :tutorial:adm:sync_12.png |}}
 +Confirm start synchronization:
 +{{ :tutorial:adm:sync_13.png |}}
 +Wait a few seconds, so synchronization can finish its job. And then go to **Organization** section (in the left menu). And there is now organization tree from the database.
 +{{ :tutorial:adm:sync_14.png |}}
 +If you have it in a state like in the upper picture you successfully complete this tutorial.
 +
 +<note>Thank you for trying this tutorial, I hope it was useful.</note>
 +
 +===== Troubleshooting =====
 +
 +==== The number of organizations is too low (when using parents) ====
 +
 +The synchronization processes only organizations, that have consistent values in the attribute **parent**. It means, that if the value in the attribute doesn't correspond to any **identifier** of any other organizations, such organization won't be processed at all by the synchronization. The only exception is the NULL value, which means that the organization is the root organization.
 +
 +Note that the values in the parent attribute must be the identifiers of the accounts. (That may be different from the codes of organizations in IdM.)
  • by apeterova