Skip to content

Commit b4a5d8a

Browse files
committed
updating spring batch example
1 parent 70b5e5d commit b4a5d8a

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

examples/spring-batch/build.gradle

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
plugins {
22
id 'java'
3-
id 'eclipse'
4-
id 'idea'
53
id 'application'
64
id 'net.saliman.properties' version '1.4.6'
75
id 'com.marklogic.ml-data-hub' version '1.1.2'
86
}
97

108
repositories {
9+
mavenLocal()
1110
jcenter()
1211
maven {url 'http://developer.marklogic.com/maven2/'}
1312
}
@@ -21,10 +20,19 @@ dependencies {
2120
runtime "com.marklogic:marklogic-spring-batch-core:0.7.2"
2221
}
2322

24-
distributions {
25-
main {
26-
baseName = 'baseJob'
27-
}
28-
}
29-
3023
mainClassName = "com.marklogic.spring.batch.Main"
24+
25+
task importMonsters(type: JavaExec) {
26+
classpath = sourceSets.main.runtimeClasspath
27+
main = "com.marklogic.spring.batch.Main"
28+
args = [
29+
"--config", "example.LoadAndRunFlow",
30+
"--project_dir", ".",
31+
"--env", "local",
32+
"--input_file_path", "./input",
33+
"--input_file_pattern", ".*\\.xml",
34+
"--entity_name", "Monster",
35+
"--flow_name", "ingest-monster",
36+
"--chunk", "100"
37+
]
38+
}

examples/spring-batch/settings.gradle

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/spring-batch/src/main/java/example/LoadAndRunFlow.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.springframework.context.annotation.Import;
2222
import org.springframework.core.env.Environment;
2323
import org.springframework.core.io.Resource;
24+
import com.marklogic.hub.HubConfig;
2425

2526
import java.util.*;
2627

@@ -41,13 +42,16 @@ public Job job(JobBuilderFactory jobBuilderFactory, Step step) {
4142
public Step step(
4243
StepBuilderFactory stepBuilderFactory,
4344
DatabaseClientProvider databaseClientProvider,
45+
@Value("#{jobParameters['project_dir']}") String projectDir,
4446
@Value("#{jobParameters['input_file_path']}") String inputFilePath,
4547
@Value("#{jobParameters['input_file_pattern']}") String inputFilePattern,
4648
@Value("#{jobParameters['entity_name']}") String entityName,
4749
@Value("#{jobParameters['flow_name']}") String flowName,
4850
@Value("#{jobParameters['output_collections']}") String[] collections) {
4951

50-
GenericDocumentManager docMgr = databaseClientProvider.getDatabaseClient().newDocumentManager();
52+
HubConfig hubConfig = HubConfig.hubFromEnvironment(projectDir, "local");
53+
54+
GenericDocumentManager docMgr = hubConfig.newStagingClient().newDocumentManager();
5155

5256
ItemProcessor<Resource, DocumentWriteOperation> processor = new ResourceToDocumentWriteOperationItemProcessor();
5357
ItemWriter<DocumentWriteOperation> writer = new ItemWriter<DocumentWriteOperation>() {

0 commit comments

Comments
 (0)