- Fix ds assignment result

- Fix drag and drop to assignment

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-08-15 17:57:52 +02:00
parent d89b6993d4
commit aa5e4d0601
7 changed files with 45 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import java.util.List;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.Target;
import org.springframework.util.CollectionUtils;
/**
* A bean which holds a complex result of an service operation to combine the
@@ -61,6 +62,10 @@ public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
@Override
public List<Target> getAssignedEntity() {
if (CollectionUtils.isEmpty(assignedTargets)) {
return Collections.emptyList();
}
return targetManagement.findTargetByControllerID(assignedTargets);
}

View File

@@ -16,6 +16,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.exception.DistributionSetTypeUndefinedException;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
@@ -818,6 +819,28 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
.isEqualTo(2);
}
@Test
@Description("Test different assignment results, after assign a ds")
public void testAlreadyAssignedTargetsToDs() {
DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3");
// create assigned DS
dsToTargetAssigned = distributionSetManagement.findDistributionSetByNameAndVersion(dsToTargetAssigned.getName(),
dsToTargetAssigned.getVersion());
final Target target = new JpaTarget("4712");
final Target savedTarget = targetManagement.createTarget(target);
final List<Target> toAssign = new ArrayList<>();
toAssign.add(savedTarget);
DistributionSetAssignmentResult assignmentResult = deploymentManagement
.assignDistributionSet(dsToTargetAssigned, toAssign);
assertThat(assignmentResult.getAssignedEntity()).hasSize(1);
assignmentResult = deploymentManagement.assignDistributionSet(dsToTargetAssigned, toAssign);
assertThat(assignmentResult.getAssignedEntity()).hasSize(0);
assertThat(distributionSetRepository.findAll()).hasSize(1);
}
private Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
final String successCondition, final String errorCondition) {

View File

@@ -558,6 +558,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
if (targetList.isEmpty()) {
final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {});
notification.displayValidationError(actionDidNotWork);
return;
}
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();

View File

@@ -158,7 +158,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
final TableTransferable tbl = (TableTransferable) event.getTransferable();
final Table source = tbl.getSourceComponent();
if (source.getId().equals(SPUIComponentIdProvider.TARGET_TABLE_ID)) {
processTargetDrop(event);
UI.getCurrent().access(() -> processTargetDrop(event));
}
}
}
@@ -216,11 +216,18 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private void processTargetDrop(final DragAndDropEvent event) {
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);
if (targetSelected.isEmpty()) {
final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {});
notification.displayValidationError(actionDidNotWork);
return;
}
final Set<String> targetList = targetSelected.stream().map(t -> t.getControllerId())
.collect(Collectors.toSet());

View File

@@ -287,6 +287,7 @@ message.forcequit.action.failed = Force Quitting the action is not possible !
message.forcequit.action.confirm = Attention!\nForce quit should only be used when the assignment action is not working properly.\nForce quitting an action has no effect on the connected target. It is just resetting \nthe data stored on the SP update server. \nAre you absolutely sure that you want to force quit this action?
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
message.action.not.allowed = Action not allowed
message.action.did.not.work = Action did not work. Please try again.
message.onlyone.distribution.assigned = Only one distribution set can be assigned
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
message.error.missing.typename = Missing Type Name

View File

@@ -284,6 +284,7 @@ message.force.action.confirm = Are you sure that you want to force this action?
message.force.action.success = Action forced successfully !
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
message.action.not.allowed = Action not allowed
message.action.did.not.work = Action did not work. Please try again.
message.onlyone.distribution.assigned = Only one distribution set can be assigned
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
message.error.missing.typename = Missing Type Name

View File

@@ -282,6 +282,7 @@ message.force.action.confirm = Are you sure that you want to force this action?
message.force.action.success = Action forced successfully !
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
message.action.not.allowed = Action not allowed
message.action.did.not.work = Action did not work. Please try again.
message.onlyone.distribution.assigned = Only one distribution set can be assigned
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
message.error.missing.typename = Missing Type Name