Bug fixes:

Custom filter detail view : Using =IN= parameter throws 'Unsupported
operator' exception and breaks the UI
Custom filter search : type any query.Search never gets finished.
Alloe case insensitive search for IN paramters

Signed-off-by: asharani-murugesh <asharani.murugesh@in.bosch.com>
This commit is contained in:
asharani-murugesh
2016-02-11 13:32:07 +01:00
8 changed files with 63 additions and 42 deletions

View File

@@ -205,7 +205,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Slice<Target> findTargetsAll(@NotNull final TargetFilterQuery targetFilterQuery, public Slice<Target> findTargetsAll(@NotNull final TargetFilterQuery targetFilterQuery,
@NotNull final Pageable pageable) { @NotNull final Pageable pageable) {
return findTargetsAll(RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class), pageable); return findTargetsAll(RSQLUtility.parse(targetFilterQuery.getQuery().toLowerCase(), TargetFields.class), pageable);
} }
/** /**
@@ -219,7 +219,7 @@ public class TargetManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Slice<Target> findTargetsAll(@NotNull final String targetFilterQuery, @NotNull final Pageable pageable) { public Slice<Target> findTargetsAll(@NotNull final String targetFilterQuery, @NotNull final Pageable pageable) {
return findTargetsAll(RSQLUtility.parse(targetFilterQuery, TargetFields.class), pageable); return findTargetsAll(RSQLUtility.parse(targetFilterQuery.toLowerCase(), TargetFields.class), pageable);
} }
/** /**
@@ -883,7 +883,7 @@ public class TargetManagement {
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
targetRoot.get(pageRequest.getSort().iterator().next().getProperty())); targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class); final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery().toLowerCase(), TargetFields.class);
final List<Specification<Target>> specList = new ArrayList<>(); final List<Specification<Target>> specList = new ArrayList<>();
specList.add(spec); specList.add(spec);
@@ -1057,7 +1057,7 @@ public class TargetManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Long countTargetByTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) { public Long countTargetByTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) {
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class); final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery.getQuery().toLowerCase(), TargetFields.class);
return targetRepository.count(specs); return targetRepository.count(specs);
} }
@@ -1070,7 +1070,7 @@ public class TargetManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Long countTargetByTargetFilterQuery(@NotNull final String targetFilterQuery) { public Long countTargetByTargetFilterQuery(@NotNull final String targetFilterQuery) {
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class); final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery.toLowerCase(), TargetFields.class);
return targetRepository.count(specs); return targetRepository.count(specs);
} }

View File

@@ -460,16 +460,38 @@ public final class RSQLUtility {
singleList.add(cb.lessThanOrEqualTo(pathOfString(fieldPath), value)); singleList.add(cb.lessThanOrEqualTo(pathOfString(fieldPath), value));
break; break;
case "=in=": case "=in=":
singleList.add(fieldPath.in(transformedValues)); singleList.add(getInPredicate(transformedValues,fieldPath));
break; break;
case "=out=": case "=out=":
singleList.add(cb.not(fieldPath.in(transformedValues))); singleList.add(getOutPredicate(transformedValues,fieldPath));
break; break;
default: default:
LOGGER.info("operator symbol {} is either not supported or not implemented"); LOGGER.info("operator symbol {} is either not supported or not implemented");
} }
} }
private Predicate getInPredicate(final List<Object> transformedValues, final Path<Object> fieldPath) {
List<String> inParams =new ArrayList<>();
for(Object param :transformedValues){
if(param instanceof String){
inParams.add(((String) param).toUpperCase());
}
}
return cb.upper(pathOfString(fieldPath)).in(inParams);
}
private Predicate getOutPredicate(final List<Object> transformedValues, final Path<Object> fieldPath) {
List<String> outParams =new ArrayList<>();
for(Object param :transformedValues){
if(param instanceof String){
outParams.add(((String) param).toUpperCase());
}
}
return cb.not(cb.upper(pathOfString(fieldPath)).in(outParams));
}
private Path<Object> getMapValueFieldPath(final A enumField, final Path<Object> fieldPath) { private Path<Object> getMapValueFieldPath(final A enumField, final Path<Object> fieldPath) {
if (!enumField.isMap() || enumField.getValueFieldName() == null) { if (!enumField.isMap() || enumField.getValueFieldName() == null) {
return fieldPath; return fieldPath;
@@ -499,6 +521,9 @@ public final class RSQLUtility {
return cb.equal(fieldPath, transformedValue); return cb.equal(fieldPath, transformedValue);
} }
private Predicate getNotEqualToPredicate(final Object transformedValue, final Path<Object> fieldPath) { private Predicate getNotEqualToPredicate(final Object transformedValue, final Path<Object> fieldPath) {
if (transformedValue instanceof String) { if (transformedValue instanceof String) {
final String preFormattedValue = escapeValueToSQL((String) transformedValue); final String preFormattedValue = escapeValueToSQL((String) transformedValue);

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.ui.filtermanagement; package org.eclipse.hawkbit.ui.filtermanagement;
import java.awt.event.FocusListener;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@@ -156,8 +155,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { } else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
setUpCaptionLayout(true); setUpCaptionLayout(true);
resetComponents(); resetComponents();
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) { } else if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
this.getUI().access(() -> updateStatusIconAfterTablePopulated()); UI.getCurrent().access(() -> updateStatusIconAfterTablePopulated());
} }
} }
@@ -331,15 +330,20 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
validationIcon.addStyleName("show-status-label"); validationIcon.addStyleName("show-status-label");
showValidationInProgress(); showValidationInProgress();
onQueryChange(event.getText()); onQueryChange(event.getText());
executor.execute(new StatusCircledAsync()); executor.execute(new StatusCircledAsync(UI.getCurrent()));
} }
}); });
} }
class StatusCircledAsync implements Runnable { class StatusCircledAsync implements Runnable {
@Override private UI current;
public StatusCircledAsync(UI current) {
this.current = current;
}
@Override
public void run() { public void run() {
UI.setCurrent(current);
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY); eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
} }
} }

View File

@@ -101,7 +101,7 @@ public class CreateOrUpdateFilterTable extends Table {
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
UI.getCurrent().access(() -> populateTableData()); UI.getCurrent().access(() -> populateTableData());
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
this.getUI().access(() -> onQuery()); UI.getCurrent().access(() -> onQuery());
} }
} }
@@ -112,7 +112,7 @@ public class CreateOrUpdateFilterTable extends Table {
filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setFilterQueryValue(null);
} else { } else {
filterManagementUIState.getTfQuery().ifPresent( filterManagementUIState.getTfQuery().ifPresent(
value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); value -> filterManagementUIState.setFilterQueryValue(value.getQuery().toLowerCase()));
} }
} }
@@ -244,6 +244,6 @@ public class CreateOrUpdateFilterTable extends Table {
private void onQuery() { private void onQuery() {
populateTableData(); populateTableData();
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE); eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON);
} }
} }

View File

@@ -32,7 +32,8 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
import com.google.common.base.Strings; import com.google.common.base.Strings;
/** /**
* * Simple implementation of generics bean query which dynamically loads {@link ProxyTarget} batch
* of beans.
* *
*/ */
public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> { public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
@@ -43,7 +44,6 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
private FilterManagementUIState filterManagementUIState; private FilterManagementUIState filterManagementUIState;
private transient I18N i18N; private transient I18N i18N;
private String filterQuery; private String filterQuery;
private Boolean isInvalidFilterQuery;
/** /**
* Parametric Constructor. * Parametric Constructor.
@@ -63,7 +63,6 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) { if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
filterQuery = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_QUERY); filterQuery = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_QUERY);
isInvalidFilterQuery = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_INVALID_QUERY);
} }
if (HawkbitCommonUtil.checkBolArray(sortStates)) { if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor // Initalize Sor
@@ -164,16 +163,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
*/ */
@Override @Override
public int size() { public int size() {
final long totSize = getTargetManagement().countTargetsAll(); long size=0;
long size;
if (!Strings.isNullOrEmpty(filterQuery)) { if (!Strings.isNullOrEmpty(filterQuery)) {
size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery); size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery);
} else if (getFilterManagementUIState().isCreateFilterViewDisplayed() || isInvalidFilterQuery) {
size = 0;
} else {
size = totSize;
} }
getFilterManagementUIState().setTargetsCountAll(totSize); getFilterManagementUIState().setTargetsCountAll(size);
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
getFilterManagementUIState().setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES); getFilterManagementUIState().setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES; size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;

