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