Correct the sql query for filtering distribution sets by tags (#511)

* Also checks if collection is empty, while building predicate

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* ID of distribution tag buttons should not contain whitespaces

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
Melanie Retter
2017-05-15 18:59:46 +02:00
committed by Kai Zimmermann
parent 1661f66006
commit a59110d147
2 changed files with 4 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaTarget_;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.CollectionUtils;
/**
* Specifications class for {@link DistributionSet}s. The class provides Spring
@@ -145,7 +146,7 @@ public final class DistributionSetSpecification {
tags.get(JpaDistributionSetTag_.name);
final Path<String> exp = tags.get(JpaDistributionSetTag_.name);
if (selectDSWithNoTag != null && selectDSWithNoTag) {
if (tagNames != null) {
if (!CollectionUtils.isEmpty(tagNames)) {
return cb.or(exp.isNull(), exp.in(tagNames));
} else {
return exp.isNull();

View File

@@ -27,6 +27,7 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.util.StringUtils;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -94,7 +95,7 @@ public class DistributionTagButtons extends AbstractFilterButtons implements Ref
@Override
protected String createButtonId(final String name) {
return name;
return StringUtils.trimAllWhitespace(name);
}
@Override