Search in sources :

Example 1 with StructureDataWriter

use of org.jumpmind.symmetric.io.data.writer.StructureDataWriter in project symmetric-ds by JumpMind.

the class DataExtractorService method extractToPayload.

public List<OutgoingBatchWithPayload> extractToPayload(ProcessInfo processInfo, Node targetNode, PayloadType payloadType, boolean useJdbcTimestampFormat, boolean useUpsertStatements, boolean useDelimiterIdentifiers) {
    OutgoingBatches batches = outgoingBatchService.getOutgoingBatches(targetNode.getNodeId(), false);
    if (batches.containsBatches()) {
        ChannelMap channelMap = configurationService.getSuspendIgnoreChannelLists(targetNode.getNodeId());
        List<OutgoingBatch> activeBatches = filterBatchesForExtraction(batches, channelMap);
        if (activeBatches.size() > 0) {
            IDdlBuilder builder = DdlBuilderFactory.createDdlBuilder(targetNode.getDatabaseType());
            if (builder == null) {
                throw new IllegalStateException("Could not find a ddl builder registered for the database type of " + targetNode.getDatabaseType() + ".  Please check the database type setting for node '" + targetNode.getNodeId() + "'");
            }
            StructureDataWriter writer = new StructureDataWriter(symmetricDialect.getPlatform(), targetNode.getDatabaseType(), payloadType, useDelimiterIdentifiers, symmetricDialect.getBinaryEncoding(), useJdbcTimestampFormat, useUpsertStatements);
            List<OutgoingBatch> extractedBatches = extract(processInfo, targetNode, activeBatches, writer, null, ExtractMode.FOR_PAYLOAD_CLIENT);
            List<OutgoingBatchWithPayload> batchesWithPayload = new ArrayList<OutgoingBatchWithPayload>();
            for (OutgoingBatch batch : extractedBatches) {
                OutgoingBatchWithPayload batchWithPayload = new OutgoingBatchWithPayload(batch, payloadType);
                batchWithPayload.setPayload(writer.getPayloadMap().get(batch.getBatchId()));
                batchWithPayload.setPayloadType(payloadType);
                batchesWithPayload.add(batchWithPayload);
            }
            return batchesWithPayload;
        }
    }
    return Collections.emptyList();
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap) OutgoingBatchWithPayload(org.jumpmind.symmetric.model.OutgoingBatchWithPayload) IDdlBuilder(org.jumpmind.db.platform.IDdlBuilder) ArrayList(java.util.ArrayList) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) StructureDataWriter(org.jumpmind.symmetric.io.data.writer.StructureDataWriter)

Aggregations

ArrayList (java.util.ArrayList)1 IDdlBuilder (org.jumpmind.db.platform.IDdlBuilder)1 StructureDataWriter (org.jumpmind.symmetric.io.data.writer.StructureDataWriter)1 ChannelMap (org.jumpmind.symmetric.model.ChannelMap)1 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)1 OutgoingBatchWithPayload (org.jumpmind.symmetric.model.OutgoingBatchWithPayload)1 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)1