Package org.apache.torque.generator.source

Examples of org.apache.torque.generator.source.SourceElement


            throw new SourceException(
                    "Error parsing Properties source file: " + e.getMessage(),
                    e);
        }

        SourceElement result
                = new SourceElement(ROOT_ELEMENT_NAME);

        for (String key : properties.orderedKeySet())
        {
            String value = properties.getProperty(key);
            SourceElement entryElement
                    = new SourceElement(ENTRY_ELEMENT_NAME);
            entryElement.setAttribute(KEY_ATTRIBUTE_NAME, key);
            entryElement.setAttribute((String) null, value);
            result.getChildren().add(entryElement);
        }
        return result;
    }
View Full Code Here


            String attributeName,
            ControllerState controllerState,
            Class<?> clazz)
        throws GeneratorException
    {
        SourceElement sourceElement = SourcePath.getElement(
                controllerState.getSourceElement(),
                elementName,
                false);
        Object attribute
                = sourceElement.getAttribute(attributeName);
        if (attribute == null)
        {
            throw new GeneratorException(
                    "Source element attribute not set in "
                    + clazz.getName()
View Full Code Here

                throw new GeneratorException(
                        "Could not initialize velocity",
                        e);
            }

            SourceElement sourceElement = controllerState.getSourceElement();

            String inputElementName = getInputElementName();
            if (inputElementName != null
                    && !inputElementName.equals(sourceElement.getName()))
            {
                throw new GeneratorException("Input element name, "
                        + sourceElement.getName()
                        + ", is not the expected name, "
                        + getInputElementName()
                        + ", for outlet "
                        + getName());
            }
View Full Code Here

        else
        {
            log.debug("options in context are disabled");
        }

        SourceElement sourceElement = controllerState.getSourceElement();
        if (sourceAttributesInContext)
        {
            Set<String> attributes = sourceElement.getAttributeNames();
            for (String key : attributes)
            {
                Object value = sourceElement.getAttribute(key);
                if (key == null)
                {
                    // The null key cannot be accessed in the context.
                    // So if the attribute NULL_KEY_CONTEXT_NAME does not
                    // exist, use this as attribute name.
                    if (sourceElement.getAttributeNames().contains(
                            NULL_KEY_CONTEXT_NAME))
                    {
                        continue;
                    }
                    key = NULL_KEY_CONTEXT_NAME;
View Full Code Here

                ControllerState controllerState,
                UnitConfiguration unitConfiguration)
            throws GeneratorException
    {
        log.info("Processing source " + source.getDescription());
        SourceElement rootElement = source.getRootElement();
        controllerState.setSourceFile(source.getSourceFile());
        SourceProcessConfiguration sourceProcessConfiguration
                = output.getSourceProcessConfiguration();
        rootElement = transformSource(
                rootElement,
View Full Code Here

                    final SourceElement rootElement,
                    final List<SourceTransformerDefinition> transformerDefinitions,
                    final ControllerState controllerState)
            throws SourceTransformerException, SourceException
    {
        SourceElement result = rootElement;
        for (SourceTransformerDefinition transformerDefinition
                : transformerDefinitions)
        {
            SourceTransformer sourceTransformer
                    = transformerDefinition.getSourceTransformer();
            String elements = transformerDefinition.getElements();
            log.debug("Applying source transformer "
                    + sourceTransformer.getClass().getName()
                    + (elements == null
                            ? " to the root element"
                            : " to the elements " + elements));

            List<SourceElement> toTransform
                    = SourcePath.getElementsFromRoot(rootElement, elements);
            if (toTransform.isEmpty())
            {
                log.debug("No element found, nothing transformed");
            }
            for (SourceElement sourceElement : toTransform)
            {
                log.debug("transforming element " + sourceElement);
                SourceElement transformedElement = sourceTransformer.transform(
                        sourceElement,
                        controllerState);
                if (transformedElement == null)
                {
                    throw new SourceTransformerException("Transformer "
                            + sourceTransformer.getClass().getName()
                            + " returned null for element "
                            + sourceElement.getName());
                }
                SourceElement parent = sourceElement.getParent();
                if (parent == null)
                {
                    result = transformedElement;
                }
                else
                {
                    List<SourceElement> children = parent.getChildren();
                    int index = children.indexOf(sourceElement);
                    children.set(index, transformedElement);
                }
            }
            log.debug("Transformation ended");
View Full Code Here

        throws GeneratorException
    {
        TokenReplacer tokenReplacer = new TokenReplacer(controllerState);
        String detonizedElementPath = tokenReplacer.process(elementPath);

        SourceElement sourceElement = SourcePath.getElement(
                controllerState.getSourceElement(),
                detonizedElementPath,
                acceptNotSet);
        if (sourceElement == null)
        {
            if (acceptNotSet)
            {
                return new OutletResult("");
            }
            else
            {
                throw new GeneratorException("SourceElementAttributeAction: "
                        + "No element "
                        + elementPath
                        + "can be found.");
            }
        }
        String detokenizedAttributeName = tokenReplacer.process(attributeName);
        Object result = sourceElement.getAttribute(detokenizedAttributeName);
        if (result == null)
        {
            if (acceptNotSet)
            {
                return new OutletResult("");
            }
            throw new GeneratorException("SourceElementAttributeAction: "
                    + "The attribute "
                    + attributeName
                    + " is not set on the element "
                    + sourceElement.getName()
                    + " (element path was "
                    + elementPath
                    + ")");
        }
        return new OutletResult(result.toString());
View Full Code Here

        if (!controllerState.getBooleanOption(
                TemplateOptionName.OM_USE_MANAGERS))
        {
            return false;
        }
        SourceElement sourceElement = controllerState.getSourceElement();
        if ("false".equals(sourceElement.getAttribute("useManagers")))
        {
            return false;
        }
        List<SourceElement> primaryKeyColumns
                = sourceElement.getChild(TableChildElementName.PRIMARY_KEYS)
                    .getChildren(TorqueSchemaElementName.COLUMN);
        return !primaryKeyColumns.isEmpty();
    }
View Full Code Here

*/
public class InterfaceSkipDecider implements SkipDecider
{
    public boolean proceed(ControllerState controllerState)
    {
        SourceElement sourceElement = controllerState.getSourceElement();
        String interfaceName
                = (String) sourceElement.getAttribute(
                        TorqueSchemaAttributeName.INTERFACE.getName());
        if (interfaceName == null)
        {
            return false;
        }
View Full Code Here

                        + outletName
                        + " does not exist");
            }
        }

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

        List<SourceElement> selectedElements
                = SourcePath.getElements(
View Full Code Here

TOP

Related Classes of org.apache.torque.generator.source.SourceElement

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.