Package smilehouse.opensyncro.pipes.component

Examples of smilehouse.opensyncro.pipes.component.ConverterIF


        /** Open iteration session at Converter components */
            // Initialize converters
        int converterIndex = 0;
        for(Iterator it = converterList.iterator(); it.hasNext();) {
            ConverterListItem converterItem = (ConverterListItem) it.next();
            ConverterIF converter = converterItem.getConverter();
            converterIndex++;

            // Set PipeComponentData to Converter components before opening iteration session
            converter.setData(converterItem.getConverterData());

            // Open Converter's iteration session
            if(openComponentSession(converter, converterIndex, info, logEntry) == PipeComponentIF.ITERATION_OPEN_STATUS_ERROR) {
                // Close preceding Converter and Source component sessions

View Full Code Here


            for(Iterator it = converterList.iterator(); it.hasNext();) {
                ConverterListItem converterItem = (ConverterListItem) it.next();
                converterIndex++;

                try {
                    ConverterIF converter = converterItem.getConverter();
                    converter.setData(converterItem.getConverterData());
                } catch(PipeComponentCreationException e) {
                    logEntry.logMessage("Pipe Converter component #" + converterIndex
                            + " cannot be loaded, aborting", this, MessageLogger.ERROR);
                    Environment.getInstance().log("Error loading Converter component #" + converterIndex +
                        " for Pipe \"" + getName() + "\"", e);
                    setExecutionEndInfo(new Date(), System.currentTimeMillis()-start, LogEntry.STATUS_CONVERSION_ERROR);
                    addLogEntry(logEntry, LogEntry.STATUS_CONVERSION_ERROR);
                    return;

                }
            }
        }

        // Get Destination component and initialize its parameters
        {
            DestinationIF destination = getDestination();
            if(destination == null) {
                if(getDestinationID() == null) {
                    logEntry.logMessage(
                        "Pipe does not have a Destination component, aborting",
                        this,
                        MessageLogger.ERROR);
                } else {
                    logEntry.logMessage(
                        "Pipe Destination component cannot be loaded, aborting",
                        this,
                        MessageLogger.ERROR);
                }
                setExecutionEndInfo(new Date(), System.currentTimeMillis()-start, LogEntry.STATUS_DESTINATION_ERROR);
                addLogEntry(logEntry, LogEntry.STATUS_DESTINATION_ERROR);
                return;
            }
            destination.setData(getDestinationData());
        }
       
        logEntry.logMessage("Starting Pipe execution", this, MessageLogger.DEBUG);
       
        try {

            /** Open Source, Converter and Destination components' sessions */
            currentTask = "Pipe Component initialization";
            statusCode = openComponentSessions(
                source,
                destination,
                getConverterList(),
                info,
                logEntry);
            if(statusCode != LogEntry.STATUS_OK) {
                // Initialization failed, LogEntry's statusCode is used at the end of this method
                // for addLogEntry() call
                throw new FailTransferException();
            }
            componentSessionsOpen = true;

            /** Pipe iteration loop starts here */
            int i = 0;
            while(true) {

                try {
                    logEntry.logMessage(
                        "Requesting data block #" + ++i + " from Source component",
                        this,
                        MessageLogger.DEBUG);

                    currentTask = "Source component " + this.source.getName();
                    statusCode = LogEntry.STATUS_SOURCE_ERROR;
                    String sourceResults[] = source.give(info, logEntry);

                    // Test if Source component returned no (more) data
                    if(sourceResults == null || sourceResults[0] == null) {
                        logEntry.logMessage(
                            "Source component returned no data",
                            this,
                            MessageLogger.DEBUG);

                        /*
                         * Exit iteration loop when Source component returns null instead of data
                         * String
                         */
                        break;
                    }

                    if(sourceResults.length > 1) {
                        logEntry.logMessage("Source component returned " + sourceResults.length
                                + " data blocks", this, MessageLogger.DEBUG);
                    }

                    // Iterate over Strings returned by Source component
                    for(int j = 0; j < sourceResults.length; j++) {

                        // Proceed with conversions
                        statusCode = LogEntry.STATUS_CONVERSION_ERROR;
                        currentTask = "Preparing to call first Converter component";

                        getConverterList();
                        Iterator it = this.converterList.iterator();

                        // Check if we have any Converters on the list
                        if(it.hasNext() == true) {

                            /*
                             * Converters (such as SplitConverter) may return multiple data parts
                             * based on a single input String
                             */

                            String[] processedData = new String[1];

                            /*
                             * For first Converter on the list we call the regular 'convert' method,
                             * which takes String as input and returns String array
                             */

                            ConverterListItem converterItem = (ConverterListItem) it.next();
                            ConverterIF converter = converterItem.getConverter();
                            currentTask = "Converter component " + converter.getName();
                            processedData = converter.convert(sourceResults[j], info, logEntry);
                            /*
                             * Test if any of the first Converter's result Strings is null, if yes ->
                             * report an error and abort Pipe execution
                             */
                            if(arrayContainsNull(processedData)) {
                                logEntry.logMessage(
                                    "Error: Converter " + converter.getName()
                                            + " returned null result, aborting",
                                    this,
                                    MessageLogger.ERROR);
                                throw new FailTransferException();
                            }

                            /*
                             * Repeat over the rest of the Converters list and call 'convertAll'
                             * method for processing every String in a String array
                             */

                            while(it.hasNext()) {

                                converterItem = (ConverterListItem) it.next();
                                converter = converterItem.getConverter();
                                currentTask = "Converter component " + converter.getName();
                                processedData = converter.convertAll(processedData, info, logEntry);
                                /*
                                 * Test if any of the Converter's result Strings is null, if yes ->
                                 * report an error and abort Pipe execution
                                 */
                                if(arrayContainsNull(processedData)) {
                                    logEntry.logMessage(
                                        "Error: Converter " + converter.getName()
                                                + " returned null result, aborting",
                                        this,
                                        MessageLogger.ERROR);
                                    throw new FailTransferException();
                                }
View Full Code Here

TOP

Related Classes of smilehouse.opensyncro.pipes.component.ConverterIF

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.