public static void addFeatureGroupDepBody(FeatureGroupSupport dep, final ElementNode depE, String ns) { if(dep.getName() != null) { addAttribute(depE, Attribute.NAME, dep.getName()); } if(!dep.isInheritFeatures()) { addAttribute(depE, Attribute.INHERIT_FEATURES, FALSE); } addFeatureGroupIncludeExclude(dep, ns, depE); writeFeatureGroupSpecBody(depE, dep, ns); if(dep.hasExternalFeatureGroups()) { for(Map.Entry<String, FeatureGroup> entry : dep.getExternalFeatureGroups().entrySet()) { final ElementNode fpE = addElement(depE, Element.ORIGIN.getLocalName(), ns); addAttribute(fpE, Attribute.NAME, entry.getKey()); addFeatureGroupIncludeExclude(entry.getValue(), ns, fpE); } } if(dep.hasPackageDeps()) { PackageXmlWriter.writePackageDeps(dep, addElement(depE, Element.PACKAGES.getLocalName(), ns)); } }
public static void addFeatureConfig(ElementNode parentE, FeatureConfig fc, String ns) { final ElementNode fcE = addElement(parentE, Element.FEATURE.getLocalName(), ns); addAttribute(fcE, Attribute.SPEC, fc.getSpecId().toString()); if(fc.getParentRef() != null) { addAttribute(fcE, Attribute.PARENT_REF, fc.getParentRef()); } addFeatureConfigBody(fcE, null, fc, ns); } }
private static void writeFeatureGroupDependency(ElementNode depsE, FeatureGroup dep, String ns) { final ElementNode depE = addElement(depsE, Element.FEATURE_GROUP.getLocalName(), ns); addFeatureGroupDepBody(dep, depE, ns); }
protected ElementNode toElement(FeatureGroup featureGroup, String ns) { final ElementNode fgE = addElement(null, Element.FEATURE_GROUP_SPEC.getLocalName(), ns); if(featureGroup.getName() != null) { addAttribute(fgE, Attribute.NAME, featureGroup.getName()); } //addFeatureGroupIncludeExclude(featureGroup, ns, fgE); writeFeatureGroupSpecBody(fgE, featureGroup, ns); if(featureGroup.hasPackageDeps()) { PackageXmlWriter.writePackageDeps(featureGroup, addElement(fgE, Element.PACKAGES.getLocalName(), ns)); } return fgE; }
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); } } }
final Path fgsDir = fpWorkDir.resolve(Constants.FEATURE_GROUPS); ensureDir(fgsDir); final FeatureGroupXmlWriter fgWriter = FeatureGroupXmlWriter.getInstance(); for(FeatureGroup fg : featureGroups.values()) { fgWriter.write(fg, fgsDir.resolve(fg.getName() + ".xml"));
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; } }
protected ElementNode toElement(FeatureGroup config) { return toElement(config, FeatureGroupXml.NAMESPACE_1_0); }
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); continue; final ElementNode paramE = addElement(fcE, Element.PARAM.getLocalName(), ns); addAttribute(paramE, Attribute.NAME, name); addAttribute(paramE, Attribute.VALUE, param.getValue()); final ElementNode paramE = addElement(fcE, Element.RESET_PARAM.getLocalName(), ns); addAttribute(paramE, Attribute.PARAM, param); final ElementNode paramE = addElement(fcE, Element.UNSET_PARAM.getLocalName(), ns); addAttribute(paramE, Attribute.PARAM, param); writeFeatureGroupSpecBody(fcE, fc, ns);
FeatureGroupXmlWriter.addFeatureGroupDepBody(config, configE, ns); return configE;
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()); 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()); final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns); addAttribute(includeE, Attribute.SPEC, spec.toString()); 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()); addFeatureConfigBody(includeE, entry.getKey(), fc, ns);