Refactor TargetIdName, DistributionSetIdName, SoftwareModuleIdName entities (#407)

* - Move TargetIdName, DistributionSetIdName, SoftwareModuleIdName to ui
entity package

- Refactor tables. Use the entity id instead of the *idname entity

- Remove expensive getEntity() calls from remote events

- Fix some NPE, if entity is deleted from another session

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Add TagretFilter Query client resource

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Fix methode signature for feign

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* fix sonar issue after merge

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* remove ds set id name after merging from rollout view

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
Dennis Melzer
2017-01-31 09:19:59 +01:00
committed by Kai Zimmermann
parent 59f218e841
commit 9980fd5619
62 changed files with 876 additions and 1139 deletions

View File

@@ -126,8 +126,8 @@ public interface DistributionSetManagement {
* @return the new persisted {@link DistributionSet}
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSet#getModules()} or
* if a provided linked entity does not exists (
* {@link DistributionSet#getModules()} or
* {@link DistributionSet#getType()})
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
* is {@link DistributionSet} does not contain mandatory
@@ -163,8 +163,8 @@ public interface DistributionSetManagement {
* to be created
* @return the new {@link DistributionSet}s
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSet#getModules()} or
* if a provided linked entity does not exists (
* {@link DistributionSet#getModules()} or
* {@link DistributionSet#getType()})
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
* is {@link DistributionSet} does not contain mandatory
@@ -181,8 +181,8 @@ public interface DistributionSetManagement {
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSetType#getMandatoryModuleTypes()} or
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
@@ -196,8 +196,8 @@ public interface DistributionSetManagement {
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSetType#getMandatoryModuleTypes()} or
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
@@ -426,7 +426,7 @@ public interface DistributionSetManagement {
* @param distributionSetFilterBuilder
* has details of filters to be applied
* @param assignedOrInstalled
* the controllerID of the Target to be ordered by
* the id of the Target to be ordered by
* @return {@link DistributionSet}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
@@ -707,4 +707,14 @@ public interface DistributionSetManagement {
DistributionSetType assignMandatorySoftwareModuleTypes(@NotNull Long dsTypeId,
@NotEmpty Collection<Long> softwareModuleTypes);
/**
* Retrieves all distribution set without details.
*
* @param ids
* the ids to for
* @return the found {@link DistributionSet}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
List<DistributionSet> findDistributionSetAllById(@NotNull Collection<Long> ids);
}

View File

@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
@@ -179,7 +178,7 @@ public interface TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
void deleteTargets(@NotEmpty Collection<Long> targetIDs);
/**
* Deletes target with the given IDs.
*
@@ -192,52 +191,6 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
void deleteTarget(@NotEmpty String controllerID);
/**
* Finds all targets for all the given parameters but returns not the full
* target but {@link TargetIdName}.
*
* @param pageRequest
* the pageRequest to enhance the query for paging and sorting
* @param filterByStatus
* find targets having this {@link TargetUpdateStatus}s. Set to
* <code>null</code> in case this is not required.
* @param overdueState
* find targets that are overdue (targets that did not respond
* during the configured intervals: poll_itvl + overdue_itvl).
* @param filterBySearchText
* to find targets having the text anywhere in name or
* description. Set <code>null</code> in case this is not
* required.
* @param installedOrAssignedDistributionSetId
* to find targets having the {@link DistributionSet} as
* installed or assigned. Set to <code>null</code> in case this
* is not required.
* @param filterByTagNames
* to find targets which are having any one in this tag names.
* Set <code>null</code> in case this is not required.
* @param selectTargetWithNoTag
* flag to select targets with no tag assigned
*
* @return the found {@link TargetIdName}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<TargetIdName> findAllTargetIdsByFilters(@NotNull Pageable pageRequest,
Collection<TargetUpdateStatus> filterByStatus, Boolean overdueState, String filterBySearchText,
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... filterByTagNames);
/**
* Finds all targets for all the given parameter {@link TargetFilterQuery}
* and returns not the full target but {@link TargetIdName}.
*
* @param pageRequest
* the pageRequest to enhance the query for paging and sorting
* @param rsqlParam
* filter definition in RSQL syntax
* @return the found {@link TargetIdName}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest, @NotNull String rsqlParam);
/**
* Finds all targets for all the given parameter {@link TargetFilterQuery}
* and that don't have the specified distribution set in their action
@@ -351,9 +304,9 @@ public interface TargetManagement {
@NotNull Pageable pageReq);
/**
* Find {@link Target} based on given ID returns found Target without
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
* possible.
* Find {@link Target}s based a given IDs. The returned target will not
* contain details (e.g {@link Target#getTags()} and
* {@link Target#getActions()})
*
* @param controllerIDs
* to look for.
@@ -363,9 +316,9 @@ public interface TargetManagement {
List<Target> findTargetByControllerID(@NotEmpty Collection<String> controllerIDs);
/**
* Find {@link Target} based on given ID returns found Target without
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
* possible.
* Find a {@link Target} based a given ID. The returned target will not
* contain details (e.g {@link Target#getTags()} and
* {@link Target#getActions()})
*
* @param controllerId
* to look for.
@@ -639,4 +592,27 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
Target updateTarget(@NotNull TargetUpdate update);
/**
* Find a {@link Target} based a given ID. The returned target will not
* contain details (e.g {@link Target#getTags()} and
* {@link Target#getActions()})
*
* @param id
* to look for
* @return {@link Target} or <code>null</code> if it does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Target findTargetById(Long id);
/**
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
* and {@link Target#getActions()} possible
*
* @param ids
* the ids to for
* @return the found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Target> findTargetAllById(@NotNull Collection<Long> ids);
}

View File

@@ -41,13 +41,6 @@ public interface Target extends NamedEntity {
*/
List<Action> getActions();
/**
* @return {@link TargetIdName} view of the {@link Target}.
*/
default TargetIdName getTargetIdName() {
return new TargetIdName(getId(), getControllerId(), getName());
}
/**
* @return the targetInfo object
*/

View File

@@ -1,93 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations 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.repository.model;
import java.io.Serializable;
/**
* ID class of the {@link Target} which contains the
* {@link Target#getControllerId()} and the {@link Target#getName()} in one
* object. Often it's necessary to remember the IDs of the {@link Target} and
* the resolve for e.g. the UI the name of the target, this is very costly
* operation, so it's much better if the ID and the name of the {@link Target}
* is already in memory available.
*/
public class TargetIdName implements Serializable {
private static final long serialVersionUID = 1L;
private final long targetId;
private String controllerId;
private String name;
/**
* @param targetId
* the ID of the target.
* @param controllerId
* the {@link Target#getControllerId()}
* @param name
* the {@link Target#getName()}
*/
public TargetIdName(final long targetId, final String controllerId, final String name) {
this.targetId = targetId;
this.controllerId = controllerId;
this.name = name;
}
public String getControllerId() {
return controllerId;
}
public String getName() {
return name;
}
public void setControllerId(final String id) {
controllerId = id;
}
public void setName(final String name) {
this.name = name;
}
public long getTargetId() {
return targetId;
}
@Override
// Exception squid:S864 - generated code
@SuppressWarnings("squid:S864")
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (targetId ^ targetId >>> 32);
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TargetIdName other = (TargetIdName) obj;
return targetId == other.targetId;
}
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
// id in the dom
return controllerId;
}
}

View File

@@ -131,4 +131,9 @@ public interface DistributionSetRepository
* @return number of found {@link DistributionSet}s
*/
long countByNameAndVersion(String name, String version);
@Override
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
@Query("SELECT d FROM JpaDistributionSet d WHERE d.id IN ?1")
List<JpaDistributionSet> findAll(Iterable<Long> ids);
}

View File

@@ -896,4 +896,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
return distributionSetRepository.countByTypeId(typeId);
}
@Override
public List<DistributionSet> findDistributionSetAllById(final Collection<Long> ids) {
return Collections.unmodifiableList(distributionSetRepository.findAll(ids));
}
}

View File

@@ -22,7 +22,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
@@ -51,7 +50,6 @@ import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
@@ -65,8 +63,6 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Isolation;
@@ -508,70 +504,6 @@ public class JpaTargetManagement implements TargetManagement {
return targetRepository.countByTargetInfoInstalledDistributionSetId(distId);
}
@Override
public List<TargetIdName> findAllTargetIdsByFilters(final Pageable pageRequest,
final Collection<TargetUpdateStatus> filterByStatus, final Boolean overdueState,
final String filterBySearchText, final Long installedOrAssignedDistributionSetId,
final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
final Root<JpaTarget> targetRoot = query.from(JpaTarget.class);
List<Object[]> resultList;
String sortProperty = JpaTarget_.id.getName();
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
sortProperty = pageRequest.getSort().iterator().next().getProperty();
}
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(JpaTarget_.id),
targetRoot.get(JpaTarget_.controllerId), targetRoot.get(JpaTarget_.name), targetRoot.get(sortProperty));
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
buildSpecificationList(new FilterParams(installedOrAssignedDistributionSetId, filterByStatus,
overdueState, filterBySearchText, selectTargetWithNoTag, filterByTagNames), false),
targetRoot, multiselect, cb);
// if we have some predicates then add it to the where clause of the
// multiselect
if (specificationsForMultiSelect.length > 0) {
multiselect.where(specificationsForMultiSelect);
}
resultList = getTargetIdNameResultSet(pageRequest, cb, targetRoot, multiselect);
return resultList.parallelStream().map(o -> new TargetIdName((long) o[0], o[1].toString(), o[2].toString()))
.collect(Collectors.toList());
}
@Override
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final Pageable pageRequest,
final String targetFilterQuery) {
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
final Root<JpaTarget> targetRoot = query.from(JpaTarget.class);
String sortProperty = JpaTarget_.id.getName();
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
sortProperty = pageRequest.getSort().iterator().next().getProperty();
}
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(JpaTarget_.id),
targetRoot.get(JpaTarget_.controllerId), targetRoot.get(JpaTarget_.name), targetRoot.get(sortProperty));
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
virtualPropertyReplacer);
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(Lists.newArrayList(spec), targetRoot,
multiselect, cb);
// if we have some predicates then add it to the where clause of the
// multiselect
if (specificationsForMultiSelect.length > 0) {
multiselect.where(specificationsForMultiSelect);
}
final List<Object[]> resultList = getTargetIdNameResultSet(pageRequest, cb, targetRoot, multiselect);
return resultList.parallelStream().map(o -> new TargetIdName((long) o[0], o[1].toString(), o[2].toString()))
.collect(Collectors.toList());
}
@Override
public Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull final Pageable pageRequest,
final Long distributionSetId, @NotNull final String targetFilterQuery) {
@@ -686,26 +618,14 @@ public class JpaTargetManagement implements TargetManagement {
});
}
private List<Object[]> getTargetIdNameResultSet(final Pageable pageRequest, final CriteriaBuilder cb,
final Root<JpaTarget> targetRoot, final CriteriaQuery<Object[]> multiselect) {
List<Object[]> resultList;
if (pageRequest.getSort() != null) {
final List<Order> orders = new ArrayList<>();
final Sort sort = pageRequest.getSort();
for (final Sort.Order sortOrder : sort) {
if (sortOrder.getDirection() == Direction.ASC) {
orders.add(cb.asc(targetRoot.get(sortOrder.getProperty())));
} else {
orders.add(cb.desc(targetRoot.get(sortOrder.getProperty())));
}
}
multiselect.orderBy(orders);
resultList = entityManager.createQuery(multiselect).setFirstResult(pageRequest.getOffset())
.setMaxResults(pageRequest.getPageSize()).getResultList();
} else {
resultList = entityManager.createQuery(multiselect).getResultList();
}
return resultList;
@Override
public Target findTargetById(final Long id) {
return targetRepository.findOne(id);
}
@Override
public List<Target> findTargetAllById(final Collection<Long> ids) {
return Collections.unmodifiableList(targetRepository.findAll(ids));
}
}

View File

@@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.ActionStatusFields;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.exception.ForceQuitActionNotAllowedException;

View File

@@ -20,6 +20,8 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException;
@@ -34,6 +36,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.eclipse.hawkbit.repository.test.util.WithUser;
import org.fest.assertions.core.Condition;
import org.junit.Test;
@@ -751,4 +755,25 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
assertThat(distributionSetRepository.findAll()).hasSize(1);
}
@Test
@Description("Verify that the find all by ids contains the entities which are looking for")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 12),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 36) })
public void verifyFindDistributionSetAllById() {
final List<Long> searchIds = new ArrayList<>();
searchIds.add(testdataFactory.createDistributionSet("ds-4").getId());
searchIds.add(testdataFactory.createDistributionSet("ds-5").getId());
searchIds.add(testdataFactory.createDistributionSet("ds-6").getId());
for (int i = 0; i < 9; i++) {
testdataFactory.createDistributionSet("test" + i);
}
final List<DistributionSet> foundDs = distributionSetManagement.findDistributionSetAllById(searchIds);
assertThat(foundDs).hasSize(3);
final List<Long> collect = foundDs.stream().map(DistributionSet::getId).collect(Collectors.toList());
assertThat(collect).containsAll(searchIds);
}
}

View File

