forked from mhavey/marklogic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuml2es.gradle
662 lines (575 loc) · 25.8 KB
/
uml2es.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/*
Gradle tasks for UML2ES Toolkit. Use this in your project.
You can either:
- copy bits and pieces of it into your own gradle build file
- use this as the basis for your gradle build file; build on it
- keep it as is and call it to run just the UML2ES tasks using gradle's -b flag;
you will also have another gradle build file with the rest of your tasks
Tasks that begin with "_" are private. Don't call them; they are called internally.
Tasks that begin with "u" are public. Call them!
Feel free to edit the versions of plugins and classes to suit your needs
*/
buildscript {
repositories {
jcenter{url "http://jcenter.bintray.com/"}
mavenLocal()
maven { url "http://plugins.gradle.org/m2" }
}
dependencies {
classpath "com.marklogic:ml-gradle:3.4.0"
classpath "net.saliman:gradle-properties-plugin:1.4.6"
}
}
apply plugin: "net.saliman.properties"
apply plugin: "com.marklogic.ml-gradle"
repositories {
jcenter{url "http://jcenter.bintray.com/"}
// Needed for mlcp dependencies
maven { url "http://plugins.gradle.org/m2" }
maven { url "http://developer.marklogic.com/maven2/" }
// Needed for hadoop dependencies for mlcp
maven { url "http://repository.cloudera.com/artifactory/cloudera-repos/" }
}
configurations {
// This configuration captures the dependencies for running mlcp (Content Pump). This is only needed if you want
// to run mlcp via Gradle tasks. If you do, using com.marklogic.gradle.task.MlcpTask is a useful starting point, as
// shown below. Need to force to use certain version of xml-apis library.
mlcp {
resolutionStrategy {
force "xml-apis:xml-apis:1.4.01"
}
}
}
dependencies {
mlcp "com.marklogic:mlcp:9.0.6"
mlcp "org.apache.commons:commons-csv:1.2"
mlcp files("lib")
}
/*
* PRIVATE TASKS: Model deployment
*/
task _mLoadXMI(type: com.marklogic.gradle.task.MlcpTask) {
def srcDir = new File("${projectDir}").getAbsolutePath()
def unixDir = srcDir.replace('\\', '/') + "/data/model"
def regex = '"' + unixDir + ",'',/,''" + '"'
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = project.findProperty("mlAppServicesHost")
def myPort = project.findProperty("mlAppServicesPort")
if (myPort == null) myPort = project.findProperty("mlRestPort")
if (myPort == null) myPort = project.findProperty("mlFinalPort")
def tparam = "dummy"
if (project.findProperty("lax") != null && project.findProperty("lax") == "true") tparam = '{"lax": "true"}'
def fullModelName = null;
if (project.findProperty("modelName") != null) fullModelName = project.findProperty("modelName") + ".xml"
def fdir = file(unixDir)
def files = null
if (fdir != null) files = fdir.list()
enabled = fullModelName != null && files != null && files.contains(fullModelName)
classpath = configurations.mlcp
command = "IMPORT"
document_type = "xml"
input_file_path = unixDir + "/" + fullModelName
input_file_type = "documents"
output_uri_replace = regex
output_uri_prefix = "/xmi2es/xmi/"
output_permissions = "rest-reader,read,rest-writer,update"
output_collections = "xmi2es"
host = myHost
port = myPort.toInteger()
transform_module = "/xmi2es/xmi2esTransform.xqy"
transform_namespace ="http://marklogic.com/xmi2es"
transform_param = tparam
}
task _mLoadExcel(type: com.marklogic.gradle.task.MlcpTask) {
def srcDir = new File("${projectDir}").getAbsolutePath()
def unixDir = srcDir.replace('\\', '/') + "/data/model-excel"
def regex = '"' + unixDir + ",'',/,''" + '"'
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = project.findProperty("mlAppServicesHost")
def myPort = project.findProperty("mlAppServicesPort")
if (myPort == null) myPort = project.findProperty("mlRestPort")
if (myPort == null) myPort = project.findProperty("mlFinalPort")
def tparam = "dummy"
if (project.findProperty("lax") != null && project.findProperty("lax") == "true") tparam = '{"lax": "true"}'
def fullModelName = null;
if (project.findProperty("modelName") != null) fullModelName = project.findProperty("modelName") + ".xlsx"
def fdir = file(unixDir)
def files = null
if (fdir != null) files = fdir.list()
enabled = fullModelName != null && files != null && files.contains(fullModelName)
classpath = configurations.mlcp
command = "IMPORT"
document_type = "binary"
input_file_path = unixDir + "/" + fullModelName
input_file_type = "documents"
output_uri_replace = regex
output_uri_prefix = "/xmi2es/excel/"
output_permissions = "rest-reader,read,rest-writer,update"
output_collections = "xmi2es"
host = myHost
port = myPort.toInteger()
transform_module = "/xmi2es/excel2uml.xqy"
transform_namespace = "http://marklogic.com/xmi2es/xlsx"
transform_param = tparam
}
task _mFetchDescriptors(type: com.marklogic.gradle.task.MlcpTask) {
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = project.findProperty("mlAppServicesHost")
def myPort = project.findProperty("mlAppServicesPort")
if (myPort == null) myPort = project.findProperty("mlRestPort")
if (myPort == null) myPort = project.findProperty("mlFinalPort")
classpath = configurations.mlcp
command = "EXPORT"
output_file_path = "data/entity-services-dump"
collection_filter = "xmi2es"
host = myHost
port = myPort.toInteger()
}
task _mCopyES(type: Copy) {
from "data/entity-services-dump/xmi2es/es"
into "data/entity-services"
}
task _mCopyESExt(type: Copy) {
from "data/entity-services-dump/xmi2es/extension"
into "data/entity-services-extension"
}
task _mCopyGenCode(type: Copy) {
from "data/entity-services-dump/xmi2es/gen"
into "src/main/ml-modules/root/modelgen"
}
task _mDeleteES(type: Delete) {
delete "data/entity-services-dump", "data/entity-services-extension"
}
task _mLoadExtendedModel(type: com.marklogic.gradle.task.MlcpTask) {
def srcDir = new File("${projectDir}").getAbsolutePath()
def unixDir = srcDir.replace('\\', '/') + "/data/entity-services-extension"
def regex = '"' + unixDir + ",'',/,''" + '"'
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = project.findProperty("mlAppServicesHost")
def myPort = project.findProperty("mlAppServicesPort")
if (myPort == null) myPort = project.findProperty("mlRestPort")
if (myPort == null) myPort = project.findProperty("mlFinalPort")
def fullModelName = null;
if (project.findProperty("modelName") != null) fullModelName = project.findProperty("modelName") + ".ttl"
enabled = fullModelName != null
classpath = configurations.mlcp
command = "IMPORT"
host = myHost
port = myPort.toInteger()
input_file_path = unixDir + "/" + fullModelName
input_file_type = "rdf"
output_uri_prefix = "/triplestore"
output_graph = project.findProperty("modelName")
}
task _mRemoveOldExtendedModel(type: com.marklogic.gradle.task.ServerEvalTask) {
def graphName = project.findProperty("modelName")
enabled = graphName != null
def js = "'use strict';\n"
js += 'declareUpdate();'
js += 'const sem = require("/MarkLogic/semantics.xqy");\n'
js += 'sem.graphDelete(sem.iri("' + graphName + '"));\n'
javascript = js;
}
/*
This ensures ES model is deployed to FINAL, not STAGING
*/
task _mDeployESModelToFinal(type: com.marklogic.gradle.task.MlcpTask) {
def srcDir = new File("${projectDir}").getAbsolutePath()
def unixDir = srcDir.replace('\\', '/') + "/data/entity-services"
def regex = '"' + unixDir + ",'',/,''" + '"'
def fullModelName = null;
if (project.findProperty("modelName") != null) fullModelName = project.findProperty("modelName") + ".json"
def fdir = file(unixDir)
def files = null
if (fdir != null) files = fdir.list()
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = ""
def myPort = project.findProperty("mlFinalPort")
if (myPort == null) myPort = "0"
enabled = fullModelName != null && files != null && files.contains(fullModelName) && project.findProperty("mlFinalPort") != null
classpath = configurations.mlcp
command = "IMPORT"
document_type = "json"
input_file_path = unixDir + "/" + fullModelName
input_file_type = "documents"
output_uri_replace = regex
output_uri_prefix = "/marklogic.com/entity-services/models/"
output_permissions = "rest-reader,read,rest-writer,update"
output_collections = "http://marklogic.com/entity-services/models"
host = myHost
port = myPort.toInteger()
}
task _mLoadMappingSpec(type: com.marklogic.gradle.task.MlcpTask) {
def srcDir = new File("${projectDir}").getAbsolutePath()
def unixDir = srcDir.replace('\\', '/') + "/data/mapping"
def regex = '"' + unixDir + ",'',/,''" + '"'
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = project.findProperty("mlAppServicesHost")
def myPort = project.findProperty("mlAppServicesPort")
if (myPort == null) myPort = project.findProperty("mlRestPort")
if (myPort == null) myPort = project.findProperty("mlFinalPort")
def fullSpecName = null;
if (project.findProperty("specName") != null) fullSpecName = project.findProperty("specName") + ".xlsx"
def fdir = file(unixDir)
def files = null
if (fdir != null) files = fdir.list()
enabled = fullSpecName != null && files != null && files.contains(fullSpecName)
classpath = configurations.mlcp
command = "IMPORT"
document_type = "binary"
input_file_path = unixDir + "/" + fullSpecName
input_file_type = "documents"
output_uri_replace = regex
output_uri_prefix = "/xmi2es/excel-mapper/"
output_permissions = "rest-reader,read,rest-writer,update"
output_collections = "xmi2es"
host = myHost
port = myPort.toInteger()
transform_module = "/xmi2es/excelMapper.xqy"
transform_namespace = "http://marklogic.com/xmi2es/xlsx/mapper"
transform_param = "dummy"
}
task _mDiscover(type: com.marklogic.gradle.task.ServerEvalTask) {
def discover = project.findProperty("discover")
def mappingURI = '"/xmi2es/excel-mapper/' + project.findProperty("specName") + '.xlsx"'
def discoveryDB = ""
if (project.findProperty("mlStagingDbName") != null) discoveryDB = '"' + project.findProperty("mlStagingDbName") + '"'
else discoveryDB = '"' + project.findProperty("mlAppName") + "-content"
enabled = discover != null && discover == "true"
def js = "'use strict';\n"
js += 'const discover = require("/xmi2es/discovery.sjs");\n'
js += 'discover.discoverFromMapping(' + mappingURI + ',' + discoveryDB + ');\n'
println js
javascript = js;
}
/*
* PRIVATE TASKS: Cookie cutter
*/
task _cDeleteCutDump(type: Delete) {
delete "data/cookieCutter-dump"
}
task _cCutEntities(type: com.marklogic.gradle.task.ServerEvalTask) {
def modelName = project.findProperty("modelName")
if (modelName != null) modelName = '"' + modelName + '"'
def entities = project.findProperty("entities")
if (entities != null) entities = '"' + entities + '"'
def entitySelect = project.findProperty("entitySelect")
if (entitySelect != null) entitySelect = '"' + entitySelect + '"'
def stg = '"' + project.findProperty("mlStagingDbName") + '"';
def js = "'use strict';\n"
js += 'const cookie = require("/xmi2es/cookieCutter.sjs");\n'
js += 'cookie.createEntities(' + modelName + ',' + entitySelect + ',' + entities + ',' + stg + ');\n'
println js
javascript = js;
}
task _cFetchEntities(type: com.marklogic.gradle.task.MlcpTask) {
def directoryFilter = "/cookieCutter/" + project.findProperty("modelName") + "/plugins/entities/"
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = ""
def myPort = project.findProperty("mlFinalPort")
if (myPort == null) myPort = "0"
classpath = configurations.mlcp
command = "EXPORT"
output_file_path = "plugins"
output_file_path = "data/cookieCutter-dump"
directory_filter = directoryFilter
host = myHost
port = myPort.toInteger()
}
task _cPromoteEntities(type: Copy) {
from "data/cookieCutter-dump/cookieCutter/" + project.findProperty("modelName") + "/plugins/entities"
into "plugins/entities"
}
task _cCutHarmonizeFlow(type: com.marklogic.gradle.task.ServerEvalTask) {
def modelName = project.findProperty("modelName")
if (modelName != null) modelName = '"' + modelName + '"'
def entityName = project.findProperty("entityName")
if (entityName != null) entityName = '"' + entityName + '"'
def dataFormat = project.findProperty("dataFormat")
if (dataFormat != null) dataFormat = '"' + dataFormat + '"'
def pluginFormat = project.findProperty("pluginFormat")
if (pluginFormat != null) pluginFormat = '"' + pluginFormat + '"'
def flowName = project.findProperty("flowName")
if (flowName != null) flowName = '"' + flowName + '"'
def contentMode = project.findProperty("contentMode")
if (contentMode != null) contentMode = '"' + contentMode + '"'
def mappingSpec = project.findProperty("mappingSpec")
if (mappingSpec != null) mappingSpec = '"' + mappingSpec + '"'
def stg = '"' + project.findProperty("mlStagingDbName") + '"';
def js = "'use strict';\n"
js += 'const cookie = require("/xmi2es/cookieCutter.sjs");\n'
js += 'cookie.createHarmonizeFlow(' + modelName + ',' + entityName + ',' + dataFormat + ',' + pluginFormat + ',' + flowName + ',' + contentMode + ',' + mappingSpec + ',' + stg + ');\n'
println js
javascript = js;
}
task _cCutConversionModule(type: com.marklogic.gradle.task.ServerEvalTask) {
def modelName = project.findProperty("modelName")
if (modelName != null) modelName = '"' + modelName + '"'
def entityName = project.findProperty("entityName")
if (entityName != null) entityName = '"' + entityName + '"'
def dataFormat = project.findProperty("dataFormat")
if (dataFormat != null) dataFormat = '"' + dataFormat + '"'
def pluginFormat = project.findProperty("pluginFormat")
if (pluginFormat != null) pluginFormat = '"' + pluginFormat + '"'
def moduleName = project.findProperty("moduleName")
if (moduleName != null) moduleName = '"' + moduleName + '"'
def contentMode = project.findProperty("contentMode")
if (contentMode != null) contentMode = '"' + contentMode + '"'
def mappingSpec = project.findProperty("mappingSpec")
if (mappingSpec != null) mappingSpec = '"' + mappingSpec + '"'
def js = "'use strict';\n"
js += 'const cookie = require("/xmi2es/cookieCutter.sjs");\n'
js += 'cookie.createConversionModule(' + modelName + ',' + entityName + ',' + dataFormat + ',' + pluginFormat + ',' + moduleName + ',' + contentMode + ',' + mappingSpec + ');\n'
println js
javascript = js;
}
task _cFetchCutHarmonizeFlow(type: com.marklogic.gradle.task.MlcpTask) {
def directoryFilter = "/cookieCutter/" + project.findProperty("modelName") + "/plugins/entities/" + project.findProperty("entityName") + "/harmonize/" + project.findProperty("flowName") + "/"
directoryFilter += ",/dm/mapper/" + project.findProperty("modelName") + "/"
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = ""
def myPort = project.findProperty("mlFinalPort")
if (myPort == null) myPort = "0"
classpath = configurations.mlcp
command = "EXPORT"
output_file_path = "data/cookieCutter-dump"
directory_filter = directoryFilter
host = myHost
port = myPort.toInteger()
}
task _cPromoteCutHarmonizeFlow(type: Copy) {
def harmPath = "plugins/entities/" + project.findProperty("entityName") + "/harmonize"
def flowPath = harmPath + "/" + project.findProperty("flowName")
enabled = project.findProperty("overwrite") == "true" || !file(flowPath).exists()
from "data/cookieCutter-dump/cookieCutter/" + project.findProperty("modelName") + "/" + flowPath
into flowPath
}
task _cFetchCutConversionModule(type: com.marklogic.gradle.task.MlcpTask) {
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = project.findProperty("mlAppServicesHost")
def myPort = project.findProperty("mlAppServicesPort")
if (myPort == null) myPort = project.findProperty("mlRestPort")
if (myPort == null) myPort = project.findProperty("mlFinalPort")
def directoryFilter = "/cookieCutter/" + project.findProperty("modelName") + "/src/main/ml-modules/root/esconversion/" + project.findProperty("modelName") + "/" + project.findProperty("entityName") + "/"
classpath = configurations.mlcp
command = "EXPORT"
output_file_path = "data/cookieCutter-dump"
directory_filter = directoryFilter
host = myHost
port = myPort.toInteger()
}
task _cPromoteCutConversionModule(type: Copy) {
def convPath = "src/main/ml-modules/root/esconversion/" + project.findProperty("modelName") + "/" + project.findProperty("entityName")
println '!!!!' + convPath
enabled = project.findProperty("overwrite") == "true" || !file(convPath).exists()
from "data/cookieCutter-dump/cookieCutter/" + project.findProperty("modelName") + "/" + convPath
into convPath
}
/*
* PUBLIC TASKS
*/
/*
uDeployModel : deploys your UML (or even Excel) model as an ES model
Input:
- modelName (XMI or Excel filename without suffix)
- lax: true/false. Default: false (Use lax mode when transforming from UML to ES.)
Dependencies:
- Your gradle project has the folder data/model
- Your model is in that folder
- Your model is XMI
- Your model ends in .xml
- Standard ml-gradle environment properties: mlAppServicesHost, mlAppServicesPort. OR ...
- Standard DHF environment properties: mlHost, mlFinalPort
Effects:
- Target database has the UML model, the ES model, the ES extensions, findings, generated code
- Target database has the ES model and its extended triples deployed
- Your gradle project has entity-services, entity-services-dump, entity-services-extension folders
- You will see generated code in src/main/ml-config, src/main/ml-modules, src/main/ml-schemas
*/
task uDeployModel() {
dependsOn '_mDeleteES'
dependsOn '_mLoadXMI'
dependsOn '_mLoadExcel'
dependsOn '_mFetchDescriptors'
dependsOn '_mCopyES'
dependsOn '_mCopyESExt'
dependsOn '_mCopyGenCode'
dependsOn '_mRemoveOldExtendedModel'
dependsOn '_mLoadExtendedModel'
dependsOn 'mlGenerateModelArtifacts'
dependsOn '_mDeployESModelToFinal'
tasks.findByName('_mLoadXMI').mustRunAfter '_mDeleteES'
tasks.findByName('_mLoadExcel').mustRunAfter '_mDeleteES'
tasks.findByName('_mFetchDescriptors').mustRunAfter '_mLoadXMI'
tasks.findByName('_mFetchDescriptors').mustRunAfter '_mLoadExcel'
tasks.findByName('_mCopyESExt').mustRunAfter '_mFetchDescriptors'
tasks.findByName('_mCopyES').mustRunAfter '_mFetchDescriptors'
tasks.findByName('_mCopyGenCode').mustRunAfter '_mFetchDescriptors'
tasks.findByName('mlGenerateModelArtifacts').mustRunAfter '_mCopyES'
tasks.findByName('_mDeployESModelToFinal').mustRunAfter '_mCopyES'
tasks.findByName('_mLoadExtendedModel').mustRunAfter '_mCopyESExt'
tasks.findByName('_mLoadExtendedModel').mustRunAfter '_mRemoveOldExtendedModel'
}
/*
uLoadMappingSpec : loads your Excel mapping spec for use in cookie cutter codegen
Input:
- specName = mandatory (Excel filename without suffix)
- discover = true/false; default false
- discoveryDB = default: content DB (non-DHF), staging DB (DHF0)
Dependencies:
- Your gradle project has the folder data/mapping
- Your mapping spec is in that folder
- Standard ml-gradle environment properties: mlAppServicesHost, mlAppServicesPort. OR ...
- Standard DHF environment properties: mlHost, mlFinalPort
Effects:
- Target database has the mapping spec (original Excel plus transformed json)
*/
task uLoadMappingSpec() {
dependsOn '_mLoadMappingSpec'
dependsOn '_mDiscover'
tasks.findByName('_mDiscover').mustRunAfter '_mLoadMappingSpec'
}
/*
uCreateDHFEntities - create DHF plugin entities; a souped-up hubCreateEntity
Input:
- modelName - name of UML module file without .xml suffix
- entities (optional) - CSV of class names representing entities to create
- entitySelect (optional) - Possible values:
"infer" - Have the cookie cutter infer which classes are entities. Ignore entities specified.
"all" - All classes are considered entities. Ignore entities specified.
Dependencies:
- Your gradle project is DHF 4.1
- You have deployed your UML model
- Standard DHF environment properties: mlHost, mlFinalPort
Effects:
- New plugins created under plugins/entities folder
*/
task uCreateDHFEntities() {
dependsOn '_cDeleteCutDump'
dependsOn '_cCutEntities'
dependsOn '_cFetchEntities'
dependsOn '_cPromoteEntities'
tasks.findByName('_cFetchEntities').mustRunAfter '_cCutEntities'
tasks.findByName('_cFetchEntities').mustRunAfter '_cDeleteCutDump'
tasks.findByName('_cPromoteEntities').mustRunAfter '_cFetchEntities'
}
/*
uCreateDHFHarmonizeFlow - creates a harmonize flow for the specified entity. A souped-up hubCreateHarmonizeFlow
Input:
- modelName - name of UML module file without .xml suffix
- entityName - name of the entity. You must already have created this using uCreateDHFEntities
- dataFormat: xml, json
- pluginFormat: xqy, sjs
- flowName: the harmonization flow name
- contentMode: possible values
es - Entity Services mode. The cookie cutter generates ES-conversion style code and
incorporates hints from the data model and the mapping spec. This is like a souped up -useES option.
dm - Declarative Mapper mode. This feature is not ready yet.
- mappingSpec: previously uploaded Excel mapping spec; refer to it by the Excel URI
- overwrite: true/false. If true and harmonization already exists, overwrite it. If you don't want to clobber, set to false.
Dependencies:
- Your gradle project is DHF 4.1
- You have deployed your UML model
- You have created the entity in question using uCreateDHFEntities
- Standard DHF environment properties: mlHost, mlFinalPort
Effects:
- New harmonization flow plugins/entities/entityName/harmonize folder
*/
task uCreateDHFHarmonizeFlow() {
dependsOn '_cDeleteCutDump'
dependsOn '_cCutHarmonizeFlow'
dependsOn '_cFetchCutHarmonizeFlow'
dependsOn '_cPromoteCutHarmonizeFlow'
tasks.findByName('_cFetchCutHarmonizeFlow').mustRunAfter '_cCutHarmonizeFlow'
tasks.findByName('_cFetchCutHarmonizeFlow').mustRunAfter '_cDeleteCutDump'
tasks.findByName('_cPromoteCutHarmonizeFlow').mustRunAfter '_cFetchCutHarmonizeFlow'
}
/*
uCreateConversionModule - creates a harmonize flow for the specified entity. A souped up es.instanceConverterGenerate.
Input:
- modelName - name of UML module file without .xml suffix
- entityName - name of the entity.
- dataFormat: xml, json
- pluginFormat: xqy, sjs
- moduleName the module name
- contentMode: possible values
es - Entity Services mode. The cookie cutter generates ES-conversion style code and
incorporates hints from the data model and the mapping spec. This is like a souped up -useES option.
dm - Declarative Mapper mode. This feature is not ready yet.
- mappingSpec: previously uploaded Excel mapping spec; refer to it by the Excel URI
- overwrite: true/false. If true and the module already exists, overwrite it. If you don't want to clobber, set to false.
Dependencies:
- You have deployed your UML model
- Standard ml-gradle environment properties: mlAppServicesHost, mlAppServicesPort. OR ...
- Standard DHF environment properties: mlHost, mlFinalPort. BUT WE RECOMMEND USING uCreateDHFHarmonizeFlow IF YOU ARE ON DHF.
Effects:
- New conversion module in src/main/ml-modules/root/modelName/entityName folder
*/
task uCreateConversionModule() {
dependsOn '_cDeleteCutDump'
dependsOn '_cCutConversionModule'
dependsOn '_cFetchCutConversionModule'
dependsOn '_cPromoteCutConversionModule'
tasks.findByName('_cFetchCutConversionModule').mustRunAfter '_cCutConversionModule'
tasks.findByName('_cFetchCutConversionModule').mustRunAfter '_cDeleteCutDump'
tasks.findByName('_cPromoteCutConversionModule').mustRunAfter '_cFetchCutConversionModule'
}
/*
uLoadDMTemplate : Loads DM template into FINAL DB. You would have obtained the local copy from
uCreateDHFHarmonizationFlow or uCreateConversionModule with contentMode=dm. Having made your tweaks to that template,
you now ingest it back to MarkLogic. This task ensures the template has the right URI and collections.
Example:
/dm/mapper/EmployeeHubModel/Employee/harmonizeGlobalDM.json
dm, cookieCutter, http://marklogic.com/entity-services/models, EmployeeHubModel
Input:
- dmPath - mandatory
Dependencies:
- dmPth contains file dm/mapper/<ModelName>/<EntityName>/<harmonizationName>.json
- Standard ml-gradle environment properties: mlAppServicesHost, mlAppServicesPort. OR ...
- Standard DHF environment properties: mlHost, mlFinalPort
Effects:
- Target database has your template
*/
task uLoadDMTemplate(type: com.marklogic.gradle.task.MlcpTask) {
def srcDir = new File("${projectDir}").getAbsolutePath()
def unixDir = srcDir.replace('\\', '/') + "/" + project.findProperty("dmPath")
def regex = '"' + unixDir + ",''" + '"'
def myHost = project.findProperty("mlHost")
if (myHost == null) myHost = project.findProperty("mlAppServicesHost")
def myPort = project.findProperty("mlAppServicesPort")
if (myPort == null) myPort = project.findProperty("mlRestPort")
if (myPort == null) myPort = project.findProperty("mlFinalPort")
// check the pathness and extract the modelName
def pathDir = unixDir + "/dm/mapper"
def dmModelName = null
def pathFiles = file(pathDir).list()
if (pathFiles != null && pathFiles.size() == 1) {
dmModelName = pathFiles[0];
}
enabled = project.findProperty("dmPath") != null && dmModelName != null
def collections = "dm,cookieCutter,http://marklogic.com/entity-services/models," + dmModelName
classpath = configurations.mlcp
command = "IMPORT"
document_type = "json"
input_file_path = unixDir + "/dm/mapper/*/*/*.json"
input_file_type = "documents"
output_uri_replace = regex
output_uri_prefix = ""
output_permissions = "rest-reader,read,rest-writer,update"
output_collections = collections
host = myHost
port = myPort.toInteger()
}
//Edit this to enable/disable code generation of mlGenerateModelArtifacts
ext {
def mdb = project.findProperty("mlFinalDbName")
if (mdb == null) mdb = project.findProperty("mlAppName" + "-content")
mlAppConfig {
modelsDatabase=mdb
generateInstanceConverter=false
generateSchema=false
generateDatabaseProperties=false
generateExtractionTemplate=false
generateSearchOptions=false
}
}