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
This commit is contained in:
Luca Frosini 2015-06-22 15:22:50 +00:00
parent f1a83888aa
commit 670a882453
5 changed files with 28 additions and 26 deletions

View File

@ -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
@ -174,6 +173,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
public void setCreatorId(String creatorId) throws InvalidValueException {
setResourceProperty(CREATOR_ID, creatorId);
}
*/
/**
* {@inheritDoc}

View File

@ -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;
@ -42,8 +41,10 @@ public class RawUsageRecord extends BasicUsageRecord {
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}
*/

View File

@ -25,20 +25,6 @@ public interface UsageRecord extends Comparable<UsageRecord>{
*/
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

View File

@ -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");

View File

@ -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");