Package org.apache.torque.generator.source.stream

Examples of org.apache.torque.generator.source.stream.FileSourceProvider


            projectPaths.setSourceDir(sourceDir);
            log("Setting source dir to " + sourceDir.toString(),
                    Project.MSG_DEBUG);
        }

        FileSourceProvider fileSourceProvider = null;
        if (sourceIncludes != null || sourceExcludes != null)
        {
            Fileset sourceFileset
                    = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            sourceIncludes,
                            sourceExcludes);
            log("Setting source includes to " + sourceIncludes,
                    Project.MSG_DEBUG);
            log("Setting source excludes to " + sourceExcludes,
                    Project.MSG_DEBUG);
            try
            {
                fileSourceProvider = new FileSourceProvider(
                        null,
                        sourceFileset,
                        combineFiles);
            }
            catch (ConfigurationException e)
View Full Code Here


                Fileset sourceFileset = new Fileset(
                        getProjectPaths().getDefaultSourcePath(),
                        includes,
                        excludes);

                sourceProvider = new FileSourceProvider(
                        sourceFormat,
                        sourceFileset,
                        combineFiles);
            }
            catch (ConfigurationException e)
View Full Code Here

        {
            projectPaths.setSourceDir(sourceDir);
            getLog().debug("Setting source dir to " + sourceDir.toString());
        }

        FileSourceProvider fileSourceProvider = null;
        if (sourceIncludes != null || sourceExcludes != null)
        {
            Fileset sourceFileset
                    = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            sourceIncludes,
                            sourceExcludes);
            getLog().debug("Setting source includes to "
                    + sourceIncludes);
            getLog().debug("Setting source excludes to "
                    + sourceExcludes);
            try
            {
                fileSourceProvider = new FileSourceProvider(
                        null,
                        sourceFileset,
                        combineFiles);
            }
            catch (ConfigurationException e)
