Esempio n. 1
0
  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> distList = new HashSet<>();

    final AbstractSelectTargetDetails dropData =
        (AbstractSelectTargetDetails) event.getTargetDetails();
    final Object distItemId = dropData.getItemIdOver();

    if (!distsSelected.contains(distItemId)) {
      distList.add(((DistributionSetIdName) distItemId).getId());
    } else {
      distList.addAll(distsSelected.stream().map(t -> t.getId()).collect(Collectors.toList()));
    }

    final String distTagName =
        HawkbitCommonUtil.removePrefix(
            event.getTransferable().getSourceComponent().getId(),
            SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS);

    final DistributionSetTagAssignmentResult result =
        distributionSetManagement.toggleTagAssignment(distList, distTagName);

    uiNotification.displaySuccess(
        HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
    if (result.getAssigned() >= 1
        && managementUIState.getDistributionTableFilters().isNoTagSelected()) {
      refreshFilter();
    }
  }
Esempio n. 2
0
 private void assignTargetTag(final DragAndDropEvent event) {
   final AbstractSelectTargetDetails dropData =
       (AbstractSelectTargetDetails) event.getTargetDetails();
   final Object distItemId = dropData.getItemIdOver();
   final String targetTagName =
       HawkbitCommonUtil.removePrefix(
           event.getTransferable().getSourceComponent().getId(),
           SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
   // get all the targets assigned to the tag
   // 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);
   } else {
     uiNotification.displaySuccess(
         i18n.get("message.no.targets.assiged.fortag", new Object[] {targetTagName}));
   }
 }