private static Map<String, String> getPropertiesFromUIFields (List<ComponentUISpecification.UIField> uiFields) { Map<String, String> result = new HashMap<>(); for (ComponentUISpecification.UIField uiField: uiFields) { if (PROPERTY_KEYS.contains(uiField.getFieldName())) { result.put(uiField.getFieldName(), (String) uiField.getDefaultValue()); } } return result; }
private Collection<TopologyComponentBundle> listCustomProcessorBundlesWithFilter(List<QueryParam> params) throws IOException { List<QueryParam> queryParamsForTopologyComponent = new ArrayList<>(); queryParamsForTopologyComponent.add(new QueryParam(TopologyComponentBundle.SUB_TYPE, TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_SUB_TYPE)); for (QueryParam qp : params) { if (qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE)) { queryParamsForTopologyComponent.add(qp); } } Collection<TopologyComponentBundle> customProcessors = this.listTopologyComponentBundlesForTypeWithFilter(TopologyComponentBundle.TopologyComponentType .PROCESSOR, queryParamsForTopologyComponent); Collection<TopologyComponentBundle> result = new ArrayList<>(); for (TopologyComponentBundle cp : customProcessors) { Map<String, Object> config = new HashMap<>(); for (ComponentUISpecification.UIField uiField: cp.getTopologyComponentUISpecification().getFields()) { config.put(uiField.getFieldName(), uiField.getDefaultValue()); } boolean matches = true; for (QueryParam qp : params) { if (!qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE) && !qp.getValue().equals(config.get(qp.getName()))) { matches = false; break; } } if (matches) { result.add(cp); } } return result; }