View Full Code Here

                {
                    Fileset sourceFileset = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            new HashSet<String>(),
                            new HashSet<String>());
                    FileSourceProvider sourceProvider = new FileSourceProvider(
                            new XmlSourceFormat(),
                            sourceFileset,
                            null);
                    sourceProvider.init(
                            configurationHandlers,
                            controllerState);
                    output.getSourceProvider().init(
                            configurationHandlers,
                            controllerState);
                    assertFileSourceProviderEquals(
                            sourceProvider,
                            (FileSourceProvider) output.getSourceProvider());
                }
                assertSourceProcessConfigurationEquals(
                        new SourceProcessConfiguration(),
                        output.getSourceProcessConfiguration());
            }

            {
                Output output = outputFiles.get(1);
                assertEquals(
                        new QualifiedName("secondOutput"),
                        output.getName());
                assertEquals(
                        "replace",
                        output.getExistingTargetStrategy());
                assertEquals(
                        "secondOutputDirKey",
                        output.getOutputDirKey());
                assertNull(output.getFilename());

                {
                    OutletReference outletConfiguration
                            = output.getContentOutlet();
                    assertEquals(
                            new QualifiedName(
                                "org.apache.torque.generator.test.readConfiguration.anotherOutlet"),
                            outletConfiguration.getName());
                }

                {
                    VelocityOutlet filenameOutlet
                            = (VelocityOutlet) output.getFilenameOutlet();
                    String templateContent
                            = filenameOutlet.getContent(controllerState);
                    // remove License from template by comparing only
                    // the last line
                    String templateContentLicenseRemoved
                            = StringUtils.substringAfterLast(templateContent, "\r\n");
                    assertEquals(
                            "test template output",
                            templateContentLicenseRemoved);
                    assertEquals(
                            new QualifiedName(
                                    "org.apache.torque.generator.configuration.filenameOutlet"),
                            filenameOutlet.getName());
                    assertTrue(filenameOutlet.isOptionsInContext());
                    assertTrue(filenameOutlet.isSourceAttributesInContext());
                    assertTrue(filenameOutlet.isVariablesInContext());
                }

                {
                    Fileset sourceFileset = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            createSetFrom("second.source.path.properties"),
                            createSetFrom("second.excluded.properties"));
                    FileSourceProvider sourceProvider = new FileSourceProvider(
                            new PropertiesSourceFormat(),
                            sourceFileset,
                            true);
                    sourceProvider.init(
                            configurationHandlers,
                            controllerState);
                    output.getSourceProvider().init(
                            configurationHandlers,
                            controllerState);
                    assertFileSourceProviderEquals(
                            sourceProvider,
                            (FileSourceProvider) output.getSourceProvider());
                }
                {
                    SourceProcessConfiguration sourceProcessConfiguration
                        = new SourceProcessConfiguration();
                    sourceProcessConfiguration.setStartElementsPath(
                            "properties/entry");
                    List<SourceTransformerDefinition> transformerDefinitions
                            = new ArrayList<SourceTransformerDefinition>();

                    transformerDefinitions.add(
                            new SourceTransformerDefinition(
                                    new ConfigurationTestTransformer(),
                                    null));
                    transformerDefinitions.add(
                            new SourceTransformerDefinition(
                                    new OtherConfigurationTestTransformer(),
                                    "database"));
                    sourceProcessConfiguration.setSourceTransformerDefinitions(
                            transformerDefinitions);
                    sourceProcessConfiguration.setSkipDecider(
                            "org.apache.torque.generator.configuration.ConfigurationTestSkipDecider");
                    assertSourceProcessConfigurationEquals(
                            sourceProcessConfiguration,
                            output.getSourceProcessConfiguration());
                }
            }
            {
                Output output = outputFiles.get(2);
                assertEquals(
                        new QualifiedName("thirdOutput"),
                        output.getName());
                assertEquals(
                        "append",
                        output.getExistingTargetStrategy());
                assertEquals(
                        "thirdOutputDirKey",
                        output.getOutputDirKey());
                assertEquals("outputFileName", output.getFilename());
                assertNull(output.getFilenameOutlet());

                {
                    OutletReference outletConfiguration
                            = output.getContentOutlet();
                    assertEquals(
                            new QualifiedName(
                                "org.apache.torque.generator.test.readConfiguration.thirdOutlet"),
                            outletConfiguration.getName());
                }

                {
                    JdbcMetadataSourceProvider sourceProvider
                            = new JdbcMetadataSourceProvider(
                                "jdbcUrl",
                                "jdbcDriver",
                                "jdbcUsername",
                                "jdbcPassword",
                                "jdbcSchema");
                    sourceProvider.init(
                            configurationHandlers,
                            controllerState);
                    output.getSourceProvider().init(
                            configurationHandlers,
                            controllerState);
View Full Code Here

                {
                    Fileset sourceFileset = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            createSetFrom("parentSource"),
                            new HashSet<String>());
                    FileSourceProvider sourceProvider = new FileSourceProvider(
                            new XmlSourceFormat(),
                            sourceFileset,
                            false);
                    output.getSourceProvider().init(
                            configurationHandlers,
                            controllerState);
                    sourceProvider.init(
                            configurationHandlers,
                            controllerState);
                    assertFileSourceProviderEquals(
                            sourceProvider,
                            (FileSourceProvider) output.getSourceProvider());
                }
                {
                    SourceProcessConfiguration sourceProcessConfiguration
                        = new SourceProcessConfiguration();
                    sourceProcessConfiguration.setStartElementsPath("parentSourceElement");
                    List<SourceTransformerDefinition> transformerDefinitions
                            = new ArrayList<SourceTransformerDefinition>();

                    transformerDefinitions.add(
                            new SourceTransformerDefinition(
                                    new OtherConfigurationTestTransformer(),
                                    "parent/database"));
                    sourceProcessConfiguration.setSourceTransformerDefinitions(
                            transformerDefinitions);
                    sourceProcessConfiguration.setSkipDecider(
                            "org.apache.torque.generator.configuration.OtherConfigurationTestSkipDecider");
                    assertSourceProcessConfigurationEquals(
                            sourceProcessConfiguration,
                            output.getSourceProcessConfiguration());
                }
            }
            {
                Output output = outputList.get(1);
                assertEquals(
                        new QualifiedName("org.apache.torque.generator.firstOutput"),
                        output.getName());
                assertEquals(
                        "skip",
                        output.getExistingTargetStrategy());
                assertEquals(
                        null,
                        output.getOutputDirKey());
                assertNull(output.getFilename());

                {
                    OutletReference outletConfiguration
                            = output.getContentOutlet();
                    assertEquals(
                            new QualifiedName(
                                "org.apache.torque.generator.test.readConfiguration.javaOutlet"),
                            outletConfiguration.getName());
                }
                {
                    JavaOutlet filenameOutlet
                            = (JavaOutlet) output.getFilenameOutlet();
                    assertEquals("Foo", filenameOutlet.getFoo());
                    assertEquals("Bar", filenameOutlet.getBar());
                    assertEquals(
                            new QualifiedName(
                                    "org.apache.torque.generator.configuration.filenameOutlet"),
                            filenameOutlet.getName());
                }

                {
                    Fileset sourceFileset = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            new HashSet<String>(),
                            new HashSet<String>());
                    FileSourceProvider sourceProvider = new FileSourceProvider(
                            new XmlSourceFormat(),
                            sourceFileset,
                            null);
                    sourceProvider.init(
                            configurationHandlers,
                            controllerState);
                    output.getSourceProvider().init(
                            configurationHandlers,
                            controllerState);
                    assertFileSourceProviderEquals(
                            sourceProvider,
                            (FileSourceProvider) output.getSourceProvider());
                }
                assertSourceProcessConfigurationEquals(
                        new SourceProcessConfiguration(),
                        output.getSourceProcessConfiguration());
            }

            {
                Output output = outputList.get(2);
                assertEquals(
                        new QualifiedName("secondOutput"),
                        output.getName());
                assertEquals(
                        "replace",
                        output.getExistingTargetStrategy());
                assertEquals(
                        output.getOutputDirKey(),
                        "secondOutputDirKey");
                assertNull(output.getFilename());

                {
                    OutletReference outletConfiguration
                            = output.getContentOutlet();
                    assertEquals(
                            new QualifiedName(
                                "org.apache.torque.generator.test.readConfiguration.anotherOutlet"),
                            outletConfiguration.getName());
                }
                {
                    VelocityOutlet filenameOutlet
                            = (VelocityOutlet) output.getFilenameOutlet();
                    String templateContent
                            = filenameOutlet.getContent(controllerState);
                    // remove License from template by comparing only
                    // the last line
                    String templateContentLicenseRemoved
                            = StringUtils.substringAfterLast(templateContent, "\r\n");
                    assertEquals(
                            "test template output",
                            templateContentLicenseRemoved);
                    assertEquals(
                            new QualifiedName(
                                    "org.apache.torque.generator.configuration.filenameOutlet"),
                            filenameOutlet.getName());
                }

                {
                    Fileset sourceFileset = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            createSetFrom("second.source.path.properties"),
                            createSetFrom("second.excluded.properties"));
                    FileSourceProvider sourceProvider = new FileSourceProvider(
                            new PropertiesSourceFormat(),
                            sourceFileset,
                            true);
                    sourceProvider.init(
                            configurationHandlers,
                            controllerState);
                    output.getSourceProvider().init(
                            configurationHandlers,
                            controllerState);
                    assertFileSourceProviderEquals(
                            sourceProvider,
                            (FileSourceProvider) output.getSourceProvider());
                }
                {
                    SourceProcessConfiguration sourceProcessConfiguration
                        = new SourceProcessConfiguration();
                    sourceProcessConfiguration.setStartElementsPath("properties/entry");
                    List<SourceTransformerDefinition> transformerDefinitions
                            = new ArrayList<SourceTransformerDefinition>();
                    transformerDefinitions.add(
                            new SourceTransformerDefinition(
                                    new ConfigurationTestTransformer(),
                                    null));
                    transformerDefinitions.add(
                            new SourceTransformerDefinition(
                                    new OtherConfigurationTestTransformer(),
                                    "database"));
                    sourceProcessConfiguration.setSourceTransformerDefinitions(
                            transformerDefinitions);
                    sourceProcessConfiguration.setSkipDecider(
                        "org.apache.torque.generator.configuration.ConfigurationTestSkipDecider");
                    assertSourceProcessConfigurationEquals(
                            sourceProcessConfiguration,
                            output.getSourceProcessConfiguration());
                }
            }
            {
                Output output = outputList.get(3);
                assertEquals(
                        new QualifiedName("thirdOutput"),
                        output.getName());
                assertEquals(
                        "append",
                        output.getExistingTargetStrategy());
                assertEquals(
                        "thirdOutputDirKey",
                        output.getOutputDirKey());
                assertEquals("outputFileName", output.getFilename());
                assertNull(output.getFilenameOutlet());

                {
                    OutletReference outletConfiguration
                            = output.getContentOutlet();
                    assertEquals(
                            new QualifiedName(
                                "org.apache.torque.generator.test.readConfiguration.thirdOutlet"),
                            outletConfiguration.getName());
                }

                {
                    JdbcMetadataSourceProvider sourceProvider
                            = new JdbcMetadataSourceProvider(
                                "jdbcUrl",
                                "jdbcDriver",
                                "jdbcUsername",
                                "jdbcPassword",
                                "jdbcSchema");
                    sourceProvider.init(
                            configurationHandlers,
                            controllerState);
                    output.getSourceProvider().init(
                            configurationHandlers,
                            controllerState);
View Full Code Here

        Set<String> sourceIncludes = new HashSet<String>();
        sourceIncludes.add("schema.xml");
        sourceFileset.setIncludes(sourceIncludes);
        sourceFileset.setBasedir(projectPaths.getDefaultSourcePath());
        SourceProvider sourceProvider
                = new FileSourceProvider(
                        null,
                        sourceFileset,
                        null);
        UnitDescriptor unitDescriptor = new UnitDescriptor(
                UnitDescriptor.Packaging.DIRECTORY,
View Full Code Here

        {
            throw new SourceTransformerException(
                    "Unknown source format" + sourceFormat);
        }

        FileSourceProvider fileSourceProvider;
        try
        {
            fileSourceProvider = new FileSourceProvider(
                    streamSourceFormat,
                    new Fileset(
                            controllerState.getSourceFile().getParentFile(),
                            fileIncludes,
                            fileExcludes),
                    false);
            fileSourceProvider.init(configurationHandlers, controllerState);
        }
        catch (ConfigurationException e)
        {
            throw new SourceTransformerException(
                    "Could initialize file source provider", e);
        }
        while (fileSourceProvider.hasNext())
        {
            Source additionalSource = fileSourceProvider.next();
            SourceElement additionalSourceRoot;
            try
            {
                additionalSourceRoot = additionalSource.getRootElement();
            }
View Full Code Here

TOP

Related Classes of org.apache.torque.generator.source.stream.FileSourceProvider

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.