Fix mayors squid:S1604 and squid:S1151 (#344)

* Fixed Last Mayor issues

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Disable lambda for Java GWT client code

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Remove lambda

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-11-10 15:00:57 +01:00
committed by Michael Hirsch
parent 23eb0c3c73
commit c1e5689f6a
7 changed files with 81 additions and 89 deletions

View File

@@ -22,7 +22,7 @@ import feign.Logger;
/** /**
* The simulated device factory to create either {@link DMFSimulatedDevice} or * The simulated device factory to create either {@link DMFSimulatedDevice} or
* {@link DDISimulatedDevice#}. * {@link DDISimulatedDevice}.
*/ */
@Service @Service
public class SimulatedDeviceFactory { public class SimulatedDeviceFactory {
@@ -61,20 +61,30 @@ public class SimulatedDeviceFactory {
final int pollDelaySec, final URL baseEndpoint, final String gatewayToken, final boolean pollImmediatly) { final int pollDelaySec, final URL baseEndpoint, final String gatewayToken, final boolean pollImmediatly) {
switch (protocol) { switch (protocol) {
case DMF_AMQP: case DMF_AMQP:
return createDmfDevice(id, tenant, pollDelaySec, pollImmediatly);
case DDI_HTTP:
return createDdiDevice(id, tenant, pollDelaySec, baseEndpoint, gatewayToken);
default:
throw new IllegalArgumentException("Protocol " + protocol + " unknown");
}
}
private AbstractSimulatedDevice createDdiDevice(final String id, final String tenant, final int pollDelaySec,
final URL baseEndpoint, final String gatewayToken) {
final ControllerResource controllerResource = Feign.builder().logger(new Logger.ErrorLogger())
.requestInterceptor(new GatewayTokenInterceptor(gatewayToken)).logLevel(Logger.Level.BASIC)
.target(ControllerResource.class, baseEndpoint.toString());
return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, deviceUpdater);
}
private AbstractSimulatedDevice createDmfDevice(final String id, final String tenant, final int pollDelaySec,
final boolean pollImmediatly) {
final AbstractSimulatedDevice device = new DMFSimulatedDevice(id, tenant, spSenderService, pollDelaySec); final AbstractSimulatedDevice device = new DMFSimulatedDevice(id, tenant, spSenderService, pollDelaySec);
device.setNextPollCounterSec(pollDelaySec); device.setNextPollCounterSec(pollDelaySec);
if (pollImmediatly) { if (pollImmediatly) {
spSenderService.createOrUpdateThing(tenant, id); spSenderService.createOrUpdateThing(tenant, id);
} }
return device; return device;
case DDI_HTTP:
final ControllerResource controllerResource = Feign.builder().logger(new Logger.ErrorLogger())
.requestInterceptor(new GatewayTokenInterceptor(gatewayToken)).logLevel(Logger.Level.BASIC)
.target(ControllerResource.class, baseEndpoint.toString());
return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, deviceUpdater);
default:
throw new IllegalArgumentException("Protocol " + protocol + " unknown");
}
} }
/** /**

View File

@@ -34,12 +34,12 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
* beans. * beans.
*/ */
public class ArtifactBeanQuery extends AbstractBeanQuery<Artifact> { public class ArtifactBeanQuery extends AbstractBeanQuery<Artifact> {
private static final long serialVersionUID = -333786310371208962L; private static final long serialVersionUID = 1L;
private Sort sort = new Sort(Direction.DESC, "filename"); private Sort sort = new Sort(Direction.DESC, "filename");
private transient ArtifactManagement artifactManagement = null; private transient ArtifactManagement artifactManagement;
private transient EntityFactory entityFactory; private transient EntityFactory entityFactory;
private transient Page<Artifact> firstPagetArtifacts = null; private transient Page<Artifact> firstPagetArtifacts;
private Long baseSwModuleId = null; private Long baseSwModuleId;
/** /**
* Parametric Constructor. * Parametric Constructor.

View File

@@ -59,7 +59,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
super(definition, queryConfig, sortIds, sortStates); super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) { if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
type = Optional.ofNullable((SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE)) type = Optional.ofNullable((SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE))
.map(t -> t.getId()).orElse(null); .map(SoftwareModuleType::getId).orElse(null);
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
if (!Strings.isNullOrEmpty(searchText)) { if (!Strings.isNullOrEmpty(searchText)) {
searchText = String.format("%%%s%%", searchText); searchText = String.format("%%%s%%", searchText);

View File

@@ -23,7 +23,6 @@ import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.filtermanagement.AutoCompleteTextFieldComponent.FilterQueryChangeListener;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
@@ -37,10 +36,8 @@ import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.TextChangeEvent; import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
@@ -226,37 +223,21 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
private void createListeners() { private void createListeners() {
nameTextFieldBlusListner = new BlurListener() { nameTextFieldBlusListner = event -> {
private static final long serialVersionUID = -2300955622205082213L;
@Override
public void blur(final BlurEvent event) {
if (!Strings.isNullOrEmpty(nameTextField.getValue())) { if (!Strings.isNullOrEmpty(nameTextField.getValue())) {
captionLayout.removeComponent(nameTextField); captionLayout.removeComponent(nameTextField);
captionLayout.addComponent(nameLabel); captionLayout.addComponent(nameLabel);
} }
}
}; };
nameLayoutClickListner = new LayoutClickListener() { nameLayoutClickListner = event -> {
private static final long serialVersionUID = 6188308537393130004L;
@Override
public void layoutClick(final LayoutClickEvent event) {
if (event.getClickedComponent() instanceof Label) { if (event.getClickedComponent() instanceof Label) {
captionLayout.removeComponent(nameLabel); captionLayout.removeComponent(nameLabel);
captionLayout.addComponent(nameTextField); captionLayout.addComponent(nameTextField);
nameTextField.focus(); nameTextField.focus();
} }
}
}; };
queryTextField.addTextChangeListener(new FilterQueryChangeListener() { queryTextField.addTextChangeListener((valid, query) -> enableDisableSaveButton(!valid, query));
@Override
public void queryChanged(final boolean valid, final String query) {
enableDisableSaveButton(!valid, query);
}
});
} }
private void onFilterNameChange(final TextChangeEvent event) { private void onFilterNameChange(final TextChangeEvent event) {

View File

@@ -42,7 +42,8 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
/** /**
* Creates a dialog window to select the distribution set for a target filter query. * Creates a dialog window to select the distribution set for a target filter
* query.
*/ */
@SpringComponent @SpringComponent
@ViewScope @ViewScope
@@ -71,18 +72,17 @@ public class DistributionSetSelectWindow
private CommonDialogWindow window; private CommonDialogWindow window;
private CheckBox checkBox; private CheckBox checkBox;
private VerticalLayout verticalLayout;
private Long tfqId; private Long tfqId;
private void init() { private void init() {
Label label = new Label(i18n.get("label.auto.assign.description")); final Label label = new Label(i18n.get("label.auto.assign.description"));
checkBox = new CheckBox(i18n.get("label.auto.assign.enable")); checkBox = new CheckBox(i18n.get("label.auto.assign.enable"));
checkBox.setId(UIComponentIdProvider.DIST_SET_SELECT_ENABLE_ID); checkBox.setId(UIComponentIdProvider.DIST_SET_SELECT_ENABLE_ID);
checkBox.setImmediate(true); checkBox.setImmediate(true);
checkBox.addValueChangeListener(this); checkBox.addValueChangeListener(this);
verticalLayout = new VerticalLayout(); final VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.addComponent(label); verticalLayout.addComponent(label);
verticalLayout.addComponent(checkBox); verticalLayout.addComponent(checkBox);
verticalLayout.addComponent(dsTable); verticalLayout.addComponent(dsTable);
@@ -93,7 +93,7 @@ public class DistributionSetSelectWindow
window.setId(UIComponentIdProvider.DIST_SET_SELECT_WINDOW_ID); window.setId(UIComponentIdProvider.DIST_SET_SELECT_WINDOW_ID);
} }
public void setValue(DistributionSetIdName distSet) { public void setValue(final DistributionSetIdName distSet) {
dsTable.setVisible(distSet != null); dsTable.setVisible(distSet != null);
checkBox.setValue(distSet != null); checkBox.setValue(distSet != null);
dsTable.setValue(distSet); dsTable.setValue(distSet);
@@ -113,16 +113,16 @@ public class DistributionSetSelectWindow
* @param tfqId * @param tfqId
* target filter query id * target filter query id
*/ */
public void showForTargetFilter(Long tfqId) { public void showForTargetFilter(final Long tfqId) {
this.tfqId = tfqId; this.tfqId = tfqId;
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryById(tfqId); final TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryById(tfqId);
if (tfq == null) { if (tfq == null) {
throw new IllegalStateException("TargetFilterQuery does not exist for the given id"); throw new IllegalStateException("TargetFilterQuery does not exist for the given id");
} }
init(); init();
DistributionSet distributionSet = tfq.getAutoAssignDistributionSet(); final DistributionSet distributionSet = tfq.getAutoAssignDistributionSet();
if (distributionSet != null) { if (distributionSet != null) {
setValue(DistributionSetIdName.generate(distributionSet)); setValue(DistributionSetIdName.generate(distributionSet));
} else { } else {
@@ -141,7 +141,7 @@ public class DistributionSetSelectWindow
* change event * change event
*/ */
@Override @Override
public void valueChange(Property.ValueChangeEvent event) { public void valueChange(final Property.ValueChangeEvent event) {
dsTable.setVisible(checkBox.getValue()); dsTable.setVisible(checkBox.getValue());
if (window != null) { if (window != null) {
window.center(); window.center();
@@ -166,7 +166,7 @@ public class DistributionSetSelectWindow
@Override @Override
public void saveOrUpdate() { public void saveOrUpdate() {
if (checkBox.getValue() && dsTable.getValue() != null) { if (checkBox.getValue() && dsTable.getValue() != null) {
DistributionSetIdName ds = (DistributionSetIdName) dsTable.getValue(); final DistributionSetIdName ds = (DistributionSetIdName) dsTable.getValue();
updateTargetFilterQueryDS(tfqId, ds.getId()); updateTargetFilterQueryDS(tfqId, ds.getId());
} else if (!checkBox.getValue()) { } else if (!checkBox.getValue()) {
@@ -177,9 +177,7 @@ public class DistributionSetSelectWindow
} }
private void updateTargetFilterQueryDS(final Long targetFilterQueryId, final Long dsId) { private void updateTargetFilterQueryDS(final Long targetFilterQueryId, final Long dsId) {
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryById(targetFilterQueryId); final TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryById(targetFilterQueryId);
if (dsId != null) { if (dsId != null) {
confirmWithConsequencesDialog(tfq, dsId); confirmWithConsequencesDialog(tfq, dsId);
@@ -189,14 +187,13 @@ public class DistributionSetSelectWindow
eventBus.publish(this, CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY); eventBus.publish(this, CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY);
} }
} }
private void confirmWithConsequencesDialog(TargetFilterQuery tfq, final Long dsId) { private void confirmWithConsequencesDialog(final TargetFilterQuery tfq, final Long dsId) {
ConfirmConsequencesDialog dialog = new ConfirmConsequencesDialog(tfq, dsId, new ConfirmCallback() { final ConfirmConsequencesDialog dialog = new ConfirmConsequencesDialog(tfq, dsId, new ConfirmCallback() {
@Override @Override
public void onConfirmResult(boolean accepted) { public void onConfirmResult(final boolean accepted) {
if (accepted) { if (accepted) {
tfq.setAutoAssignDistributionSet(distributionSetManagement.findDistributionSetById(dsId)); tfq.setAutoAssignDistributionSet(distributionSetManagement.findDistributionSetById(dsId));
targetFilterQueryManagement.updateTargetFilterQuery(tfq); targetFilterQueryManagement.updateTargetFilterQuery(tfq);
@@ -213,21 +210,22 @@ public class DistributionSetSelectWindow
} }
/** /**
* A dialog that displays how many targets will be assigned immediately with the * A dialog that displays how many targets will be assigned immediately with
* the
*/ */
private class ConfirmConsequencesDialog extends Window implements Button.ClickListener { private class ConfirmConsequencesDialog extends Window implements Button.ClickListener {
private static final long serialVersionUID = 7738545414137389326L; private static final long serialVersionUID = 7738545414137389326L;
private TargetFilterQuery targetFilterQuery; private final TargetFilterQuery targetFilterQuery;
private Long distributionSetId; private final Long distributionSetId;
private Button okButton; private Button okButton;
private Button cancelButton;
private ConfirmCallback callback; private final ConfirmCallback callback;
public ConfirmConsequencesDialog(TargetFilterQuery targetFilterQuery, final Long dsId, ConfirmCallback callback) { public ConfirmConsequencesDialog(final TargetFilterQuery targetFilterQuery, final Long dsId,
final ConfirmCallback callback) {
super(i18n.get("caption.confirm.assign.consequences")); super(i18n.get("caption.confirm.assign.consequences"));
this.callback = callback; this.callback = callback;
@@ -243,30 +241,31 @@ public class DistributionSetSelectWindow
setModal(true); setModal(true);
setResizable(false); setResizable(false);
VerticalLayout layout = new VerticalLayout(); final VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true); layout.setSpacing(true);
layout.setMargin(true); layout.setMargin(true);
setContent(layout); setContent(layout);
Long targetsCount = targetManagement.countTargetsByTargetFilterQueryAndNonDS(distributionSetId, targetFilterQuery); final Long targetsCount = targetManagement.countTargetsByTargetFilterQueryAndNonDS(distributionSetId,
targetFilterQuery);
Label mainTextLabel; Label mainTextLabel;
if (targetsCount == 0) { if (targetsCount == 0) {
mainTextLabel = new Label(i18n.get("message.confirm.assign.consequences.none")); mainTextLabel = new Label(i18n.get("message.confirm.assign.consequences.none"));
} else { } else {
mainTextLabel = new Label(i18n.get("message.confirm.assign.consequences.text", new Object[]{targetsCount})); mainTextLabel = new Label(
i18n.get("message.confirm.assign.consequences.text", new Object[] { targetsCount }));
} }
layout.addComponent(mainTextLabel); layout.addComponent(mainTextLabel);
HorizontalLayout buttonsLayout = new HorizontalLayout(); final HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setSizeFull(); buttonsLayout.setSizeFull();
buttonsLayout.setSpacing(true); buttonsLayout.setSpacing(true);
buttonsLayout.addStyleName("actionButtonsMargin"); buttonsLayout.addStyleName("actionButtonsMargin");
layout.addComponent(buttonsLayout); layout.addComponent(buttonsLayout);
okButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON, i18n.get("button.ok"), "", "",
okButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON, i18n.get("button.ok"), "", "", true, true, FontAwesome.SAVE, SPUIButtonStyleNoBorderWithIcon.class);
FontAwesome.SAVE, SPUIButtonStyleNoBorderWithIcon.class);
okButton.setSizeUndefined(); okButton.setSizeUndefined();
okButton.addStyleName("default-color"); okButton.addStyleName("default-color");
okButton.addClickListener(this); okButton.addClickListener(this);
@@ -274,9 +273,8 @@ public class DistributionSetSelectWindow
buttonsLayout.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); buttonsLayout.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);
buttonsLayout.setExpandRatio(okButton, 1.0F); buttonsLayout.setExpandRatio(okButton, 1.0F);
final Button cancelButton = SPUIComponentProvider.getButton(UIComponentIdProvider.CANCEL_BUTTON,
cancelButton = SPUIComponentProvider.getButton(UIComponentIdProvider.CANCEL_BUTTON, i18n.get("button.cancel"), "", "", true, i18n.get("button.cancel"), "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class);
FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class);
cancelButton.setSizeUndefined(); cancelButton.setSizeUndefined();
cancelButton.addStyleName("default-color"); cancelButton.addStyleName("default-color");
cancelButton.addClickListener(this); cancelButton.addClickListener(this);
@@ -284,11 +282,10 @@ public class DistributionSetSelectWindow
buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_LEFT); buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_LEFT);
buttonsLayout.setExpandRatio(cancelButton, 1.0F); buttonsLayout.setExpandRatio(cancelButton, 1.0F);
} }
@Override @Override
public void buttonClick(Button.ClickEvent event) { public void buttonClick(final Button.ClickEvent event) {
if (event.getButton().getId().equals(okButton.getId())) { if (event.getButton().getId().equals(okButton.getId())) {
callback.onConfirmResult(true); callback.onConfirmResult(true);
} else { } else {

View File

@@ -29,9 +29,10 @@ import com.vaadin.shared.ui.Connect;
* {@link TextFieldSuggestionBoxServerRpc} call. * {@link TextFieldSuggestionBoxServerRpc} call.
* *
*/ */
@SuppressWarnings({ "deprecation", "squid:CallToDeprecatedMethod" }) @SuppressWarnings({ "deprecation", "squid:CallToDeprecatedMethod", "squid:S1604" })
// need to use VOverlay because otherwise it's not in the correct theme // need to use VOverlay because otherwise it's not in the correct theme
// widget @see com.vaadin.client.ui.VOverlay.getOverlayContainer() // widget @see com.vaadin.client.ui.VOverlay.getOverlayContainer()
// GWT 2.7 does not support Java 8
@Connect(TextFieldSuggestionBox.class) @Connect(TextFieldSuggestionBox.class)
public class AutoCompleteTextFieldConnector extends AbstractExtensionConnector { public class AutoCompleteTextFieldConnector extends AbstractExtensionConnector {
@@ -139,3 +140,4 @@ public class AutoCompleteTextFieldConnector extends AbstractExtensionConnector {
rpc.suggest(textFieldWidget.getValue(), textFieldWidget.getCursorPos()); rpc.suggest(textFieldWidget.getValue(), textFieldWidget.getCursorPos());
} }
} }

View File

@@ -23,6 +23,8 @@ import com.vaadin.client.ui.VTextField;
/** /**
* The suggestion list within the suggestion pop-up panel. * The suggestion list within the suggestion pop-up panel.
*/ */
// Exception squid:S1604 - GWT 2.7 does not support Java 8
@SuppressWarnings("squid:S1604")
public class SuggestionsSelectList extends MenuBar { public class SuggestionsSelectList extends MenuBar {
public static final String CLASSNAME = "autocomplete"; public static final String CLASSNAME = "autocomplete";