use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainModel method getTemplatesFromExportDomain.
protected void getTemplatesFromExportDomain() {
GetAllFromExportDomainQueryParameters tempVar = new GetAllFromExportDomainQueryParameters(storagePool.getId(), (Guid) getEntity());
Frontend.getInstance().runQuery(QueryType.GetTemplatesFromExportDomain, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
Map<VmTemplate, List<DiskImage>> dictionary = (HashMap<VmTemplate, List<DiskImage>>) returnValue.getReturnValue();
Map<Guid, Guid> tempMap = new HashMap<>();
for (Entry<VmTemplate, List<DiskImage>> entry : dictionary.entrySet()) {
tempMap.put(entry.getKey().getId(), null);
}
for (Entry<Guid, List<Disk>> missingTemplateEntry : missingTemplateDiskMap.entrySet()) {
if (tempMap.containsKey(missingTemplateEntry.getKey())) {
for (Disk disk : missingTemplateEntry.getValue()) {
addDiskImportData(disk.getId(), filteredStorageDomains, ((DiskImage) disk).getVolumeType(), new EntityModel(true));
}
} else {
showCloseMessage(ConstantsManager.getInstance().getConstants().errorTemplateCannotBeFoundMessage());
return;
}
}
ImportVmFromExportDomainModel.this.setMessage(ConstantsManager.getInstance().getConstants().importMissingStorages());
for (ImportVmData vmData : (List<ImportVmData>) getItems()) {
if (!Guid.Empty.equals(vmData.getVm().getVmtGuid()) && missingTemplateDiskMap.containsKey(vmData.getVm().getVmtGuid())) {
vmData.setTemplateExistsInSetup(false);
}
}
postInitDisks();
}));
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class ImportVmModel method validateName.
private boolean validateName(final ImportVmData data) {
final int maxNameLength = getMaxNameLength();
VmImportGeneralModel model = (VmImportGeneralModel) getDetailModels().get(0);
EntityModel<String> vmName = new EntityModel<>(data.getVm().getName());
vmName.validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(maxNameLength), new I18NNameValidation(), new UniqueNameValidator(data), value -> isNameExistsInTheSystem(vmName.getEntity()) ? ValidationResult.fail(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason()) : ValidationResult.ok() });
data.setError(vmName.getIsValid() ? null : ConstantsManager.getInstance().getConstants().invalidName());
// Updating the 'name' model in general sub-tab
model.getName().setInvalidityReasons(vmName.getInvalidityReasons());
model.getName().setIsValid(vmName.getIsValid());
return vmName.getIsValid();
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class ImportVmsModel method updateVms.
private void updateVms(List<VM> vms) {
clearVms();
List<EntityModel<VM>> externalVms = new ArrayList<>();
for (VM vm : vms) {
externalVms.add(new EntityModel<>(vm));
}
externalVmModels.setItems(externalVms);
stopProgress();
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class UnitVmModel method firstBootDevice_SelectedItemChanged.
private void firstBootDevice_SelectedItemChanged(Object sender, EventArgs args) {
EntityModel<BootSequence> entityModel = getFirstBootDevice().getSelectedItem();
BootSequence firstDevice = entityModel.getEntity();
EntityModel<BootSequence> prevItem = null;
List<EntityModel<BootSequence>> list = new ArrayList<>();
for (EntityModel<BootSequence> item : getFirstBootDevice().getItems()) {
if (item.getEntity() != firstDevice) {
list.add(item);
if (getSecondBootDevice().getSelectedItem() != null && item.getEntity() == getSecondBootDevice().getSelectedItem().getEntity()) {
prevItem = item;
}
}
}
EntityModel<BootSequence> tempVar = new EntityModel<>();
tempVar.setTitle(ConstantsManager.getInstance().getConstants().noneTitle());
EntityModel<BootSequence> noneOption = tempVar;
list.add(0, noneOption);
getSecondBootDevice().setItems(list);
if (prevItem != null) {
getSecondBootDevice().setSelectedItem(prevItem);
} else {
getSecondBootDevice().setSelectedItem(noneOption);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class PriorityUtil method postUpdatePriority.
private void postUpdatePriority(PriorityUpdatingCallbacks callbacks) {
before(callbacks);
List<EntityModel<Integer>> items = new ArrayList<>();
EntityModel tempVar = new EntityModel();
tempVar.setTitle(ConstantsManager.getInstance().getConstants().lowTitle());
tempVar.setEntity(1);
items.add(tempVar);
EntityModel tempVar2 = new EntityModel();
tempVar2.setTitle(ConstantsManager.getInstance().getConstants().mediumTitle());
tempVar2.setEntity(cachedMaxPriority / 2);
items.add(tempVar2);
EntityModel tempVar3 = new EntityModel();
tempVar3.setTitle(ConstantsManager.getInstance().getConstants().highTitle());
tempVar3.setEntity(cachedMaxPriority);
items.add(tempVar3);
// If there was some priority selected before, try select it again.
EntityModel<Integer> oldPriority = model.getPriority().getSelectedItem();
model.getPriority().setItems(items);
if (oldPriority != null) {
for (EntityModel<Integer> item : items) {
Integer val1 = item.getEntity();
Integer val2 = oldPriority.getEntity();
if (val1 != null && val1.equals(val2)) {
model.getPriority().setSelectedItem(item);
break;
}
}
} else {
model.getPriority().setSelectedItem(Linq.firstOrNull(items));
}
after(callbacks);
}
Aggregations