reduced empty collections. Fixed Ui eventbus memory leak.
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
package org.eclipse.hawkbit.ui.artifacts.details;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.shared.ui.label.ContentMode;
|
||||
@@ -207,8 +208,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
private Container createArtifactLazyQueryContainer() {
|
||||
final Map<String, Object> queryConfiguration = new HashMap<>();
|
||||
return getArtifactLazyQueryContainer(queryConfiguration);
|
||||
return getArtifactLazyQueryContainer(Collections.emptyMap());
|
||||
}
|
||||
|
||||
private LazyQueryContainer getArtifactLazyQueryContainer(final Map<String, Object> queryConfig) {
|
||||
@@ -429,9 +429,12 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
||||
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
|
||||
}
|
||||
}
|
||||
final Map<String, Object> queryConfiguration = new HashMap<>();
|
||||
final Map<String, Object> queryConfiguration;
|
||||
if (baseSwModuleId != null) {
|
||||
queryConfiguration = Maps.newHashMapWithExpectedSize(1);
|
||||
queryConfiguration.put(SPUIDefinitions.BY_BASE_SOFTWARE_MODULE, baseSwModuleId);
|
||||
} else {
|
||||
queryConfiguration = Collections.emptyMap();
|
||||
}
|
||||
final LazyQueryContainer artifactContainer = getArtifactLazyQueryContainer(queryConfiguration);
|
||||
artifactDetailsTable.setContainerDataSource(artifactContainer);
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
package org.eclipse.hawkbit.ui.artifacts.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
|
||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Component;
|
||||
@@ -54,16 +54,17 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> createDropConfigurations() {
|
||||
final Map<String, List<String>> config = new HashMap<>();
|
||||
final Map<String, List<String>> config = Maps.newHashMapWithExpectedSize(1);
|
||||
// Delete drop area droppable components
|
||||
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList(
|
||||
SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
|
||||
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
|
||||
Arrays.asList(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE,
|
||||
SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private static Map<String, Object> createDropHintConfigurations() {
|
||||
final Map<String, Object> config = new HashMap<>();
|
||||
final Map<String, Object> config = Maps.newHashMapWithExpectedSize(2);
|
||||
config.put(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START);
|
||||
config.put(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START);
|
||||
return config;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
package org.eclipse.hawkbit.ui.artifacts.footer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -26,6 +25,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.IndexedContainer;
|
||||
@@ -64,7 +64,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
|
||||
|
||||
@Override
|
||||
protected Map<String, ConfirmationTab> getConfimrationTabs() {
|
||||
final Map<String, ConfirmationTab> tabs = new HashMap<>();
|
||||
final Map<String, ConfirmationTab> tabs = Maps.newHashMapWithExpectedSize(2);
|
||||
if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) {
|
||||
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -37,6 +36,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.event.dd.DragAndDropEvent;
|
||||
@@ -97,7 +97,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
||||
}
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(2);
|
||||
artifactUploadState.getSoftwareModuleFilters().getSearchText()
|
||||
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.vaadin.client.renderers.WidgetRenderer;
|
||||
import com.vaadin.client.ui.VLabel;
|
||||
@@ -29,11 +29,11 @@ public class HtmlLabelRenderer extends WidgetRenderer<String, VLabel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RendererCellReference cell, String input, VLabel label) {
|
||||
Map<String, String> map = formatInput(input);
|
||||
String value = map.containsKey("value") ? map.get("value") : null;
|
||||
String style = map.containsKey("style") ? map.get("style") : null;
|
||||
String id = map.containsKey("id") ? map.get("id") : null;
|
||||
public void render(final RendererCellReference cell, final String input, final VLabel label) {
|
||||
final Map<String, String> map = formatInput(input);
|
||||
final String value = map.containsKey("value") ? map.get("value") : null;
|
||||
final String style = map.containsKey("style") ? map.get("style") : null;
|
||||
final String id = map.containsKey("id") ? map.get("id") : null;
|
||||
|
||||
if (value != null) {
|
||||
label.setHTML("<span>&#x" + Integer.toHexString(Integer.parseInt(value)) + ";</span>");
|
||||
@@ -44,7 +44,7 @@ public class HtmlLabelRenderer extends WidgetRenderer<String, VLabel> {
|
||||
label.getElement().setId(id);
|
||||
}
|
||||
|
||||
private void applyStyle(VLabel label, String style) {
|
||||
private void applyStyle(final VLabel label, final String style) {
|
||||
label.setStyleName(VLabel.CLASSNAME);
|
||||
label.addStyleName(getStyle("small"));
|
||||
label.addStyleName(getStyle("font-icon"));
|
||||
@@ -57,11 +57,12 @@ public class HtmlLabelRenderer extends WidgetRenderer<String, VLabel> {
|
||||
return new StringBuilder(style).append(" ").append(VLabel.CLASSNAME).append("-").append(style).toString();
|
||||
}
|
||||
|
||||
private Map<String, String> formatInput(String input) {
|
||||
Map<String, String> details = new HashMap<>();
|
||||
String[] tempData = input.split(",");
|
||||
for (String statusWithCount : tempData) {
|
||||
String[] statusWithCountList = statusWithCount.split(":");
|
||||
private Map<String, String> formatInput(final String input) {
|
||||
|
||||
final String[] tempData = input.split(",");
|
||||
final Map<String, String> details = Maps.newHashMapWithExpectedSize(tempData.length);
|
||||
for (final String statusWithCount : tempData) {
|
||||
final String[] statusWithCountList = statusWithCount.split(":");
|
||||
details.put(statusWithCountList[0], statusWithCountList[1]);
|
||||
}
|
||||
return details;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
private VerticalLayout tagsLayout;
|
||||
|
||||
private final Map<String, StringBuilder> assignedSWModule = new HashMap<>();
|
||||
private Map<String, StringBuilder> assignedSWModule;
|
||||
|
||||
/**
|
||||
* softwareLayout Initialize the component.
|
||||
@@ -144,6 +144,10 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
}
|
||||
|
||||
if (null != softwareModuleIdNameList) {
|
||||
if (assignedSWModule == null) {
|
||||
assignedSWModule = new HashMap<>();
|
||||
}
|
||||
|
||||
for (final SoftwareModuleIdName swIdName : softwareModuleIdNameList) {
|
||||
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(swIdName.getId());
|
||||
if (assignedSWModule.containsKey(softwareModule.getType().getName())) {
|
||||
@@ -186,6 +190,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void updateSoftwareModule(final SoftwareModule module) {
|
||||
if (assignedSWModule == null) {
|
||||
assignedSWModule = new HashMap<>();
|
||||
}
|
||||
|
||||
softwareModuleTable.getContainerDataSource().getItemIds();
|
||||
if (assignedSWModule.containsKey(module.getType().getName())) {
|
||||
@@ -363,7 +370,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
|
||||
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
|
||||
&& getSelectedBaseEntity() != null) {
|
||||
assignedSWModule.clear();
|
||||
if (assignedSWModule != null) {
|
||||
assignedSWModule.clear();
|
||||
}
|
||||
setSelectedBaseEntity(
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()));
|
||||
UI.getCurrent().access(() -> populateModule());
|
||||
@@ -375,7 +384,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
if (saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ASSIGNMENT
|
||||
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS
|
||||
|| saveActionWindowEvent == SaveActionWindowEvent.DELETE_ALL_SOFWARE) {
|
||||
assignedSWModule.clear();
|
||||
if (assignedSWModule != null) {
|
||||
assignedSWModule.clear();
|
||||
}
|
||||
showUnsavedAssignment();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.event.dd.DragAndDropEvent;
|
||||
@@ -167,7 +168,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
}
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(2);
|
||||
manageDistUIState.getManageDistFilters().getSearchText()
|
||||
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
|
||||
@@ -530,7 +531,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
return manageMetadataBtn;
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long itemId) {
|
||||
private void showMetadataDetails(final Long itemId) {
|
||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId);
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
package org.eclipse.hawkbit.ui.distributions.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,6 +16,7 @@ import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Component;
|
||||
@@ -66,7 +66,7 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> createDropConfigurations() {
|
||||
final Map<String, List<String>> config = new HashMap<>();
|
||||
final Map<String, List<String>> config = Maps.newHashMapWithExpectedSize(2);
|
||||
|
||||
// Delete drop area droppable components
|
||||
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
|
||||
@@ -82,7 +82,7 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
}
|
||||
|
||||
private static Map<String, Object> createDropHintConfigurations() {
|
||||
final Map<String, Object> config = new HashMap<>();
|
||||
final Map<String, Object> config = Maps.newHashMapWithExpectedSize(4);
|
||||
config.put(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, DragEvent.DISTRIBUTION_TYPE_DRAG);
|
||||
config.put(SPUIComponentIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
|
||||
config.put(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, DragEvent.SOFTWAREMODULE_DRAG);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.footer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -37,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.IndexedContainer;
|
||||
@@ -90,7 +90,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
|
||||
@Override
|
||||
protected Map<String, ConfirmationTab> getConfimrationTabs() {
|
||||
final Map<String, ConfirmationTab> tabs = new HashMap<>();
|
||||
final Map<String, ConfirmationTab> tabs = Maps.newHashMapWithExpectedSize(5);
|
||||
/* Create tab for SW Modules delete */
|
||||
if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
|
||||
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
|
||||
@@ -112,7 +112,6 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
}
|
||||
|
||||
/* Create tab for Assign Software Module */
|
||||
|
||||
if (!manageDistUIState.getAssignedList().isEmpty()) {
|
||||
tabs.put(i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.smtable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -40,6 +39,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.event.dd.DragAndDropEvent;
|
||||
@@ -143,7 +143,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
||||
}
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(3);
|
||||
manageDistUIState.getSoftwareModuleFilters().getSearchText()
|
||||
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ import static org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.Sof
|
||||
import static org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
|
||||
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_NAME;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
|
||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||
@@ -59,10 +58,9 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
||||
|
||||
@Override
|
||||
protected LazyQueryContainer createButtonsLazyQueryContainer() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final BeanQueryFactory<SoftwareModuleTypeBeanQuery> typeQF = new BeanQueryFactory<>(
|
||||
SoftwareModuleTypeBeanQuery.class);
|
||||
typeQF.setQueryConfiguration(queryConfig);
|
||||
typeQF.setQueryConfiguration(Collections.emptyMap());
|
||||
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, VAR_NAME), typeQF);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
||||
|
||||
private Set<Long> selectedSoftwareModules = emptySet();
|
||||
|
||||
private Set<String> selectedDeleteDistSetTypes = new HashSet<>();
|
||||
private final Set<String> selectedDeleteDistSetTypes = new HashSet<>();
|
||||
|
||||
private Set<String> selectedDeleteSWModuleTypes = new HashSet<>();
|
||||
|
||||
@@ -201,10 +201,6 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
||||
return selectedDeleteDistSetTypes;
|
||||
}
|
||||
|
||||
public void setSelectedDeleteDistSetTypes(final Set<String> selectedDeleteDistSetTypes) {
|
||||
this.selectedDeleteDistSetTypes = selectedDeleteDistSetTypes;
|
||||
}
|
||||
|
||||
public Set<String> getSelectedDeleteSWModuleTypes() {
|
||||
return selectedDeleteSWModuleTypes;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -37,6 +36,7 @@ import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.shared.ui.label.ContentMode;
|
||||
@@ -142,7 +142,7 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
}
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(2);
|
||||
if (!Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) {
|
||||
queryConfig.put(SPUIDefinitions.FILTER_BY_QUERY, filterManagementUIState.getFilterQueryValue());
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
@@ -128,7 +129,7 @@ public class TargetFilterTable extends Table {
|
||||
}
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(1);
|
||||
filterManagementUIState.getCustomFilterSearchText()
|
||||
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
return queryConfig;
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.management.dstable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -178,10 +177,9 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
* @return
|
||||
*/
|
||||
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<>(
|
||||
DistributionSetTypeBeanQuery.class);
|
||||
dtQF.setQueryConfiguration(queryConfig);
|
||||
dtQF.setQueryConfiguration(Collections.emptyMap());
|
||||
|
||||
final LazyQueryContainer disttypeContainer = new LazyQueryContainer(
|
||||
new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
package org.eclipse.hawkbit.ui.management.dstable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -56,6 +55,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.event.dd.DragAndDropEvent;
|
||||
@@ -240,7 +240,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
}
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(4);
|
||||
managementUIState.getDistributionTableFilters().getSearchText()
|
||||
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
managementUIState.getDistributionTableFilters().getPinnedTargetId()
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.management.dstag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||
@@ -101,9 +100,8 @@ public class DistributionTagButtons extends AbstractFilterButtons {
|
||||
|
||||
@Override
|
||||
protected LazyQueryContainer createButtonsLazyQueryContainer() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final BeanQueryFactory<DistributionTagBeanQuery> tagQF = new BeanQueryFactory<>(DistributionTagBeanQuery.class);
|
||||
tagQF.setQueryConfiguration(queryConfig);
|
||||
tagQF.setQueryConfiguration(Collections.emptyMap());
|
||||
return HawkbitCommonUtil.createDSLazyQueryContainer(
|
||||
new BeanQueryFactory<DistributionTagBeanQuery>(DistributionTagBeanQuery.class));
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
package org.eclipse.hawkbit.ui.management.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,6 +16,7 @@ import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Component;
|
||||
@@ -67,7 +67,7 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> createDropConfigurations() {
|
||||
final Map<String, List<String>> config = new HashMap<>();
|
||||
final Map<String, List<String>> config = Maps.newHashMapWithExpectedSize(6);
|
||||
|
||||
// Delete drop area acceptable components
|
||||
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
|
||||
@@ -82,7 +82,8 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, SPUIComponentIdProvider.DIST_TABLE_ID));
|
||||
|
||||
// Target table header acceptable components
|
||||
config.put(SPUIComponentIdProvider.TARGET_DROP_FILTER_ICON, Arrays.asList(SPUIComponentIdProvider.DIST_TABLE_ID));
|
||||
config.put(SPUIComponentIdProvider.TARGET_DROP_FILTER_ICON,
|
||||
Arrays.asList(SPUIComponentIdProvider.DIST_TABLE_ID));
|
||||
|
||||
// Distribution table acceptable components
|
||||
config.put(SPUIComponentIdProvider.DIST_TABLE_ID, Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS,
|
||||
@@ -94,7 +95,7 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
}
|
||||
|
||||
private static Map<String, Object> createDropHintConfigurations() {
|
||||
final Map<String, Object> config = new HashMap<>();
|
||||
final Map<String, Object> config = Maps.newHashMapWithExpectedSize(4);
|
||||
config.put(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, DragEvent.TARGET_TAG_DRAG);
|
||||
config.put(SPUIComponentIdProvider.TARGET_TABLE_ID, DragEvent.TARGET_DRAG);
|
||||
config.put(SPUIComponentIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.IndexedContainer;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
@@ -88,7 +89,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
|
||||
|
||||
@Override
|
||||
protected Map<String, ConfirmationTab> getConfimrationTabs() {
|
||||
final Map<String, ConfirmationTab> tabs = new HashMap<>();
|
||||
final Map<String, ConfirmationTab> tabs = Maps.newHashMapWithExpectedSize(3);
|
||||
if (!managementUIState.getDeletedDistributionList().isEmpty()) {
|
||||
tabs.put(i18n.get("caption.delete.dist.accordion.tab"), createDeletedDistributionTab());
|
||||
}
|
||||
|
||||
@@ -87,10 +87,9 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
|
||||
private boolean customFilterSelected;
|
||||
|
||||
private boolean bulkUploadWindowMinimised;
|
||||
|
||||
|
||||
private DistributionSetIdName lastSelectedDistribution;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the lastSelectedDistribution
|
||||
*/
|
||||
@@ -98,12 +97,10 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
|
||||
return Optional.ofNullable(lastSelectedDistribution);
|
||||
}
|
||||
|
||||
|
||||
public void setLastSelectedDistribution(final DistributionSetIdName value) {
|
||||
this.lastSelectedDistribution = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the bulkUploadWindowMinimised
|
||||
*/
|
||||
|
||||
@@ -9,12 +9,9 @@
|
||||
package org.eclipse.hawkbit.ui.management.targettable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
@@ -40,6 +37,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.tokenfield.TokenField;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.shared.ui.combobox.FilteringMode;
|
||||
@@ -112,12 +110,6 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
||||
buildLayout();
|
||||
setImmediate(true);
|
||||
setCompositionRoot(mainLayout);
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
protected void onStartOfUpload() {
|
||||
@@ -242,7 +234,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
||||
*/
|
||||
private Container createContainer() {
|
||||
|
||||
final Map<String, Object> queryConfiguration = new HashMap<>();
|
||||
final Map<String, Object> queryConfiguration = Maps.newHashMapWithExpectedSize(2);
|
||||
|
||||
final List<String> list = new ArrayList<>();
|
||||
queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG,
|
||||
|
||||
@@ -19,10 +19,10 @@ import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_F
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -43,12 +43,6 @@ import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
|
||||
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
|
||||
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.filter.FilterExpression;
|
||||
import org.eclipse.hawkbit.ui.filter.Filters;
|
||||
import org.eclipse.hawkbit.ui.filter.target.CustomTargetFilter;
|
||||
import org.eclipse.hawkbit.ui.filter.target.TargetSearchTextFilter;
|
||||
import org.eclipse.hawkbit.ui.filter.target.TargetStatusFilter;
|
||||
import org.eclipse.hawkbit.ui.filter.target.TargetTagFilter;
|
||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
|
||||
@@ -78,6 +72,7 @@ import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.event.dd.DragAndDropEvent;
|
||||
@@ -140,11 +135,14 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
if (TargetCreatedEvent.class.isInstance(firstEvent)) {
|
||||
onTargetCreatedEvents();
|
||||
} else if (TargetInfoUpdateEvent.class.isInstance(firstEvent)) {
|
||||
onTargetInfoUpdateEvents((List<TargetInfoUpdateEvent>) events);
|
||||
onTargetUpdateEvents(((List<TargetInfoUpdateEvent>) events).stream()
|
||||
.map(targetInfoUpdateEvent -> targetInfoUpdateEvent.getEntity().getTarget())
|
||||
.collect(Collectors.toList()));
|
||||
} else if (TargetDeletedEvent.class.isInstance(firstEvent)) {
|
||||
onTargetDeletedEvent((List<TargetDeletedEvent>) events);
|
||||
} else if (TargetUpdatedEvent.class.isInstance(firstEvent)) {
|
||||
onTargetUpdateEvents((List<TargetUpdatedEvent>) events);
|
||||
onTargetUpdateEvents(((List<TargetUpdatedEvent>) events).stream()
|
||||
.map(targetInfoUpdateEvent -> targetInfoUpdateEvent.getEntity()).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +346,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(7);
|
||||
managementUIState.getTargetTableFilters().getSearchText()
|
||||
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
managementUIState.getTargetTableFilters().getDistributionSet()
|
||||
@@ -746,16 +744,17 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void updateVisibleItemOnEvent(final TargetInfo targetInfo, final Target target,
|
||||
final TargetIdName targetIdName) {
|
||||
private void updateVisibleItemOnEvent(final TargetInfo targetInfo) {
|
||||
final Target target = targetInfo.getTarget();
|
||||
final TargetIdName targetIdName = target.getTargetIdName();
|
||||
|
||||
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final Item item = targetContainer.getItem(targetIdName);
|
||||
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName());
|
||||
if (targetInfo != null) {
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP)
|
||||
.setValue(HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n));
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus());
|
||||
}
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP)
|
||||
.setValue(HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n));
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus());
|
||||
}
|
||||
|
||||
private boolean isLastSelectedTarget(final TargetIdName targetIdName) {
|
||||
@@ -767,62 +766,30 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
* EventListener method which is called by the event bus to notify about a
|
||||
* list of {@link TargetInfoUpdateEvent}.
|
||||
*
|
||||
* @param targetInfoUpdateEvents
|
||||
* list of target info update event
|
||||
* @param updatedTargets
|
||||
* list of updated targets
|
||||
*/
|
||||
private void onTargetInfoUpdateEvents(final List<TargetInfoUpdateEvent> targetInfoUpdateEvents) {
|
||||
private void onTargetUpdateEvents(final List<Target> updatedTargets) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shoulTargetsUpdated = false;
|
||||
Target lastSelectedTarget = null;
|
||||
for (final TargetInfoUpdateEvent targetInfoUpdateEvent : targetInfoUpdateEvents) {
|
||||
final TargetInfo targetInfo = targetInfoUpdateEvent.getEntity();
|
||||
final Target target = targetInfo.getTarget();
|
||||
final TargetIdName targetIdName = target.getTargetIdName();
|
||||
if (Filters.or(getTargetTableFilters(target)).doFilter()) {
|
||||
shoulTargetsUpdated = true;
|
||||
} else {
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
updateVisibleItemOnEvent(targetInfo, target, targetIdName);
|
||||
}
|
||||
}
|
||||
// workaround until push is available for action history, re-select
|
||||
// the updated target so the action history gets refreshed.
|
||||
if (isLastSelectedTarget(targetIdName)) {
|
||||
lastSelectedTarget = target;
|
||||
}
|
||||
}
|
||||
if (shoulTargetsUpdated) {
|
||||
refreshTargets();
|
||||
}
|
||||
if (lastSelectedTarget != null) {
|
||||
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, lastSelectedTarget));
|
||||
}
|
||||
}
|
||||
|
||||
private void onTargetUpdateEvents(final List<TargetUpdatedEvent> events) {
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shoulTargetsUpdated = false;
|
||||
Target lastSelectedTarget = null;
|
||||
for (final TargetUpdatedEvent targetUpdatedEvent : events) {
|
||||
final Target target = targetUpdatedEvent.getEntity();
|
||||
final TargetIdName targetIdName = target.getTargetIdName();
|
||||
if (Filters.or(getTargetTableFilters(target)).doFilter()) {
|
||||
shoulTargetsUpdated = true;
|
||||
} else {
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
updateVisibleItemOnEvent(null, target, targetIdName);
|
||||
}
|
||||
}
|
||||
if (isLastSelectedTarget(targetIdName)) {
|
||||
lastSelectedTarget = target;
|
||||
}
|
||||
}
|
||||
if (shoulTargetsUpdated) {
|
||||
if (isFilterEnabled()) {
|
||||
LOG.debug("Filter enabled on UI {}. Refresh targets from database.", getUI().getUIId());
|
||||
refreshTargets();
|
||||
} else {
|
||||
updatedTargets.stream().filter(target -> visibleItemIds.contains(target.getTargetIdName()))
|
||||
.forEach(target -> updateVisibleItemOnEvent(target.getTargetInfo()));
|
||||
}
|
||||
if (lastSelectedTarget != null) {
|
||||
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, lastSelectedTarget));
|
||||
|
||||
// workaround until push is available for action
|
||||
// history, re-select
|
||||
// the updated target so the action history gets
|
||||
// refreshed.
|
||||
final Optional<Target> selected = updatedTargets.stream()
|
||||
.filter(target -> isLastSelectedTarget(target.getTargetIdName())).findAny();
|
||||
if (selected.isPresent()) {
|
||||
LOG.debug("Selected element has changed on UI {}. Reselect to update action history.", getUI().getUIId());
|
||||
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, selected.get()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,17 +797,11 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
refreshTargets();
|
||||
}
|
||||
|
||||
private List<FilterExpression> getTargetTableFilters(final Target target) {
|
||||
private boolean isFilterEnabled() {
|
||||
final TargetTableFilters targetTableFilters = managementUIState.getTargetTableFilters();
|
||||
final List<FilterExpression> filters = new ArrayList<>();
|
||||
if (targetTableFilters.getSearchText().isPresent()) {
|
||||
filters.add(new TargetSearchTextFilter(target, targetTableFilters.getSearchText().get()));
|
||||
}
|
||||
filters.add(new TargetStatusFilter(targetTableFilters.getClickedStatusTargetTags()));
|
||||
filters.add(new TargetTagFilter(target, targetTableFilters.getClickedTargetTags(),
|
||||
targetTableFilters.isNoTagSelected()));
|
||||
filters.add(new CustomTargetFilter(targetTableFilters.getTargetFilterQuery()));
|
||||
return filters;
|
||||
return targetTableFilters.getSearchText().isPresent() || !targetTableFilters.getClickedTargetTags().isEmpty()
|
||||
|| !targetTableFilters.getClickedStatusTargetTags().isEmpty()
|
||||
|| targetTableFilters.getTargetFilterQuery().isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
package org.eclipse.hawkbit.ui.management.targettag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
@@ -102,8 +101,7 @@ public class TargetFilterQueryButtons extends Table {
|
||||
protected LazyQueryContainer createButtonsLazyQueryContainer() {
|
||||
final BeanQueryFactory<TargetFilterBeanQuery> queryFactory = new BeanQueryFactory<>(
|
||||
TargetFilterBeanQuery.class);
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
queryFactory.setQueryConfiguration(queryConfig);
|
||||
queryFactory.setQueryConfiguration(Collections.emptyMap());
|
||||
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, "id"), queryFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.push;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.BlockingDeque;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -57,10 +57,11 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DelayedEventBusPushStrategy.class);
|
||||
|
||||
private static final int BLOCK_SIZE = 10_000;
|
||||
private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
||||
private final ScheduledExecutorService executorService;
|
||||
private final BlockingDeque<org.eclipse.hawkbit.eventbus.event.Event> queue = new LinkedBlockingDeque<>(BLOCK_SIZE);
|
||||
private final EventBus.SessionEventBus eventBus;
|
||||
private final com.google.common.eventbus.EventBus systemEventBus;
|
||||
private int uiid = -1;
|
||||
|
||||
private ScheduledFuture<?> jobHandle;
|
||||
|
||||
@@ -68,15 +69,20 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param executorService
|
||||
* for scheduled execution of event forwarding to the UI
|
||||
* @param eventBus
|
||||
* the session event bus to where the events should be dispatched
|
||||
* @param systemEventBus
|
||||
* the system event bus where to retrieve the events from the
|
||||
* back-end
|
||||
* @param eventProvider
|
||||
* for event delegation to UI
|
||||
*/
|
||||
public DelayedEventBusPushStrategy(final SessionEventBus eventBus,
|
||||
public DelayedEventBusPushStrategy(final ScheduledExecutorService executorService, final SessionEventBus eventBus,
|
||||
final com.google.common.eventbus.EventBus systemEventBus, final UIEventProvider eventProvider) {
|
||||
this.executorService = executorService;
|
||||
this.eventBus = eventBus;
|
||||
this.systemEventBus = systemEventBus;
|
||||
this.eventProvider = eventProvider;
|
||||
@@ -100,7 +106,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
}
|
||||
|
||||
if (!queue.offer(event)) {
|
||||
LOG.warn("Deque limit is reached, cannot add more events!!! Dropped event is {}", event);
|
||||
LOG.trace("Deque limit is reached, cannot add more events for UI {}! Dropped event is {}", uiid, event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +118,12 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
|
||||
@Override
|
||||
public void init(final UI vaadinUI) {
|
||||
LOG.debug("Initialize delayed event push strategy");
|
||||
uiid = vaadinUI.getUIId();
|
||||
LOG.info("Initialize delayed event push strategy for UI {}", uiid);
|
||||
if (vaadinUI.getSession() == null) {
|
||||
LOG.error("Vaadin session of UI {} is null! Event push disabled!", uiid);
|
||||
}
|
||||
|
||||
jobHandle = executorService.scheduleWithFixedDelay(new DispatchRunnable(vaadinUI, vaadinUI.getSession()), 500,
|
||||
2000, TimeUnit.MILLISECONDS);
|
||||
systemEventBus.register(this);
|
||||
@@ -120,10 +131,9 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
|
||||
@Override
|
||||
public void clean() {
|
||||
LOG.debug("Cleanup resources");
|
||||
jobHandle.cancel(true);
|
||||
LOG.info("Cleanup delayed event push strategy for UI", uiid);
|
||||
systemEventBus.unregister(this);
|
||||
executorService.shutdownNow();
|
||||
jobHandle.cancel(true);
|
||||
queue.clear();
|
||||
}
|
||||
|
||||
@@ -138,7 +148,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
* @return {@code true} if the event can be dispatched to the UI otherwise
|
||||
* {@code false}
|
||||
*/
|
||||
protected boolean eventSecurityCheck(final SecurityContext userContext,
|
||||
protected static boolean eventSecurityCheck(final SecurityContext userContext,
|
||||
final org.eclipse.hawkbit.eventbus.event.Event event) {
|
||||
if (userContext == null || userContext.getAuthentication() == null) {
|
||||
return false;
|
||||
@@ -163,27 +173,29 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("UI EventBus aggregator started");
|
||||
LOG.debug("UI EventBus aggregator started for UI {}", uiid);
|
||||
final long timestamp = System.currentTimeMillis();
|
||||
final List<org.eclipse.hawkbit.eventbus.event.Event> events = new LinkedList<>();
|
||||
for (int i = 0; i < BLOCK_SIZE; i++) {
|
||||
|
||||
final int size = queue.size();
|
||||
if (size <= 0) {
|
||||
LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", uiid);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<org.eclipse.hawkbit.eventbus.event.Event> events = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final org.eclipse.hawkbit.eventbus.event.Event pollEvent = queue.poll();
|
||||
if (pollEvent == null) {
|
||||
continue;
|
||||
}
|
||||
events.add(pollEvent);
|
||||
events.add(i, pollEvent);
|
||||
}
|
||||
|
||||
if (events.isEmpty()) {
|
||||
LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", uiid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vaadinSession == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.debug("UI EventBus aggregator session: {}", vaadinSession);
|
||||
|
||||
final WrappedSession wrappedSession = vaadinSession.getSession();
|
||||
if (wrappedSession == null) {
|
||||
return;
|
||||
@@ -191,10 +203,13 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
|
||||
final int eventsSize = events.size();
|
||||
|
||||
LOG.debug("UI EventBus aggregator dispatches {} events for session {} for UI {}", eventsSize, vaadinSession,
|
||||
uiid);
|
||||
|
||||
doDispatch(events, wrappedSession);
|
||||
|
||||
LOG.debug("UI EventBus aggregator done with sending {} events in {} ms", eventsSize,
|
||||
System.currentTimeMillis() - timestamp);
|
||||
LOG.debug("UI EventBus aggregator done with sending {} events in {} ms for UI {}", eventsSize,
|
||||
System.currentTimeMillis() - timestamp, uiid);
|
||||
|
||||
}
|
||||
|
||||
@@ -210,9 +225,13 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
if (vaadinSession.getState() != State.OPEN) {
|
||||
return;
|
||||
}
|
||||
LOG.debug("UI EventBus aggregator of UI {} got lock on session.", uiid);
|
||||
fowardSingleEvents(events, userContext);
|
||||
fowardBulkEvents(events, userContext);
|
||||
});
|
||||
LOG.debug("UI EventBus aggregator of UI {} left lock on session.", uiid);
|
||||
}).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
LOG.error("Wait for Vaadin session for UI {} interrupted!", uiid, e);
|
||||
} finally {
|
||||
SecurityContextHolder.setContext(oldContext);
|
||||
}
|
||||
@@ -222,10 +241,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
final SecurityContext userContext) {
|
||||
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
|
||||
publishBulkEvent(events, userContext, filterBulkEvenTypes);
|
||||
}
|
||||
|
||||
private void publishBulkEvent(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
||||
final SecurityContext userContext, final Set<Class<?>> filterBulkEvenTypes) {
|
||||
for (final Class<?> bulkType : filterBulkEvenTypes) {
|
||||
final List<org.eclipse.hawkbit.eventbus.event.Event> listBulkEvents = events.stream()
|
||||
.filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event)
|
||||
@@ -237,6 +253,11 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
private void publishBulkEvent(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
||||
final SecurityContext userContext, final Set<Class<?>> filterBulkEvenTypes) {
|
||||
|
||||
}
|
||||
|
||||
private void fowardSingleEvents(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
||||
final SecurityContext userContext) {
|
||||
events.stream()
|
||||
|
||||
@@ -21,7 +21,6 @@ import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_TOTAL_TARGET
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -57,6 +56,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.converter.Converter;
|
||||
@@ -495,7 +495,8 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
* Contains all expected rollout status per column to enable or disable
|
||||
* the button.
|
||||
*/
|
||||
private static final Map<String, RolloutStatus> EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON = new HashMap<>();
|
||||
private static final Map<String, RolloutStatus> EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON = Maps
|
||||
.newHashMapWithExpectedSize(2);
|
||||
private final Container.Indexed containerDataSource;
|
||||
|
||||
static {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
package org.eclipse.hawkbit.ui.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@@ -435,8 +435,7 @@ public final class HawkbitCommonUtil {
|
||||
*/
|
||||
public static LazyQueryContainer createLazyQueryContainer(
|
||||
final BeanQueryFactory<? extends AbstractBeanQuery<?>> queryFactory) {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
queryFactory.setQueryConfiguration(queryConfig);
|
||||
queryFactory.setQueryConfiguration(Collections.emptyMap());
|
||||
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), queryFactory);
|
||||
}
|
||||
|
||||
@@ -448,8 +447,7 @@ public final class HawkbitCommonUtil {
|
||||
*/
|
||||
public static LazyQueryContainer createDSLazyQueryContainer(
|
||||
final BeanQueryFactory<? extends AbstractBeanQuery<?>> queryFactory) {
|
||||
final Map<String, Object> queryConfig = new HashMap<>();
|
||||
queryFactory.setQueryConfiguration(queryConfig);
|
||||
queryFactory.setQueryConfiguration(Collections.emptyMap());
|
||||
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, "tagIdName"), queryFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.utils;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@@ -19,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.server.WebBrowser;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ import com.vaadin.server.WebBrowser;
|
||||
public final class SPDateTimeUtil {
|
||||
|
||||
private static final String DURATION_FORMAT = "y','M','d','H','m','s";
|
||||
private static final Map<Integer, CalendarI18N> DURATION_I18N = new HashMap<>();
|
||||
private static final Map<Integer, CalendarI18N> DURATION_I18N = Maps.newHashMapWithExpectedSize(6);
|
||||
|
||||
static {
|
||||
DURATION_I18N.put(0, CalendarI18N.YEAR);
|
||||
|
||||
Reference in New Issue
Block a user