List<IParameter> params = ((SearchMethodBinding) nextMethodBinding).getParameters();
// TODO: this would probably work best if we sorted these by
// required first, then optional
RestResourceSearchParam searchParam = null;
ExtensionDt searchParamChain = null;
for (IParameter nextParameterObj : params) {
if (!(nextParameterObj instanceof SearchParameter)) {
continue;
}
SearchParameter nextParameter = (SearchParameter) nextParameterObj;
if (searchParam == null) {
if (!nameToSearchParam.containsKey(nextParameter.getName())) {
RestResourceSearchParam param = resource.addSearchParam();
param.setName(nextParameter.getName());
param.setDocumentation(nextParameter.getDescription());
param.setType(nextParameter.getParamType());
searchParam = param;
} else {
searchParam = nameToSearchParam.get(nextParameter.getName());
}
if (searchParam != null) {
searchParam.setType(nextParameter.getParamType());
}
} else {
searchParamChain = searchParam.addUndeclaredExtension(false, ExtensionConstants.CONF_ADDITIONAL_PARAM);
// if (searchParamChain == null) {
// } else {
// searchParamChain = searchParamChain.addUndeclaredExtension(false, ExtensionConstants.CONF_ADDITIONAL_PARAM);
// }
ExtensionDt ext = new ExtensionDt();
ext.setUrl(ExtensionConstants.CONF_ADDITIONAL_PARAM_NAME);
ext.setValue(new StringDt(nextParameter.getName()));
searchParamChain.getUndeclaredExtensions().add(ext);
ext = new ExtensionDt();
ext.setUrl(ExtensionConstants.CONF_ADDITIONAL_PARAM_DESCRIPTION);
ext.setValue(new StringDt(nextParameter.getDescription()));
searchParamChain.getUndeclaredExtensions().add(ext);
ext = new ExtensionDt();
ext.setUrl(ExtensionConstants.CONF_ADDITIONAL_PARAM_TYPE);
if (nextParameter.getParamType() != null) {
ext.setValue(new CodeDt(nextParameter.getParamType().getCode()));
}
searchParamChain.getUndeclaredExtensions().add(ext);
ext = new ExtensionDt();
ext.setUrl(ExtensionConstants.CONF_ADDITIONAL_PARAM_REQUIRED);
ext.setValue(new BooleanDt(nextParameter.isRequired()));
searchParamChain.getUndeclaredExtensions().add(ext);
}
}