.filter(uiField -> uiField.getType().equals(ComponentUISpecification.UIFieldType.FILE)) .map(uiField -> uiField.getFieldName()) .collect(toList());
private static ComponentUISpecification getCustomProcessorUISpecification (ComponentUISpecification componentUISpecification) { ComponentUISpecification result = new ComponentUISpecification(); List<ComponentUISpecification.UIField> fields = new ArrayList<>(); for (ComponentUISpecification.UIField uiField: componentUISpecification.getFields()) { if (uiField.getFieldName().startsWith(TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_PREFIX)) { ComponentUISpecification.UIField newUIField = new ComponentUISpecification.UIField(uiField); newUIField.setFieldName(uiField.getFieldName().replaceFirst(TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_PREFIX_REGEX, "")); fields.add(newUIField); } } result.setFields(fields); return (result.getFields().isEmpty() ? null : 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; }
private ComponentUISpecification.UIField createUIField (String fieldName, String uiName, boolean isOptional, boolean isUserInput, String tooltip, ComponentUISpecification.UIFieldType type, Object defaultValue) { ComponentUISpecification.UIField uiField = new ComponentUISpecification.UIField(); uiField.setFieldName(fieldName); uiField.setUiName(uiName); uiField.setIsOptional(isOptional); uiField.setIsUserInput(isUserInput); uiField.setTooltip(tooltip); uiField.setType(type); uiField.setDefaultValue(defaultValue); return uiField; } }
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 List<ComponentUISpecification.UIField> getCustomProcessorUIFieldsWithPrefix () { List<ComponentUISpecification.UIField> result = new ArrayList<>(); if (topologyComponentUISpecification != null) { for (ComponentUISpecification.UIField uiField : this.topologyComponentUISpecification.getFields()) { ComponentUISpecification.UIField newUIField = new ComponentUISpecification.UIField(uiField); newUIField.setFieldName(TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_PREFIX + uiField.getFieldName()); result.add(newUIField); } } return result; }