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:
committed by
Michael Hirsch
parent
23eb0c3c73
commit
c1e5689f6a
@@ -22,7 +22,7 @@ import feign.Logger;
|
||||
|
||||
/**
|
||||
* The simulated device factory to create either {@link DMFSimulatedDevice} or
|
||||
* {@link DDISimulatedDevice#}.
|
||||
* {@link DDISimulatedDevice}.
|
||||
*/
|
||||
@Service
|
||||
public class SimulatedDeviceFactory {
|
||||
@@ -61,22 +61,32 @@ public class SimulatedDeviceFactory {
|
||||
final int pollDelaySec, final URL baseEndpoint, final String gatewayToken, final boolean pollImmediatly) {
|
||||
switch (protocol) {
|
||||
case DMF_AMQP:
|
||||
final AbstractSimulatedDevice device = new DMFSimulatedDevice(id, tenant, spSenderService, pollDelaySec);
|
||||
device.setNextPollCounterSec(pollDelaySec);
|
||||
if (pollImmediatly) {
|
||||
spSenderService.createOrUpdateThing(tenant, id);
|
||||
}
|
||||
return device;
|
||||
return createDmfDevice(id, tenant, pollDelaySec, pollImmediatly);
|
||||
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);
|
||||
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);
|
||||
device.setNextPollCounterSec(pollDelaySec);
|
||||
if (pollImmediatly) {
|
||||
spSenderService.createOrUpdateThing(tenant, id);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating a simulated device and send an immediate DMF poll to update
|
||||
* server.
|
||||
|
||||
@@ -34,12 +34,12 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||
* beans.
|
||||
*/
|
||||
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 transient ArtifactManagement artifactManagement = null;
|
||||
private transient ArtifactManagement artifactManagement;
|
||||
private transient EntityFactory entityFactory;
|
||||
private transient Page<Artifact> firstPagetArtifacts = null;
|
||||
private Long baseSwModuleId = null;
|
||||
private transient Page<Artifact> firstPagetArtifacts;
|
||||
private Long baseSwModuleId;
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
|
||||
super(definition, queryConfig, sortIds, sortStates);
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
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);
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
searchText = String.format("%%%s%%", searchText);
|
||||
|
||||
@@ -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.SPUIComponentProvider;
|
||||
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.state.FilterManagementUIState;
|
||||
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 com.google.common.base.Strings;
|
||||
import com.vaadin.event.FieldEvents.BlurEvent;
|
||||
import com.vaadin.event.FieldEvents.BlurListener;
|
||||
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
||||
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
|
||||
import com.vaadin.event.LayoutEvents.LayoutClickListener;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
@@ -226,37 +223,21 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
|
||||
private void createListeners() {
|
||||
nameTextFieldBlusListner = new BlurListener() {
|
||||
private static final long serialVersionUID = -2300955622205082213L;
|
||||
|
||||
@Override
|
||||
public void blur(final BlurEvent event) {
|
||||
if (!Strings.isNullOrEmpty(nameTextField.getValue())) {
|
||||
captionLayout.removeComponent(nameTextField);
|
||||
captionLayout.addComponent(nameLabel);
|
||||
}
|
||||
nameTextFieldBlusListner = event -> {
|
||||
if (!Strings.isNullOrEmpty(nameTextField.getValue())) {
|
||||
captionLayout.removeComponent(nameTextField);
|
||||
captionLayout.addComponent(nameLabel);
|
||||
}
|
||||
};
|
||||
nameLayoutClickListner = new LayoutClickListener() {
|
||||
private static final long serialVersionUID = 6188308537393130004L;
|
||||
|
||||
@Override
|
||||
public void layoutClick(final LayoutClickEvent event) {
|
||||
if (event.getClickedComponent() instanceof Label) {
|
||||
captionLayout.removeComponent(nameLabel);
|
||||
captionLayout.addComponent(nameTextField);
|
||||
nameTextField.focus();
|
||||
}
|
||||
nameLayoutClickListner = event -> {
|
||||
if (event.getClickedComponent() instanceof Label) {
|
||||
captionLayout.removeComponent(nameLabel);
|
||||
captionLayout.addComponent(nameTextField);
|
||||
nameTextField.focus();
|
||||
}
|
||||
};
|
||||
|
||||
queryTextField.addTextChangeListener(new FilterQueryChangeListener() {
|
||||
@Override
|
||||
public void queryChanged(final boolean valid, final String query) {
|
||||
enableDisableSaveButton(!valid, query);
|
||||
}
|
||||
});
|
||||
|
||||
queryTextField.addTextChangeListener((valid, query) -> enableDisableSaveButton(!valid, query));
|
||||
}
|
||||
|
||||
private void onFilterNameChange(final TextChangeEvent event) {
|
||||
|
||||
@@ -42,7 +42,8 @@ import com.vaadin.ui.VerticalLayout;
|
||||
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
|
||||
@ViewScope
|
||||
@@ -71,18 +72,17 @@ public class DistributionSetSelectWindow
|
||||
|
||||
private CommonDialogWindow window;
|
||||
private CheckBox checkBox;
|
||||
private VerticalLayout verticalLayout;
|
||||
private Long tfqId;
|
||||
|
||||
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.setId(UIComponentIdProvider.DIST_SET_SELECT_ENABLE_ID);
|
||||
checkBox.setImmediate(true);
|
||||
checkBox.addValueChangeListener(this);
|
||||
|
||||
verticalLayout = new VerticalLayout();
|
||||
final VerticalLayout verticalLayout = new VerticalLayout();
|
||||
verticalLayout.addComponent(label);
|
||||
verticalLayout.addComponent(checkBox);
|
||||
verticalLayout.addComponent(dsTable);
|
||||
@@ -93,7 +93,7 @@ public class DistributionSetSelectWindow
|
||||
window.setId(UIComponentIdProvider.DIST_SET_SELECT_WINDOW_ID);
|
||||
}
|
||||
|
||||
public void setValue(DistributionSetIdName distSet) {
|
||||
public void setValue(final DistributionSetIdName distSet) {
|
||||
dsTable.setVisible(distSet != null);
|
||||
checkBox.setValue(distSet != null);
|
||||
dsTable.setValue(distSet);
|
||||
@@ -113,17 +113,17 @@ public class DistributionSetSelectWindow
|
||||
* @param tfqId
|
||||
* target filter query id
|
||||
*/
|
||||
public void showForTargetFilter(Long tfqId) {
|
||||
public void showForTargetFilter(final Long tfqId) {
|
||||
this.tfqId = tfqId;
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryById(tfqId);
|
||||
if(tfq == null) {
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryById(tfqId);
|
||||
if (tfq == null) {
|
||||
throw new IllegalStateException("TargetFilterQuery does not exist for the given id");
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
DistributionSet distributionSet = tfq.getAutoAssignDistributionSet();
|
||||
if(distributionSet != null) {
|
||||
final DistributionSet distributionSet = tfq.getAutoAssignDistributionSet();
|
||||
if (distributionSet != null) {
|
||||
setValue(DistributionSetIdName.generate(distributionSet));
|
||||
} else {
|
||||
setValue(null);
|
||||
@@ -141,7 +141,7 @@ public class DistributionSetSelectWindow
|
||||
* change event
|
||||
*/
|
||||
@Override
|
||||
public void valueChange(Property.ValueChangeEvent event) {
|
||||
public void valueChange(final Property.ValueChangeEvent event) {
|
||||
dsTable.setVisible(checkBox.getValue());
|
||||
if (window != null) {
|
||||
window.center();
|
||||
@@ -165,11 +165,11 @@ public class DistributionSetSelectWindow
|
||||
*/
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if(checkBox.getValue() && dsTable.getValue() != null) {
|
||||
DistributionSetIdName ds = (DistributionSetIdName) dsTable.getValue();
|
||||
if (checkBox.getValue() && dsTable.getValue() != null) {
|
||||
final DistributionSetIdName ds = (DistributionSetIdName) dsTable.getValue();
|
||||
updateTargetFilterQueryDS(tfqId, ds.getId());
|
||||
|
||||
} else if(!checkBox.getValue()) {
|
||||
} else if (!checkBox.getValue()) {
|
||||
updateTargetFilterQueryDS(tfqId, null);
|
||||
|
||||
}
|
||||
@@ -177,11 +177,9 @@ public class DistributionSetSelectWindow
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
tfq.setAutoAssignDistributionSet(null);
|
||||
@@ -189,15 +187,14 @@ public class DistributionSetSelectWindow
|
||||
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
|
||||
public void onConfirmResult(boolean accepted) {
|
||||
if(accepted) {
|
||||
public void onConfirmResult(final boolean accepted) {
|
||||
if (accepted) {
|
||||
tfq.setAutoAssignDistributionSet(distributionSetManagement.findDistributionSetById(dsId));
|
||||
targetFilterQueryManagement.updateTargetFilterQuery(tfq);
|
||||
eventBus.publish(this, CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY);
|
||||
@@ -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 static final long serialVersionUID = 7738545414137389326L;
|
||||
|
||||
private TargetFilterQuery targetFilterQuery;
|
||||
private Long distributionSetId;
|
||||
private final TargetFilterQuery targetFilterQuery;
|
||||
private final Long distributionSetId;
|
||||
|
||||
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"));
|
||||
|
||||
this.callback = callback;
|
||||
@@ -243,30 +241,31 @@ public class DistributionSetSelectWindow
|
||||
setModal(true);
|
||||
setResizable(false);
|
||||
|
||||
VerticalLayout layout = new VerticalLayout();
|
||||
final VerticalLayout layout = new VerticalLayout();
|
||||
layout.setSpacing(true);
|
||||
layout.setMargin(true);
|
||||
setContent(layout);
|
||||
|
||||
Long targetsCount = targetManagement.countTargetsByTargetFilterQueryAndNonDS(distributionSetId, targetFilterQuery);
|
||||
final Long targetsCount = targetManagement.countTargetsByTargetFilterQueryAndNonDS(distributionSetId,
|
||||
targetFilterQuery);
|
||||
Label mainTextLabel;
|
||||
if(targetsCount == 0) {
|
||||
if (targetsCount == 0) {
|
||||
mainTextLabel = new Label(i18n.get("message.confirm.assign.consequences.none"));
|
||||
} 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);
|
||||
|
||||
HorizontalLayout buttonsLayout = new HorizontalLayout();
|
||||
final HorizontalLayout buttonsLayout = new HorizontalLayout();
|
||||
buttonsLayout.setSizeFull();
|
||||
buttonsLayout.setSpacing(true);
|
||||
buttonsLayout.addStyleName("actionButtonsMargin");
|
||||
layout.addComponent(buttonsLayout);
|
||||
|
||||
|
||||
okButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON, i18n.get("button.ok"), "", "", true,
|
||||
FontAwesome.SAVE, SPUIButtonStyleNoBorderWithIcon.class);
|
||||
okButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON, i18n.get("button.ok"), "", "",
|
||||
true, FontAwesome.SAVE, SPUIButtonStyleNoBorderWithIcon.class);
|
||||
okButton.setSizeUndefined();
|
||||
okButton.addStyleName("default-color");
|
||||
okButton.addClickListener(this);
|
||||
@@ -274,9 +273,8 @@ public class DistributionSetSelectWindow
|
||||
buttonsLayout.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);
|
||||
buttonsLayout.setExpandRatio(okButton, 1.0F);
|
||||
|
||||
|
||||
cancelButton = SPUIComponentProvider.getButton(UIComponentIdProvider.CANCEL_BUTTON, i18n.get("button.cancel"), "", "", true,
|
||||
FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class);
|
||||
final Button cancelButton = SPUIComponentProvider.getButton(UIComponentIdProvider.CANCEL_BUTTON,
|
||||
i18n.get("button.cancel"), "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class);
|
||||
cancelButton.setSizeUndefined();
|
||||
cancelButton.addStyleName("default-color");
|
||||
cancelButton.addClickListener(this);
|
||||
@@ -284,12 +282,11 @@ public class DistributionSetSelectWindow
|
||||
buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_LEFT);
|
||||
buttonsLayout.setExpandRatio(cancelButton, 1.0F);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonClick(Button.ClickEvent event) {
|
||||
if(event.getButton().getId().equals(okButton.getId())) {
|
||||
public void buttonClick(final Button.ClickEvent event) {
|
||||
if (event.getButton().getId().equals(okButton.getId())) {
|
||||
callback.onConfirmResult(true);
|
||||
} else {
|
||||
callback.onConfirmResult(false);
|
||||
|
||||
@@ -29,9 +29,10 @@ import com.vaadin.shared.ui.Connect;
|
||||
* {@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
|
||||
// widget @see com.vaadin.client.ui.VOverlay.getOverlayContainer()
|
||||
// GWT 2.7 does not support Java 8
|
||||
@Connect(TextFieldSuggestionBox.class)
|
||||
public class AutoCompleteTextFieldConnector extends AbstractExtensionConnector {
|
||||
|
||||
@@ -139,3 +140,4 @@ public class AutoCompleteTextFieldConnector extends AbstractExtensionConnector {
|
||||
rpc.suggest(textFieldWidget.getValue(), textFieldWidget.getCursorPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import com.vaadin.client.ui.VTextField;
|
||||
/**
|
||||
* 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 static final String CLASSNAME = "autocomplete";
|
||||
|
||||
Reference in New Issue
Block a user