Injectable UI target data suppliers (#1123)

* initial proposal for injectible target data provider

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* improved selection of first entity in grid

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* introduced constructor to explicitely set DataCommunicator for a Grid

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* made data communicator for target grid injectable

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* adapted size page request to load only one entity for getting total elements, fixed grid duplicates in case lastModified property is the same for targets and rollouts

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* DeleteSupport rethrows the exception to be intercepted by error handlers

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* minor grid refactoring

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* adapted docu for base data providers

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* added custom filter data provider, made filter effectively immutable by cloning before data refresh

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* grid returns size directly from data provider instead of data communicator

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* restructured data provider/communicator dependency injection, added injectable data supplier for target filter view grid

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* do not remove confirmation dialog window from UI explicitely

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* fixed sonar, added docs

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>
This commit is contained in:
Bondar Bogdan
2021-06-02 16:58:35 +02:00
committed by GitHub
parent df7b0701d7
commit 40b28e212d
50 changed files with 736 additions and 200 deletions

View File

@@ -8,8 +8,6 @@
*/ */
package org.eclipse.hawkbit.repository.jpa; package org.eclipse.hawkbit.repository.jpa;
import static org.springframework.data.domain.Sort.Direction;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -21,8 +19,8 @@ import javax.persistence.EntityManager;
import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.QuotaManagement; import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RolloutApprovalStrategy; import org.eclipse.hawkbit.repository.RolloutApprovalStrategy;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutExecutor; import org.eclipse.hawkbit.repository.RolloutExecutor;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutHelper; import org.eclipse.hawkbit.repository.RolloutHelper;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
@@ -60,6 +58,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionException;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -297,8 +296,7 @@ public class JpaRolloutExecutor implements RolloutExecutor {
if (hasScheduledActions) { if (hasScheduledActions) {
try { try {
final Iterable<JpaAction> iterable = scheduledActions::iterator; final Iterable<JpaAction> iterable = scheduledActions::iterator;
final List<Long> actionIds = StreamSupport.stream(iterable.spliterator(), false) final List<Long> actionIds = StreamSupport.stream(iterable.spliterator(), false).map(Action::getId)
.map(Action::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
actionRepository.deleteByIdIn(actionIds); actionRepository.deleteByIdIn(actionIds);
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
@@ -369,8 +367,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
private void updateTotalTargetCount(final JpaRolloutGroup rolloutGroup, final long countTargetsOfRolloutGroup) { private void updateTotalTargetCount(final JpaRolloutGroup rolloutGroup, final long countTargetsOfRolloutGroup) {
final JpaRollout jpaRollout = (JpaRollout) rolloutGroup.getRollout(); final JpaRollout jpaRollout = (JpaRollout) rolloutGroup.getRollout();
final long updatedTargetCount = final long updatedTargetCount = jpaRollout.getTotalTargets()
jpaRollout.getTotalTargets() - (rolloutGroup.getTotalTargets() - countTargetsOfRolloutGroup); - (rolloutGroup.getTotalTargets() - countTargetsOfRolloutGroup);
jpaRollout.setTotalTargets(updatedTargetCount); jpaRollout.setTotalTargets(updatedTargetCount);
rolloutGroup.setTotalTargets((int) countTargetsOfRolloutGroup); rolloutGroup.setTotalTargets((int) countTargetsOfRolloutGroup);
rolloutRepository.save(jpaRollout); rolloutRepository.save(jpaRollout);
@@ -394,9 +392,9 @@ public class JpaRolloutExecutor implements RolloutExecutor {
private boolean isRolloutGroupComplete(final JpaRollout rollout, final JpaRolloutGroup rolloutGroup) { private boolean isRolloutGroupComplete(final JpaRollout rollout, final JpaRolloutGroup rolloutGroup) {
final Long actionsLeftForRollout = ActionType.DOWNLOAD_ONLY == rollout.getActionType() final Long actionsLeftForRollout = ActionType.DOWNLOAD_ONLY == rollout.getActionType()
? actionRepository.countByRolloutAndRolloutGroupAndStatusNotIn(rollout, rolloutGroup, ? actionRepository.countByRolloutAndRolloutGroupAndStatusNotIn(rollout, rolloutGroup,
DOWNLOAD_ONLY_ACTION_TERMINATION_STATUSES) DOWNLOAD_ONLY_ACTION_TERMINATION_STATUSES)
: actionRepository.countByRolloutAndRolloutGroupAndStatusNotIn(rollout, rolloutGroup, : actionRepository.countByRolloutAndRolloutGroupAndStatusNotIn(rollout, rolloutGroup,
DEFAULT_ACTION_TERMINATION_STATUSES); DEFAULT_ACTION_TERMINATION_STATUSES);
return actionsLeftForRollout == 0; return actionsLeftForRollout == 0;
} }
@@ -440,8 +438,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
} }
private void executeRolloutGroupSuccessAction(final Rollout rollout, final RolloutGroup rolloutGroup) { private void executeRolloutGroupSuccessAction(final Rollout rollout, final RolloutGroup rolloutGroup) {
context.getBean(rolloutGroup.getSuccessAction().getBeanName(), RolloutGroupActionEvaluator.class) context.getBean(rolloutGroup.getSuccessAction().getBeanName(), RolloutGroupActionEvaluator.class).eval(rollout,
.eval(rollout, rolloutGroup, rolloutGroup.getSuccessActionExp()); rolloutGroup, rolloutGroup.getSuccessActionExp());
} }
private void startFirstRolloutGroup(final Rollout rollout) { private void startFirstRolloutGroup(final Rollout rollout) {
@@ -496,7 +494,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
final long targetsInGroupFilter = DeploymentHelper.runInNewTransaction(txManager, final long targetsInGroupFilter = DeploymentHelper.runInNewTransaction(txManager,
"countAllTargetsByTargetFilterQueryAndNotInRolloutGroups", "countAllTargetsByTargetFilterQueryAndNotInRolloutGroups",
count -> targetManagement.countByRsqlAndNotInRolloutGroups(readyGroups, groupTargetFilter)); count -> targetManagement.countByRsqlAndNotInRolloutGroups(readyGroups, groupTargetFilter));
final long expectedInGroup = Math.round(group.getTargetPercentage() / 100 * (double) targetsInGroupFilter); final long expectedInGroup = Math
.round((double) (group.getTargetPercentage() / 100) * (double) targetsInGroupFilter);
final long currentlyInGroup = DeploymentHelper.runInNewTransaction(txManager, final long currentlyInGroup = DeploymentHelper.runInNewTransaction(txManager,
"countRolloutTargetGroupByRolloutGroup", "countRolloutTargetGroupByRolloutGroup",
count -> rolloutTargetGroupRepository.countByRolloutGroup(group)); count -> rolloutTargetGroupRepository.countByRolloutGroup(group));
@@ -573,7 +572,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
try { try {
long actionsCreated; long actionsCreated;
do { do {
actionsCreated = createActionsForTargetsInNewTransaction(rollout.getId(), group.getId(), TRANSACTION_TARGETS); actionsCreated = createActionsForTargetsInNewTransaction(rollout.getId(), group.getId(),
TRANSACTION_TARGETS);
totalActionsCreated += actionsCreated; totalActionsCreated += actionsCreated;
} while (actionsCreated > 0); } while (actionsCreated > 0);
@@ -584,8 +584,7 @@ public class JpaRolloutExecutor implements RolloutExecutor {
return totalActionsCreated; return totalActionsCreated;
} }
private Long createActionsForTargetsInNewTransaction(final long rolloutId, final long groupId, private Long createActionsForTargetsInNewTransaction(final long rolloutId, final long groupId, final int limit) {
final int limit) {
return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> { return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> {
final PageRequest pageRequest = PageRequest.of(0, limit); final PageRequest pageRequest = PageRequest.of(0, limit);
final Rollout rollout = rolloutRepository.findById(rolloutId) final Rollout rollout = rolloutRepository.findById(rolloutId)

View File

@@ -11,6 +11,12 @@ package org.eclipse.hawkbit.ui;
import java.util.List; import java.util.List;
import org.eclipse.hawkbit.im.authentication.PermissionService; import org.eclipse.hawkbit.im.authentication.PermissionService;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.common.data.mappers.TargetToProxyTargetMapper;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetFilterStateDataSupplier;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetFilterStateDataSupplierImpl;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetManagementStateDataSupplier;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetManagementStateDataSupplierImpl;
import org.eclipse.hawkbit.ui.error.HawkbitUIErrorHandler; import org.eclipse.hawkbit.ui.error.HawkbitUIErrorHandler;
import org.eclipse.hawkbit.ui.error.extractors.ConstraintViolationErrorExtractor; import org.eclipse.hawkbit.ui.error.extractors.ConstraintViolationErrorExtractor;
import org.eclipse.hawkbit.ui.error.extractors.UiErrorDetailsExtractor; import org.eclipse.hawkbit.ui.error.extractors.UiErrorDetailsExtractor;
@@ -28,6 +34,7 @@ import org.vaadin.spring.servlet.Vaadin4SpringServlet;
import com.vaadin.server.ErrorHandler; import com.vaadin.server.ErrorHandler;
import com.vaadin.server.SystemMessagesProvider; import com.vaadin.server.SystemMessagesProvider;
import com.vaadin.server.VaadinServlet; import com.vaadin.server.VaadinServlet;
import com.vaadin.spring.annotation.UIScope;
/** /**
* Enables UI components for the Management UI. * Enables UI components for the Management UI.
@@ -95,11 +102,21 @@ public class MgmtUiConfiguration {
return new HawkbitUIErrorHandler(i18n, uiErrorDetailsExtractor); return new HawkbitUIErrorHandler(i18n, uiErrorDetailsExtractor);
} }
/**
* UI Upload Error details extractor bean.
*
* @return UI Upload Error details extractor
*/
@Bean @Bean
UiErrorDetailsExtractor uploadErrorExtractor() { UiErrorDetailsExtractor uploadErrorExtractor() {
return new UploadErrorExtractor(); return new UploadErrorExtractor();
} }
/**
* UI ConstraintViolation Error details extractor bean.
*
* @return UI ConstraintViolation Error details extractor
*/
@Bean @Bean
UiErrorDetailsExtractor constraintViolationErrorExtractor(final VaadinMessageSource i18n) { UiErrorDetailsExtractor constraintViolationErrorExtractor(final VaadinMessageSource i18n) {
return new ConstraintViolationErrorExtractor(i18n); return new ConstraintViolationErrorExtractor(i18n);
@@ -114,4 +131,40 @@ public class MgmtUiConfiguration {
public VaadinServlet vaadinServlet() { public VaadinServlet vaadinServlet() {
return new Vaadin4SpringServlet(); return new Vaadin4SpringServlet();
} }
/**
* UI target entity mapper bean.
*
* @return UI target entity mapper
*/
@Bean
public TargetToProxyTargetMapper targetToProxyTargetMapper(final VaadinMessageSource i18n) {
return new TargetToProxyTargetMapper(i18n);
}
/**
* UI Management target data supplier bean.
*
* @return UI target data supplier for Management view
*/
@Bean
@ConditionalOnMissingBean
@UIScope
public TargetManagementStateDataSupplier targetManagementStateDataSupplier(final TargetManagement targetManagement,
final TargetToProxyTargetMapper targetToProxyTargetMapper) {
return new TargetManagementStateDataSupplierImpl(targetManagement, targetToProxyTargetMapper);
}
/**
* UI Filter target data supplier bean.
*
* @return UI target data supplier for Filter view
*/
@Bean
@ConditionalOnMissingBean
@UIScope
public TargetFilterStateDataSupplier targetFilterStateDataSupplier(final TargetManagement targetManagement,
final TargetToProxyTargetMapper targetToProxyTargetMapper) {
return new TargetFilterStateDataSupplierImpl(targetManagement, targetToProxyTargetMapper);
}
} }

View File

@@ -84,9 +84,9 @@ public class SoftwareModuleGrid extends AbstractGrid<ProxySoftwareModule, SwFilt
* @param view * @param view
* EventView * EventView
*/ */
public SoftwareModuleGrid(final CommonUiDependencies uiDependencies, final TypeFilterLayoutUiState smTypeFilterLayoutUiState, public SoftwareModuleGrid(final CommonUiDependencies uiDependencies,
final GridLayoutUiState smGridLayoutUiState, final SoftwareModuleManagement softwareModuleManagement, final TypeFilterLayoutUiState smTypeFilterLayoutUiState, final GridLayoutUiState smGridLayoutUiState,
final EventView view) { final SoftwareModuleManagement softwareModuleManagement, final EventView view) {
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker()); super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
this.smTypeFilterLayoutUiState = smTypeFilterLayoutUiState; this.smTypeFilterLayoutUiState = smTypeFilterLayoutUiState;
@@ -95,8 +95,8 @@ public class SoftwareModuleGrid extends AbstractGrid<ProxySoftwareModule, SwFilt
this.softwareModuleManagement = softwareModuleManagement; this.softwareModuleManagement = softwareModuleManagement;
this.softwareModuleToProxyMapper = new SoftwareModuleToProxyMapper(); this.softwareModuleToProxyMapper = new SoftwareModuleToProxyMapper();
setSelectionSupport(new SelectionSupport<ProxySoftwareModule>(this, eventBus, EventLayout.SM_LIST, view, setSelectionSupport(new SelectionSupport<>(this, eventBus, EventLayout.SM_LIST, view, this::mapIdToProxyEntity,
this::mapIdToProxyEntity, this::getSelectedEntityIdFromUiState, this::setSelectedEntityIdToUiState)); this::getSelectedEntityIdFromUiState, this::setSelectedEntityIdToUiState));
if (smGridLayoutUiState.isMaximized()) { if (smGridLayoutUiState.isMaximized()) {
getSelectionSupport().disableSelection(); getSelectionSupport().disableSelection();
} else { } else {
@@ -110,7 +110,7 @@ public class SoftwareModuleGrid extends AbstractGrid<ProxySoftwareModule, SwFilt
setFilterSupport(new FilterSupport<>( setFilterSupport(new FilterSupport<>(
new SoftwareModuleDataProvider(softwareModuleManagement, new SoftwareModuleDataProvider(softwareModuleManagement,
new AssignedSoftwareModuleToProxyMapper(softwareModuleToProxyMapper)), new AssignedSoftwareModuleToProxyMapper(softwareModuleToProxyMapper)),
getSelectionSupport()::deselectAll)); SwFilterParams::new, getSelectionSupport()::deselectAll));
initFilterMappings(); initFilterMappings();
getFilterSupport().setFilter(new SwFilterParams()); getFilterSupport().setFilter(new SwFilterParams());

View File

@@ -26,7 +26,6 @@ import com.vaadin.server.Sizeable.Unit;
import com.vaadin.shared.ui.ContentMode; import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@@ -138,9 +137,6 @@ public class ConfirmationDialog implements Serializable {
return new SaveDialogCloseListener() { return new SaveDialogCloseListener() {
@Override @Override
public void saveOrUpdate() { public void saveOrUpdate() {
if (window.getParent() != null) {
UI.getCurrent().removeWindow(window);
}
callback.accept(true); callback.accept(true);
} }

View File

@@ -8,6 +8,8 @@
*/ */
package org.eclipse.hawkbit.ui.common.data.filters; package org.eclipse.hawkbit.ui.common.data.filters;
import java.util.Objects;
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetDistributionsStateDataProvider; import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetDistributionsStateDataProvider;
/** /**
@@ -38,6 +40,17 @@ public class DsDistributionsFilterParams extends DsFilterParams {
this.dsTypeId = dsTypeId; this.dsTypeId = dsTypeId;
} }
/**
* Copy Constructor.
*
* @param filter
* A filter to be copied
*/
public DsDistributionsFilterParams(final DsDistributionsFilterParams filter) {
super(filter);
this.dsTypeId = filter.getDsTypeId();
}
/** /**
* @return DsTypeId * @return DsTypeId
*/ */
@@ -54,4 +67,22 @@ public class DsDistributionsFilterParams extends DsFilterParams {
public void setDsTypeId(final Long dsTypeId) { public void setDsTypeId(final Long dsTypeId) {
this.dsTypeId = dsTypeId; this.dsTypeId = dsTypeId;
} }
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DsDistributionsFilterParams other = (DsDistributionsFilterParams) obj;
return Objects.equals(this.getSearchText(), other.getSearchText())
&& Objects.equals(this.getDsTypeId(), other.getDsTypeId());
}
@Override
public int hashCode() {
return Objects.hash(getSearchText(), getDsTypeId());
}
} }

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.common.data.filters; package org.eclipse.hawkbit.ui.common.data.filters;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects;
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetManagementStateDataProvider; import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetManagementStateDataProvider;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -38,6 +39,16 @@ public class DsFilterParams implements Serializable {
this.searchText = searchText; this.searchText = searchText;
} }
/**
* Copy Constructor.
*
* @param filter
* A filter to be copied
*/
public DsFilterParams(final DsFilterParams filter) {
this.searchText = filter.getSearchText();
}
/** /**
* @return SearchText * @return SearchText
*/ */
@@ -55,4 +66,20 @@ public class DsFilterParams implements Serializable {
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null; this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
} }
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DsFilterParams other = (DsFilterParams) obj;
return Objects.equals(this.getSearchText(), other.getSearchText());
}
@Override
public int hashCode() {
return Objects.hash(getSearchText());
}
} }

View File

@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.common.data.filters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.Objects;
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetManagementStateDataProvider; import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetManagementStateDataProvider;
@@ -44,13 +44,28 @@ public class DsManagementFilterParams extends DsFilterParams {
* String as pinned target controller Id * String as pinned target controller Id
*/ */
public DsManagementFilterParams(final String searchText, final boolean noTagClicked, public DsManagementFilterParams(final String searchText, final boolean noTagClicked,
final List<String> distributionSetTags, final String pinnedTargetControllerId) { final Collection<String> distributionSetTags, final String pinnedTargetControllerId) {
super(searchText); super(searchText);
this.noTagClicked = noTagClicked; this.noTagClicked = noTagClicked;
this.distributionSetTags = distributionSetTags; this.distributionSetTags = distributionSetTags;
this.pinnedTargetControllerId = pinnedTargetControllerId; this.pinnedTargetControllerId = pinnedTargetControllerId;
} }
/**
* Copy Constructor.
*
* @param filter
* A filter to be copied
*/
public DsManagementFilterParams(final DsManagementFilterParams filter) {
super(filter);
this.noTagClicked = filter.isNoTagClicked();
this.distributionSetTags = filter.getDistributionSetTags() != null
? new ArrayList<>(filter.getDistributionSetTags())
: null;
this.pinnedTargetControllerId = filter.getPinnedTargetControllerId();
}
/** /**
* @return DistributionSetTags * @return DistributionSetTags
*/ */
@@ -101,4 +116,24 @@ public class DsManagementFilterParams extends DsFilterParams {
public void setNoTagClicked(final boolean noTagClicked) { public void setNoTagClicked(final boolean noTagClicked) {
this.noTagClicked = noTagClicked; this.noTagClicked = noTagClicked;
} }
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DsManagementFilterParams other = (DsManagementFilterParams) obj;
return Objects.equals(this.getSearchText(), other.getSearchText())
&& Objects.equals(this.isNoTagClicked(), other.isNoTagClicked())
&& Objects.equals(this.getDistributionSetTags(), other.getDistributionSetTags())
&& Objects.equals(this.getPinnedTargetControllerId(), other.getPinnedTargetControllerId());
}
@Override
public int hashCode() {
return Objects.hash(getSearchText(), isNoTagClicked(), getDistributionSetTags(), getPinnedTargetControllerId());
}
} }

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.common.data.filters; package org.eclipse.hawkbit.ui.common.data.filters;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects;
import org.eclipse.hawkbit.ui.common.data.providers.SoftwareModuleDataProvider; import org.eclipse.hawkbit.ui.common.data.providers.SoftwareModuleDataProvider;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -34,11 +35,11 @@ public class SwFilterParams implements Serializable {
* Constructor. * Constructor.
* *
* @param searchText * @param searchText
* String as search text * String as search text
* @param softwareModuleTypeId * @param softwareModuleTypeId
* Long as software module Id * Long as software module Id
* @param lastSelectedDistributionId * @param lastSelectedDistributionId
* Long as Last selected Distribution Id * Long as Last selected Distribution Id
*/ */
public SwFilterParams(final String searchText, final Long softwareModuleTypeId, public SwFilterParams(final String searchText, final Long softwareModuleTypeId,
final Long lastSelectedDistributionId) { final Long lastSelectedDistributionId) {
@@ -47,6 +48,18 @@ public class SwFilterParams implements Serializable {
this.lastSelectedDistributionId = lastSelectedDistributionId; this.lastSelectedDistributionId = lastSelectedDistributionId;
} }
/**
* Copy Constructor.
*
* @param filter
* A filter to be copied
*/
public SwFilterParams(final SwFilterParams filter) {
this.searchText = filter.getSearchText();
this.softwareModuleTypeId = filter.getSoftwareModuleTypeId();
this.lastSelectedDistributionId = filter.getLastSelectedDistributionId();
}
/** /**
* Get SearchText * Get SearchText
* *
@@ -60,7 +73,7 @@ public class SwFilterParams implements Serializable {
* Setter for searchText * Setter for searchText
* *
* @param searchText * @param searchText
* String * String
*/ */
public void setSearchText(final String searchText) { public void setSearchText(final String searchText) {
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null; this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
@@ -79,7 +92,7 @@ public class SwFilterParams implements Serializable {
* Setter for softwareModuleTypeId * Setter for softwareModuleTypeId
* *
* @param softwareModuleTypeId * @param softwareModuleTypeId
* Long * Long
*/ */
public void setSoftwareModuleTypeId(final Long softwareModuleTypeId) { public void setSoftwareModuleTypeId(final Long softwareModuleTypeId) {
this.softwareModuleTypeId = softwareModuleTypeId; this.softwareModuleTypeId = softwareModuleTypeId;
@@ -98,9 +111,28 @@ public class SwFilterParams implements Serializable {
* Setter for lastSelectedDistributionId * Setter for lastSelectedDistributionId
* *
* @param lastSelectedDistributionId * @param lastSelectedDistributionId
* Long * Long
*/ */
public void setLastSelectedDistributionId(final Long lastSelectedDistributionId) { public void setLastSelectedDistributionId(final Long lastSelectedDistributionId) {
this.lastSelectedDistributionId = lastSelectedDistributionId; this.lastSelectedDistributionId = lastSelectedDistributionId;
} }
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final SwFilterParams other = (SwFilterParams) obj;
return Objects.equals(this.getSearchText(), other.getSearchText())
&& Objects.equals(this.getSoftwareModuleTypeId(), other.getSoftwareModuleTypeId())
&& Objects.equals(this.getLastSelectedDistributionId(), other.getLastSelectedDistributionId());
}
@Override
public int hashCode() {
return Objects.hash(getSearchText(), getSoftwareModuleTypeId(), getLastSelectedDistributionId());
}
} }

View File

@@ -9,8 +9,10 @@
package org.eclipse.hawkbit.ui.common.data.filters; package org.eclipse.hawkbit.ui.common.data.filters;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Objects;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.data.providers.TargetManagementStateDataProvider; import org.eclipse.hawkbit.ui.common.data.providers.TargetManagementStateDataProvider;
@@ -43,21 +45,21 @@ public class TargetManagementFilterParams implements Serializable {
* Constructor. * Constructor.
* *
* @param pinnedDistId * @param pinnedDistId
* Id for Pinned distribution * Id for Pinned distribution
* @param searchText * @param searchText
* String as search text * String as search text
* @param targetUpdateStatusList * @param targetUpdateStatusList
* Collection of TargetUpdateStatus * Collection of TargetUpdateStatus
* @param overdueState * @param overdueState
* boolean * boolean
* @param distributionId * @param distributionId
* Long * Long
* @param noTagClicked * @param noTagClicked
* boolean * boolean
* @param targetTags * @param targetTags
* Collection of string as target tags * Collection of string as target tags
* @param targetFilterQueryId * @param targetFilterQueryId
* Id for target filter query * Id for target filter query
*/ */
public TargetManagementFilterParams(final Long pinnedDistId, final String searchText, public TargetManagementFilterParams(final Long pinnedDistId, final String searchText,
final Collection<TargetUpdateStatus> targetUpdateStatusList, final boolean overdueState, final Collection<TargetUpdateStatus> targetUpdateStatusList, final boolean overdueState,
@@ -73,12 +75,30 @@ public class TargetManagementFilterParams implements Serializable {
this.targetFilterQueryId = targetFilterQueryId; this.targetFilterQueryId = targetFilterQueryId;
} }
/**
* Copy Constructor.
*
* @param filter
* A filter to be copied
*/
public TargetManagementFilterParams(final TargetManagementFilterParams filter) {
this.pinnedDistId = filter.getPinnedDistId();
this.searchText = filter.getSearchText();
this.targetUpdateStatusList = filter.getTargetUpdateStatusList() != null
? new ArrayList<>(filter.getTargetUpdateStatusList())
: null;
this.overdueState = filter.isOverdueState();
this.distributionId = filter.getDistributionId();
this.noTagClicked = filter.isNoTagClicked();
this.targetTags = filter.getTargetTags() != null ? new ArrayList<>(filter.getTargetTags()) : null;
this.targetFilterQueryId = filter.getTargetFilterQueryId();
}
/** /**
* Gets the flag that indicates if the filter is selected * Gets the flag that indicates if the filter is selected
* *
* @return boolean * @return boolean <code>true</code> if the filter is selected, otherwise
* <code>true</code> if the filter is selected, otherwise * <code>false</code>
* <code>false</code>
*/ */
public boolean isAnyFilterSelected() { public boolean isAnyFilterSelected() {
return isAnyTagSelected() || isAnyStatusFilterSelected() || isSearchActive() || isAnyComplexFilterSelected(); return isAnyTagSelected() || isAnyStatusFilterSelected() || isSearchActive() || isAnyComplexFilterSelected();
@@ -113,7 +133,7 @@ public class TargetManagementFilterParams implements Serializable {
* Sets the pinnedDistId * Sets the pinnedDistId
* *
* @param pinnedDistId * @param pinnedDistId
* Id for pinned distribution * Id for pinned distribution
*/ */
public void setPinnedDistId(final Long pinnedDistId) { public void setPinnedDistId(final Long pinnedDistId) {
this.pinnedDistId = pinnedDistId; this.pinnedDistId = pinnedDistId;
@@ -132,7 +152,7 @@ public class TargetManagementFilterParams implements Serializable {
* Sets the searchText * Sets the searchText
* *
* @param searchText * @param searchText
* Text for search * Text for search
*/ */
public void setSearchText(final String searchText) { public void setSearchText(final String searchText) {
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null; this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
@@ -151,7 +171,7 @@ public class TargetManagementFilterParams implements Serializable {
* Sets the targetUpdateStatusList * Sets the targetUpdateStatusList
* *
* @param targetUpdateStatusList * @param targetUpdateStatusList
* Collection of targetUpdateStatus * Collection of targetUpdateStatus
*/ */
public void setTargetUpdateStatusList(final Collection<TargetUpdateStatus> targetUpdateStatusList) { public void setTargetUpdateStatusList(final Collection<TargetUpdateStatus> targetUpdateStatusList) {
this.targetUpdateStatusList = targetUpdateStatusList; this.targetUpdateStatusList = targetUpdateStatusList;
@@ -170,7 +190,7 @@ public class TargetManagementFilterParams implements Serializable {
* Sets the distributionId * Sets the distributionId
* *
* @param distributionId * @param distributionId
* Distribution Id * Distribution Id
*/ */
public void setDistributionId(final Long distributionId) { public void setDistributionId(final Long distributionId) {
this.distributionId = distributionId; this.distributionId = distributionId;
@@ -189,7 +209,7 @@ public class TargetManagementFilterParams implements Serializable {
* Sets the targetTags * Sets the targetTags
* *
* @param targetTags * @param targetTags
* Collection of targetTags * Collection of targetTags
*/ */
public void setTargetTags(final Collection<String> targetTags) { public void setTargetTags(final Collection<String> targetTags) {
this.targetTags = targetTags; this.targetTags = targetTags;
@@ -198,8 +218,7 @@ public class TargetManagementFilterParams implements Serializable {
/** /**
* Gets the targetFilterQueryId * Gets the targetFilterQueryId
* *
* @return targetFilterQueryId * @return targetFilterQueryId Id for target filter query
* Id for target filter query
*/ */
public Long getTargetFilterQueryId() { public Long getTargetFilterQueryId() {
return targetFilterQueryId; return targetFilterQueryId;
@@ -209,7 +228,7 @@ public class TargetManagementFilterParams implements Serializable {
* Sets the targetFilterQueryId * Sets the targetFilterQueryId
* *
* @param targetFilterQueryId * @param targetFilterQueryId
* Id for target filter query * Id for target filter query
*/ */
public void setTargetFilterQueryId(final Long targetFilterQueryId) { public void setTargetFilterQueryId(final Long targetFilterQueryId) {
this.targetFilterQueryId = targetFilterQueryId; this.targetFilterQueryId = targetFilterQueryId;
@@ -218,9 +237,8 @@ public class TargetManagementFilterParams implements Serializable {
/** /**
* Gets the state of overdue * Gets the state of overdue
* *
* @return overdueState * @return overdueState <code>true</code> if the state is set, otherwise
* <code>true</code> if the state is set, otherwise * <code>false</code>
* <code>false</code>
*/ */
public boolean isOverdueState() { public boolean isOverdueState() {
return overdueState; return overdueState;
@@ -240,9 +258,8 @@ public class TargetManagementFilterParams implements Serializable {
/** /**
* Gets the status of tag clicked * Gets the status of tag clicked
* *
* @return noTagClicked * @return noTagClicked <code>true</code> if the tag is clicked, otherwise
* <code>true</code> if the tag is clicked, otherwise * <code>false</code>
* <code>false</code>
*/ */
public boolean isNoTagClicked() { public boolean isNoTagClicked() {
return noTagClicked; return noTagClicked;
@@ -258,4 +275,31 @@ public class TargetManagementFilterParams implements Serializable {
public void setNoTagClicked(final boolean noTagClicked) { public void setNoTagClicked(final boolean noTagClicked) {
this.noTagClicked = noTagClicked; this.noTagClicked = noTagClicked;
} }
// equals requires all fields in condition
@SuppressWarnings("squid:S1067")
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TargetManagementFilterParams other = (TargetManagementFilterParams) obj;
return Objects.equals(this.getPinnedDistId(), other.getPinnedDistId())
&& Objects.equals(this.getSearchText(), other.getSearchText())
&& Objects.equals(this.getTargetUpdateStatusList(), other.getTargetUpdateStatusList())
&& Objects.equals(this.isOverdueState(), other.isOverdueState())
&& Objects.equals(this.getDistributionId(), other.getDistributionId())
&& Objects.equals(this.isNoTagClicked(), other.isNoTagClicked())
&& Objects.equals(this.getTargetTags(), other.getTargetTags())
&& Objects.equals(this.getTargetFilterQueryId(), other.getTargetFilterQueryId());
}
@Override
public int hashCode() {
return Objects.hash(getPinnedDistId(), getSearchText(), getTargetUpdateStatusList(), isOverdueState(),
getDistributionId(), isNoTagClicked(), getTargetTags(), getTargetFilterQueryId());
}
} }

View File

@@ -27,11 +27,11 @@ import com.vaadin.data.provider.Query;
* {@link ProxyIdentifiableEntity} entities. * {@link ProxyIdentifiableEntity} entities.
* *
* @param <T> * @param <T>
* Generic type of ProxyIdentifiableEntity * UI Proxy entity type
* @param <U> * @param <U>
* Generic type * Backend entity type
* @param <F> * @param <F>
* Generic type * Filter type
*/ */
public abstract class AbstractGenericDataProvider<T extends ProxyIdentifiableEntity, U, F> public abstract class AbstractGenericDataProvider<T extends ProxyIdentifiableEntity, U, F>
extends AbstractBackEndDataProvider<T, F> { extends AbstractBackEndDataProvider<T, F> {
@@ -45,9 +45,9 @@ public abstract class AbstractGenericDataProvider<T extends ProxyIdentifiableEnt
* Constructor for GenericDataProvider * Constructor for GenericDataProvider
* *
* @param defaultSortOrder * @param defaultSortOrder
* Sort * Sort
*/ */
public AbstractGenericDataProvider(final Sort defaultSortOrder) { protected AbstractGenericDataProvider(final Sort defaultSortOrder) {
this.defaultSortOrder = defaultSortOrder; this.defaultSortOrder = defaultSortOrder;
} }

View File

@@ -22,11 +22,11 @@ import org.springframework.data.domain.Sort.Direction;
* mapping them to {@link ProxyIdentifiableEntity} entities. * mapping them to {@link ProxyIdentifiableEntity} entities.
* *
* @param <T> * @param <T>
* Generic type of ProxyIdentifiableEntity * UI Proxy entity type
* @param <U> * @param <U>
* Generic type of Identifiable * Backend entity Identifiable type
* @param <F> * @param <F>
* Generic type * Filter type
*/ */
public abstract class AbstractProxyDataProvider<T extends ProxyIdentifiableEntity, U extends Identifiable<Long>, F> public abstract class AbstractProxyDataProvider<T extends ProxyIdentifiableEntity, U extends Identifiable<Long>, F>
extends AbstractGenericDataProvider<T, U, F> { extends AbstractGenericDataProvider<T, U, F> {
@@ -38,9 +38,9 @@ public abstract class AbstractProxyDataProvider<T extends ProxyIdentifiableEntit
* Constructor for ProxyDataProvider with mapper * Constructor for ProxyDataProvider with mapper
* *
* @param mapper * @param mapper
* IdentifiableEntityToProxyIdentifiableEntityMapper of generic type * mapper from backend entity to UI Proxy entity
*/ */
public AbstractProxyDataProvider(final IdentifiableEntityToProxyIdentifiableEntityMapper<T, U> mapper) { protected AbstractProxyDataProvider(final IdentifiableEntityToProxyIdentifiableEntityMapper<T, U> mapper) {
this(mapper, Sort.by(Direction.ASC, "id")); this(mapper, Sort.by(Direction.ASC, "id"));
} }
@@ -48,11 +48,11 @@ public abstract class AbstractProxyDataProvider<T extends ProxyIdentifiableEntit
* Constructor for ProxyDataProvider with mapper and sorting order * Constructor for ProxyDataProvider with mapper and sorting order
* *
* @param mapper * @param mapper
* IdentifiableEntityToProxyIdentifiableEntityMapper of generic type * mapper from backend entity to UI Proxy entity
* @param defaultSortOrder * @param defaultSortOrder
* Sort * Sort
*/ */
public AbstractProxyDataProvider(final IdentifiableEntityToProxyIdentifiableEntityMapper<T, U> mapper, protected AbstractProxyDataProvider(final IdentifiableEntityToProxyIdentifiableEntityMapper<T, U> mapper,
final Sort defaultSortOrder) { final Sort defaultSortOrder) {
super(defaultSortOrder); super(defaultSortOrder);

View File

@@ -34,9 +34,9 @@ public class ActionStatusDataProvider extends AbstractProxyDataProvider<ProxyAct
* Constructor for ActionStatusDataProvider * Constructor for ActionStatusDataProvider
* *
* @param deploymentManagement * @param deploymentManagement
* DeploymentManagement * DeploymentManagement
* @param entityMapper * @param entityMapper
* ActionStatusToProxyActionStatusMapper * ActionStatusToProxyActionStatusMapper
*/ */
public ActionStatusDataProvider(final DeploymentManagement deploymentManagement, public ActionStatusDataProvider(final DeploymentManagement deploymentManagement,
final ActionStatusToProxyActionStatusMapper entityMapper) { final ActionStatusToProxyActionStatusMapper entityMapper) {
@@ -61,6 +61,6 @@ public class ActionStatusDataProvider extends AbstractProxyDataProvider<ProxyAct
return 0L; return 0L;
} }
return loadBackendEntities(pageRequest, actionId).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), actionId).getTotalElements();
} }
} }

View File

@@ -38,9 +38,9 @@ public class ActionStatusMsgDataProvider extends AbstractGenericDataProvider<Pro
* Constructor for ActionStatusMsgDataProvider * Constructor for ActionStatusMsgDataProvider
* *
* @param deploymentManagement * @param deploymentManagement
* DeploymentManagement * DeploymentManagement
* @param noMessageText * @param noMessageText
* Message not available text * Message not available text
*/ */
public ActionStatusMsgDataProvider(final DeploymentManagement deploymentManagement, final String noMessageText) { public ActionStatusMsgDataProvider(final DeploymentManagement deploymentManagement, final String noMessageText) {
this(deploymentManagement, noMessageText, Sort.by(Direction.DESC, "id")); this(deploymentManagement, noMessageText, Sort.by(Direction.DESC, "id"));
@@ -50,11 +50,11 @@ public class ActionStatusMsgDataProvider extends AbstractGenericDataProvider<Pro
* Constructor for ActionStatusMsgDataProvider to call super class * Constructor for ActionStatusMsgDataProvider to call super class
* *
* @param deploymentManagement * @param deploymentManagement
* DeploymentManagement * DeploymentManagement
* @param noMessageText * @param noMessageText
* Message not available text * Message not available text
* @param defaultSortOrder * @param defaultSortOrder
* Sort * Sort
*/ */
public ActionStatusMsgDataProvider(final DeploymentManagement deploymentManagement, final String noMessageText, public ActionStatusMsgDataProvider(final DeploymentManagement deploymentManagement, final String noMessageText,
final Sort defaultSortOrder) { final Sort defaultSortOrder) {
@@ -105,6 +105,6 @@ public class ActionStatusMsgDataProvider extends AbstractGenericDataProvider<Pro
return 0L; return 0L;
} }
return loadBackendEntities(pageRequest, actionStatusId).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), actionStatusId).getTotalElements();
} }
} }

View File

@@ -33,9 +33,9 @@ public class ArtifactDataProvider extends AbstractProxyDataProvider<ProxyArtifac
* Constructor for ArtifactDataProvider * Constructor for ArtifactDataProvider
* *
* @param artifactManagement * @param artifactManagement
* ArtifactManagement * ArtifactManagement
* @param entityMapper * @param entityMapper
* ArtifactToProxyArtifactMapper * ArtifactToProxyArtifactMapper
*/ */
public ArtifactDataProvider(final ArtifactManagement artifactManagement, public ArtifactDataProvider(final ArtifactManagement artifactManagement,
final ArtifactToProxyArtifactMapper entityMapper) { final ArtifactToProxyArtifactMapper entityMapper) {
@@ -59,6 +59,6 @@ public class ArtifactDataProvider extends AbstractProxyDataProvider<ProxyArtifac
return 0L; return 0L;
} }
return loadBackendEntities(pageRequest, smId).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), smId).getTotalElements();
} }
} }

View File

@@ -36,11 +36,11 @@ public class DistributionSetDistributionsStateDataProvider
* Constructor for DistributionSetDistributionsStateDataProvider * Constructor for DistributionSetDistributionsStateDataProvider
* *
* @param distributionSetManagement * @param distributionSetManagement
* DistributionSetManagement * DistributionSetManagement
* @param distributionSetTypeManagement * @param distributionSetTypeManagement
* DistributionSetTypeManagement * DistributionSetTypeManagement
* @param entityMapper * @param entityMapper
* DistributionSetToProxyDistributionMapper * DistributionSetToProxyDistributionMapper
*/ */
public DistributionSetDistributionsStateDataProvider(final DistributionSetManagement distributionSetManagement, public DistributionSetDistributionsStateDataProvider(final DistributionSetManagement distributionSetManagement,
final DistributionSetTypeManagement distributionSetTypeManagement, final DistributionSetTypeManagement distributionSetTypeManagement,
@@ -68,6 +68,6 @@ public class DistributionSetDistributionsStateDataProvider
@Override @Override
protected long sizeInBackEnd(final PageRequest pageRequest, final DsDistributionsFilterParams filter) { protected long sizeInBackEnd(final PageRequest pageRequest, final DsDistributionsFilterParams filter) {
return loadBackendEntities(pageRequest, filter).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
} }
} }

View File

@@ -34,9 +34,9 @@ public class DistributionSetManagementStateDataProvider
* Constructor for DistributionSetManagementStateDataProvider * Constructor for DistributionSetManagementStateDataProvider
* *
* @param distributionSetManagement * @param distributionSetManagement
* DistributionSetManagement * DistributionSetManagement
* @param entityMapper * @param entityMapper
* DistributionSetToProxyDistributionMapper * DistributionSetToProxyDistributionMapper
*/ */
public DistributionSetManagementStateDataProvider(final DistributionSetManagement distributionSetManagement, public DistributionSetManagementStateDataProvider(final DistributionSetManagement distributionSetManagement,
final DistributionSetToProxyDistributionMapper entityMapper) { final DistributionSetToProxyDistributionMapper entityMapper) {
@@ -67,7 +67,7 @@ public class DistributionSetManagementStateDataProvider
@Override @Override
protected long sizeInBackEnd(final PageRequest pageRequest, final DsManagementFilterParams filter) { protected long sizeInBackEnd(final PageRequest pageRequest, final DsManagementFilterParams filter) {
return loadBackendEntities(pageRequest, filter).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
} }
} }

View File

@@ -35,9 +35,9 @@ public class DistributionSetStatelessDataProvider
* Constructor for DistributionSetStatelessDataProvider * Constructor for DistributionSetStatelessDataProvider
* *
* @param distributionSetManagement * @param distributionSetManagement
* DistributionSetManagement * DistributionSetManagement
* @param entityMapper * @param entityMapper
* DistributionSetToProxyDistributionMapper * DistributionSetToProxyDistributionMapper
*/ */
public DistributionSetStatelessDataProvider(final DistributionSetManagement distributionSetManagement, public DistributionSetStatelessDataProvider(final DistributionSetManagement distributionSetManagement,
final DistributionSetToProxyDistributionMapper entityMapper) { final DistributionSetToProxyDistributionMapper entityMapper) {
@@ -60,6 +60,6 @@ public class DistributionSetStatelessDataProvider
@Override @Override
protected long sizeInBackEnd(final PageRequest pageRequest, final String filter) { protected long sizeInBackEnd(final PageRequest pageRequest, final String filter) {
return loadBackendEntities(pageRequest, filter).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
} }
} }

View File

@@ -28,7 +28,7 @@ public class DsMetaDataDataProvider extends AbstractMetaDataDataProvider<Distrib
* Constructor for DsMetaDataDataProvider * Constructor for DsMetaDataDataProvider
* *
* @param distributionSetManagement * @param distributionSetManagement
* DistributionSetManagement * DistributionSetManagement
*/ */
public DsMetaDataDataProvider(final DistributionSetManagement distributionSetManagement) { public DsMetaDataDataProvider(final DistributionSetManagement distributionSetManagement) {
super(); super();
@@ -51,6 +51,6 @@ public class DsMetaDataDataProvider extends AbstractMetaDataDataProvider<Distrib
return 0L; return 0L;
} }
return loadBackendEntities(pageRequest, dsId).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), dsId).getTotalElements();
} }
} }

View File

@@ -39,7 +39,7 @@ public class RolloutDataProvider extends AbstractProxyDataProvider<ProxyRollout,
*/ */
public RolloutDataProvider(final RolloutManagement rolloutManagement, public RolloutDataProvider(final RolloutManagement rolloutManagement,
final RolloutToProxyRolloutMapper entityMapper) { final RolloutToProxyRolloutMapper entityMapper) {
super(entityMapper, Sort.by(Direction.DESC, "lastModifiedAt")); super(entityMapper, Sort.by(Direction.DESC, "lastModifiedAt", "id"));
this.rolloutManagement = rolloutManagement; this.rolloutManagement = rolloutManagement;
} }

View File

@@ -28,7 +28,7 @@ public class SmMetaDataDataProvider extends AbstractMetaDataDataProvider<Softwar
* Constructor for SmMetaDataDataProvider * Constructor for SmMetaDataDataProvider
* *
* @param softwareModuleManagement * @param softwareModuleManagement
* SoftwareModuleManagement * SoftwareModuleManagement
*/ */
public SmMetaDataDataProvider(final SoftwareModuleManagement softwareModuleManagement) { public SmMetaDataDataProvider(final SoftwareModuleManagement softwareModuleManagement) {
super(); super();
@@ -59,6 +59,6 @@ public class SmMetaDataDataProvider extends AbstractMetaDataDataProvider<Softwar
return 0L; return 0L;
} }
return loadBackendEntities(pageRequest, smId).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), smId).getTotalElements();
} }
} }

View File

@@ -33,9 +33,9 @@ public class TargetFilterQueryDataProvider
* Constructor for TargetFilterQueryDataProvider * Constructor for TargetFilterQueryDataProvider
* *
* @param targetFilterQueryManagement * @param targetFilterQueryManagement
* TargetFilterQueryManagement * TargetFilterQueryManagement
* @param entityMapper * @param entityMapper
* TargetFilterQueryToProxyTargetFilterMapper * TargetFilterQueryToProxyTargetFilterMapper
*/ */
public TargetFilterQueryDataProvider(final TargetFilterQueryManagement targetFilterQueryManagement, public TargetFilterQueryDataProvider(final TargetFilterQueryManagement targetFilterQueryManagement,
final TargetFilterQueryToProxyTargetFilterMapper entityMapper) { final TargetFilterQueryToProxyTargetFilterMapper entityMapper) {
@@ -59,6 +59,6 @@ public class TargetFilterQueryDataProvider
return targetFilterQueryManagement.count(); return targetFilterQueryManagement.count();
} }
return targetFilterQueryManagement.findByName(pageRequest, filter).getTotalElements(); return targetFilterQueryManagement.findByName(PageRequest.of(0, 1), filter).getTotalElements();
} }
} }

View File

@@ -32,9 +32,9 @@ public class TargetFilterQueryDetailsDataProvider
* Constructor for TargetFilterQueryDetailsDataProvider * Constructor for TargetFilterQueryDetailsDataProvider
* *
* @param targetFilterQueryManagement * @param targetFilterQueryManagement
* TargetFilterQueryManagement * TargetFilterQueryManagement
* @param entityMapper * @param entityMapper
* TargetFilterQueryToProxyTargetFilterMapper * TargetFilterQueryToProxyTargetFilterMapper
*/ */
public TargetFilterQueryDetailsDataProvider(final TargetFilterQueryManagement targetFilterQueryManagement, public TargetFilterQueryDetailsDataProvider(final TargetFilterQueryManagement targetFilterQueryManagement,
final TargetFilterQueryToProxyTargetFilterMapper entityMapper) { final TargetFilterQueryToProxyTargetFilterMapper entityMapper) {
@@ -58,6 +58,6 @@ public class TargetFilterQueryDetailsDataProvider
return 0L; return 0L;
} }
return loadBackendEntities(pageRequest, dsId).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), dsId).getTotalElements();
} }
} }

View File

@@ -38,13 +38,13 @@ public class TargetManagementStateDataProvider
* Constructor for TargetManagementStateDataProvider * Constructor for TargetManagementStateDataProvider
* *
* @param targetManagement * @param targetManagement
* TargetManagement * TargetManagement
* @param entityMapper * @param entityMapper
* TargetToProxyTargetMapper * TargetToProxyTargetMapper
*/ */
public TargetManagementStateDataProvider(final TargetManagement targetManagement, public TargetManagementStateDataProvider(final TargetManagement targetManagement,
final TargetToProxyTargetMapper entityMapper) { final TargetToProxyTargetMapper entityMapper) {
super(entityMapper, Sort.by(Direction.DESC, "lastModifiedAt")); super(entityMapper, Sort.by(Direction.DESC, "lastModifiedAt", "id"));
this.targetManagement = targetManagement; this.targetManagement = targetManagement;
} }

View File

@@ -28,7 +28,7 @@ public class TargetMetaDataDataProvider extends AbstractMetaDataDataProvider<Tar
* Constructor for TargetManagement * Constructor for TargetManagement
* *
* @param targetManagement * @param targetManagement
* TargetManagement * TargetManagement
*/ */
public TargetMetaDataDataProvider(final TargetManagement targetManagement) { public TargetMetaDataDataProvider(final TargetManagement targetManagement) {
super(); super();
@@ -52,7 +52,7 @@ public class TargetMetaDataDataProvider extends AbstractMetaDataDataProvider<Tar
return 0L; return 0L;
} }
return targetManagement.findMetaDataByControllerId(pageRequest, currentlySelectedControllerId) return targetManagement.findMetaDataByControllerId(PageRequest.of(0, 1), currentlySelectedControllerId)
.getTotalElements(); .getTotalElements();
} }
} }

View File

@@ -31,9 +31,9 @@ public class TargetTagDataProvider extends AbstractProxyDataProvider<ProxyTag, T
* Constructor for TargetTagDataProvider * Constructor for TargetTagDataProvider
* *
* @param tagManagementService * @param tagManagementService
* TargetTagManagement * TargetTagManagement
* @param mapper * @param mapper
* TagToProxyTagMapper of TargetTag * TagToProxyTagMapper of TargetTag
*/ */
public TargetTagDataProvider(final TargetTagManagement tagManagementService, public TargetTagDataProvider(final TargetTagManagement tagManagementService,
final TagToProxyTagMapper<TargetTag> mapper) { final TagToProxyTagMapper<TargetTag> mapper) {
@@ -49,7 +49,7 @@ public class TargetTagDataProvider extends AbstractProxyDataProvider<ProxyTag, T
@Override @Override
protected long sizeInBackEnd(final PageRequest pageRequest, final Void filter) { protected long sizeInBackEnd(final PageRequest pageRequest, final Void filter) {
return loadBackendEntities(pageRequest, filter).getTotalElements(); return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
} }
} }

View File

@@ -0,0 +1,38 @@
/**
* Copyright (c) 2021 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.suppliers;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataProvider;
/**
* Interface for backend data retrieval provider.
*
* @param <T>
* UI Proxy entity type
* @param <F>
* Filter type
*/
public interface DataSupplier<T, F> {
/**
* Provides back end data.
*
* @return back end data provider
*/
DataProvider<T, F> dataProvider();
/**
* Provides client/server data communicator component.
*
* @return data communicator
*/
DataCommunicator<T> dataCommunicator();
}

View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2021 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.suppliers;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
/**
* Interface for target backend data retrieval provider for Filter View.
*
*/
public interface TargetFilterStateDataSupplier extends DataSupplier<ProxyTarget, String> {
}

View File

@@ -0,0 +1,52 @@
/**
* Copyright (c) 2021 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.suppliers;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.common.data.mappers.TargetToProxyTargetMapper;
import org.eclipse.hawkbit.ui.common.data.providers.TargetFilterStateDataProvider;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataProvider;
/**
* Target backend data retrieval provider for Filter View default
* implementation.
*
*/
public class TargetFilterStateDataSupplierImpl implements TargetFilterStateDataSupplier {
private final TargetFilterStateDataProvider dataProvider;
private final DataCommunicator<ProxyTarget> dataCommunicator;
/**
* Constructor.
*
* @param targetManagement
* Target Management
* @param targetToProxyTargetMapper
* Backend to UI Proxy target entity mapper
*/
public TargetFilterStateDataSupplierImpl(final TargetManagement targetManagement,
final TargetToProxyTargetMapper targetToProxyTargetMapper) {
this.dataProvider = new TargetFilterStateDataProvider(targetManagement, targetToProxyTargetMapper);
this.dataCommunicator = new DataCommunicator<>();
}
@Override
public DataProvider<ProxyTarget, String> dataProvider() {
return dataProvider;
}
@Override
public DataCommunicator<ProxyTarget> dataCommunicator() {
return dataCommunicator;
}
}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) 2021 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.suppliers;
import org.eclipse.hawkbit.ui.common.data.filters.TargetManagementFilterParams;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
/**
* Interface for target backend data retrieval provider for Management View.
*
*/
public interface TargetManagementStateDataSupplier extends DataSupplier<ProxyTarget, TargetManagementFilterParams> {
}

View File

@@ -0,0 +1,53 @@
/**
* Copyright (c) 2021 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.suppliers;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.common.data.filters.TargetManagementFilterParams;
import org.eclipse.hawkbit.ui.common.data.mappers.TargetToProxyTargetMapper;
import org.eclipse.hawkbit.ui.common.data.providers.TargetManagementStateDataProvider;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataProvider;
/**
* Target backend data retrieval provider for Management View default
* implementation.
*
*/
public class TargetManagementStateDataSupplierImpl implements TargetManagementStateDataSupplier {
private final TargetManagementStateDataProvider dataProvider;
private final DataCommunicator<ProxyTarget> dataCommunicator;
/**
* Constructor.
*
* @param targetManagement
* Target Management
* @param targetToProxyTargetMapper
* Backend to UI Proxy target entity mapper
*/
public TargetManagementStateDataSupplierImpl(final TargetManagement targetManagement,
final TargetToProxyTargetMapper targetToProxyTargetMapper) {
this.dataProvider = new TargetManagementStateDataProvider(targetManagement, targetToProxyTargetMapper);
this.dataCommunicator = new DataCommunicator<>();
}
@Override
public DataProvider<ProxyTarget, TargetManagementFilterParams> dataProvider() {
return dataProvider;
}
@Override
public DataCommunicator<ProxyTarget> dataCommunicator() {
return dataCommunicator;
}
}

View File

@@ -52,20 +52,21 @@ public class MetaDataWindowGrid<F> extends AbstractGrid<ProxyMetaData, F> implem
* callback method to delete metadata entities * callback method to delete metadata entities
* *
*/ */
public MetaDataWindowGrid(final CommonUiDependencies uiDependencies, final AbstractMetaDataDataProvider<?, F> dataProvider,final BooleanSupplier hasMetadataChangePermission, public MetaDataWindowGrid(final CommonUiDependencies uiDependencies,
final AbstractMetaDataDataProvider<?, F> dataProvider, final BooleanSupplier hasMetadataChangePermission,
final Predicate<Collection<ProxyMetaData>> itemsDeletionCallback) { final Predicate<Collection<ProxyMetaData>> itemsDeletionCallback) {
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker()); super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
this.hasMetadataChangePermission = hasMetadataChangePermission; this.hasMetadataChangePermission = hasMetadataChangePermission;
this.metaDataDeleteSupport = new DeleteSupport<>(this, i18n, uiDependencies.getUiNotification(), "caption.metadata", this.metaDataDeleteSupport = new DeleteSupport<>(this, i18n, uiDependencies.getUiNotification(),
"caption.metadata.plur", ProxyMetaData::getKey, itemsDeletionCallback, "caption.metadata", "caption.metadata.plur", ProxyMetaData::getKey, itemsDeletionCallback,
UIComponentIdProvider.METADATA_DELETE_CONFIRMATION_DIALOG); UIComponentIdProvider.METADATA_DELETE_CONFIRMATION_DIALOG);
setFilterSupport(new FilterSupport<>(dataProvider)); setFilterSupport(new FilterSupport<>(dataProvider));
// we don't need to send selection events, because details layout // we don't need to send selection events, because details layout
// is part of MetaData Window // is part of MetaData Window
setSelectionSupport(new SelectionSupport<ProxyMetaData>(this)); setSelectionSupport(new SelectionSupport<>(this));
getSelectionSupport().enableSingleSelection(); getSelectionSupport().enableSingleSelection();
init(); init();

View File

@@ -61,8 +61,8 @@ public abstract class AbstractDsGrid<F> extends AbstractGrid<ProxyDistributionSe
this.dsManagement = dsManagement; this.dsManagement = dsManagement;
this.dsToProxyDistributionMapper = new DistributionSetToProxyDistributionMapper(); this.dsToProxyDistributionMapper = new DistributionSetToProxyDistributionMapper();
setSelectionSupport(new SelectionSupport<ProxyDistributionSet>(this, eventBus, EventLayout.DS_LIST, view, setSelectionSupport(new SelectionSupport<>(this, eventBus, EventLayout.DS_LIST, view, this::mapIdToProxyEntity,
this::mapIdToProxyEntity, this::getSelectedEntityIdFromUiState, this::setSelectedEntityIdToUiState)); this::getSelectedEntityIdFromUiState, this::setSelectedEntityIdToUiState));
if (distributionSetGridLayoutUiState.isMaximized()) { if (distributionSetGridLayoutUiState.isMaximized()) {
getSelectionSupport().disableSelection(); getSelectionSupport().disableSelection();
} else { } else {

View File

@@ -19,7 +19,9 @@ import org.eclipse.hawkbit.ui.common.grid.support.SelectionSupport;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataProviderListener; import com.vaadin.data.provider.DataProviderListener;
import com.vaadin.data.provider.Query;
import com.vaadin.ui.Grid; import com.vaadin.ui.Grid;
import com.vaadin.ui.components.grid.GridSelectionModel; import com.vaadin.ui.components.grid.GridSelectionModel;
@@ -70,6 +72,25 @@ public abstract class AbstractGrid<T extends ProxyIdentifiableEntity, F> extends
*/ */
protected AbstractGrid(final VaadinMessageSource i18n, final UIEventBus eventBus, protected AbstractGrid(final VaadinMessageSource i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker) { final SpPermissionChecker permissionChecker) {
this(i18n, eventBus, permissionChecker, new DataCommunicator<>());
}
/**
* Constructor.
*
* @param i18n
* i18n
* @param eventBus
* eventBus
* @param permissionChecker
* permissionChecker
* @param dataCommunicator
* dataCommunicator
*/
protected AbstractGrid(final VaadinMessageSource i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker, final DataCommunicator<T> dataCommunicator) {
super(dataCommunicator);
this.i18n = i18n; this.i18n = i18n;
this.eventBus = eventBus; this.eventBus = eventBus;
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;
@@ -136,7 +157,7 @@ public abstract class AbstractGrid<T extends ProxyIdentifiableEntity, F> extends
* Get total number of items. * Get total number of items.
*/ */
public int getDataSize() { public int getDataSize() {
return getDataCommunicator().getDataProviderSize(); return getDataProvider().size(new Query<>());
} }
/** /**

View File

@@ -158,6 +158,7 @@ public class DeleteSupport<T extends ProxyIdentifiableEntity> {
grid.deselectAll(); grid.deselectAll();
boolean isDeletionSuccessfull = false; boolean isDeletionSuccessfull = false;
RuntimeException deletionException = null;
try { try {
isDeletionSuccessfull = itemsDeletionCallback.test(itemsToBeDeleted); isDeletionSuccessfull = itemsDeletionCallback.test(itemsToBeDeleted);
} catch (final RuntimeException ex) { } catch (final RuntimeException ex) {
@@ -165,12 +166,16 @@ public class DeleteSupport<T extends ProxyIdentifiableEntity> {
.map(String::valueOf).collect(Collectors.joining(",")); .map(String::valueOf).collect(Collectors.joining(","));
LOG.warn("Deletion of {} with ids '{}' failed: {}", localizedEntityTypeSing, itemsToBeDeletedIds, LOG.warn("Deletion of {} with ids '{}' failed: {}", localizedEntityTypeSing, itemsToBeDeletedIds,
ex.getMessage()); ex.getMessage());
deletionException = ex;
} }
if (isDeletionSuccessfull) { if (isDeletionSuccessfull) {
notification.displaySuccess(successNotificationText); notification.displaySuccess(successNotificationText);
} else { } else {
notification.displayWarning(failureNotificationText); notification.displayWarning(failureNotificationText);
if (deletionException != null) {
throw deletionException;
}
} }
} }

View File

@@ -11,23 +11,27 @@ package org.eclipse.hawkbit.ui.common.grid.support;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.UnaryOperator;
import org.eclipse.hawkbit.ui.common.event.FilterType; import org.eclipse.hawkbit.ui.common.event.FilterType;
import com.vaadin.data.provider.ConfigurableFilterDataProvider; import com.vaadin.data.provider.ConfigurableFilterDataProvider;
import com.vaadin.data.provider.DataProvider; import com.vaadin.data.provider.DataProvider;
import com.vaadin.data.provider.DataProviderWrapper;
import com.vaadin.data.provider.Query;
/** /**
* Support for Filter in Grid * Support for Filter in Grid
* *
* @param <T> * @param <T>
* Generic type * Data provider Proxy entity type
* @param <F> * @param <F>
* Generic type * Custom filter type
*/ */
public class FilterSupport<T, F> { public class FilterSupport<T, F> {
private final ConfigurableFilterDataProvider<T, Void, F> filterDataProvider; private final CustomFilterDataProviderWrapper<T, F> filterDataProvider;
private final EnumMap<FilterType, FilterTypeSetter<?>> filterTypeToSetterMapping; private final EnumMap<FilterType, FilterTypeSetter<?>> filterTypeToSetterMapping;
private final UnaryOperator<F> filterCloner;
private final Runnable afterRefreshFilterCallback; private final Runnable afterRefreshFilterCallback;
private F entityFilter; private F entityFilter;
@@ -36,23 +40,51 @@ public class FilterSupport<T, F> {
* Constructor for FilterSupport * Constructor for FilterSupport
* *
* @param dataProvider * @param dataProvider
* Data provider for filter * Data provider that should be enhanced with a custom filter
*/ */
public FilterSupport(final DataProvider<T, F> dataProvider) { public FilterSupport(final DataProvider<T, F> dataProvider) {
this(dataProvider, null); this(dataProvider, null, null);
} }
/** /**
* Constructor for FilterSupport * Constructor for FilterSupport
* *
* @param dataProvider * @param dataProvider
* Data provider for filter * Data provider that should be enhanced with a custom filter
* @param filterCloner
* Creates a clone for a filter
*/
public FilterSupport(final DataProvider<T, F> dataProvider, final UnaryOperator<F> filterCloner) {
this(dataProvider, filterCloner, null);
}
/**
* Constructor for FilterSupport
*
* @param dataProvider
* Data provider that should be enhanced with a custom filter
* @param afterRefreshFilterCallback * @param afterRefreshFilterCallback
* Runnable * Callback to be called after filter/data refresh
*/ */
public FilterSupport(final DataProvider<T, F> dataProvider, final Runnable afterRefreshFilterCallback) { public FilterSupport(final DataProvider<T, F> dataProvider, final Runnable afterRefreshFilterCallback) {
this.filterDataProvider = dataProvider.withConfigurableFilter(); this(dataProvider, null, afterRefreshFilterCallback);
}
/**
* Constructor for FilterSupport
*
* @param dataProvider
* Data provider that should be enhanced with a custom filter
* @param filterCloner
* Creates a clone for a filter
* @param afterRefreshFilterCallback
* Callback to be called after filter/data refresh
*/
public FilterSupport(final DataProvider<T, F> dataProvider, final UnaryOperator<F> filterCloner,
final Runnable afterRefreshFilterCallback) {
this.filterDataProvider = new CustomFilterDataProviderWrapper<>(dataProvider);
this.filterTypeToSetterMapping = new EnumMap<>(FilterType.class); this.filterTypeToSetterMapping = new EnumMap<>(FilterType.class);
this.filterCloner = filterCloner;
this.afterRefreshFilterCallback = afterRefreshFilterCallback; this.afterRefreshFilterCallback = afterRefreshFilterCallback;
} }
@@ -121,7 +153,9 @@ public class FilterSupport<T, F> {
* Refresh filter data * Refresh filter data
*/ */
public void refreshFilter() { public void refreshFilter() {
filterDataProvider.setFilter(entityFilter); // data provider receives a fresh copy of current entity filter
// to make it effectively immutable
filterDataProvider.setFilter(filterCloner != null ? filterCloner.apply(entityFilter) : entityFilter);
if (afterRefreshFilterCallback != null) { if (afterRefreshFilterCallback != null) {
afterRefreshFilterCallback.run(); afterRefreshFilterCallback.run();
@@ -131,7 +165,7 @@ public class FilterSupport<T, F> {
/** /**
* @return Filter data provider * @return Filter data provider
*/ */
public ConfigurableFilterDataProvider<T, Void, F> getFilterDataProvider() { public CustomFilterDataProviderWrapper<T, F> getFilterDataProvider() {
return filterDataProvider; return filterDataProvider;
} }
@@ -215,4 +249,50 @@ public class FilterSupport<T, F> {
} }
} }
} }
/**
* Data provider with custom filter that can be set programmatically.
*
* @param <T>
* Data provider Proxy entity type
* @param <F>
* Custom filter type
*/
public static class CustomFilterDataProviderWrapper<T, F> extends DataProviderWrapper<T, Void, F>
implements ConfigurableFilterDataProvider<T, Void, F> {
private static final long serialVersionUID = 1L;
private transient F customFilter;
/**
* Constructor.
*
* @param dataProvider
* the wrapped data provider
*/
public CustomFilterDataProviderWrapper(final DataProvider<T, F> dataProvider) {
super(dataProvider);
}
@Override
protected F getFilter(final Query<T, Void> query) {
// Filter of Void query is always null, so can be ignored
return getFilter();
}
/**
* Gets the custom filter.
*
* @return custom filter
*/
public F getFilter() {
return customFilter;
}
@Override
public void setFilter(final F filter) {
this.customFilter = filter;
refreshAll();
}
}
} }

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.common.grid.support; package org.eclipse.hawkbit.ui.common.grid.support;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -23,6 +24,7 @@ import org.eclipse.hawkbit.ui.common.event.EventTopics;
import org.eclipse.hawkbit.ui.common.event.EventView; import org.eclipse.hawkbit.ui.common.event.EventView;
import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload; import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload;
import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload.SelectionChangedEventType; import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload.SelectionChangedEventType;
import org.springframework.util.CollectionUtils;
import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.shared.Registration; import com.vaadin.shared.Registration;
@@ -248,15 +250,12 @@ public class SelectionSupport<T extends ProxyIdentifiableEntity> {
return false; return false;
} }
final int size = grid.getDataCommunicator().getDataProviderSize(); final List<T> firstItem = grid.getDataCommunicator().fetchItemsWithRange(0, 1);
if (size > 0) {
final T firstItem = grid.getDataCommunicator().fetchItemsWithRange(0, 1).get(0);
if (firstItem != null) { if (!CollectionUtils.isEmpty(firstItem)) {
grid.select(firstItem); grid.select(firstItem.get(0));
return true; return true;
}
} }
grid.deselectAll(); grid.deselectAll();

View File

@@ -81,8 +81,10 @@ public class DistributionSetGrid extends AbstractDsGrid<DsDistributionsFilterPar
getDragAndDropSupportSupport().addDropTarget(); getDragAndDropSupportSupport().addDropTarget();
} }
setFilterSupport(new FilterSupport<>(new DistributionSetDistributionsStateDataProvider(dsManagement, setFilterSupport(new FilterSupport<>(
dsTypeManagement, dsToProxyDistributionMapper), getSelectionSupport()::deselectAll)); new DistributionSetDistributionsStateDataProvider(dsManagement, dsTypeManagement,
dsToProxyDistributionMapper),
DsDistributionsFilterParams::new, getSelectionSupport()::deselectAll));
initFilterMappings(); initFilterMappings();
getFilterSupport().setFilter(new DsDistributionsFilterParams()); getFilterSupport().setFilter(new DsDistributionsFilterParams());

View File

@@ -58,6 +58,10 @@ public class HawkbitUIErrorHandler implements ErrorHandler {
@Override @Override
public void error(final ErrorEvent event) { public void error(final ErrorEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug("Ui error received. Trying to extract details...", event.getThrowable());
}
final Page currentPage = getPageFrom(event); final Page currentPage = getPageFrom(event);
final List<UiErrorDetails> errorDetails = extractErrorDetails(event); final List<UiErrorDetails> errorDetails = extractErrorDetails(event);

View File

@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.CommonUiDependencies; import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetFilterStateDataSupplier;
import org.eclipse.hawkbit.ui.common.event.EventLayout; import org.eclipse.hawkbit.ui.common.event.EventLayout;
import org.eclipse.hawkbit.ui.common.event.EventView; import org.eclipse.hawkbit.ui.common.event.EventView;
import org.eclipse.hawkbit.ui.common.event.EventViewAware; import org.eclipse.hawkbit.ui.common.event.EventViewAware;
@@ -63,17 +64,19 @@ public class FilterManagementView extends VerticalLayout implements View {
final FilterManagementUIState filterManagementUIState, final RsqlValidationOracle rsqlValidationOracle, final FilterManagementUIState filterManagementUIState, final RsqlValidationOracle rsqlValidationOracle,
final TargetFilterQueryManagement targetFilterQueryManagement, final SpPermissionChecker permissionChecker, final TargetFilterQueryManagement targetFilterQueryManagement, final SpPermissionChecker permissionChecker,
final UINotification notification, final UiProperties uiProperties, final EntityFactory entityFactory, final UINotification notification, final UiProperties uiProperties, final EntityFactory entityFactory,
final TargetManagement targetManagement, final DistributionSetManagement distributionSetManagement) { final TargetManagement targetManagement, final DistributionSetManagement distributionSetManagement,
final TargetFilterStateDataSupplier targetFilterStateDataSupplier) {
this.filterManagementUIState = filterManagementUIState; this.filterManagementUIState = filterManagementUIState;
final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus, notification, final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus,
permissionChecker); notification, permissionChecker);
this.targetFilterGridLayout = new TargetFilterGridLayout(uiDependencies, targetFilterQueryManagement, this.targetFilterGridLayout = new TargetFilterGridLayout(uiDependencies, targetFilterQueryManagement,
targetManagement, distributionSetManagement, filterManagementUIState); targetManagement, distributionSetManagement, filterManagementUIState);
this.targetFilterDetailsLayout = new TargetFilterDetailsLayout(uiDependencies, uiProperties, rsqlValidationOracle, this.targetFilterDetailsLayout = new TargetFilterDetailsLayout(uiDependencies, uiProperties,
targetManagement, targetFilterQueryManagement, filterManagementUIState.getDetailsLayoutUiState()); rsqlValidationOracle, targetFilterQueryManagement, targetFilterStateDataSupplier,
filterManagementUIState.getDetailsLayoutUiState());
final Map<EventLayout, VisibilityHandler> layoutVisibilityHandlers = new EnumMap<>(EventLayout.class); final Map<EventLayout, VisibilityHandler> layoutVisibilityHandlers = new EnumMap<>(EventLayout.class);
layoutVisibilityHandlers.put(EventLayout.TARGET_FILTER_QUERY_LIST, layoutVisibilityHandlers.put(EventLayout.TARGET_FILTER_QUERY_LIST,

View File

@@ -9,12 +9,12 @@
package org.eclipse.hawkbit.ui.filtermanagement; package org.eclipse.hawkbit.ui.filtermanagement;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle; import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.CommonUiDependencies; import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetFilterStateDataSupplier;
import org.eclipse.hawkbit.ui.common.event.EventLayout; import org.eclipse.hawkbit.ui.common.event.EventLayout;
import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware; import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware;
import org.eclipse.hawkbit.ui.common.event.EventView; import org.eclipse.hawkbit.ui.common.event.EventView;
@@ -38,7 +38,7 @@ public class TargetFilterDetailsLayout extends AbstractGridComponentLayout {
private final transient FilterChangedListener<ProxyTarget> targetFilterListener; private final transient FilterChangedListener<ProxyTarget> targetFilterListener;
/** /**
* TargetFilterDetailsLayout constructor * TargetFilterDetailsLayout constructor.
* *
* @param uiDependencies * @param uiDependencies
* {@link CommonUiDependencies} * {@link CommonUiDependencies}
@@ -46,20 +46,22 @@ public class TargetFilterDetailsLayout extends AbstractGridComponentLayout {
* properties * properties
* @param rsqlValidationOracle * @param rsqlValidationOracle
* to get RSQL validation and suggestions * to get RSQL validation and suggestions
* @param targetManagement
* management to get targets matching the filters
* @param targetFilterManagement * @param targetFilterManagement
* management to CRUD target filters * management to CRUD target filters
* @param targetFilterStateDataSupplier
* target grid data supplier
* @param uiState * @param uiState
* to persist the user interaction * to persist the user interaction
*/ */
public TargetFilterDetailsLayout(final CommonUiDependencies uiDependencies, final UiProperties uiProperties, public TargetFilterDetailsLayout(final CommonUiDependencies uiDependencies, final UiProperties uiProperties,
final RsqlValidationOracle rsqlValidationOracle, final TargetManagement targetManagement, final RsqlValidationOracle rsqlValidationOracle, final TargetFilterQueryManagement targetFilterManagement,
final TargetFilterQueryManagement targetFilterManagement, final TargetFilterDetailsLayoutUiState uiState) { final TargetFilterStateDataSupplier targetFilterStateDataSupplier,
final TargetFilterDetailsLayoutUiState uiState) {
this.targetFilterDetailsGridHeader = new TargetFilterDetailsGridHeader(uiDependencies, targetFilterManagement, this.targetFilterDetailsGridHeader = new TargetFilterDetailsGridHeader(uiDependencies, targetFilterManagement,
uiProperties, rsqlValidationOracle, uiState); uiProperties, rsqlValidationOracle, uiState);
this.targetFilterTargetGrid = new TargetFilterTargetGrid(uiDependencies, targetManagement, uiState); this.targetFilterTargetGrid = new TargetFilterTargetGrid(uiDependencies, targetFilterStateDataSupplier,
uiState);
this.targetFilterCountMessageLabel = new TargetFilterCountMessageLabel(uiDependencies.getI18n()); this.targetFilterCountMessageLabel = new TargetFilterCountMessageLabel(uiDependencies.getI18n());
initGridDataUpdatedListener(); initGridDataUpdatedListener();

View File

@@ -8,13 +8,11 @@
*/ */
package org.eclipse.hawkbit.ui.filtermanagement; package org.eclipse.hawkbit.ui.filtermanagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.common.CommonUiDependencies; import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder; import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.TargetStatusIconSupplier; import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.TargetStatusIconSupplier;
import org.eclipse.hawkbit.ui.common.data.mappers.TargetToProxyTargetMapper;
import org.eclipse.hawkbit.ui.common.data.providers.TargetFilterStateDataProvider;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetFilterStateDataSupplier;
import org.eclipse.hawkbit.ui.common.event.FilterType; import org.eclipse.hawkbit.ui.common.event.FilterType;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid; import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.common.grid.support.FilterSupport; import org.eclipse.hawkbit.ui.common.grid.support.FilterSupport;
@@ -36,14 +34,25 @@ public class TargetFilterTargetGrid extends AbstractGrid<ProxyTarget, String> {
private final TargetFilterDetailsLayoutUiState uiState; private final TargetFilterDetailsLayoutUiState uiState;
TargetFilterTargetGrid(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement, /**
* TargetFilterTargetGrid constructor.
*
* @param uiDependencies
* {@link CommonUiDependencies}
* @param targetFilterStateDataSupplier
* data supplier
* @param uiState
* layout state
*/
public TargetFilterTargetGrid(final CommonUiDependencies uiDependencies,
final TargetFilterStateDataSupplier targetFilterStateDataSupplier,
final TargetFilterDetailsLayoutUiState uiState) { final TargetFilterDetailsLayoutUiState uiState) {
super(uiDependencies.getI18n(), uiDependencies.getEventBus()); super(uiDependencies.getI18n(), uiDependencies.getEventBus(), null,
targetFilterStateDataSupplier.dataCommunicator());
this.uiState = uiState; this.uiState = uiState;
setFilterSupport(new FilterSupport<>( setFilterSupport(new FilterSupport<>(targetFilterStateDataSupplier.dataProvider()));
new TargetFilterStateDataProvider(targetManagement, new TargetToProxyTargetMapper(i18n))));
initFilterMappings(); initFilterMappings();
targetStatusIconSupplier = new TargetStatusIconSupplier<>(i18n, ProxyTarget::getUpdateStatus, TARGET_STATUS_ID); targetStatusIconSupplier = new TargetStatusIconSupplier<>(i18n, ProxyTarget::getUpdateStatus, TARGET_STATUS_ID);

View File

@@ -31,6 +31,7 @@ import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.CommonUiDependencies; import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetManagementStateDataSupplier;
import org.eclipse.hawkbit.ui.common.event.EventLayout; import org.eclipse.hawkbit.ui.common.event.EventLayout;
import org.eclipse.hawkbit.ui.common.event.EventView; import org.eclipse.hawkbit.ui.common.event.EventView;
import org.eclipse.hawkbit.ui.common.event.EventViewAware; import org.eclipse.hawkbit.ui.common.event.EventViewAware;
@@ -95,21 +96,23 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
final TargetTagManagement targetTagManagement, final TargetTagManagement targetTagManagement,
final DistributionSetTagManagement distributionSetTagManagement, final DistributionSetTagManagement distributionSetTagManagement,
final TargetFilterQueryManagement targetFilterQueryManagement, final SystemManagement systemManagement, final TargetFilterQueryManagement targetFilterQueryManagement, final SystemManagement systemManagement,
final TenantConfigurationManagement configManagement, final SystemSecurityContext systemSecurityContext, final TenantConfigurationManagement configManagement,
@Qualifier("uiExecutor") final Executor uiExecutor) { final TargetManagementStateDataSupplier targetManagementStateDataSupplier,
final SystemSecurityContext systemSecurityContext, @Qualifier("uiExecutor") final Executor uiExecutor) {
this.permChecker = permChecker; this.permChecker = permChecker;
this.managementUIState = managementUIState; this.managementUIState = managementUIState;
final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus, uiNotification, final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus,
permChecker); uiNotification, permChecker);
if (permChecker.hasTargetReadPermission()) { if (permChecker.hasTargetReadPermission()) {
this.targetTagFilterLayout = new TargetTagFilterLayout(uiDependencies, managementUIState, this.targetTagFilterLayout = new TargetTagFilterLayout(uiDependencies, managementUIState,
targetFilterQueryManagement, targetTagManagement, targetManagement, targetFilterQueryManagement, targetTagManagement, targetManagement,
managementUIState.getTargetTagFilterLayoutUiState()); managementUIState.getTargetTagFilterLayoutUiState());
this.targetGridLayout = new TargetGridLayout(uiDependencies, targetManagement, deploymentManagement, uiProperties, this.targetGridLayout = new TargetGridLayout(uiDependencies, targetManagement, deploymentManagement,
targetTagManagement, distributionSetManagement, uiExecutor, configManagement, systemSecurityContext, uiProperties, targetTagManagement, distributionSetManagement, uiExecutor, configManagement,
targetManagementStateDataSupplier, systemSecurityContext,
managementUIState.getTargetTagFilterLayoutUiState(), managementUIState.getTargetGridLayoutUiState(), managementUIState.getTargetTagFilterLayoutUiState(), managementUIState.getTargetGridLayoutUiState(),
managementUIState.getTargetBulkUploadUiState(), managementUIState.getTargetBulkUploadUiState(),
managementUIState.getDistributionGridLayoutUiState()); managementUIState.getDistributionGridLayoutUiState());

View File

@@ -15,8 +15,8 @@ import java.util.Optional;
import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
import org.eclipse.hawkbit.ui.common.CommonUiDependencies; import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder; import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionStatusIconSupplier; import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionStatusIconSupplier;
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionTypeIconSupplier; import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionTypeIconSupplier;
@@ -84,7 +84,7 @@ public class ActionHistoryGrid extends AbstractGrid<ProxyAction, String> {
private final transient MasterEntitySupport<ProxyTarget> masterEntitySupport; private final transient MasterEntitySupport<ProxyTarget> masterEntitySupport;
ActionHistoryGrid(final CommonUiDependencies uiDependencies, final DeploymentManagement deploymentManagement, public ActionHistoryGrid(final CommonUiDependencies uiDependencies, final DeploymentManagement deploymentManagement,
final ActionHistoryGridLayoutUiState actionHistoryGridLayoutUiState) { final ActionHistoryGridLayoutUiState actionHistoryGridLayoutUiState) {
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker()); super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
@@ -93,7 +93,7 @@ public class ActionHistoryGrid extends AbstractGrid<ProxyAction, String> {
this.actionToProxyActionMapper = new ActionToProxyActionMapper(); this.actionToProxyActionMapper = new ActionToProxyActionMapper();
// currently we do not restore action history selection // currently we do not restore action history selection
setSelectionSupport(new SelectionSupport<ProxyAction>(this, eventBus, EventLayout.ACTION_HISTORY_LIST, setSelectionSupport(new SelectionSupport<>(this, eventBus, EventLayout.ACTION_HISTORY_LIST,
EventView.DEPLOYMENT, this::mapIdToProxyEntity, null, null)); EventView.DEPLOYMENT, this::mapIdToProxyEntity, null, null));
if (actionHistoryGridLayoutUiState.isMaximized()) { if (actionHistoryGridLayoutUiState.isMaximized()) {
getSelectionSupport().enableSingleSelection(); getSelectionSupport().enableSingleSelection();

View File

@@ -48,11 +48,12 @@ public class ActionStatusGrid extends AbstractGrid<ProxyActionStatus, Long> {
* @param deploymentManagement * @param deploymentManagement
* deploymentManagement * deploymentManagement
*/ */
protected ActionStatusGrid(final CommonUiDependencies uiDependencies, final DeploymentManagement deploymentManagement) { public ActionStatusGrid(final CommonUiDependencies uiDependencies,
final DeploymentManagement deploymentManagement) {
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker()); super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
setSelectionSupport(new SelectionSupport<ProxyActionStatus>(this, eventBus, setSelectionSupport(new SelectionSupport<>(this, eventBus, EventLayout.ACTION_HISTORY_STATUS_LIST,
EventLayout.ACTION_HISTORY_STATUS_LIST, EventView.DEPLOYMENT, null, null, null)); EventView.DEPLOYMENT, null, null, null));
getSelectionSupport().enableSingleSelection(); getSelectionSupport().enableSingleSelection();
setFilterSupport(new FilterSupport<>( setFilterSupport(new FilterSupport<>(

View File

@@ -44,10 +44,11 @@ public class ActionStatusMsgGrid extends AbstractGrid<ProxyMessage, Long> {
private final Registration itemClickListenerRegistration; private final Registration itemClickListenerRegistration;
protected ActionStatusMsgGrid(final CommonUiDependencies uiDependencies, final DeploymentManagement deploymentManagement) { public ActionStatusMsgGrid(final CommonUiDependencies uiDependencies,
final DeploymentManagement deploymentManagement) {
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker()); super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
setSelectionSupport(new SelectionSupport<ProxyMessage>(this)); setSelectionSupport(new SelectionSupport<>(this));
getSelectionSupport().enableSingleSelection(); getSelectionSupport().enableSingleSelection();
addStyleName(SPUIStyleDefinitions.ACTION_HISTORY_MESSAGE_GRID); addStyleName(SPUIStyleDefinitions.ACTION_HISTORY_MESSAGE_GRID);

View File

@@ -126,7 +126,7 @@ public class DistributionGrid extends AbstractDsGrid<DsManagementFilterParams> {
setFilterSupport(new FilterSupport<>( setFilterSupport(new FilterSupport<>(
new DistributionSetManagementStateDataProvider(distributionSetManagement, dsToProxyDistributionMapper), new DistributionSetManagementStateDataProvider(distributionSetManagement, dsToProxyDistributionMapper),
getSelectionSupport()::deselectAll)); DsManagementFilterParams::new, getSelectionSupport()::deselectAll));
initFilterMappings(); initFilterMappings();
getFilterSupport().setFilter(new DsManagementFilterParams()); getFilterSupport().setFilter(new DsManagementFilterParams());

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.ui.management; package org.eclipse.hawkbit.ui.management.targettable;
import java.util.Collection; import java.util.Collection;
@@ -28,7 +28,7 @@ import com.vaadin.ui.Label;
* Count message label which display current filter details and details on * Count message label which display current filter details and details on
* pinning. * pinning.
*/ */
public class CountMessageLabel extends AbstractFooterSupport { public class TargetCountMessageLabel extends AbstractFooterSupport {
private final VaadinMessageSource i18n; private final VaadinMessageSource i18n;
private final TargetManagement targetManagement; private final TargetManagement targetManagement;
@@ -43,7 +43,7 @@ public class CountMessageLabel extends AbstractFooterSupport {
* @param i18n * @param i18n
* I18N * I18N
*/ */
public CountMessageLabel(final TargetManagement targetManagement, final VaadinMessageSource i18n) { public TargetCountMessageLabel(final TargetManagement targetManagement, final VaadinMessageSource i18n) {
this.targetManagement = targetManagement; this.targetManagement = targetManagement;
this.i18n = i18n; this.i18n = i18n;
this.targetCountLabel = new Label(); this.targetCountLabel = new Label();

View File

@@ -29,9 +29,9 @@ import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.TargetPollingStat
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.TargetStatusIconSupplier; import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.TargetStatusIconSupplier;
import org.eclipse.hawkbit.ui.common.data.filters.TargetManagementFilterParams; import org.eclipse.hawkbit.ui.common.data.filters.TargetManagementFilterParams;
import org.eclipse.hawkbit.ui.common.data.mappers.TargetToProxyTargetMapper; import org.eclipse.hawkbit.ui.common.data.mappers.TargetToProxyTargetMapper;
import org.eclipse.hawkbit.ui.common.data.providers.TargetManagementStateDataProvider;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetManagementStateDataSupplier;
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
import org.eclipse.hawkbit.ui.common.event.EventLayout; import org.eclipse.hawkbit.ui.common.event.EventLayout;
@@ -104,6 +104,8 @@ public class TargetGrid extends AbstractGrid<ProxyTarget, TargetManagementFilter
* DeploymentManagement * DeploymentManagement
* @param configManagement * @param configManagement
* TenantConfigurationManagement * TenantConfigurationManagement
* @param targetManagementStateDataSupplier
* data supplier
* @param systemSecurityContext * @param systemSecurityContext
* SystemSecurityContext * SystemSecurityContext
* @param uiProperties * @param uiProperties
@@ -117,11 +119,13 @@ public class TargetGrid extends AbstractGrid<ProxyTarget, TargetManagementFilter
*/ */
public TargetGrid(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement, public TargetGrid(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement,
final DeploymentManagement deploymentManagement, final TenantConfigurationManagement configManagement, final DeploymentManagement deploymentManagement, final TenantConfigurationManagement configManagement,
final TargetManagementStateDataSupplier targetManagementStateDataSupplier,
final SystemSecurityContext systemSecurityContext, final UiProperties uiProperties, final SystemSecurityContext systemSecurityContext, final UiProperties uiProperties,
final TargetGridLayoutUiState targetGridLayoutUiState, final TargetGridLayoutUiState targetGridLayoutUiState,
final DistributionGridLayoutUiState distributionGridLayoutUiState, final DistributionGridLayoutUiState distributionGridLayoutUiState,
final TargetTagFilterLayoutUiState targetTagFilterLayoutUiState) { final TargetTagFilterLayoutUiState targetTagFilterLayoutUiState) {
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker()); super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker(),
targetManagementStateDataSupplier.dataCommunicator());
this.targetManagement = targetManagement; this.targetManagement = targetManagement;
this.targetGridLayoutUiState = targetGridLayoutUiState; this.targetGridLayoutUiState = targetGridLayoutUiState;
@@ -129,9 +133,8 @@ public class TargetGrid extends AbstractGrid<ProxyTarget, TargetManagementFilter
this.distributionGridLayoutUiState = distributionGridLayoutUiState; this.distributionGridLayoutUiState = distributionGridLayoutUiState;
this.targetToProxyTargetMapper = new TargetToProxyTargetMapper(i18n); this.targetToProxyTargetMapper = new TargetToProxyTargetMapper(i18n);
setSelectionSupport(new SelectionSupport<ProxyTarget>(this, eventBus, EventLayout.TARGET_LIST, setSelectionSupport(new SelectionSupport<>(this, eventBus, EventLayout.TARGET_LIST, EventView.DEPLOYMENT,
EventView.DEPLOYMENT, this::mapIdToProxyEntity, this::getSelectedEntityIdFromUiState, this::mapIdToProxyEntity, this::getSelectedEntityIdFromUiState, this::setSelectedEntityIdToUiState));
this::setSelectedEntityIdToUiState));
if (targetGridLayoutUiState.isMaximized()) { if (targetGridLayoutUiState.isMaximized()) {
getSelectionSupport().disableSelection(); getSelectionSupport().disableSelection();
} else { } else {
@@ -164,9 +167,8 @@ public class TargetGrid extends AbstractGrid<ProxyTarget, TargetManagementFilter
getDragAndDropSupportSupport().addDragAndDrop(); getDragAndDropSupportSupport().addDragAndDrop();
} }
setFilterSupport( setFilterSupport(new FilterSupport<>(targetManagementStateDataSupplier.dataProvider(),
new FilterSupport<>(new TargetManagementStateDataProvider(targetManagement, targetToProxyTargetMapper), TargetManagementFilterParams::new, getSelectionSupport()::deselectAll));
getSelectionSupport()::deselectAll));
initFilterMappings(); initFilterMappings();
getFilterSupport().setFilter(new TargetManagementFilterParams()); getFilterSupport().setFilter(new TargetManagementFilterParams());

View File

@@ -79,7 +79,7 @@ public class TargetGridHeader extends AbstractEntityGridHeader {
/** /**
* Add distribution set filter drop area * Add distribution set filter drop area
*/ */
public void addDsDroArea() { public void addDsDropArea() {
final Component distributionSetFilterDropArea = distributionSetFilterDropAreaSupport.getHeaderComponent(); final Component distributionSetFilterDropArea = distributionSetFilterDropAreaSupport.getHeaderComponent();
addComponent(distributionSetFilterDropArea); addComponent(distributionSetFilterDropArea);
setComponentAlignment(distributionSetFilterDropArea, Alignment.TOP_CENTER); setComponentAlignment(distributionSetFilterDropArea, Alignment.TOP_CENTER);

View File

@@ -24,6 +24,7 @@ import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import org.eclipse.hawkbit.ui.common.data.suppliers.TargetManagementStateDataSupplier;
import org.eclipse.hawkbit.ui.common.event.EventLayout; import org.eclipse.hawkbit.ui.common.event.EventLayout;
import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware; import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware;
import org.eclipse.hawkbit.ui.common.event.EventTopics; import org.eclipse.hawkbit.ui.common.event.EventTopics;
@@ -44,7 +45,6 @@ import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGridR
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedPinAwareSupport; import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedPinAwareSupport;
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedSelectionAwareSupport; import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedSelectionAwareSupport;
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedTagTokenAwareSupport; import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedTagTokenAwareSupport;
import org.eclipse.hawkbit.ui.management.CountMessageLabel;
import org.eclipse.hawkbit.ui.management.bulkupload.BulkUploadWindowBuilder; import org.eclipse.hawkbit.ui.management.bulkupload.BulkUploadWindowBuilder;
import org.eclipse.hawkbit.ui.management.bulkupload.TargetBulkUploadUiState; import org.eclipse.hawkbit.ui.management.bulkupload.TargetBulkUploadUiState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionGridLayoutUiState; import org.eclipse.hawkbit.ui.management.dstable.DistributionGridLayoutUiState;
@@ -60,7 +60,7 @@ public class TargetGridLayout extends AbstractGridComponentLayout {
private final TargetGrid targetGrid; private final TargetGrid targetGrid;
private final TargetDetailsHeader targetDetailsHeader; private final TargetDetailsHeader targetDetailsHeader;
private final TargetDetails targetDetails; private final TargetDetails targetDetails;
private final transient CountMessageLabel countMessageLabel; private final transient TargetCountMessageLabel countMessageLabel;
private final transient GenericEventListener<TargetFilterTabChangedEventPayload> filterTabChangedListener; private final transient GenericEventListener<TargetFilterTabChangedEventPayload> filterTabChangedListener;
private final transient FilterChangedListener<ProxyTarget> targetFilterListener; private final transient FilterChangedListener<ProxyTarget> targetFilterListener;
@@ -90,6 +90,8 @@ public class TargetGridLayout extends AbstractGridComponentLayout {
* Executor * Executor
* @param configManagement * @param configManagement
* TenantConfigurationManagement * TenantConfigurationManagement
* @param targetManagementStateDataSupplier
* target grid data supplier
* @param systemSecurityContext * @param systemSecurityContext
* SystemSecurityContext * SystemSecurityContext
* @param targetTagFilterLayoutUiState * @param targetTagFilterLayoutUiState
@@ -105,6 +107,7 @@ public class TargetGridLayout extends AbstractGridComponentLayout {
final DeploymentManagement deploymentManagement, final UiProperties uiProperties, final DeploymentManagement deploymentManagement, final UiProperties uiProperties,
final TargetTagManagement targetTagManagement, final DistributionSetManagement distributionSetManagement, final TargetTagManagement targetTagManagement, final DistributionSetManagement distributionSetManagement,
final Executor uiExecutor, final TenantConfigurationManagement configManagement, final Executor uiExecutor, final TenantConfigurationManagement configManagement,
final TargetManagementStateDataSupplier targetManagementStateDataSupplier,
final SystemSecurityContext systemSecurityContext, final SystemSecurityContext systemSecurityContext,
final TargetTagFilterLayoutUiState targetTagFilterLayoutUiState, final TargetTagFilterLayoutUiState targetTagFilterLayoutUiState,
final TargetGridLayoutUiState targetGridLayoutUiState, final TargetGridLayoutUiState targetGridLayoutUiState,
@@ -114,23 +117,24 @@ public class TargetGridLayout extends AbstractGridComponentLayout {
EventView.DEPLOYMENT); EventView.DEPLOYMENT);
final TargetMetaDataWindowBuilder targetMetaDataWindowBuilder = new TargetMetaDataWindowBuilder(uiDependencies, final TargetMetaDataWindowBuilder targetMetaDataWindowBuilder = new TargetMetaDataWindowBuilder(uiDependencies,
targetManagement); targetManagement);
final BulkUploadWindowBuilder bulkUploadWindowBuilder = new BulkUploadWindowBuilder(uiDependencies, uiProperties, final BulkUploadWindowBuilder bulkUploadWindowBuilder = new BulkUploadWindowBuilder(uiDependencies,
uiExecutor, targetManagement, deploymentManagement, targetTagManagement, distributionSetManagement, uiProperties, uiExecutor, targetManagement, deploymentManagement, targetTagManagement,
targetBulkUploadUiState); distributionSetManagement, targetBulkUploadUiState);
this.targetGridHeader = new TargetGridHeader(uiDependencies, targetWindowBuilder, bulkUploadWindowBuilder, this.targetGridHeader = new TargetGridHeader(uiDependencies, targetWindowBuilder, bulkUploadWindowBuilder,
targetTagFilterLayoutUiState, targetGridLayoutUiState, targetBulkUploadUiState); targetTagFilterLayoutUiState, targetGridLayoutUiState, targetBulkUploadUiState);
this.targetGridHeader.buildHeader(); this.targetGridHeader.buildHeader();
this.targetGridHeader.addDsDroArea(); this.targetGridHeader.addDsDropArea();
this.targetGrid = new TargetGrid(uiDependencies, targetManagement, deploymentManagement, configManagement, this.targetGrid = new TargetGrid(uiDependencies, targetManagement, deploymentManagement, configManagement,
systemSecurityContext, uiProperties, targetGridLayoutUiState, distributionGridLayoutUiState, targetManagementStateDataSupplier, systemSecurityContext, uiProperties, targetGridLayoutUiState,
targetTagFilterLayoutUiState); distributionGridLayoutUiState, targetTagFilterLayoutUiState);
this.targetDetailsHeader = new TargetDetailsHeader(uiDependencies, targetWindowBuilder, targetMetaDataWindowBuilder); this.targetDetailsHeader = new TargetDetailsHeader(uiDependencies, targetWindowBuilder,
this.targetDetails = new TargetDetails(uiDependencies, targetTagManagement, targetManagement, deploymentManagement,
targetMetaDataWindowBuilder); targetMetaDataWindowBuilder);
this.targetDetails = new TargetDetails(uiDependencies, targetTagManagement, targetManagement,
deploymentManagement, targetMetaDataWindowBuilder);
this.countMessageLabel = new CountMessageLabel(targetManagement, uiDependencies.getI18n()); this.countMessageLabel = new TargetCountMessageLabel(targetManagement, uiDependencies.getI18n());
initGridDataUpdatedListener(); initGridDataUpdatedListener();
@@ -138,16 +142,16 @@ public class TargetGridLayout extends AbstractGridComponentLayout {
EventTopics.TARGET_FILTER_TAB_CHANGED, this::onTargetFilterTabChanged); EventTopics.TARGET_FILTER_TAB_CHANGED, this::onTargetFilterTabChanged);
this.targetFilterListener = new FilterChangedListener<>(uiDependencies.getEventBus(), ProxyTarget.class, this.targetFilterListener = new FilterChangedListener<>(uiDependencies.getEventBus(), ProxyTarget.class,
new EventViewAware(EventView.DEPLOYMENT), targetGrid.getFilterSupport()); new EventViewAware(EventView.DEPLOYMENT), targetGrid.getFilterSupport());
this.pinningChangedListener = new PinningChangedListener<>(uiDependencies.getEventBus(), ProxyDistributionSet.class, this.pinningChangedListener = new PinningChangedListener<>(uiDependencies.getEventBus(),
targetGrid.getPinSupport()); ProxyDistributionSet.class, targetGrid.getPinSupport());
this.targetChangedListener = new SelectionChangedListener<>(uiDependencies.getEventBus(), this.targetChangedListener = new SelectionChangedListener<>(uiDependencies.getEventBus(),
new EventLayoutViewAware(EventLayout.TARGET_LIST, EventView.DEPLOYMENT), new EventLayoutViewAware(EventLayout.TARGET_LIST, EventView.DEPLOYMENT),
getMasterTargetAwareComponents()); getMasterTargetAwareComponents());
this.selectTargetListener = new SelectGridEntityListener<>(uiDependencies.getEventBus(), this.selectTargetListener = new SelectGridEntityListener<>(uiDependencies.getEventBus(),
new EventLayoutViewAware(EventLayout.TARGET_LIST, EventView.DEPLOYMENT), new EventLayoutViewAware(EventLayout.TARGET_LIST, EventView.DEPLOYMENT),
targetGrid.getSelectionSupport()); targetGrid.getSelectionSupport());
this.targetModifiedListener = new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxyTarget.class) this.targetModifiedListener = new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(),
.entityModifiedAwareSupports(getTargetModifiedAwareSupports()).build(); ProxyTarget.class).entityModifiedAwareSupports(getTargetModifiedAwareSupports()).build();
this.tagModifiedListener = new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxyTag.class) this.tagModifiedListener = new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxyTag.class)
.entityModifiedAwareSupports(getTagModifiedAwareSupports()).parentEntityType(ProxyTarget.class).build(); .entityModifiedAwareSupports(getTagModifiedAwareSupports()).parentEntityType(ProxyTarget.class).build();
this.bulkUploadListener = new BulkUploadChangedListener(uiDependencies.getEventBus(), this.bulkUploadListener = new BulkUploadChangedListener(uiDependencies.getEventBus(),
@@ -252,7 +256,7 @@ public class TargetGridLayout extends AbstractGridComponentLayout {
* *
* @return Count message label * @return Count message label
*/ */
public CountMessageLabel getCountMessageLabel() { public TargetCountMessageLabel getCountMessageLabel() {
return countMessageLabel; return countMessageLabel;
} }
} }