Optimize UI queries (#1234)
* first iteration of query optimization for target and distribution set * fixed type distribution set filter * adapted all ui dataproviders to use repository count * adapted test to not check target attributes within search query * unified search behaviuor for ds and sm * removed unneccessary count queries for some mgmt calls * removed unneccessary type id proprty from ProxyDistributionSetInfo to minimize lazy fetches * refactored mgmt classes * removed duplication of name version filter * fixed copy rollout compatibility check * cleaned-up management left overs * added index to rollouts table on tenant/status queries Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>
This commit is contained in:
@@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetManagementStateDataProvider;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
|
||||
@@ -65,7 +64,7 @@ public class DsFilterParams implements Serializable {
|
||||
* String
|
||||
*/
|
||||
public void setSearchText(final String searchText) {
|
||||
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
|
||||
this.searchText = searchText;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.SoftwareModuleDataProvider;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
|
||||
@@ -78,7 +77,7 @@ public class SwFilterParams implements Serializable {
|
||||
* String
|
||||
*/
|
||||
public void setSearchText(final String searchText) {
|
||||
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
|
||||
this.searchText = searchText;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,8 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyAdvancedRolloutGroup;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQueryInfo;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -55,9 +55,9 @@ public class RolloutGroupToAdvancedDefinitionMapper {
|
||||
final String groupTargetFilterQuery = rolloutGroup.getTargetFilterQuery();
|
||||
if (!StringUtils.isEmpty(groupTargetFilterQuery)) {
|
||||
advancedGroupRow.setTargetFilterQuery(groupTargetFilterQuery);
|
||||
final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement.findByQuery(PageRequest.of(0, 1),
|
||||
final Slice<TargetFilterQuery> filterQueries = targetFilterQueryManagement.findByQuery(PageRequest.of(0, 1),
|
||||
groupTargetFilterQuery);
|
||||
if (filterQueries.getTotalElements() == 1) {
|
||||
if (filterQueries.getNumberOfElements() == 1) {
|
||||
final TargetFilterQuery tfq = filterQueries.getContent().get(0);
|
||||
advancedGroupRow.setTargetFilterQueryInfo(
|
||||
new ProxyTargetFilterQueryInfo(tfq.getId(), tfq.getName(), tfq.getQuery()));
|
||||
|
||||
@@ -26,8 +26,7 @@ public class RolloutToProxyRolloutMapper extends AbstractNamedEntityToProxyNamed
|
||||
mapNamedEntityAttributes(rollout, proxyRollout);
|
||||
|
||||
final DistributionSet ds = rollout.getDistributionSet();
|
||||
proxyRollout.setDsInfo(new ProxyDistributionSetInfo(ds.getId(), ds.getName(), ds.getVersion(),
|
||||
ds.getType().getId(), ds.isValid()));
|
||||
proxyRollout.setDsInfo(new ProxyDistributionSetInfo(ds.getId(), ds.getName(), ds.getVersion(), ds.isValid()));
|
||||
proxyRollout
|
||||
.setNumberOfGroups(rollout.getRolloutGroupsCreated() > 0 ? rollout.getRolloutGroupsCreated() : null);
|
||||
proxyRollout.setForcedTime(rollout.getForcedTime() > 0 ? rollout.getForcedTime() : null);
|
||||
|
||||
@@ -38,8 +38,7 @@ public class TargetFilterQueryToProxyTargetFilterMapper
|
||||
if (distributionSet != null) {
|
||||
proxyTargetFilter.setAutoAssignmentEnabled(true);
|
||||
proxyTargetFilter.setDistributionSetInfo(new ProxyDistributionSetInfo(distributionSet.getId(),
|
||||
distributionSet.getName(), distributionSet.getVersion(), distributionSet.getType().getId(),
|
||||
distributionSet.isValid()));
|
||||
distributionSet.getName(), distributionSet.getVersion(), distributionSet.isValid()));
|
||||
proxyTargetFilter.setAutoAssignActionType(targetFilterQuery.getAutoAssignActionType());
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,6 @@ public class ActionStatusDataProvider extends AbstractProxyDataProvider<ProxyAct
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return loadBackendEntities(PageRequest.of(0, 1), actionId).getTotalElements();
|
||||
return deploymentManagement.countActionStatusByAction(actionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,6 @@ public class ActionStatusMsgDataProvider extends AbstractGenericDataProvider<Pro
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return loadBackendEntities(PageRequest.of(0, 1), actionStatusId).getTotalElements();
|
||||
return deploymentManagement.countMessagesByActionStatusId(actionStatusId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ public class ArtifactDataProvider extends AbstractProxyDataProvider<ProxyArtifac
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return loadBackendEntities(PageRequest.of(0, 1), smId).getTotalElements();
|
||||
return artifactManagement.countBySoftwareModule(smId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,14 @@
|
||||
package org.eclipse.hawkbit.ui.common.data.providers;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.ui.common.data.filters.DsDistributionsFilterParams;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.DistributionSetToProxyDistributionMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
|
||||
/**
|
||||
* Data provider for {@link DistributionSet}, which dynamically loads a batch of
|
||||
@@ -30,44 +29,40 @@ public class DistributionSetDistributionsStateDataProvider
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final transient DistributionSetManagement distributionSetManagement;
|
||||
private final transient DistributionSetTypeManagement distributionSetTypeManagement;
|
||||
|
||||
/**
|
||||
* Constructor for DistributionSetDistributionsStateDataProvider
|
||||
*
|
||||
* @param distributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param distributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param entityMapper
|
||||
* DistributionSetToProxyDistributionMapper
|
||||
*/
|
||||
public DistributionSetDistributionsStateDataProvider(final DistributionSetManagement distributionSetManagement,
|
||||
final DistributionSetTypeManagement distributionSetTypeManagement,
|
||||
final DistributionSetToProxyDistributionMapper entityMapper) {
|
||||
super(entityMapper);
|
||||
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
this.distributionSetTypeManagement = distributionSetTypeManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Page<DistributionSet> loadBackendEntities(final PageRequest pageRequest,
|
||||
protected Slice<DistributionSet> loadBackendEntities(final PageRequest pageRequest,
|
||||
final DsDistributionsFilterParams filter) {
|
||||
return distributionSetManagement.findByDistributionSetFilter(pageRequest, buildDsFilter(filter));
|
||||
}
|
||||
|
||||
private DistributionSetFilter buildDsFilter(final DsDistributionsFilterParams filter) {
|
||||
final DistributionSetFilterBuilder builder = new DistributionSetFilterBuilder().setIsDeleted(false);
|
||||
|
||||
if (filter != null) {
|
||||
final DistributionSetType type = filter.getDsTypeId() == null ? null
|
||||
: distributionSetTypeManagement.get(filter.getDsTypeId()).orElse(null);
|
||||
|
||||
builder.setSearchText(filter.getSearchText()).setSelectDSWithNoTag(false).setType(type);
|
||||
builder.setSearchText(filter.getSearchText()).setSelectDSWithNoTag(false).setTypeId(filter.getDsTypeId());
|
||||
}
|
||||
|
||||
return distributionSetManagement.findByDistributionSetFilter(pageRequest, builder.build());
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long sizeInBackEnd(final PageRequest pageRequest, final DsDistributionsFilterParams filter) {
|
||||
return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
|
||||
return distributionSetManagement.countByDistributionSetFilter(buildDsFilter(filter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,13 @@ package org.eclipse.hawkbit.ui.common.data.providers;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.filters.DsManagementFilterParams;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.DistributionSetToProxyDistributionMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -46,28 +47,34 @@ public class DistributionSetManagementStateDataProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Page<DistributionSet> loadBackendEntities(final PageRequest pageRequest,
|
||||
protected Slice<DistributionSet> loadBackendEntities(final PageRequest pageRequest,
|
||||
final DsManagementFilterParams filter) {
|
||||
if (filter == null) {
|
||||
return distributionSetManagement.findByCompleted(pageRequest, true);
|
||||
}
|
||||
|
||||
final String pinnedControllerId = filter.getPinnedTargetControllerId();
|
||||
final DistributionSetFilterBuilder builder = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||
.setIsComplete(true).setSearchText(filter.getSearchText()).setSelectDSWithNoTag(filter.isNoTagClicked())
|
||||
.setTagNames(filter.getDistributionSetTags());
|
||||
|
||||
if (!StringUtils.isEmpty(pinnedControllerId)) {
|
||||
return distributionSetManagement.findByFilterAndAssignedInstalledDsOrderedByLinkTarget(pageRequest, builder,
|
||||
pinnedControllerId);
|
||||
return distributionSetManagement.findByDistributionSetFilterOrderByLinkedTarget(pageRequest,
|
||||
buildDsFilter(filter), pinnedControllerId);
|
||||
}
|
||||
|
||||
return distributionSetManagement.findByDistributionSetFilter(pageRequest, builder.build());
|
||||
return distributionSetManagement.findByDistributionSetFilter(pageRequest, buildDsFilter(filter));
|
||||
}
|
||||
|
||||
private DistributionSetFilter buildDsFilter(final DsManagementFilterParams filter) {
|
||||
return new DistributionSetFilterBuilder().setIsDeleted(false).setIsComplete(true)
|
||||
.setSearchText(filter.getSearchText()).setSelectDSWithNoTag(filter.isNoTagClicked())
|
||||
.setTagNames(filter.getDistributionSetTags()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long sizeInBackEnd(final PageRequest pageRequest, final DsManagementFilterParams filter) {
|
||||
return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
|
||||
if (filter == null) {
|
||||
return distributionSetManagement.countByCompleted(true);
|
||||
}
|
||||
|
||||
return distributionSetManagement.countByDistributionSetFilter(buildDsFilter(filter));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ package org.eclipse.hawkbit.ui.common.data.providers;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.DistributionSetToProxyDistributionMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -47,19 +48,22 @@ public class DistributionSetStatelessDataProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Page<DistributionSet> loadBackendEntities(final PageRequest pageRequest, final String filter) {
|
||||
final DistributionSetFilterBuilder builder = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||
.setIsComplete(true).setIsValid(true);
|
||||
protected Slice<DistributionSet> loadBackendEntities(final PageRequest pageRequest, final String filter) {
|
||||
return distributionSetManagement.findByDistributionSetFilter(pageRequest, buildDsFilter(filter));
|
||||
}
|
||||
|
||||
private DistributionSetFilter buildDsFilter(final String filter) {
|
||||
final DistributionSetFilterBuilder dsFilterBuilder = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||
.setIsComplete(true).setIsValid(true);
|
||||
if (!StringUtils.isEmpty(filter)) {
|
||||
builder.setFilterString(filter);
|
||||
dsFilterBuilder.setSearchText(filter);
|
||||
}
|
||||
|
||||
return distributionSetManagement.findByDistributionSetFilter(pageRequest, builder.build());
|
||||
return dsFilterBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long sizeInBackEnd(final PageRequest pageRequest, final String filter) {
|
||||
return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
|
||||
return distributionSetManagement.countByDistributionSetFilter(buildDsFilter(filter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ public class DsMetaDataDataProvider extends AbstractMetaDataDataProvider<Distrib
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return loadBackendEntities(PageRequest.of(0, 1), dsId).getTotalElements();
|
||||
return distributionSetManagement.countMetaDataByDistributionSetId(dsId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ public class SmMetaDataDataProvider extends AbstractMetaDataDataProvider<Softwar
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return loadBackendEntities(PageRequest.of(0, 1), smId).getTotalElements();
|
||||
return softwareModuleManagement.countMetaDataBySoftwareModuleId(smId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ public class TargetFilterQueryDataProvider
|
||||
return targetFilterQueryManagement.count();
|
||||
}
|
||||
|
||||
return targetFilterQueryManagement.findByName(PageRequest.of(0, 1), filter).getTotalElements();
|
||||
return targetFilterQueryManagement.countByName(filter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.eclipse.hawkbit.ui.common.data.mappers.TargetFilterQueryToProxyTarget
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
|
||||
@@ -44,12 +45,12 @@ public class TargetFilterQueryDetailsDataProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Page<TargetFilterQuery> loadBackendEntities(final PageRequest pageRequest, final Long dsId) {
|
||||
protected Slice<TargetFilterQuery> loadBackendEntities(final PageRequest pageRequest, final Long dsId) {
|
||||
if (dsId == null) {
|
||||
return Page.empty(pageRequest);
|
||||
}
|
||||
|
||||
return targetFilterQueryManagement.findByAutoAssignDSAndRsql(pageRequest, dsId, null);
|
||||
return targetFilterQueryManagement.findByAutoAssignDistributionSetId(pageRequest, dsId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,6 +59,6 @@ public class TargetFilterQueryDetailsDataProvider
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return loadBackendEntities(PageRequest.of(0, 1), dsId).getTotalElements();
|
||||
return targetFilterQueryManagement.countByAutoAssignDistributionSetId(dsId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public class TargetMetaDataDataProvider extends AbstractMetaDataDataProvider<Tar
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return targetManagement.findMetaDataByControllerId(PageRequest.of(0, 1), currentlySelectedControllerId)
|
||||
.getTotalElements();
|
||||
return targetManagement.countMetaDataByControllerId(currentlySelectedControllerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class TargetTagDataProvider extends AbstractProxyDataProvider<ProxyTag, T
|
||||
|
||||
@Override
|
||||
protected long sizeInBackEnd(final PageRequest pageRequest, final Void filter) {
|
||||
return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
|
||||
return tagManagementService.count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import org.eclipse.hawkbit.repository.TargetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.IdentifiableEntityToProxyIdentifiableEntityMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -35,26 +35,32 @@ public class TargetTypeDataProvider<T extends ProxyIdentifiableEntity>
|
||||
* Constructor
|
||||
*
|
||||
* @param targetTypeManagement
|
||||
* TargetTypeManagement
|
||||
* TargetTypeManagement
|
||||
* @param mapper
|
||||
* Mapper
|
||||
* Mapper
|
||||
*/
|
||||
public TargetTypeDataProvider(final TargetTypeManagement targetTypeManagement, IdentifiableEntityToProxyIdentifiableEntityMapper<T, TargetType> mapper) {
|
||||
public TargetTypeDataProvider(final TargetTypeManagement targetTypeManagement,
|
||||
final IdentifiableEntityToProxyIdentifiableEntityMapper<T, TargetType> mapper) {
|
||||
super(mapper, Sort.by(Direction.ASC, "name"));
|
||||
this.targetTypeManagement = targetTypeManagement;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Page<TargetType> loadBackendEntities(PageRequest pageRequest, String filter) {
|
||||
if (!StringUtils.isEmpty(filter)){
|
||||
return targetTypeManagement.findByName(pageRequest, filter);
|
||||
protected Slice<TargetType> loadBackendEntities(final PageRequest pageRequest, final String filter) {
|
||||
if (StringUtils.isEmpty(filter)) {
|
||||
return targetTypeManagement.findAll(pageRequest);
|
||||
}
|
||||
return targetTypeManagement.findAll(pageRequest);
|
||||
|
||||
return targetTypeManagement.findByName(pageRequest, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long sizeInBackEnd(PageRequest pageRequest, String filter) {
|
||||
return loadBackendEntities(PageRequest.of(0, 1), filter).getTotalElements();
|
||||
protected long sizeInBackEnd(final PageRequest pageRequest, final String filter) {
|
||||
if (StringUtils.isEmpty(filter)) {
|
||||
return targetTypeManagement.count();
|
||||
}
|
||||
|
||||
return targetTypeManagement.countByName(filter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,6 @@ public class ProxyDistributionSet extends ProxyNamedEntity implements VersionAwa
|
||||
ds.setId(dsInfo.getId());
|
||||
ds.setName(dsInfo.getName());
|
||||
ds.setVersion(dsInfo.getVersion());
|
||||
ds.setTypeInfo(new ProxyTypeInfo(dsInfo.getDsTypeId(), null));
|
||||
ds.setNameVersion(dsInfo.getNameVersion());
|
||||
ds.setIsValid(dsInfo.isValid());
|
||||
|
||||
@@ -170,12 +169,12 @@ public class ProxyDistributionSet extends ProxyNamedEntity implements VersionAwa
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Id, name, version, dsTypeId and invalidation state of distribution
|
||||
* set
|
||||
* Gets the Id, name, version, dsTypeId and invalidation state of
|
||||
* distribution set
|
||||
*
|
||||
* @return proxy of Id, name, version, dsTypeId and invalidation state
|
||||
*/
|
||||
public ProxyDistributionSetInfo getInfo() {
|
||||
return new ProxyDistributionSetInfo(getId(), getName(), getVersion(), getTypeInfo().getId(), getIsValid());
|
||||
return new ProxyDistributionSetInfo(getId(), getName(), getVersion(), getIsValid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ public class ProxyDistributionSetInfo extends ProxyIdentifiableEntity {
|
||||
private String name;
|
||||
private String version;
|
||||
private String nameVersion;
|
||||
private Long dsTypeId;
|
||||
private boolean isValid;
|
||||
|
||||
/**
|
||||
@@ -40,18 +39,14 @@ public class ProxyDistributionSetInfo extends ProxyIdentifiableEntity {
|
||||
* distribution set name
|
||||
* @param version
|
||||
* distribution set version
|
||||
* @param dsTypeId
|
||||
* ID of the assigned dsType
|
||||
* @param isValid
|
||||
* invalidation state
|
||||
*/
|
||||
public ProxyDistributionSetInfo(final Long id, final String name, final String version, final Long dsTypeId,
|
||||
final boolean isValid) {
|
||||
public ProxyDistributionSetInfo(final Long id, final String name, final String version, final boolean isValid) {
|
||||
super(id);
|
||||
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.dsTypeId = dsTypeId;
|
||||
this.isValid = isValid;
|
||||
this.nameVersion = HawkbitCommonUtil.getFormattedNameVersion(name, version);
|
||||
}
|
||||
@@ -88,19 +83,11 @@ public class ProxyDistributionSetInfo extends ProxyIdentifiableEntity {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
public Long getDsTypeId() {
|
||||
return dsTypeId;
|
||||
}
|
||||
|
||||
public void setDsTypeId(final Long dsTypeId) {
|
||||
this.dsTypeId = dsTypeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// nameVersion is ignored because it is a composition of name and
|
||||
// version
|
||||
return Objects.hash(getId(), getName(), getVersion(), getDsTypeId(), isValid());
|
||||
return Objects.hash(getId(), getName(), getVersion(), isValid());
|
||||
}
|
||||
|
||||
// equals method requires all of the used conditions
|
||||
@@ -119,7 +106,6 @@ public class ProxyDistributionSetInfo extends ProxyIdentifiableEntity {
|
||||
// version
|
||||
return Objects.equals(this.getId(), other.getId()) && Objects.equals(this.getName(), other.getName())
|
||||
&& Objects.equals(this.getVersion(), other.getVersion())
|
||||
&& Objects.equals(this.getDsTypeId(), other.getDsTypeId())
|
||||
&& Objects.equals(this.isValid(), other.isValid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class SwModulesToDistributionSetAssignmentSupport
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ds.getIsValid()) {
|
||||
if (Boolean.FALSE.equals(ds.getIsValid())) {
|
||||
/* Distribution is invalidated */
|
||||
addSpecificValidationErrorMessage(
|
||||
i18n.getMessage(UIMessageIdProvider.MESSAGE_ERROR_DISTRIBUTIONSET_INVALID, ds.getNameVersion()));
|
||||
@@ -145,8 +145,8 @@ public class SwModulesToDistributionSetAssignmentSupport
|
||||
private boolean checkDuplicateSmToDsAssignment(final ProxySoftwareModule sm, final ProxyDistributionSet ds,
|
||||
final Collection<Long> smIdsAlreadyAssignedToDs) {
|
||||
if (!CollectionUtils.isEmpty(smIdsAlreadyAssignedToDs) && smIdsAlreadyAssignedToDs.contains(sm.getId())) {
|
||||
addSpecificValidationErrorMessage(i18n.getMessage("message.software.dist.already.assigned", sm.getNameAndVersion(),
|
||||
ds.getNameVersion()));
|
||||
addSpecificValidationErrorMessage(i18n.getMessage("message.software.dist.already.assigned",
|
||||
sm.getNameAndVersion(), ds.getNameVersion()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,8 +158,8 @@ public class SwModulesToDistributionSetAssignmentSupport
|
||||
if (!dsType.containsModuleType(sm.getTypeInfo().getId())) {
|
||||
final String smTypeName = smTypeManagement.get(sm.getTypeInfo().getId()).map(SoftwareModuleType::getName)
|
||||
.orElse("");
|
||||
addSpecificValidationErrorMessage(i18n.getMessage("message.software.dist.type.notallowed", sm.getNameAndVersion(),
|
||||
ds.getNameVersion(), smTypeName));
|
||||
addSpecificValidationErrorMessage(i18n.getMessage("message.software.dist.type.notallowed",
|
||||
sm.getNameAndVersion(), ds.getNameVersion(), smTypeName));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,7 @@ public class DistributionSetGrid extends AbstractDsGrid<DsDistributionsFilterPar
|
||||
}
|
||||
|
||||
setFilterSupport(new FilterSupport<>(
|
||||
new DistributionSetDistributionsStateDataProvider(dsManagement, dsTypeManagement,
|
||||
dsToProxyDistributionMapper),
|
||||
new DistributionSetDistributionsStateDataProvider(dsManagement, dsToProxyDistributionMapper),
|
||||
DsDistributionsFilterParams::new, getSelectionSupport()::deselectAll));
|
||||
initFilterMappings();
|
||||
getFilterSupport().setFilter(new DsDistributionsFilterParams());
|
||||
@@ -105,10 +104,10 @@ public class DistributionSetGrid extends AbstractDsGrid<DsDistributionsFilterPar
|
||||
|
||||
private static String getRowStyle(final ProxyDistributionSet ds) {
|
||||
final StringBuilder style = new StringBuilder();
|
||||
if (!ds.getIsComplete()) {
|
||||
if (Boolean.FALSE.equals(ds.getIsComplete())) {
|
||||
style.append(SPUIDefinitions.INCOMPLETE_DISTRIBUTION);
|
||||
}
|
||||
if (!ds.getIsValid()) {
|
||||
if (Boolean.FALSE.equals(ds.getIsValid())) {
|
||||
style.append(" ");
|
||||
style.append(SPUIDefinitions.INVALID_DISTRIBUTION);
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ public class RolloutFormLayout extends ValidatableLayout {
|
||||
private Long rolloutId;
|
||||
private Long totalTargets;
|
||||
|
||||
private Consumer<String> filterQueryChangedListener;
|
||||
private Consumer<Long> distSetChangedListener;
|
||||
private Consumer<ProxyTargetFilterQuery> filterQueryChangedListener;
|
||||
private Consumer<ProxyDistributionSet> distSetChangedListener;
|
||||
|
||||
/**
|
||||
* Constructor for RolloutFormLayout
|
||||
@@ -204,7 +204,7 @@ public class RolloutFormLayout extends ValidatableLayout {
|
||||
private HasValue.ValueChangeListener<ProxyTargetFilterQuery> filterQueryChangedListener() {
|
||||
return event -> {
|
||||
if (filterQueryChangedListener != null) {
|
||||
filterQueryChangedListener.accept(event.getValue() != null ? event.getValue().getQuery() : null);
|
||||
filterQueryChangedListener.accept(event.getValue());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -212,11 +212,7 @@ public class RolloutFormLayout extends ValidatableLayout {
|
||||
private HasValue.ValueChangeListener<ProxyDistributionSet> distSetChangedListener() {
|
||||
return event -> {
|
||||
if (distSetChangedListener != null) {
|
||||
if (event.getValue() != null && event.getValue().getTypeInfo() != null) {
|
||||
distSetChangedListener.accept(event.getValue().getTypeInfo().getId());
|
||||
} else {
|
||||
distSetChangedListener.accept(null);
|
||||
}
|
||||
distSetChangedListener.accept(event.getValue());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -300,7 +296,7 @@ public class RolloutFormLayout extends ValidatableLayout {
|
||||
* @param filterQueryChangedListener
|
||||
* Changed listener
|
||||
*/
|
||||
public void setFilterQueryChangedListener(final Consumer<String> filterQueryChangedListener) {
|
||||
public void setFilterQueryChangedListener(final Consumer<ProxyTargetFilterQuery> filterQueryChangedListener) {
|
||||
this.filterQueryChangedListener = filterQueryChangedListener;
|
||||
}
|
||||
|
||||
@@ -310,7 +306,7 @@ public class RolloutFormLayout extends ValidatableLayout {
|
||||
* @param distSetChangedListener
|
||||
* Changed listener
|
||||
*/
|
||||
public void setDistSetChangedListener(final Consumer<Long> distSetChangedListener) {
|
||||
public void setDistSetChangedListener(final Consumer<ProxyDistributionSet> distSetChangedListener) {
|
||||
this.distSetChangedListener = distSetChangedListener;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.eclipse.hawkbit.ui.rollout.window.RolloutWindowDependencies;
|
||||
import org.eclipse.hawkbit.ui.rollout.window.components.AutoStartOptionGroupLayout.AutoStartOption;
|
||||
import org.eclipse.hawkbit.ui.rollout.window.layouts.AddRolloutWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -94,9 +94,9 @@ public class CopyRolloutWindowController extends AddRolloutWindowController {
|
||||
}
|
||||
|
||||
private void setTargetFilterId(final ProxyRolloutWindow proxyRolloutWindow) {
|
||||
final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement.findByQuery(PageRequest.of(0, 1),
|
||||
final Slice<TargetFilterQuery> filterQueries = targetFilterQueryManagement.findByQuery(PageRequest.of(0, 1),
|
||||
proxyRolloutWindow.getTargetFilterQuery());
|
||||
if (filterQueries.getTotalElements() > 0) {
|
||||
if (filterQueries.getNumberOfElements() > 0) {
|
||||
final TargetFilterQuery tfq = filterQueries.getContent().get(0);
|
||||
proxyRolloutWindow
|
||||
.setTargetFilterInfo(new ProxyTargetFilterQueryInfo(tfq.getId(), tfq.getName(), tfq.getQuery()));
|
||||
|
||||
@@ -11,10 +11,15 @@ package org.eclipse.hawkbit.ui.rollout.window.layouts;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyAdvancedRolloutGroup;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyRolloutWindow;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyRolloutWindow.GroupDefinitionMode;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.rollout.window.RolloutWindowDependencies;
|
||||
import org.eclipse.hawkbit.ui.rollout.window.components.AdvancedGroupsLayout;
|
||||
import org.eclipse.hawkbit.ui.rollout.window.components.RolloutFormLayout;
|
||||
@@ -34,6 +39,7 @@ import com.vaadin.ui.TabSheet;
|
||||
public class AddRolloutWindowLayout extends AbstractRolloutWindowLayout {
|
||||
|
||||
private final TargetManagement targetManagement;
|
||||
private final DistributionSetManagement dsManagement;
|
||||
|
||||
private final RolloutFormLayout rolloutFormLayout;
|
||||
private final SimpleGroupsLayout simpleGroupsLayout;
|
||||
@@ -57,6 +63,7 @@ public class AddRolloutWindowLayout extends AbstractRolloutWindowLayout {
|
||||
super(dependencies);
|
||||
|
||||
this.targetManagement = dependencies.getTargetManagement();
|
||||
this.dsManagement = dependencies.getDistributionSetManagement();
|
||||
|
||||
this.rolloutFormLayout = rolloutComponentBuilder.createRolloutFormLayout();
|
||||
this.simpleGroupsLayout = rolloutComponentBuilder.createSimpleGroupsLayout();
|
||||
@@ -90,8 +97,8 @@ public class AddRolloutWindowLayout extends AbstractRolloutWindowLayout {
|
||||
advancedGroupsLayout.setAdvancedGroupDefinitionsChangedListener(this::onAdvancedGroupsChanged);
|
||||
}
|
||||
|
||||
private void onFilterQueryChange(final String filterQuery) {
|
||||
this.filterQuery = filterQuery;
|
||||
private void onFilterQueryChange(final ProxyTargetFilterQuery targetFilterQuery) {
|
||||
filterQuery = targetFilterQuery != null ? targetFilterQuery.getQuery() : null;
|
||||
updateTotalTargets();
|
||||
|
||||
if (isAdvancedGroupsTabSelected()) {
|
||||
@@ -99,8 +106,8 @@ public class AddRolloutWindowLayout extends AbstractRolloutWindowLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void onDistSetTypeChange(final Long dsTypeId) {
|
||||
this.dsTypeId = dsTypeId;
|
||||
private void onDistSetTypeChange(final ProxyDistributionSet ds) {
|
||||
dsTypeId = ds != null ? getDsTypeId(ds) : null;
|
||||
updateTotalTargets();
|
||||
|
||||
if (isAdvancedGroupsTabSelected()) {
|
||||
@@ -108,8 +115,16 @@ public class AddRolloutWindowLayout extends AbstractRolloutWindowLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private Long getDsTypeId(final @NotNull ProxyDistributionSet ds) {
|
||||
if (ds.getTypeInfo() != null) {
|
||||
return ds.getTypeInfo().getId();
|
||||
}
|
||||
|
||||
return dsManagement.get(ds.getId()).map(dist -> dist.getType().getId()).orElse(null);
|
||||
}
|
||||
|
||||
private void updateTotalTargets() {
|
||||
this.totalTargets = getTotalTargets(filterQuery, dsTypeId);
|
||||
totalTargets = getTotalTargets(filterQuery, dsTypeId);
|
||||
rolloutFormLayout.setTotalTargets(totalTargets);
|
||||
visualGroupDefinitionLayout.setTotalTargets(totalTargets);
|
||||
if (isSimpleGroupsTabSelected()) {
|
||||
|
||||
Reference in New Issue
Block a user