@Override public Object getQueryableId() { return getId(); }
public QuotaCRUDParameters(Quota quota) { quotaId = quota.getId(); this.quota = quota; }
/** * Comparator adapter. Quota with topId will be the first in sorted list. */ public static Comparator<Quota> withTopId(final Guid topId, final Comparator<Quota> defaultComparator) { return Comparator.comparing((Quota q) -> !q.getId().equals(topId)).thenComparing(defaultComparator); } }
@Override public ValidationResult validate(Object value) { ValidationResult result = new ValidationResult(); if (value == null || (value instanceof Quota && (((Quota)value).getId() == null || Guid.Empty.equals(((Quota)value).getId())))) { result.setSuccess(false); result.getReasons().add(ConstantsManager.getInstance().getConstants().thisFieldCantBeEmptyInvalidReason()); } return result; } }
private void saveStorageSpecificQuotas(Quota quota) { // Add quota specific storage domains limitations. for (QuotaStorage quotaStorage : quota.getQuotaStorages()) { getCallsHandler().executeModification("InsertQuotaLimitation", getQuotaStorageParameterMap(quota.getId(), quotaStorage)); } }
private void saveClusterSpecificQuotas(Quota quota) { // Add quota specific vds group limitations. for (QuotaCluster quotaCluster : quota.getQuotaClusters()) { getCallsHandler().executeModification("InsertQuotaLimitation", getQuotaClusterParameterMap(quota.getId(), quotaCluster)); } }
protected void updateDiskQuotas(List<Disk> disks) { for (Disk disk : disks) { Quota quota = getDiskQuotaMap().getEntity().get(disk.getId()); if (quota == null) { quota = getStorageQuota().getSelectedItem(); } if (quota != null) { ((DiskImage) disk).setQuotaId(quota.getId()); } } }
@Override public boolean isQuotaInUse(Quota quota){ MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("quota_id", quota.getId()); Map<String, Object> dbResults = new SimpleJdbcCall(getJdbcTemplate()).withFunctionName("IsQuotaInUse").execute( parameterSource); String resultKey = getDialect().getFunctionReturnKey(); return dbResults.get(resultKey) != null && (Boolean) dbResults.get(resultKey); }
@Override protected void syncSearch() { super.syncSearch(); IdQueryParameters params = new IdQueryParameters(getEntity().getId()); Frontend.getInstance().runQuery(QueryType.GetQuotaStorageByQuotaId, params, new SetItemsAsyncQuery()); }
@Override protected void syncSearch() { super.syncSearch(); IdQueryParameters params = new IdQueryParameters(getEntity().getId()); Frontend.getInstance().runQuery(QueryType.GetQuotaClusterByQuotaId, params, new SetItemsAsyncQuery()); }
private void updateQuota(DiskImage diskImage) { if (getQuota().getIsAvailable() && getQuota().getSelectedItem() != null) { diskImage.setQuotaId(getQuota().getSelectedItem().getId()); } }
@Override protected void build(UnitVmModel model, VmBase vm) { if (model.getQuota().getIsAvailable() && model.getQuota().getSelectedItem() != null) { vm.setQuotaId(model.getQuota().getSelectedItem().getId()); } } }
private void updateIncomingId(QuotaStorageLimit incoming, Quota entity) { if (incoming.isSetStorageDomain() && incoming.getStorageDomain().isSetId()) { incoming.setId(incoming.getStorageDomain().getId()); } else { incoming.setId(entity.getId().toString()); } }
private void updateIncomingId(QuotaClusterLimit incoming, Quota entity) { if (incoming.isSetCluster() && incoming.getCluster().isSetId()) { incoming.setId(incoming.getCluster().getId()); } else { incoming.setId(entity.getId().toString()); } }
/** * Test get Quota by Name, with name of specific Quota. */ @Test public void testGetQuotaByExistingName() { Quota quotaGeneralToSpecific = dao.getQuotaByQuotaName("Quota General", FixturesTool.STORAGE_POOL_NFS); assertEquals(dao.getById(FixturesTool.QUOTA_GENERAL) .getQuotaName(), quotaGeneralToSpecific.getQuotaName()); assertEquals(dao.getById(FixturesTool.QUOTA_GENERAL).getId(), quotaGeneralToSpecific.getId()); }
@Test public void testSpecificQuotaLimitations() { // Set new Quota definition. Quota quota = createGeneralQuota(); quota.setQuotaClusters(getQuotaCluster(getSpecificQuotaCluster(quota.getId()))); quota.setQuotaStorages(getQuotaStorage(getSpecificQuotaStorage(quota.getId()))); dao.save(quota); Quota quotaEntity = dao.getById(quota.getId()); assertNotNull(quotaEntity); assertEquals(quota, quotaEntity); }
@Override protected void syncSearch() { if (getEntity() == null) { return; } super.syncSearch(); IdQueryParameters tempVar = new IdQueryParameters(getEntity().getId()); tempVar.setRefresh(getIsQueryFirstTime()); Frontend.getInstance().runQuery(QueryType.GetTemplatesRelatedToQuotaId, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> { setItems((ArrayList<VM>) returnValue.getReturnValue()); setIsEmpty(((List) getItems()).size() == 0); })); }
@Test public void testSpecificAndGeneralQuotaLimitations() { // Set new Quota definition. Quota quota = createGeneralQuota(); quota.setQuotaClusters(getQuotaCluster(getSpecificQuotaCluster(quota.getId()))); quota.setQuotaStorages(getQuotaStorage(null)); quota.setGlobalQuotaStorage(new QuotaStorage(null, null, null, 10000L, 0d)); dao.save(quota); Quota quotaEntity = dao.getById(quota.getId()); assertNotNull(quotaEntity); assertEquals(quota, quotaEntity); }
private MapSqlParameterSource createQuotaMetaDataParameterMapper(Quota quota) { return createQuotaIdParameterMapper(quota.getId()).addValue("storage_pool_id", quota.getStoragePoolId()) .addValue("quota_name", quota.getQuotaName()) .addValue("description", quota.getDescription()) .addValue("threshold_cluster_percentage", quota.getThresholdClusterPercentage()) .addValue("threshold_storage_percentage", quota.getThresholdStoragePercentage()) .addValue("grace_cluster_percentage", quota.getGraceClusterPercentage()) .addValue("grace_storage_percentage", quota.getGraceStoragePercentage()) .addValue("is_default", quota.isDefault()); }
@Test public void testGeneralQuotaLimitations() { // Set new Quota definition. Quota quota = createGeneralQuota(); setQuotaGlobalLimitations(quota); quota.setQuotaClusters(getQuotaCluster(null)); quota.setQuotaStorages(getQuotaStorage(null)); dao.save(quota); Quota quotaEntity = dao.getById(quota.getId()); assertNotNull(quotaEntity); assertEquals(quota, quotaEntity); assertEquals("rhel6.NFS", quotaEntity.getStoragePoolName()); assertEquals(QuotaEnforcementTypeEnum.DISABLED, quotaEntity.getQuotaEnforcementType()); }