@Override protected String extractNameFromEntity(VmTemplate entity) { return entity.getName(); }
public ImportTemplateData(VmTemplate template) { setEntity(template); templateName = template.getName(); }
protected void preSearchCalled(VmTemplate template) { setSearchString("Events:event_template=" + template.getName()); //$NON-NLS-1$ }
protected String getObjectName(ImportTemplateData templateData) { return templateData.getTemplate().getName(); }
protected String getObjectName(ImportTemplateData templateData) { return templateData.getTemplate().getName(); }
private Map<String, List<String>> getDependentVMsForTemplates(List<VM> vmsInExportDomain, List<VmTemplate> templates) { // Build a map between the template ID and the template instance Map<Guid, VmTemplate> templateMap = Entities.businessEntitiesById(templates); // Build a map between the template name and a list of dependent VMs names return vmsInExportDomain .stream() .filter(vm -> templateMap.containsKey(vm.getVmtGuid())) .collect(Collectors.groupingBy(vm -> templateMap.get(vm.getVmtGuid()).getName(), Collectors.mapping(VM::getName, Collectors.toList()))); }
protected boolean validateSuffix(String suffix, EntityModel entityModel) { return objectsToClone.stream() .map(itd -> itd.getTemplate().getName()) .allMatch(n -> validateName(n + suffix, entityModel, getClonedAppendedNameValidators())); }
@Override public String getVmTemplateName() { if (StringUtils.isEmpty(vmTemplateName) && getVmTemplate() != null) { vmTemplateName = getVmTemplate().getName(); } return vmTemplateName; }
protected boolean validateSuffix(String suffix, EntityModel entityModel) { return objectsToClone.stream() .map(itd -> itd.getTemplate().getName()) .allMatch(n -> validateName(n + suffix, entityModel, getClonedAppendedNameValidators())); }
private void genVersionToBaseTemplate(Iterable<VmTemplate> items) { if (items == null) { templateIdToBaseTemplateName = null; return; } Map<Guid, VmTemplate> templateIdToTemplate = new HashMap<>(); for (VmTemplate template : items) { templateIdToTemplate.put(template.getId(), template); } templateIdToBaseTemplateName = new HashMap<>(); for (VmTemplate template : items) { VmTemplate baseTemplate = templateIdToTemplate.get(template.getBaseTemplateId()); templateIdToBaseTemplateName.put(template.getId(), baseTemplate != null ? baseTemplate.getName() : ""); //$NON-NLS-1$ } }
@Override public void search() { if (getEntity() != null) { setSearchString("Vms: template.name=" + getEntity().getName()); //$NON-NLS-1$ super.search(); } }
static org.ovirt.engine.core.common.businessentities.InstanceType setUpEntityExpectations(VmTemplate entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getDescription()).thenReturn(DESCRIPTIONS[index]); when(entity.getNumOfCpus()).thenReturn(8); when(entity.getNumOfSockets()).thenReturn(2); when(entity.getThreadsPerCpu()).thenReturn(1); when(entity.getCpuPerSocket()).thenReturn(4); when(entity.isBaseTemplate()).thenReturn(true); return entity; }
protected org.ovirt.engine.core.common.businessentities.VmTemplate getTemplateEntity() { VmTemplate entity = mock(VmTemplate.class); when(entity.getId()).thenReturn(GUIDS[1]); when(entity.getClusterId()).thenReturn(GUIDS[2]); when(entity.getName()).thenReturn(NAMES[1]); when(entity.getDescription()).thenReturn(DESCRIPTIONS[1]); when(entity.getNumOfCpus()).thenReturn(8); when(entity.getNumOfSockets()).thenReturn(2); when(entity.getDefaultDisplayType()).thenReturn(DisplayType.vga); when(entity.getNumOfMonitors()).thenReturn(2); when(entity.getVmType()).thenReturn(VmType.Server); return entity; }
protected void exportOva() { VmTemplate selectedEntity = getSelectedItem(); if (selectedEntity == null) { return; } if (getWindow() != null) { return; } ExportOvaModel model = getSelectedItems().size() == 1 ? new ExportOvaModel(selectedEntity.getName()) : new ExportOvaModel(); setWindow(model); model.startProgress(); setupExportOvaModel(model); AsyncDataProvider.getInstance().getHostListByDataCenter(new AsyncQuery<>( hosts -> postExportOvaGetHosts(hosts.stream() .filter(host -> host.getStatus() == VDSStatus.Up) .collect(Collectors.toList())) ), extractStoragePoolIdNullSafe(selectedEntity)); }
@Override protected void remove() { if (getWindow() != null) { return; } ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(constants.removeBackedUpTemplatesTitle()); model.setHelpTag(HelpTag.remove_backed_up_template); model.setHashName("remove_backed_up_template"); //$NON-NLS-1$ List<String> items = getSelectedItems() .stream() .map(template -> template.getName() + getTemplateVersionNameAndNumber(template)) .collect(Collectors.toList()); model.setItems(items); model.setNote(constants.noteTheDeletedItemsMightStillAppearOntheSubTab()); model.getCommands().add(UICommand.createDefaultOkUiCommand("OnRemove", this)); //$NON-NLS-1$ model.getCommands().add(UICommand.createCancelUiCommand(CANCEL_COMMAND, this)); }
public NetworkTemplateListModel() { setTitle(ConstantsManager.getInstance().getConstants().templatesTitle()); setHelpTag(HelpTag.templates); setHashName("templates"); //$NON-NLS-1$ setAvailableInModes(ApplicationMode.VirtOnly); setComparator(Comparator .comparing((PairQueryable<VmNetworkInterface, VmTemplate> p) -> p.getSecond().getClusterName()) .thenComparing(p -> p.getSecond().getName())); setRemoveCommand(new UICommand("Remove", this)); //$NON-NLS-1$ updateActionAvailability(); }
@Test public void testGetEntityNameByIdAndTypeForVmTemplate() { VmTemplate vmTemplate = vmTemplateDao.get(VM_TEMPLATE_ID); assertNotNull(vmTemplate); String name = vmTemplate.getName(); assertEquals(name, dao.getEntityNameByIdAndType(VM_TEMPLATE_ID, VdcObjectType.VmTemplate)); }
@Override protected void baseTemplateSelectedItemChanged() { if (getModel().getBaseTemplate().getSelectedItem() != null && getModel().getIsSubTemplate().getEntity()) { // template.name for version should be the same as the base template name getModel().getName().setEntity(getModel().getBaseTemplate().getSelectedItem().getName()); } }
@Override protected MapSqlParameterSource createFullParametersMapper(VmTemplate template) { return createBaseParametersMapper(template) .addValue("child_count", template.getChildCount()) .addValue("name", template.getName()) .addValue("status", template.getStatus()) .addValue("is_disabled", template.isDisabled()) .addValue("template_type", template.getTemplateType().name()) .addValue("base_template_id", template.getBaseTemplateId()) .addValue("template_version_name", template.getTemplateVersionName()); }
@Override protected void isSubTemplateEntityChanged() { getModel().getName().setIsChangeable(!getModel().getIsSubTemplate().getEntity()); if (!getModel().getIsSubTemplate().getEntity()) { getModel().getName().setEntity(""); //$NON-NLS-1$ } else { // there will always be at least 'Blank' base template getModel().getBaseTemplate().setSelectedItem(getModel().getBaseTemplate().getItems().iterator().next()); // copy any entered name to be the template-version name getModel().getTemplateVersionName().setEntity(getModel().getName().getEntity()); getModel().getName().setEntity(getModel().getBaseTemplate().getSelectedItem().getName()); } }