use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class UpdateQuotaCommandTest method setUpQuota.
private Quota setUpQuota(Guid guid) {
Quota quota = new Quota();
quota.setId(guid);
int numQutoaClusters = RandomUtils.instance().nextInt(10);
List<QuotaCluster> quotaClusters = new ArrayList<>(numQutoaClusters);
for (int i = 0; i < numQutoaClusters; ++i) {
quotaClusters.add(new QuotaCluster());
}
quota.setQuotaClusters(quotaClusters);
int numQutoaStorages = RandomUtils.instance().nextInt(10);
List<QuotaStorage> quotaStorages = new ArrayList<>(numQutoaStorages);
for (int i = 0; i < numQutoaClusters; ++i) {
quotaStorages.add(new QuotaStorage());
}
quota.setQuotaStorages(quotaStorages);
return quota;
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class GetQuotaStorageByQuotaIdQueryTest method testExecuteQueryCommand.
@Test
public void testExecuteQueryCommand() {
// Mock the parameters
Guid quotaId = Guid.newGuid();
when(params.getId()).thenReturn(quotaId);
// Create the return value
QuotaStorage group = new QuotaStorage();
group.setQuotaId(quotaId);
// Mock the Dao
when(quotaDao.getQuotaStorageByQuotaGuidWithGeneralDefault(quotaId)).thenReturn(Collections.singletonList(group));
// Execute the query
getQuery().executeQueryCommand();
// Assert the result
@SuppressWarnings("unchecked") List<QuotaStorage> results = getQuery().getQueryReturnValue().getReturnValue();
assertEquals("Wrong number of results returned", 1, results.size());
assertEquals("Wrong results returned", group, results.get(0));
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaCRUDCommand method setQuotaStorage.
private void setQuotaStorage(Quota quota) {
// Create unlimited global storage quota if no other is specified
if (quota.isEmptyStorageQuota()) {
quota.setGlobalQuotaStorage(new QuotaStorage(Guid.newGuid(), quota.getId(), null, -1L, 0.0));
return;
}
if (quota.isGlobalStorageQuota()) {
quota.getGlobalQuotaStorage().setQuotaId(quota.getId());
quota.getGlobalQuotaStorage().setQuotaStorageId(Guid.newGuid());
return;
}
for (QuotaStorage quotaStorage : quota.getQuotaStorages()) {
quotaStorage.setQuotaId(quota.getId());
quotaStorage.setQuotaStorageId(Guid.newGuid());
}
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaManagerTest method getQuotaStorage.
private QuotaStorage getQuotaStorage(long storageSize, double storageSizeUsed) {
QuotaStorage storageQuota = new QuotaStorage();
storageQuota.setStorageSizeGB(storageSize);
storageQuota.setStorageSizeGBUsage(storageSizeUsed);
storageQuota.setStorageId(DESTINATION_GUID);
return storageQuota;
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaPopupView method initQuotaStorageTable.
private void initQuotaStorageTable() {
quotaStorageTable = new ListModelObjectCellTable<>();
storageQuotaTableContainer.add(quotaStorageTable);
isStorageInQuotaColumn = new Column<QuotaStorage, Boolean>(new CheckboxCell(true, true)) {
@Override
public Boolean getValue(QuotaStorage object) {
if (selectedStorageGuid.contains(object.getStorageId()) || object.getStorageSizeGB() != null) {
if (!selectedStorageGuid.contains(object.getStorageId())) {
selectedStorageGuid.add(object.getStorageId());
}
return true;
}
return false;
}
};
isStorageInQuotaColumn.setFieldUpdater((index, object, value) -> {
if (value) {
selectedStorageGuid.add(object.getStorageId());
object.setStorageSizeGB(QuotaStorage.UNLIMITED);
} else {
selectedStorageGuid.remove(object.getStorageId());
object.setStorageSizeGB(null);
}
if (model.getGlobalStorageQuota().getEntity()) {
quotaStorageTable.asEditor().edit(model.getQuotaStorages());
} else {
quotaStorageTable.asEditor().edit(model.getAllDataCenterStorages());
}
});
quotaStorageTable.addColumn(new AbstractTextColumn<QuotaStorage>() {
@Override
public String getValue(QuotaStorage object) {
if (object.getStorageName() == null || object.getStorageName().length() == 0) {
return constants.utlQuotaAllStoragesQuotaPopup();
}
return object.getStorageName();
}
}, constants.storageNameQuota(), // $NON-NLS-1$
"200px");
// $NON-NLS-1$
quotaStorageTable.addColumn(new QuotaUtilizationStatusColumn<QuotaStorage>(), constants.empty(), "1px");
quotaStorageTable.addColumn(new AbstractTextColumn<QuotaStorage>() {
@Override
public String getValue(QuotaStorage object) {
if (object.getStorageSizeGB() == null) {
// $NON-NLS-1$
return "";
} else if (object.getStorageSizeGB().equals(QuotaStorage.UNLIMITED)) {
return messages.unlimitedStorageConsumption(object.getStorageSizeGBUsage() == 0 ? // $NON-NLS-1$
"0" : diskSizeRenderer.render(object.getStorageSizeGBUsage()));
} else {
return messages.limitedStorageConsumption(object.getStorageSizeGBUsage() == 0 ? // $NON-NLS-1$
"0" : diskSizeRenderer.render(object.getStorageSizeGBUsage()), object.getStorageSizeGB());
}
}
}, constants.quota());
Column<QuotaStorage, String> editColumn = new Column<QuotaStorage, String>(new NullableButtonCell()) {
@Override
public String getValue(QuotaStorage object) {
if (model.getGlobalStorageQuota().getEntity() || (model.getSpecificStorageQuota().getEntity() && selectedStorageGuid.contains(object.getStorageId()))) {
return constants.editCellQuota();
}
return null;
}
};
editColumn.setFieldUpdater((index, object, value) -> model.editQuotaStorage(object));
// $NON-NLS-1$
quotaStorageTable.addColumn(editColumn, constants.empty(), "50px");
}
Aggregations