public QuotaStorage(QuotaStorage quotaStorage) { this.quotaStorageId = quotaStorage.getQuotaStorageId(); this.quotaId = quotaStorage.getQuotaId(); this.storageId = quotaStorage.getStorageId(); this.setStorageSizeGB(quotaStorage.getStorageSizeGB()); this.storageLimitGigaByteUsage = quotaStorage.getStorageSizeGBUsage(); }
public void editQuotaStorage(QuotaStorage object) { this.quotaStorage = object; getEditQuotaStorageCommand().execute(); EditQuotaStorageModel model = new EditQuotaStorageModel(); model.setTitle(ConstantsManager.getInstance().getConstants().defineStorageQuotaOnDataCenterTitle()); model.setEntity(object); if (object.getStorageSizeGB() == null || object.getStorageSizeGB().equals(QuotaStorage.UNLIMITED)) { model.getUnlimitedStorage().setEntity(true); } else { model.getSpecificStorage().setEntity(true); model.getSpecificStorageValue().setEntity(object.getStorageSizeGB()); } setWindow(model); UICommand command = UICommand.createDefaultOkUiCommand("OnEditStorageQuota", this); //$NON-NLS-1$ model.getCommands().add(command); model.getCommands().add(UICommand.createCancelUiCommand("Cancel", this)); //$NON-NLS-1$ }
private static void map(QuotaStorageLimit model, QuotaStorage quotaStorage, String storageDomainId, String dataCenterId, String quotaId) { model.setQuota(new Quota()); model.getQuota().setId(quotaId); model.getQuota().setDataCenter(new DataCenter()); model.getQuota().getDataCenter().setId(dataCenterId); if (storageDomainId != null) { model.setStorageDomain(new StorageDomain()); model.getStorageDomain().setId(storageDomainId); } if (quotaStorage.getStorageSizeGB() != null) { model.setLimit(quotaStorage.getStorageSizeGB()); } if (quotaStorage.getStorageSizeGBUsage() != null) { model.setUsage(quotaStorage.getStorageSizeGBUsage()); } }
private boolean hasUnlimitedSpecificQuota() { QuotaModel model = (QuotaModel) getWindow(); if (model.getSpecificClusterQuota().getEntity()) { for (QuotaCluster quotaCluster : model.getAllDataCenterClusters().getItems()) { if (QuotaCluster.UNLIMITED_MEM.equals(quotaCluster.getMemSizeMB()) || QuotaCluster.UNLIMITED_VCPU.equals(quotaCluster.getVirtualCpu())) { return true; } } } if (model.getSpecificStorageQuota().getEntity()) { for (QuotaStorage quotaStorage : model.getAllDataCenterStorages().getItems()) { if (QuotaStorage.UNLIMITED.equals(quotaStorage.getStorageSizeGB())) { return true; } } } return false; }
storage.setStorageSizeGB(quota.getGlobalQuotaStorage().getStorageSizeGB()); storage.setStorageSizeGBUsage(quota.getGlobalQuotaStorage().getStorageSizeGBUsage()); qModel.getGlobalStorageQuota().setEntity(true); if (quotaStorage.getStorageId().equals(iter.getStorageId())) { quotaStorage.setQuotaStorageId(iter.getQuotaStorageId()); quotaStorage.setStorageSizeGB(iter.getStorageSizeGB()); quotaStorage.setStorageSizeGBUsage(iter.getStorageSizeGBUsage()); containStorage = true;
/** * Build quota storage parameter map, for quota limitation table, to indicate specific limitation on storage domain. * * @param quotaId * - The global quota id which the storage is referencing to * @param quotaStorage * - The business entity which reflects the limitation on the specific storage. * @return - Parameter Map */ private MapSqlParameterSource getQuotaStorageParameterMap(Guid quotaId, QuotaStorage quotaStorage) { return createQuotaIdParameterMapper(quotaStorage.getQuotaStorageId()).addValue("quota_id", quotaId) .addValue("storage_id", quotaStorage.getStorageId()) .addValue("cluster_id", null) .addValue("storage_size_gb", quotaStorage.getStorageSizeGB()) .addValue("virtual_cpu", null) .addValue("mem_size_mb", null); }
/** * Make Quota specific to be the same as Quota general and specific. */ @Test public void testUpdateQuota() { Quota quotaGeneralToSpecific = dao.getById(FixturesTool.QUOTA_GENERAL); // Save quotaName and cluster list for future check. String quotaName = "New Temporary name"; List<QuotaCluster> quotaClusterList = getQuotaCluster(getSpecificQuotaCluster(quotaGeneralToSpecific.getId())); Long newStorageLimit = 2345L; // Check before the update, that the fields are not equal. assertNotEquals(quotaName, quotaGeneralToSpecific.getQuotaName()); assertNotEquals(quotaClusterList.size(), quotaGeneralToSpecific.getQuotaClusters().size()); assertNotEquals(newStorageLimit, quotaGeneralToSpecific.getGlobalQuotaStorage().getStorageSizeGB()); // Update quotaGeneralToSpecific.setQuotaName(quotaName); quotaGeneralToSpecific.getGlobalQuotaStorage().setStorageSizeGB(newStorageLimit); quotaGeneralToSpecific.setQuotaClusters(quotaClusterList); dao.update(quotaGeneralToSpecific); quotaGeneralToSpecific = dao.getById(FixturesTool.QUOTA_GENERAL); // Check after the update, that the fields are equal now. assertEquals(quotaName, quotaGeneralToSpecific.getQuotaName()); assertEquals(quotaClusterList.size(), quotaGeneralToSpecific.getQuotaClusters().size()); assertEquals(newStorageLimit, quotaGeneralToSpecific.getGlobalQuotaStorage().getStorageSizeGB()); }
/** * Build parameter map, for quota limitation table, to indicate global limitation on {@code StoragePool}. * * @param quota * - The global quota. * @return - Global quota Parameter Map. */ private MapSqlParameterSource getFullQuotaParameterMap(Quota quota) { return getCustomMapSqlParameterSource() .addValue("id", quota.getId()) .addValue("quota_id", quota.getId()) .addValue("cluster_id", null) .addValue("storage_id", null) .addValue("storage_size_gb", quota.getGlobalQuotaStorage() != null ? quota.getGlobalQuotaStorage() .getStorageSizeGB() : null) .addValue("virtual_cpu", quota.getGlobalQuotaCluster() != null ? quota.getGlobalQuotaCluster().getVirtualCpu() : null) .addValue("mem_size_mb", quota.getGlobalQuotaCluster() != null ? quota.getGlobalQuotaCluster().getMemSizeMB() : null); }
for (QuotaStorage iter : model.getQuotaStorages().getItems()) { quota.setGlobalQuotaStorage(new QuotaStorage()); quota.getGlobalQuotaStorage().setStorageSizeGB(iter.getStorageSizeGB()); quota.getQuotaStorages().clear(); for (QuotaStorage iter : model.getAllDataCenterStorages().getItems()) { quotaStorage = iter; if (quotaStorage.getStorageSizeGB() != null) { quotaStorageList.add(quotaStorage);
private boolean validateNotEmpty() { getSpecificClusterQuota().setIsValid(true); getSpecificStorageQuota().setIsValid(true); if (getGlobalClusterQuota().getEntity() || getGlobalStorageQuota().getEntity()) { return true; } if (getAllDataCenterClusters().getItems() != null) { for (QuotaCluster quotaCluster : getAllDataCenterClusters().getItems()) { if (quotaCluster.getMemSizeMB() != null) { return true; } } } if (getAllDataCenterStorages().getItems() != null) { for (QuotaStorage quotaStorage : getAllDataCenterStorages().getItems()) { if (quotaStorage.getStorageSizeGB() != null) { return true; } } } getSpecificClusterQuota().validateEntity(new IValidation[] { quotaEmptyValidation }); getSpecificStorageQuota().validateEntity(new IValidation[] { quotaEmptyValidation }); return false; }