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);
}
}
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations