use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class FeatureSpecXmlWriter method toElement.
protected ElementNode toElement(FeatureSpec featureSpec) {
final ElementNode specE = addElement(null, Element.FEATURE_SPEC);
addAttribute(specE, Attribute.NAME, featureSpec.getName());
if (featureSpec.hasAnnotations()) {
for (FeatureAnnotation fa : featureSpec.getAnnotations()) {
final ElementNode annotationE = addElement(specE, Element.ANNOTATION);
addAttribute(annotationE, Attribute.NAME, fa.getName());
if (fa.hasElements()) {
for (Map.Entry<String, String> entry : fa.getElements().entrySet()) {
final ElementNode elemE = addElement(annotationE, Element.ELEM);
addAttribute(elemE, Attribute.NAME, entry.getKey());
if (entry.getValue() != null) {
addAttribute(elemE, Attribute.VALUE, entry.getValue());
}
}
}
}
}
if (featureSpec.providesCapabilities()) {
writeCaps(addElement(specE, Element.PROVIDES), featureSpec.getProvidedCapabilities());
}
if (featureSpec.requiresCapabilities()) {
writeCaps(addElement(specE, Element.REQUIRES), featureSpec.getRequiredCapabilities());
}
if (featureSpec.hasFeatureDeps()) {
final ElementNode depsE = addElement(specE, Element.DEPENDENCIES);
for (FeatureDependencySpec dep : featureSpec.getFeatureDeps()) {
final ElementNode depE = addElement(depsE, Element.DEPENDENCY);
addAttribute(depE, Attribute.FEATURE_ID, dep.getFeatureId().toString());
if (dep.getOrigin() != null) {
addAttribute(depE, Attribute.DEPENDENCY, dep.getOrigin());
}
if (dep.isInclude()) {
addAttribute(depE, Attribute.INCLUDE, TRUE);
}
}
}
if (featureSpec.hasFeatureRefs()) {
final ElementNode refsE = addElement(specE, Element.REFERENCES);
for (FeatureReferenceSpec ref : featureSpec.getFeatureRefs()) {
final ElementNode refE = addElement(refsE, Element.REFERENCE);
final String feature = ref.getFeature().toString();
if (ref.getOrigin() != null) {
addAttribute(refE, Attribute.DEPENDENCY, ref.getOrigin());
}
addAttribute(refE, Attribute.FEATURE, feature);
if (!feature.equals(ref.getName())) {
addAttribute(refE, Attribute.NAME, ref.getName());
}
if (ref.isNillable()) {
addAttribute(refE, Attribute.NILLABLE, TRUE);
}
if (ref.isInclude()) {
addAttribute(refE, Attribute.INCLUDE, TRUE);
}
for (Map.Entry<String, String> mapping : ref.getMappedParams().entrySet()) {
final ElementNode paramE = addElement(refE, Element.PARAMETER);
addAttribute(paramE, Attribute.NAME, mapping.getKey());
addAttribute(paramE, Attribute.MAPS_TO, mapping.getValue());
}
}
}
if (featureSpec.hasParams()) {
final ElementNode paramsE = addElement(specE, Element.PARAMETERS);
for (FeatureParameterSpec paramSpec : featureSpec.getParams().values()) {
final ElementNode paramE = addElement(paramsE, Element.PARAMETER);
addAttribute(paramE, Attribute.NAME, paramSpec.getName());
if (paramSpec.isFeatureId()) {
addAttribute(paramE, Attribute.FEATURE_ID, TRUE);
} else if (paramSpec.isNillable()) {
addAttribute(paramE, Attribute.NILLABLE, TRUE);
}
if (paramSpec.hasDefaultValue()) {
addAttribute(paramE, Attribute.DEFAULT, paramSpec.getDefaultValue());
}
if (paramSpec.getType() != null && !Constants.BUILT_IN_TYPE_STRING.equals(paramSpec.getType())) {
addAttribute(paramE, Attribute.TYPE, paramSpec.getType());
}
}
}
if (featureSpec.hasPackageDeps()) {
PackageXmlWriter.writePackageDeps(featureSpec, addElement(specE, Element.PACKAGES));
}
return specE;
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class FeatureGroupXmlWriter method addFeatureGroupIncludeExclude.
static void addFeatureGroupIncludeExclude(FeatureGroupSupport dep, String ns, final ElementNode depE) {
if (dep.hasExcludedSpecs()) {
for (SpecId spec : dep.getExcludedSpecs()) {
final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(excludeE, Attribute.SPEC, spec.toString());
}
}
if (dep.hasExcludedFeatures()) {
for (Map.Entry<FeatureId, String> excluded : dep.getExcludedFeatures().entrySet()) {
final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(excludeE, Attribute.FEATURE_ID, excluded.getKey().toString());
if (excluded.getValue() != null) {
addAttribute(excludeE, Attribute.PARENT_REF, excluded.getValue());
}
}
}
if (dep.hasIncludedSpecs()) {
for (SpecId spec : dep.getIncludedSpecs()) {
final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
addAttribute(includeE, Attribute.SPEC, spec.toString());
}
}
if (dep.hasIncludedFeatures()) {
for (Map.Entry<FeatureId, FeatureConfig> entry : dep.getIncludedFeatures().entrySet()) {
final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
addAttribute(includeE, Attribute.FEATURE_ID, entry.getKey().toString());
final FeatureConfig fc = entry.getValue();
if (fc.getParentRef() != null) {
addAttribute(includeE, Attribute.PARENT_REF, fc.getParentRef());
}
if (fc != null) {
addFeatureConfigBody(includeE, entry.getKey(), fc, ns);
}
}
}
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class FeatureGroupXmlWriter method writeFeatureGroupDependency.
private static void writeFeatureGroupDependency(ElementNode depsE, FeatureGroup dep, String ns) {
final ElementNode depE = addElement(depsE, Element.FEATURE_GROUP.getLocalName(), ns);
addFeatureGroupDepBody(dep, depE, ns);
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class FeatureGroupXmlWriter method addFeatureConfigBody.
private static void addFeatureConfigBody(ElementNode fcE, FeatureId id, FeatureConfig fc, String ns) {
if (fc.hasFeatureDeps()) {
for (FeatureDependencySpec depSpec : fc.getFeatureDeps()) {
final ElementNode depE = addElement(fcE, Element.DEPENDS.getLocalName(), ns);
if (depSpec.getOrigin() != null) {
addAttribute(depE, Attribute.ORIGIN, depSpec.getOrigin());
}
addAttribute(depE, Attribute.FEATURE_ID, depSpec.getFeatureId().toString());
if (depSpec.isInclude()) {
addAttribute(depE, Attribute.INCLUDE, TRUE);
}
}
}
if (fc.hasParams()) {
for (Map.Entry<String, String> param : fc.getParams().entrySet()) {
final String name = param.getKey();
if (id != null && id.hasParam(name)) {
continue;
}
final ElementNode paramE = addElement(fcE, Element.PARAM.getLocalName(), ns);
addAttribute(paramE, Attribute.NAME, name);
addAttribute(paramE, Attribute.VALUE, param.getValue());
}
}
if (fc.hasResetParams()) {
for (String param : fc.getResetParams()) {
final ElementNode paramE = addElement(fcE, Element.RESET_PARAM.getLocalName(), ns);
addAttribute(paramE, Attribute.PARAM, param);
}
}
if (fc.hasUnsetParams()) {
for (String param : fc.getUnsetParams()) {
final ElementNode paramE = addElement(fcE, Element.UNSET_PARAM.getLocalName(), ns);
addAttribute(paramE, Attribute.PARAM, param);
}
}
writeFeatureGroupSpecBody(fcE, fc, ns);
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class ProvisioningXmlWriter method writeFeaturePackConfig.
static void writeFeaturePackConfig(ElementNode fp, FeaturePackLocation location, FeaturePackConfig featurePack, String origin) {
final String ns = fp.getNamespace();
addAttribute(fp, Attribute.LOCATION, location.toString());
if (origin != null) {
addElement(fp, Element.ORIGIN.getLocalName(), ns).addChild(new TextNode(origin));
}
if (featurePack.hasPatches()) {
final ElementNode patches = addElement(fp, Element.PATCHES.getLocalName(), ns);
for (FPID patchId : featurePack.getPatches()) {
final ElementNode patch = addElement(patches, Element.PATCH.getLocalName(), ns);
addAttribute(patch, Attribute.ID, patchId.toString());
}
}
writeConfigCustomizations(fp, ns, featurePack);
ElementNode packages = null;
final Boolean inheritPackages = featurePack.getInheritPackages();
if (inheritPackages != null) {
packages = addElement(fp, Element.PACKAGES.getLocalName(), ns);
addAttribute(packages, Attribute.INHERIT, String.valueOf(inheritPackages));
}
if (featurePack.hasExcludedPackages()) {
if (packages == null) {
packages = addElement(fp, Element.PACKAGES.getLocalName(), ns);
}
for (String excluded : featurePack.getExcludedPackages()) {
final ElementNode exclude = addElement(packages, Element.EXCLUDE.getLocalName(), ns);
addAttribute(exclude, Attribute.NAME, excluded);
}
}
if (featurePack.hasIncludedPackages()) {
if (packages == null) {
packages = addElement(fp, Element.PACKAGES.getLocalName(), ns);
}
for (String included : featurePack.getIncludedPackages()) {
final ElementNode include = addElement(packages, Element.INCLUDE.getLocalName(), ns);
addAttribute(include, Attribute.NAME, included);
}
}
}
Aggregations