Search in sources :

Example 1 with ResolvedData

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

the class DataLoaderService method buildDataWriter.

protected IDataWriter buildDataWriter(ProcessInfo processInfo, String sourceNodeId, String channelId, long batchId, boolean isRetry) {
    TransformTable[] transforms = null;
    NodeGroupLink link = null;
    List<ResolvedData> resolvedDatas = new ArrayList<ResolvedData>();
    List<IDatabaseWriterFilter> filters = extensionService.getExtensionPointList(IDatabaseWriterFilter.class);
    List<IDatabaseWriterFilter> dynamicFilters = filters;
    List<IDatabaseWriterErrorHandler> errorHandlers = extensionService.getExtensionPointList(IDatabaseWriterErrorHandler.class);
    List<IDatabaseWriterErrorHandler> dynamicErrorHandlers = errorHandlers;
    if (sourceNodeId != null) {
        Node sourceNode = nodeService.findNode(sourceNodeId, true);
        if (sourceNode != null) {
            link = new NodeGroupLink(sourceNode.getNodeGroupId(), parameterService.getNodeGroupId());
        }
        Map<LoadFilterType, Map<String, List<LoadFilter>>> loadFilters = loadFilterService.findLoadFiltersFor(link, true);
        List<DynamicDatabaseWriterFilter> databaseWriterFilters = DynamicDatabaseWriterFilter.getDatabaseWriterFilters(engine, loadFilters);
        if (loadFilters != null && loadFilters.size() > 0) {
            dynamicFilters = new ArrayList<IDatabaseWriterFilter>(filters.size() + 1);
            dynamicFilters.addAll(filters);
            dynamicFilters.addAll(databaseWriterFilters);
            dynamicErrorHandlers = new ArrayList<IDatabaseWriterErrorHandler>(errorHandlers.size() + 1);
            dynamicErrorHandlers.addAll(errorHandlers);
            dynamicErrorHandlers.addAll(databaseWriterFilters);
        }
        List<TransformTableNodeGroupLink> transformsList = transformService.findTransformsFor(link, TransformPoint.LOAD);
        transforms = transformsList != null ? transformsList.toArray(new TransformTable[transformsList.size()]) : null;
        if (isRetry) {
            List<IncomingError> incomingErrors = getIncomingErrors(batchId, sourceNodeId);
            for (IncomingError incomingError : incomingErrors) {
                if (incomingError.isResolveIgnore() || StringUtils.isNotBlank(incomingError.getResolveData())) {
                    resolvedDatas.add(new ResolvedData(incomingError.getFailedRowNumber(), incomingError.getResolveData(), incomingError.isResolveIgnore()));
                }
            }
        }
    }
    TransformWriter transformWriter = new TransformWriter(platform, TransformPoint.LOAD, null, transformService.getColumnTransforms(), transforms);
    IDataWriter targetWriter = getFactory(channelId).getDataWriter(sourceNodeId, symmetricDialect, transformWriter, dynamicFilters, dynamicErrorHandlers, getConflictSettingsNodeGroupLinks(link, false), resolvedDatas);
    transformWriter.setNestedWriter(new ProcessInfoDataWriter(targetWriter, processInfo));
    return transformWriter;
}
Also used : ResolvedData(org.jumpmind.symmetric.io.data.writer.ResolvedData) Node(org.jumpmind.symmetric.model.Node) ArrayList(java.util.ArrayList) TransformTable(org.jumpmind.symmetric.io.data.transform.TransformTable) DynamicDatabaseWriterFilter(org.jumpmind.symmetric.load.DynamicDatabaseWriterFilter) IncomingError(org.jumpmind.symmetric.model.IncomingError) IDatabaseWriterErrorHandler(org.jumpmind.symmetric.io.data.writer.IDatabaseWriterErrorHandler) TransformTableNodeGroupLink(org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink) NodeGroupLink(org.jumpmind.symmetric.model.NodeGroupLink) IDatabaseWriterFilter(org.jumpmind.symmetric.io.data.writer.IDatabaseWriterFilter) ProcessInfoDataWriter(org.jumpmind.symmetric.model.ProcessInfoDataWriter) LoadFilterType(org.jumpmind.symmetric.model.LoadFilter.LoadFilterType) LoadFilter(org.jumpmind.symmetric.model.LoadFilter) TransformWriter(org.jumpmind.symmetric.io.data.writer.TransformWriter) ChannelMap(org.jumpmind.symmetric.model.ChannelMap) Map(java.util.Map) HashMap(java.util.HashMap) TransformTableNodeGroupLink(org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink) IDataWriter(org.jumpmind.symmetric.io.data.IDataWriter)

Example 2 with ResolvedData

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

the class DataLoaderService method buildDataWriter.

protected IDataWriter buildDataWriter(ProcessInfo processInfo, String sourceNodeId, String channelId, long batchId) {
    TransformTable[] transforms = null;
    NodeGroupLink link = null;
    List<ResolvedData> resolvedDatas = new ArrayList<ResolvedData>();
    List<IDatabaseWriterFilter> filters = extensionService.getExtensionPointList(IDatabaseWriterFilter.class);
    List<IDatabaseWriterFilter> dynamicFilters = filters;
    List<IDatabaseWriterErrorHandler> errorHandlers = extensionService.getExtensionPointList(IDatabaseWriterErrorHandler.class);
    List<IDatabaseWriterErrorHandler> dynamicErrorHandlers = errorHandlers;
    if (sourceNodeId != null) {
        Node sourceNode = nodeService.findNode(sourceNodeId);
        if (sourceNode != null) {
            link = new NodeGroupLink(sourceNode.getNodeGroupId(), parameterService.getNodeGroupId());
        }
        Map<LoadFilterType, Map<String, List<LoadFilter>>> loadFilters = loadFilterService.findLoadFiltersFor(link, true);
        List<DynamicDatabaseWriterFilter> databaseWriterFilters = DynamicDatabaseWriterFilter.getDatabaseWriterFilters(engine, loadFilters);
        if (loadFilters != null && loadFilters.size() > 0) {
            dynamicFilters = new ArrayList<IDatabaseWriterFilter>(filters.size() + 1);
            dynamicFilters.addAll(filters);
            dynamicFilters.addAll(databaseWriterFilters);
            dynamicErrorHandlers = new ArrayList<IDatabaseWriterErrorHandler>(errorHandlers.size() + 1);
            dynamicErrorHandlers.addAll(errorHandlers);
            dynamicErrorHandlers.addAll(databaseWriterFilters);
        }
        List<TransformTableNodeGroupLink> transformsList = transformService.findTransformsFor(link, TransformPoint.LOAD);
        transforms = transformsList != null ? transformsList.toArray(new TransformTable[transformsList.size()]) : null;
        List<IncomingError> incomingErrors = getIncomingErrors(batchId, sourceNodeId);
        for (IncomingError incomingError : incomingErrors) {
            if (incomingError.isResolveIgnore() || StringUtils.isNotBlank(incomingError.getResolveData())) {
                resolvedDatas.add(new ResolvedData(incomingError.getFailedRowNumber(), incomingError.getResolveData(), incomingError.isResolveIgnore()));
            }
        }
    }
    TransformWriter transformWriter = new TransformWriter(platform, TransformPoint.LOAD, null, transformService.getColumnTransforms(), transforms);
    IDataWriter targetWriter = getFactory(channelId).getDataWriter(sourceNodeId, symmetricDialect, transformWriter, dynamicFilters, dynamicErrorHandlers, getConflictSettingsNodeGroupLinks(link, false), resolvedDatas);
    transformWriter.setNestedWriter(new ProcessInfoDataWriter(targetWriter, processInfo));
    return transformWriter;
}
Also used : ResolvedData(org.jumpmind.symmetric.io.data.writer.ResolvedData) Node(org.jumpmind.symmetric.model.Node) ArrayList(java.util.ArrayList) TransformTable(org.jumpmind.symmetric.io.data.transform.TransformTable) DynamicDatabaseWriterFilter(org.jumpmind.symmetric.load.DynamicDatabaseWriterFilter) IncomingError(org.jumpmind.symmetric.model.IncomingError) IDatabaseWriterErrorHandler(org.jumpmind.symmetric.io.data.writer.IDatabaseWriterErrorHandler) TransformTableNodeGroupLink(org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink) NodeGroupLink(org.jumpmind.symmetric.model.NodeGroupLink) IDatabaseWriterFilter(org.jumpmind.symmetric.io.data.writer.IDatabaseWriterFilter) ProcessInfoDataWriter(org.jumpmind.symmetric.model.ProcessInfoDataWriter) LoadFilterType(org.jumpmind.symmetric.model.LoadFilter.LoadFilterType) LoadFilter(org.jumpmind.symmetric.model.LoadFilter) TransformWriter(org.jumpmind.symmetric.io.data.writer.TransformWriter) ChannelMap(org.jumpmind.symmetric.model.ChannelMap) Map(java.util.Map) HashMap(java.util.HashMap) TransformTableNodeGroupLink(org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink) IDataWriter(org.jumpmind.symmetric.io.data.IDataWriter)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IDataWriter (org.jumpmind.symmetric.io.data.IDataWriter)2 TransformTable (org.jumpmind.symmetric.io.data.transform.TransformTable)2 IDatabaseWriterErrorHandler (org.jumpmind.symmetric.io.data.writer.IDatabaseWriterErrorHandler)2 IDatabaseWriterFilter (org.jumpmind.symmetric.io.data.writer.IDatabaseWriterFilter)2 ResolvedData (org.jumpmind.symmetric.io.data.writer.ResolvedData)2 TransformWriter (org.jumpmind.symmetric.io.data.writer.TransformWriter)2 DynamicDatabaseWriterFilter (org.jumpmind.symmetric.load.DynamicDatabaseWriterFilter)2 ChannelMap (org.jumpmind.symmetric.model.ChannelMap)2 IncomingError (org.jumpmind.symmetric.model.IncomingError)2 LoadFilter (org.jumpmind.symmetric.model.LoadFilter)2 LoadFilterType (org.jumpmind.symmetric.model.LoadFilter.LoadFilterType)2 Node (org.jumpmind.symmetric.model.Node)2 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)2 ProcessInfoDataWriter (org.jumpmind.symmetric.model.ProcessInfoDataWriter)2 TransformTableNodeGroupLink (org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink)2