private Object resolveIdParamValue(Map<String, String> params, final FeatureParameterSpec param) throws ProvisioningException { final ResolvedFeatureParam resolvedParam = getResolvedParam(param.getName()); final String strValue = params.get(param.getName()); if(strValue == null) { final Object value = resolvedParam.defaultValue; if (value == null) { throw new ProvisioningDescriptionException(Errors.nonNillableParameterIsNull(id, param.getName())); } return value; } return resolvedParam.type.fromString(strValue); }
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); }
String configValue = params.get(idParamSpec.getName()); if(configValue != null) { final Object childValue = paramFromString(idParamSpec.getName(), configValue); final Object idValue = resolvedParams.put(idParamSpec.getName(), childValue); if(idValue != null && !idValue.equals(childValue)) { throw new ProvisioningDescriptionException(Errors.idParamForeignKeyInitConflict(id, idParamSpec.getName(), childValue, idValue)); if(resolvedParams.containsKey(idParamSpec.getName())) { continue; final Object childValue = getResolvedParam(idParamSpec.getName()).defaultValue; if(childValue == null) { throw new ProvisioningDescriptionException(Errors.nonNillableParameterIsNull(id, idParamSpec.getName())); resolvedParams.put(idParamSpec.getName(), childValue); final Object parentValue = parentId.params.get(idParamSpec.getName()); String configValue = params.get(idParamSpec.getName()); if(configValue != null) { final Object childValue = paramFromString(idParamSpec.getName(), configValue); if(parentValue != null && !parentValue.equals(childValue)) { throw new ProvisioningDescriptionException(Errors.idParamForeignKeyInitConflict(id, idParamSpec.getName(), childValue, parentValue)); resolvedParams.put(idParamSpec.getName(), childValue); continue; resolvedParams.put(idParamSpec.getName(), parentValue); continue;
private ResolvedFeatureParam resolveParamSpec(FeatureParameterSpec paramSpec, ParameterTypeProvider typeProvider) throws ProvisioningException { final FeatureParameterType type; try { type = typeProvider.getType(id.producer, paramSpec.getType()); } catch(ParameterTypeNotFoundException e) { throw new ProvisioningException(Errors.failedToResolveParameter(id, paramSpec.getName()), e); } return new ResolvedFeatureParam(paramSpec, type); }
final String paramName = targetIdParam.getName(); final String refParamName = paramName;
for(Map.Entry<String, FeatureParameterSpec> entry : xmlSpec.getParams().entrySet()) { final FeatureParameterSpec param = entry.getValue(); resolvedParamSpecs = CollectionUtils.put(resolvedParamSpecs, param.getName(), resolveParamSpec(param, typeProvider));
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)); } } }
public static Builder builder(FeatureParameterSpec param) { Builder builder = new Builder(param.getName()); builder.setDefaultValue(param.getDefaultValue()); if (param.isFeatureId()) { builder.setFeatureId(); } if(param.isNillable()) { builder.setNillable(); } builder.setType(param.getType()); return builder; }
for (FeatureParameterSpec param : idparams) { StringBuilder builder = new StringBuilder(); builder.append(tab + param.getName()).append(Config.getLineSeparator()); builder.append(tab + tab + "description : " + "no description available").append(Config.getLineSeparator()); builder.append(tab + tab + "type : " + param.getType()).append(Config.getLineSeparator()); if (!param.isFeatureId()) { StringBuilder builder = new StringBuilder(); builder.append(tab + param.getName()).append(Config.getLineSeparator()); builder.append(tab + tab + "description : " + "no description available").append(Config.getLineSeparator()); builder.append(tab + tab + "type : " + param.getType()).append(Config.getLineSeparator());
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);