public FeatureReferenceSpec build() throws ProvisioningDescriptionException { return new FeatureReferenceSpec(origin, name, featureSpec, nillable, include, mappedParams); } }
public static FeatureReferenceSpec create(String str, boolean nillable) throws ProvisioningDescriptionException { return create(str, str, nillable); }
private void assertRefNotNillable(final ResolvedFeature feature, final FeatureReferenceSpec refSpec) throws ProvisioningDescriptionException { if (!refSpec.isNillable()) { throw new ProvisioningDescriptionException(Errors.nonNillableRefIsNull(feature, refSpec.getName())); } }
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()); 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());
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)); } } }
parentFeature = resolvedFeature; for(FeatureReferenceSpec refSpec : spec.xmlSpec.getFeatureRefs()) { if(!refSpec.isInclude()) { continue; final FeaturePackRuntimeBuilder originalFp = setOrigin(refSpec.getOrigin()); try { final ResolvedFeatureSpec refResolvedSpec = getFeatureSpec(refSpec.getFeature().getName()); final List<ResolvedFeatureId> refIds = spec.resolveRefId(parentFeature, refSpec, refResolvedSpec); if (!refIds.isEmpty()) {
private ResolvedFeatureSpec resolveRefMapping(ProvisioningRuntimeBuilder rt, FeaturePackRuntimeBuilder origin, FeatureReferenceSpec refSpec) throws ProvisioningException { try { if(refSpec.getOrigin() != null) { origin = rt.layout.getFeaturePack(origin.getSpec().getFeaturePackDep(refSpec.getOrigin()).getLocation().getProducer()); } final ResolvedFeatureSpec resolvedRefSpec = rt.getFeatureSpec(origin, refSpec.getFeature().getName()); assertRefParamMapping(refSpec, resolvedRefSpec); return resolvedRefSpec; } catch (ProvisioningDescriptionException e) { throw new ProvisioningDescriptionException(Errors.failedToResolveFeatureReference(refSpec, id), e); } }
if (refSpec.hasMappedParams()) { for (Map.Entry<String, String> mapping : refSpec.getMappedParams().entrySet()) { if (xmlSpec.getParam(mapping.getKey()).isFeatureId()) { continue;
} else { for (FeatureReferenceSpec c : f.getSpec().getFeatureRefs()) { session.println(tab + c.getFeature());
static String failedToResolveFeatureReference(FeatureReferenceSpec refSpec, ResolvedSpecId spec) { return "Failed to resolve feature reference " + refSpec.getName() + " for " + spec; }
name = feature; final FeatureReferenceSpec.Builder refBuilder = FeatureReferenceSpec.builder(feature).setOrigin(dependency).setName(name).setNillable(nillable).setInclude(include);
Map<String, Object> params = Collections.emptyMap(); boolean child = feature.hasId() ? false : true; // no id is considered a child to make the list-add not break the branch if(refSpec.hasMappedParams()) { for (Map.Entry<String, String> mapping : refSpec.getMappedParams().entrySet()) { final String paramName = mapping.getKey(); final String refParamName = mapping.getValue();
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); }
if (refSpec.hasMappedParams()) { for (Map.Entry<String, String> mapping : refSpec.getMappedParams().entrySet()) { final FeatureParameterSpec param = xmlSpec.getParam(mapping.getKey()); if(!param.isFeatureId()) {
public static FeatureReferenceSpec create(String str) throws ProvisioningDescriptionException { return create(str, str, false); }
public static FeatureReferenceSpec create(String name, String feature, boolean nillable) throws ProvisioningDescriptionException { return new FeatureReferenceSpec(null, name, feature, nillable, false, Collections.emptyMap()); }