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)
public Slice<Target> findTargetsAll(@NotNull final TargetFilterQuery targetFilterQuery,
@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)
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(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<>();
specList.add(spec);
@@ -1057,7 +1057,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
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);
}
@@ -1070,7 +1070,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
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);
}

View File

@@ -460,16 +460,38 @@ public final class RSQLUtility {
singleList.add(cb.lessThanOrEqualTo(pathOfString(fieldPath), value));
break;
case "=in=":
singleList.add(fieldPath.in(transformedValues));
singleList.add(getInPredicate(transformedValues,fieldPath));
break;
case "=out=":
singleList.add(cb.not(fieldPath.in(transformedValues)));
singleList.add(getOutPredicate(transformedValues,fieldPath));
break;
default:
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) {
if (!enumField.isMap() || enumField.getValueFieldName() == null) {
return fieldPath;
@@ -499,6 +521,9 @@ public final class RSQLUtility {
return cb.equal(fieldPath, transformedValue);
}
private Predicate getNotEqualToPredicate(final Object transformedValue, final Path<Object> fieldPath) {
if (transformedValue instanceof String) {
final String preFormattedValue = escapeValueToSQL((String) transformedValue);

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.ui.filtermanagement;
import java.awt.event.FocusListener;
import java.util.concurrent.Executor;
import javax.annotation.PostConstruct;
@@ -156,8 +155,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
setUpCaptionLayout(true);
resetComponents();
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
this.getUI().access(() -> updateStatusIconAfterTablePopulated());
} else if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
UI.getCurrent().access(() -> updateStatusIconAfterTablePopulated());
}
}
@@ -331,15 +330,20 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
validationIcon.addStyleName("show-status-label");
showValidationInProgress();
onQueryChange(event.getText());
executor.execute(new StatusCircledAsync());
executor.execute(new StatusCircledAsync(UI.getCurrent()));
}
});
}
class StatusCircledAsync implements Runnable {
@Override
private UI current;
public StatusCircledAsync(UI current) {
this.current = current;
}
@Override
public void run() {
UI.setCurrent(current);
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) {
UI.getCurrent().access(() -> populateTableData());
} 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);
} else {
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() {
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;
/**
*
* Simple implementation of generics bean query which dynamically loads {@link ProxyTarget} batch
* of beans.
*
*/
public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
@@ -43,7 +44,6 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
private FilterManagementUIState filterManagementUIState;
private transient I18N i18N;
private String filterQuery;
private Boolean isInvalidFilterQuery;
/**
* Parametric Constructor.
@@ -63,7 +63,6 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
filterQuery = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_QUERY);
isInvalidFilterQuery = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_INVALID_QUERY);
}
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor
@@ -164,16 +163,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
*/
@Override
public int size() {
final long totSize = getTargetManagement().countTargetsAll();
long size;
long size=0;
if (!Strings.isNullOrEmpty(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) {
getFilterManagementUIState().setTargetsTruncated(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 {
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
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
|| 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());
}
}
@@ -90,8 +90,7 @@ public class TargetFilterCountMessageLabel extends Label {
long totalTargets = 0;
if (filterManagementUIState.isCreateFilterViewDisplayed() || filterManagementUIState.isEditViewDisplayed()) {
if (null != filterManagementUIState.getFilterQueryValue()) {
totalTargets = targetManagement
.countTargetByTargetFilterQuery(filterManagementUIState.getFilterQueryValue());
totalTargets = filterManagementUIState.getTargetsCountAll().get();
}
final StringBuilder targetMessage = new StringBuilder(i18n.get("label.target.filtered.total"));
if (filterManagementUIState.getTargetsTruncated() != null) {

View File

@@ -344,22 +344,21 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private boolean duplicateCheck(final String name, final String 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;
} else {
if (existingDs == null) {
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;
}
/**