use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class RemoveQosModel method handleSetMessageQueryResult.
protected void handleSetMessageQueryResult(FrontendMultipleQueryAsyncResult result) {
Map<String, String> entitiesAndQos = new HashMap<>();
setHelpTag(getRemoveQosHelpTag());
setHashName(getRemoveQosHashName());
int index = 0;
for (QueryReturnValue returnValue : result.getReturnValues()) {
for (Nameable entity : (List<Nameable>) returnValue.getReturnValue()) {
entitiesAndQos.put(entity.getName(), sourceListModel.getSelectedItems().get(index).getName());
}
index++;
}
if (entitiesAndQos.isEmpty()) {
ArrayList<String> list = new ArrayList<>();
for (T item : sourceListModel.getSelectedItems()) {
list.add(item.getName());
}
setItems(list);
} else {
setMessage(getRemoveQosMessage(entitiesAndQos.size()));
ArrayList<String> list = new ArrayList<>();
for (Entry<String, String> item : entitiesAndQos.entrySet()) {
// $NON-NLS-1$ //$NON-NLS-2$
list.add(item.getKey() + " (" + item.getValue() + ")");
}
setItems(list);
}
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class RemoveStorageQosModel method handleSetMessageQueryResult.
protected void handleSetMessageQueryResult(FrontendMultipleQueryAsyncResult result) {
setHelpTag(getRemoveQosHelpTag());
setHashName(getRemoveQosHashName());
int index = 0;
int numberOfTimesUsedByDiskProfiles = 0;
ArrayList<String> list = new ArrayList<>();
for (QueryReturnValue returnValue : result.getReturnValues()) {
List<Nameable> diskProfileEntities = returnValue.getReturnValue();
String qosName = sourceListModel.getSelectedItems().get(index).getName();
if (diskProfileEntities.size() == 0) {
list.add(qosName);
} else {
numberOfTimesUsedByDiskProfiles += diskProfileEntities.size();
List<String> diskProfileNames = new ArrayList<>();
for (Nameable diskProfileEntity : diskProfileEntities) {
String diskProfileName = diskProfileEntity.getName();
diskProfileNames.add(diskProfileName);
}
// $NON-NLS-1$
String diskProfileNamesAsString = String.join(", ", diskProfileNames);
list.add(ConstantsManager.getInstance().getMessages().removeStorageQoSItem(qosName, diskProfileNamesAsString));
}
index++;
}
setMessage(getRemoveQosMessage(numberOfTimesUsedByDiskProfiles));
setItems(list);
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class RemoveNetworkQoSModel method setMessage.
private void setMessage() {
ArrayList<QueryParametersBase> parameters = new ArrayList<>();
ArrayList<QueryType> queryTypes = new ArrayList<>();
for (Object networkQoS : sourceListModel.getSelectedItems()) {
QueryParametersBase parameter = new IdQueryParameters(((NetworkQoS) networkQoS).getId());
parameters.add(parameter);
queryTypes.add(QueryType.GetVnicProfilesByNetworkQosId);
}
Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> {
ArrayList<VnicProfileView> vnicProfiles = new ArrayList<>();
setHelpTag(HelpTag.remove_network_qos);
// $NON-NLS-1$
setHashName("remove_network_qos");
for (QueryReturnValue returnValue : result.getReturnValues()) {
vnicProfiles.addAll((ArrayList<VnicProfileView>) returnValue.getReturnValue());
}
if (vnicProfiles.isEmpty()) {
ArrayList<String> list = new ArrayList<>();
for (Object item : sourceListModel.getSelectedItems()) {
NetworkQoS i = (NetworkQoS) item;
list.add(i.getName());
}
setItems(list);
} else {
setMessage(ConstantsManager.getInstance().getMessages().removeNetworkQoSMessage(vnicProfiles.size()));
ArrayList<String> list = new ArrayList<>();
for (VnicProfileView item : vnicProfiles) {
list.add(item.getName());
}
setItems(list);
}
});
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class ImportVmFromExternalProviderModel method initQuotaForStorageDomains.
private void initQuotaForStorageDomains() {
List<QueryType> queryTypeList = new ArrayList<>();
List<QueryParametersBase> queryParamsList = new ArrayList<>();
for (StorageDomain storage : getStorage().getItems()) {
queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
queryParamsList.add(new IdQueryParameters(storage.getId()));
}
storageQuotaMap = new HashMap<>();
Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
Iterator<QueryReturnValue> returnValuesIter = result.getReturnValues().iterator();
Iterator<StorageDomain> domainsIter = getStorage().getItems().iterator();
boolean noQuota = true;
while (domainsIter.hasNext()) {
ArrayList<Quota> quotaList = returnValuesIter.next().getReturnValue();
noQuota = noQuota && quotaList.isEmpty();
storageQuotaMap.put(domainsIter.next().getId(), quotaList);
}
if (noQuota && QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(storagePool.getQuotaEnforcementType())) {
showCloseMessage(ConstantsManager.getInstance().getConstants().missingQuotaStorageEnforceMode());
}
initDisksStorageDomainsList();
});
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class ImportVmsModel method loadVmsFromExportDomain.
public void loadVmsFromExportDomain() {
clearProblem();
startProgress();
Frontend.getInstance().runQuery(QueryType.GetVmsFromExportDomain, new GetAllFromExportDomainQueryParameters(getDataCenters().getSelectedItem().getId(), exportDomain.getEntity().getId()), new AsyncQuery<QueryReturnValue>(returnValue -> updateVms(returnValue.<List<VM>>getReturnValue())));
}
Aggregations