From 73c7b931116cd11d52ed09f3adffd38b7346ffd7 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 25 Jun 2015 14:32:14 +0000 Subject: [PATCH] refs #200: Create accouting-lib library https://support.d4science.org/issues/200 Fixing model git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115552 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gcube/accounting/datamodel/AggregatedUsageRecord.java | 3 +-- .../org/gcube/accounting/datamodel/AggregationStrategy.java | 5 ++--- .../accounting/datamodel/persistence/PersistenceTest.java | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java index 322d3a3..a6a497b 100644 --- a/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java @@ -8,8 +8,7 @@ import org.gcube.accounting.exception.InvalidValueException; /** * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ */ -public interface AggregatedUsageRecord, B extends SingleUsageRecord> extends SingleUsageRecord { - +public interface AggregatedUsageRecord, B extends SingleUsageRecord> { public T getAggregatedUsageRecord(B usageRecord) throws InvalidValueException ; diff --git a/src/main/java/org/gcube/accounting/datamodel/AggregationStrategy.java b/src/main/java/org/gcube/accounting/datamodel/AggregationStrategy.java index 57c941e..18acc01 100644 --- a/src/main/java/org/gcube/accounting/datamodel/AggregationStrategy.java +++ b/src/main/java/org/gcube/accounting/datamodel/AggregationStrategy.java @@ -52,9 +52,8 @@ public abstract class AggregationStrategy, protected boolean isAggregable(UsageRecord record) { for(String field : aggregationField){ Serializable recordValue = record.getResourceProperty(field); - Serializable thisValue = t.getResourceProperty(field); + Serializable thisValue = ((BasicUsageRecord) t).getResourceProperty(field); - // TODO Check THIS if(!recordValue.equals(thisValue)){ return false; } @@ -89,7 +88,7 @@ public abstract class AggregationStrategy, Calendar newCreationTime = Calendar.getInstance(); t = reallyAggregate(convertedRecord); - t.setCreationTime(newCreationTime); + ((BasicUsageRecord) t).setCreationTime(newCreationTime); return t; }catch(NotAggregatableRecordsExceptions e){ diff --git a/src/test/java/org/gcube/accounting/datamodel/persistence/PersistenceTest.java b/src/test/java/org/gcube/accounting/datamodel/persistence/PersistenceTest.java index c88780e..078c126 100644 --- a/src/test/java/org/gcube/accounting/datamodel/persistence/PersistenceTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/persistence/PersistenceTest.java @@ -25,15 +25,12 @@ public class PersistenceTest { public void test() throws Exception { Persistence.setFallbackLocation(System.getProperty("user.home")); Persistence.getInstance(); - //Persistence persistence = Persistence.getInstance(); - //persistence.connect(); } @Test public void stressTest() throws Exception { Persistence.setFallbackLocation(System.getProperty("user.home")); Persistence persistence = Persistence.getInstance(); - //persistence.connect(); int quantity = 3000; Calendar startTestTime = new GregorianCalendar(); for(int i=0; i< quantity; i++){