embulk-output-embulk_output_domo 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3978b59b3985b4520d50f23256d3708bda278d3c
4
- data.tar.gz: 2324808afdd8b2ba25934dbbffd95eecfabd8cb0
3
+ metadata.gz: 369ef52a51a9004c3d21d03946c6034b24d359d4
4
+ data.tar.gz: 9d046241a16d2156fca7cff577ca72560ca6d86b
5
5
  SHA512:
6
- metadata.gz: cef3cb441fb4d03a5e290747d61e08bc38fa31943cd165c70d0908d809aad1b3c023e2a8cd876f0ed2073a598eb461664bf749b8b1b7011850dfd5168f736fd8
7
- data.tar.gz: 640715724ddb4e0ad5e9abc1dd9fe490dc803ad7ab4c9b16a6454ece9099d6a8d3f28fbce4bdc6e29a763fc61178f833653acc9aea7df130b0ffc3b35d28a221
6
+ metadata.gz: 9e463ffcac24d5cebf86265d8a37905d3b2e9802df8b90d61d60234528e938fc578f9720e09dde4869a86d0fb9a52a847d500b03e06e8ea096b0700bf9c7507c
7
+ data.tar.gz: 51229748f9c9994efc3ea2413e9e8a96464559ec466dabbc259b6a52d318c5555ce44ac0bc8cfbaccea3ac6c138f90566befacfeb24f9820addf71c9cf333781
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.3.2"
16
+ version = "0.3.3"
17
17
 
18
18
  sourceCompatibility = 1.8
19
19
  targetCompatibility = 1.8
@@ -160,50 +160,6 @@ public class EmbulkOutputDomoOutputPlugin
160
160
  Newline getNewlineInField();
161
161
  }
162
162
 
163
- public com.domo.sdk.datasets.model.Schema getDomoSchema(Schema schema){
164
- /**
165
- * We need to return domo Schema
166
- * e.g. new com.domo.sdk.datasets.model.Schema(Lists.newArrayList(new Column(STRING, "Friend"), new Column(STRING, "Attending")))
167
- */
168
- ArrayList<com.domo.sdk.datasets.model.Column> domoSchema = new ArrayList<com.domo.sdk.datasets.model.Column>();
169
- for (int i = 0; i < schema.size(); i++) {
170
- Column column = schema.getColumn(i);
171
- Type type = column.getType();
172
- System.out.println("{\n" +
173
- " \"type\" : \""+type.getName().toUpperCase()+"\",\n" +
174
- " \"name\" : \""+column.getName() +"\"\n" +
175
- " },");
176
- switch (type.getName()) {
177
- case "long":
178
- domoSchema.add(new com.domo.sdk.datasets.model.Column(ColumnType.LONG, column.getName()));
179
- break;
180
- case "double":
181
- // System.out.println("Double Column" + column.getName());
182
- domoSchema.add(new com.domo.sdk.datasets.model.Column(ColumnType.DOUBLE, column.getName()));
183
- break;
184
- case "boolean":
185
- domoSchema.add(new com.domo.sdk.datasets.model.Column( ColumnType.LONG, column.getName()));
186
- break;
187
- case "string":
188
- domoSchema.add(new com.domo.sdk.datasets.model.Column(ColumnType.STRING, column.getName()));
189
- break;
190
- case "timestamp":
191
- domoSchema.add(new com.domo.sdk.datasets.model.Column( ColumnType.DATETIME, column.getName()));
192
- break;
193
- default:
194
- logger.info("Unsupported type " + type.getName());
195
- break;
196
- }
197
- }
198
- if(domoSchema != null && domoSchema.size()>0){
199
- return new com.domo.sdk.datasets.model.Schema(domoSchema);
200
- }
201
- else{
202
- logger.error("Cannot create domo schema");
203
- throw new RuntimeException("Cannot create domo Schema");
204
- }
205
- }
206
-
207
163
  @Override
