format sources with correct formatter.

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
Michael Hirsch
2016-02-15 12:32:12 +01:00
parent bd4d6770e2
commit 7b79010fbf
5 changed files with 93 additions and 100 deletions

View File

@@ -461,46 +461,46 @@ 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(getInPredicate(transformedValues,fieldPath)); singleList.add(getInPredicate(transformedValues, fieldPath));
break; break;
case "=out=": case "=out=":
singleList.add(getOutPredicate(transformedValues,fieldPath)); 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());
}
}
if (!inParams.isEmpty()) {
return cb.upper(pathOfString(fieldPath)).in(inParams);
} else {
return fieldPath.in(transformedValues);
} private Predicate getInPredicate(final List<Object> transformedValues, final Path<Object> fieldPath) {
} final List<String> inParams = new ArrayList<>();
for (final Object param : transformedValues) {
if (param instanceof String) {
inParams.add(((String) param).toUpperCase());
}
}
if (!inParams.isEmpty()) {
return cb.upper(pathOfString(fieldPath)).in(inParams);
} else {
return fieldPath.in(transformedValues);
private Predicate getOutPredicate(final List<Object> transformedValues, final Path<Object> fieldPath) { }
List<String> outParams = new ArrayList<>(); }
for (Object param : transformedValues) {
if (param instanceof String) { private Predicate getOutPredicate(final List<Object> transformedValues, final Path<Object> fieldPath) {
outParams.add(((String) param).toUpperCase()); final List<String> outParams = new ArrayList<>();
} for (final Object param : transformedValues) {
} if (param instanceof String) {
if (!outParams.isEmpty()) { outParams.add(((String) param).toUpperCase());
return cb.not(cb.upper(pathOfString(fieldPath)).in(outParams)); }
} else { }
return cb.not(fieldPath.in(transformedValues)); if (!outParams.isEmpty()) {
return cb.not(cb.upper(pathOfString(fieldPath)).in(outParams));
} else {
return cb.not(fieldPath.in(transformedValues));
}
}
}
}
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;
@@ -509,7 +509,7 @@ public final class RSQLUtility {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Predicate mapToMapPredicate(final ComparisonNode node, final Path<Object> fieldPath, private Predicate mapToMapPredicate(final ComparisonNode node, final Path<Object> fieldPath,
final A enumField) { final A enumField) {
if (!enumField.isMap()) { if (!enumField.isMap()) {
return null; return null;
@@ -517,10 +517,11 @@ public final class RSQLUtility {
final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR); final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
final String keyValue = graph[graph.length - 1]; final String keyValue = graph[graph.length - 1];
if (fieldPath instanceof MapJoin) { if (fieldPath instanceof MapJoin) {
//Currently we support only string key .So below cast is safe. // Currently we support only string key .So below cast is safe.
return cb.equal(cb.upper((Expression<String>) (((MapJoin<?, ?, ?>) fieldPath).key())), keyValue.toUpperCase()); return cb.equal(cb.upper((Expression<String>) (((MapJoin<?, ?, ?>) fieldPath).key())),
keyValue.toUpperCase());
} }
return cb.equal(cb.upper(fieldPath.get(enumField.getKeyFieldName())), keyValue.toUpperCase()); return cb.equal(cb.upper(fieldPath.get(enumField.getKeyFieldName())), keyValue.toUpperCase());
} }
@@ -532,9 +533,6 @@ 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

@@ -8,7 +8,6 @@
*/ */
package org.eclipse.hawkbit.ui.filtermanagement; package org.eclipse.hawkbit.ui.filtermanagement;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@@ -122,7 +121,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private LayoutClickListener nameLayoutClickListner; private LayoutClickListener nameLayoutClickListner;
private boolean validationFailed = false; private boolean validationFailed = false;
/** /**
* Initialize the Campaign Status History Header. * Initialize the Campaign Status History Header.
*/ */
@@ -148,20 +147,18 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final CustomFilterUIEvent custFUIEvent) { void onEvent(final CustomFilterUIEvent custFUIEvent) {
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) { if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
populateComponents(); populateComponents();
eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW); eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW);
} 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.UPDATE_TARGET_FILTER_SEARCH_ICON) { } else if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
UI.getCurrent().access(() -> updateStatusIconAfterTablePopulated()); UI.getCurrent().access(() -> updateStatusIconAfterTablePopulated());
} }
} }
private void populateComponents() { private void populateComponents() {
if (filterManagementUIState.getTfQuery().isPresent()) { if (filterManagementUIState.getTfQuery().isPresent()) {
queryTextField.setValue(filterManagementUIState.getTfQuery().get().getQuery()); queryTextField.setValue(filterManagementUIState.getTfQuery().get().getQuery());
@@ -219,8 +216,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
closeIcon = createSearchResetIcon(); closeIcon = createSearchResetIcon();
} }
private TextField createNameTextField() { private TextField createNameTextField() {
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
@@ -337,13 +333,15 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
class StatusCircledAsync implements Runnable { class StatusCircledAsync implements Runnable {
private UI current; private final UI current;
public StatusCircledAsync(UI current) {
this.current = current; public StatusCircledAsync(final UI current) {
} this.current = current;
@Override }
@Override
public void run() { public void run() {
UI.setCurrent(current); UI.setCurrent(current);
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY); eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
} }
} }
@@ -364,7 +362,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
enableDisableSaveButton(validationFailed, input); enableDisableSaveButton(validationFailed, input);
} else { } else {
setInitialStatusIconStyle(validationIcon); setInitialStatusIconStyle(validationIcon);
filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setFilterQueryValue(null);
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE); filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
} }
@@ -372,9 +370,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
private void enableDisableSaveButton(final boolean validationFailed, final String query) { private void enableDisableSaveButton(final boolean validationFailed, final String query) {
if (validationFailed if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query)
|| (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField || (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) {
.getValue().equals(oldFilterName)))) {
saveButton.setEnabled(false); saveButton.setEnabled(false);
} else { } else {
if (hasSavePermission()) { if (hasSavePermission()) {
@@ -390,10 +387,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
return false; return false;
} }
private void showValidationSuccesIcon() { private void showValidationSuccesIcon() {
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON); validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
} }
private void showValidationFailureIcon() { private void showValidationFailureIcon() {
@@ -474,8 +470,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
targetFilterQuery.setName(nameTextField.getValue()); targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue()); targetFilterQuery.setQuery(queryTextField.getValue());
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery); targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
notification.displaySuccess(i18n.get("message.create.filter.success", notification.displaySuccess(
new Object[] { targetFilterQuery.getName() })); i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() }));
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY); eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
} }
@@ -516,12 +512,12 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
return true; return true;
} }
private void updateStatusIconAfterTablePopulated() { private void updateStatusIconAfterTablePopulated() {
queryTextField.focus(); queryTextField.focus();
if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) { if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) {
showValidationSuccesIcon(); showValidationSuccesIcon();
} }
} }
} }

