├── .gitignore
├── CONTRIBUTING.md
├── LICENSE.md
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── build.gradle
├── circle.yml
├── config
└── checkstyle
│ └── checkstyle.xml
├── core
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── marklogic
│ │ │ └── spring
│ │ │ └── batch
│ │ │ ├── bind
│ │ │ ├── ExecutionContextAdapter.java
│ │ │ ├── JobExecutionAdapter.java
│ │ │ ├── JobInstanceAdapter.java
│ │ │ ├── JobParametersAdapter.java
│ │ │ └── StepExecutionAdapter.java
│ │ │ ├── columnmap
│ │ │ ├── ColumnMapSerializer.java
│ │ │ ├── DefaultStaxColumnMapSerializer.java
│ │ │ ├── JacksonColumnMapSerializer.java
│ │ │ └── XmlStringColumnMapSerializer.java
│ │ │ ├── config
│ │ │ ├── MarkLogicBatchConfiguration.java
│ │ │ ├── MarkLogicBatchConfigurer.java
│ │ │ ├── MarkLogicConfiguration.java
│ │ │ └── UseMarkLogicBatchCondition.java
│ │ │ ├── core
│ │ │ ├── AdaptedExecutionContext.java
│ │ │ ├── AdaptedJobExecution.java
│ │ │ ├── AdaptedJobInstance.java
│ │ │ ├── AdaptedJobParameters.java
│ │ │ ├── AdaptedStepExecution.java
│ │ │ ├── MarkLogicSpringBatch.java
│ │ │ ├── explore
│ │ │ │ └── support
│ │ │ │ │ └── MarkLogicJobExplorerFactoryBean.java
│ │ │ ├── launch
│ │ │ │ └── support
│ │ │ │ │ └── CommandLineJobRunner.java
│ │ │ ├── package-info.java
│ │ │ └── repository
│ │ │ │ ├── dao
│ │ │ │ ├── MarkLogicExecutionContextDao.java
│ │ │ │ ├── MarkLogicJobExecutionDao.java
│ │ │ │ ├── MarkLogicJobInstanceDao.java
│ │ │ │ └── MarkLogicStepExecutionDao.java
│ │ │ │ └── support
│ │ │ │ ├── MarkLogicJobRepositoryFactoryBean.java
│ │ │ │ └── MarkLogicJobRepositoryProperties.java
│ │ │ └── item
│ │ │ ├── listener
│ │ │ └── SimpleChunkListener.java
│ │ │ ├── processor
│ │ │ ├── AbstractMarkLogicItemProcessor.java
│ │ │ ├── ColumnMapProcessor.java
│ │ │ ├── MarkLogicItemProcessor.java
│ │ │ ├── ResourceToDocumentWriteOperationItemProcessor.java
│ │ │ ├── XmlElementItemProcessor.java
│ │ │ └── support
│ │ │ │ ├── DocumentUriGenerator.java
│ │ │ │ └── UriGenerator.java
│ │ │ ├── reader
│ │ │ ├── DocumentItemReader.java
│ │ │ ├── InvokeModuleItemReader.java
│ │ │ └── ValuesItemReader.java
│ │ │ ├── tasklet
│ │ │ ├── DeleteDocumentsTasklet.java
│ │ │ └── EvaluateServerSideStringTasklet.java
│ │ │ └── writer
│ │ │ ├── DataHubItemWriter.java
│ │ │ ├── InvokeModuleItemWriter.java
│ │ │ ├── MarkLogicItemWriter.java
│ │ │ ├── MarkLogicPatchItemWriter.java
│ │ │ ├── XccItemWriter.java
│ │ │ └── support
│ │ │ ├── DefaultUriTransformer.java
│ │ │ └── UriTransformer.java
│ └── resources
│ │ └── logback.xml
│ └── test
│ ├── java
│ └── com
│ │ └── marklogic
│ │ ├── client
│ │ └── JavaClientApiIssue388Test.java
│ │ └── spring
│ │ └── batch
│ │ ├── JobExecutionTestUtils.java
│ │ ├── JobParametersTestUtils.java
│ │ ├── MarkLogicSpringBatchConfigTests.java
│ │ ├── SpringBatchNamespaceProvider.java
│ │ ├── bind
│ │ ├── JaxbConfiguration.java
│ │ ├── MarshallSpringBatchPojoToXmlTest.java
│ │ └── UnmarshallSpringBatchPojoTest.java
│ │ ├── config
│ │ ├── DoNotUseMarkLogicBatchConfigurerTest.java
│ │ └── UseMarkLogicBatchConfigurerTest.java
│ │ ├── core
│ │ ├── explore
│ │ │ ├── GetJobInstancesTest.java
│ │ │ └── support
│ │ │ │ └── SimpleJobExplorerTests.java
│ │ ├── job
│ │ │ └── JobSupport.java
│ │ ├── launch
│ │ │ └── support
│ │ │ │ ├── CommandLineJobRunnerTests.java
│ │ │ │ └── TestJobParametersIncrementer.java
│ │ ├── repository
│ │ │ ├── dao
│ │ │ │ ├── MarkLogicExecutionContextDaoTests.java
│ │ │ │ ├── MarkLogicJobDaoTests.java
│ │ │ │ ├── MarkLogicJobExecutionDaoTests.java
│ │ │ │ ├── MarkLogicJobInstanceDaoTests.java
│ │ │ │ └── MarkLogicStepExecutionsDaoTest.java
│ │ │ └── support
│ │ │ │ └── SimpleJobRepositoryIntegrationTests.java
│ │ └── step
│ │ │ └── StepSupport.java
│ │ ├── item
│ │ ├── columnmap
│ │ │ └── JacksonColumnMapSerializerTest.java
│ │ ├── processor
│ │ │ ├── ColumnMapProcessorTest.java
│ │ │ └── support
│ │ │ │ └── DocumentUriGeneratorTest.java
│ │ ├── reader
│ │ │ └── ValuesItemReaderTest.java
│ │ └── writer
│ │ │ ├── InvokeModuleItemWriterTest.java
│ │ │ ├── MarkLogicItemWriterTest.java
│ │ │ ├── MarkLogicPatchItemWriterTest.java
│ │ │ ├── UriTransformerTest.java
│ │ │ └── XccItemWriterTest.java
│ │ └── test
│ │ └── LoggingItemWriter.java
│ └── resources
│ ├── config
│ ├── job.xml
│ ├── job2.xml
│ ├── launcher-with-environment.xml
│ ├── launcher-with-locator.xml
│ └── test-environment.xml
│ ├── job.properties
│ ├── options
│ └── sample-options.properties
│ ├── transforms
│ └── simple.xqy
│ └── xml
│ ├── execution-context.xml
│ ├── job-execution-2.xml
│ ├── job-execution.xml
│ ├── job-instance.xml
│ ├── job-parameters.xml
│ └── step-execution.xml
├── file
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ └── item
│ │ └── file
│ │ ├── AvroItemReader.java
│ │ ├── EnhancedResourcesItemReader.java
│ │ ├── SplitXmlDocumentReader.java
│ │ ├── TikaParserItemProcessor.java
│ │ └── support
│ │ ├── MapFileVisitor.java
│ │ └── TikaParser.java
│ └── test
│ ├── java
│ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ └── item
│ │ └── file
│ │ ├── AvroItemReaderTest.java
│ │ ├── EnhancedResourcesItemReaderTest.java
│ │ └── support
│ │ ├── MapFileVisitorTest.java
│ │ └── TikaParserTest.java
│ └── resources
│ ├── avro
│ ├── sampleAvroSerialized.avro
│ └── sampleOutput.txt
│ └── word
│ └── test-1.docx
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── http
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── marklogic
│ │ │ └── spring
│ │ │ └── batch
│ │ │ └── item
│ │ │ └── http
│ │ │ ├── HttpJsonItemReader.java
│ │ │ └── HttpXmlItemReader.java
│ └── resources
│ │ └── job.properties
│ └── test
│ └── java
│ └── com
│ └── marklogic
│ └── spring
│ └── batch
│ └── item
│ └── http
│ ├── HttpJsonItemReaderTest.java
│ └── HttpXmlItemReaderTest.java
├── job.properties
├── mlJobRepo
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ ├── DeployMarkLogicJobRepository.java
│ │ ├── MarkLogicSimpleJobRepositoryAppDeployer.java
│ │ └── MarkLogicSimpleJobRepositoryConfig.java
│ └── resources
│ ├── content-database.json
│ ├── logback.xml
│ └── options.xml
├── rdbms
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ └── item
│ │ └── rdbms
│ │ └── AllTablesItemReader.java
│ └── test
│ ├── java
│ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ └── item
│ │ └── rdbms
│ │ ├── AllTablesItemReaderTest.java
│ │ └── config
│ │ └── H2DatabaseConfiguration.java
│ └── resources
│ └── db
│ └── sampledata.sql
├── rdf
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── marklogic
│ │ │ └── spring
│ │ │ └── batch
│ │ │ └── item
│ │ │ └── rdf
│ │ │ ├── AbstractDocumentWriter.java
│ │ │ ├── GraphItemWriter.java
│ │ │ ├── RdfTripleItemReader.java
│ │ │ └── RdfTripleItemWriter.java
│ └── resources
│ │ └── logback.xml
│ └── test
│ ├── java
│ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ └── item
│ │ └── rdf
│ │ ├── ImportRdfFromFileJob.java
│ │ └── ImportRdfFromFileJobTest.java
│ └── resources
│ ├── job.properties
│ ├── logback.xml
│ └── triple
│ ├── test1.ttl
│ └── tigers.ttl
├── samples
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ ├── main
│ └── java
│ │ ├── YourJobConfig.java
│ │ └── YourTwoStepJobConfig.java
│ └── test
│ ├── java
│ ├── TwoStepJobTest.java
│ ├── YourJobTest.java
│ └── YourJobWithNoMarkLogicJobRepoTest.java
│ └── resources
│ └── job.properties
├── settings.gradle
├── shapefiles
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ └── item
│ │ └── shapefile
│ │ ├── ShapefileProcessor.java
│ │ └── support
│ │ ├── HttpClientOgreProxy.java
│ │ └── OgreProxy.java
│ └── test
│ ├── java
│ └── com
│ │ └── marklogic
│ │ └── spring
│ │ └── batch
│ │ └── item
│ │ └── shapefile
│ │ └── ShapefileProcessorTest.java
│ └── resources
│ ├── logback.xml
│ └── shapefiles
│ └── Colleges_Syria.zip
└── test
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
└── main
└── java
└── com
└── marklogic
└── spring
└── batch
└── test
├── AbstractJobRepositoryTest.java
├── AbstractJobRunnerTest.java
├── AbstractSpringBatchTest.java
├── EmptyItemWriter.java
├── JobRepositorySupport.java
├── JobRunnerContext.java
└── SpringBatchNamespaceProvider.java
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | build/
3 | classes/
4 | out/
5 | .classpath
6 | .project
7 | .gradle
8 | .settings
9 | .idea/
10 | *.iml
11 | *.ipr
12 | *.iws
13 | marklogic-spring-batch.sublime*
14 | output-*.xml
15 | .nb-gradle/
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | | Branch | Status |
4 | | ------------- | ------------- |
5 | | master |  |
6 | | dev |  |
7 |
8 | # MarkLogic Spring Batch
9 |
10 | The MarkLogic Spring Batch project is an extension of the CORE and INFRASTRUCTURE components of Spring Batch to make it easier to write batch processing programs using MarkLogic.
11 |
12 | Start with the [project home page](https://github.com/marklogic-community/marklogic-spring-batch/wiki) to get started.
13 |
14 | ## Prerequisites
15 |
16 | * MarkLogic 8+
17 | * JDK 1.8+
18 |
19 | ## Installing the Test Environment
20 |
21 | Open $PROJECT_ROOT/gradle.properties. Review the mlHost, mlRestPort, mlJobRepoPort properties to confirm there are no conflicts
22 |
23 | gradlew mlDeploy
24 |
25 | This command will set up your test database and application server.
26 |
27 | ## Running the tests
28 |
29 | Review the host/port/user credentials properties for the following property files.
30 |
31 | * ./core/src/test/resources/job.properties
32 | * ./infrastructure/src/test/resources/job.properties
33 | * ./rdf/src/test/resources/job.properties
34 | * ./samples/src/test/resources/job.properties
35 |
36 | Run the following command to execute all project tests. All tests should pass.
37 |
38 | gradlew test
39 |
40 | ## Coding Style Tests
41 |
42 | This project uses both checkstyle and PMD.
43 |
44 | gradlew check
45 |
46 | ## Deployment
47 |
48 | The product of this project are jar files that are published to [bintray](https://dl.bintray.com/sastafford/maven/). The following libraries are created.
49 |
50 | | Group | Artifact |
51 | | ------|----------|
52 | | com.marklogic | marklogic-spring-batch-core |
53 | | com.marklogic | marklogic-spring-batch-test |
54 | | com.marklogic | spring-batch-http |
55 | | com.marklogic | spring-batch-rdbms |
56 | | com.marklogic | spring-batch-file |
57 |
58 | The gradle bintray plugin is used to publish to bintray.
59 |
60 | gradlew :core:bintrayUpload
61 | gradlew :file:bintrayUpload
62 | gradlew :test:bintrayUpload
63 | gradlew :http:bintrayUpload
64 | gradlew :rdbms:bintrayUpload
65 |
66 | ## How do I use these libraries?
67 |
68 | ### Gradle
69 |
70 | ```groovy
71 | dependencies {
72 | compile 'com.marklogic:marklogic-spring-batch-core:1.+'
73 | testCompile 'com.marklogic:marklogic-spring-batch-test:1.+'
74 | }
75 | ```
76 |
77 |
78 | ### Maven
79 |
80 | ```xml
81 |
82 |
83 | com.marklogic
84 | marklogic-spring-batch-core
85 | 1.5.0
86 |
87 |
88 | ```
89 |
90 |
91 | # How can I contribute to the project?
92 |
93 | Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute code to this project and the process for submitting pull requests to us.
94 |
95 | # What license does MarkLogic Spring Batch use?
96 |
97 | See the [LICENSE.md](LICENSE.md) file for details
98 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven {
4 | url "https://plugins.gradle.org/m2/"
5 | jcenter()
6 | }
7 | }
8 | dependencies {
9 | classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
10 | classpath "com.marklogic:ml-gradle:3.2.0"
11 | }
12 | }
13 |
14 | plugins {
15 | id "com.marklogic.ml-gradle" version "3.3.0"
16 | }
17 |
18 | mlPostDeploy.dependsOn ":mlJobRepo:deployMarkLogicJobRepository"
19 | mlUndeploy.dependsOn "mlJobRepo:undeployMarkLogicJobRepository"
20 |
21 | allprojects {
22 | apply plugin: "checkstyle"
23 | apply plugin: "pmd"
24 |
25 | repositories {
26 | jcenter()
27 | mavenCentral()
28 | maven { url "http://repo.spring.io/release" }
29 | maven { url "http://developer.marklogic.com/maven2/" }
30 | }
31 |
32 | task wrapper(type: Wrapper) {
33 | gradleVersion = '4.5'
34 | }
35 |
36 | pmd {
37 | ruleSets = ["java-basic", "java-braces", "java-unusedcode", "java-imports"]
38 | }
39 |
40 | checkstyle {
41 | configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
42 | toolVersion = '7.1.2'
43 | }
44 |
45 | }
46 |
47 | subprojects {
48 | apply plugin: "java"
49 | apply plugin: "maven-publish"
50 | apply plugin: "idea"
51 |
52 | ext {
53 | springBatchVersion = '4.0.0.RELEASE'
54 | springVersion = '5.0.2.RELEASE'
55 | }
56 |
57 | dependencies {
58 | compile "ch.qos.logback:logback-classic:1.2.3"
59 | testCompile "junit:junit:4.12"
60 | }
61 |
62 | sourceCompatibility = 1.8
63 | targetCompatibility = 1.8
64 | }
65 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | services:
3 | - docker
4 | java:
5 | version: oraclejdk8
6 |
7 | dependencies:
8 | override:
9 | # Install git-lfs
10 | #- curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
11 | #- sudo apt-get install git-lfs=1.1.0
12 | #- ssh git@github.com git-lfs-authenticate sastafford/marklogic-spring-batch.git download
13 | # Docker commands
14 | - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD
15 | - docker info
16 | - docker pull $DOCKER_MARKLOGIC_IMAGE
17 |
18 | test:
19 | override:
20 | - docker run --hostname grover --name ml -d -p 8000:8000 -p 8001:8001 -p 8002:8002 -p 8200:8200 -p 8201:8201 $DOCKER_MARKLOGIC_IMAGE
21 | - sleep 10
22 | #- git lfs env
23 | #- git lfs pull
24 | - pwd
25 | - chmod +x gradlew
26 | - ./gradlew mlInit -PmlHost=localhost --info
27 | - ./gradlew mlInstallAdmin -PmlHost=localhost -PmlAdminPassword=admin -PmlAdminUsername=admin --info
28 | - ./gradlew mlDeploy -PmlHost=localhost --info
29 | - ./gradlew test --info
30 |
31 | post:
32 | - mkdir -p $CIRCLE_TEST_REPORTS/junit/
33 | - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
--------------------------------------------------------------------------------
/config/checkstyle/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/core/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.jfrog.bintray"
2 |
3 | dependencies {
4 | // For the CommandLineInterface main program
5 | compile "net.sf.jopt-simple:jopt-simple:5.0.1"
6 |
7 | compile "org.springframework.batch:spring-batch-core:$springBatchVersion"
8 | compile "com.marklogic:marklogic-client-api:4.0.3"
9 | compile "com.marklogic:ml-javaclient-util:3.2.0"
10 | compile "org.apache.commons:commons-lang3:3.5"
11 |
12 | testCompile "org.springframework.batch:spring-batch-test:$springBatchVersion"
13 | testCompile "com.marklogic:ml-junit:3.0.0"
14 |
15 | // Used by marshall/unmarshall tests, which depends on Jaxb2Marshaller
16 | testCompile "org.springframework:spring-oxm:$springVersion"
17 | testCompile project(":test")
18 |
19 | runtime "org.springframework.batch:spring-batch-core:$springBatchVersion"
20 | runtime "net.sf.jopt-simple:jopt-simple:5.0.1"
21 | }
22 |
23 | ext {
24 | artifact = "marklogic-spring-batch-core"
25 | }
26 |
27 | javadoc {
28 | excludes = ["com/marklogic/spring/batch/bind", "com/marklogic/spring/batch/core" ]
29 | }
30 |
31 | task sourcesJar(type: Jar, dependsOn: classes) {
32 | baseName = artifactId
33 | version = project.version
34 | classifier = 'sources'
35 | from sourceSets.main.allSource
36 | }
37 |
38 | jar {
39 | baseName = artifact
40 | version = project.version
41 | }
42 |
43 | publishing {
44 | publications {
45 | mainJavaWithSources(MavenPublication) {
46 | groupId group
47 | artifactId artifact
48 | version project.version
49 | from components.java
50 | artifact sourcesJar
51 | }
52 | }
53 | }
54 |
55 | bintray {
56 | user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
57 | key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY')
58 | publications = [bintrayPublicationName]
59 | pkg {
60 | repo = bintrayRepo
61 | name = artifact
62 | userOrg = bintrayUserOrg
63 | licenses = [bintrayLicense]
64 | vcsUrl = bintrayVcsUrl
65 | version {
66 | name = project.version
67 | released = new Date()
68 | vcsTag = project.version
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/core/gradle.properties:
--------------------------------------------------------------------------------
1 | artifactId=marklogic-spring-batch-core
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/core/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marklogic-community/marklogic-spring-batch/9ae06d957312714cf2df40cb8eb523449d3841db/core/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/core/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-bin.zip
6 |
--------------------------------------------------------------------------------
/core/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/bind/ExecutionContextAdapter.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.bind;
2 |
3 | import javax.xml.bind.annotation.adapters.XmlAdapter;
4 |
5 | import org.springframework.batch.item.ExecutionContext;
6 |
7 | import com.marklogic.spring.batch.core.AdaptedExecutionContext;
8 |
9 | public class ExecutionContextAdapter extends XmlAdapter {
10 |
11 | @Override
12 | public ExecutionContext unmarshal(AdaptedExecutionContext v) throws Exception {
13 | return new ExecutionContext(v.getMap());
14 | }
15 |
16 | @Override
17 | public AdaptedExecutionContext marshal(ExecutionContext v) throws Exception {
18 | return new AdaptedExecutionContext(v);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/bind/JobExecutionAdapter.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.bind;
2 |
3 | import javax.xml.bind.annotation.adapters.XmlAdapter;
4 | import org.springframework.batch.core.BatchStatus;
5 | import org.springframework.batch.core.ExitStatus;
6 | import org.springframework.batch.core.JobExecution;
7 |
8 | import com.marklogic.spring.batch.core.AdaptedJobExecution;
9 |
10 | public class JobExecutionAdapter extends XmlAdapter{
11 |
12 | @Override
13 | public JobExecution unmarshal(AdaptedJobExecution v) throws Exception {
14 | JobExecution jobExec = new JobExecution(v.getId(), v.getJobParameters());
15 | jobExec.setJobInstance(v.getJobInstance());
16 | jobExec.setCreateTime(v.getCreateDateTime());
17 | jobExec.setEndTime(v.getEndDateTime());
18 | jobExec.setLastUpdated(v.getLastUpdatedDateTime());
19 | jobExec.setStartTime(v.getStartDateTime());
20 | jobExec.setStatus(BatchStatus.valueOf(v.getStatus()));
21 | jobExec.setExitStatus(new ExitStatus(v.getExitCode(), ""));
22 | jobExec.addStepExecutions(v.getStepExecutions());
23 | jobExec.setVersion(v.getVersion());
24 | jobExec.setExecutionContext(v.getExecutionContext());
25 | return jobExec;
26 | }
27 |
28 | @Override
29 | public AdaptedJobExecution marshal(JobExecution v) throws Exception {
30 | return new AdaptedJobExecution(v);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/bind/JobInstanceAdapter.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.bind;
2 |
3 | import com.marklogic.spring.batch.core.AdaptedJobInstance;
4 | import org.springframework.batch.core.JobInstance;
5 | import org.springframework.batch.core.JobParameters;
6 |
7 | import javax.xml.bind.annotation.adapters.XmlAdapter;
8 |
9 | public class JobInstanceAdapter extends XmlAdapter {
10 |
11 | private JobParameters jobParameters;
12 |
13 | public JobInstanceAdapter() {
14 |
15 | }
16 |
17 | public JobInstanceAdapter(JobParameters jobParameters) {
18 | this.jobParameters = jobParameters;
19 | }
20 |
21 | @Override
22 | public JobInstance unmarshal(AdaptedJobInstance v) throws Exception {
23 | JobInstance jobInstance = new JobInstance(v.getId(), v.getJobName());
24 | jobInstance.setVersion(v.getVersion());
25 | return jobInstance;
26 | }
27 |
28 | @Override
29 | public AdaptedJobInstance marshal(JobInstance v) throws Exception {
30 | AdaptedJobInstance aji = new AdaptedJobInstance(v);
31 | if (!(jobParameters == null)) {
32 | aji.setJobKey(jobParameters);
33 | }
34 | return aji;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/bind/JobParametersAdapter.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.bind;
2 |
3 | import java.text.DateFormat;
4 | import java.text.SimpleDateFormat;
5 | import java.util.ArrayList;
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | import javax.xml.bind.annotation.adapters.XmlAdapter;
10 |
11 | import org.springframework.batch.core.JobParameter;
12 | import org.springframework.batch.core.JobParameters;
13 | import org.springframework.batch.core.JobParametersBuilder;
14 |
15 | import com.marklogic.spring.batch.core.AdaptedJobParameters;
16 |
17 | public class JobParametersAdapter extends XmlAdapter {
18 |
19 | @Override
20 | public JobParameters unmarshal(AdaptedJobParameters params) throws Exception {
21 | JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
22 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
23 | for (AdaptedJobParameters.AdaptedJobParameter param : params.getParameters()) {
24 | switch (param.type) {
25 | case "STRING":
26 | jobParametersBuilder.addString(param.key, param.value, param.identifier);
27 | break;
28 | case "DATE":
29 | jobParametersBuilder.addDate(param.key, df.parse(param.value), param.identifier);
30 | break;
31 | case "DOUBLE":
32 | jobParametersBuilder.addDouble(param.key, Double.valueOf(param.value), param.identifier);
33 | break;
34 | case "LONG":
35 | jobParametersBuilder.addLong(param.key, Long.valueOf(param.value), param.identifier);
36 | break;
37 | }
38 | }
39 | return jobParametersBuilder.toJobParameters();
40 | }
41 |
42 | @Override
43 | public AdaptedJobParameters marshal(JobParameters jobParams) throws Exception {
44 | AdaptedJobParameters adaptedJobParams = new AdaptedJobParameters();
45 | List listOfParameters = new ArrayList<>();
46 | if (jobParams == null) {
47 | return adaptedJobParams;
48 | } else {
49 | for (Map.Entry entry : jobParams.getParameters().entrySet()) {
50 | AdaptedJobParameters.AdaptedJobParameter param = new AdaptedJobParameters.AdaptedJobParameter();
51 | param.key = entry.getKey();
52 | JobParameter jobParam = entry.getValue();
53 | param.type = jobParam.getType().toString();
54 | param.identifier = jobParam.isIdentifying();
55 | switch (jobParam.getType()) {
56 | case STRING:
57 | param.value = jobParams.getString(entry.getKey());
58 | break;
59 | case DATE:
60 | param.value = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(jobParams.getDate(entry.getKey()));
61 | break;
62 | case DOUBLE:
63 | param.value = jobParams.getDouble(entry.getKey()).toString();
64 | break;
65 | case LONG:
66 | param.value = jobParams.getLong(entry.getKey()).toString();
67 | break;
68 | }
69 | listOfParameters.add(param);
70 | }
71 | adaptedJobParams.setParameters(listOfParameters);
72 | }
73 | return adaptedJobParams;
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/bind/StepExecutionAdapter.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.bind;
2 |
3 | import javax.xml.bind.annotation.adapters.XmlAdapter;
4 |
5 | import org.springframework.batch.core.ExitStatus;
6 | import org.springframework.batch.core.JobExecution;
7 | import org.springframework.batch.core.JobInstance;
8 | import org.springframework.batch.core.StepExecution;
9 |
10 | import com.marklogic.spring.batch.core.AdaptedStepExecution;
11 |
12 | public class StepExecutionAdapter extends XmlAdapter {
13 |
14 | @Override
15 | public StepExecution unmarshal(AdaptedStepExecution v) throws Exception {
16 | JobExecution je = new JobExecution(v.getJobExecutionId());
17 | JobInstance ji = new JobInstance(v.getJobInstanceId(), v.getJobName());
18 | je.setJobInstance(ji);
19 | StepExecution step = new StepExecution(v.getStepName(), je);
20 | step.setId(v.getId());
21 | step.setStartTime(v.getStartTime());
22 | step.setEndTime(v.getEndTime());
23 | step.setReadSkipCount(v.getReadSkipCount());
24 | step.setWriteSkipCount(v.getWriteSkipCount());
25 | step.setProcessSkipCount(v.getProcessSkipCount());
26 | step.setReadCount(v.getReadCount());
27 | step.setWriteCount(v.getWriteCount());
28 | step.setFilterCount(v.getFilterCount());
29 | step.setRollbackCount(v.getRollbackCount());
30 | step.setExitStatus(new ExitStatus(v.getExitCode()));
31 | step.setLastUpdated(v.getLastUpdated());
32 | step.setVersion(v.getVersion());
33 | step.setStatus(v.getStatus());
34 | step.setExecutionContext(v.getExecutionContext());
35 | return step;
36 | }
37 |
38 | @Override
39 | public AdaptedStepExecution marshal(StepExecution v) throws Exception {
40 | return new AdaptedStepExecution(v);
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/columnmap/ColumnMapSerializer.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.columnmap;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Strategy interface for how a Spring "column map" can be written to a String of JSON or XML or, really, whatever you
7 | * want.
8 | */
9 | public interface ColumnMapSerializer {
10 |
11 | String serializeColumnMap(Map columnMap, String rootLocalName);
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/columnmap/JacksonColumnMapSerializer.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.columnmap;
2 |
3 | import com.fasterxml.jackson.core.JsonProcessingException;
4 | import com.fasterxml.jackson.databind.ObjectMapper;
5 |
6 | import java.util.Map;
7 |
8 | /**
9 | * Simple implementation that uses Jackson's writeValueAsString method. The outputted JSON string can be customized by
10 | * passing in your own ObjectMapper implementation.
11 | */
12 | public class JacksonColumnMapSerializer implements ColumnMapSerializer {
13 |
14 | private ObjectMapper objectMapper;
15 |
16 | public JacksonColumnMapSerializer() {
17 | this(new ObjectMapper());
18 | }
19 |
20 | public JacksonColumnMapSerializer(ObjectMapper objectMapper) {
21 | this.objectMapper = objectMapper;
22 | }
23 |
24 | @Override
25 | public String serializeColumnMap(Map columnMap, String rootLocalName) {
26 | try {
27 | return objectMapper.writeValueAsString(columnMap);
28 | } catch (JsonProcessingException e) {
29 | throw new RuntimeException("Unable to write map as JSON: " + e.getMessage(), e);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/columnmap/XmlStringColumnMapSerializer.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.columnmap;
2 |
3 | import org.apache.commons.lang3.StringEscapeUtils;
4 |
5 | import java.util.Map;
6 |
7 | public class XmlStringColumnMapSerializer implements ColumnMapSerializer {
8 |
9 | @Override
10 | public String serializeColumnMap(Map columnMap, String rootLocalName) {
11 | String content = "";
12 | String rootName = rootLocalName.length() == 0 ? "record" : rootLocalName.replaceAll("[^A-Za-z0-9\\_\\-]", "");
13 | content = "<" + rootName + ">\n";
14 |
15 | for (Map.Entry entry : transformColumnMap(columnMap).entrySet()) {
16 | String elName = entry.getKey().replaceAll("[^A-Za-z0-9\\_\\-]", "");
17 | String value = entry.getValue() == null ? "" : StringEscapeUtils.escapeXml11(entry.getValue().toString());
18 | content += "<" + elName + ">" + value + "" + elName + ">\n";
19 | }
20 |
21 | content += "" + rootName + ">";
22 | return content;
23 | }
24 |
25 | //The strategy is to extend this class and overwrite this method.
26 | protected Map transformColumnMap(Map columnMap) {
27 | return columnMap;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/config/MarkLogicBatchConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.config;
2 |
3 | import com.marklogic.client.ext.DatabaseClientConfig;
4 | import com.marklogic.client.ext.helper.DatabaseClientProvider;
5 | import com.marklogic.client.ext.spring.SimpleDatabaseClientProvider;
6 | import org.springframework.beans.factory.annotation.Qualifier;
7 | import org.springframework.beans.factory.annotation.Value;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.context.annotation.ComponentScan;
10 | import org.springframework.context.annotation.Conditional;
11 | import org.springframework.context.annotation.Configuration;
12 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
13 |
14 | import java.util.List;
15 |
16 | @Configuration
17 | @ComponentScan(
18 | basePackageClasses = {
19 | com.marklogic.spring.batch.config.MarkLogicBatchConfigurer.class,
20 | com.marklogic.spring.batch.core.repository.support.MarkLogicJobRepositoryProperties.class
21 | })
22 | public class MarkLogicBatchConfiguration {
23 |
24 | @Bean
25 | public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() {
26 | return new PropertySourcesPlaceholderConfigurer();
27 | }
28 |
29 | @Conditional(UseMarkLogicBatchCondition.class)
30 | @Bean(name = "markLogicJobRepositoryDatabaseClientConfig")
31 | @Qualifier("markLogicJobRepositoryDatabaseClientConfig")
32 | public DatabaseClientConfig markLogicJobRepositoryDatabaseClientConfig(
33 | @Value("#{'${marklogic.jobrepo.host:localhost}'.split(',')}") List hosts,
34 | @Value("${marklogic.jobrepo.port:8201}") int port,
35 | @Value("${marklogic.jobrepo.username:admin}") String username,
36 | @Value("${marklogic.jobrepo.password:admin}") String password) {
37 | return new DatabaseClientConfig(hosts.get(0), port, username, password);
38 | }
39 |
40 | @Conditional(UseMarkLogicBatchCondition.class)
41 | @Bean(name = "markLogicJobRepositoryDatabaseClientProvider")
42 | @Qualifier("markLogicJobRepositoryDatabaseClientProvider")
43 | public DatabaseClientProvider markLogicJobRepositoryDatabaseClientProvider(
44 | @Qualifier("markLogicJobRepositoryDatabaseClientConfig")
45 | DatabaseClientConfig marklogicJobRepositoryClientConfig) {
46 | return new SimpleDatabaseClientProvider(marklogicJobRepositoryClientConfig);
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/config/MarkLogicConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.config;
2 |
3 | import com.marklogic.client.ext.DatabaseClientConfig;
4 | import com.marklogic.client.ext.helper.DatabaseClientProvider;
5 | import com.marklogic.client.ext.spring.SimpleDatabaseClientProvider;
6 | import org.springframework.beans.factory.annotation.Qualifier;
7 | import org.springframework.beans.factory.annotation.Value;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.context.annotation.Configuration;
10 |
11 | import java.util.List;
12 |
13 | @Configuration
14 | public class MarkLogicConfiguration {
15 |
16 | @Bean
17 | public DatabaseClientConfig databaseClientConfig(
18 | @Value("#{'${marklogic.host:localhost}'.split(',')}") List hosts,
19 | @Value("${marklogic.port:8000}") int port,
20 | @Value("${marklogic.username:admin}") String username,
21 | @Value("${marklogic.password:admin}") String password) {
22 | return new DatabaseClientConfig(hosts.get(0), port, username, password);
23 | }
24 |
25 | @Bean
26 | @Qualifier("targetDatabaseClientProvider")
27 | public DatabaseClientProvider databaseClientProvider(DatabaseClientConfig databaseClientConfig) {
28 | return new SimpleDatabaseClientProvider(databaseClientConfig);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/config/UseMarkLogicBatchCondition.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.config;
2 |
3 | import org.springframework.context.annotation.Condition;
4 | import org.springframework.context.annotation.ConditionContext;
5 | import org.springframework.core.env.Environment;
6 | import org.springframework.core.type.AnnotatedTypeMetadata;
7 |
8 | public class UseMarkLogicBatchCondition implements Condition {
9 |
10 | @Override
11 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
12 | Environment env = context.getEnvironment();
13 | Boolean enabled = env.getProperty("marklogic.batch.config.enabled", Boolean.class);
14 | if (enabled == null) {
15 | return false;
16 | } else {
17 | return enabled.booleanValue();
18 | }
19 |
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/core/AdaptedExecutionContext.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.core;
2 |
3 | import org.springframework.batch.item.ExecutionContext;
4 |
5 | import javax.xml.bind.annotation.XmlRootElement;
6 | import javax.xml.bind.annotation.XmlType;
7 | import java.util.HashMap;
8 | import java.util.Iterator;
9 | import java.util.Map;
10 | import java.util.Map.Entry;
11 | import java.util.Set;
12 |
13 | @XmlRootElement(name = "executionContext", namespace = MarkLogicSpringBatch.JOB_NAMESPACE)
14 | @XmlType(namespace = MarkLogicSpringBatch.JOB_NAMESPACE)
15 | public class AdaptedExecutionContext {
16 |
17 | private Map map = new HashMap<>();
18 | private int hashCode;
19 | private boolean dirtyFlag;
20 |
21 | public AdaptedExecutionContext() {
22 |
23 | }
24 |
25 | public AdaptedExecutionContext(ExecutionContext exeContext) throws InstantiationException, IllegalAccessException {
26 | this.hashCode = exeContext.hashCode();
27 | this.dirtyFlag = exeContext.isDirty();
28 |
29 | // Get a set of the entries
30 | Set> set = exeContext.entrySet();
31 | // Get an iterator
32 | Iterator> i = set.iterator();
33 | // Display elements
34 | while (i.hasNext()) {
35 | Entry me = i.next();
36 | String name = me.getKey();
37 | Object obj = getValue(me.getValue());
38 | map.put(name, obj);
39 | }
40 | }
41 |
42 | public Map getMap() {
43 | return map;
44 | }
45 |
46 | public void setMap(Map map) {
47 | this.map = map;
48 | }
49 |
50 | public int getHashCode() {
51 | return hashCode;
52 | }
53 |
54 | public void setHashCode(int hashCode) {
55 | this.hashCode = hashCode;
56 | }
57 |
58 | public boolean isDirtyFlag() {
59 | return dirtyFlag;
60 | }
61 |
62 | public void setDirtyFlag(boolean dirtyFlag) {
63 | this.dirtyFlag = dirtyFlag;
64 | }
65 |
66 | private Object getValue(Object value) {
67 |
68 | if (String.class.isInstance(value)) {
69 | value = value;
70 | } else if (Long.class.isInstance(value)) {
71 | value = value;
72 | } else if (Double.class.isInstance(value)) {
73 | value = value;
74 | } else if (Integer.class.isInstance(value)) {
75 | value = value;
76 | } else if (Boolean.class.isInstance(value)) {
77 | value = value;
78 | } else {
79 | value = value;
80 | }
81 | return value;
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/core/AdaptedJobInstance.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.core;
2 |
3 | import javax.xml.bind.annotation.XmlRootElement;
4 | import javax.xml.bind.annotation.XmlType;
5 |
6 | import org.springframework.batch.core.DefaultJobKeyGenerator;
7 | import org.springframework.batch.core.JobInstance;
8 | import org.springframework.batch.core.JobKeyGenerator;
9 | import org.springframework.batch.core.JobParameters;
10 |
11 | import java.util.Date;
12 |
13 | @XmlRootElement(name = "jobInstance", namespace=MarkLogicSpringBatch.JOB_NAMESPACE)
14 | @XmlType(namespace=MarkLogicSpringBatch.JOB_NAMESPACE)
15 | public class AdaptedJobInstance {
16 |
17 | private Long id;
18 | private Integer version = 0;
19 | private String jobName;
20 | private String jobKey;
21 | private Date createDateTime;
22 |
23 | private JobKeyGenerator jobKeyGenerator = new DefaultJobKeyGenerator();
24 |
25 | public AdaptedJobInstance() { }
26 |
27 | public AdaptedJobInstance(JobInstance jobInstance) {
28 | this.id = jobInstance.getId();
29 | if (jobInstance.getVersion() == null) {
30 | jobInstance.setVersion(0);
31 | } else {
32 | this.setVersion(jobInstance.getVersion());
33 | }
34 | this.jobName = jobInstance.getJobName();
35 | }
36 |
37 | public AdaptedJobInstance(JobInstance jobInstance, JobParameters jobParameters) {
38 | this(jobInstance);
39 | setJobKey(jobKeyGenerator.generateKey(jobParameters));
40 | }
41 |
42 | public String getJobName() {
43 | return jobName;
44 | }
45 |
46 | public void setJobName(String jobName) {
47 | this.jobName = jobName;
48 | }
49 |
50 | public Long getId() {
51 | return id;
52 | }
53 |
54 | public void setId(Long id) {
55 | this.id = id;
56 | }
57 |
58 | public Integer getVersion() {
59 | return version;
60 | }
61 |
62 | public void setVersion(Integer version) {
63 | this.version = version;
64 | }
65 |
66 | public String getJobKey() { return jobKey; }
67 |
68 | public void setJobKey(String jobKey) {
69 | this.jobKey = jobKey;
70 | }
71 |
72 | public void setJobKey(JobParameters jobParameters) {
73 | this.jobKey = jobKeyGenerator.generateKey(jobParameters);
74 | }
75 |
76 | public Date getCreateDateTime() {
77 | return createDateTime;
78 | }
79 |
80 | public void setCreateDateTime(Date createDateTime) {
81 | this.createDateTime = createDateTime;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/core/AdaptedJobParameters.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.core;
2 |
3 | import java.util.List;
4 |
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlElement;
7 | import javax.xml.bind.annotation.XmlRootElement;
8 | import javax.xml.bind.annotation.XmlType;
9 | import javax.xml.bind.annotation.XmlValue;
10 |
11 | @XmlRootElement(name="jobParameters", namespace=MarkLogicSpringBatch.JOB_NAMESPACE)
12 | @XmlType(namespace=MarkLogicSpringBatch.JOB_NAMESPACE)
13 | public class AdaptedJobParameters {
14 |
15 | private List parameters;
16 |
17 | @XmlElement(name="jobParameter")
18 | public List getParameters() {
19 | return parameters;
20 | }
21 |
22 | public void setParameters(List parameters) {
23 | this.parameters = parameters;
24 | }
25 |
26 | public AdaptedJobParameters() {
27 |
28 | }
29 |
30 | public static class AdaptedJobParameter {
31 | @XmlAttribute
32 | public String key;
33 |
34 | @XmlAttribute
35 | public String type;
36 |
37 | @XmlAttribute
38 | public boolean identifier;
39 |
40 | @XmlValue
41 | public String value;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/core/MarkLogicSpringBatch.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.core;
2 |
3 | public interface MarkLogicSpringBatch {
4 |
5 | String JOB_NAMESPACE = "http://marklogic.com/spring-batch";
6 | String JOB_NAMESPACE_PREFIX = "msb";
7 | String SPRING_BATCH_DIR = "/projects.spring.io/spring-batch/";
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/core/explore/support/MarkLogicJobExplorerFactoryBean.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.core.explore.support;
2 |
3 | import com.marklogic.client.DatabaseClient;
4 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicExecutionContextDao;
5 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicJobExecutionDao;
6 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicJobInstanceDao;
7 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicStepExecutionDao;
8 | import com.marklogic.spring.batch.core.repository.support.MarkLogicJobRepositoryProperties;
9 | import org.springframework.batch.core.explore.JobExplorer;
10 | import org.springframework.batch.core.explore.support.AbstractJobExplorerFactoryBean;
11 | import org.springframework.batch.core.explore.support.SimpleJobExplorer;
12 | import org.springframework.batch.core.repository.dao.ExecutionContextDao;
13 | import org.springframework.batch.core.repository.dao.JobExecutionDao;
14 | import org.springframework.batch.core.repository.dao.JobInstanceDao;
15 | import org.springframework.batch.core.repository.dao.StepExecutionDao;
16 |
17 | public class MarkLogicJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean {
18 |
19 | private DatabaseClient databaseClient;
20 | private MarkLogicJobRepositoryProperties properties;
21 |
22 | public void setDatabaseClient(DatabaseClient databaseClient) {
23 | this.databaseClient = databaseClient;
24 | }
25 |
26 | public void setMarkLogicJobRepositoryProperties(MarkLogicJobRepositoryProperties properties) {
27 | this.properties = properties;
28 | }
29 |
30 | @Override
31 | protected JobInstanceDao createJobInstanceDao() throws Exception {
32 | return new MarkLogicJobInstanceDao(databaseClient, properties);
33 | }
34 |
35 | @Override
36 | protected JobExecutionDao createJobExecutionDao() throws Exception {
37 | return new MarkLogicJobExecutionDao(databaseClient, properties);
38 | }
39 |
40 | @Override
41 | protected StepExecutionDao createStepExecutionDao() throws Exception {
42 | return new MarkLogicStepExecutionDao(databaseClient, properties);
43 | }
44 |
45 | @Override
46 | protected ExecutionContextDao createExecutionContextDao() throws Exception {
47 | return new MarkLogicExecutionContextDao(databaseClient, properties);
48 | }
49 |
50 | @Override
51 | public JobExplorer getObject() throws Exception {
52 | return new SimpleJobExplorer(createJobInstanceDao(),
53 | createJobExecutionDao(), createStepExecutionDao(),
54 | createExecutionContextDao());
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/core/package-info.java:
--------------------------------------------------------------------------------
1 | @XmlSchema(
2 | namespace=MarkLogicSpringBatch.JOB_NAMESPACE,
3 | elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
4 | xmlns = {
5 | @XmlNs(prefix = MarkLogicSpringBatch.JOB_NAMESPACE_PREFIX, namespaceURI=MarkLogicSpringBatch.JOB_NAMESPACE),
6 | @XmlNs(prefix = "xs", namespaceURI="http://www.w3.org/2001/XMLSchema"),
7 | @XmlNs(prefix = "xsi", namespaceURI="http://www.w3.org/2001/XMLSchema-instance")
8 | }
9 | )
10 |
11 | /**
12 | * Provides the adapted JAXB classes necessary to persist JobExecution data in MarkLogic
13 | *
14 | * @since 1.0
15 |
16 | */
17 |
18 | package com.marklogic.spring.batch.core;
19 |
20 | import javax.xml.bind.annotation.XmlSchema;
21 | import javax.xml.bind.annotation.XmlNs;
22 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/core/repository/support/MarkLogicJobRepositoryFactoryBean.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.core.repository.support;
2 |
3 | import com.marklogic.client.DatabaseClient;
4 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicExecutionContextDao;
5 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicJobExecutionDao;
6 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicJobInstanceDao;
7 | import com.marklogic.spring.batch.core.repository.dao.MarkLogicStepExecutionDao;
8 | import org.springframework.batch.core.repository.dao.ExecutionContextDao;
9 | import org.springframework.batch.core.repository.dao.JobExecutionDao;
10 | import org.springframework.batch.core.repository.dao.JobInstanceDao;
11 | import org.springframework.batch.core.repository.dao.StepExecutionDao;
12 | import org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean;
13 | import org.springframework.beans.factory.InitializingBean;
14 | import org.springframework.util.Assert;
15 |
16 | public class MarkLogicJobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean implements InitializingBean {
17 |
18 | private DatabaseClient databaseClient;
19 | private MarkLogicJobRepositoryProperties properties;
20 |
21 | public void setDatabaseClient(DatabaseClient databaseClient) {
22 | this.databaseClient = databaseClient;
23 | }
24 |
25 | public void setMarkLogicJobRepositoryProperties(MarkLogicJobRepositoryProperties properties) {
26 | this.properties = properties;
27 | }
28 |
29 | @Override
30 | protected JobInstanceDao createJobInstanceDao() throws Exception {
31 | return new MarkLogicJobInstanceDao(databaseClient, properties);
32 | }
33 |
34 | @Override
35 | protected JobExecutionDao createJobExecutionDao() throws Exception {
36 | return new MarkLogicJobExecutionDao(databaseClient, properties);
37 | }
38 |
39 | @Override
40 | protected StepExecutionDao createStepExecutionDao() throws Exception {
41 | return new MarkLogicStepExecutionDao(databaseClient, properties);
42 | }
43 |
44 | @Override
45 | protected ExecutionContextDao createExecutionContextDao() throws Exception {
46 | return new MarkLogicExecutionContextDao(databaseClient, properties);
47 | }
48 |
49 | @Override
50 | public void afterPropertiesSet() throws Exception {
51 | Assert.notNull(databaseClient, "DatabaseClient cannot be NULL");
52 | super.afterPropertiesSet();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/item/listener/SimpleChunkListener.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.item.listener;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.batch.core.ChunkListener;
6 | import org.springframework.batch.core.scope.context.ChunkContext;
7 |
8 | public class SimpleChunkListener implements ChunkListener {
9 |
10 | Logger logger = LoggerFactory.getLogger(SimpleChunkListener.class);
11 |
12 | @Override
13 | public void beforeChunk(ChunkContext context) {
14 |
15 | }
16 |
17 | @Override
18 | public void afterChunk(ChunkContext context) {
19 | logger.info("Chunk Processed");
20 | }
21 |
22 | @Override
23 | public void afterChunkError(ChunkContext context) {
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/core/src/main/java/com/marklogic/spring/batch/item/processor/ColumnMapProcessor.java:
--------------------------------------------------------------------------------
1 | package com.marklogic.spring.batch.item.processor;
2 |
3 | import com.marklogic.client.io.StringHandle;
4 | import com.marklogic.client.io.marker.AbstractWriteHandle;
5 | import com.marklogic.spring.batch.columnmap.ColumnMapSerializer;
6 | import com.marklogic.spring.batch.item.processor.support.UriGenerator;
7 |
8 | import java.util.Map;
9 | import java.util.UUID;
10 |
11 | public class ColumnMapProcessor extends AbstractMarkLogicItemProcessor