@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
@@ -163,9 +162,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
@Step
private void verfiyThat1TargetAIsInStatusPendingAndHasDSInstalled(final DistributionSet installedSet,
final List<TargetUpdateStatus> pending, final Target expected) {
final TargetIdName expectedIdName = convertToIdName(expected);
final String query = "updatestatus==pending and installedds.name==" + installedSet.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, pending, null, null, installedSet.getId(), Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(1)
@@ -176,19 +173,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, installedSet.getId(),
Boolean.FALSE, new String[0])).as("has number of elements").hasSize(1)
.as("and contains the following elements").containsExactly(expectedIdName)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat200targetsWithGivenTagAreInStatusPendingorUnknown(final TargetTag targTagW,
final List<TargetUpdateStatus> both, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName();
assertThat(targetManagement
@@ -199,27 +188,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, both, null, null, null, Boolean.FALSE,
targTagW.getName())).as("has number of elements").hasSize(200).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
private static List<TargetIdName> convertToIdNames(final List<Target> expected) {
return expected.stream()
.map(target -> new TargetIdName(target.getId(), target.getControllerId(), target.getName()))
.collect(Collectors.toList());
}
private static TargetIdName convertToIdName(final Target target) {
return new TargetIdName(target.getId(), target.getControllerId(), target.getName());
}
@Step
private void verifyThat2TargetsWithGivenTagAreInPending(final TargetTag targTagW,
final List<TargetUpdateStatus> pending, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==pending and tag==" + targTagW.getName();
assertThat(targetManagement
@@ -231,17 +204,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, null, Boolean.FALSE,
targTagW.getName())).as("has number of elements").hasSize(2).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat2TargetsWithGivenTagAndDSIsInPending(final TargetTag targTagW, final DistributionSet setA,
final List<TargetUpdateStatus> pending, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ") and tag==" + targTagW.getName();
@@ -254,17 +221,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, null, Boolean.FALSE,
targTagW.getName())).as("has number of elements").hasSize(2).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat1TargetWithGivenNameOrDescAndTagAndDSIsInPending(final TargetTag targTagW,
final DistributionSet setA, final List<TargetUpdateStatus> pending, final Target expected) {
final TargetIdName expectedIdName = convertToIdName(expected);
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ") and (name==*targ-B* or description==*targ-B*) and tag==" + targTagW.getName();
@@ -276,18 +237,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, "%targ-B%", setA.getId(),
Boolean.FALSE, targTagW.getName())).as("has number of elements").hasSize(1)
.as("and contains the following elements").containsExactly(expectedIdName)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat1TargetWithGivenNameOrDescAndDSIsInPending(final DistributionSet setA,
final List<TargetUpdateStatus> pending, final Target expected) {
final TargetIdName expectedIdName = convertToIdName(expected);
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ") and (name==*targ-A* or description==*targ-A*)";
@@ -300,18 +254,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, "%targ-A%", setA.getId(),
Boolean.FALSE, new String[0])).as("has number of elements").hasSize(1)
.as("and contains the following elements").containsExactly(expectedIdName)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat3TargetsWithGivenDSAreInPending(final DistributionSet setA,
final List<TargetUpdateStatus> pending, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ")";
@@ -324,17 +271,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, setA.getId(), Boolean.FALSE,
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat3TargetsAreInStatusPending(final List<TargetUpdateStatus> pending,
final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==pending";
assertThat(targetManagement
@@ -345,17 +286,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, null, Boolean.FALSE,
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat99TargetsWithGivenNameOrDescAndTagAreInStatusUnknown(final TargetTag targTagW,
final List<TargetUpdateStatus> unknown, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==unknown and (name==*targ-B* or description==*targ-B*) and tag=="
+ targTagW.getName();
@@ -368,17 +303,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, "%targ-B%", null, Boolean.FALSE,
targTagW.getName())).as("has number of elements").hasSize(99).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat99TargetsWithNameOrDescriptionAreInGivenStatus(final List<TargetUpdateStatus> unknown,
final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)";
assertThat(targetManagement
@@ -391,10 +320,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, "%targ-A%", null, Boolean.FALSE,
new String[0])).as("has number of elements").hasSize(99).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
@@ -411,17 +336,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
setA.getId(), Boolean.FALSE, new String[0])))
.as("and filter query returns the same result")
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, setA.getId(), Boolean.FALSE,
new String[0])).as("has number of elements").hasSize(0)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat198TargetsAreInStatusUnknownAndHaveGivenTags(final TargetTag targTagY,
final TargetTag targTagW, final List<TargetUpdateStatus> unknown, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName()
+ ")";
@@ -433,18 +352,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, null, Boolean.FALSE,
targTagY.getName(), targTagW.getName())).as("has number of elements").hasSize(198)
.as("and contains the following elements").containsAll(expectedIdNames)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat397TargetsAreInStatusUnknown(final List<TargetUpdateStatus> unknown,
final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "updatestatus==unknown";
assertThat(targetManagement
@@ -456,16 +368,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, null, Boolean.FALSE,
new String[0])).as("has number of elements").hasSize(397).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat198TargetsAreInStatusUnknownAndOverdue(final List<TargetUpdateStatus> unknown,
final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
// be careful: simple filters are concatenated using AND-gating
final String query = "lastcontrollerrequestat=le=${overdue_ts};updatestatus==UNKNOWN";
@@ -478,16 +385,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, Boolean.TRUE, null, null, Boolean.FALSE,
new String[0])).as("has number of elements").hasSize(198).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat1TargetWithDescOrNameHasDS(final DistributionSet setA, final Target expected) {
final TargetIdName expectedIdName = convertToIdName(expected);
final String query = "(name==*targ-A* or description==*targ-A*) and (assignedds.name==" + setA.getName()
+ " or installedds.name==" + setA.getName() + ")";
@@ -501,16 +402,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-A%", setA.getId(),
Boolean.FALSE, new String[0])).as("has number of elements").hasSize(1)
.as("and contains the following elements").containsExactly(expectedIdName)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat3TargetsHaveDSAssigned(final DistributionSet setA, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName();
assertThat(targetManagement
@@ -523,10 +418,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, null, setA.getId(), Boolean.FALSE,
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
@@ -542,10 +433,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-C%", setA.getId(),
Boolean.FALSE, targTagX.getName())).as("has number of elements").hasSize(0)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
@@ -561,16 +448,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-A%", setA.getId(),
Boolean.FALSE, targTagW.getName())).as("has number of elements").hasSize(0)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
private void verifyThat1TargetHasTagHasDescOrNameAndDs(final TargetTag targTagW, final DistributionSet setA,
final Target expected) {
final TargetIdName expectedIdName = convertToIdName(expected);
final String query = "(name==*targ-c* or description==*targ-C*) and tag==" + targTagW.getName()
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement
@@ -583,11 +465,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-C%", setA.getId(),
Boolean.FALSE, targTagW.getName())).as("has number of elements").hasSize(1)
.as("and contains the following elements").containsExactly(expectedIdName)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step
@@ -605,7 +482,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
@Step
private void verifyThat100TargetsContainsGivenTextAndHaveTagAssigned(final TargetTag targTagY,
final TargetTag targTagW, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "(name==*targ-B* or description==*targ-B*) and (tag==" + targTagY.getName() + " or tag=="
+ targTagW.getName() + ")";
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, "%targ-B%", null, Boolean.FALSE,
@@ -617,12 +493,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-B%", null, Boolean.FALSE,
targTagY.getName(), targTagW.getName())).as("has number of elements").hasSize(100)
.as("and contains the following elements").containsAll(expectedIdNames)
.as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@SafeVarargs
@@ -634,7 +504,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
@Step
private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) {
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
final String query = "tag==" + targTagD.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, null, null, null, null, Boolean.FALSE, targTagD.getName()).getContent())
@@ -646,11 +515,6 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, null, null, Boolean.FALSE,
targTagD.getName())).as("has number of elements").hasSize(200).as("and contains the following elements")
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
}
@Step

View File

@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.validation.ConstraintViolationException;
@@ -705,14 +706,13 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
toggleTagAssignment(targAs, targTagA);
assertThat(targetManagement.findTargetsByControllerIDsWithTags(
targAs.stream().map(Target::getControllerId).collect(toList()))).as("Target count is wrong")
.hasSize(25);
assertThat(targetManagement
.findTargetsByControllerIDsWithTags(targAs.stream().map(Target::getControllerId).collect(toList())))
.as("Target count is wrong").hasSize(25);
// no lazy loading exception and tag correctly assigned
assertThat(targetManagement
.findTargetsByControllerIDsWithTags(
targAs.stream().map(Target::getControllerId).collect(toList()))
.findTargetsByControllerIDsWithTags(targAs.stream().map(Target::getControllerId).collect(toList()))
.stream().map(target -> target.getTags().contains(targTagA)).collect(toList()))
.as("Tags not correctly assigned").containsOnly(true);
}
@@ -767,11 +767,31 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTargets(25, "target-id-B", "first description");
Page<Target> foundTargets = targetManagement.findTargetsAll(rsqlFilter, new PageRequest(0, 100));
final Page<Target> foundTargets = targetManagement.findTargetsAll(rsqlFilter, new PageRequest(0, 100));
assertThat(targetManagement.findTargetsAll(new PageRequest(0, 100)).getNumberOfElements()).as("Total targets")
.isEqualTo(50);
assertThat(foundTargets.getTotalElements()).as("Targets in RSQL filter").isEqualTo(27L);
}
@Test
@Description("Verify that the find all targets by ids method contains the entities that we are looking for")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12) })
public void verifyFindTargetAllById() {
final List<Long> searchIds = new ArrayList<>();
searchIds.add(testdataFactory.createTarget("target-4").getId());
searchIds.add(testdataFactory.createTarget("target-5").getId());
searchIds.add(testdataFactory.createTarget("target-6").getId());
for (int i = 0; i < 9; i++) {
testdataFactory.createTarget("test" + i);
}
final List<Target> foundDs = targetManagement.findTargetAllById(searchIds);
assertThat(foundDs).hasSize(3);
final List<Long> collect = foundDs.stream().map(Target::getId).collect(Collectors.toList());
assertThat(collect).containsAll(searchIds);
}
}

View File

@@ -21,6 +21,7 @@ import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
@@ -54,14 +55,18 @@ public class DistributionSetMetadatadetailslayout extends Table {
private Long selectedDistSetId;
private final UINotification notification;
public DistributionSetMetadatadetailslayout(final I18N i18n, final SpPermissionChecker permissionChecker,
final DistributionSetManagement distributionSetManagement,
final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory) {
final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory,
final UINotification notification) {
this.i18n = i18n;
this.permissionChecker = permissionChecker;
this.distributionSetManagement = distributionSetManagement;
this.dsMetadataPopupLayout = dsMetadataPopupLayout;
this.entityFactory = entityFactory;
this.notification = notification;
createDSMetadataTable();
addCustomGeneratedColumns();
}
@@ -144,6 +149,10 @@ public class DistributionSetMetadatadetailslayout extends Table {
private void showMetadataDetails(final Long selectedDistSetId, final String metadataKey) {
final DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId);
if (distSet == null) {
notification.displayWarning(i18n.get("distributionset.not.exists"));
return;
}
/* display the window */
UI.getCurrent()

View File

@@ -17,7 +17,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -192,7 +191,7 @@ public class SoftwareModuleDetailsTable extends Table {
} else {
final DistributionSet newDistributionSet = distributionSetManagement
.unassignSoftwareModule(distributionSet.getId(), unAssignedSw.getId());
manageDistUIState.setLastSelectedEntity(DistributionSetIdName.generate(newDistributionSet));
manageDistUIState.setLastSelectedEntity(newDistributionSet.getId());
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName()));

View File

@@ -6,15 +6,14 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common;
package org.eclipse.hawkbit.ui.common.entity;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.model.DistributionSet;
/**
*
*
* Represent a {@link DistributionSet} data transfer object for the ui.
*/
public class DistributionSetIdName implements Serializable {
private static final long serialVersionUID = 1L;
@@ -22,19 +21,10 @@ public class DistributionSetIdName implements Serializable {
private final Long id;
private final String name;
private final String version;
public static DistributionSetIdName generate(final DistributionSet distributionSet) {
return new DistributionSetIdName(distributionSet.getId(), distributionSet.getName(),
distributionSet.getVersion());
}
public static DistributionSetIdName generate(final Long id, final String name, final String version) {
return new DistributionSetIdName(id, name, version);
}
/**
* Constructor.
*
* @param id
* the {@link DistributionSet#getId()}
* @param name
@@ -49,6 +39,16 @@ public class DistributionSetIdName implements Serializable {
this.version = version;
}
/**
* Constructor.
*
* @param distributionSet
* the distributionSet
*/
public DistributionSetIdName(final DistributionSet distributionSet) {
this(distributionSet.getId(), distributionSet.getName(), distributionSet.getVersion());
}
public Long getId() {
return id;
}

View File

@@ -6,10 +6,12 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.model;
package org.eclipse.hawkbit.ui.common.entity;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
/**
* To hold software module name and Id.
*
@@ -70,4 +72,11 @@ public class SoftwareModuleIdName implements Serializable {
}
return true;
}
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
// id in the dom
return id.toString();
}
}

View File

@@ -0,0 +1,109 @@
/**
* Copyright (c) 2015 Bosch Software Innovations 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.entity;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.model.Target;
/**
* Represent a {@link Target} data transfer object for the ui.
*/
public class TargetIdName implements Serializable {
private static final long serialVersionUID = 1L;
private final Long targetId;
private final String controllerId;
private String targetName;
/**
* Constructor.
*
* @param target
* the target
*/
public TargetIdName(final Target target) {
this(target.getId(), target.getControllerId(), target.getName());
}
/**
* Constructor.
*
* @param targetId
* the target id
* @param controllerId
* the controller id
*/
public TargetIdName(final Long targetId, final String controllerId) {
this(targetId, controllerId, null);
}
private TargetIdName(final Long targetId, final String controllerId, final String targetName) {
this.targetId = targetId;
this.controllerId = controllerId;
this.targetName = targetName;
}
public String getControllerId() {
return controllerId;
}
public Long getTargetId() {
return targetId;
}
public String getTargetName() {
return targetName;
}
public void setTargetName(final String targetName) {
this.targetName = targetName;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((targetId == null) ? 0 : targetId.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TargetIdName)) {
return false;
}
final TargetIdName other = (TargetIdName) obj;
if (targetId == null) {
if (other.targetId != null) {
return false;
}
} else if (!targetId.equals(other.targetId)) {
return false;
}
return true;
}
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
// id in the dom
return controllerId;
}
}

View File

@@ -441,6 +441,10 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
((LazyQueryContainer) getContainerDataSource()).refresh();
}
protected UINotification getNotification() {
return notification;
}
protected abstract boolean hasDropPermission();
protected abstract boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource);

View File

@@ -159,7 +159,7 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
if (assignmentResult.getAssigned() > 0 && managementUIState.getLastSelectedDsIdName() != null) {
final List<Long> assignedDsNames = assignmentResult.getAssignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName())) {
return true;
}
}
@@ -170,7 +170,7 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
if (assignmentResult.getUnassigned() > 0 && managementUIState.getLastSelectedDsIdName() != null) {
final List<Long> assignedDsNames = assignmentResult.getUnassignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName())) {
return true;
}
}

View File

