Some items that my comboBox has got this character _
I need to replace them with a space,
Was using an ugly replace (“_”, " ");
I get a vendor here with org.jsonschema2pojo, hence I come with this character _ both vendor and product
Https://cve.circl.lu/api/browse/oracle
I have 2 combos, one of vendor and another of products, when I fill my vendor combo and its items has _ I can remove it and put space, but then my product does not match the product to create my table with the method
updateCVETable line 59
[url=https://cve.circl.lu/api/browse/oracle]
public List<String> [b]
getAllVendors
[/b]() {
client = ClientBuilder.newClient();
target = client.target("https://cve.circl.lu/api/browse");
List<String> replaceVendor = new ArrayList<String>();
List<String> vendors = target.request(MediaType.APPLICATION_JSON).get(Vendors.class).getVendor();
for(int f=0; f<vendors.size(); f++) {
if(vendors.get(f).contains("_")) {
replaceVendor.add(vendors.get(f).replaceAll("_", " "));
}else {
replaceVendor.add(vendors.get(f));
}
}
return replaceVendor;
}
public List<String> [b]
getVendorProducts
[/b](String vendor) {
client = ClientBuilder.newClient();
target = client.target("https://cve.circl.lu/api/browse/" + vendor);
List<String> replaceProducts = new ArrayList<String>();
List<String> products = target.request(MediaType.APPLICATION_JSON).get(Products.class).getProduct();
for(int f=0; f<products.size(); f++) {
if(products.get(f).contains("_")) {
replaceProducts.add(products.get(f).replaceAll("_", " "));
}else {
replaceProducts.add(products.get(f));
}
}
return replaceProducts;
}
private Component buildToolbar() {
vendorsComboBox = new ComboBox();
for(String s : cveService.getAllVendors()) {
vendorsComboBox.addItem(s);
}
vendorsComboBox.addValueChangeListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = -5188369735622627751L;
@Override
public void valueChange(ValueChangeEvent event) {
if (vendorsComboBox.getValue() != null) {
[b]
updateProductsComboBox
[/b](vendorsComboBox.getValue().toString());
} else {
cleanTable();
}
}
});
vendorsComboBox.setInputPrompt("Vendor");
vendorsComboBox.setNullSelectionAllowed(false);
productsComboBox = new ComboBox();
productsComboBox.addValueChangeListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = -5188369735622627751L;
@Override
public void valueChange(ValueChangeEvent event) {
if (productsComboBox.getValue() != null) {
List<CVEList> allCVEByProduct = cveService.getAllCVEByProduct(vendorsComboBox.getValue().toString(), productsComboBox.getValue().toString());
Notification.show("llenar tabla",Type.ERROR_MESSAGE);
updateCVETable(allCVEByProduct);
} else {
cleanTable();
}
}
});
productsComboBox.setInputPrompt("Product");
productsComboBox.setNullSelectionAllowed(false);
/*
* final Button explore = new ButtoExplorn("e"); explore.setDescription(
* "Create a new report from the selected transactions");
* explore.addClickListener(new ClickListener() {
*
* @Override public void buttonClick(final ClickEvent event) {
* createNewReportFromSelection(); } }); explore.setEnabled(false);
*/
HorizontalLayout toolbar = new HorizontalLayout(vendorsComboBox, productsComboBox, buildFilter());
toolbar.setSpacing(true);
toolbar.addStyleName("toolbar");
Responsive.makeResponsive(toolbar);
return toolbar;
}
private void [b]
updateProductsComboBox
[/b](String vendor) {
productsComboBox.removeAllItems();
List<String> products = cveService.getVendorProducts(vendor);
for (String product : products) {
productsComboBox.addItem(product);
}
}
[/url]