View File

@@ -100,18 +100,16 @@ 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) {
UI.getCurrent().access(() -> onQuery()); UI.getCurrent().access(() -> onQuery());
} }
} }
private void restoreOnLoad() {
private void restoreOnLoad() {
if (filterManagementUIState.isCreateFilterViewDisplayed()) { if (filterManagementUIState.isCreateFilterViewDisplayed()) {
filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setFilterQueryValue(null);
} else { } else {
filterManagementUIState.getTfQuery().ifPresent( filterManagementUIState.getTfQuery()
value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); .ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
} }
} }
@@ -127,8 +125,9 @@ public class CreateOrUpdateFilterTable extends Table {
targetQF.setQueryConfiguration(queryConfig); targetQF.setQueryConfiguration(queryConfig);
// create lazy query container with lazy defination and query // create lazy query container with lazy defination and query
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true, final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF); new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME),
targetQF);
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
return targetTableContainer; return targetTableContainer;
@@ -181,16 +180,16 @@ public class CreateOrUpdateFilterTable extends Table {
private List<TableColumn> getVisbleColumns() { private List<TableColumn> getVisbleColumns() {
final List<TableColumn> columnList = new ArrayList<>(); final List<TableColumn> columnList = new ArrayList<>();
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"),0.15f)); columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), columnList.add(
0.1F)); new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
.get("header.assigned.ds"), 0.125F)); i18n.get("header.assigned.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
.get("header.installed.ds"), 0.125F)); i18n.get("header.installed.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
return columnList; return columnList;
@@ -198,8 +197,8 @@ public class CreateOrUpdateFilterTable extends Table {
private Component getStatusIcon(final Object itemId) { private Component getStatusIcon(final Object itemId) {
final Item row1 = getItem(itemId); final Item row1 = getItem(itemId);
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1.getItemProperty( final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
label.setContentMode(ContentMode.HTML); label.setContentMode(ContentMode.HTML);
if (targetStatus == TargetUpdateStatus.PENDING) { if (targetStatus == TargetUpdateStatus.PENDING) {
@@ -240,9 +239,9 @@ public class CreateOrUpdateFilterTable extends Table {
protected void addCustomGeneratedColumns() { protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId)); addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId));
} }
private void onQuery() { private void onQuery() {
populateTableData(); populateTableData();
eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON);
} }
} }

View File

@@ -32,8 +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 * Simple implementation of generics bean query which dynamically loads
* of beans. * {@link ProxyTarget} batch of beans.
* *
*/ */
public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> { public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
@@ -163,7 +163,7 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
*/ */
@Override @Override
public int size() { public int size() {
long size=0; long size = 0;
if (!Strings.isNullOrEmpty(filterQuery)) { if (!Strings.isNullOrEmpty(filterQuery)) {
size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery); size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery);
} }

View File

@@ -71,7 +71,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.UPDATE_TARGET_FILTER_SEARCH_ICON) { || custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
UI.getCurrent().access(() -> displayTargetFilterMessage()); UI.getCurrent().access(() -> displayTargetFilterMessage());
} }
} }