Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit dfa831e

Browse files
author
Scott Stafford
committed
Merge branch 'dev'
2 parents 0149a0a + d659b0b commit dfa831e

File tree

113 files changed

+4495
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+4495
-343
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@ Each contributor should be knowledgeable and proficient at the following project
1313
* [MarkLogic JUnit Library](https://github.com/rjrudin/ml-junit)
1414
* [MarkLogic App Deployer](https://github.com/rjrudin/ml-app-deployer)
1515
* [Git](http://git-scm.com/doc)
16+
* [Git Large File System](https://git-lfs.github.com/) - this is required to pull down large binary files used for the Entity Extraction examples
1617

1718
# What software do I need?
1819

1920
* [MarkLogic 8+](http://developer.marklogic.com/products)
2021
* [Java Development Kit 1.8+](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
21-
* Recommended: [Gradle 3.+](http://gradle.org/gradle-download/)
22+
* (Recommended) [Gradle 3.+](http://gradle.org/gradle-download/)
2223

2324
You will need to first install MarkLogic if you haven't already. It is recommended to use a virtual machine or remote server to run MarkLogic to partition our resources (MarkLogic likes to use a lot of memory).
2425

26+
# Git Large File System
27+
28+
Make sure that after you clone this repository that you also pull from Git LFS. Otherwise your tests may not pass.
29+
2530
# What code baseline should I use?
26-
We use a [fork-and-Branch Git workflow](http://blog.scottlowe.org/2015/01/27/using-fork-branch-git-workflow/). The dev branch contains the latest and greatest code, while master represents the latest published version. **Always branch from DEV**. If you issue a pull request, make sure to compare against the DEV branch.
31+
The dev branch contains the latest and greatest code, while master represents the latest published version. **Always branch from DEV**. If you issue a pull request, make sure to compare against the DEV branch.
32+
33+
We use a [fork-and-Branch Git workflow](http://blog.scottlowe.org/2015/01/27/using-fork-branch-git-workflow/).
2734

2835
# Should I use an IDE?
2936
Yes, it is recommended to use a Java friendly IDE to make one's life easier. Of course, you can use a simple text editor if that is your preference. The lead authors have a recent preference for [IntelliJ](https://www.jetbrains.com/idea/). We also use Gradle for our swiss army knife of building, testing, deploying, etc. One of the cool features of Gradle is the ability to create the project files for two popular IDE's, IntelliJ and Eclipse.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ subprojects {
2222

2323
dependencies {
2424
compile "org.springframework.batch:spring-batch-core:3.0.7.RELEASE"
25-
compile "com.marklogic:ml-javaclient-util:2.10.0-alpha"
25+
compile "com.marklogic:ml-javaclient-util:2.10.0"
2626
}
2727

2828
task wrapper(type: Wrapper) {
@@ -36,7 +36,7 @@ subprojects {
3636

3737
checkstyle {
3838
configFile = file("${project.rootDir}/dev-tools/checkstyle/checkstyle.xml")
39-
toolVersion = '6.19'
39+
toolVersion = '7.1.2'
4040
}
4141

4242
task sourcesJar(type: Jar, dependsOn: classes) {

core/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Fri Sep 30 20:57:34 EDT 2016
1+
#Tue Oct 04 14:55:15 EDT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME

core/src/main/java/com/marklogic/client/io/MarkLogicWriteHandle.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.marklogic.client.io;
22

3-
import com.marklogic.client.document.DocumentUriTemplate;
43
import com.marklogic.client.document.DocumentWriteOperation;
54
import com.marklogic.client.io.marker.AbstractWriteHandle;
65
import com.marklogic.client.io.marker.DocumentMetadataWriteHandle;
@@ -15,6 +14,10 @@ public class MarkLogicWriteHandle implements DocumentWriteOperation {
1514
private DocumentMetadataHandle metadataHandle;
1615
private AbstractWriteHandle handle;
1716
private OperationType opType;
17+
18+
public MarkLogicWriteHandle() {
19+
20+
}
1821

1922
public MarkLogicWriteHandle(String uri, DocumentMetadataHandle metadata, AbstractWriteHandle handle) {
2023
this.uri = uri;

core/src/main/java/com/marklogic/spring/batch/Main.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.context.annotation.Configuration;
2323
import org.springframework.core.env.JOptCommandLinePropertySource;
2424
import org.springframework.core.type.filter.AnnotationTypeFilter;
25-
import org.springframework.core.type.filter.RegexPatternTypeFilter;
2625

2726
import java.io.File;
2827
import java.io.FileReader;

core/src/main/java/com/marklogic/spring/batch/core/repository/dao/AbstractMarkLogicBatchMetadataDao.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77

88
public abstract class AbstractMarkLogicBatchMetadataDao extends LoggingObject {
99

10-
protected DatabaseClient databaseClient;
11-
12-
protected DataFieldMaxValueIncrementer incrementer;
10+
protected DatabaseClient databaseClient;
1311

14-
protected final long LOWER_RANGE = 0;
12+
protected DataFieldMaxValueIncrementer incrementer;
13+
14+
protected final long LOWER_RANGE = 0;
1515
protected final long UPPER_RANGE = 9999999;
16-
16+
1717
public final String SEARCH_OPTIONS_NAME = "spring-batch";
18-
19-
public final String SPRING_BATCH_DIR = "/projects.spring.io/spring-batch/";
20-
21-
public final String COLLECTION_JOB_INSTANCE = "http://marklogic.com/spring-batch/job-instance";
22-
23-
public DatabaseClient getDatabaseClient() {
24-
return databaseClient;
25-
}
26-
27-
public void setIncrementer(DataFieldMaxValueIncrementer incrementer) {
28-
this.incrementer = incrementer;
29-
}
18+
19+
public final String SPRING_BATCH_DIR = "/projects.spring.io/spring-batch/";
20+
21+
public final String COLLECTION_JOB_INSTANCE = "http://marklogic.com/spring-batch/job-instance";
22+
23+
public DatabaseClient getDatabaseClient() {
24+
return databaseClient;
25+
}
26+
27+
public void setIncrementer(DataFieldMaxValueIncrementer incrementer) {
28+
this.incrementer = incrementer;
29+
}
3030

3131
}

core/src/main/java/com/marklogic/spring/batch/item/AbstractDocumentWriter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import com.marklogic.client.io.DocumentMetadataHandle;
88
import com.marklogic.client.io.DocumentMetadataHandle.Capability;
99

10-
import java.io.File;
11-
1210
/**
1311
* Base class for writing documents. Should be able to support both the Client API and XCC.
1412
*/

core/src/main/java/com/marklogic/spring/batch/item/MarkLogicItemWriter.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.marklogic.spring.batch.item;
22

33
import com.marklogic.client.DatabaseClient;
4-
import com.marklogic.client.document.DocumentWriteOperation;
5-
import com.marklogic.client.document.DocumentWriteSet;
6-
import com.marklogic.client.document.GenericDocumentManager;
4+
import com.marklogic.client.document.*;
5+
import com.marklogic.client.io.Format;
76
import org.slf4j.Logger;
87
import org.slf4j.LoggerFactory;
98
import org.springframework.batch.item.ItemWriter;
109

1110
import java.util.List;
11+
import java.util.Map;
1212

1313
/*
1414
The MarkLogicItemWriter is an ItemWriter used to write any type of document to MarkLogic. It expects a
@@ -24,6 +24,9 @@ public class MarkLogicItemWriter implements ItemWriter<DocumentWriteOperation> {
2424
private String outputUriPrefix;
2525
private String outputUriReplace;
2626
private String outputUriSuffix;
27+
private ServerTransform serverTransform;
28+
private Format format;
29+
private boolean transformOn = false;
2730

2831
public MarkLogicItemWriter(DatabaseClient client) {
2932
this.client = client;
@@ -40,9 +43,13 @@ public void write(List<? extends DocumentWriteOperation> items) throws Exception
4043
uri = (outputUriSuffix != null) ? uri + outputUriSuffix : uri;
4144
batch.add(uri, item.getMetadata(), item.getContent());
4245
}
43-
docMgr.write(batch);
46+
if (!transformOn) {
47+
docMgr.write(batch);
48+
} else {
49+
docMgr.write(batch, serverTransform);
50+
}
4451
}
45-
52+
4653
private String applyOutputUriReplace(String uri, String outputUriReplace) {
4754
String[] regexReplace = outputUriReplace.split(",");
4855
for (int i = 0; i < regexReplace.length; i=i+2) {
@@ -74,6 +81,19 @@ public void setOutputUriReplace(String outputUriReplace) {
7481
public void setOutputUriSuffix(String outputUriSuffix) {
7582
this.outputUriSuffix = outputUriSuffix;
7683
}
77-
78-
84+
85+
/*
86+
Applies transform for every document
87+
*/
88+
public void setTransform(Format format, String transformName, Map<String, String> transformParameters) {
89+
this.format = format;
90+
docMgr.setContentFormat(format);
91+
this.serverTransform = new ServerTransform(transformName);
92+
if (transformParameters != null) {
93+
for (String key : transformParameters.keySet()) {
94+
serverTransform.put(key, transformParameters.get(key));
95+
}
96+
}
97+
transformOn = true;
98+
}
7999
}

core/src/main/java/com/marklogic/uri/DefaultUriGenerator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.marklogic.uri;
22

3-
import java.io.File;
43
import java.util.UUID;
54

65
public class DefaultUriGenerator implements UriGenerator<String>{

core/src/test/java/com/marklogic/spring/batch/bind/MarshallSpringBatchPojoToXmlTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.marklogic.spring.batch.bind;
22

3-
import com.marklogic.client.spring.BasicConfig;
43
import com.marklogic.junit.Fragment;
54
import com.marklogic.junit.NamespaceProvider;
65
import com.marklogic.spring.batch.*;

0 commit comments

Comments
 (0)