use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class ImportRepoImageModel method executeCommand.
@Override
public void executeCommand(UICommand command) {
if (!validate()) {
return;
}
super.executeCommand(command);
startProgress();
ArrayList<ActionParametersBase> actionParameters = new ArrayList<>();
final StringBuilder imageNames = new StringBuilder();
for (EntityModel entity : getEntities()) {
RepoImage repoImage = (RepoImage) entity.getEntity();
// $NON-NLS-1$
imageNames.append("\n -");
imageNames.append(repoImage.getRepoImageName());
ImportRepoImageParameters importParameters = new ImportRepoImageParameters();
// source
importParameters.setSourceRepoImageId(repoImage.getRepoImageId());
importParameters.setSourceStorageDomainId(sourceStorageDomain.getId());
// destination
importParameters.setDiskAlias(((RepoImageModel) entity).getDiskImageAlias());
importParameters.setStoragePoolId(getDataCenter().getSelectedItem().getId());
importParameters.setStorageDomainId(getStorageDomain().getSelectedItem().getId());
importParameters.setClusterId(getStorageDomain().getSelectedItem().getId());
Quota selectedQuota = getQuota().getSelectedItem();
if (selectedQuota != null) {
importParameters.setQuotaId(selectedQuota.getId());
}
Boolean importAsTemplate = getImportAsTemplate().getEntity();
importParameters.setImportAsTemplate(importAsTemplate);
if (importAsTemplate) {
importParameters.setClusterId(getCluster().getSelectedItem().getId());
String templateName = getTemplateName().getEntity();
if (StringHelper.isNotNullOrEmpty(templateName)) {
importParameters.setTemplateName(templateName);
}
}
actionParameters.add(importParameters);
}
Frontend.getInstance().runMultipleAction(ActionType.ImportRepoImage, actionParameters, result -> {
ImportExportRepoImageBaseModel model = (ImportExportRepoImageBaseModel) result.getState();
model.stopProgress();
model.cancel();
ConfirmationModel confirmModel = new ConfirmationModel();
storageIsoListModel.setConfirmWindow(confirmModel);
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().importImagesTitle());
confirmModel.setHelpTag(HelpTag.import_images);
// $NON-NLS-1$
confirmModel.setHashName("import_images");
confirmModel.setMessage(ConstantsManager.getInstance().getMessages().importProcessHasBegunForImages(imageNames.toString()));
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("CancelConfirm", storageIsoListModel).setTitle(ConstantsManager.getInstance().getConstants().close()).setIsDefault(true).setIsCancel(true));
}, this);
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class ImportRepoImageModel method setRepoImages.
public void setRepoImages(List<RepoImage> repoImages) {
ArrayList<EntityModel> entities = new ArrayList<>();
for (RepoImage i : repoImages) {
entities.add(new RepoImageModel(i));
}
setEntities(entities);
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class AdElementListModel method addUsersToModel.
protected void addUsersToModel(QueryReturnValue returnValue, Set<String> excludeUsers) {
for (Queryable item : (List<Queryable>) returnValue.getReturnValue()) {
DirectoryUser a = (DirectoryUser) item;
if (!excludeUsers.contains(a.getId())) {
EntityModel<DbUser> tempVar2 = new EntityModel<>();
tempVar2.setEntity(new DbUser(a));
getusers().add(tempVar2);
}
}
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class TagListModel method tagToModel.
public TagModel tagToModel(Tags tag) {
EntityModel<String> tempVar = new EntityModel<>();
tempVar.setEntity(tag.getTagName());
EntityModel<String> name = tempVar;
EntityModel<String> tempVar2 = new EntityModel<>();
tempVar2.setEntity(tag.getDescription());
EntityModel<String> description = tempVar2;
ArrayList<TagModel> children = new ArrayList<>();
for (Tags a : tag.getChildren()) {
children.add(tagToModel(a));
}
TagModel model = new TagModel();
model.setId(tag.getTagId());
model.setName(name);
model.setDescription(description);
model.setType((tag.getIsReadonly() == null ? false : tag.getIsReadonly()) ? TagModelType.ReadOnly : TagModelType.Regular);
model.setSelection(false);
model.setParentId(tag.getParentId() == null ? Guid.Empty : tag.getParentId());
model.setChildren(children);
for (TagModel child : children) {
child.setParent(model);
}
model.getSelectionChangedEvent().addListener(this);
return model;
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class StorageListModel method importFileStoragePostInit.
public void importFileStoragePostInit() {
Guid storagePoolId = null;
StoragePool dataCenter = storageModel.getContainer().getDataCenter().getSelectedItem();
if (dataCenter != null && !dataCenter.getId().equals(Guid.Empty)) {
storagePoolId = dataCenter.getId();
}
// Check storage domain existence
AsyncDataProvider.getInstance().getStorageDomainsByConnection(new AsyncQuery<>(storages -> {
if (storages != null && storages.size() > 0) {
String storageName = storages.get(0).getStorageName();
onFinish(context, false, storageModel, ConstantsManager.getInstance().getMessages().importFailedDomainAlreadyExistStorageMsg(storageName));
} else {
StorageServerConnections tempVar = new StorageServerConnections();
tempVar.setConnection(path);
tempVar.setStorageType(storageType);
if (storageModel instanceof NfsStorageModel) {
NfsStorageModel nfsModel = (NfsStorageModel) storageModel;
if (isConnectionOverriden()) {
tempVar.setNfsVersion((NfsVersion) ((EntityModel) nfsModel.getVersion().getSelectedItem()).getEntity());
tempVar.setNfsRetrans(nfsModel.getRetransmissions().asConvertible().nullableShort());
tempVar.setNfsTimeo(nfsModel.getTimeout().asConvertible().nullableShort());
}
}
if (storageModel instanceof PosixStorageModel) {
PosixStorageModel posixModel = (PosixStorageModel) storageModel;
tempVar.setVfsType(posixModel.getVfsType().getEntity());
tempVar.setMountOptions(posixModel.getMountOptions().getEntity());
}
fileConnection = tempVar;
importFileStorageConnect();
}
}), storagePoolId, path);
}
Aggregations