@@ -125,19 +125,17 @@ public class TargetTagToken extends AbstractTargetTagToken<Target> {
}
protected boolean isAssign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0 && managementUIState.getLastSelectedTargetIdName() != null) {
return assignmentResult.getAssignedEntity().stream().map(t -> t.getControllerId())
.anyMatch(controllerId -> controllerId
.equals(managementUIState.getLastSelectedTargetIdName().getControllerId()));
if (assignmentResult.getAssigned() > 0 && managementUIState.getLastSelectedTargetId() != null) {
return assignmentResult.getAssignedEntity().stream().map(t -> t.getId())
.anyMatch(controllerId -> controllerId.equals(managementUIState.getLastSelectedTargetId()));
}
return false;
}
protected boolean isUnassign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0 && managementUIState.getLastSelectedTargetIdName() != null) {
return assignmentResult.getUnassignedEntity().stream().map(t -> t.getControllerId())
.anyMatch(controllerId -> controllerId
.equals(managementUIState.getLastSelectedTargetIdName().getControllerId()));
if (assignmentResult.getUnassigned() > 0 && managementUIState.getLastSelectedTargetId() != null) {
return assignmentResult.getUnassignedEntity().stream().map(t -> t.getId())
.anyMatch(controllerId -> controllerId.equals(managementUIState.getLastSelectedTargetId()));
}
return false;
}

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.ui.components;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -21,8 +20,6 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
*/
public class ProxyDistribution {
private static final long serialVersionUID = -8891449133620645310L;
private Long distId;
private String createdDate;
@@ -50,10 +47,13 @@ public class ProxyDistribution {
}
/**
* Creates a new proxy distribution set by using the values from a distribution set
* @param distributionSet the source distribution set
* Creates a new proxy distribution set by using the values from a
* distribution set
*
* @param distributionSet
* the source distribution set
*/
public ProxyDistribution(DistributionSet distributionSet) {
public ProxyDistribution(final DistributionSet distributionSet) {
setName(distributionSet.getName());
setDescription(distributionSet.getDescription());
setDistId(distributionSet.getId());
@@ -68,22 +68,10 @@ public class ProxyDistribution {
setIsComplete(distributionSet.isComplete());
}
/**
* @return the nameVersion
*/
public String getNameVersion() {
return nameVersion;
}
public DistributionSetIdName getDistributionSetIdName() {
return DistributionSetIdName.generate(id, name, version);
}
/**
* @param nameVersion
* the nameVersion to set
*/
public void setNameVersion(final String nameVersion) {
this.nameVersion = nameVersion;
}

View File

@@ -10,11 +10,10 @@ package org.eclipse.hawkbit.ui.components;
import java.io.Serializable;
import java.net.URI;
import java.security.SecureRandom;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
@@ -22,15 +21,11 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
* Proxy for {@link Target}.
*
*/
/**
* @author kaizimmerm
*
*/
public class ProxyTarget implements Serializable {
private static final long serialVersionUID = -8891449133620645310L;
private String controllerId;
private URI address = null;
private Long lastTargetQuery = null;
private URI address;
private Long lastTargetQuery;
private Long installationDate;
private Long id;
@@ -41,8 +36,6 @@ public class ProxyTarget implements Serializable {
private DistributionSet assignedDistributionSet;
private TargetIdName targetIdName;
private String assignedDistNameVersion;
private String installedDistNameVersion;
@@ -107,254 +100,122 @@ public class ProxyTarget implements Serializable {
this.targetInfo = targetInfo;
}
/**
* @param controllerId
*/
public ProxyTarget() {
final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE;
targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString());
}
/**
* @return the createdByUser
*/
public String getCreatedByUser() {
return createdByUser;
}
/**
* @param createdByUser
* the createdByUser to set
*/
public void setCreatedByUser(final String createdByUser) {
this.createdByUser = createdByUser;
}
/**
* @return the createdDate
*/
public String getCreatedDate() {
return createdDate;
}
/**
* @param createdDate
* the createdDate to set
*/
public void setCreatedDate(final String createdDate) {
this.createdDate = createdDate;
}
/**
* @return the modifiedByUser
*/
public String getModifiedByUser() {
return modifiedByUser;
}
/**
* @param modifiedByUser
* the modifiedByUser to set
*/
public void setModifiedByUser(final String modifiedByUser) {
this.modifiedByUser = modifiedByUser;
}
/**
* @return the lastModifiedDate
*/
public String getLastModifiedDate() {
return lastModifiedDate;
}
/**
* @param lastModifiedDate
* the lastModifiedDate to set
*/
public void setLastModifiedDate(final String lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
/**
* @return the assignedDistNameVersion
*/
public String getAssignedDistNameVersion() {
return assignedDistNameVersion;
}
/**
* @param assignedDistNameVersion
* the assignedDistNameVersion to set
*/
public void setAssignedDistNameVersion(final String assignedDistNameVersion) {
this.assignedDistNameVersion = assignedDistNameVersion;
}
/**
* @return the installedDistNameVersion
*/
public String getInstalledDistNameVersion() {
return installedDistNameVersion;
}
/**
* @param installedDistNameVersion
* the installedDistNameVersion to set
*/
public void setInstalledDistNameVersion(final String installedDistNameVersion) {
this.installedDistNameVersion = installedDistNameVersion;
}
/**
* GET - ID.
*
* @return String as ID.
*/
public String getControllerId() {
return controllerId;
}
/**
* SET - ID.
*
* @param controllerId
* as ID
*/
public void setControllerId(final String controllerId) {
this.controllerId = controllerId;
}
/**
* @return the ipAddress
*/
public URI getAddress() {
return address;
}
/**
* @param ipAddress
* the ipAddress to set
*/
public void setAddress(final URI address) {
this.address = address;
}
/**
* @return the lastTargetQuery
*/
public Long getLastTargetQuery() {
return lastTargetQuery;
}
/**
* @param lastTargetQuery
* the lastTargetQuery to set
*/
public void setLastTargetQuery(final Long lastTargetQuery) {
this.lastTargetQuery = lastTargetQuery;
}
/**
* @return the installationDate
*/
public Long getInstallationDate() {
return installationDate;
}
/**
* @param installationDate
* the installationDate to set
*/
public void setInstallationDate(final Long installationDate) {
this.installationDate = installationDate;
}
/**
* @return the updateStatus
*/
public TargetUpdateStatus getUpdateStatus() {
return updateStatus;
}
/**
* @param updateStatus
* the updateStatus to set
*/
public void setUpdateStatus(final TargetUpdateStatus updateStatus) {
this.updateStatus = updateStatus;
}
/**
* @return the installedDistributionSet
*/
public DistributionSet getInstalledDistributionSet() {
return installedDistributionSet;
}
/**
* @param installedDistributionSet
* the installedDistributionSet to set
*/
public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) {
this.installedDistributionSet = installedDistributionSet;
}
/**
* @return the assignedDistributionSet
*/
public DistributionSet getAssignedDistributionSet() {
return assignedDistributionSet;
}
/**
* @param assignedDistributionSet
* the assignedDistributionSet to set
*/
public void setAssignedDistributionSet(final DistributionSet assignedDistributionSet) {
this.assignedDistributionSet = assignedDistributionSet;
}
/**
* @return the targetIdName
*/
public TargetIdName getTargetIdName() {
return this.targetIdName;
}
/**
* @param targetIdName
* the targetIdName to set
*/
public void setTargetIdName(final TargetIdName targetIdName) {
this.targetIdName = targetIdName;
}
/**
* @return the pollStatusToolTip
*/
public String getPollStatusToolTip() {
return pollStatusToolTip;
}
/**
* @param pollStatusToolTip
* the pollStatusToolTip to set
*/
public void setPollStatusToolTip(final String pollStatusToolTip) {
this.pollStatusToolTip = pollStatusToolTip;
}
/**
* @return the status
*/
public Status getStatus() {
return status;
}
/**
* @param status
* the status to set
*/
public void setStatus(final Status status) {
this.status = status;
}

View File

@@ -21,15 +21,15 @@ import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetMetadatadetailslayout;
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
import org.eclipse.hawkbit.ui.common.detailslayout.TargetFilterQueryDetailsTable;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -111,7 +111,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
eventBus, manageDistUIState, uiNotification);
dsMetadataTable = new DistributionSetMetadatadetailslayout(i18n, permissionChecker, distributionSetManagement,
dsMetadataPopupLayout, entityFactory);
dsMetadataPopupLayout, entityFactory, uiNotification);
tfqDetailsTable = new TargetFilterQueryDetailsTable(i18n);
addTabs(detailsTab);
@@ -143,7 +143,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = manageDistUIState
.getAssignedList();
final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent()
? manageDistUIState.getLastSelectedDistribution().get().getId() : null;
? manageDistUIState.getLastSelectedDistribution().get() : null;
Set<SoftwareModuleIdName> softwareModuleIdNameList = null;
for (final Map.Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
@@ -186,7 +186,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
if (getPermissionChecker().hasUpdateDistributionPermission()
&& manageDistUIState.getLastSelectedDistribution().isPresent()
&& targetManagement.countTargetByAssignedDistributionSet(
manageDistUIState.getLastSelectedDistribution().get().getId()) <= 0) {
manageDistUIState.getLastSelectedDistribution().get()) <= 0) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
reassignSoftModule.setEnabled(false);

View File

@@ -21,11 +21,11 @@ import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -69,7 +69,7 @@ import com.vaadin.ui.UI;
/**
* Distribution set table.
*/
public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> {
public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet, Long> {
private static final long serialVersionUID = -7731776093470487988L;
@@ -112,25 +112,24 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
final List<Long> visibleItemIds = (List<Long>) getVisibleItemIds();
updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds);
handleSelectedAndUpdatedDs(eventContainer.getEvents());
updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds);
}
private void handleSelectedAndUpdatedDs(final List<DistributionSetUpdateEvent> events) {
manageDistUIState.getLastSelectedDistribution()
.ifPresent(lastSelectedDsIdName -> events.stream().map(DistributionSetUpdateEvent::getEntity)
.filter(set -> set.getId().equals(lastSelectedDsIdName.getId())).findFirst()
.ifPresent(selectedSetUpdated -> eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedSetUpdated))));
.ifPresent(lastSelectedDsIdName -> events.stream()
.filter(event -> event.getEntityId().equals(lastSelectedDsIdName)).findFirst()
.ifPresent(event -> eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, event.getEntity()))));
}
private void updateVisableTableEntries(final List<DistributionSetUpdateEvent> events,
final List<DistributionSetIdName> visibleItemIds) {
events.stream().filter(event -> event.getEntity().isComplete())
.filter(event -> visibleItemIds.contains(DistributionSetIdName.generate(event.getEntity())))
final List<Long> visibleItemIds) {
events.stream().filter(event -> visibleItemIds.contains(event.getEntityId()))
.filter(event -> event.getEntity().isComplete())
.forEach(event -> updateDistributionInTable(event.getEntity()));
}
@@ -147,8 +146,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
distributionQF.setQueryConfiguration(queryConfiguration);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
distributionQF);
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), distributionQF);
}
private Map<String, Object> prepareQueryConfigFilters() {
@@ -186,8 +184,8 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
}
@Override
protected DistributionSet findEntityByTableValue(final DistributionSetIdName entityTableId) {
return distributionSetManagement.findDistributionSetByIdWithDetails(entityTableId.getId());
protected DistributionSet findEntityByTableValue(final Long entityTableId) {
return distributionSetManagement.findDistributionSetByIdWithDetails(entityTableId);
}
@Override
@@ -200,8 +198,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
if (distributionSet != null) {
manageDistUIState.setLastSelectedEntity(new DistributionSetIdName(distributionSet.getId(),
distributionSet.getName(), distributionSet.getVersion()));
manageDistUIState.setLastSelectedEntity(distributionSet.getId());
}
}
@@ -219,16 +216,13 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
protected void onDropEventFromTable(final DragAndDropEvent event) {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> source = (AbstractTable<SoftwareModule, Long>) transferable.getSourceComponent();
final AbstractTable<?, Long> source = (AbstractTable<?, Long>) transferable.getSourceComponent();
final Set<Long> softwareModulesIdList = source.getDeletedEntityByTransferable(transferable);
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object distItemId = dropData.getItemIdOver();
final Item item = getItem(distItemId);
if (item != null && item.getItemProperty("id") != null && item.getItemProperty("name") != null) {
handleDropEvent(source, softwareModulesIdList, item);
}
handleDropEvent(source, softwareModulesIdList, distItemId);
}
@@ -247,11 +241,15 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
return super.isDropValid(dragEvent);
}
private void handleDropEvent(final Table source, final Set<Long> softwareModulesIdList, final Item item) {
final Long distId = (Long) item.getItemProperty("id").getValue();
final String distName = (String) item.getItemProperty("name").getValue();
final String distVersion = (String) item.getItemProperty("version").getValue();
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, distVersion);
private void handleDropEvent(final Table source, final Set<Long> softwareModulesIdList, final Object distId) {
final DistributionSet distributionSet = distributionSetManagement.findDistributionSetById((Long) distId);
if (distributionSet == null) {
notification.displayWarning(i18n.get("distributionset.not.exists"));
return;
}
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet);
final HashMap<Long, HashSet<SoftwareModuleIdName>> map;
if (manageDistUIState.getConsolidatedDistSoftwarewList().containsKey(distributionSetIdName)) {
@@ -267,23 +265,11 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
final String swVersion = (String) softwareItem.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(softwareModuleId);
if (validSoftwareModule(distId, softwareModule)) {
if (validSoftwareModule((Long) distId, softwareModule)) {
final SoftwareModuleIdName softwareModuleIdName = new SoftwareModuleIdName(softwareModuleId,
name.concat(":" + swVersion));
publishAssignEvent(distId, softwareModule);
/*
* If software module type is software, means multiple softwares
* can assigned to that type. Hence if multipe softwares belongs
* to same type is drroped, then add to the list.
*/
publishAssignEvent((Long) distId, softwareModule);
handleSoftwareCase(map, softwareModule, softwareModuleIdName);
/*
* If software module type is firmware, means single software
* can be assigned to that type. Hence if multiple softwares
* belongs to same type is dropped, then override with previous
* one.
*/
handleFirmwareCase(map, softwareModule, softwareModuleIdName);
} else {
return;
@@ -299,7 +285,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) {
if (manageDistUIState.getLastSelectedDistribution().isPresent()
&& manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
&& manageDistUIState.getLastSelectedDistribution().get().equals(distId)) {
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, softwareModule));
}
@@ -479,8 +465,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
final String nameVersionStr = getNameAndVerion(itemId);
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
manageMetaDataBtn
.addClickListener(event -> showMetadataDetails(((DistributionSetIdName) itemId).getId()));
manageMetaDataBtn.addClickListener(event -> showMetadataDetails((Long) itemId));
return manageMetaDataBtn;
}
});
@@ -517,8 +502,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
}
private void updateDistributionInTable(final DistributionSet editedDs) {
final Item item = getContainerDataSource()
.getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
final Item item = getContainerDataSource().getItem(editedDs.getId());
updateEntity(editedDs, item);
}

View File

@@ -9,16 +9,19 @@
package org.eclipse.hawkbit.ui.distributions.footer;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
@@ -50,11 +53,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = 3494052985006132714L;
private final transient SystemManagement systemManagement;
private final transient DistributionSetManagement distributionSetManagement;
private final ManageDistUIState manageDistUIState;
private final DistributionsConfirmationWindowLayout distConfirmationWindowLayout;
private final DistributionsViewClientCriterion distributionsViewClientCriterion;
public DSDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
@@ -68,7 +72,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
this.distConfirmationWindowLayout = new DistributionsConfirmationWindowLayout(i18n, eventBus, dsManagement,
softwareManagement, manageDistUIState);
this.distributionsViewClientCriterion = distributionsViewClientCriterion;
this.distributionSetManagement = dsManagement;
init();
}
@@ -179,32 +183,25 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, DistributionSetIdName> table = (AbstractTable<?, DistributionSetIdName>) sourceTable;
final Set<DistributionSetIdName> distributionIdNameSet = table.getDeletedEntityByTransferable(transferable);
/*
* Flags to identify whether all dropped distributions are already in
* the deleted list (or) some distributions are already in the deleted
* distribution list.
*/
final AbstractTable<?, Long> table = (AbstractTable<?, Long>) sourceTable;
final Set<Long> ids = table.getDeletedEntityByTransferable(transferable);
final List<DistributionSet> findDistributionSetAllById = distributionSetManagement
.findDistributionSetAllById(ids);
if (findDistributionSetAllById.isEmpty()) {
notification.displayWarning(i18n.get("distributionsets.not.exists"));
return;
}
final Set<DistributionSetIdName> distributionIdNameSet = findDistributionSetAllById.stream()
.map(distributionSet -> new DistributionSetIdName(distributionSet)).collect(Collectors.toSet());
final int existingDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
final int newDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
if (newDeletedDistributionsSize == existingDeletedDistributionsSize) {
/*
* No new distributions are added, all distributions dropped now are
* already available in the delete list. Hence display warning
* message accordingly.
*/
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
/*
* Not the all distributions dropped now are added to the delete
* list. There are some distributions are already there in the
* delete list. Hence display warning message accordingly.
*/
notification.displayValidationError(i18n.get("message.dist.deleted.pending"));
}

View File

@@ -17,11 +17,12 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -395,9 +396,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
contactContainer.addContainerProperty(DIST_NAME, String.class, "");
Item item;
for (final DistributionSetIdName distIdName : manageDistUIState.getDeletedDistributionList()) {
item = contactContainer.addItem(distIdName);
final Item item = contactContainer.addItem(distIdName);
item.getItemProperty(DIST_NAME).setValue(distIdName.getName().concat(":" + distIdName.getVersion()));
}
return contactContainer;
@@ -461,7 +461,6 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final int deleteDistTypeCount = manageDistUIState.getSelectedDeleteDistSetTypes().size();
for (final String deleteDistTypeName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
dsManagement
.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName).getId());
}

View File

@@ -97,8 +97,6 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
styleTableOnDistSelection();
}
/* All event Listeners */
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SMFilterEvent filterEvent) {
UI.getCurrent().access(() -> {
@@ -184,7 +182,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
.ifPresent(type -> queryConfig.put(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE, type));
manageDistUIState.getLastSelectedDistribution()
.ifPresent(distIdName -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, distIdName.getId()));
.ifPresent(id -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, id));
return queryConfig;
}

View File

