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(); } }
private String getItemid(final String filename, final SoftwareModule softwareModule) { return new StringBuilder(filename) .append( HawkbitCommonUtil.getFormattedNameVersion( softwareModule.getName(), softwareModule.getVersion())) .toString(); }
private void restoreState() { final Indexed container = grid.getContainerDataSource(); if (container.getItemIds().isEmpty()) { container.removeAllItems(); for (final UploadStatusObject statusObject : artifactUploadState.getUploadedFileStatusList()) { final Item item = container.addItem( getItemid(statusObject.getFilename(), statusObject.getSelectedSoftwareModule())); item.getItemProperty(REASON) .setValue(statusObject.getReason() != null ? statusObject.getReason() : ""); if (statusObject.getStatus() != null) { item.getItemProperty(STATUS).setValue(statusObject.getStatus()); } if (statusObject.getProgress() != null) { item.getItemProperty(PROGRESS).setValue(statusObject.getProgress()); } item.getItemProperty(FILE_NAME).setValue(statusObject.getFilename()); final SoftwareModule sw = statusObject.getSelectedSoftwareModule(); item.getItemProperty(SPUILabelDefinitions.NAME_VERSION) .setValue(HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion())); } if (artifactUploadState.isUploadCompleted()) { minimizeButton.setEnabled(false); } } }
@SuppressWarnings("unchecked") private void uploadRecevied(final String filename, final SoftwareModule softwareModule) { final Item item = uploads.addItem(getItemid(filename, softwareModule)); if (item != null) { item.getItemProperty(FILE_NAME).setValue(filename); item.getItemProperty(SPUILabelDefinitions.NAME_VERSION) .setValue( HawkbitCommonUtil.getFormattedNameVersion( softwareModule.getName(), softwareModule.getVersion())); final UploadStatusObject uploadStatus = new UploadStatusObject(filename, softwareModule); uploadStatus.setStatus("Active"); artifactUploadState.getUploadedFileStatusList().add(uploadStatus); } }
private String validate( final Set<TargetIdName> targetDetailsList, final DistributionSetIdName distributionSetIdName) { 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); } } } return pendingActionMessage; }
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})); } }
@Override protected String getName() { return HawkbitCommonUtil.getFormattedNameVersion( getSelectedBaseEntity().getName(), getSelectedBaseEntity().getVersion()); }
@Override protected void addContainerProperties(final Container container) { HawkbitCommonUtil.getDsTableColumnProperties(container); }