208
164
  public ConfigDiff transaction(ConfigSource config,
209
165
  Schema schema, int taskCount,
@@ -219,7 +175,7 @@ public class EmbulkOutputDomoOutputPlugin
219
175
 
220
176
  try {
221
177
  if (client == null) {
222
- //getDomoSchema(schema);
178
+ com.domo.sdk.datasets.model.Schema ds_schema = getDomoSchema(schema);
223
179
  com.domo.sdk.request.Config domoConfig = com.domo.sdk.request.Config.with()
224
180
  .clientId(clientId)
225
181
  .clientSecret(clientSecret)
@@ -231,18 +187,36 @@ public class EmbulkOutputDomoOutputPlugin
231
187
 
232
188
  client = DomoClient.create(domoConfig);
233
189
  streamClient = client.streamClient();
234
-
190
+ logger.info("Lets search for dataSource.name = "+task.getStreamName());
235
191
  List<Stream> searchedSds = streamClient.search("dataSource.name:" + task.getStreamName());
236
- sds = searchedSds.get(0);
237
- logger.info("Stream "+ sds);
238
- execution = streamClient.createExecution(sds.getId());
239
- logger.info("Created Execution: " + execution);
240
- timestampFormatters = Timestamps.newTimestampColumnFormatters(task, schema, task.getColumnOptions());
241
- totalBatches = task.getBatchSize();
242
- File directory = new File(TEMP_DIR);
243
- if(!directory.exists()) {
244
- directory.mkdirs();
192
+ logger.info("Found search sds size = "+searchedSds.size());
193
+ if (searchedSds.size() >0) {
194
+ sds = searchedSds.get(0);
195
+ }
196
+ else{
197
+ logger.info("Lets create new Stream");
198
+ CreateDataSetRequest ds = new CreateDataSetRequest();
199
+ ds.setName(task.getStreamName());
200
+ ds.setDescription(task.getStreamName());
201
+ ds.setSchema(ds_schema);
202
+
203
+ logger.info("We have to create sds");
204
+ StreamRequest sdsRequest = new StreamRequest();
205
+
206
+ sdsRequest.setDataSet(ds);
207
+ sdsRequest.setUpdateMethod(UpdateMethod.REPLACE);
208
+
209
+ sds = streamClient.create(sdsRequest);
245
210
  }
211
+ logger.info("Stream "+ sds);
212
+ execution = streamClient.createExecution(sds.getId());
213
+ logger.info("Created Execution: " + execution);
214
+ timestampFormatters = Timestamps.newTimestampColumnFormatters(task, schema, task.getColumnOptions());
215
+ totalBatches = task.getBatchSize();
216
+ File directory = new File(TEMP_DIR);
217
+ if(!directory.exists()) {
218
+ directory.mkdirs();
219
+ }
246
220
  }
247
221
  }
248
222
  catch(Exception ex){
@@ -254,6 +228,7 @@ public class EmbulkOutputDomoOutputPlugin
254
228
  control.run(task.dump());
255
229
  return Exec.newConfigDiff();
256
230
  }
231
+
257
232
  @Override
258
233
  public ConfigDiff resume(TaskSource taskSource,
259
234
  Schema schema, int taskCount,
@@ -261,6 +236,7 @@ public class EmbulkOutputDomoOutputPlugin
261
236
  {
262
237
  throw new UnsupportedOperationException("embulk_output_domo output plugin does not support resuming");
263
238
  }
239
+
264
240
  @Override
265
241
  public void cleanup(TaskSource taskSource,
266
242
  Schema schema, int taskCount,
@@ -424,6 +400,7 @@ public class EmbulkOutputDomoOutputPlugin
424
400
  @Override
425
401
  public void booleanColumn(Column column) {
426
402
  addDelimiter(column);
403
+ //logger.info(pageReader.getBoolean(column));
427
404
  if (!pageReader.isNull(column)) {
428
405
  addValue(Boolean.toString(pageReader.getBoolean(column)));
429
406
  } else {
@@ -484,7 +461,7 @@ public class EmbulkOutputDomoOutputPlugin
484
461
  /**
485
462
  *
486
463
  * @param v String value
487
- * @param delimiter csv delimeter
464
+ * @param delimiter csv delimiter
488
465
  * @param policy enum QuotePolicy
489
466
  * @param quote Quote Character
490
467
  * @param escape Escape Character
@@ -700,6 +677,48 @@ public class EmbulkOutputDomoOutputPlugin
700
677
  bw.write(fileContent);
701
678
  bw.close();
702
679
  }
703
-
680
+ public com.domo.sdk.datasets.model.Schema getDomoSchema(Schema schema){
681
+ /**
682
+ * We need to return domo Schema
683
+ * e.g. new com.domo.sdk.datasets.model.Schema(Lists.newArrayList(new Column(STRING, "Friend"), new Column(STRING, "Attending")))
684
+ */
685
+ ArrayList<com.domo.sdk.datasets.model.Column> domoSchema = new ArrayList<com.domo.sdk.datasets.model.Column>();
686
+ for (int i = 0; i < schema.size(); i++) {
687
+ Column column = schema.getColumn(i);
688
+ Type type = column.getType();
689
+ // System.out.println("{\n" +
690
+ // " \"type\" : \""+type.getName().toUpperCase()+"\",\n" +
691
+ // " \"name\" : \""+column.getName() +"\"\n" +
692
+ // " },");
693
+ switch (type.getName()) {
694
+ case "long":
695
+ domoSchema.add(new com.domo.sdk.datasets.model.Column(ColumnType.LONG, column.getName()));
696
+ break;
697
+ case "double":
698
+ // System.out.println("Double Column" + column.getName());
699
+ domoSchema.add(new com.domo.sdk.datasets.model.Column(ColumnType.DOUBLE, column.getName()));
700
+ break;
701
+ case "boolean":
702
+ domoSchema.add(new com.domo.sdk.datasets.model.Column( ColumnType.LONG, column.getName()));
703
+ break;
704
+ case "string":
705
+ domoSchema.add(new com.domo.sdk.datasets.model.Column(ColumnType.STRING, column.getName()));
706
+ break;
707
+ case "timestamp":
708
+ domoSchema.add(new com.domo.sdk.datasets.model.Column( ColumnType.DATETIME, column.getName()));
709
+ break;
710
+ default:
711
+ logger.info("Unsupported type " + type.getName());
712
+ break;
713
+ }
714
+ }
715
+ if(domoSchema.size() > 0){
716
+ return new com.domo.sdk.datasets.model.Schema(domoSchema);
717
+ }
718
+ else{
719
+ logger.error("Cannot create domo schema");
720
+ throw new RuntimeException("Cannot create domo Schema");
721
+ }
722
+ }
704
723
 
705
724
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-embulk_output_domo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angelos Alexopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2019-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ files:
67
67
  - classpath/commons-io-2.6.jar
68
68
  - classpath/hamcrest-core-1.3.jar
69
69
  - classpath/okio-1.12.0.jar
70
- - classpath/embulk-output-embulk_output_domo-0.3.2.jar
70
+ - classpath/embulk-output-embulk_output_domo-0.3.3.jar
71
71
  homepage: https://github.com/alexopoulos7/embulk-output-embulk_output_domo
72
72
  licenses:
73
73
  - MIT