Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
devel:documentation:systems:dev:scripted-jdbc-connector [2019/02/26 09:14] kotisovam [Using Scripted JDBC connector] snippet moved to admin guide |
devel:documentation:systems:dev:scripted-jdbc-connector [2022/08/23 15:49] apeterova Info about pooling configuration due to memory leak |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Using Scripted JDBC connector ====== | ====== Using Scripted JDBC connector ====== | ||
+ | |||
{{tag> jdbc connector}} | {{tag> jdbc connector}} | ||
- | |||
===== Configuration ===== | ===== Configuration ===== | ||
Line 10: | Line 10: | ||
* set an inline script (recommended only for deployments without FS) | * set an inline script (recommended only for deployments without FS) | ||
- | Another useful setting is " | + | Another useful setting is " |
+ | |||
+ | ==== Pooling configuration ==== | ||
+ | |||
+ | We recommed using the [[.: | ||
===== Schema attributes ===== | ===== Schema attributes ===== | ||
- | While retrieving account data from target system (the SEARCH operation), the connector requires us to set both %%__%%NAME%%__%% and %%__%%UID%%__%% attribute unconditionally. Both **must** be Strings. Therefore you are required to do this manually in your SEARCH script. Following is an example of retrieving user data: | + | While retrieving account data from target system (the SEARCH operation), the connector requires us to set both < |
<code groovy> | <code groovy> | ||
+ | import groovy.sql.Sql | ||
+ | import groovy.transform.Field | ||
+ | |||
@Field UID_ATTR = " | @Field UID_ATTR = " | ||
@Field TABLE_NAME = " | @Field TABLE_NAME = " | ||
Line 22: | Line 29: | ||
def sql = new Sql(connection) | def sql = new Sql(connection) | ||
def result = [] | def result = [] | ||
- | def select = " | + | String |
sql.eachRow(select, | sql.eachRow(select, | ||
def res = [:] | def res = [:] | ||
Line 32: | Line 39: | ||
}) | }) | ||
return result | return result | ||
+ | |||
+ | |||
</ | </ | ||
- | All retrieved attributes must be **a list of maps** (look for '' | ||
- | Another ' | + | All retrieved attributes must be **a list of maps** |
+ | |||
+ | Another ' | ||
- ignore the attribute in your script | - ignore the attribute in your script | ||
- always rename the attribute in the script | - always rename the attribute in the script | ||
- | The first option expects that you have an additional attribute | + | The first option expects that you have an additional attribute |
* LOGIN | * LOGIN | ||
- | * %%__%%NAME%%__%% | + | * < |
- | Then in mapping we check the LOGIN attribute as identifier and choose however we want to fill its value. The only difference with %%__%%NAME%%__%% attributes is that we will not check the identifier checkbox, otherwise it stays the same. | + | Then in mapping we check the LOGIN attribute as identifier and choose however we want to fill its value. The only difference with < |
- | The second option requires that all of your CRUD scripts handle the %%__%%NAME%%__%% attribute in a special way. For example you can rename it to your ID column name. This way of handling the identifier is rather straightforward, | + | The second option requires that all of your CRUD scripts handle the < |
===== Using groovy SQL ===== | ===== Using groovy SQL ===== | ||
- | Groovy has a powerful yet simple mechanism of querying databases through JDBC implemented in the '' | + | Groovy has a powerful yet simple mechanism of querying databases through JDBC implemented in the '' |
All values of ICF Attribute are of type java.lang.Object. To put it simply, typing does not exist here and the developer must handle it manually. If you only send simple attributes such as Strings, there is probably no need to worry about your queries. However mixing types together may cause unpredictable results. | All values of ICF Attribute are of type java.lang.Object. To put it simply, typing does not exist here and the developer must handle it manually. If you only send simple attributes such as Strings, there is probably no need to worry about your queries. However mixing types together may cause unpredictable results. | ||
Line 61: | Line 71: | ||
def retrieved = sql.firstRow(" | def retrieved = sql.firstRow(" | ||
println retrieved | println retrieved | ||
+ | |||
+ | |||
</ | </ | ||
- | Now everything should work just fine and we get our desired row printed out. But what if '' | ||
- | The danger with ICF Attributes is that these contain a //value// field - a list of values the Attribute carries. But if you accidentally call '' | + | Now everything should work just fine and we get our desired row printed out. But what if ''< |
+ | |||
+ | The danger with ICF Attributes is that these contain a // | ||
===== List of input variables ===== | ===== List of input variables ===== | ||
Line 77: | Line 90: | ||
* objectClass: | * objectClass: | ||
* id: The entry identifier (OpenICF " | * id: The entry identifier (OpenICF " | ||
- | * attributes: an Attribute Map, containg the '' | + | * attributes: an Attribute Map, containg the '' |
* password: password string, clear text | * password: password string, clear text | ||
* options: a handler to the OperationOptions Map | * options: a handler to the OperationOptions Map | ||
Line 101: | Line 114: | ||
* objectClass: | * objectClass: | ||
* uid: a String representing the entry uid | * uid: a String representing the entry uid | ||
- | * attributes: an Attribute Map, containg the '' | + | * attributes: an Attribute Map, containg the '' |
* password: password string, clear text (only for UPDATE) | * password: password string, clear text (only for UPDATE) | ||
* options: a handler to the OperationOptions Map | * options: a handler to the OperationOptions Map | ||
Line 113: | Line 126: | ||
* options: a handler to the OperationOptions Map | * options: a handler to the OperationOptions Map | ||
* uid: String for the unique id that specifies the object to delete | * uid: String for the unique id that specifies the object to delete | ||
+ | |||
+ |