Skip to content

Commit abfbc51

Browse files
author
Olha Virolainen
authored
Issue 23 incorrect required fields (#34)
* Add new insert Action
1 parent 7ab6352 commit abfbc51

File tree

105 files changed

+1855
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1855
-612
lines changed

CHANGELOG.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
1-
## 2.2.0 (August 28, 2019)
1+
# JDBC Component
2+
3+
## 2.3.0 (September 25, 2019)
4+
5+
* Add new action `Insert`
6+
7+
## 2.2.0 (August 28, 2019)
28

39
* Add support `Configuration properties` for DB connection
410
* Enable circleci
511

6-
## 2.1.0 (July 30, 2019)
7-
8-
* Initial release which includes a bunch of previous unversioned releases
12+
## 2.1.0 (2019-07-22)
13+
14+
* Add Execute stored procedure action
15+
16+
## 2.0.1 (2019-06-24)
17+
18+
* Fix error logging for generating metadata of `Select` action
19+
20+
## 2.0.0 (2018-09-19)
21+
22+
* Add Select trigger
23+
* Add Get rows polling trigger
24+
25+
* Add Select action
26+
* Add Lookup by primary key action
27+
* Add Upsert by primary key action (for migration)
28+
* Add Delete by primary key action
29+
30+
* Remove CreateOrUpdateRecord action
31+
32+
* Fix issue in postgresql - getDate(null)
33+
* Fix null values as input for select

README.md

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This is an open source component for working with object-relational database management systems on [elastic.io platform](http://www.elastic.io "elastic.io platform").
55

66
### Completeness Matrix
7-
![JDBC Component Completeness Matrix](https://user-images.githubusercontent.com/5710732/55414696-e7c7bf80-556b-11e9-8aa9-bfe2ebca4303.png)
7+
![JDBC Component Completeness Matrix](https://user-images.githubusercontent.com/16806832/65326373-f6f20680-dbb9-11e9-9ad2-0900f68fd6e3.png)
88

99
[JDBC Component Completeness Matrix](https://docs.google.com/spreadsheets/d/1sZr9ydJbMK8v-TguctmFDiqgjRKcrpbdj4CeFuZEkQU/edit?usp=sharing)
1010

@@ -24,6 +24,9 @@ Following actions are inside:
2424
``UPSERT BY PRIMARY KEY`` - this action will execute select command from specified table, as search criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"), and execute insert command by PRIMARY KEY with specified field, if result does not found, else - action will execute update command by PRIMARY KEY with specified field. The action returns only one result row (a primary key is unique).
2525

2626
``DELETE BY PRIMARY KEY`` - this action will execute delete query from specified table, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"). The action returns an integer value that indicates the number of rows affected, the returned value can be 0 or 1 (a primary key is unique).
27+
28+
``INSERT`` - this action will execute insert query into the specified table. The action returns boolean value is execution insert successful or not.
29+
2730
### How works
2831

2932
### Requirements
@@ -168,38 +171,29 @@ Checkbox ``Don't throw Error on an Empty Result`` allows to emit an empty respon
168171
![image](https://user-images.githubusercontent.com/40201204/43644579-f593d1c8-9737-11e8-9b97-ee9e575a19f7.png)
169172
As an input metadata you will get a Primary Key field to provide the data inside as a clause value.
170173

171-
### Upsert Row By Primary Key action
172-
The action will execute ``SELECT`` command from a ``Tables`` dropdown field, as search criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"), and execute ``INSERT`` command by PRIMARY KEY with specified field, if result does not found, else - action will execute ``UPDATE`` command by PRIMARY KEY with specified field. The action returns only one result row (a primary key is unique).
173-
1. Find and select jdbc-component in the component repository
174-
![image](https://user-images.githubusercontent.com/16806832/44981615-c70a9d80-af7b-11e8-8055-3b553abe8212.png)
175-
176-
2. Create new or select existing credentials
177-
![image](https://user-images.githubusercontent.com/16806832/44981652-e86b8980-af7b-11e8-897e-04d1fc9a93cf.png)
178-
179-
3. Select action "Upsert Row By Primary Key" from list
180-
![image](https://user-images.githubusercontent.com/16806832/44981700-0d5ffc80-af7c-11e8-9ac3-aedb16e1d788.png)
174+
### Insert action
175+
The action will execute ``INSERT`` command into the table from ``Table`` dropdown list the values specified in the body.
181176

182-
4. Select table from ``Table`` dropdown list
183-
![image](https://user-images.githubusercontent.com/16806832/44981754-38e2e700-af7c-11e8-87d3-f029a7fec8fa.png)
177+
#### List of Expected Config fields
184178

185-
5. Specify input data (field with red asterisk is Primary key), and click "Continue"
186-
![image](https://user-images.githubusercontent.com/16806832/44981854-83fcfa00-af7c-11e8-9ef2-8c06e77fed1e.png)
179+
#### Input fields description
180+
##### Table
187181

188-
6. Retrieving sample
189-
![image](https://user-images.githubusercontent.com/16806832/44983059-86f9e980-af80-11e8-8178-77e463488c7a.png)
182+
Action contains only one configuration field `Table` - dropdown list with available table names.
183+
![image](https://user-images.githubusercontent.com/16806832/65327293-3f122880-dbbc-11e9-8a07-a10131900962.png)
190184

191-
7. Retrieve sample result
192-
![image](https://user-images.githubusercontent.com/16806832/44982952-2ec2e780-af80-11e8-98b1-58c3adbc15b9.png)
185+
#### Expected input metadata
193186

194-
8. Click "Continue"
195-
![image](https://user-images.githubusercontent.com/16806832/44983101-b0b31080-af80-11e8-82d8-0e70e4b4ff97.png)
187+
As input metadata, you will get all fields of the selected table except for fields with `auto-increment` or `auto-calculated` property.
196188

197-
9. Finish component configuration
198-
![image](https://user-images.githubusercontent.com/16806832/44983365-90378600-af81-11e8-9be4-4dbb39af0fdc.png)
189+
#### Expected output metadata
199190

200-
#### Input fields description
201-
As an input metadata you will get all fields of selected table. [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY") is required field (will mark as asterisk) and other input fields are optional.
202-
![image](https://user-images.githubusercontent.com/16806832/44397461-1a76f780-a549-11e8-8247-9a6f9aa3f3b4.png)
191+
As output metadata, you will get execution insert result like:
192+
```json
193+
{
194+
"result": true
195+
}
196+
```
203197

204198
### Delete Row By Primary Key action
205199
![image](https://user-images.githubusercontent.com/40201204/43592505-5b6bbfe8-967e-11e8-845e-2ce8ac707357.png)
@@ -249,6 +243,39 @@ Component generates next metadata:
249243

250244
![image](https://user-images.githubusercontent.com/22715422/62056735-edd26200-b226-11e9-871e-0efc305d70b2.png)
251245

246+
### Upsert Row By Primary Key action
247+
The action will execute ``SELECT`` command from a ``Tables`` dropdown field, as search criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"), and execute ``INSERT`` command by PRIMARY KEY with specified field, if result does not found, else - action will execute ``UPDATE`` command by PRIMARY KEY with specified field. The action returns only one result row (a primary key is unique).
248+
1. Find and select jdbc-component in the component repository
249+
![image](https://user-images.githubusercontent.com/16806832/44981615-c70a9d80-af7b-11e8-8055-3b553abe8212.png)
250+
251+
2. Create new or select existing credentials
252+
![image](https://user-images.githubusercontent.com/16806832/44981652-e86b8980-af7b-11e8-897e-04d1fc9a93cf.png)
253+
254+
3. Select action "Upsert Row By Primary Key" from list
255+
![image](https://user-images.githubusercontent.com/16806832/44981700-0d5ffc80-af7c-11e8-9ac3-aedb16e1d788.png)
256+
257+
4. Select table from ``Table`` dropdown list
258+
![image](https://user-images.githubusercontent.com/16806832/44981754-38e2e700-af7c-11e8-87d3-f029a7fec8fa.png)
259+
260+
5. Specify input data (field with red asterisk is Primary key), and click "Continue"
261+
![image](https://user-images.githubusercontent.com/16806832/44981854-83fcfa00-af7c-11e8-9ef2-8c06e77fed1e.png)
262+
263+
6. Retrieving sample
264+
![image](https://user-images.githubusercontent.com/16806832/44983059-86f9e980-af80-11e8-8178-77e463488c7a.png)
265+
266+
7. Retrieve sample result
267+
![image](https://user-images.githubusercontent.com/16806832/44982952-2ec2e780-af80-11e8-98b1-58c3adbc15b9.png)
268+
269+
8. Click "Continue"
270+
![image](https://user-images.githubusercontent.com/16806832/44983101-b0b31080-af80-11e8-82d8-0e70e4b4ff97.png)
271+
272+
9. Finish component configuration
273+
![image](https://user-images.githubusercontent.com/16806832/44983365-90378600-af81-11e8-9be4-4dbb39af0fdc.png)
274+
275+
#### Input fields description
276+
As an input metadata you will get all fields of selected table. [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY") is required field (will mark as asterisk) and other input fields are optional.
277+
![image](https://user-images.githubusercontent.com/16806832/44397461-1a76f780-a549-11e8-8247-9a6f9aa3f3b4.png)
278+
252279

253280
### Create or update record action (Deprecated)
254281
This action exists in JDBC component only for backward compatibility.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group = 'io.elastic'
2-
version = '2.2.0'
2+
version = '2.3.0'
33
apply plugin: 'java'
44
apply plugin: 'idea'
55
apply plugin: 'eclipse'

changelog.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

component.json

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
"prompt": "Select a Table",
6767
"label": "Tables List",
6868
"required": true,
69-
"model": "io.elastic.jdbc.TableNameProvider"
69+
"model": "io.elastic.jdbc.providers.TableNameProvider"
7070
},
7171
"pollingField": {
7272
"viewClass": "SelectView",
7373
"prompt": "Select a Timestamp (or similar) Column",
7474
"label": "Timestamp (or similar) Column",
75-
"model": "io.elastic.jdbc.ColumnNamesProvider",
75+
"model": "io.elastic.jdbc.providers.ColumnNamesProvider",
7676
"required": true,
7777
"require": [
7878
"tableName"
@@ -85,7 +85,7 @@
8585
"placeholder": "1970-01-01 00:00:00.000"
8686
}
8787
},
88-
"dynamicMetadata": "io.elastic.jdbc.ColumnNamesProvider"
88+
"dynamicMetadata": "io.elastic.jdbc.providers.ColumnNamesProvider"
8989
},
9090
"selectTrigger": {
9191
"main": "io.elastic.jdbc.triggers.SelectTrigger",
@@ -107,7 +107,7 @@
107107
"placeholder": "1970-01-01 00:00:00.000"
108108
}
109109
},
110-
"dynamicMetadata": "io.elastic.jdbc.ColumnNamesProvider"
110+
"dynamicMetadata": "io.elastic.jdbc.providers.ColumnNamesProvider"
111111
},
112112
"select": {
113113
"main": "io.elastic.jdbc.triggers.SelectTriggerOld",
@@ -121,20 +121,20 @@
121121
"prompt": "Select a Table",
122122
"label": "Tables List",
123123
"required": true,
124-
"model": "io.elastic.jdbc.TableNameProviderOld"
124+
"model": "io.elastic.jdbc.providers.TableNameProviderOld"
125125
},
126126
"orderField": {
127127
"viewClass": "SelectView",
128128
"prompt": "Select a field to order rows",
129129
"label": "Order Column",
130-
"model": "io.elastic.jdbc.ColumnNamesProviderOld",
130+
"model": "io.elastic.jdbc.providers.ColumnNamesProviderOld",
131131
"required": true,
132132
"require": [
133133
"tableName"
134134
]
135135
}
136136
},
137-
"dynamicMetadata": "io.elastic.jdbc.ColumnNamesProviderOld"
137+
"dynamicMetadata": "io.elastic.jdbc.providers.ColumnNamesProviderOld"
138138
}
139139
},
140140
"actions": {
@@ -148,17 +148,17 @@
148148
"prompt": "Select a Table",
149149
"label": "Table",
150150
"required": true,
151-
"model": "io.elastic.jdbc.TableNameProvider"
151+
"model": "io.elastic.jdbc.providers.TableNameProvider"
152152
},
153153
"nullableResult": {
154154
"label": "Don`t throw Error on an Empty Result",
155155
"viewClass": "CheckBoxView"
156156
}
157157
},
158-
"dynamicMetadata": "io.elastic.jdbc.PrimaryColumnNamesProvider"
158+
"dynamicMetadata": "io.elastic.jdbc.providers.PrimaryColumnNamesProvider"
159159
},
160160
"upsertRowByPrimaryKey": {
161-
"main": "io.elastic.jdbc.actions.UpsertRowByPrimaryKey",
161+
"main": "io.elastic.jdbc.actions.providers.UpsertRowByPrimaryKey",
162162
"title": "Upsert Row By Primary Key",
163163
"description": "Executes upsert by primary key",
164164
"fields": {
@@ -167,10 +167,25 @@
167167
"prompt": "Select a Table",
168168
"label": "Table",
169169
"required": true,
170-
"model": "io.elastic.jdbc.TableNameProvider"
170+
"model": "io.elastic.jdbc.providers.TableNameProvider"
171171
}
172172
},
173-
"dynamicMetadata": "io.elastic.jdbc.ColumnNamesWithPrimaryKeyProvider"
173+
"dynamicMetadata": "io.elastic.jdbc.providers.ColumnNamesWithPrimaryKeyProvider"
174+
},
175+
"insert": {
176+
"main": "io.elastic.jdbc.actions.InsertAction",
177+
"title": "Insert",
178+
"description": "Executes insert value",
179+
"fields": {
180+
"tableName": {
181+
"viewClass": "SelectView",
182+
"prompt": "Select a Table",
183+
"label": "Table",
184+
"required": true,
185+
"model": "io.elastic.jdbc.providers.TableNameProvider"
186+
}
187+
},
188+
"dynamicMetadata": "io.elastic.jdbc.providers.ColumnNamesForInsertProvider"
174189
},
175190
"deleteRowByPrimaryKey": {
176191
"main": "io.elastic.jdbc.actions.DeleteRowByPrimaryKey",
@@ -182,14 +197,14 @@
182197
"prompt": "Select a Table",
183198
"label": "Tables",
184199
"required": true,
185-
"model": "io.elastic.jdbc.TableNameProvider"
200+
"model": "io.elastic.jdbc.providers.TableNameProvider"
186201
},
187202
"nullableResult": {
188203
"label": "Don`t throw Error on an Empty Result",
189204
"viewClass": "CheckBoxView"
190205
}
191206
},
192-
"dynamicMetadata": "io.elastic.jdbc.PrimaryColumnNamesProvider"
207+
"dynamicMetadata": "io.elastic.jdbc.providers.PrimaryColumnNamesProvider"
193208
},
194209
"selectAction": {
195210
"main": "io.elastic.jdbc.actions.SelectAction",
@@ -208,7 +223,7 @@
208223
"viewClass": "CheckBoxView"
209224
}
210225
},
211-
"dynamicMetadata": "io.elastic.jdbc.QueryColumnNamesProvider"
226+
"dynamicMetadata": "io.elastic.jdbc.providers.QueryColumnNamesProvider"
212227
},
213228
"createOrUpdateRecord": {
214229
"main": "io.elastic.jdbc.actions.CreateOrUpdateRecord",
@@ -221,20 +236,20 @@
221236
"prompt": "Select a Table",
222237
"label": "Tables",
223238
"required": true,
224-
"model": "io.elastic.jdbc.TableNameProviderOld"
239+
"model": "io.elastic.jdbc.providers.TableNameProviderOld"
225240
},
226241
"idColumn": {
227242
"viewClass": "SelectView",
228243
"prompt": "Select an ID column",
229244
"label": "ID Column",
230-
"model": "io.elastic.jdbc.ColumnNamesProviderOld",
245+
"model": "io.elastic.jdbc.providers.ColumnNamesProviderOld",
231246
"required": true,
232247
"require": [
233248
"tableName"
234249
]
235250
}
236251
},
237-
"dynamicMetadata": "io.elastic.jdbc.ColumnNamesProviderOld"
252+
"dynamicMetadata": "io.elastic.jdbc.providers.ColumnNamesProviderOld"
238253
},
239254
"executeStoredProcedure": {
240255
"main": "io.elastic.jdbc.actions.ExecuteStoredProcedure",
@@ -246,20 +261,20 @@
246261
"prompt": "Select a Schema",
247262
"label": "DB Schema",
248263
"required": true,
249-
"model": "io.elastic.jdbc.SchemasProvider"
264+
"model": "io.elastic.jdbc.providers.SchemasProvider"
250265
},
251266
"procedureName": {
252267
"viewClass": "SelectView",
253268
"prompt": "Select a stored procedure name",
254269
"label": "Stored procedure",
255-
"model": "io.elastic.jdbc.ProcedureFieldsNameProvider",
270+
"model": "io.elastic.jdbc.providers.ProcedureFieldsNameProvider",
256271
"required": true,
257272
"require": [
258273
"schemaName"
259274
]
260275
}
261276
},
262-
"dynamicMetadata": "io.elastic.jdbc.ProcedureFieldsNameProvider"
277+
"dynamicMetadata": "io.elastic.jdbc.providers.ProcedureFieldsNameProvider"
263278
}
264279
}
265280
}

src/main/java/io/elastic/jdbc/JdbcCredentialsVerifier.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.elastic.api.CredentialsVerifier;
44
import io.elastic.api.InvalidCredentialsException;
5+
import io.elastic.jdbc.utils.Utils;
56
import java.sql.Connection;
67
import java.sql.SQLException;
78
import javax.json.JsonObject;

src/main/java/io/elastic/jdbc/actions/CreateOrUpdateRecord.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import io.elastic.api.ExecutionParameters;
66
import io.elastic.api.Message;
77
import io.elastic.api.Module;
8-
import io.elastic.jdbc.EnginesOld;
9-
import io.elastic.jdbc.SailorVersionsAdapter;
10-
import io.elastic.jdbc.UtilsOld;
8+
import io.elastic.jdbc.utils.EnginesOld;
9+
import io.elastic.jdbc.utils.SailorVersionsAdapter;
10+
import io.elastic.jdbc.utils.UtilsOld;
1111
import org.slf4j.Logger;
1212
import org.slf4j.LoggerFactory;
1313

0 commit comments

Comments
 (0)