Differences

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

Link to this comparison view

Both sides previous revision Previous revision
tutorial:adm:systems_db_contracts [2018/03/05 09:11]
stloukalp
tutorial:adm:systems_db_contracts [2018/03/05 09:13] (current)
stloukalp
Line 1: Line 1:
 +====== Systems - DB: Users' contracts 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 **contracts**:​
 +<​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>​
 +CREATE TABLE public.contracts
 +(
 +  id character varying(255),​
 +  name character varying(255),​
 +  state character varying(255),​
 +  disbled character varying(255),​
 +  description character varying(255),​
 +  valid_from date,
 +  valid_to date,
 +  team_leader character varying(255),​
 +  leader character varying(255),​
 +  main character varying(255),​
 +  changed character varying(255),​
 +  organization_name character varying(255),​
 +  organization_code character varying(255),​
 +  owner character varying(255)
 +)
 +WITH (
 +  OIDS=FALSE
 +);
 +ALTER TABLE public.contracts
 +  OWNER TO idmadmin;
 +</​code>​
 +  * And add two records:
 +<​code>​
 +INSERT INTO public.contracts(
 +            id, name, state, disbled, description,​ valid_from, valid_to, ​
 +            team_leader,​ leader, main, changed, organization_name,​ organization_code, ​
 +            owner)
 +    VALUES (
 +'​1','​Contract one','​30','​false','​visualize dot-com ROI','​2016-05-04','​2016-06-21','​john.doe','​john.doe','​true','​2016-06-25','​Skinder','​68016-376','​john.roe'​);​
 +
 +INSERT INTO public.contracts(
 +            id, name, state, disbled, description,​ valid_from, valid_to, ​
 +            team_leader,​ leader, main, changed, organization_name,​ organization_code, ​
 +            owner)
 +    VALUES (
 +'​2','​Contract two','​20','​true','​revolutionize viral experiences','​2017-04-06',​null,​null,​null,'​true','​2016-06-15','​Einti','​60429-911','​john.roe'​);​
 +</​code>​
 +
 +===== Create and edit DB system =====
 +  * We go into **Systems** agenda and add a 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:​contracts_03.png |}}
 +Go to **Configuration** tab and fill in information about your database. Ours are as such:
 +<​code>​
 +^ Host                 ^ jdbc:​postgresql://​localhost:​5432/​jdbcTest ​ ^
 +| Port                 | 5432                                       |
 +| User                 | idmadmin ​                                  |
 +| User Password ​       | ******** ​                                  |
 +| Database ​            | jdbcTest ​                                  |
 +| Table                | contracts ​                                 |
 +| Key Column ​          | id                                         |
 +| JDBC Driver ​         | org.postgresql.Driver ​                     |
 +| JDBC Connection URL  | jdbc:​postgresql://​localhost:​5432/​jdbcTest ​ |
 +</​code>​
 +{{ :​tutorial:​adm:​contracts_04.png |}}
 +  * Then go to tab **Scheme** and generate scheme.
 +{{ :​tutorial:​adm:​contracts_05.png |}}
 +  * Then go to **Mapping** and click on **Add** button.
 +{{ :​tutorial:​adm:​contracts_06.png |}}
 +  * Now fill in information from the picture below and click on **Save and continue**.
 +{{ :​tutorial:​adm:​contracts_07.png |}}
 +  * At the bottom of page, there are mapped attributes. We are going to add 7 attributes:
 +<​code>​
 +^ Attribute in schema ^ Name       ^ Identifier ^ Entity attr. ^ Entity field     ^ IdM key    ^ Transform from system ^
 +| leader ​             | leader ​    | false      | true         | Guarantess ​      | guarantees | does not have         |
 +| name                | name       | false      | true         | Name of position | position ​  | does not have         |
 +| __NAME__ ​           | __NAME__ ​  | true       | false        |                  |            | does not have         |
 +| owner               | owner      | false      | true         | Owner            | identity ​  | does not have         |
 +| state               | state      | false      | true         | State            | state      | has                   |
 +| valid_from ​         | valid_from | false      | true         | Valid from       | validFrom ​ | has                   |
 +| valid_to ​           | valid_to ​  | false      | true         | Valid till       | validTill ​ | has                   |
 +</​code>​
 +  * In **Transformation from system** field of **state** attribute there is green button **Insert script** select **Compiles identity-relation state** and click **Select**
 +{{ :​tutorial:​adm:​contracts_07_02.png |}}
 +  * Paste to **Transformation from system** field of **valid\_from** and **valid\_to** attributes:
 +
 +<​code>​
 +import org.joda.time.LocalDate;​
 + 
 +if(attributeValue){
 +    return new LocalDate(attributeValue);​
 +}
 +</​code>​
 +
 +  * Two examples how to fill attributes:
 +{{ :​tutorial:​adm:​contracts_08.png |}}
 +{{ :​tutorial:​adm:​contracts_09.png |}}
 +  * Now we have 7 mapped attributes:
 +{{ :​tutorial:​adm:​contracts_10.png |}}
 +  * Go to tab **Synchronization** and **Add** new synchronization.
 +{{ :​tutorial:​adm:​contracts_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:​contracts_12.png |}}
 +  * Confirm start synchronization:​
 +{{ :​tutorial:​adm:​sync_13.png |}}
 +  * Wait a few seconds, so synchronization can finish its job. And then go to **Users** section (in the left menu). And find user **john.roe**.
 +  * In tab positions there is now 3 contracts. The **Default** contract has been here since creating this user (for testing purposes) and the other two are synchronized from the database.
 +{{ :​tutorial:​adm:​contracts_14.png |}}
 +If you have it in a state like in the upper picture you successfully complete this tutorial.
 +
 +<note tip>​Thank you for following this tutorial, I hope it was useful.</​note>​