Search in sources :

Example 21 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class FeatureGroupXmlWriter method writeFeatureGroupSpecBody.

static void writeFeatureGroupSpecBody(final ElementNode configE, ConfigItemContainer featureGroup, String ns) {
    if (!featureGroup.hasItems()) {
        return;
    }
    String currentOrigin = null;
    ElementNode parent = configE;
    for (ConfigItem item : featureGroup.getItems()) {
        final String itemOrigin = item.getOrigin();
        if (itemOrigin != null) {
            if (!itemOrigin.equals(currentOrigin)) {
                parent = addElement(configE, Element.ORIGIN.getLocalName(), ns);
                addAttribute(parent, Attribute.NAME, itemOrigin);
                currentOrigin = itemOrigin;
            }
        } else if (currentOrigin != null) {
            currentOrigin = null;
            parent = configE;
        }
        if (item.isGroup()) {
            writeFeatureGroupDependency(parent, (FeatureGroup) item, ns);
        } else {
            addFeatureConfig(parent, (FeatureConfig) item, ns);
        }
    }
}
Also used : ConfigItem(org.jboss.galleon.config.ConfigItem) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 22 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class ConfigLayerXmlWriter method toElement.

protected ElementNode toElement(ConfigLayerSpec layer, String ns) {
    final ElementNode configE = addElement(null, Element.LAYER_SPEC.getLocalName(), ns);
    addAttribute(configE, Attribute.NAME, layer.getName());
    if (layer.hasLayerDeps()) {
        final ElementNode layers = addElement(configE, Element.DEPENDENCIES.getLocalName(), ns);
        for (ConfigLayerDependency layerDep : layer.getLayerDeps()) {
            final ElementNode layerE = addElement(layers, Element.LAYER.getLocalName(), ns);
            addAttribute(layerE, Attribute.NAME, layerDep.getName());
            if (layerDep.isOptional()) {
                addAttribute(layerE, Attribute.OPTIONAL, "true");
            }
        }
    }
    FeatureGroupXmlWriter.addFeatureGroupDepBody(layer, configE, ns);
    return configE;
}
Also used : ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 23 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class ConfigXmlWriter method toElement.

protected ElementNode toElement(ConfigModel config, String ns) {
    final ElementNode configE = addElement(null, Element.CONFIG.getLocalName(), ns);
    if (config.getModel() != null) {
        addAttribute(configE, Attribute.MODEL, config.getModel());
    }
    if (config.hasProperties()) {
        final ElementNode propsE = addElement(configE, Element.PROPS.getLocalName(), ns);
        for (Map.Entry<String, String> prop : config.getProperties().entrySet()) {
            final ElementNode propE = addElement(propsE, Element.PROP.getLocalName(), ns);
            addAttribute(propE, Attribute.NAME, prop.getKey());
            addAttribute(propE, Attribute.VALUE, prop.getValue());
        }
    }
    if (config.hasConfigDeps()) {
        final ElementNode configDeps = addElement(configE, Element.CONFIG_DEPS.getLocalName(), ns);
        for (Map.Entry<String, ConfigId> dep : config.getConfigDeps().entrySet()) {
            final ElementNode configDep = addElement(configDeps, Element.CONFIG_DEP.getLocalName(), ns);
            addAttribute(configDep, Attribute.ID.getLocalName(), dep.getKey());
            final ConfigId configId = dep.getValue();
            if (configId.getModel() != null) {
                addAttribute(configDep, Attribute.MODEL.getLocalName(), configId.getModel());
            }
            if (configId.getName() != null) {
                addAttribute(configDep, Attribute.NAME.getLocalName(), configId.getName());
            }
        }
    }
    ElementNode layers = null;
    if (!config.isInheritLayers()) {
        layers = addElement(configE, Element.LAYERS.getLocalName(), ns);
        addAttribute(layers, Attribute.INHERIT, "false");
    }
    if (config.hasIncludedLayers()) {
        if (layers == null) {
            layers = addElement(configE, Element.LAYERS.getLocalName(), ns);
        }
        for (String layerDep : config.getIncludedLayers()) {
            final ElementNode layer = addElement(layers, Element.INCLUDE.getLocalName(), ns);
            addAttribute(layer, Attribute.NAME, layerDep);
        }
    }
    if (config.hasExcludedLayers()) {
        if (layers == null) {
            layers = addElement(configE, Element.LAYERS.getLocalName(), ns);
        }
        for (String layerDep : config.getExcludedLayers()) {
            final ElementNode layer = addElement(layers, Element.EXCLUDE.getLocalName(), ns);
            addAttribute(layer, Attribute.NAME, layerDep);
        }
    }
    FeatureGroupXmlWriter.addFeatureGroupDepBody(config, configE, ns);
    return configE;
}
Also used : ConfigId(org.jboss.galleon.config.ConfigId) ElementNode(org.jboss.galleon.xml.util.ElementNode) Map(java.util.Map)

Example 24 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class PackageXmlWriter method writeOrigin.

private static void writeOrigin(ElementNode deps, String origin, Collection<PackageDependencySpec> depGroup, String ns) {
    final ElementNode fpElement = addElement(deps, PackageDepsSpecXmlParser.ORIGIN, ns);
    addAttribute(fpElement, Attribute.NAME, origin);
    for (PackageDependencySpec depSpec : depGroup) {
        writePackageDependency(fpElement, depSpec, ns);
    }
}
Also used : PackageDependencySpec(org.jboss.galleon.spec.PackageDependencySpec) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 25 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class PackageXmlWriter method toElement.

protected ElementNode toElement(PackageSpec pkgSpec) {
    final ElementNode pkg = addElement(null, Element.PACKAGE_SPEC);
    addAttribute(pkg, Attribute.NAME, pkgSpec.getName());
    if (pkgSpec.hasPackageDeps()) {
        writePackageDeps(pkgSpec, addElement(pkg, Element.DEPENDENCIES.getLocalName(), Element.DEPENDENCIES.getNamespace()));
    }
    return pkg;
}
Also used : ElementNode(org.jboss.galleon.xml.util.ElementNode)

Aggregations

ElementNode (org.jboss.galleon.xml.util.ElementNode)27 Map (java.util.Map)8 TextNode (org.jboss.galleon.xml.util.TextNode)4 XMLStreamException (javax.xml.stream.XMLStreamException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)2 FeatureDependencySpec (org.jboss.galleon.spec.FeatureDependencySpec)2 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ConfigItem (org.jboss.galleon.config.ConfigItem)1 ConfigModel (org.jboss.galleon.config.ConfigModel)1 FeatureConfig (org.jboss.galleon.config.FeatureConfig)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1 CapabilitySpec (org.jboss.galleon.spec.CapabilitySpec)1 ConfigLayerDependency (org.jboss.galleon.spec.ConfigLayerDependency)1 FeatureAnnotation (org.jboss.galleon.spec.FeatureAnnotation)1 FeatureId (org.jboss.galleon.spec.FeatureId)1 FeaturePackPlugin (org.jboss.galleon.spec.FeaturePackPlugin)1 FeatureParameterSpec (org.jboss.galleon.spec.FeatureParameterSpec)1 FeatureReferenceSpec (org.jboss.galleon.spec.FeatureReferenceSpec)1 PackageDependencySpec (org.jboss.galleon.spec.PackageDependencySpec)1