Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Adjustments for tde changes #22

Merged
merged 1 commit into from
Apr 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import java.util.Set;

import com.marklogic.client.DatabaseClient;
import com.marklogic.client.document.JSONDocumentManager;
import com.marklogic.client.document.TextDocumentManager;
import com.marklogic.client.document.XMLDocumentManager;
import com.marklogic.client.helper.LoggingObject;
import com.marklogic.client.impl.JSONDocumentImpl;
import com.marklogic.client.io.DocumentMetadataHandle;
import com.marklogic.client.io.FileHandle;
import com.marklogic.client.io.Format;
import com.marklogic.client.schemasloader.SchemasFinder;
Expand All @@ -20,15 +23,22 @@ public class DefaultSchemasLoader extends LoggingObject implements SchemasLoader
public Set<File> loadSchemas(File baseDir, SchemasFinder schemasDataFinder, DatabaseClient client) {
XMLDocumentManager xmlDocMgr = client.newXMLDocumentManager();
TextDocumentManager textDocMgr = client.newTextDocumentManager();
JSONDocumentManager jsonDocMgr = client.newJSONDocumentManager();

List<File> schemasData = schemasDataFinder.findSchemas(baseDir);

Set<File> loadedSchemas = new HashSet<>();

DocumentMetadataHandle tdeCollection = new DocumentMetadataHandle().withCollections("http://marklogic.com/xdmp/tde");
for (File f : schemasData) {
String extension = getExtensionNameFromFile(f);
FileHandle handle = new FileHandle(f);
if (extension.equals("tde") || extension.equals("xsd")) {
if (extension.equals("tdej")) {
jsonDocMgr.write(f.getName(), tdeCollection, handle.withFormat(Format.JSON));
}
else if (extension.equals("tdex")) {
xmlDocMgr.write(f.getName(), tdeCollection, handle.withFormat(Format.XML));
}
else if (extension.equals("xsd")) {
xmlDocMgr.write(f.getName(), handle.withFormat(Format.XML));
} else {
textDocMgr.write(f.getName(), handle.withFormat(Format.TEXT));
Expand Down