Package org.easybatch.flatfile

Examples of org.easybatch.flatfile.FlatFileRecordReader


    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordFilter(new StartsWithStringRecordFilter("#"))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id", "name"}))
                .registerRecordValidator(new BeanValidationRecordValidator<Greeting>())
                .registerRecordProcessor(new GreetingSlowProcessor())
                .build();
View Full Code Here


    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id", "name"}))
                .registerRecordProcessor(new GreetingProcessor())
                .build();

        // Run easy batch engine
View Full Code Here

    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordFilter(new StartsWithStringRecordFilter("#"))
                .registerRecordMapper(new FixedLengthRecordMapper<Greeting>(
                        Greeting.class,
                        new int[]{3,3},
                        new String[]{"id", "name"}))
View Full Code Here

        fileWriter.close();
    }

    public static EasyBatchEngine buildCsvEasyBatchEngine(String customersFile) throws Exception {
        return new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(customersFile)))
                .registerRecordMapper(new DelimitedRecordMapper<Customer>(Customer.class,
                        new String[]{"id", "firstName", "lastName", "birthDate", "email", "phone", "street", "zipCode", "city", "country"}))
                .build();
    }
View Full Code Here

        productMapper.setDelimiter("|");
        productMapper.setQualifier("\"");

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from products-jsr303.csv
                .registerRecordMapper(productMapper)
                .registerRecordValidator(new BeanValidationRecordValidator<Product>())
                .registerRecordProcessor(new ProductProcessor())
                .build();
View Full Code Here

        System.out.println(COMMENT_SEPARATOR);
        System.out.println("Running a single Easy Batch instance");
        System.out.println(COMMENT_SEPARATOR);
        long singleInstanceStartTime = System.nanoTime();
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        EasyBatchReport easyBatchReport = easyBatchEngine.call();
        System.out.println(easyBatchReport);

        long singleInstanceEndTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - singleInstanceStartTime);

        System.out.println(COMMENT_SEPARATOR);
        System.out.println("Running two Easy Batch instances in parallel");
        System.out.println(COMMENT_SEPARATOR);
        long parallelInstancesStartTime = System.nanoTime();

        // To avoid any thread-safety issues,
        // we will create 2 engines with separate instances of record readers and processors

        // Build an easy batch engine1
        EasyBatchEngine easyBatchEngine1 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordFilter(new RecordNumberGreaterThanRecordFilter(5)) // filter records 6-10
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        // Build an easy batch engine2
        EasyBatchEngine easyBatchEngine2 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordFilter(new RecordNumberLowerThanRecordFilter(6)) // filter records 1-5
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        //create a 2 threads pool to call Easy Batch engines in parallel
View Full Code Here

    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id", "name"}))
                .registerRecordValidator(new BeanValidationRecordValidator<Greeting>())
                .registerRecordProcessor(new GreetingProcessor())
                .build();
View Full Code Here

        // To avoid any thread-safety issues,
        // we will create 2 engines with separate instances of record readers and processors

        // Build an easy batch engine1
        EasyBatchEngine easyBatchEngine1 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages-part1.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        // Build an easy batch engine2
        EasyBatchEngine easyBatchEngine2 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[1]))) //read data from secret-messages-part2.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        //create a 2 threads pool to call Easy Batch engines in parallel
        ExecutorService executorService = Executors.newFixedThreadPool(2);
View Full Code Here

        DatabaseUtil.startEmbeddedDatabase();
        DatabaseUtil.initializeSessionFactory();

        // Build an easy batch engine to read greetings from csv file
        EasyBatchEngine easyBatchCsvEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id","name"}))
                .registerRecordProcessor(new GreetingDataLoader())
                .build();

        // Build an easy batch engine to read greetings from xml file
View Full Code Here

        productMapper.setQualifier("\"");
        productMapper.registerTypeConverter(Origin.class, new OriginTypeConverter());

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from products.csv
                .registerRecordMapper(productMapper)
                .registerRecordProcessor(new ProductProcessor())
                .build();

        // Run easy batch engine and get execution report
View Full Code Here

TOP

Related Classes of org.easybatch.flatfile.FlatFileRecordReader

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.