@@ -17,9 +17,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.SoftwareModuleIdName;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -32,7 +32,7 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
*/
@SpringComponent
@VaadinSessionScope
public class ManageDistUIState implements ManagmentEntityState<DistributionSetIdName>, Serializable {
public class ManageDistUIState implements ManagmentEntityState<Long>, Serializable {
private static final long serialVersionUID = -7569047247017742928L;
@@ -44,9 +44,9 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<>();
private Set<DistributionSetIdName> selectedDistributions = new HashSet<>();
private Set<Long> selectedDistributions = new HashSet<>();
private DistributionSetIdName lastSelectedDistribution;
private Long lastSelectedDistribution;
private Set<Long> selectedSoftwareModules = emptySet();
@@ -107,24 +107,24 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
/**
* @return the slectedDistributions
*/
public Optional<Set<DistributionSetIdName>> getSelectedDistributions() {
public Optional<Set<Long>> getSelectedDistributions() {
return Optional.ofNullable(selectedDistributions);
}
/**
* @return the lastSelectedDistribution
*/
public Optional<DistributionSetIdName> getLastSelectedDistribution() {
public Optional<Long> getLastSelectedDistribution() {
return Optional.ofNullable(lastSelectedDistribution);
}
@Override
public void setLastSelectedEntity(final DistributionSetIdName value) {
public void setLastSelectedEntity(final Long value) {
this.lastSelectedDistribution = value;
}
@Override
public void setSelectedEnitities(final Set<DistributionSetIdName> values) {
public void setSelectedEnitities(final Set<Long> values) {
selectedDistributions = values;
}

View File

@@ -120,8 +120,7 @@ public class CreateOrUpdateFilterTable extends Table {
// create lazy query container with lazy defination and query
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME),
targetQF);
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
return targetTableContainer;

View File

@@ -100,7 +100,7 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
for (final Target targ : targetBeans) {
final ProxyTarget prxyTarget = new ProxyTarget();
prxyTarget.setTargetIdName(targ.getTargetIdName());
prxyTarget.setId(targ.getId());
prxyTarget.setName(targ.getName());
prxyTarget.setDescription(targ.getDescription());
prxyTarget.setControllerId(targ.getControllerId());

View File

@@ -87,8 +87,7 @@ public class DistributionSetSelectTable extends Table {
distributionQF.setQueryConfiguration(queryConfiguration);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
distributionQF);
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), distributionQF);
}
private void addContainerproperties() {

View File

@@ -15,7 +15,6 @@ import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorderWithIcon;
@@ -90,20 +89,13 @@ public class DistributionSetSelectWindow
window.setId(UIComponentIdProvider.DIST_SET_SELECT_WINDOW_ID);
}
public void setValue(final DistributionSetIdName distSet) {
public void setValue(final Long distSet) {
dsTable.setVisible(distSet != null);
checkBox.setValue(distSet != null);
dsTable.setValue(distSet);
dsTable.setCurrentPageFirstItemId(distSet);
}
public DistributionSetIdName getValue() {
if (checkBox.getValue()) {
return (DistributionSetIdName) dsTable.getValue();
}
return null;
}
/**
* Shows a distribution set select window for the given target filter query
*
@@ -121,7 +113,7 @@ public class DistributionSetSelectWindow
final DistributionSet distributionSet = tfq.getAutoAssignDistributionSet();
if (distributionSet != null) {
setValue(DistributionSetIdName.generate(distributionSet));
setValue(distributionSet.getId());
} else {
setValue(null);
}
@@ -163,8 +155,7 @@ public class DistributionSetSelectWindow
@Override
public void saveOrUpdate() {
if (checkBox.getValue() && dsTable.getValue() != null) {
final DistributionSetIdName ds = (DistributionSetIdName) dsTable.getValue();
updateTargetFilterQueryDS(tfqId, ds.getId());
updateTargetFilterQueryDS(tfqId, (Long) dsTable.getValue());
} else if (!checkBox.getValue()) {
updateTargetFilterQueryDS(tfqId, null);

View File

@@ -124,14 +124,15 @@ public class DeploymentView extends AbstractNotificationView implements BrowserW
final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout = new CreateUpdateTargetTagLayoutWindow(
i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification);
this.targetTagFilterLayout = new TargetTagFilterLayout(i18n, createUpdateTargetTagLayout, managementUIState,
managementViewClientCriterion, permChecker, eventBus, uiNotification, entityFactory, targetManagement,
managementViewClientCriterion, permChecker, eventBus, uiNotification, entityFactory,
targetFilterQueryManagement);
final TargetTable targetTable = new TargetTable(eventBus, i18n, uiNotification, targetManagement,
managementUIState, permChecker, managementViewClientCriterion);
managementUIState, permChecker, managementViewClientCriterion, distributionSetManagement,
tagManagement);
this.targetTableLayout = new TargetTableLayout(eventbus, targetTable, targetManagement, entityFactory, i18n,
eventBus, uiNotification, managementUIState, managementViewClientCriterion, deploymentManagement,
uiproperties, permChecker, uiNotification, tagManagement);
uiproperties, permChecker, uiNotification, tagManagement, distributionSetManagement);
this.distributionTagLayout = new DistributionTagLayout(eventbus, managementUIState, i18n, permChecker, eventBus,
tagManagement, entityFactory, uiNotification, distFilterParameters, distributionSetManagement,

View File

@@ -829,14 +829,13 @@ public class ActionHistoryTable extends TreeTable {
*/
private void updateDistributionTableStyle() {
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& null != managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) {
final String alreadyPinnedControllerId = managementUIState.getDistributionTableFilters().getPinnedTargetId()
.get();
// if the current target is pinned publish a pin event again
if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(target.getControllerId())) {
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
}
if (!managementUIState.getDistributionTableFilters().getPinnedTarget().isPresent()) {
return;
}
final Long alreadyPinnedControllerId = managementUIState.getDistributionTableFilters().getPinnedTarget().get()
.getTargetId();
if (alreadyPinnedControllerId.equals(target.getId())) {
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
}
}

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.TenantMetaData;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
@@ -244,8 +243,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
notificationMessage.displaySuccess(
i18n.get("message.new.dist.save.success", new Object[] { newDist.getName(), newDist.getVersion() }));
distributionSetTable.setValue(
Sets.newHashSet(new DistributionSetIdName(newDist.getId(), newDist.getName(), newDist.getVersion())));
distributionSetTable.setValue(Sets.newHashSet(newDist.getId()));
}
private boolean isDuplicate() {

View File

@@ -19,6 +19,7 @@ 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.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -44,7 +45,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
private Sort sort = new Sort(Direction.ASC, "id");
private Collection<String> distributionTags;
private String searchText;
private String pinnedControllerId;
private TargetIdName pinnedTarget;
private transient DistributionSetManagement distributionSetManagement;
private transient Page<DistributionSet> firstPageDistributionSets;
private Boolean noTagClicked = Boolean.FALSE;
@@ -69,7 +70,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
distributionTags = (Collection<String>) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
pinnedControllerId = (String) queryConfig.get(SPUIDefinitions.ORDER_BY_PINNED_TARGET);
pinnedTarget = (TargetIdName) queryConfig.get(SPUIDefinitions.ORDER_BY_PINNED_TARGET);
if (!Strings.isNullOrEmpty(searchText)) {
searchText = String.format("%%%s%%", searchText);
}
@@ -100,14 +101,14 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
final List<ProxyDistribution> proxyDistributions = new ArrayList<>();
if (startIndex == 0 && firstPageDistributionSets != null) {
distBeans = firstPageDistributionSets;
} else if (pinnedControllerId != null) {
} else if (pinnedTarget != null) {
final DistributionSetFilterBuilder distributionSetFilterBuilder = new DistributionSetFilterBuilder()
.setIsDeleted(false).setIsComplete(true).setSearchText(searchText)
.setSelectDSWithNoTag(noTagClicked).setTagNames(distributionTags);
distBeans = getDistributionSetManagement().findDistributionSetsAllOrderedByLinkTarget(
new OffsetBasedPageRequest(startIndex, count, sort), distributionSetFilterBuilder,
pinnedControllerId);
pinnedTarget.getControllerId());
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
// if no search filters available
distBeans = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
@@ -140,7 +141,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
@Override
public int size() {
if (pinnedControllerId != null) {
if (pinnedTarget != null) {
final DistributionSetFilterBuilder distributionSetFilterBuilder = new DistributionSetFilterBuilder()
.setIsDeleted(false).setIsComplete(true).setSearchText(searchText)
@@ -148,7 +149,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsAllOrderedByLinkTarget(
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), distributionSetFilterBuilder,
pinnedControllerId);
pinnedTarget.getControllerId());
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
// if no search filters available
firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(

View File

@@ -51,6 +51,8 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
private final DistributionSetMetadatadetailslayout dsMetadataTable;
private final UINotification notificationMessage;
DistributionDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker,
final ManagementUIState managementUIState, final DistributionSetManagement distributionSetManagement,
final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory,
@@ -64,12 +66,13 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
this.dsMetadataPopupLayout = new DsMetadataPopupLayout(i18n, notificationMessage, eventBus,
distributionSetManagement, entityFactory, permissionChecker);
this.distributionAddUpdateWindowLayout = distributionAddUpdateWindowLayout;
this.notificationMessage = notificationMessage;
softwareModuleTable = new SoftwareModuleDetailsTable(i18n, false, permissionChecker, null, null, null,
notificationMessage);
dsMetadataTable = new DistributionSetMetadatadetailslayout(i18n, permissionChecker, distributionSetManagement,
dsMetadataPopupLayout, entityFactory);
dsMetadataPopupLayout, entityFactory, notificationMessage);
addTabs(detailsTab);
restoreState();
}
@@ -193,6 +196,10 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected void showMetadata(final ClickEvent event) {
final DistributionSet ds = distributionSetManagement.findDistributionSetById(getSelectedBaseEntityId());
if (ds == null) {
notificationMessage.displayWarning(getI18n().get("distributionset.not.exists"));
return;
}
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
}

View File

@@ -9,10 +9,10 @@
package org.eclipse.hawkbit.ui.management.dstable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -23,11 +23,10 @@ import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdateE
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
@@ -39,6 +38,7 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -71,7 +71,7 @@ import com.vaadin.ui.UI;
/**
* Distribution set table.
*/
public class DistributionTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> {
public class DistributionTable extends AbstractNamedVersionTable<DistributionSet, Long> {
private static final long serialVersionUID = -1928335256399519494L;
@@ -108,7 +108,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
@EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
final List<Long> visibleItemIds = (List<Long>) getVisibleItemIds();
if (allOfThemAffectCompletedSetsThatAreNotVisible(eventContainer.getEvents(), visibleItemIds)) {
refreshContainer();
@@ -116,47 +116,37 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
visibleItemIds)) {
updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds);
}
final Long lastSelectedDsIdName = managementUIState.getLastSelectedDsIdName();
eventContainer.getEvents().stream().filter(event -> event.getEntityId().equals(lastSelectedDsIdName))
.findFirst().ifPresent(event -> eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, event.getEntity())));
final DistributionSetIdName lastSelectedDsIdName = managementUIState.getLastSelectedDsIdName();
// refresh the details tabs only if selected ds is updated
if (lastSelectedDsIdName != null) {
final Optional<DistributionSet> selectedSetUpdated = eventContainer.getEvents().stream()
.map(event -> event.getEntity()).filter(set -> set.getId().equals(lastSelectedDsIdName.getId()))
.findFirst();
if (selectedSetUpdated.isPresent()) {
// update table row+details layout
eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedSetUpdated.get()));
}
}
}
private static boolean allOfThemAffectCompletedSetsThatAreNotVisible(final List<DistributionSetUpdateEvent> events,
final List<DistributionSetIdName> visibleItemIds) {
return events.stream().map(event -> event.getEntity())
.allMatch(set -> set.isComplete() && !visibleItemIds.contains(DistributionSetIdName.generate(set)));
final List<Long> visibleItemIds) {
return events.stream()
.allMatch(event -> !visibleItemIds.contains(event.getEntityId()) && event.getEntity().isComplete());
}
private void updateVisableTableEntries(final List<DistributionSetUpdateEvent> events,
final List<DistributionSetIdName> visibleItemIds) {
events.stream().filter(event -> event.getEntity().isComplete())
.filter(event -> visibleItemIds.contains(DistributionSetIdName.generate(event.getEntity())))
final List<Long> visibleItemIds) {
events.stream().filter(event -> visibleItemIds.contains(event.getEntityId()))
.filter(event -> event.getEntity().isComplete())
.forEach(event -> updateDistributionInTable(event.getEntity()));
}
private boolean checkAndHandleIfVisibleDsSwitchesFromCompleteToIncomplete(
final List<DistributionSetUpdateEvent> events, final List<DistributionSetIdName> visibleItemIds) {
final List<DistributionSet> setsThatAreVisibleButNotCompleteAnymore = events.stream()
.map(event -> event.getEntity()).filter(set -> !set.isComplete())
.filter(set -> visibleItemIds.contains(DistributionSetIdName.generate(set)))
final List<DistributionSetUpdateEvent> events, final List<Long> visibleItemIds) {
final List<Long> setsThatAreVisibleButNotCompleteAnymore = events.stream()
.filter(event -> visibleItemIds.contains(event.getEntityId()))
.filter(event -> !event.getEntity().isComplete()).map(event -> event.getEntityId())
.collect(Collectors.toList());
if (!setsThatAreVisibleButNotCompleteAnymore.isEmpty()) {
refreshContainer();
if (setsThatAreVisibleButNotCompleteAnymore.stream()
.anyMatch(set -> set.getId().equals(managementUIState.getLastSelectedDsIdName().getId()))) {
managementUIState.setLastSelectedDistribution(null);
.anyMatch(id -> id.equals(managementUIState.getLastSelectedDsIdName()))) {
managementUIState.setLastSelectedEntity(null);
}
@@ -238,15 +228,14 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
DistributionBeanQuery.class);
distributionQF.setQueryConfiguration(queryConfiguration);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
distributionQF);
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), distributionQF);
}
private Map<String, Object> prepareQueryConfigFilters() {
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(4);
managementUIState.getDistributionTableFilters().getSearchText()
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
managementUIState.getDistributionTableFilters().getPinnedTargetId()
managementUIState.getDistributionTableFilters().getPinnedTarget()
.ifPresent(value -> queryConfig.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value));
final List<String> list = new ArrayList<>();
queryConfig.put(SPUIDefinitions.FILTER_BY_NO_TAG,
@@ -314,16 +303,15 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
@Override
protected DistributionSet findEntityByTableValue(final DistributionSetIdName lastSelectedId) {
return distributionSetManagement.findDistributionSetByIdWithDetails(lastSelectedId.getId());
protected DistributionSet findEntityByTableValue(final Long lastSelectedId) {
return distributionSetManagement.findDistributionSetByIdWithDetails(lastSelectedId);
}
@Override
protected void publishEntityAfterValueChange(final DistributionSet selectedLastEntity) {
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
if (selectedLastEntity != null) {
managementUIState.setLastSelectedDistribution(new DistributionSetIdName(selectedLastEntity.getId(),
selectedLastEntity.getName(), selectedLastEntity.getVersion()));
managementUIState.setLastSelectedEntity(selectedLastEntity.getId());
}
}
@@ -375,16 +363,16 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
private void assignDsTag(final DragAndDropEvent event) {
final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails();
final Table distTable = (Table) taregtDet.getTarget();
final Set<DistributionSetIdName> distsSelected = getTableValue(distTable);
final Set<Long> distsSelected = getTableValue(distTable);
final Set<Long> distList = new HashSet<>();
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object distItemId = dropData.getItemIdOver();
if (!distsSelected.contains(distItemId)) {
distList.add(((DistributionSetIdName) distItemId).getId());
distList.add((Long) distItemId);
} else {
distList.addAll(distsSelected.stream().map(t -> t.getId()).collect(Collectors.toList()));
distList.addAll(distsSelected);
}
final String distTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
@@ -408,38 +396,42 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
// assign dist to those targets
final List<Target> assignedTargets = targetService.findTargetsByTag(targetTagName);
if (!assignedTargets.isEmpty()) {
final Set<TargetIdName> targetDetailsList = new HashSet<>();
assignedTargets.forEach(target -> targetDetailsList
.add(new TargetIdName(target.getId(), target.getControllerId(), target.getName())));
assignTargetToDs(getItem(distItemId), targetDetailsList);
assignTargetToDs(getItem(distItemId), assignedTargets);
} else {
notification.displaySuccess(i18n.get("message.no.targets.assiged.fortag", new Object[] { targetTagName }));
}
}
@SuppressWarnings("unchecked")
private void assignTargetToDs(final DragAndDropEvent event) {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
final AbstractTable<?, TargetIdName> source = (AbstractTable<?, TargetIdName>) transferable
.getSourceComponent();
final Set<TargetIdName> targetDetailsList = source.getDeletedEntityByTransferable(transferable);
final TargetTable targetTable = (TargetTable) transferable.getSourceComponent();
final Set<Long> targetIdSet = targetTable.getDeletedEntityByTransferable(transferable);
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object distItemId = dropData.getItemIdOver();
assignTargetToDs(getItem(distItemId), targetDetailsList);
assignTargetToDs(getItem(distItemId), targetService.findTargetAllById(targetIdSet));
}
private void assignTargetToDs(final Item item, final Set<TargetIdName> targetDetailsList) {
if (item != null && item.getItemProperty("id") != null && item.getItemProperty("name") != null) {
final Long distId = (Long) item.getItemProperty("id").getValue();
final String distName = (String) item.getItemProperty("name").getValue();
final String distVersion = (String) item.getItemProperty("version").getValue();
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName,
distVersion);
showOrHidePopupAndNotification(validate(targetDetailsList, distributionSetIdName));
private void assignTargetToDs(final Item item, final Collection<Target> targetDetailsList) {
if (item == null || item.getItemProperty("id") == null) {
return;
}
if (targetDetailsList.isEmpty()) {
getNotification().displayWarning(i18n.get("targets.not.exists"));
return;
}
final Long distId = (Long) item.getItemProperty("id").getValue();
final DistributionSet findDistributionSetById = distributionSetManagement.findDistributionSetById(distId);
if (findDistributionSetById == null) {
notification.displayWarning(i18n.get("distributionset.not.exists"));
return;
}
showOrHidePopupAndNotification(validate(targetDetailsList, findDistributionSetById));
}
@Override
@@ -473,28 +465,29 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
return false;
}
private String validate(final Set<TargetIdName> targetDetailsList,
final DistributionSetIdName distributionSetIdName) {
private String validate(final Collection<Target> targetDetailsList, final DistributionSet distributionSet) {
String pendingActionMessage = null;
for (final TargetIdName trgtNameId : targetDetailsList) {
if (null != trgtNameId) {
if (managementUIState.getAssignedList().keySet().contains(trgtNameId)
&& managementUIState.getAssignedList().get(trgtNameId).equals(distributionSetIdName)) {
pendingActionMessage = getPendingActionMessage(pendingActionMessage, trgtNameId.getControllerId(),
HawkbitCommonUtil.getDistributionNameAndVersion(distributionSetIdName.getName(),
distributionSetIdName.getVersion()));
} else {
managementUIState.getAssignedList().put(trgtNameId, distributionSetIdName);
}
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet);
for (final Target target : targetDetailsList) {
final TargetIdName key = new TargetIdName(target);
if (managementUIState.getAssignedList().keySet().contains(key)
&& managementUIState.getAssignedList().get(key).equals(distributionSetIdName)) {
pendingActionMessage = getPendingActionMessage(pendingActionMessage, target.getControllerId(),
HawkbitCommonUtil.getDistributionNameAndVersion(distributionSetIdName.getName(),
distributionSetIdName.getVersion()));
} else {
managementUIState.getAssignedList().put(key, distributionSetIdName);
}
}
return pendingActionMessage;
}
private String getPendingActionMessage(final String message, final String targId, final String distNameVersion) {
private String getPendingActionMessage(final String message, final String controllerId,
final String distNameVersion) {
String pendActionMsg = i18n.get("message.target.assigned.pending");
if (null == message) {
pendActionMsg = i18n.get("message.dist.pending.action", new Object[] { targId, distNameVersion });
pendActionMsg = i18n.get("message.dist.pending.action", new Object[] { controllerId, distNameVersion });
}
return pendActionMsg;
}
@@ -509,8 +502,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
private void updateDistributionInTable(final DistributionSet editedDs) {
final Item item = getContainerDataSource()
.getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
final Item item = getContainerDataSource().getItem(editedDs.getId());
if (item == null) {
return;
}
@@ -530,12 +522,12 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
private void styleDistributionTableOnPinning() {
if (!managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()) {
if (!managementUIState.getDistributionTableFilters().getPinnedTarget().isPresent()) {
return;
}
final Target targetObj = targetService.findTargetByControllerIDWithDetails(
managementUIState.getDistributionTableFilters().getPinnedTargetId().get());
managementUIState.getDistributionTableFilters().getPinnedTarget().get().getControllerId());
if (targetObj != null) {
final DistributionSet assignedDistribution = targetObj.getAssignedDistributionSet();
@@ -554,24 +546,27 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
private static String getPinnedDistributionStyle(final Long installedDistItemIds,
final Long assignedDistTableItemIds, final Object itemId) {
final Long distId = ((DistributionSetIdName) itemId).getId();
if (distId != null && distId.equals(installedDistItemIds)) {
return SPUIDefinitions.HIGHTLIGHT_GREEN;
final Long distId = (Long) itemId;
} else if (distId != null && distId.equals(assignedDistTableItemIds)) {
return SPUIDefinitions.HIGHTLIGHT_ORANGE;
} else {
if (distId == null) {
return null;
}
if (distId.equals(installedDistItemIds)) {
return SPUIDefinitions.HIGHTLIGHT_GREEN;
}
if (distId.equals(assignedDistTableItemIds)) {
return SPUIDefinitions.HIGHTLIGHT_ORANGE;
}
return null;
}
private Object getPinButton(final Object itemId) {
final DistributionSetIdName dist = (DistributionSetIdName) getContainerDataSource().getItem(itemId)
.getItemProperty(SPUILabelDefinitions.VAR_DIST_ID_NAME).getValue();
final Button pinBtn = getPinBtn(itemId, dist.getName(), dist.getVersion());
final Button pinBtn = getPinBtn(itemId);
saveDistributionPinnedBtn(pinBtn);
pinBtn.addClickListener(this::addPinClickListener);
rePinDistribution(pinBtn, dist.getId());
rePinDistribution(pinBtn, (Long) itemId);
return pinBtn;
}
@@ -626,7 +621,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
private void pinDitribution(final Button eventBtn) {
/* if distribution set is pinned ,unpin target if pinned */
managementUIState.getDistributionTableFilters().setPinnedTargetId(null);
managementUIState.getDistributionTableFilters().setPinnedTarget(null);
/* Dist table restyle */
eventBus.publish(this, PinUnpinEvent.PIN_DISTRIBUTION);
applyPinStyle(eventBtn);
@@ -671,13 +666,20 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
return pinBtnId.toString();
}
private static Button getPinBtn(final Object itemId, final String distName, final String distVersion) {
private Button getPinBtn(final Object itemId) {
final Item item = getContainerDataSource().getItem(itemId);
final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName((Long) itemId, name, version);
final Button pinBtn = new Button();
pinBtn.setIcon(FontAwesome.THUMB_TACK);
pinBtn.setHeightUndefined();
pinBtn.addStyleName(getPinStyle());
pinBtn.setData(itemId);
pinBtn.setId(getPinButtonId(distName, distVersion));
pinBtn.setData(distributionSetIdName);
pinBtn.setId(getPinButtonId(name, version));
pinBtn.setImmediate(true);
return pinBtn;
}
@@ -715,9 +717,11 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
private void showMetadataDetails(final Object itemId) {
final DistributionSetIdName distIdName = (DistributionSetIdName) getContainerDataSource().getItem(itemId)
.getItemProperty(SPUILabelDefinitions.VAR_DIST_ID_NAME).getValue();
final DistributionSet ds = distributionSetManagement.findDistributionSetById(distIdName.getId());
final DistributionSet ds = distributionSetManagement.findDistributionSetById((Long) itemId);
if (ds == null) {
notification.displayWarning(i18n.get("distributionset.not.exists"));
return;
}
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
}

View File

@@ -10,12 +10,10 @@ package org.eclipse.hawkbit.ui.management.event;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
@@ -57,7 +55,7 @@ public class DistributionTagDropEvent implements DropHandler {
private final transient EventBus.UIEventBus eventBus;
private final ManagementViewClientCriterion managementViewClientCriterion;
public DistributionTagDropEvent(final I18N i18n, final UINotification notification,
final SpPermissionChecker permChecker, final DistributionTableFilters distFilterParameters,
final DistributionSetManagement distributionSetManagement, final UIEventBus eventBus,
@@ -134,19 +132,16 @@ public class DistributionTagDropEvent implements DropHandler {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
@SuppressWarnings("unchecked")
final AbstractTable<?, DistributionSetIdName> source = (AbstractTable<?, DistributionSetIdName>) transferable
.getSourceComponent();
final AbstractTable<?, Long> source = (AbstractTable<?, Long>) transferable.getSourceComponent();
final Set<DistributionSetIdName> distSelected = source.getDeletedEntityByTransferable(transferable);
final Set<Long> distributionList = distSelected.stream().map(entity -> entity.getId())
.collect(Collectors.toSet());
final Set<Long> distSelected = source.getDeletedEntityByTransferable(transferable);
final String distTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS);
final List<String> tagsClickedList = distFilterParameters.getDistSetTags();
final DistributionSetTagAssignmentResult result = distributionSetManagement
.toggleTagAssignment(distributionList, distTagName);
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distSelected,
distTagName);
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {

View File

@@ -9,15 +9,20 @@
package org.eclipse.hawkbit.ui.management.footer;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -67,6 +72,10 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private final CountMessageLabel countMessageLabel;
private final transient TargetManagement targetManagement;
private final transient DistributionSetManagement distributionSetManagement;
public DeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final TagManagement tagManagementService,
final ManagementViewClientCriterion managementViewClientCriterion,
@@ -81,7 +90,8 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
managementUIState, targetManagement, deploymentManagement, distributionSetManagement);
this.countMessageLabel = new CountMessageLabel(eventBus, targetManagement, i18n, managementUIState,
targetTable);
this.targetManagement = targetManagement;
this.distributionSetManagement = distributionSetManagement;
init();
}
@@ -264,18 +274,29 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, DistributionSetIdName> distTable = (AbstractTable<?, DistributionSetIdName>) sourceTable;
final Set<DistributionSetIdName> distributionIdNameSet = distTable.getDeletedEntityByTransferable(transferable);
final AbstractTable<?, Long> distTable = (AbstractTable<?, Long>) sourceTable;
final Set<Long> ids = distTable.getDeletedEntityByTransferable(transferable);
final DistributionSetIdName dsInBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload()
.getDsNameAndVersion();
if (isDsInUseInBulkUpload(distributionIdNameSet, dsInBulkUpload)) {
distributionIdNameSet.remove(dsInBulkUpload);
final Long dsInBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload().getDsNameAndVersion();
if (isDsInUseInBulkUpload(ids, dsInBulkUpload)) {
ids.remove(dsInBulkUpload);
}
if (distributionIdNameSet.isEmpty()) {
if (ids.isEmpty()) {
return;
}
final List<DistributionSet> findDistributionSetAllById = distributionSetManagement
.findDistributionSetAllById(ids);
if (findDistributionSetAllById.isEmpty()) {
notification.displayWarning(i18n.get("distributionsets.not.exists"));
return;
}
final Set<DistributionSetIdName> distributionIdNameSet = findDistributionSetAllById.stream()
.map(distributionSet -> new DistributionSetIdName(distributionSet)).collect(Collectors.toSet());
checkDeletedDistributionSets(distributionIdNameSet);
}
@@ -307,11 +328,15 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
notification.displayValidationError(i18n.get(messageKey));
}
private boolean isDsInUseInBulkUpload(final Set<DistributionSetIdName> distributionIdNameSet,
final DistributionSetIdName dsInBulkUpload) {
private boolean isDsInUseInBulkUpload(final Set<Long> distributionIdNameSet, final Long dsInBulkUpload) {
if (distributionIdNameSet.contains(dsInBulkUpload)) {
notification.displayValidationError(i18n.get("message.tag.use.bulk.upload",
HawkbitCommonUtil.getFormattedNameVersion(dsInBulkUpload.getName(), dsInBulkUpload.getVersion())));
final DistributionSet distributionSet = distributionSetManagement.findDistributionSetById(dsInBulkUpload);
if (distributionSet == null) {
notification.displayWarning(i18n.get("distributionset.not.exists"));
return true;
}
notification.displayValidationError(i18n.get("message.tag.use.bulk.upload", HawkbitCommonUtil
.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())));
return true;
}
return false;
@@ -319,21 +344,28 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) sourceTable;
final Set<TargetIdName> targetIdNameSet = targetTable.getDeletedEntityByTransferable(transferable);
final TargetTable targetTable = (TargetTable) sourceTable;
final Set<Long> targetIdSet = targetTable.getDeletedEntityByTransferable(transferable);
final Collection<Target> findTargetAllById = targetManagement.findTargetAllById(targetIdSet);
if (findTargetAllById.isEmpty()) {
notification.displayWarning(i18n.get("targets.not.exists"));
return;
}
checkDeletedTargets(targetIdNameSet);
final Set<TargetIdName> targetIdNames = findTargetAllById.stream().map(target -> new TargetIdName(target))
.collect(Collectors.toSet());
checkDeletedTargets(targetIdNames);
}
private void checkDeletedTargets(final Set<TargetIdName> targetIdNameSet) {
private void checkDeletedTargets(final Set<TargetIdName> targetIdSet) {
final int existingDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
managementUIState.getDeletedTargetList().addAll(targetIdNameSet);
managementUIState.getDeletedTargetList().addAll(targetIdSet);
final int newDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
showAlreadyDeletedDistributionSetNotfication(existingDeletedTargetsSize, newDeletedTargetsSize,
"message.targets.already.deleted");
showPendingDeletedNotifaction(targetIdNameSet, existingDeletedTargetsSize, newDeletedTargetsSize,
showPendingDeletedNotifaction(targetIdSet, existingDeletedTargetsSize, newDeletedTargetsSize,
"message.target.deleted.pending");
}

View File

@@ -13,6 +13,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -23,10 +24,10 @@ import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.RepositoryModelConstants;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
@@ -45,7 +46,6 @@ import com.google.common.collect.Maps;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align;
@@ -125,8 +125,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
// Add the discard action column
assignmnetTab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final ClickListener clickListener = event -> discardAssignment(
(TargetIdName) ((Button) event.getComponent()).getData(), assignmnetTab);
final ClickListener clickListener = event -> discardAssignment((TargetIdName) itemId, assignmnetTab);
return createDiscardButton(itemId, clickListener);
});
@@ -156,7 +155,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
? actionTypeOptionGroupLayout.getForcedTimeDateField().getValue().getTime()
: RepositoryModelConstants.NO_FORCE_TIME;
final Map<Long, ArrayList<TargetIdName>> saveAssignedList = Maps.newHashMapWithExpectedSize(itemIds.size());
final Map<Long, List<TargetIdName>> saveAssignedList = Maps.newHashMapWithExpectedSize(itemIds.size());
int successAssignmentCount = 0;
int duplicateAssignmentCount = 0;
@@ -170,10 +169,10 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
targetIdSetList = new ArrayList<>();
}
targetIdSetList.add(itemId);
saveAssignedList.put(distId, (ArrayList<TargetIdName>) targetIdSetList);
saveAssignedList.put(distId, targetIdSetList);
}
for (final Map.Entry<Long, ArrayList<TargetIdName>> mapEntry : saveAssignedList.entrySet()) {
for (final Map.Entry<Long, List<TargetIdName>> mapEntry : saveAssignedList.entrySet()) {
tempIdList = saveAssignedList.get(mapEntry.getKey());
final DistributionSetAssignmentResult distributionSetAssignmentResult = deploymentManagement
.assignDistributionSet(mapEntry.getKey(), actionType, forcedTimeStamp,
@@ -205,20 +204,14 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
}
private void resfreshPinnedDetails(final Map<Long, ArrayList<TargetIdName>> saveAssignedList) {
/**
* If pinned Ds id is there in saved assignment list then refresh the
* pinning
*/
private void resfreshPinnedDetails(final Map<Long, List<TargetIdName>> saveAssignedList) {
if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) {
if (saveAssignedList.keySet().contains(managementUIState.getTargetTableFilters().getPinnedDistId().get())) {
eventBus.publish(this, PinUnpinEvent.PIN_DISTRIBUTION);
}
} else if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()) {
final Set<TargetIdName> targetIdNameList = managementUIState.getAssignedList().keySet();
final List<String> assignedTargetIds = targetIdNameList.stream()
.map(targetIdName -> targetIdName.getControllerId()).collect(Collectors.toList());
if (assignedTargetIds.contains(managementUIState.getDistributionTableFilters().getPinnedTargetId().get())) {
} else if (managementUIState.getDistributionTableFilters().getPinnedTarget().isPresent()) {
final Set<TargetIdName> assignedTargetIds = managementUIState.getAssignedList().keySet();
if (assignedTargetIds.contains(managementUIState.getDistributionTableFilters().getPinnedTarget().get())) {
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
}
}
@@ -242,9 +235,9 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
}
private void discardAssignment(final TargetIdName targetIdName, final ConfirmationTab tab) {
tab.getTable().getContainerDataSource().removeItem(targetIdName);
managementUIState.getAssignedList().remove(targetIdName);
private void discardAssignment(final TargetIdName targetId, final ConfirmationTab tab) {
tab.getTable().getContainerDataSource().removeItem(targetId);
managementUIState.getAssignedList().remove(targetId);
final int assigCount = tab.getTable().getContainerDataSource().size();
if (0 == assigCount) {
removeCurrentTab(tab);
@@ -258,20 +251,19 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(TARGET_NAME, String.class, "");
contactContainer.addContainerProperty(DISTRIBUTION_NAME, String.class, "");
contactContainer.addContainerProperty(TARGET_ID, String.class, "");
contactContainer.addContainerProperty(TARGET_ID, Long.class, "");
contactContainer.addContainerProperty(DIST_ID, Long.class, "");
Item saveTblitem;
final Map<TargetIdName, DistributionSetIdName> assignedList = managementUIState.getAssignedList();
for (final Map.Entry<TargetIdName, DistributionSetIdName> entry : assignedList.entrySet()) {
saveTblitem = contactContainer.addItem(entry.getKey());
final Item saveTblitem = contactContainer.addItem(entry.getKey());
saveTblitem.getItemProperty(TARGET_NAME).setValue(entry.getKey().getName());
saveTblitem.getItemProperty(TARGET_NAME).setValue(entry.getKey().getTargetName());
saveTblitem.getItemProperty(DISTRIBUTION_NAME).setValue(HawkbitCommonUtil
.getDistributionNameAndVersion(entry.getValue().getName(), entry.getValue().getVersion()));
saveTblitem.getItemProperty(TARGET_ID).setValue(entry.getKey().getControllerId());
saveTblitem.getItemProperty(TARGET_ID).setValue(entry.getKey().getTargetId());
saveTblitem.getItemProperty(DIST_ID).setValue(entry.getValue().getId());
}
return contactContainer;
@@ -294,8 +286,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
/* Add the discard action column */
tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final ClickListener clickListener = event -> discardTargetDelete(
(TargetIdName) ((Button) event.getComponent()).getData(), itemId, tab);
final ClickListener clickListener = event -> discardTargetDelete((TargetIdName) itemId, tab);
return createDiscardButton(itemId, clickListener);
});
@@ -327,8 +318,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
/* Add the discard action column */
tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final ClickListener clickListener = event -> discardDSDelete(
(DistributionSetIdName) ((Button) event.getComponent()).getData(), itemId, tab);
final ClickListener clickListener = event -> discardDSDelete((DistributionSetIdName) itemId, tab);
return createDiscardButton(itemId, clickListener);
});
@@ -342,11 +332,9 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
return tab;
}
private void discardDSDelete(final DistributionSetIdName discardDsIdName, final Object itemId,
final ConfirmationTab tab) {
private void discardDSDelete(final DistributionSetIdName discardDsIdName, final ConfirmationTab tab) {
managementUIState.getDeletedDistributionList().remove(discardDsIdName);
tab.getTable().getContainerDataSource().removeItem(itemId);
tab.getTable().getContainerDataSource().removeItem(itemId);
tab.getTable().getContainerDataSource().removeItem(discardDsIdName);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
@@ -401,12 +389,10 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
}
private void unPinDeletedTarget(final String pinnedTargetId) {
private void unPinDeletedTarget(final TargetIdName pinnedTarget) {
final Set<TargetIdName> deletedTargets = managementUIState.getDeletedTargetList();
final List<String> deletedTargetsControllerIds = deletedTargets.stream().map(t -> t.getControllerId())
.collect(Collectors.toList());
if (deletedTargetsControllerIds.contains(pinnedTargetId)) {
managementUIState.getDistributionTableFilters().setPinnedTargetId(null);
if (deletedTargets.contains(pinnedTarget)) {
managementUIState.getDistributionTableFilters().setPinnedTarget(null);
eventBus.publish(this, PinUnpinEvent.UNPIN_TARGET);
}
}
@@ -433,28 +419,28 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
eventBus.publish(this, SaveActionWindowEvent.SHOW_HIDE_TAB);
}
private void removeFromAssignmentTab(final Map.Entry entry, final DistributionSetIdName value) {
private void removeFromAssignmentTab(final Entry<TargetIdName, DistributionSetIdName> entry,
final DistributionSetIdName value) {
if (Objects.equals(entry.getValue(), value)) {
assignmnetTab.getTable().removeItem(entry.getKey());
assignmnetTab.getTable().removeItem(entry.getKey().getTargetId());
}
}
private IndexedContainer getTargetModuleTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(TARGET_ID, String.class, "");
contactContainer.addContainerProperty(TARGET_ID, Long.class, "");
contactContainer.addContainerProperty(TARGET_NAME, String.class, "");
Item item;
for (final TargetIdName targteId : managementUIState.getDeletedTargetList()) {
item = contactContainer.addItem(targteId);
item.getItemProperty(TARGET_ID).setValue(targteId.getControllerId());
item.getItemProperty(TARGET_NAME).setValue(targteId.getName());
item.getItemProperty(TARGET_ID).setValue(targteId.getTargetId());
item.getItemProperty(TARGET_NAME).setValue(targteId.getTargetName());
}
return contactContainer;
}
private void discardTargetDelete(final TargetIdName discardTargetIdName, final Object itemId,
final ConfirmationTab tab) {
managementUIState.getDeletedTargetList().remove(discardTargetIdName);
private void discardTargetDelete(final TargetIdName itemId, final ConfirmationTab tab) {
managementUIState.getDeletedTargetList().remove(itemId);
tab.getTable().getContainerDataSource().removeItem(itemId);
final int assigCount = tab.getTable().getContainerDataSource().size();
@@ -475,8 +461,9 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
}
private void deleteAllTargets(final ConfirmationTab tab) {
final Set<TargetIdName> itemIds = managementUIState.getDeletedTargetList();
final List<Long> targetIds = itemIds.stream().map(t -> t.getTargetId()).collect(Collectors.toList());
final Set<TargetIdName> targetIdNames = managementUIState.getDeletedTargetList();
final Set<Long> targetIds = targetIdNames.stream().map(TargetIdName::getTargetId).collect(Collectors.toSet());
targetManagement.deleteTargets(targetIds);
@@ -488,7 +475,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
setActionMessage(i18n.get("message.target.delete.success"));
removeDeletedTargetsFromAssignmentTab();
managementUIState.getDistributionTableFilters().getPinnedTargetId().ifPresent(this::unPinDeletedTarget);
managementUIState.getDistributionTableFilters().getPinnedTarget().ifPresent(this::unPinDeletedTarget);
eventBus.publish(this, SaveActionWindowEvent.SHOW_HIDE_TAB);
managementUIState.getDeletedTargetList().clear();
@@ -498,7 +485,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
for (final TargetIdName targetNameId : managementUIState.getDeletedTargetList()) {
if (managementUIState.getAssignedList().containsKey(targetNameId)) {
managementUIState.getAssignedList().remove(targetNameId);
assignmnetTab.getTable().removeItem(targetNameId);
assignmnetTab.getTable().removeItem(targetNameId.getTargetId());
}
}
}

View File

@@ -13,6 +13,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.VaadinSessionScope;
@@ -31,7 +33,7 @@ public class DistributionTableFilters implements Serializable {
private Long distId;
private String pinnedTargetId;
private TargetIdName pinnedTarget;
private final List<String> distSetTags = new ArrayList<>();
@@ -67,12 +69,12 @@ public class DistributionTableFilters implements Serializable {
this.distId = distId;
}
public Optional<String> getPinnedTargetId() {
return Optional.ofNullable(pinnedTargetId);
public Optional<TargetIdName> getPinnedTarget() {
return Optional.ofNullable(pinnedTarget);
}
public void setPinnedTargetId(final String pinnedTargetId) {
this.pinnedTargetId = pinnedTargetId;
public void setPinnedTarget(final TargetIdName pinnedTarget) {
this.pinnedTarget = pinnedTarget;
}
public Optional<String> getSearchText() {

View File

@@ -17,9 +17,9 @@ import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -32,7 +32,7 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
*/
@VaadinSessionScope
@SpringComponent
public class ManagementUIState implements ManagmentEntityState<DistributionSetIdName>, Serializable {
public class ManagementUIState implements ManagmentEntityState<Long>, Serializable {
private static final long serialVersionUID = 7301409196969723794L;
@@ -52,10 +52,8 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
private Boolean distTagLayoutVisible = Boolean.FALSE;
// Contains ID and NAme of last selected target
private TargetIdName lastSelectedTargetIdName;
// Contains list of ID and Names of all the selected Targets
private Set<TargetIdName> selectedTargetIdName = Collections.emptySet();
private Long lastSelectedTargetId;
private Set<Long> selectedTargetId = Collections.emptySet();
private boolean targetTagFilterClosed;
@@ -67,10 +65,9 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
private boolean dsTableMaximized;
// Contains ID and NAme of last selected target
private DistributionSetIdName lastSelectedDsIdName;
// Contains list of ID and Names of all the selected Targets
private Set<DistributionSetIdName> selectedDsIdName = Collections.emptySet();
private Long lastSelectedDsIdName;
private Set<Long> selectedDsIdName = Collections.emptySet();
private boolean targetTableMaximized;
@@ -86,8 +83,6 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
private boolean bulkUploadWindowMinimised;
private DistributionSetIdName lastSelectedDistribution;
@Autowired
ManagementUIState(final DistributionTableFilters distributionTableFilters,
final TargetTableFilters targetTableFilters) {
@@ -95,17 +90,6 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
this.targetTableFilters = targetTableFilters;
}
/**
* @return the lastSelectedDistribution
*/
public Optional<DistributionSetIdName> getLastSelectedDistribution() {
return Optional.ofNullable(lastSelectedDistribution);
}
public void setLastSelectedDistribution(final DistributionSetIdName value) {
this.lastSelectedDistribution = value;
}
/**
* @return the bulkUploadWindowMinimised
*/
@@ -180,20 +164,20 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
return deletedTargetList;
}
public TargetIdName getLastSelectedTargetIdName() {
return lastSelectedTargetIdName;
public Long getLastSelectedTargetId() {
return lastSelectedTargetId;
}
public void setLastSelectedTargetIdName(final TargetIdName lastSelectedTargetIdName) {
this.lastSelectedTargetIdName = lastSelectedTargetIdName;
public void setLastSelectedTargetId(final Long lastSelectedTargetId) {
this.lastSelectedTargetId = lastSelectedTargetId;
}
public Optional<Set<TargetIdName>> getSelectedTargetIdName() {
return Optional.ofNullable(selectedTargetIdName);
public Optional<Set<Long>> getSelectedTargetId() {
return Optional.ofNullable(selectedTargetId);
}
public void setSelectedTargetIdName(final Set<TargetIdName> selectedTargetIdName) {
this.selectedTargetIdName = selectedTargetIdName;
public void setSelectedTargetId(final Set<Long> selectedTargetId) {
this.selectedTargetId = selectedTargetId;
}
/**
@@ -264,22 +248,22 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
this.dsTableMaximized = isDsTableMaximized;
}
public DistributionSetIdName getLastSelectedDsIdName() {
public Long getLastSelectedDsIdName() {
return lastSelectedDsIdName;
}
@Override
public void setLastSelectedEntity(final DistributionSetIdName value) {
public void setLastSelectedEntity(final Long value) {
this.lastSelectedDsIdName = value;
}
@Override
public void setSelectedEnitities(final Set<DistributionSetIdName> values) {
public void setSelectedEnitities(final Set<Long> values) {
this.selectedDsIdName = values;
}
public Optional<Set<DistributionSetIdName>> getSelectedDsIdName() {
public Optional<Set<Long>> getSelectedDsIdName() {
return Optional.ofNullable(selectedDsIdName);
}

View File

@@ -12,8 +12,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
/**
* Hold details for target bulk upload window.
*
@@ -22,7 +20,7 @@ public class TargetBulkUpload implements Serializable {
private static final long serialVersionUID = -7697723122460382323L;
private DistributionSetIdName dsNameAndVersion;
private Long dsNameAndVersion;
private String description;
@@ -53,7 +51,7 @@ public class TargetBulkUpload implements Serializable {
/**
* @return the dsNameAndVersion
*/
public DistributionSetIdName getDsNameAndVersion() {
public Long getDsNameAndVersion() {
return dsNameAndVersion;
}
@@ -76,7 +74,7 @@ public class TargetBulkUpload implements Serializable {
* @param dsNameAndVersion
* the dsNameAndVersion to set
*/
public void setDsNameAndVersion(final DistributionSetIdName dsNameAndVersion) {
public void setDsNameAndVersion(final Long dsNameAndVersion) {
this.dsNameAndVersion = dsNameAndVersion;
}

View File

@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Optional;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.VaadinSessionScope;

View File

@@ -31,7 +31,6 @@ import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken.TagData;
import org.eclipse.hawkbit.ui.components.HawkbitErrorNotificationMessage;
@@ -299,11 +298,11 @@ public class BulkUploadHandler extends CustomComponent
final long forcedTimeStamp = new Date().getTime();
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
final List<String> targetsList = targetBulkUpload.getTargetsCreated();
final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) {
final Long dsSelected = (Long) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected) == null) {
return i18n.get("message.bulk.upload.assignment.failed");
}
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion(), actionType,
forcedTimeStamp, targetsList);
return null;
}

View File

@@ -145,7 +145,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
uINotification.displaySuccess(i18n.get("message.save.success", new Object[] { newTarget.getName() }));
}
public Window getWindow() {
public Window createNewWindow() {
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.get(UIComponentIdProvider.TARGET_ADD_CAPTION)).content(this).layout(formLayout).i18n(i18n)
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
@@ -157,12 +157,18 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
* Returns Target Update window based on the selected Entity Id in the
* target table.
*
* @param entityId
* @return window
* @param controllerId
* the target controller id
* @return window or {@code null} if target is not exists.
*/
public Window getWindow(final String entityId) {
populateValuesOfTarget(entityId);
getWindow();
public Window getWindow(final String controllerId) {
final Target target = targetManagement.findTargetByControllerID(controllerId);
if (target == null) {
uINotification.displayWarning(i18n.get("target.not.exists", new Object[] { controllerId }));
return null;
}
populateValuesOfTarget(target);
createNewWindow();
window.addStyleName("target-update-window");
return window;
}
@@ -193,14 +199,11 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
}
/**
* @param controllerId
*/
private void populateValuesOfTarget(final String controllerId) {
private void populateValuesOfTarget(final Target target) {
resetComponents();
this.controllerId = controllerId;
this.controllerId = target.getControllerId();
editTarget = Boolean.TRUE;
final Target target = targetManagement.findTargetByControllerID(controllerId);
controllerIDTextField.setValue(target.getControllerId());
controllerIDTextField.setEnabled(Boolean.FALSE);
nameTextField.setValue(target.getName());

View File

@@ -132,7 +132,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
}
for (final Target targ : targetBeans) {
final ProxyTarget prxyTarget = new ProxyTarget();
prxyTarget.setTargetIdName(targ.getTargetIdName());
prxyTarget.setId(targ.getId());
prxyTarget.setName(targ.getName());
prxyTarget.setDescription(targ.getDescription());
prxyTarget.setControllerId(targ.getControllerId());

View File

@@ -18,7 +18,6 @@ import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -111,7 +110,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
protected void onStartOfUpload() {
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
targetBulkUpload.setDsNameAndVersion((DistributionSetIdName) dsNamecomboBox.getValue());
targetBulkUpload.setDsNameAndVersion((Long) dsNamecomboBox.getValue());
targetBulkUpload.setDescription(descTextArea.getValue());
targetBulkUpload.setProgressBarCurrentValue(0F);
targetBulkUpload.setFailedUploadCount(0L);
@@ -245,8 +244,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
DistributionBeanQuery.class);
distributionQF.setQueryConfiguration(queryConfiguration);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
distributionQF);
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), distributionQF);
}
private void buildLayout() {

View File

@@ -110,15 +110,17 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
if (getSelectedBaseEntity() == null) {
return;
}
targetAddUpdateWindowLayout.getWindow(getSelectedBaseEntity().getControllerId());
openWindow();
}
private void openWindow() {
final Window newDistWindow = targetAddUpdateWindowLayout.getWindow();
newDistWindow.setCaption(getI18n().get(UIComponentIdProvider.TARGET_UPDATE_CAPTION));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
final Window targetWindow = targetAddUpdateWindowLayout.getWindow(getSelectedBaseEntity().getControllerId());
if (targetWindow == null) {
return;
}
targetWindow.setCaption(getI18n().get(UIComponentIdProvider.TARGET_UPDATE_CAPTION));
UI.getCurrent().addWindow(targetWindow);
targetWindow.setVisible(Boolean.TRUE);
}
@Override
@@ -128,7 +130,7 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
@Override
protected Boolean onLoadIsTableRowSelected() {
return managementUIState.getLastSelectedTargetIdName() != null;
return managementUIState.getLastSelectedTargetId() != null;
}
@Override

View File

@@ -19,6 +19,7 @@ import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_F
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -26,19 +27,23 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.collections4.CollectionUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.FilterParams;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.event.remote.entity.RemoteEntityEvent;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
@@ -73,6 +78,7 @@ import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
@@ -91,7 +97,7 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Concrete implementation of Target table.
*/
public class TargetTable extends AbstractTable<Target, TargetIdName> {
public class TargetTable extends AbstractTable<Target, Long> {
private static final Logger LOG = LoggerFactory.getLogger(TargetTable.class);
private static final String TARGET_PINNED = "targetPinned";
@@ -99,6 +105,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
private static final int PROPERTY_DEPT = 3;
private final transient TargetManagement targetManagement;
private final transient DistributionSetManagement distributionSetManagement;
private final transient TagManagement tagManagement;
private final SpPermissionChecker permChecker;
@@ -111,12 +119,15 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
public TargetTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification,
final TargetManagement targetManagement, final ManagementUIState managementUIState,
final SpPermissionChecker permChecker, final ManagementViewClientCriterion managementViewClientCriterion) {
final SpPermissionChecker permChecker, final ManagementViewClientCriterion managementViewClientCriterion,
final DistributionSetManagement distributionSetManagement, final TagManagement tagManagement) {
super(eventBus, i18n, notification);
this.targetManagement = targetManagement;
this.permChecker = permChecker;
this.managementViewClientCriterion = managementViewClientCriterion;
this.managementUIState = managementUIState;
this.distributionSetManagement = distributionSetManagement;
this.tagManagement = tagManagement;
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
@@ -141,8 +152,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
if (isFilterEnabled()) {
refreshTargets();
} else {
eventContainer.getEvents().stream()
.filter(event -> visibleItemIds.contains(new TargetIdName(event.getEntityId(), null, null)))
eventContainer.getEvents().stream().filter(event -> visibleItemIds.contains(event.getEntityId()))
.forEach(event -> updateVisibleItemOnEvent(event.getEntity().getTargetInfo()));
}
publishTargetSelectedEntityForRefresh(eventContainer.getEvents().stream());
@@ -150,8 +160,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
private void publishTargetSelectedEntityForRefresh(
final Stream<? extends RemoteEntityEvent<Target>> targetEntityEventStream) {
targetEntityEventStream.filter(event -> isLastSelectedTarget(new TargetIdName(event.getEntityId(), null, null)))
.findAny().ifPresent(event -> eventBus.publish(this,
targetEntityEventStream.filter(event -> isLastSelectedTarget(event.getEntityId())).findAny()
.ifPresent(event -> eventBus.publish(this,
new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, event.getEntity())));
}
@@ -222,15 +232,42 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
targetQF.setQueryConfiguration(queryConfig);
// create lazy query container with lazy defination and query
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME),
targetQF);
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
return targetTableContainer;
}
@Override
protected void addContainerProperties(final Container container) {
HawkbitCommonUtil.addTargetTableContainerProperties(container);
final LazyQueryContainer targetTableContainer = (LazyQueryContainer) container;
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CONT_ID, String.class, "", false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class,
TargetUpdateStatus.UNKNOWN, false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_ID, Long.class, null,
false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_ID, Long.class, null,
false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "",
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class,
"", false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.LAST_QUERY_DATE, Date.class, null, false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false,
true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false,
true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null,
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null,
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGN_DIST_SET, DistributionSet.class, null,
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALL_DIST_SET, DistributionSet.class, null,
false, true);
}
@Override
@@ -243,13 +280,13 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
@Override
protected boolean isFirstRowSelectedOnLoad() {
return !managementUIState.getSelectedTargetIdName().isPresent()
|| managementUIState.getSelectedTargetIdName().get().isEmpty();
return !managementUIState.getSelectedTargetId().isPresent()
|| managementUIState.getSelectedTargetId().get().isEmpty();
}
@Override
protected Object getItemIdToSelect() {
return managementUIState.getSelectedTargetIdName().orElse(null);
return managementUIState.getSelectedTargetId().orElse(null);
}
@Override
@@ -258,18 +295,18 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
@Override
protected Target findEntityByTableValue(final TargetIdName lastSelectedId) {
return targetManagement.findTargetByControllerIDWithDetails(lastSelectedId.getControllerId());
protected Target findEntityByTableValue(final Long lastSelectedId) {
return targetManagement.findTargetById(lastSelectedId);
}
@Override
protected void setManagementEntitiyStateValues(final Set<TargetIdName> values, final TargetIdName lastId) {
managementUIState.setSelectedTargetIdName(values);
managementUIState.setLastSelectedTargetIdName(lastId);
protected void setManagementEntitiyStateValues(final Set<Long> values, final Long lastId) {
managementUIState.setSelectedTargetId(values);
managementUIState.setLastSelectedTargetId(lastId);
}
@Override
protected ManagmentEntityState<TargetIdName> getManagmentEntityState() {
protected ManagmentEntityState<Long> getManagmentEntityState() {
return null;
}
@@ -339,6 +376,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
private Button getTagetPinButton(final Object itemId) {
final Button pinBtn = new Button();
final String controllerId = (String) getContainerDataSource().getItem(itemId)
.getItemProperty(SPUILabelDefinitions.VAR_CONT_ID).getValue();
final TargetIdName pinnedTarget = new TargetIdName((Long) itemId, controllerId);
final StringBuilder pinBtnStyle = new StringBuilder(ValoTheme.BUTTON_BORDERLESS_COLORED);
pinBtnStyle.append(' ');
pinBtnStyle.append(ValoTheme.BUTTON_SMALL);
@@ -346,10 +386,10 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
pinBtnStyle.append(ValoTheme.BUTTON_ICON_ONLY);
pinBtn.setStyleName(pinBtnStyle.toString());
pinBtn.setHeightUndefined();
pinBtn.setData(itemId);
pinBtn.setId(UIComponentIdProvider.TARGET_PIN_ICON + itemId);
pinBtn.setData(pinnedTarget);
pinBtn.setId(UIComponentIdProvider.TARGET_PIN_ICON + controllerId);
pinBtn.addClickListener(this::addPinClickListener);
if (isPinned(((TargetIdName) itemId).getControllerId())) {
if (isPinned(pinnedTarget)) {
pinBtn.addStyleName(TARGET_PINNED);
isTargetPinned = Boolean.TRUE;
targetPinnedBtn = pinBtn;
@@ -360,9 +400,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
return pinBtn;
}
private boolean isPinned(final String targetId) {
return managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get());
private boolean isPinned(final TargetIdName pinnedTarget) {
return managementUIState.getDistributionTableFilters().getPinnedTarget().isPresent()
&& managementUIState.getDistributionTableFilters().getPinnedTarget().get().equals(pinnedTarget);
}
/**
@@ -387,19 +427,19 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
* as button
*/
private void checkifAlreadyPinned(final Button eventBtn) {
final String newPinnedTargetItemId = ((TargetIdName) eventBtn.getData()).getControllerId();
String targetId = null;
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()) {
targetId = managementUIState.getDistributionTableFilters().getPinnedTargetId().get();
final TargetIdName newPinnedTargetItemId = (TargetIdName) eventBtn.getData();
TargetIdName targetId = null;
if (managementUIState.getDistributionTableFilters().getPinnedTarget().isPresent()) {
targetId = managementUIState.getDistributionTableFilters().getPinnedTarget().get();
}
if (targetId == null) {
isTargetPinned = !isTargetPinned;
managementUIState.getDistributionTableFilters().setPinnedTargetId(newPinnedTargetItemId);
managementUIState.getDistributionTableFilters().setPinnedTarget(newPinnedTargetItemId);
} else if (targetId.equals(newPinnedTargetItemId)) {
isTargetPinned = Boolean.FALSE;
} else {
isTargetPinned = true;
managementUIState.getDistributionTableFilters().setPinnedTargetId(newPinnedTargetItemId);
managementUIState.getDistributionTableFilters().setPinnedTarget(newPinnedTargetItemId);
if (null != targetPinnedBtn) {
resetPinStyle(targetPinnedBtn);
}
@@ -419,7 +459,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
private void unPinTarget(final Button eventBtn) {
managementUIState.getDistributionTableFilters().setPinnedTargetId(null);
managementUIState.getDistributionTableFilters().setPinnedTarget(null);
eventBus.publish(this, PinUnpinEvent.UNPIN_TARGET);
resetPinStyle(eventBtn);
}
@@ -461,8 +501,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
private void tagAssignment(final DragAndDropEvent event) {
final List<String> targetList = getDraggedTargetList(event).stream().map(TargetIdName::getControllerId)
.collect(Collectors.toList());
final List<Long> targetList = getDraggedTargetList(event).stream().collect(Collectors.toList());
final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
@@ -472,15 +511,49 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
return;
}
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
final TargetTagAssignmentResult result = toggleTagAssignment(targetList, targTagName);
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
refreshFilter();
}
}
/**
* Toggles {@link TargetTag} assignment to given target ids by means that if
* some (or all) of the targets in the list have the {@link Tag} not yet
* assigned, they will be. If all of theme have the tag already assigned
* they will be removed instead. Additionally a success popup is shown.
*
* @param targetIds
* to toggle for
* @param targTagName
* to toggle
* @return TagAssigmentResult with all meta data of the assignment outcome.
*/
public TargetTagAssignmentResult toggleTagAssignment(final Collection<Long> targetIds, final String targTagName) {
final List<String> controllerIds = targetManagement.findTargetAllById(targetIds).stream()
.map(Target::getControllerId).collect(Collectors.toList());
if (controllerIds.isEmpty()) {
notification.displayWarning(i18n.get("targets.not.exists"));
return new TargetTagAssignmentResult(0, 0, 0, Lists.newArrayListWithCapacity(0),
Lists.newArrayListWithCapacity(0), null);
}
final TargetTag tag = tagManagement.findTargetTag(targTagName);
if (tag == null) {
notification.displayWarning(i18n.get("targettag.not.exists", new Object[] { targTagName }));
return new TargetTagAssignmentResult(0, 0, 0, Lists.newArrayListWithCapacity(0),
Lists.newArrayListWithCapacity(0), null);
}
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(controllerIds, targTagName);
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
return result;
}
@Override
protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
final String tagName = HawkbitCommonUtil.removePrefix(wrapperSource.getId(),
@@ -510,30 +583,55 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
private void dsToTargetAssignment(final DragAndDropEvent event) {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
final AbstractTable<NamedEntity, DistributionSetIdName> source = (AbstractTable<NamedEntity, DistributionSetIdName>) transferable
.getSourceComponent();
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> source = (AbstractTable<?, Long>) transferable.getSourceComponent();
final Set<Long> ids = source.getDeletedEntityByTransferable(transferable);
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object targetItemId = dropData.getItemIdOver();
LOG.debug("Adding a log to check if targetItemId is null : {} ", targetItemId);
if (targetItemId != null) {
final TargetIdName targetId = (TargetIdName) targetItemId;
String message = null;
if (targetItemId == null) {
getNotification().displayWarning(i18n.get("target.not.exists", new Object[] { "" }));
return;
}
final Long targetId = (Long) targetItemId;
final Target target = targetManagement.findTargetById(targetId);
if (target == null) {
getNotification().displayWarning(i18n.get("target.not.exists", new Object[] { "" }));
return;
}
final TargetIdName createTargetIdName = new TargetIdName(target);
for (final DistributionSetIdName distributionNameId : source.getDeletedEntityByTransferable(transferable)) {
if (null != distributionNameId) {
if (managementUIState.getAssignedList().keySet().contains(targetId)
&& managementUIState.getAssignedList().get(targetId).equals(distributionNameId)) {
message = getPendingActionMessage(message,
HawkbitCommonUtil.getDistributionNameAndVersion(distributionNameId.getName(),
distributionNameId.getVersion()),
targetId.getControllerId());
} else {
managementUIState.getAssignedList().put(targetId, distributionNameId);
}
final List<DistributionSet> findDistributionSetAllById = distributionSetManagement
.findDistributionSetAllById(ids);
if (findDistributionSetAllById.isEmpty()) {
notification.displayWarning(i18n.get("distributionsets.not.exists"));
return;
}
addNewTargetToAssignmentList(createTargetIdName, findDistributionSetAllById);
}
private void addNewTargetToAssignmentList(final TargetIdName createTargetIdName,
final List<DistributionSet> findDistributionSetAllById) {
String message = null;
final Set<DistributionSetIdName> distributionIdNameSet = findDistributionSetAllById.stream()
.map(distributionSet -> new DistributionSetIdName(distributionSet)).collect(Collectors.toSet());
for (final DistributionSetIdName distributionNameId : distributionIdNameSet) {
if (distributionNameId != null) {
if (managementUIState.getAssignedList().keySet().contains(createTargetIdName)
&& managementUIState.getAssignedList().get(createTargetIdName).equals(distributionNameId)) {
message = getPendingActionMessage(message,
HawkbitCommonUtil.getDistributionNameAndVersion(distributionNameId.getName(),
distributionNameId.getVersion()),
createTargetIdName.getControllerId());
} else {
managementUIState.getAssignedList().put(createTargetIdName, distributionNameId);
}
}
showOrHidePopupAndNotification(message);
}
showOrHidePopupAndNotification(message);
}
/**
@@ -559,12 +657,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
* @param distName
* as Name
* @param targetId
* as ID of Traget
* as ID of target
* @return String as msg
*/
private String getPendingActionMessage(final String message, final String distName, final String targetId) {
private String getPendingActionMessage(final String message, final String distName, final String controllerId) {
if (message == null) {
return i18n.get("message.dist.pending.action", new Object[] { targetId, distName });
return i18n.get("message.dist.pending.action", new Object[] { controllerId, distName });
}
return i18n.get("message.target.assigned.pending");
}
@@ -578,7 +676,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
@SuppressWarnings("unchecked")
public void updateTarget(final Target updatedTarget) {
if (updatedTarget != null) {
final Item item = getItem(updatedTarget.getTargetIdName());
final Item item = getItem(updatedTarget.getId());
// TO DO update SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER
// &
// SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER
@@ -701,10 +799,10 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
@SuppressWarnings("unchecked")
private void updateVisibleItemOnEvent(final TargetInfo targetInfo) {
final Target target = targetInfo.getTarget();
final TargetIdName targetIdName = target.getTargetIdName();
final Long targetId = target.getId();
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
final Item item = targetContainer.getItem(targetIdName);
final Item item = targetContainer.getItem(targetId);
item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName());
@@ -712,9 +810,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
.setValue(HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n));
}
private boolean isLastSelectedTarget(final TargetIdName targetIdName) {
return null != managementUIState.getLastSelectedTargetIdName()
&& managementUIState.getLastSelectedTargetIdName().equals(targetIdName);
private boolean isLastSelectedTarget(final Long targetId) {
return managementUIState.getLastSelectedTargetId() != null
&& managementUIState.getLastSelectedTargetId().equals(targetId);
}
private boolean isFilterEnabled() {

View File

@@ -11,12 +11,14 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.util.Set;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -35,6 +37,7 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUITargetDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.util.CollectionUtils;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -70,11 +73,13 @@ public class TargetTableHeader extends AbstractTableHeader {
private boolean isComplexFilterViewDisplayed;
private final transient DistributionSetManagement distributionSetManagement;
TargetTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
final UINotification notification, final ManagementUIState managementUIState,
final ManagementViewClientCriterion managementViewClientCriterion, final TargetManagement targetManagement,
final DeploymentManagement deploymentManagement, final UiProperties uiproperties, final UIEventBus eventBus,
final EntityFactory entityFactory, final UINotification uinotification, final TagManagement tagManagement) {
final EntityFactory entityFactory, final UINotification uinotification, final TagManagement tagManagement, DistributionSetManagement distributionSetManagement) {
super(i18n, permChecker, eventbus, managementUIState, null, null);
this.notification = notification;
this.managementViewClientCriterion = managementViewClientCriterion;
@@ -82,7 +87,7 @@ public class TargetTableHeader extends AbstractTableHeader {
entityFactory);
this.targetBulkUpdateWindow = new TargetBulkUpdateWindowLayout(i18n, targetManagement, eventBus,
managementUIState, deploymentManagement, uiproperties, permChecker, uinotification, tagManagement);
this.distributionSetManagement = distributionSetManagement;
onLoadRestoreState();
}
@@ -270,7 +275,7 @@ public class TargetTableHeader extends AbstractTableHeader {
@Override
protected void addNewItem(final ClickEvent event) {
targetAddUpdateWindow.resetComponents();
final Window addTargetWindow = targetAddUpdateWindow.getWindow();
final Window addTargetWindow = targetAddUpdateWindow.createNewWindow();
addTargetWindow.setCaption(i18n.get(UIComponentIdProvider.TARGET_ADD_CAPTION));
UI.getCurrent().addWindow(addTargetWindow);
addTargetWindow.setVisible(Boolean.TRUE);
@@ -323,14 +328,22 @@ public class TargetTableHeader extends AbstractTableHeader {
if (doValidations(event)) {
final TableTransferable tableTransferable = (TableTransferable) event.getTransferable();
final Table source = tableTransferable.getSourceComponent();
if (source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) {
final Set<DistributionSetIdName> distributionIdSet = getDropppedDistributionDetails(tableTransferable);
if (distributionIdSet != null && !distributionIdSet.isEmpty()) {
final DistributionSetIdName distributionSetIdName = distributionIdSet.iterator().next();
managementUIState.getTargetTableFilters().setDistributionSet(distributionSetIdName);
addFilterTextField(distributionSetIdName);
}
if (!UIComponentIdProvider.DIST_TABLE_ID.equals(source.getId())) {
return;
}
final Set<Long> distributionIdSet = getDropppedDistributionDetails(tableTransferable);
if (CollectionUtils.isEmpty(distributionIdSet)) {
return;
}
final Long distributionSetId = distributionIdSet.iterator().next();
DistributionSet distributionSet =distributionSetManagement.findDistributionSetById(distributionSetId);
if(distributionSet == null){
notification.displayWarning(i18n.get("distributionset.not.exists"));
return;
}
DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet);
managementUIState.getTargetTableFilters().setDistributionSet(distributionSetIdName);
addFilterTextField(distributionSetIdName);
}
}
@@ -363,9 +376,9 @@ public class TargetTableHeader extends AbstractTableHeader {
return isValid;
}
private Set<DistributionSetIdName> getDropppedDistributionDetails(final TableTransferable transferable) {
private static Set<Long> getDropppedDistributionDetails(final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, DistributionSetIdName> distTable = (AbstractTable<?, DistributionSetIdName>) transferable
final AbstractTable<?, Long> distTable = (AbstractTable<?, Long>) transferable
.getSourceComponent();
return distTable.getDeletedEntityByTransferable(transferable);
}

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.management.targettable;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
@@ -43,13 +44,13 @@ public class TargetTableLayout extends AbstractTableLayout<TargetTable> {
final ManagementViewClientCriterion managementViewClientCriterion,
final DeploymentManagement deploymentManagement, final UiProperties uiproperties,
final SpPermissionChecker permissionChecker, final UINotification uinotification,
final TagManagement tagManagement) {
final TagManagement tagManagement, final DistributionSetManagement distributionSetManagement) {
this.eventBus = eventBus;
this.targetDetails = new TargetDetails(i18n, eventbus, permissionChecker, managementUIState, uinotification,
tagManagement, targetManagement, entityFactory);
this.targetTableHeader = new TargetTableHeader(i18n, permissionChecker, eventBus, notification,
managementUIState, managementViewClientCriterion, targetManagement, deploymentManagement, uiproperties,
eventbus, entityFactory, uinotification, tagManagement);
eventbus, entityFactory, uinotification, tagManagement, distributionSetManagement);
super.init(targetTableHeader, targetTable, targetDetails);
}

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.management.targettag;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
@@ -60,9 +59,9 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange
final SpPermissionChecker permChecker, final ManagementUIState managementUIState, final I18N i18n,
final UIEventBus eventBus, final ManagementViewClientCriterion managementViewClientCriterion,
final UINotification notification, final EntityFactory entityFactory,
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement) {
final TargetFilterQueryManagement targetFilterQueryManagement) {
this.filterByButtons = new TargetTagFilterButtons(eventBus, managementUIState, managementViewClientCriterion,
i18n, notification, permChecker, entityFactory, targetManagement);
i18n, notification, permChecker, entityFactory);
this.targetFilterQueryButtonsTab = new TargetFilterQueryButtons(managementUIState, eventBus);
this.filterByStatusFotter = new FilterByStatusLayout(i18n, eventBus, managementUIState);
this.customTargetTagFilterButtonClick = new CustomTargetTagFilterButtonClick(eventBus, managementUIState,

View File

@@ -10,12 +10,9 @@ package org.eclipse.hawkbit.ui.management.targettag;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
@@ -25,6 +22,7 @@ import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -67,12 +65,10 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref
private final transient EntityFactory entityFactory;
private final transient TargetManagement targetManagement;
TargetTagFilterButtons(final UIEventBus eventBus, final ManagementUIState managementUIState,
final ManagementViewClientCriterion managementViewClientCriterion, final I18N i18n,
final UINotification notification, final SpPermissionChecker permChecker, final EntityFactory entityFactory,
final TargetManagement targetManagement) {
final UINotification notification, final SpPermissionChecker permChecker,
final EntityFactory entityFactory) {
super(eventBus, new TargetTagFilterButtonClick(eventBus, managementUIState));
this.managementUIState = managementUIState;
this.managementViewClientCriterion = managementViewClientCriterion;
@@ -80,7 +76,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref
this.notification = notification;
this.permChecker = permChecker;
this.entityFactory = entityFactory;
this.targetManagement = targetManagement;
addNewTargetTag(entityFactory.tag().create().name(NO_TAG).build());
}
@@ -199,20 +194,12 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
final TableTransferable transferable = (TableTransferable) event.getTransferable();
@SuppressWarnings("unchecked")
final AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) transferable
.getSourceComponent();
final Set<TargetIdName> targetSelected = targetTable.getDeletedEntityByTransferable(transferable);
final Set<String> targetList = targetSelected.stream().map(t -> t.getControllerId())
.collect(Collectors.toSet());
final TargetTable targetTable = (TargetTable) transferable.getSourceComponent();
final Set<Long> targetList = targetTable.getDeletedEntityByTransferable(transferable);
final String targTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
final TargetTagAssignmentResult result = targetTable.toggleTagAssignment(targetList, targTagName);
publishAssignTargetTagEvent(result);

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.management.targettag;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.RefreshableContainer;
@@ -36,11 +35,10 @@ public class TargetTagFilterLayout extends AbstractTargetTagFilterLayout impleme
final ManagementUIState managementUIState,
final ManagementViewClientCriterion managementViewClientCriterion, final SpPermissionChecker permChecker,
final UIEventBus eventBus, final UINotification notification, final EntityFactory entityFactory,
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement) {
final TargetFilterQueryManagement targetFilterQueryManagement) {
super(new TargetTagFilterHeader(i18n, createUpdateTargetTagLayout, managementUIState, permChecker, eventBus),
new MultipleTargetFilter(createUpdateTargetTagLayout, permChecker, managementUIState, i18n, eventBus,
managementViewClientCriterion, notification, entityFactory, targetManagement,
targetFilterQueryManagement),
managementViewClientCriterion, notification, entityFactory, targetFilterQueryManagement),
managementUIState);
this.createUpdateTargetTagLayout = createUpdateTargetTagLayout;
eventBus.subscribe(this);

View File

@@ -38,7 +38,6 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.builder.ComboBoxBuilder;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
@@ -157,8 +156,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
AddUpdateRolloutWindowLayout(final RolloutManagement rolloutManagement, final TargetManagement targetManagement,
final UINotification uiNotification, final UiProperties uiProperties, final EntityFactory entityFactory,
final I18N i18n, final UIEventBus eventBus, final TargetFilterQueryManagement targetFilterQueryManagement) {
this.actionTypeOptionGroupLayout = new ActionTypeOptionGroupLayout(i18n);
this.autoStartOptionGroupLayout = new AutoStartOptionGroupLayout(i18n);
actionTypeOptionGroupLayout = new ActionTypeOptionGroupLayout(i18n);
autoStartOptionGroupLayout = new AutoStartOptionGroupLayout(i18n);
this.rolloutManagement = rolloutManagement;
this.targetManagement = targetManagement;
this.uiNotification = uiNotification;
@@ -168,7 +167,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
this.eventBus = eventBus;
this.targetFilterQueryManagement = targetFilterQueryManagement;
this.defineGroupsLayout = new DefineGroupsLayout(i18n, entityFactory, rolloutManagement,
defineGroupsLayout = new DefineGroupsLayout(i18n, entityFactory, rolloutManagement,
targetFilterQueryManagement);
defaultRolloutGroupConditions = new RolloutGroupConditionBuilder().withDefaults().build();
@@ -600,10 +599,10 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
return;
}
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
final Long distributionSetId = (Long) distributionSet.getValue();
final RolloutUpdate rolloutUpdate = entityFactory.rollout().update(rollout.getId()).name(rolloutName.getValue())
.description(description.getValue()).set(distributionSetIdName.getId()).actionType(getActionType())
.description(description.getValue()).set(distributionSetId).actionType(getActionType())
.forcedTime(getForcedTimeStamp());
if (AutoStartOptionGroupLayout.AutoStartOption.AUTO_START.equals(getAutoStartOption())) {
@@ -656,7 +655,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
private Rollout saveRollout() {
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
final Long distributionId = (Long) distributionSet.getValue();
final int amountGroup = Integer.parseInt(noOfGroups.getValue());
final int errorThresholdPercent = getErrorThresholdPercentage(amountGroup);
@@ -667,8 +666,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
final RolloutCreate rolloutCreate = entityFactory.rollout().create().name(rolloutName.getValue())
.description(description.getValue()).set(distributionSetIdName.getId())
.targetFilterQuery(getTargetFilterQuery()).actionType(getActionType()).forcedTime(getForcedTimeStamp());
.description(description.getValue()).set(distributionId).targetFilterQuery(getTargetFilterQuery())
.actionType(getActionType()).forcedTime(getForcedTimeStamp());
if (AutoStartOptionGroupLayout.AutoStartOption.AUTO_START.equals(getAutoStartOption())) {
rolloutCreate.startAt(System.currentTimeMillis());
@@ -785,8 +784,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
final BeanQueryFactory<DistributionBeanQuery> distributionQF = new BeanQueryFactory<>(
DistributionBeanQuery.class);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
distributionQF);
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), distributionQF);
}
private TextField createRolloutNameField() {
@@ -851,13 +849,6 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
}
/**
*
* Populate rollout details.
*
* @param rolloutId
* rollout id
*/
private void populateData(final Long rolloutId, final boolean copy) {
if (rolloutId == null) {
return;
@@ -865,7 +856,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
rollout = rolloutManagement.findRolloutById(rolloutId);
description.setValue(rollout.getDescription());
distributionSet.setValue(DistributionSetIdName.generate(rollout.getDistributionSet()));
distributionSet.setValue(rollout.getDistributionSet().getId());
setActionType(rollout);
setAutoStartType(rollout);
@@ -960,7 +951,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
String value;
ERRORTHRESOLDOPTIONS(final String val) {
this.value = val;
value = val;
}
/**

View File

@@ -98,7 +98,6 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
private static ProxyTarget mapTargetToProxy(final TargetWithActionStatus targetWithActionStatus) {
final Target targ = targetWithActionStatus.getTarget();
final ProxyTarget prxyTarget = new ProxyTarget();
prxyTarget.setTargetIdName(targ.getTargetIdName());
prxyTarget.setName(targ.getName());
prxyTarget.setDescription(targ.getDescription());
prxyTarget.setControllerId(targ.getControllerId());

View File

@@ -10,13 +10,11 @@ package org.eclipse.hawkbit.ui.utils;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.PollStatus;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
@@ -64,9 +62,6 @@ public final class HawkbitCommonUtil {
private static final String PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT = "var a = document.getElementById('tag-color-preview'); if(a) { document.head.removeChild(a); } ";
private static final String PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT = "document.getElementById('tag-color-preview').innerHTML = tagColorPreviewStyle;";
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
private HawkbitCommonUtil() {
}
@@ -444,42 +439,6 @@ public final class HawkbitCommonUtil {
.append(PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT).toString();
}
/**
* Add target table container properties.
*
* @param container
* table container
*/
public static void addTargetTableContainerProperties(final Container container) {
final LazyQueryContainer targetTableContainer = (LazyQueryContainer) container;
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CONT_ID, String.class, "", false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class,
TargetUpdateStatus.UNKNOWN, false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_ID, Long.class, null,
false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_ID, Long.class, null,
false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "",
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class,
"", false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.LAST_QUERY_DATE, Date.class, null, false, false);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false,
true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false,
true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null,
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null,
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
targetTableContainer.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
targetTableContainer.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
}
/**
* Apply style for status label in target table.
*

View File

@@ -119,14 +119,6 @@ public final class SPUILabelDefinitions {
* CONT ID.
*/
public static final String VAR_CONT_ID = "controllerId";
/**
* CONT ID AND NAME = ItemId.
*/
public static final String VAR_CONT_ID_NAME = "targetIdName";
/**
* Distribution set ID and Name= ItemId.
*/
public static final String VAR_DIST_ID_NAME = "distributionSetIdName";
/**
* Distribution set ID.
@@ -147,6 +139,10 @@ public final class SPUILabelDefinitions {
*/
public static final String VAR_DESC = "description";
public static final String ASSIGN_DIST_SET = "assignedDistributionSet";
public static final String INSTALL_DIST_SET = "installedDistributionSet";
/**
* VERSION.
*/

View File

@@ -961,9 +961,6 @@ public final class UIComponentIdProvider {
*/
public static final String DIST_SET_SELECT_CONS_WINDOW_ID = "distribution.set.select.consequences.window";
/**
* Distribution set select enable checkbox id
*/
public static final String DIST_SET_SELECT_ENABLE_ID = "distribution.set.select.enable";
public static final String NOTIFICATION_UNREAD_ID = "notification.unread";

View File

@@ -43,6 +43,17 @@ public class UINotification implements Serializable {
true);
}
/**
* Display warning type of notification message.
*
* @param message
* is the message to displayed as warning.
*/
public void displayWarning(final String message) {
notificationMessage.showNotification(SPUILabelDefinitions.SP_NOTIFICATION_WARNING_MESSAGE_STYLE, null, message,
true);
}
/**
* Display error type of notification message.
*

View File

@@ -575,3 +575,11 @@ controller.polling.title=Polling Configuration
controller.polling.time=Polling Time
controller.polling.overduetime=Polling Overdue Time
# entity not exist
target.not.exists=Target {0} does not exists. Maybe the target was deleted.
targets.not.exists=Targets does not exists. Maybe the targets was deleted.
distributionset.not.existsDistribution=Distribution set does not exist. Maybe the set was deleted.
distributionsets.not.exists=Distribution sets do not exists. Maybe the sets were deleted.
targettag.not.exists=Target tag {0} does not exists. Maybe the target tag was deleted.