Search in sources :

Example 96 with EntityModel

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();
    }));
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) Inject(com.google.inject.Inject) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HashMap(java.util.HashMap) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) ActionType(org.ovirt.engine.core.common.action.ActionType) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) Frontend(org.ovirt.engine.ui.frontend.Frontend) QuotaListModel(org.ovirt.engine.ui.uicommonweb.models.quota.QuotaListModel) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) ClusterListModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterListModel) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Quota(org.ovirt.engine.core.common.businessentities.Quota) ImportVmParameters(org.ovirt.engine.core.common.action.ImportVmParameters) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Entry(java.util.Map.Entry) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Entry(java.util.Map.Entry) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)

Example 97 with EntityModel

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();
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)

Example 98 with EntityModel

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();
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Example 99 with EntityModel

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);
    }
}
Also used : BootSequence(org.ovirt.engine.core.common.businessentities.BootSequence) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Example 100 with EntityModel

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);
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Aggregations

EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)105 ArrayList (java.util.ArrayList)56 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)27 List (java.util.List)26 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)23 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)22 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)22 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)22 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)20 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)19 ActionType (org.ovirt.engine.core.common.action.ActionType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)17 Guid (org.ovirt.engine.core.compat.Guid)17 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 QueryType (org.ovirt.engine.core.common.queries.QueryType)16 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)13