com.marklogic.spark.writer.DocBuilderFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marklogic-spark-connector Show documentation
Show all versions of marklogic-spark-connector Show documentation
Spark 3 connector for MarkLogic
/*
* Copyright © 2024 MarkLogic Corporation. All Rights Reserved.
*/
package com.marklogic.spark.writer;
import com.marklogic.client.io.DocumentMetadataHandle;
/**
* This is intended to migrate to java-client-api and likely just be a Builder class on DocumentWriteOperation.
*/
class DocBuilderFactory {
private DocumentMetadataHandle metadata;
private DocBuilder.UriMaker uriMaker;
DocBuilderFactory() {
this.metadata = new DocumentMetadataHandle();
}
DocBuilder newDocBuilder() {
return new DocBuilder(uriMaker, metadata);
}
DocBuilderFactory withCollections(String collections) {
if (collections != null && collections.trim().length() > 0) {
metadata.withCollections(collections.split(","));
}
return this;
}
DocBuilderFactory withPermissions(String permissionsString) {
metadata.getPermissions().addFromDelimitedString(permissionsString);
return this;
}
DocBuilderFactory withUriMaker(DocBuilder.UriMaker uriMaker) {
this.uriMaker = uriMaker;
return this;
}
}