introduced open actionIds in MgmtTargetAssignmentResponseBody (#864)

* introduced open actionIds in MgmtTargetAssignmentResponseBody

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed SonarQube issues

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* removed unused method parameter

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* updated documentation tests

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* added limit to the alreadyAssignedActions in the AssignmentResult

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* moved alreadyAssignedActions limitation to MgmtDistributionSetMapper

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed review findings

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* removed alreadyAssignedActions

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed sonarQube issues

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed compilation error

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed PR review findings

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed PR review findings

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* Renamed AssignmentResult to AbstractAssignmentResult

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed review findings

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* fixed formatting

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* reverted method visibility

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>
This commit is contained in:
Ahmed Sayed
2019-08-20 11:31:20 +02:00
committed by Dominic Schabel
parent 973f1952c7
commit d40b11d2ab
43 changed files with 580 additions and 402 deletions

View File

@@ -88,7 +88,6 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
@@ -547,21 +546,19 @@ public class TargetTable extends AbstractTable<Target> {
* @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.get(targetIds).stream().map(Target::getControllerId)
.collect(Collectors.toList());
if (controllerIds.isEmpty()) {
final List<Target> targets = targetManagement.get(targetIds);
if (targets.isEmpty()) {
getNotification().displayWarning(getI18n().getMessage("targets.not.exists"));
return new TargetTagAssignmentResult(0, 0, 0, Lists.newArrayListWithCapacity(0),
Lists.newArrayListWithCapacity(0), null);
return new TargetTagAssignmentResult(0, Collections.emptyList(), Collections.emptyList(), null);
}
final Optional<TargetTag> tag = tagManagement.getByName(targTagName);
if (!tag.isPresent()) {
getNotification().displayWarning(getI18n().getMessage("targettag.not.exists", targTagName));
return new TargetTagAssignmentResult(0, 0, 0, Lists.newArrayListWithCapacity(0),
Lists.newArrayListWithCapacity(0), null);
return new TargetTagAssignmentResult(0, Collections.emptyList(), Collections.emptyList(), null);
}
final List<String> controllerIds = targets.stream().map(Target::getControllerId).collect(Collectors.toList());
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(controllerIds, targTagName);
getNotification().displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, getI18n()));
@@ -988,4 +985,4 @@ public class TargetTable extends AbstractTable<Target> {
.getConfigurationValue(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, Boolean.class).getValue());
}
}
}

View File

@@ -14,7 +14,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.AbstractAssignmentResult;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.PollStatus;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
@@ -294,7 +294,7 @@ public final class HawkbitCommonUtil {
* @return message
*/
public static String createAssignmentMessage(final String tagName,
final AssignmentResult<? extends NamedEntity> result, final VaadinMessageSource i18n) {
final AbstractAssignmentResult<? extends NamedEntity> result, final VaadinMessageSource i18n) {
final StringBuilder formMsg = new StringBuilder();
final int assignedCount = result.getAssigned();
final int alreadyAssignedCount = result.getAlreadyAssigned();