From 3661f051dbd1e4951432a9539cf78849edd306ee Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 9 Jun 2015 09:03:43 +0000 Subject: [PATCH] refs #200: Create accouting-lib library https://support.d4science.org/issues/200 Implementing library git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115258 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gcube/accounting/datamodel/RawUsageRecord.java | 8 ++++---- .../datamodel/implementations/JobUsageRecord.java | 12 +++++++++++- .../implementations/PortletUsageRecord.java | 13 ++++++++++++- .../implementations/ServiceUsageRecord.java | 12 +++++++++++- .../implementations/StorageUsageUsageRecord.java | 14 ++++++++++++-- .../datamodel/implementations/TaskUsageRecord.java | 11 ++++++++++- .../accounting/messaging/ResourceAccounting.java | 2 +- 7 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java index d0dae81..1132a24 100644 --- a/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java @@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory; * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ * */ -public abstract class RawUsageRecord implements UsageRecord, Serializable { +public abstract class RawUsageRecord implements UsageRecord, Serializable { private static Logger logger = LoggerFactory.getLogger(RawUsageRecord.class); @@ -490,7 +490,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable { return 1; } - public static List aggregate(List records){ + protected List aggregate(List records){ // TODO implements throw new UnsupportedOperationException(); } @@ -506,8 +506,8 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable { * @throws Exception if fails */ public static UsageRecord getUsageRecord(Map usageRecordMap) throws Exception { - // TODO Auto-generated method stub - return null; + // TODO implements + throw new UnsupportedOperationException(); } } diff --git a/src/main/java/org/gcube/accounting/datamodel/implementations/JobUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/implementations/JobUsageRecord.java index 5da2758..fc20041 100644 --- a/src/main/java/org/gcube/accounting/datamodel/implementations/JobUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/implementations/JobUsageRecord.java @@ -4,6 +4,7 @@ package org.gcube.accounting.datamodel.implementations; import java.util.Calendar; +import java.util.List; import org.gcube.accounting.datamodel.RawUsageRecord; import org.gcube.accounting.datamodel.SingleUsageRecord; @@ -19,7 +20,7 @@ import org.gcube.accounting.exception.InvalidValueException; * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ * */ -public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord { +public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord { /** * Generated Serial Version UID @@ -142,4 +143,13 @@ public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord return wallDuration; } + /** + * {@inheritDoc} + */ + @Override + public List aggregate(List records) { + // TODO implements + throw new UnsupportedOperationException(); + } + } diff --git a/src/main/java/org/gcube/accounting/datamodel/implementations/PortletUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/implementations/PortletUsageRecord.java index a5547e3..cd95a4b 100644 --- a/src/main/java/org/gcube/accounting/datamodel/implementations/PortletUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/implementations/PortletUsageRecord.java @@ -3,6 +3,8 @@ */ package org.gcube.accounting.datamodel.implementations; +import java.util.List; + import org.gcube.accounting.datamodel.RawUsageRecord; import org.gcube.accounting.datamodel.SingleUsageRecord; import org.gcube.accounting.datamodel.decorators.RequiredField; @@ -15,7 +17,7 @@ import org.gcube.accounting.exception.InvalidValueException; * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ * */ -public class PortletUsageRecord extends RawUsageRecord implements SingleUsageRecord { +public class PortletUsageRecord extends RawUsageRecord implements SingleUsageRecord { /** * Generated Serial Version UID @@ -61,4 +63,13 @@ public class PortletUsageRecord extends RawUsageRecord implements SingleUsageRec setResourceSpecificProperty(OPERATION_ID, operationId); } + /** + * {@inheritDoc} + */ + @Override + public List aggregate(List records) { + // TODO implements + throw new UnsupportedOperationException(); + } + } diff --git a/src/main/java/org/gcube/accounting/datamodel/implementations/ServiceUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/implementations/ServiceUsageRecord.java index af231ae..a650d60 100644 --- a/src/main/java/org/gcube/accounting/datamodel/implementations/ServiceUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/implementations/ServiceUsageRecord.java @@ -3,6 +3,8 @@ */ package org.gcube.accounting.datamodel.implementations; +import java.util.List; + import org.gcube.accounting.datamodel.RawUsageRecord; import org.gcube.accounting.datamodel.SingleUsageRecord; import org.gcube.accounting.datamodel.decorators.RequiredField; @@ -16,7 +18,7 @@ import org.gcube.accounting.exception.InvalidValueException; * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ * */ -public class ServiceUsageRecord extends RawUsageRecord implements SingleUsageRecord { +public class ServiceUsageRecord extends RawUsageRecord implements SingleUsageRecord { /** * Generated Serial Version UID @@ -118,4 +120,12 @@ public class ServiceUsageRecord extends RawUsageRecord implements SingleUsageRec setResourceSpecificProperty(SERVICE_NAME, serviceName); } + /** + * {@inheritDoc} + */ + @Override + public List aggregate(List records) { + // TODO implements + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/org/gcube/accounting/datamodel/implementations/StorageUsageUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/implementations/StorageUsageUsageRecord.java index 05bbfc3..80d60c2 100644 --- a/src/main/java/org/gcube/accounting/datamodel/implementations/StorageUsageUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/implementations/StorageUsageUsageRecord.java @@ -3,6 +3,8 @@ */ package org.gcube.accounting.datamodel.implementations; +import java.util.List; + import org.gcube.accounting.datamodel.RawUsageRecord; import org.gcube.accounting.datamodel.SingleUsageRecord; import org.gcube.accounting.datamodel.decorators.RequiredField; @@ -17,7 +19,7 @@ import org.gcube.accounting.exception.InvalidValueException; * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ * */ -public class StorageUsageUsageRecord extends RawUsageRecord implements SingleUsageRecord { +public class StorageUsageUsageRecord extends RawUsageRecord implements SingleUsageRecord { /** * Generated Serial Version UID @@ -124,5 +126,13 @@ public class StorageUsageUsageRecord extends RawUsageRecord implements SingleUsa public void setResourceOwner(String owner) throws InvalidValueException { setResourceSpecificProperty(RESOURCE_OWNER, owner); } - + + /** + * {@inheritDoc} + */ + @Override + public List aggregate(List records) { + // TODO implements + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/org/gcube/accounting/datamodel/implementations/TaskUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/implementations/TaskUsageRecord.java index 6427d9e..f485510 100644 --- a/src/main/java/org/gcube/accounting/datamodel/implementations/TaskUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/implementations/TaskUsageRecord.java @@ -4,6 +4,7 @@ package org.gcube.accounting.datamodel.implementations; import java.util.Calendar; +import java.util.List; import org.gcube.accounting.datamodel.RawUsageRecord; import org.gcube.accounting.datamodel.SingleUsageRecord; @@ -19,7 +20,7 @@ import org.gcube.accounting.exception.InvalidValueException; * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ * */ -public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord { +public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord { /** * Generated Serial Version UID @@ -199,4 +200,12 @@ public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord setResourceSpecificProperty(PROCESSORS, processors); } + /** + * {@inheritDoc} + */ + @Override + public List aggregate(List records) { + // TODO implements + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/org/gcube/accounting/messaging/ResourceAccounting.java b/src/main/java/org/gcube/accounting/messaging/ResourceAccounting.java index c59aa17..dc748a9 100644 --- a/src/main/java/org/gcube/accounting/messaging/ResourceAccounting.java +++ b/src/main/java/org/gcube/accounting/messaging/ResourceAccounting.java @@ -19,7 +19,7 @@ public class ResourceAccounting { } @Deprecated - public void sendAccountingMessage(RawUsageRecord message){ + public void sendAccountingMessage(@SuppressWarnings("rawtypes") RawUsageRecord message){ persistence.account(message); }