Skip to content

Commit 8898623

Browse files
committed
Address comments
1 parent db07a0b commit 8898623

File tree

6 files changed

+94
-77
lines changed

6 files changed

+94
-77
lines changed

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ protected DBConnectorPath getDBConnectorPath(String path) {
112112

113113
@Override
114114
protected SchemaReader getSchemaReader(String sessionID) {
115-
return new OracleSourceSchemaReader(sessionID, config.getTreatAsOldTimestampConn(),
116-
config.getTreatPrecisionlessNumAsDeciConn());
115+
return new OracleSourceSchemaReader(sessionID, config.getTreatAsOldTimestamp(),
116+
config.getTreatPrecisionlessNumAsDeci());
117117
}
118118

119119
@Override

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnectorConfig.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public OracleConnectorConfig(String host, int port, String user, String password
4747

4848
public OracleConnectorConfig(String host, int port, String user, String password, String jdbcPluginName,
4949
String connectionArguments, String connectionType, String database,
50-
String role, Boolean useSSL, String treatAsOldTimestampConn,
51-
String treatPrecisionlessNumAsDeciConn) {
50+
String role, Boolean useSSL, Boolean treatAsOldTimestamp,
51+
Boolean treatPrecisionlessNumAsDeci) {
5252

5353
this.host = host;
5454
this.port = port;
@@ -60,8 +60,8 @@ public OracleConnectorConfig(String host, int port, String user, String password
6060
this.database = database;
6161
this.role = role;
6262
this.useSSL = useSSL;
63-
this.treatAsOldTimestampConn = treatAsOldTimestampConn;
64-
this.treatPrecisionlessNumAsDeciConn = treatPrecisionlessNumAsDeciConn;
63+
this.treatAsOldTimestamp = treatAsOldTimestamp;
64+
this.treatPrecisionlessNumAsDeci = treatPrecisionlessNumAsDeci;
6565
}
6666

6767
@Override
@@ -88,15 +88,15 @@ public String getConnectionString() {
8888
@Nullable
8989
public Boolean useSSL;
9090

91-
@Name(OracleConstants.TREAT_AS_OLD_TIMESTAMP_CONN)
91+
@Name(OracleConstants.TREAT_AS_OLD_TIMESTAMP)
9292
@Description("A hidden field to handle timestamp as CDAP's timestamp micros or string as per old behavior.")
9393
@Nullable
94-
public String treatAsOldTimestampConn;
94+
public Boolean treatAsOldTimestamp;
9595

96-
@Name(OracleConstants.TREAT_PRECISIONLESSNUM_AS_DECI_CONN)
96+
@Name(OracleConstants.TREAT_PRECISIONLESSNUM_AS_DECI)
9797
@Description("A hidden field to handle precision less number as CDAP's decimal per old behavior.")
9898
@Nullable
99-
public String treatPrecisionlessNumAsDeciConn;
99+
public Boolean treatPrecisionlessNumAsDeci;
100100

101101
@Override
102102
protected int getDefaultPort() {
@@ -120,12 +120,14 @@ public Boolean getSSlMode() {
120120
return useSSL != null && useSSL;
121121
}
122122

123-
public Boolean getTreatAsOldTimestampConn() {
124-
return Boolean.parseBoolean(treatAsOldTimestampConn);
123+
@Nullable
124+
public Boolean getTreatAsOldTimestamp() {
125+
return treatAsOldTimestamp;
125126
}
126127

127-
public Boolean getTreatPrecisionlessNumAsDeciConn() {
128-
return Boolean.parseBoolean(treatPrecisionlessNumAsDeciConn);
128+
@Nullable
129+
public Boolean getTreatPrecisionlessNumAsDeci() {
130+
return treatPrecisionlessNumAsDeci;
129131
}
130132

131133
@Override

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ private OracleConstants() {
4444
public static final String TRANSACTION_ISOLATION_LEVEL = "transactionIsolationLevel";
4545
public static final String USE_SSL = "useSSL";
4646
public static final String TREAT_AS_OLD_TIMESTAMP = "treatAsOldTimestamp";
47-
public static final String TREAT_AS_OLD_TIMESTAMP_CONN = "treatAsOldTimestampConn";
4847
public static final String TREAT_PRECISIONLESSNUM_AS_DECI = "treatPrecisionlessNumAsDeci";
49-
public static final String TREAT_PRECISIONLESSNUM_AS_DECI_CONN = "treatPrecisionlessNumAsDeciConn";
5048

5149
/**
5250
* Constructs the Oracle connection string based on the provided connection type, host, port, and database.

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSource.java

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,8 @@ protected String createConnectionString() {
6565
protected SchemaReader getSchemaReader() {
6666
//PLUGIN-1893 : Based on field/properties from Oracle source and Oracle connection we will pass the flag to control
6767
//handle schema to make it backward compatible.
68-
boolean treatAsOldTimestamp = oracleSourceConfig.getConnection().getTreatAsOldTimestampConn();
69-
70-
// If a user has modified the Oracle Source's properties, then it will take precedence.
71-
// In case of default value (which is false), the Conn's value should be considered.
72-
if (sourceConfig.getTreatAsOldTimestamp().equalsIgnoreCase("true") ||
73-
sourceConfig.getTreatAsOldTimestamp().equalsIgnoreCase("false")) {
74-
treatAsOldTimestamp = Boolean.parseBoolean(sourceConfig.getTreatAsOldTimestamp());
75-
}
76-
77-
boolean treatPrecisionlessNumAsDeci = oracleSourceConfig.getConnection().getTreatPrecisionlessNumAsDeciConn();
78-
if (sourceConfig.getTreatPrecisionlessNumAsDeci().equalsIgnoreCase("true") ||
79-
sourceConfig.getTreatPrecisionlessNumAsDeci().equalsIgnoreCase("false")) {
80-
treatPrecisionlessNumAsDeci = Boolean.parseBoolean(sourceConfig.getTreatPrecisionlessNumAsDeci());
81-
}
68+
boolean treatAsOldTimestamp = oracleSourceConfig.getConnection().getTreatAsOldTimestamp();
69+
boolean treatPrecisionlessNumAsDeci = oracleSourceConfig.getConnection().getTreatPrecisionlessNumAsDeci();
8270

8371
return new OracleSourceSchemaReader(null, treatAsOldTimestamp, treatPrecisionlessNumAsDeci);
8472
}
@@ -140,35 +128,22 @@ public static class OracleSourceConfig extends AbstractDBSpecificSourceConfig {
140128
@Nullable
141129
private Integer defaultRowPrefetch;
142130

143-
@Name(OracleConstants.TREAT_AS_OLD_TIMESTAMP)
144-
@Description("A hidden field to handle timestamp as CDAP's timestamp micros or string as per old behavior.")
145-
@Nullable
146-
private String treatAsOldTimestamp;
147-
148-
@Name(OracleConstants.TREAT_PRECISIONLESSNUM_AS_DECI)
149-
@Description("A hidden field to handle precision less number as CDAP's decimal per old behavior.")
150-
@Nullable
151-
public String treatPrecisionlessNumAsDeci;
152-
153131
public OracleSourceConfig(String host, int port, String user, String password, String jdbcPluginName,
154132
String connectionArguments, String connectionType, String database, String role,
155133
int defaultBatchValue, int defaultRowPrefetch,
156134
String importQuery, Integer numSplits, int fetchSize,
157-
String boundingQuery, String splitBy, Boolean useSSL, String treatAsOldTimestampConn,
158-
String treatAsOldTimestamp, String treatPrecisionlessNumAsDeciConn,
159-
String treatPrecisionlessNumAsDeci) {
135+
String boundingQuery, String splitBy, Boolean useSSL, Boolean treatAsOldTimestamp,
136+
Boolean treatPrecisionlessNumAsDeci) {
160137
this.connection = new OracleConnectorConfig(host, port, user, password, jdbcPluginName, connectionArguments,
161-
connectionType, database, role, useSSL, treatAsOldTimestampConn,
162-
treatPrecisionlessNumAsDeciConn);
138+
connectionType, database, role, useSSL, treatAsOldTimestamp,
139+
treatPrecisionlessNumAsDeci);
163140
this.defaultBatchValue = defaultBatchValue;
164141
this.defaultRowPrefetch = defaultRowPrefetch;
165142
this.fetchSize = fetchSize;
166143
this.importQuery = importQuery;
167144
this.numSplits = numSplits;
168145
this.boundingQuery = boundingQuery;
169146
this.splitBy = splitBy;
170-
this.treatAsOldTimestamp = treatAsOldTimestamp;
171-
this.treatPrecisionlessNumAsDeci = treatPrecisionlessNumAsDeci;
172147
}
173148

174149
@Override
@@ -195,14 +170,6 @@ public OracleConnectorConfig getConnection() {
195170
return connection;
196171
}
197172

198-
public String getTreatAsOldTimestamp() {
199-
return treatAsOldTimestamp == null ? "" : treatAsOldTimestamp;
200-
}
201-
202-
public String getTreatPrecisionlessNumAsDeci() {
203-
return treatPrecisionlessNumAsDeci == null ? "" : treatPrecisionlessNumAsDeci;
204-
}
205-
206173
@Override
207174
public void validate(FailureCollector collector) {
208175
ConfigUtil.validateConnection(this, useConnection, connection, collector);

oracle-plugin/widgets/Oracle-batchsource.json

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,44 @@
120120
]
121121
}
122122
},
123+
{
124+
"widget-type": "hidden",
125+
"label": "Treat as old timestamp",
126+
"name": "treatAsOldTimestamp",
127+
"widget-attributes": {
128+
"layout": "inline",
129+
"default": "false",
130+
"options": [
131+
{
132+
"id": "true",
133+
"label": "true"
134+
},
135+
{
136+
"id": "false",
137+
"label": "false"
138+
}
139+
]
140+
}
141+
},
142+
{
143+
"widget-type": "hidden",
144+
"label": "Treat precision less number as Decimal(old behavior)",
145+
"name": "treatPrecisionlessNumAsDeci",
146+
"widget-attributes": {
147+
"layout": "inline",
148+
"default": "false",
149+
"options": [
150+
{
151+
"id": "true",
152+
"label": "true"
153+
},
154+
{
155+
"id": "false",
156+
"label": "false"
157+
}
158+
]
159+
}
160+
},
123161
{
124162
"name": "connectionType",
125163
"label": "Connection Type",
@@ -246,24 +284,6 @@
246284
"default": "40",
247285
"min": "1"
248286
}
249-
},
250-
{
251-
"widget-type": "hidden",
252-
"label": "Treat as old timestamp.",
253-
"name": "treatAsOldTimestamp",
254-
"description": "If edited, then this will take precedence over other properties and the edited value shall be true or false only",
255-
"widget-attributes": {
256-
"default": "default-no"
257-
}
258-
},
259-
{
260-
"widget-type": "hidden",
261-
"label": "Treat precision less number as Decimal(old behavior)",
262-
"name": "treatPrecisionlessNumAsDeci",
263-
"description": "If edited, then this will take precedence over other properties and the edited value shall be true or false only",
264-
"widget-attributes": {
265-
"default": "default-no"
266-
}
267287
}
268288
]
269289
}
@@ -344,6 +364,14 @@
344364
{
345365
"type": "property",
346366
"name": "transactionIsolationLevel"
367+
},
368+
{
369+
"type": "property",
370+
"name": "getTreatAsOldTimestampConn"
371+
},
372+
{
373+
"type": "property",
374+
"name": "treatPrecisionlessNumAsDeci"
347375
}
348376
]
349377
},

oracle-plugin/widgets/Oracle-connector.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,39 @@
133133
{
134134
"widget-type": "hidden",
135135
"label": "Treat as old timestamp",
136-
"name": "treatAsOldTimestampConn",
136+
"name": "treatAsOldTimestamp",
137137
"widget-attributes": {
138-
"default": "false"
138+
"layout": "inline",
139+
"default": "false",
140+
"options": [
141+
{
142+
"id": "true",
143+
"label": "true"
144+
},
145+
{
146+
"id": "false",
147+
"label": "false"
148+
}
149+
]
139150
}
140151
},
141152
{
142153
"widget-type": "hidden",
143154
"label": "Treat precision less number as Decimal(old behavior)",
144-
"name": "treatPrecisionlessNumAsDeciConn",
155+
"name": "treatPrecisionlessNumAsDeci",
145156
"widget-attributes": {
146-
"default": "false"
157+
"layout": "inline",
158+
"default": "false",
159+
"options": [
160+
{
161+
"id": "true",
162+
"label": "true"
163+
},
164+
{
165+
"id": "false",
166+
"label": "false"
167+
}
168+
]
147169
}
148170
}
149171
]

0 commit comments

Comments
 (0)