From 372b5a2e5de9bfa0a1dd753bd8ed835a1a896292 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 14 Apr 2021 01:07:20 +0200 Subject: [PATCH] Deprecated not needed properties to reduce data and improve aggregation --- CHANGELOG.md | 5 +++ pom.xml | 2 +- .../AbstractStorageStatusRecord.java | 9 ++--- .../basetypes/AbstractStorageUsageRecord.java | 12 +----- .../AggregatedStorageStatusRecordTest.java | 37 ++++++++++++------- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 847f6c2..bc96ff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for Accounting Library +## [v4.1.0-SNAPSHOT] + +- Deprecated not needed properties to reduce data and improve aggregation +- Improved regex to comply with new version of Thredds called methods [#18053] + ## [v4.0.0] [r.5.0.0] - diff --git a/pom.xml b/pom.xml index d4a892e..a7e8849 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.accounting accounting-lib - 4.0.0 + 4.1.0-SNAPSHOT Accounting Library Accounting Library diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java index 887ba70..8b96874 100644 --- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java @@ -123,8 +123,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord { @Deprecated public void setDataServiceClass(String dataServiceClass) throws InvalidValueException { - setResourceProperty(DATA_SERVICECLASS, AbstractStorageUsageRecord.NOT_NEEDED); - // setResourceProperty(DATA_SERVICECLASS, dataServiceClass); + setResourceProperty(DATA_SERVICECLASS, dataServiceClass); } @Deprecated @@ -135,8 +134,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord { @Deprecated public void setDataServiceName(String dataServiceName) throws InvalidValueException { - setResourceProperty(DATA_SERVICENAME, AbstractStorageUsageRecord.NOT_NEEDED); - // setResourceProperty(DATA_SERVICENAME, dataServiceName); + setResourceProperty(DATA_SERVICENAME, dataServiceName); } @Deprecated @@ -147,8 +145,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord { @Deprecated public void setDataServiceId(String dataServiceId) throws InvalidValueException { - setResourceProperty(DATA_SERVICEID, AbstractStorageUsageRecord.NOT_NEEDED); - // setResourceProperty(DATA_SERVICEID, dataServiceId); + setResourceProperty(DATA_SERVICEID, dataServiceId); } @JsonIgnore diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java index be24635..b05ba52 100644 --- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java @@ -24,8 +24,6 @@ import org.gcube.documentstore.records.implementation.validations.annotations.Va */ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord { - protected static final String NOT_NEEDED = "NOT_NEEDED"; - /** * Generated Serial Version UID */ @@ -143,8 +141,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord { */ @Deprecated public void setResourceScope(String scope) throws InvalidValueException { - setResourceProperty(RESOURCE_SCOPE, NOT_NEEDED); - // setResourceProperty(RESOURCE_SCOPE, scope); + setResourceProperty(RESOURCE_SCOPE, scope); } @JsonIgnore @@ -164,12 +161,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord { @Deprecated public void setResourceURI(URI resourceURI) throws InvalidValueException { - try { - setResourceProperty(RESOURCE_URI, new URI(NOT_NEEDED)); - }catch (Exception e) { - setResourceProperty(RESOURCE_URI, NOT_NEEDED); - } - // setResourceProperty(RESOURCE_URI, resourceURI); + setResourceProperty(RESOURCE_URI, resourceURI); } @JsonIgnore diff --git a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageStatusRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageStatusRecordTest.java index 113f645..bae6d05 100644 --- a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageStatusRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageStatusRecordTest.java @@ -54,30 +54,30 @@ public class AggregatedStorageStatusRecordTest extends ContextTest { public void secondAsNotAggregated() throws InvalidValueException, NotAggregatableRecordsExceptions { SecurityTokenProvider.instance.reset(); ScopeProvider.instance.reset(); - StorageStatusRecord storageVolumeUsageRecord = TestUsageRecord.createTestStorageVolumeUsageRecord(); - Assert.assertTrue(storageVolumeUsageRecord.getScope()==null); - storageVolumeUsageRecord.setScope(TestUsageRecord.TEST_SCOPE); + StorageStatusRecord storageStatusUsageRecord = TestUsageRecord.createTestStorageVolumeUsageRecord(); + Assert.assertTrue(storageStatusUsageRecord.getScope()==null); + storageStatusUsageRecord.setScope(TestUsageRecord.TEST_SCOPE); - storageVolumeUsageRecord.setResourceProperty(TestUsageRecord.TEST_PROPERTY_NAME, TestUsageRecord.TEST_PROPERTY_VALUE); - storageVolumeUsageRecord.validate(); - logger.debug("StorageVolumeUsageRecord : {}", storageVolumeUsageRecord); + storageStatusUsageRecord.setResourceProperty(TestUsageRecord.TEST_PROPERTY_NAME, TestUsageRecord.TEST_PROPERTY_VALUE); + storageStatusUsageRecord.validate(); + logger.debug("StorageVolumeUsageRecord : {}", storageStatusUsageRecord); - AggregatedStorageStatusRecord aggregated = new AggregatedStorageStatusRecord(storageVolumeUsageRecord); + AggregatedStorageStatusRecord aggregated = new AggregatedStorageStatusRecord(storageStatusUsageRecord); logger.debug("StorageVolumeUsageRecord Converted to Aggregated: {}", aggregated); aggregated.validate(); - StorageStatusRecord storageVolumeUsageRecord2 = TestUsageRecord.createTestStorageVolumeUsageRecord(); - storageVolumeUsageRecord2.setScope(TestUsageRecord.TEST_SCOPE); + StorageStatusRecord storageStatusUsageRecord2 = TestUsageRecord.createTestStorageVolumeUsageRecord(); + storageStatusUsageRecord2.setScope(TestUsageRecord.TEST_SCOPE); - storageVolumeUsageRecord2.validate(); - logger.debug("StorageVolumeUsageRecord 2 : {}", storageVolumeUsageRecord2); + storageStatusUsageRecord2.validate(); + logger.debug("StorageVolumeUsageRecord 2 : {}", storageStatusUsageRecord2); - long secondDataVolume = storageVolumeUsageRecord2.getDataVolume(); + long secondDataVolume = storageStatusUsageRecord2.getDataVolume(); - long secondDataCount = storageVolumeUsageRecord2.getDataCount(); + long secondDataCount = storageStatusUsageRecord2.getDataCount(); - aggregated.aggregate(storageVolumeUsageRecord2); + aggregated.aggregate(storageStatusUsageRecord2); logger.debug("Resulting Aggregated StorageVolumeUsageRecord: {}", aggregated); aggregated.validate(); @@ -87,11 +87,16 @@ public class AggregatedStorageStatusRecordTest extends ContextTest { Assert.assertFalse(aggregated.getResourceProperties().containsKey(TestUsageRecord.TEST_PROPERTY_NAME)); } + @SuppressWarnings("deprecation") @Test public void secondAsAggregated() throws InvalidValueException, NotAggregatableRecordsExceptions { SecurityTokenProvider.instance.reset(); ScopeProvider.instance.reset(); StorageStatusRecord storageStatusUsageRecord = TestUsageRecord.createTestStorageVolumeUsageRecord(); + storageStatusUsageRecord.setDataServiceClass("DataServiceClass1"); + storageStatusUsageRecord.setDataServiceName("DataServiceName1"); + storageStatusUsageRecord.setDataServiceId("DataServiceId1"); + Assert.assertTrue(storageStatusUsageRecord.getScope()==null); storageStatusUsageRecord.setScope(TestUsageRecord.TEST_SCOPE); storageStatusUsageRecord.validate(); @@ -102,6 +107,10 @@ public class AggregatedStorageStatusRecordTest extends ContextTest { aggregated.validate(); StorageStatusRecord storageVolumeUsageRecord2 = TestUsageRecord.createTestStorageVolumeUsageRecord(); + storageVolumeUsageRecord2.setDataServiceClass("DataServiceClass2"); + storageVolumeUsageRecord2.setDataServiceName("DataServiceName2"); + storageVolumeUsageRecord2.setDataServiceId("DataServiceId2"); + Assert.assertTrue(storageVolumeUsageRecord2.getScope()==null); storageVolumeUsageRecord2.setScope(TestUsageRecord.TEST_SCOPE); storageVolumeUsageRecord2.setResourceProperty(TestUsageRecord.TEST_PROPERTY_NAME, TestUsageRecord.TEST_PROPERTY_VALUE);