View File

@@ -15,5 +15,5 @@ package org.eclipse.hawkbit.ui.filtermanagement.event;
* *
*/ */
public enum CustomFilterUIEvent { public enum CustomFilterUIEvent {
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, TARGET_FILTER_STATUS_HIDE FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, UPDATE_TARGET_FILTER_SEARCH_ICON
} }

View File

@@ -75,7 +75,7 @@ public class TargetFilterCountMessageLabel extends Label {
if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
|| custFUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW || custFUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW
|| custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { ||custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
UI.getCurrent().access(() -> displayTargetFilterMessage()); UI.getCurrent().access(() -> displayTargetFilterMessage());
} }
} }
@@ -90,8 +90,7 @@ public class TargetFilterCountMessageLabel extends Label {
long totalTargets = 0; long totalTargets = 0;
if (filterManagementUIState.isCreateFilterViewDisplayed() || filterManagementUIState.isEditViewDisplayed()) { if (filterManagementUIState.isCreateFilterViewDisplayed() || filterManagementUIState.isEditViewDisplayed()) {
if (null != filterManagementUIState.getFilterQueryValue()) { if (null != filterManagementUIState.getFilterQueryValue()) {
totalTargets = targetManagement totalTargets = filterManagementUIState.getTargetsCountAll().get();
.countTargetByTargetFilterQuery(filterManagementUIState.getFilterQueryValue());
} }
final StringBuilder targetMessage = new StringBuilder(i18n.get("label.target.filtered.total")); final StringBuilder targetMessage = new StringBuilder(i18n.get("label.target.filtered.total"));
if (filterManagementUIState.getTargetsTruncated() != null) { if (filterManagementUIState.getTargetsTruncated() != null) {

View File

@@ -344,22 +344,21 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private boolean duplicateCheck(final String name, final String version) { private boolean duplicateCheck(final String name, final String version) {
final DistributionSet existingDs = distributionSetManagement.findDistributionSetByNameAndVersion(name, version); final DistributionSet existingDs = distributionSetManagement.findDistributionSetByNameAndVersion(name, version);
/*
* Distribution should not exists with the same name & version. Display
* error message, when the "existingDs" is not null and it is add window
* (or) when the "existingDs" is not null and it is edit window and the
* distribution Id of the edit window is different then the "existingDs"
*/
if (existingDs != null && !existingDs.getId().equals(editDistId)) {
distNameTextField.addStyleName("v-textfield-error");
distVersionTextField.addStyleName("v-textfield-error");
notificationMessage.displayValidationError(
i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() }));
return false; if (existingDs == null) {
} else {
return true; return true;
} }
if (editDistribution && !existingDs.getId().equals(editDistId)) {
return true;
}
distNameTextField.addStyleName("v-textfield-error");
distVersionTextField.addStyleName("v-textfield-error");
notificationMessage.displayValidationError(
i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() }));
return false;
} }
/** /**