From 670a8824534b21108107f07dd9365fa53f2e88cd Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 22 Jun 2015 15:22:50 +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@115465 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../datamodel/BasicUsageRecord.java | 12 +++++----- .../accounting/datamodel/RawUsageRecord.java | 24 ++++++++++++++++--- .../accounting/datamodel/UsageRecord.java | 14 ----------- .../accounting/persistence/Persistence.java | 1 - .../ServiceUsageRecordTest.java | 3 +-- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java index 965ad5f..7062e35 100644 --- a/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java @@ -46,8 +46,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable { @RequiredField @NotEmpty public static final String ID = "id"; - @RequiredField @NotEmpty - public static final String CREATOR_ID = "creatorId"; + @RequiredField @NotEmpty public static final String CONSUMER_ID = "consumerId"; @RequiredField @ValidLong @@ -159,21 +158,22 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable { setResourceProperty(ID, id); } - /** + /* * * {@inheritDoc} - */ + * / @Override public String getCreatorId() { return (String) this.resourceProperties.get(CREATOR_ID); } - /** + /* * * {@inheritDoc} - */ + * / @Override public void setCreatorId(String creatorId) throws InvalidValueException { setResourceProperty(CREATOR_ID, creatorId); } + */ /** * {@inheritDoc} diff --git a/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java index c93fe76..aa90902 100644 --- a/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java @@ -21,7 +21,6 @@ import org.gcube.accounting.datamodel.implementations.PortletUsageRecord; import org.gcube.accounting.datamodel.implementations.ServiceUsageRecord; import org.gcube.accounting.datamodel.implementations.StorageUsageRecord; import org.gcube.accounting.datamodel.implementations.TaskUsageRecord; -import org.gcube.accounting.datamodel.validations.annotations.NotEmpty; import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull; import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator; import org.gcube.accounting.exception.InvalidValueException; @@ -41,9 +40,11 @@ public class RawUsageRecord extends BasicUsageRecord { private static final long serialVersionUID = 1203390363640634895L; private static Logger logger = LoggerFactory.getLogger(RawUsageRecord.class); + + @DeprecatedWarning @NotEmptyIfNotNull + public static final String CREATOR_ID = "creatorId"; - - @DeprecatedWarning @NotEmpty + @DeprecatedWarning @NotEmptyIfNotNull protected static final String RESOURCE_OWNER = "resourceOwner"; @DeprecatedWarning @MoveToCreationTime @@ -148,6 +149,23 @@ public class RawUsageRecord extends BasicUsageRecord { super(properties); } + /** + * Return the identity of the entity creating this {#UsageRecord} + * @return Creator ID + */ + public String getCreatorId() { + return (String) this.resourceProperties.get(CREATOR_ID); + } + + /** + * Set the identity of the entity creating this {#UsageRecord} + * @param creatorId Creator ID + * @throws InvalidValueException + */ + public void setCreatorId(String creatorId) throws InvalidValueException { + setResourceProperty(CREATOR_ID, creatorId); + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/gcube/accounting/datamodel/UsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/UsageRecord.java index 27aa091..c708afc 100644 --- a/src/main/java/org/gcube/accounting/datamodel/UsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/UsageRecord.java @@ -25,20 +25,6 @@ public interface UsageRecord extends Comparable{ */ public void setId(String id) throws InvalidValueException; - /** - * Return the identity of the entity creating this {#UsageRecord} - * @return Creator ID - */ - public String getCreatorId(); - - /** - * Set the identity of the entity creating this {#UsageRecord} - * @param creatorId Creator ID - * @throws InvalidValueException - */ - public void setCreatorId(String creatorId) throws InvalidValueException; - - /** * Return the identity of the entity that consumed the resource * @return Consumer ID diff --git a/src/main/java/org/gcube/accounting/persistence/Persistence.java b/src/main/java/org/gcube/accounting/persistence/Persistence.java index 43f6d1c..2a2d47b 100644 --- a/src/main/java/org/gcube/accounting/persistence/Persistence.java +++ b/src/main/java/org/gcube/accounting/persistence/Persistence.java @@ -83,7 +83,6 @@ public abstract class Persistence { public static UsageRecord createTestUsageRecord(){ ServiceUsageRecord serviceUsageRecord = new ServiceUsageRecord(); try { - serviceUsageRecord.setCreatorId("accounting"); serviceUsageRecord.setConsumerId("accounting"); serviceUsageRecord.setResourceScope("/gcube/devsec"); diff --git a/src/test/java/org/gcube/accounting/datamodel/implementation/ServiceUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/implementation/ServiceUsageRecordTest.java index 8bad572..e2aa3dd 100644 --- a/src/test/java/org/gcube/accounting/datamodel/implementation/ServiceUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/implementation/ServiceUsageRecordTest.java @@ -20,8 +20,7 @@ public class ServiceUsageRecordTest { Persistence persistence = Persistence.getInstance(); ServiceUsageRecord serviceUsageRecord = new ServiceUsageRecord(); - serviceUsageRecord.setCreatorId("luca.frosini"); - serviceUsageRecord.setConsumerId("accounting"); + serviceUsageRecord.setConsumerId("luca.frosini"); serviceUsageRecord.setResourceScope("/gcube/devsec"); serviceUsageRecord.setServiceClass("Accounting"); serviceUsageRecord.setServiceName("Accounting-Lib");