version 3.0 Insert jackson to convert model.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@148471 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7d84242b84
commit
987f94b896
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>accounting-lib-trunk_ultimo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-lib</artifactId>
|
||||
<version>2.4.1-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<name>Accounting Library</name>
|
||||
<description>Accounting Library</description>
|
||||
<packaging>jar</packaging>
|
||||
|
|
|
@ -11,9 +11,10 @@ import org.gcube.documentstore.records.implementation.validations.annotations.Va
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
|
||||
public interface AggregatedUsageRecord<A extends AggregatedUsageRecord<A,U>, U extends UsageRecord> extends AggregatedRecord<A,U> {
|
||||
|
||||
@ValidBoolean
|
||||
@ValidBoolean
|
||||
public static final String AGGREGATED = AggregatedRecord.AGGREGATED;
|
||||
|
||||
@ValidInteger
|
||||
|
|
|
@ -22,12 +22,16 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class BasicUsageRecord extends AbstractRecord implements UsageRecord {
|
||||
@JsonTypeName(value="UsageRecord")
|
||||
public class BasicUsageRecord extends AbstractRecord implements UsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -78,7 +82,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
|||
try {
|
||||
this.setScope(getScopeFromToken());
|
||||
} catch(Exception e) {
|
||||
logger.warn("Unable to automatically set the scope using scope provider. The record will not be valid if the scope will not be explicitly set.");
|
||||
logger.warn("Unable to automaticcally set the scope using scope provider. The record will not be valid if the scope will not be explicitly set.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +107,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public String getConsumerId() {
|
||||
return (String) this.resourceProperties.get(CONSUMER_ID);
|
||||
|
@ -111,15 +116,26 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setConsumerId(String consumerId) throws InvalidValueException {
|
||||
setResourceProperty(CONSUMER_ID, consumerId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
protected String giveMeRecordType() {
|
||||
return BasicUsageRecord.class.getSimpleName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public String getScope() {
|
||||
return (String) this.resourceProperties.get(SCOPE);
|
||||
|
@ -128,6 +144,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setScope(String scope) throws InvalidValueException {
|
||||
setResourceProperty(SCOPE, scope);
|
||||
|
@ -136,6 +153,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public OperationResult getOperationResult(){
|
||||
try {
|
||||
|
@ -150,6 +168,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
|||
* {@inheritDoc}
|
||||
* @throws InvalidValueException
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationResult(OperationResult operationResult) throws InvalidValueException {
|
||||
setResourceProperty(OPERATION_RESULT, operationResult);
|
||||
|
|
|
@ -17,10 +17,14 @@ import org.gcube.documentstore.records.implementation.AggregatedField;
|
|||
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="JobUsageRecord")
|
||||
public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements AggregatedUsageRecord<AggregatedJobUsageRecord, JobUsageRecord> {
|
||||
|
||||
|
||||
|
@ -43,7 +47,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
super(properties);
|
||||
}
|
||||
|
||||
// TODO
|
||||
// TODO
|
||||
public AggregatedJobUsageRecord(JobUsageRecord record) throws InvalidValueException{
|
||||
//throw new UnsupportedOperationException();
|
||||
super(record.getResourceProperties());
|
||||
|
@ -57,28 +61,34 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
this.setEndTime(creationTime);
|
||||
|
||||
}
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getMaxInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
||||
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getMinInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
||||
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
||||
}
|
||||
|
@ -86,6 +96,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -94,6 +105,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -102,6 +114,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -110,11 +123,28 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
protected long durationWeightedAverage(AggregatedJobUsageRecord record) throws InvalidValueException{
|
||||
long thisDuration = this.getDuration() * this.getOperationCount();
|
||||
|
@ -127,6 +157,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedJobUsageRecord aggregate(AggregatedJobUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -156,6 +187,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedJobUsageRecord aggregate(JobUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -193,8 +225,9 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<JobUsageRecord> getAggregable() {
|
||||
return JobUsageRecord.class;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,14 @@ import org.gcube.documentstore.exception.InvalidValueException;
|
|||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="PortletUsageRecord")
|
||||
public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord implements AggregatedUsageRecord<AggregatedPortletUsageRecord, PortletUsageRecord> {
|
||||
|
||||
|
||||
|
@ -36,14 +40,24 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
|
||||
// TODO
|
||||
public AggregatedPortletUsageRecord(PortletUsageRecord portletUsageRecord) throws InvalidValueException {
|
||||
throw new UnsupportedOperationException();
|
||||
//TEST AGGREGATE
|
||||
super(portletUsageRecord.getResourceProperties());
|
||||
this.setOperationCount(1);
|
||||
Calendar creationTime = portletUsageRecord.getCreationTime();
|
||||
this.setCreationTime(Calendar.getInstance());
|
||||
this.setStartTime(creationTime);
|
||||
this.setEndTime(creationTime);
|
||||
//END TEST comment a throw
|
||||
//throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
|
@ -52,6 +66,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -60,6 +75,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -68,6 +84,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -76,36 +93,59 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public AggregatedPortletUsageRecord aggregate(
|
||||
AggregatedPortletUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
/* TODO
|
||||
AggregationUtility<AggregatedPortletUsageRecord> aggregationUtility = new AggregationUtility<AggregatedPortletUsageRecord>(this);
|
||||
aggregationUtility.aggregate(record);
|
||||
} catch(NotAggregatableRecordsExceptions e){
|
||||
throw e; */
|
||||
} catch(Exception ex){
|
||||
throw new NotAggregatableRecordsExceptions(ex);
|
||||
}
|
||||
//return this;
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedPortletUsageRecord aggregate(AggregatedPortletUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
/* TODO*/
|
||||
AggregationUtility<AggregatedPortletUsageRecord> aggregationUtility = new AggregationUtility<AggregatedPortletUsageRecord>(this);
|
||||
|
||||
aggregationUtility.aggregate(record);
|
||||
} catch(NotAggregatableRecordsExceptions e){
|
||||
throw e;
|
||||
} catch(Exception ex){
|
||||
throw new NotAggregatableRecordsExceptions(ex);
|
||||
}
|
||||
return this;
|
||||
|
||||
//throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedPortletUsageRecord aggregate(PortletUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -141,6 +181,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<PortletUsageRecord> getAggregable() {
|
||||
return PortletUsageRecord.class;
|
||||
}
|
||||
|
|
|
@ -17,10 +17,14 @@ import org.gcube.documentstore.records.implementation.AggregatedField;
|
|||
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="ServiceUsageRecord")
|
||||
public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord implements AggregatedUsageRecord<AggregatedServiceUsageRecord, ServiceUsageRecord> {
|
||||
|
||||
/**
|
||||
|
@ -28,6 +32,8 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
*/
|
||||
private static final long serialVersionUID = 6387584974618335623L;
|
||||
|
||||
|
||||
|
||||
@AggregatedField
|
||||
public static final String DURATION = AbstractServiceUsageRecord.DURATION;
|
||||
|
||||
|
@ -56,28 +62,35 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
this.setEndTime(creationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getMaxInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
||||
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public long getMinInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
||||
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
||||
}
|
||||
|
@ -85,6 +98,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -93,6 +107,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -101,18 +116,37 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
|
||||
protected long durationWeightedAverage(AggregatedServiceUsageRecord record){
|
||||
long thisDuration = this.getDuration() * this.getOperationCount();
|
||||
|
@ -125,6 +159,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedServiceUsageRecord aggregate(AggregatedServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -160,6 +195,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedServiceUsageRecord aggregate(ServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -174,6 +210,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isAggregable(AggregatedServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
@ -184,7 +221,8 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public boolean isAggregable(ServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -200,6 +238,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<ServiceUsageRecord> getAggregable() {
|
||||
return ServiceUsageRecord.class;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,14 @@ import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
|||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
import org.gcube.documentstore.records.implementation.AggregatedField;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
||||
*/
|
||||
@JsonTypeName(value="StorageStatusRecord")
|
||||
public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord implements AggregatedUsageRecord<AggregatedStorageStatusRecord, StorageStatusRecord> {
|
||||
|
||||
/**
|
||||
|
@ -50,11 +54,13 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
this.setEndTime(creationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
|
@ -63,6 +69,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -71,6 +78,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -79,6 +87,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -87,15 +96,33 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageStatusRecord aggregate(
|
||||
AggregatedStorageStatusRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
@ -117,6 +144,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageStatusRecord aggregate(StorageStatusRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -157,6 +185,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<StorageStatusRecord> getAggregable() {
|
||||
return StorageStatusRecord.class;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,14 @@ import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
|||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
import org.gcube.documentstore.records.implementation.AggregatedField;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="StorageUsageRecord")
|
||||
public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord implements AggregatedUsageRecord<AggregatedStorageUsageRecord, StorageUsageRecord> {
|
||||
|
||||
/**
|
||||
|
@ -47,11 +51,13 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
this.setEndTime(creationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
|
@ -60,6 +66,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -76,6 +83,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -84,15 +92,33 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageUsageRecord aggregate(
|
||||
AggregatedStorageUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
@ -112,6 +138,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageUsageRecord aggregate(StorageUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -152,6 +179,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<StorageUsageRecord> getAggregable() {
|
||||
return StorageUsageRecord.class;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,14 @@ import org.gcube.documentstore.exception.InvalidValueException;
|
|||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="AggregatedTaskUsageRecord")
|
||||
public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implements AggregatedUsageRecord<AggregatedTaskUsageRecord, TaskUsageRecord> {
|
||||
|
||||
/**
|
||||
|
@ -38,11 +42,13 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
|
@ -51,6 +57,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -59,6 +66,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -67,6 +75,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -75,6 +84,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
|
@ -75,6 +77,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* @return the Job Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getJobId() {
|
||||
return (String) this.resourceProperties.get(JOB_ID);
|
||||
}
|
||||
|
@ -83,40 +86,48 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
* @param jobId Job Id
|
||||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setJobId(String jobId) throws InvalidValueException {
|
||||
setResourceProperty(JOB_ID, jobId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getJobQualifier() {
|
||||
return (String) this.resourceProperties.get(JOB_QUALIFIER);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobQualifier(String jobQualifier) throws InvalidValueException {
|
||||
setResourceProperty(JOB_QUALIFIER, jobQualifier);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getJobName() {
|
||||
return (String) this.resourceProperties.get(JOB_NAME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobName(String jobName) throws InvalidValueException {
|
||||
setResourceProperty(JOB_NAME, jobName);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getJobStartTime() {
|
||||
long millis = (Long) this.resourceProperties.get(JOB_START_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobStartTime(Calendar jobStartTime) throws InvalidValueException {
|
||||
setResourceProperty(JOB_START_TIME, jobStartTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getJobEndTime() {
|
||||
long millis = (Long) this.resourceProperties.get(JOB_END_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobEndTime(Calendar jobEndTime) throws InvalidValueException {
|
||||
setResourceProperty(JOB_END_TIME, jobEndTime.getTimeInMillis());
|
||||
}
|
||||
|
@ -134,6 +145,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDuration() throws InvalidValueException {
|
||||
Long wallDuration = (Long) this.resourceProperties.get(DURATION);
|
||||
if(wallDuration == null){
|
||||
|
@ -145,6 +157,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
}
|
||||
return wallDuration;
|
||||
}
|
||||
@JsonIgnore
|
||||
public void setDuration(Long duration) throws InvalidValueException {
|
||||
setResourceProperty(DURATION, duration);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.gcube.documentstore.records.implementation.RequiredField;
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
|
@ -52,26 +54,32 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
|
|||
return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getPortletId() {
|
||||
return (String) this.resourceProperties.get(PORTLET_ID);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setPortletId(String portletId) throws InvalidValueException {
|
||||
setResourceProperty(PORTLET_ID, portletId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getOperationId() {
|
||||
return (String) this.resourceProperties.get(OPERATION_ID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setOperationId(String operationId) throws InvalidValueException {
|
||||
setResourceProperty(OPERATION_ID, operationId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getMessage() {
|
||||
return (String) this.resourceProperties.get(MESSAGE);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMessage(String message) throws InvalidValueException {
|
||||
setResourceProperty(MESSAGE, message);
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ import org.gcube.documentstore.records.implementation.RequiredField;
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||
|
||||
public class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -26,6 +28,7 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* KEY for : hostname:port of the Hosting Node made the service call
|
||||
*/
|
||||
|
||||
@RequiredField @NotEmpty
|
||||
public static final String CALLER_HOST = "callerHost";
|
||||
|
||||
|
@ -91,63 +94,76 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
protected String giveMeRecordType() {
|
||||
return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getCallerHost() {
|
||||
return (String) this.resourceProperties.get(CALLER_HOST);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setCallerHost(String callerHost) throws InvalidValueException {
|
||||
setResourceProperty(CALLER_HOST, callerHost);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getHost() {
|
||||
return (String) this.resourceProperties.get(HOST);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setHost(String host) throws InvalidValueException {
|
||||
setResourceProperty(HOST, host);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getServiceClass() {
|
||||
return (String) this.resourceProperties.get(SERVICE_CLASS);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setServiceClass(String serviceClass) throws InvalidValueException {
|
||||
setResourceProperty(SERVICE_CLASS, serviceClass);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getServiceName() {
|
||||
return (String) this.resourceProperties.get(SERVICE_NAME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setServiceName(String serviceName) throws InvalidValueException {
|
||||
setResourceProperty(SERVICE_NAME, serviceName);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public String getCalledMethod() {
|
||||
return (String) this.resourceProperties.get(CALLED_METHOD);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setCalledMethod(String calledMethod) throws InvalidValueException {
|
||||
setResourceProperty(CALLED_METHOD, calledMethod);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Long getDuration() {
|
||||
return (Long) this.resourceProperties.get(DURATION);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDuration(Long duration) throws InvalidValueException {
|
||||
setResourceProperty(DURATION, duration);
|
||||
}
|
||||
|
||||
/*Add a new field*/
|
||||
@JsonIgnore
|
||||
public String getCallerQualifier() {
|
||||
return (String) this.resourceProperties.get(CALLERQUALIFIER);
|
||||
}
|
||||
@JsonIgnore
|
||||
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
||||
setResourceProperty(CALLERQUALIFIER, callerQualifier);
|
||||
}
|
||||
|
|
|
@ -9,13 +9,15 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidDataType;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidDataTypeVolume;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidURI;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
||||
*
|
||||
|
@ -42,7 +44,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
* The value is a controlled dictionary by
|
||||
* {@link #StorageStatusRecord.DataType}
|
||||
*/
|
||||
@RequiredField @ValidDataType
|
||||
@RequiredField @ValidDataTypeVolume
|
||||
public static final String DATA_TYPE = "dataType";
|
||||
|
||||
/**
|
||||
|
@ -94,58 +96,72 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
return AbstractStorageStatusRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDataVolume() {
|
||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public DataType getDataType() {
|
||||
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataType(DataType dataType) throws InvalidValueException {
|
||||
setResourceProperty(DATA_TYPE, dataType);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDataCount() {
|
||||
return (Long) this.resourceProperties.get(DATA_COUNT);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataCount(long dataCount) throws InvalidValueException {
|
||||
setResourceProperty(DATA_COUNT, dataCount);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDataServiceClass() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICECLASS);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataServiceClass(String dataServiceClass) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICECLASS, dataServiceClass);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDataServiceName() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICENAME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataServiceName(String dataServiceName) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICENAME, dataServiceName);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDataServiceId() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICEID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataServiceId(String dataServiceId) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICEID, dataServiceId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public URI getProviderId() {
|
||||
return (URI) this.resourceProperties.get(PROVIDER_ID);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setProviderId(URI provideId) throws InvalidValueException {
|
||||
setResourceProperty(PROVIDER_ID, provideId);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
|
@ -116,6 +118,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* Return the identity id of the storage resource owner
|
||||
* @return the identity id of the accounting owner
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getResourceOwner() {
|
||||
return (String) this.resourceProperties.get(RESOURCE_OWNER);
|
||||
}
|
||||
|
@ -125,6 +128,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* @param owner the identity id of the storage resource owner
|
||||
* @throws InvalidValueException
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setResourceOwner(String owner) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_OWNER, owner);
|
||||
}
|
||||
|
@ -132,6 +136,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* Return the scope of the storage resource
|
||||
* @return The scope id of the storage resource
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getResourceScope() {
|
||||
return (String) this.resourceProperties.get(RESOURCE_SCOPE);
|
||||
}
|
||||
|
@ -141,54 +146,67 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* @param scope the scope of the storage resource
|
||||
* @throws InvalidValueException
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setResourceScope(String scope) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_SCOPE, scope);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public URI getProviderURI() {
|
||||
return (URI) this.resourceProperties.get(PROVIDER_URI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setProviderURI(URI providerURI) throws InvalidValueException {
|
||||
setResourceProperty(PROVIDER_URI, providerURI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public URI getResourceURI() {
|
||||
return (URI) this.resourceProperties.get(RESOURCE_URI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setResourceURI(URI resourceURI) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_URI, resourceURI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public OperationType getOperationType() {
|
||||
return (OperationType) this.resourceProperties.get(OPERATION_TYPE);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setOperationType(OperationType operationType) throws InvalidValueException {
|
||||
setResourceProperty(OPERATION_TYPE, operationType);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public DataType getDataType() {
|
||||
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataType(DataType dataType) throws InvalidValueException {
|
||||
setResourceProperty(DATA_TYPE, dataType);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDataVolume() {
|
||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getQualifier() {
|
||||
return (String) this.resourceProperties.get(QUALIFIER);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setQualifier(String qualifier) throws InvalidValueException {
|
||||
setResourceProperty(QUALIFIER, qualifier);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,13 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
|
||||
public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
|
@ -27,7 +30,8 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
*/
|
||||
private static final long serialVersionUID = -2208425042550641240L;
|
||||
|
||||
@RequiredField @NotEmpty
|
||||
|
||||
@RequiredField @NotEmpty
|
||||
public static final String TASK_ID = "taskId";
|
||||
@NotEmptyIfNotNull
|
||||
public static final String REF_JOB_ID = "refJobId";
|
||||
|
@ -37,9 +41,9 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
@NotEmptyIfNotNull
|
||||
public static final String REF_HOSTING_NODE_ID = "refHostingNodeId";
|
||||
|
||||
@ValidLong
|
||||
@ValidLong @RequiredField
|
||||
public static final String TASK_START_TIME = "taskStartTime";
|
||||
@ValidLong
|
||||
@ValidLong @RequiredField
|
||||
public static final String TASK_END_TIME = "taskEndTime";
|
||||
|
||||
@RequiredField @ComputedField(action=CalculateTaskWallDurationAction.class) @ValidLong
|
||||
|
@ -69,6 +73,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* @return the Task Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getTaskId() {
|
||||
return (String) this.resourceProperties.get(TASK_ID);
|
||||
}
|
||||
|
@ -77,6 +82,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
* @param taskId Task Id
|
||||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setTaskId(String taskId) throws InvalidValueException {
|
||||
setResourceProperty(TASK_ID, taskId);
|
||||
}
|
||||
|
@ -84,6 +90,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* @return the Referenced Job Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getRefJobId() {
|
||||
return (String) this.resourceProperties.get(REF_JOB_ID);
|
||||
}
|
||||
|
@ -92,40 +99,49 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
* @param refJobId Referenced Job Id
|
||||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setRefJobId(String refJobId) throws InvalidValueException {
|
||||
setResourceProperty(REF_JOB_ID, refJobId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getHost() {
|
||||
return (String) this.resourceProperties.get(HOST);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setHost(String host) throws InvalidValueException {
|
||||
setResourceProperty(HOST, host);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getRefHostingNodeId() {
|
||||
return (String) this.resourceProperties.get(REF_HOSTING_NODE_ID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setRefHostingNodeId(String refHostingNodeId) throws InvalidValueException {
|
||||
setResourceProperty(REF_HOSTING_NODE_ID, refHostingNodeId);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getTaskStartTime() {
|
||||
long millis = (Long) this.resourceProperties.get(TASK_START_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setTaskStartTime(Calendar startTime) throws InvalidValueException {
|
||||
setResourceProperty(TASK_START_TIME, startTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getTaskEndTime() {
|
||||
long millis = (Long) this.resourceProperties.get(TASK_END_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setTaskEndTime(Calendar endTime) throws InvalidValueException {
|
||||
setResourceProperty(TASK_END_TIME, endTime.getTimeInMillis());
|
||||
}
|
||||
|
@ -142,6 +158,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getWallDuration() throws InvalidValueException {
|
||||
Long wallDuration = (Long) this.resourceProperties.get(WALL_DURATION);
|
||||
if(wallDuration == null){
|
||||
|
@ -154,11 +171,19 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
return wallDuration;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setWallDuration(Long duration) throws InvalidValueException {
|
||||
setResourceProperty(WALL_DURATION, duration);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@JsonIgnore
|
||||
public Map<String, Serializable> getInputParameters(){
|
||||
return (HashMap<String, Serializable>) getResourceProperty(INPUT_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public void setInputParameters(HashMap<String, Serializable> inputParameters) throws InvalidValueException{
|
||||
setResourceProperty(INPUT_PARAMETERS, inputParameters);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
|||
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="NotAggregateJobUsageRecord")
|
||||
public class JobUsageRecord extends AbstractJobUsageRecord {
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
|||
import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="NotAggregatePortletUsageRecord")
|
||||
public class PortletUsageRecord extends AbstractPortletUsageRecord {
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
|||
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="NotAggregateServiceUsageRecord")
|
||||
public class ServiceUsageRecord extends AbstractServiceUsageRecord {
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,10 +5,13 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
/**
|
||||
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
@JsonTypeName(value="NotAggregateStorageStatusRecord")
|
||||
public class StorageStatusRecord extends AbstractStorageStatusRecord {
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
|||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="NotAggregateStorageUsageRecord")
|
||||
public class StorageUsageRecord extends AbstractStorageUsageRecord {
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
|||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="TaskUsageRecord")
|
||||
public class TaskUsageRecord extends AbstractTaskUsageRecord {
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.gcube.accounting.datamodel.validations.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidDataTypeValidatorVolume;
|
||||
import org.gcube.documentstore.records.implementation.FieldDecorator;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@FieldDecorator(action=ValidDataTypeValidatorVolume.class)
|
||||
public @interface ValidDataTypeVolume {
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
|
||||
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package org.gcube.accounting.datamodel.validations.validators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord.DataType;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ValidDataTypeValidatorVolume implements FieldAction {
|
||||
|
||||
private static final String ERROR = String.format("Not Instance of %s", DataType.class.getSimpleName());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
if(value instanceof DataType){
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
if(value instanceof String){
|
||||
try{
|
||||
DataType dataType = DataType.valueOf((String) value);
|
||||
if(dataType !=null){
|
||||
return dataType;
|
||||
}
|
||||
} catch(Exception e){
|
||||
// Trying another way
|
||||
}
|
||||
|
||||
try{
|
||||
Integer integer = Integer.getInteger((String) value);
|
||||
if(integer!=null){
|
||||
value = integer;
|
||||
}
|
||||
} catch(Exception e){
|
||||
// Trying another way
|
||||
}
|
||||
}
|
||||
|
||||
if(value instanceof Integer){
|
||||
return DataType.values()[(Integer) value];
|
||||
}
|
||||
|
||||
if(value instanceof Enum){
|
||||
return DataType.values()[((Enum) value).ordinal()];
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
|
||||
throw new InvalidValueException(ERROR);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -50,4 +50,6 @@ public class AccountingPersistence {
|
|||
getAccountingPersistence().close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public class AccountingPersistenceFactory {
|
|||
public static void initAccountingPackages(){
|
||||
PersistenceBackendFactory.addRecordPackage(ServiceUsageRecord.class.getPackage());
|
||||
PersistenceBackendFactory.addRecordPackage(AggregatedServiceUsageRecord.class.getPackage());
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
|
@ -48,6 +49,7 @@ public class AccountingPersistenceFactory {
|
|||
PersistenceBackendFactory.flushAll(timeout, timeUnit);
|
||||
}
|
||||
|
||||
|
||||
public static void shutDown(long timeout, TimeUnit timeUnit){
|
||||
//flush all and shutdown connection and thread
|
||||
PersistenceBackendFactory.flushAll(timeout, timeUnit);
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.accounting.datamodel.aggregation;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecordTest;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.accounting.datamodel.aggregation;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecordTest;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
|
|
@ -5,7 +5,6 @@ package org.gcube.accounting.datamodel.aggregation;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecordTest;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.accounting.datamodel.aggregation;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecordTest;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package org.gcube.documentstore.persistence;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.documentstore.records.DSMapper;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.RecordUtility;
|
||||
import org.gcube.documentstore.records.implementation.AbstractRecord;
|
||||
import org.gcube.testutility.ScopedTest;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MyTest extends ScopedTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(MyTest.class);
|
||||
|
||||
@Test
|
||||
public void test() throws Exception{
|
||||
File f = new File("test.log");
|
||||
|
||||
DSMapper.registerSubtypes(Record.class);
|
||||
DSMapper.registerSubtypes(AbstractRecord.class);
|
||||
DSMapper.registerSubtypes(UsageRecord.class);
|
||||
DSMapper.registerSubtypes(BasicUsageRecord.class);
|
||||
DSMapper.registerSubtypes(AbstractServiceUsageRecord.class);
|
||||
DSMapper.registerSubtypes(ServiceUsageRecord.class);
|
||||
|
||||
/*
|
||||
Record record = TestUsageRecord.createTestServiceUsageRecord();
|
||||
|
||||
FallbackPersistenceBackend fallbackPersistenceBackend = new FallbackPersistenceBackend(f);
|
||||
|
||||
fallbackPersistenceBackend.reallyAccount(record);
|
||||
*/
|
||||
/*
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(f))) {
|
||||
for(String line; (line = br.readLine()) != null; ) {
|
||||
try {
|
||||
Record record = RecordUtility.getRecord(ServiceUsageRecord.class, line);
|
||||
logger.debug(record.toString());
|
||||
} catch(Exception e){
|
||||
logger.error("Was not possible parse line {} to obtain a valid Record. Going to writing back this line as string fallback file.", line, e);
|
||||
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error("File non trovato", e);
|
||||
} catch (IOException e) {
|
||||
logger.error("IOException", e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,28 +1,29 @@
|
|||
package org.gcube.testutility;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.accounting.persistence.AccountingPersistence;
|
||||
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
import org.gcube.documentstore.records.DSMapper;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.RecordUtility;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
public class MyTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MyTest.class);
|
||||
|
@ -35,39 +36,31 @@ public class MyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception{
|
||||
public void testFull() throws Exception{
|
||||
|
||||
|
||||
|
||||
|
||||
AccountingPersistence apq= AccountingPersistenceFactory.getPersistence();
|
||||
|
||||
//Record record=TestUsageRecord.createTestServiceUsageRecord();
|
||||
//Record record2=TestUsageRecord.createTestServiceUsageRecord();
|
||||
|
||||
|
||||
Record record=TestUsageRecord.createTestStorageVolumeUsageRecord();
|
||||
|
||||
//Record record=TestUsageRecord.createTestServiceUsageRecord();//ok verificato
|
||||
//Record record=TestUsageRecord.createTestStorageUsageRecord();//ok verificato
|
||||
//Record record=TestUsageRecord.createTestStorageVolumeUsageRecord();//ok verificato
|
||||
//Record record=TestUsageRecord.createTestPortletUsageRecord();//ok verificato
|
||||
Record record=TestUsageRecord.createTestTaskUsageRecord();//ok verificato
|
||||
//Record record=TestUsageRecord.createTestJobUsageRecord();//ok
|
||||
logger.debug("----record:{}",record);
|
||||
apq.account(record);
|
||||
//apq.account(record);
|
||||
//apq.account(record2);
|
||||
Thread.sleep(3000);
|
||||
|
||||
apq.flush(3000, TimeUnit.MILLISECONDS);
|
||||
|
||||
Thread.sleep(1500);
|
||||
apq.flush(1500, TimeUnit.MILLISECONDS);
|
||||
logger.debug("end flush");
|
||||
|
||||
|
||||
File elaborationFile = new File("/home/pieve/_gcube_devNext.fallback.log");
|
||||
|
||||
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
|
||||
for(String line; (line = br.readLine()) != null; ) {
|
||||
try {
|
||||
//Record r =DSMapper.unmarshal(Record.class, line);
|
||||
|
||||
Record r = RecordUtility.getRecord( line);
|
||||
logger.debug("{}", r);
|
||||
logger.debug("--record:{}", r);
|
||||
|
||||
} catch(Exception e){
|
||||
logger.error("Was not possible parse line {} to obtain a valid Record. Going to writing back this line as string fallback file.", line, e);
|
||||
|
@ -76,14 +69,31 @@ public class MyTest {
|
|||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error("File non trovato", e);
|
||||
} catch (IOException e) {
|
||||
logger.error("IOException", e);
|
||||
} catch (IOException ei) {
|
||||
logger.error("IOException", ei);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSingle() throws Exception{
|
||||
|
||||
Record record=TestUsageRecord.createTestServiceUsageRecord();
|
||||
logger.debug("----init record:{}",record.toString());
|
||||
String test=DSMapper.marshal(record);
|
||||
logger.debug("----marshal single record:{}",test);
|
||||
|
||||
Record r =DSMapper.unmarshal(Record.class, test);
|
||||
logger.debug("----unmarshal single record:{}",r.toString());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,21 +3,91 @@
|
|||
*/
|
||||
package org.gcube.testutility;
|
||||
|
||||
//import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gcube.common.authorization.client.Constants;
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.junit.Before;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class ScopedTest {
|
||||
|
||||
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
|
||||
|
||||
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||
|
||||
private static final String GCUBE_DEVNEXT_VARNAME = "GCUBE_DEVNEXT";
|
||||
public static final String GCUBE_DEVNEXT;
|
||||
|
||||
private static final String GCUBE_DEVNEXT_NEXTNEXT_VARNAME = "GCUBE_DEVNEXT_NEXTNEXT";
|
||||
public static final String GCUBE_DEVNEXT_NEXTNEXT;
|
||||
|
||||
public static final String GCUBE_DEVSEC_VARNAME = "GCUBE_DEVSEC";
|
||||
public static final String GCUBE_DEVSEC;
|
||||
|
||||
public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE";
|
||||
public static final String GCUBE_DEVSEC_DEVVRE;
|
||||
|
||||
public static final String DEFAULT_TEST_SCOPE;
|
||||
public static final String ALTERNATIVE_TEST_SCOPE;
|
||||
|
||||
static {
|
||||
Properties properties = new Properties();
|
||||
InputStream input = ScopedTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
|
||||
|
||||
@Before
|
||||
public void before() throws Exception{
|
||||
SecurityTokenProvider.instance.reset();
|
||||
try {
|
||||
// load the properties file
|
||||
properties.load(input);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
GCUBE_DEVNEXT = properties.getProperty(GCUBE_DEVNEXT_VARNAME);
|
||||
GCUBE_DEVNEXT_NEXTNEXT = properties.getProperty(GCUBE_DEVNEXT_NEXTNEXT_VARNAME);
|
||||
|
||||
SecurityTokenProvider.instance.set("");
|
||||
GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME);
|
||||
GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME);
|
||||
|
||||
DEFAULT_TEST_SCOPE = GCUBE_DEVNEXT;
|
||||
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVSEC;
|
||||
}
|
||||
|
||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception{
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.info("Context of token {} is {}", token, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
public static void setContext(String token) throws ObjectNotFound, Exception{
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
ScopeProvider.instance.set(getCurrentScope(token));
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception{
|
||||
setContext(DEFAULT_TEST_SCOPE);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception{
|
||||
SecurityTokenProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,7 +86,6 @@ public class TestUsageRecord {
|
|||
try {
|
||||
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
||||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||
|
||||
usageRecord.setCallerHost(TEST_CALLER_HOST);
|
||||
usageRecord.setHost(TEST_HOST);
|
||||
usageRecord.setCallerQualifier(TEST_CALLER_QUALIFIER);
|
||||
|
@ -183,6 +182,7 @@ public class TestUsageRecord {
|
|||
|
||||
usageRecord.setJobId(TEST_JOB_ID);
|
||||
usageRecord.setJobName(TEST_JOB_NAME);
|
||||
usageRecord.setJobQualifier("212505");
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.setTimeInMillis(startTime.getTimeInMillis() + HALF_DURATION);
|
||||
|
@ -209,7 +209,7 @@ public class TestUsageRecord {
|
|||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||
|
||||
usageRecord.setTaskId(TEST_TASK_ID);
|
||||
usageRecord.setTaskId(TEST_JOB_ID);
|
||||
//usageRecord.setTaskId(TEST_JOB_ID);
|
||||
usageRecord.setHost(TEST_HOST);
|
||||
|
||||
usageRecord.setRefHostingNodeId(UUID.randomUUID().toString());
|
||||
|
@ -222,10 +222,14 @@ public class TestUsageRecord {
|
|||
usageRecord.setTaskStartTime(startTime);
|
||||
usageRecord.setTaskEndTime(endTime);
|
||||
|
||||
usageRecord.setResourceProperty("finalState", "DONE") ;
|
||||
usageRecord.setResourceProperty("ESEMpio", "PLUTO") ;
|
||||
|
||||
HashMap<String, Serializable> inputParameters = new HashMap<>();
|
||||
inputParameters.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||
inputParameters.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||
|
||||
|
||||
HashMap<String, Serializable> parameter = new HashMap<>();
|
||||
parameter.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||
parameter.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||
|
@ -233,6 +237,7 @@ public class TestUsageRecord {
|
|||
inputParameters.put(TEST_NESTED_MAP, parameter);
|
||||
|
||||
usageRecord.setInputParameters(inputParameters);
|
||||
|
||||
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
GCUBE_DEVNEXT=
|
||||
GCUBE_DEVNEXT_NEXTNEXT=
|
||||
GCUBE_DEVSEC=
|
||||
GCUBE_DEVSEC_DEVVRE=
|
Loading…
Reference in New Issue