Package org.apache.torque.generator.outlet

Examples of org.apache.torque.generator.outlet.Outlet


            {
                log.debug("Start generation of Output File path");
            }
            controllerState.setOutputFile(null);

            Outlet filenameOutlet = output.getFilenameOutlet();
            OutletReference contentOutletReference
                    = new OutletReference(
                            filenameOutlet.getName());
            controllerState.setRootOutletReference(
                    contentOutletReference);
            // use the namespace not of the filenameOutlet
            // but of the real outlet
            // TODO: is this a good idea ? make configurable ?
            controllerState.setOutletNamespace(
                    output.getContentOutlet().getNamespace());
            filenameOutlet.beforeExecute(controllerState);
            OutletResult filenameResult
                = filenameOutlet.execute(controllerState);
            if (!filenameResult.isStringResult())
            {
                throw new GeneratorException(
                        "The result of a filename generation must be a String,"
                        + " not a byte array");
            }
            String filename = filenameResult.getStringResult();
            filenameOutlet.afterExecute(controllerState);
            if (log.isDebugEnabled())
            {
                log.debug("End generation of Output File path, result is "
                        + filename);
            }
View Full Code Here


                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),
View Full Code Here

    public OutletResult execute(ControllerState controllerState)
        throws GeneratorException
    {
        TokenReplacer tokenReplacer = new TokenReplacer(controllerState);

        Outlet outlet;
        {
            OutletConfiguration outletConfiguration
                    = controllerState.getUnitConfiguration()
                        .getOutletConfiguration();
            String detokenizedOutletName
                    = tokenReplacer.process(outletName);
            QualifiedName outletQName = new QualifiedName(
                    detokenizedOutletName,
                    Namespace.ROOT_NAMESPACE);

            outlet = outletConfiguration.getOutlet(outletQName);
            if (outlet == null)
            {
                throw new GeneratorException("TraverseAllAction : The outlet "
                        + outletName
                        + " does not exist");
            }
        }

        SourceElement currentElement = controllerState.getSourceElement();
        String detokenizedElementToTraverseName
                = tokenReplacer.process(elementsToTraverseName);

        List<SourceElement> selectedElements
                = SourcePath.getElements(
                        currentElement,
                        detokenizedElementToTraverseName);
        if (!acceptEmpty && selectedElements.isEmpty())
        {
            throw new GeneratorException(
                    "TraverseAllAction : selected element "
                        + elementsToTraverseName
                        + " does not exist and acceptEmpty was set to false");
        }

        List<OutletResult> resultList
                = new ArrayList<OutletResult>(selectedElements.size());
        for (SourceElement sourceElement : selectedElements)
        {
            controllerState.setSourceElement(sourceElement);
            outlet.beforeExecute(controllerState);
            resultList.add(outlet.execute(controllerState));
            outlet.afterExecute(controllerState);
        }
        controllerState.setSourceElement(currentElement);
        if (resultList.isEmpty())
        {
            return new OutletResult("");
View Full Code Here

        TokenReplacer tokenReplacer = new TokenReplacer(controllerState);
        String detokenizedOutletName = tokenReplacer.process(outletName);
        QualifiedName qualifiedOutletName = new QualifiedName(
                detokenizedOutletName,
                Namespace.ROOT_NAMESPACE);
        Outlet outlet = controllerState.getUnitConfiguration()
                .getOutletConfiguration()
                .getOutlet(qualifiedOutletName);
        if (outlet == null)
        {
            throw new GeneratorException("ApplyAction : The outlet "
                    + outletName
                    + " does not exist");
        }

        SourceElement currentElement = controllerState.getSourceElement();
        String detokenizedPath = tokenReplacer.process(path);

        List<SourceElement> selectedElements
                = SourcePath.getElements(currentElement, detokenizedPath);
        if (selectedElements.isEmpty())
        {
            if (!acceptNotSet)
            {
                throw new GeneratorException(
                        "ApplyAction : selected path "
                            + path
                            + " does not match an element"
                            + " and acceptNotSet was set to false");
            }
            return new OutletResult("");
        }
        if (selectedElements.size() > 1)
        {
            throw new GeneratorException(
                    "ApplyAction : selected path "
                        + path
                        + " contains more than one element ("
                        + selectedElements.size()
                        + " times)");
        }
        // selectedElements has size 1
        controllerState.setSourceElement(selectedElements.get(0));
        outlet.beforeExecute(controllerState);
        OutletResult result = outlet.execute(controllerState);
        outlet.afterExecute(controllerState);
        controllerState.setSourceElement(currentElement);
        return result;
    }
View Full Code Here

        if (outletHandler != null)
        {
            outletHandler.endElement(uri, localName, rawName);
            if (outletHandler.isFinished())
            {
                Outlet outlet = outletHandler.getOutlet();
                outlets.add(outlet);
                if (log.isDebugEnabled())
                {
                    log.debug("Parsed configuration for the outlet "
                            + outlet.getName());
                }
                outletHandler = null;
            }
        }
        else if (mergepointHandler != null)
View Full Code Here

                    + " : Could not link class " + className
                    + " : " + e.getMessage());
            throw e;
        }

        Outlet result;
        try
        {
            Constructor<?> constructor
                    = outletClass.getConstructor(QualifiedName.class);
            result = (Outlet) constructor.newInstance(outletName);
View Full Code Here

                        + name
                        + " needs to be qualified with the outlet name");
            }
            QualifiedName outletName = new QualifiedName(
                    qualifiedMergepointName.getNamespace().toString());
            Outlet outlet = outlets.get(outletName);
            if (outlet == null)
            {
                throw new ConfigurationException(
                        "No outlet with name "
                        + outletName
                        + "exists (required by the isolated mergepoint mapping"
                        + " with the name "
                        + name
                        + ")");
            }
            MergepointMapping originalMergepointMapping = entry.getValue();
            MergepointMapping resolvedMergepointMapping
                    = new MergepointMapping(
                            qualifiedMergepointName.getName(),
                            originalMergepointMapping.getActions());
            outlet.setMergepointMapping(resolvedMergepointMapping);
        }
        mergepointMappingsResolved = true;
        mergepointMappings.clear();
    }
View Full Code Here

        if (unitDescriptor == null)
        {
            throw new NullPointerException(
                    "unitDescriptor must not be null");
        }
        Outlet existingOutlet = outlets.get(outlet.getName());
        if (existingOutlet != null)
        {
            throw new ConfigurationException("Trying to add the outlet "
                    + outlet.getName()
                    + " and class "
                    + outlet.getClass().getName()
                    + " : A outlet with the same name "
                    + " already exists, it has the class "
                    + existingOutlet.getClass().getName());
        }
        if (unitDescriptor.isAddDebuggingInfoToOutput())
        {
            outlet = new DebuggingOutletWrapper(outlet);
        }
View Full Code Here

                outlets,
                mergepointMappings,
                unitDescriptor);
        outletConfiguration.resolveMergepointMappings();

        Outlet outlet = outletConfiguration.getOutlet(
                new QualifiedName("test.outlet"));
        assertEquals(1, outlet.getMergepointMappings().size());
        assertEquals(
                1,
                outlet.getMergepointMapping("testMergepoint")
                    .getActions().size());
    }
View Full Code Here

TOP

Related Classes of org.apache.torque.generator.outlet.Outlet

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.