public Collection<FeatureAnnotation> getAnnotations() { return xmlSpec.getAnnotations(); }
private Map<ResolvedFeatureId, FeatureDependencySpec> resolveSpecDeps(ProvisioningRuntimeBuilder rt) throws ProvisioningException { if(resolvedDeps != null) { return resolvedDeps; } resolvedDeps = Collections.emptyMap(); if(xmlSpec.hasFeatureDeps()) { resolvedDeps = resolveFeatureDeps(rt, xmlSpec.getFeatureDeps()); } return resolvedDeps; }
void resolveRefMappings(ProvisioningRuntimeBuilder rt) throws ProvisioningException { if(!xmlSpec.hasFeatureRefs()) { resolvedRefTargets = Collections.emptyMap(); return; } final FeaturePackRuntimeBuilder ownFp = rt.layout.getFeaturePack(id.producer); Collection<FeatureReferenceSpec> refs = xmlSpec.getFeatureRefs(); if (refs.size() == 1) { resolvedRefTargets = Collections.singletonMap(refs.iterator().next().getName(), resolveRefMapping(rt, ownFp, refs.iterator().next())); return; } final Map<String, ResolvedFeatureSpec> tmp = new HashMap<>(refs.size()); for (FeatureReferenceSpec refSpec : refs) { tmp.put(refSpec.getName(), resolveRefMapping(rt, ownFp, refSpec)); } this.resolvedRefTargets = Collections.unmodifiableMap(tmp); }
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(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(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(featureSpec.hasParams()) { final ElementNode paramsE = addElement(specE, Element.PARAMETERS); for(FeatureParameterSpec paramSpec : featureSpec.getParams().values()) { final ElementNode paramE = addElement(paramsE, Element.PARAMETER);
List<FeatureParameterSpec> idparams = f.getSpec().getIdParams(); String tab = " "; session.println(Config.getLineSeparator() + "Feature Id parameters"); Map<String, FeatureParameterSpec> params = f.getSpec().getParams(); if (params.isEmpty()) { session.println("NONE"); if (f.getSpec().getProvidedCapabilities().isEmpty()) { session.println(tab + "NONE"); } else { for (CapabilitySpec c : f.getSpec().getProvidedCapabilities()) { session.println(tab + c.toString()); if (f.getSpec().getRequiredCapabilities().isEmpty()) { session.println(tab + "NONE"); } else { for (CapabilitySpec c : f.getSpec().getRequiredCapabilities()) { session.println(tab + c.toString()); if (f.getSpec().getFeatureDeps().isEmpty()) { session.println(tab + "NONE"); } else { for (FeatureDependencySpec c : f.getSpec().getFeatureDeps()) { session.println(tab + c.getFeatureId().toString()); if (f.getSpec().getFeatureRefs().isEmpty()) { session.println(tab + "NONE"); } else {
ResolvedFeatureId resolveIdFromForeignKey(ResolvedFeatureId parentId, String parentRef, Map<String, String> params) throws ProvisioningException { if(!xmlSpec.hasId()) { return null; final List<FeatureParameterSpec> idParamSpecs = xmlSpec.getIdParams(); final Map<String, Object> resolvedParams = new HashMap<>(idParamSpecs.size()); final FeatureReferenceSpec refSpec = xmlSpec.getFeatureRef(parentRef); final FeatureParameterSpec param = xmlSpec.getParam(mapping.getKey()); if(!param.isFeatureId()) { continue;
this.xmlSpec = spec; if(xmlSpec.hasParams()) { for(Map.Entry<String, FeatureParameterSpec> entry : xmlSpec.getParams().entrySet()) { final FeatureParameterSpec param = entry.getValue(); resolvedParamSpecs = CollectionUtils.put(resolvedParamSpecs, param.getName(), resolveParamSpec(param, typeProvider)); final FeatureAnnotation newFb = xmlSpec.getAnnotation(FeatureAnnotation.FEATURE_BRANCH); if(newFb != null) { branchId = newFb.getElement(FeatureAnnotation.FEATURE_BRANCH_ID);
private void assertRefParamMapping(final FeatureReferenceSpec refSpec, final ResolvedFeatureSpec targetSpec) throws ProvisioningDescriptionException { if (!targetSpec.xmlSpec.hasId()) { throw new ProvisioningDescriptionException(id + " feature spec declares reference " + refSpec.getName() + " to feature spec " + targetSpec.id + " that has no ID parameters"); } if(!refSpec.hasMappedParams()) { for(FeatureParameterSpec targetIdParam : targetSpec.xmlSpec.getIdParams()) { if(!xmlSpec.hasParam(targetIdParam.getName())) { throw new ProvisioningDescriptionException(Errors.nonExistingForeignKeyParam(refSpec.getName(), id, targetIdParam.getName())); } } return; } if (targetSpec.xmlSpec.getIdParams().size() != refSpec.getParamsMapped()) { throw new ProvisioningDescriptionException("The number of foreign key parameters of reference " + refSpec.getName() + " in feature spec " + id + " does not match the number of the ID parameters of the referenced feature spec " + targetSpec.id); } for(Map.Entry<String, String> mapping : refSpec.getMappedParams().entrySet()) { if (!xmlSpec.hasParam(mapping.getKey())) { throw new ProvisioningDescriptionException(Errors.nonExistingForeignKeyParam(refSpec.getName(), id, mapping.getKey())); } if (!targetSpec.xmlSpec.hasParam(mapping.getValue())) { throw new ProvisioningDescriptionException( Errors.nonExistingForeignKeyTarget(mapping.getKey(), refSpec.getName(), id, mapping.getValue(), targetSpec.id)); } } }
if(specFeatures.spec.xmlSpec.providesCapabilities()) { for(CapabilitySpec cap : specFeatures.spec.xmlSpec.getProvidedCapabilities()) { if(cap.isStatic()) { getProviders(cap.toString(), true).add(specFeatures); if(entry.getValue().spec.getSpec().hasId()) { continue;
throws ProvisioningException { if(spec.xmlSpec.hasPackageDeps()) { processPackageDeps(spec.xmlSpec, null); if(spec.xmlSpec.hasFeatureRefs()) { final ResolvedFeature myParent = parentFeature; parentFeature = resolvedFeature; for(FeatureReferenceSpec refSpec : spec.xmlSpec.getFeatureRefs()) { if(!refSpec.isInclude()) { continue;
Map<String, String> params = new HashMap<>(); for (String opt : options.keySet()) { FeatureParameterSpec p = spec.getSpec().getParams().get(opt); String value = options.get(opt); if (p.isFeatureId()) { featId = new FeatureId(spec.getSpec().getName(), ids); FeatureConfig fc = FeatureConfig.newConfig(featId);
public String getType() { return spec.getName(); }
Set<String> getAllParameters() { return spec.getParams().keySet(); }
ResolvedFeatureId resolveFeatureId(Map<String, String> params) throws ProvisioningException { if(!xmlSpec.hasId()) { return null; } final List<FeatureParameterSpec> idSpecs = xmlSpec.getIdParams(); if(idSpecs.size() == 1) { final FeatureParameterSpec idSpec = idSpecs.get(0); return new ResolvedFeatureId(id, Collections.singletonMap(idSpec.getName(), resolveIdParamValue(params, idSpec))); } final Map<String, Object> resolvedParams = new HashMap<>(idSpecs.size()); for(FeatureParameterSpec param : idSpecs) { resolvedParams.put(param.getName(), resolveIdParamValue(params, param)); } return new ResolvedFeatureId(id, resolvedParams); }
private void doOrder(ProvisioningRuntimeBuilder rt) throws ProvisioningException { for (SpecFeatures features : specFeatures.values()) { // resolve references features.spec.resolveRefMappings(rt); // resolve and register capability providers if(features.spec.xmlSpec.providesCapabilities()) { for(CapabilitySpec cap : features.spec.xmlSpec.getProvidedCapabilities()) { if(cap.isStatic()) { getProviders(cap.toString(), true).add(features); } else { for(ResolvedFeature feature : features.getFeatures()) { final List<String> resolvedCaps = capResolver.resolve(cap, feature); if(resolvedCaps.isEmpty()) { continue; } for(String resolvedCap : resolvedCaps) { getProviders(resolvedCap, true).add(feature); } } } } } } orderedFeatures = new ArrayList<>(features.size()); for(SpecFeatures features : specFeatures.values()) { orderFeaturesInSpec(features, false); } }
if(!child && (resolvedParam.spec.isFeatureId() && targetSpec.getSpec().getParam(refParamName).isFeatureId())) { child = true; for(FeatureParameterSpec targetIdParam : targetSpec.xmlSpec.getIdParams()) { final String paramName = targetIdParam.getName(); final String refParamName = paramName;
final ProvisionedFeature actual = feature[1]; final FeatureSpec fSpec = layout.getFeaturePack(actual.getSpecId().getProducer()).getFeatureSpec(actual.getSpecId().getName()).getSpec(); final FeatureConfig config = new FeatureConfig(fSpec.getName()); config.setOrigin(provisionedConfig.originOf(actual.getSpecId().getProducer())); final FeatureParameterSpec pSpec = fSpec.getParam(paramName); if(!actualParams.remove(paramName)) { if(pSpec.isNillable() && pSpec.hasDefaultValue() && !Constants.GLN_UNDEFINED.equals(pSpec.getDefaultValue())) {
private List<CircularRefInfo> orderCapabilityProviders(ResolvedFeature feature, List<CircularRefInfo> circularRefs) throws ProvisioningException { for (CapabilitySpec capSpec : feature.spec.xmlSpec.getRequiredCapabilities()) { final List<String> resolvedCaps = capResolver.resolve(capSpec, feature); if (resolvedCaps.isEmpty()) { continue; } for (String resolvedCap : resolvedCaps) { final CapabilityProviders providers; try { providers = getProviders(resolvedCap, false); } catch (ProvisioningException e) { throw new ProvisioningException(Errors.noCapabilityProvider(feature, capSpec, resolvedCap)); } final List<CircularRefInfo> circles = orderProviders(providers); if (circularRefs == null) { circularRefs = circles; } else { if (circularRefs.size() == 1) { final CircularRefInfo first = circularRefs.get(0); circularRefs = new ArrayList<>(1 + circles.size()); circularRefs.add(first); } circularRefs.addAll(circles); } } } return circularRefs; }
@Override public FeatureSpec parse(final Reader input) throws XMLStreamException, ProvisioningDescriptionException { final FeatureSpec.Builder builder = FeatureSpec.builder(); XmlParsers.parse(input, builder); return builder.build(); } }
public FeatureSpec build() throws ProvisioningDescriptionException { return new FeatureSpec(this); } }