Package org.apache.torque.generator.control.existingtargetstrategy

Examples of org.apache.torque.generator.control.existingtargetstrategy.ExistingTargetStrategy


        }
        controllerState.setSourceElement(startElement);
        log.debug("Processing new startElement "
                + startElement.getName());

        ExistingTargetStrategy existingTargetStrategy = null;
        for (ExistingTargetStrategy candidate : EXISTING_TARGET_STRATEGIES)
        {
            if (candidate.getStrategyName().equals(
                    output.getExistingTargetStrategy()))
            {
                existingTargetStrategy = candidate;
                break;
            }
        }
        if (existingTargetStrategy == null)
        {
            throw new ControllerException("existingTargetStrategy "
                    + output.getExistingTargetStrategy()
                    + " not found");
        }

        createOutputFilename(output, controllerState);
        File outputFile = ControllerHelper.getOutputFile(
                output.getOutputDirKey(),
                output.getFilename(),
                unitConfiguration);
        controllerState.setOutputFile(outputFile);

        if (!existingTargetStrategy.beforeGeneration(
                output.getOutputDirKey(),
                output.getFilename(),
                getOutputEncoding(output, unitConfiguration),
                unitConfiguration))
        {
            log.info("Skipping generation of File "
                    + outputFile.getAbsolutePath()
                    + " because of existingTargetStrategy "
                    + existingTargetStrategy.getStrategyName());
            return;
        }
        if (log.isInfoEnabled())
        {
            log.info("Start generation of File "
                    + outputFile.getAbsolutePath());
        }

        OutletReference contentOutletConfiguration
                = output.getContentOutlet();
        controllerState.setOutletNamespace(
                contentOutletConfiguration.getNamespace());
        controllerState.setRootOutletReference(
                contentOutletConfiguration);

        OutletConfiguration outletConfiguration
                = unitConfiguration.getOutletConfiguration();

        Outlet outlet = outletConfiguration.getOutlet(
                contentOutletConfiguration.getName());
        if (outlet == null)
        {
            throw new ControllerException(
                    "No outlet configured for outlet name \""
                        + contentOutletConfiguration.getName()
                        + "\"");
        }

        SkipDecider skipDecider
                = output.getSourceProcessConfiguration().getSkipDecider();
        if (skipDecider != null)
        {
            if (!skipDecider.proceed(controllerState))
            {
                log.debug("SkipDecider " + skipDecider.getClass().getName()
                        + " decided to skip "
                        + "generation of file "
                        + controllerState.getOutputFile());
                return;
            }
            else
            {
                log.debug("SkipDecider " + skipDecider.getClass().getName()
                        + " decided to proceed");
            }
        }

        {
            File parentOutputDir
                    = controllerState.getOutputFile().getParentFile();
            if (parentOutputDir != null
                    && !parentOutputDir.isDirectory())
            {
                boolean success = parentOutputDir.mkdirs();
                if (!success)
                {
                    throw new ControllerException(
                            "Could not create directory \""
                                + parentOutputDir.getAbsolutePath()
                                + "\"");
                }
            }
        }

        outlet.beforeExecute(controllerState);
        OutletResult result = outlet.execute(controllerState);
        outlet.afterExecute(controllerState);

        existingTargetStrategy.afterGeneration(
                output.getOutputDirKey(),
                output.getFilename(),
                getOutputEncoding(output, unitConfiguration),
                result,
                unitConfiguration);
View Full Code Here

TOP

Related Classes of org.apache.torque.generator.control.existingtargetstrategy.ExistingTargetStrategy

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.