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>
|
<groupId>org.gcube.accounting</groupId>
|
||||||
<artifactId>accounting-lib</artifactId>
|
<artifactId>accounting-lib</artifactId>
|
||||||
<version>2.4.1-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
<name>Accounting Library</name>
|
<name>Accounting Library</name>
|
||||||
<description>Accounting Library</description>
|
<description>Accounting Library</description>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.gcube.documentstore.records.implementation.validations.annotations.Va
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface AggregatedUsageRecord<A extends AggregatedUsageRecord<A,U>, U extends UsageRecord> extends AggregatedRecord<A,U> {
|
public interface AggregatedUsageRecord<A extends AggregatedUsageRecord<A,U>, U extends UsageRecord> extends AggregatedRecord<A,U> {
|
||||||
|
|
||||||
@ValidBoolean
|
@ValidBoolean
|
||||||
|
|
|
@ -22,12 +22,16 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @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
|
* Generated Serial Version UID
|
||||||
|
@ -78,7 +82,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
try {
|
try {
|
||||||
this.setScope(getScopeFromToken());
|
this.setScope(getScopeFromToken());
|
||||||
} catch(Exception e) {
|
} 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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public String getConsumerId() {
|
public String getConsumerId() {
|
||||||
return (String) this.resourceProperties.get(CONSUMER_ID);
|
return (String) this.resourceProperties.get(CONSUMER_ID);
|
||||||
|
@ -111,15 +116,26 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setConsumerId(String consumerId) throws InvalidValueException {
|
public void setConsumerId(String consumerId) throws InvalidValueException {
|
||||||
setResourceProperty(CONSUMER_ID, consumerId);
|
setResourceProperty(CONSUMER_ID, consumerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
protected String giveMeRecordType() {
|
||||||
|
return BasicUsageRecord.class.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public String getScope() {
|
public String getScope() {
|
||||||
return (String) this.resourceProperties.get(SCOPE);
|
return (String) this.resourceProperties.get(SCOPE);
|
||||||
|
@ -128,6 +144,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setScope(String scope) throws InvalidValueException {
|
public void setScope(String scope) throws InvalidValueException {
|
||||||
setResourceProperty(SCOPE, scope);
|
setResourceProperty(SCOPE, scope);
|
||||||
|
@ -136,6 +153,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public OperationResult getOperationResult(){
|
public OperationResult getOperationResult(){
|
||||||
try {
|
try {
|
||||||
|
@ -150,6 +168,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @throws InvalidValueException
|
* @throws InvalidValueException
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setOperationResult(OperationResult operationResult) throws InvalidValueException {
|
public void setOperationResult(OperationResult operationResult) throws InvalidValueException {
|
||||||
setResourceProperty(OPERATION_RESULT, operationResult);
|
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.RequiredField;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
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
|
* This Class is for library internal use only
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="JobUsageRecord")
|
||||||
public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements AggregatedUsageRecord<AggregatedJobUsageRecord, JobUsageRecord> {
|
public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements AggregatedUsageRecord<AggregatedJobUsageRecord, JobUsageRecord> {
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,28 +61,34 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
this.setEndTime(creationTime);
|
this.setEndTime(creationTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public int getOperationCount() {
|
public int getOperationCount() {
|
||||||
return super.getOperationCount();
|
return super.getOperationCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||||
super.setOperationCount(operationCount);
|
super.setOperationCount(operationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getMaxInvocationTime() {
|
public long getMaxInvocationTime() {
|
||||||
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
||||||
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getMinInvocationTime() {
|
public long getMinInvocationTime() {
|
||||||
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
||||||
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +96,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getStartTime() {
|
public Calendar getStartTime() {
|
||||||
return super.getStartTimeAsCalendar();
|
return super.getStartTimeAsCalendar();
|
||||||
|
@ -94,6 +105,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||||
super.setStartTime(startTime);
|
super.setStartTime(startTime);
|
||||||
|
@ -102,6 +114,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getEndTime() {
|
public Calendar getEndTime() {
|
||||||
return super.getEndTimeAsCalendar();
|
return super.getEndTimeAsCalendar();
|
||||||
|
@ -110,12 +123,29 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||||
super.setEndTime(endTime);
|
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{
|
protected long durationWeightedAverage(AggregatedJobUsageRecord record) throws InvalidValueException{
|
||||||
long thisDuration = this.getDuration() * this.getOperationCount();
|
long thisDuration = this.getDuration() * this.getOperationCount();
|
||||||
long recordDuration = record.getDuration() * record.getOperationCount();
|
long recordDuration = record.getDuration() * record.getOperationCount();
|
||||||
|
@ -127,6 +157,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedJobUsageRecord aggregate(AggregatedJobUsageRecord record)
|
public AggregatedJobUsageRecord aggregate(AggregatedJobUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
|
@ -156,6 +187,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedJobUsageRecord aggregate(JobUsageRecord record)
|
public AggregatedJobUsageRecord aggregate(JobUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
|
@ -195,6 +227,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public Class<JobUsageRecord> getAggregable() {
|
public Class<JobUsageRecord> getAggregable() {
|
||||||
return JobUsageRecord.class;
|
return JobUsageRecord.class;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,14 @@ import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
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
|
* This Class is for library internal use only
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="PortletUsageRecord")
|
||||||
public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord implements AggregatedUsageRecord<AggregatedPortletUsageRecord, PortletUsageRecord> {
|
public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord implements AggregatedUsageRecord<AggregatedPortletUsageRecord, PortletUsageRecord> {
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,14 +40,24 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
public AggregatedPortletUsageRecord(PortletUsageRecord portletUsageRecord) throws InvalidValueException {
|
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
|
@Override
|
||||||
public int getOperationCount() {
|
public int getOperationCount() {
|
||||||
return super.getOperationCount();
|
return super.getOperationCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||||
super.setOperationCount(operationCount);
|
super.setOperationCount(operationCount);
|
||||||
|
@ -52,6 +66,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getStartTime() {
|
public Calendar getStartTime() {
|
||||||
return super.getStartTimeAsCalendar();
|
return super.getStartTimeAsCalendar();
|
||||||
|
@ -60,6 +75,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||||
super.setStartTime(startTime);
|
super.setStartTime(startTime);
|
||||||
|
@ -68,6 +84,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getEndTime() {
|
public Calendar getEndTime() {
|
||||||
return super.getEndTimeAsCalendar();
|
return super.getEndTimeAsCalendar();
|
||||||
|
@ -76,36 +93,59 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||||
super.setEndTime(endTime);
|
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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AggregatedPortletUsageRecord aggregate(
|
@JsonIgnore
|
||||||
AggregatedPortletUsageRecord record)
|
public AggregatedPortletUsageRecord aggregate(AggregatedPortletUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
/* TODO
|
/* TODO*/
|
||||||
AggregationUtility<AggregatedPortletUsageRecord> aggregationUtility = new AggregationUtility<AggregatedPortletUsageRecord>(this);
|
AggregationUtility<AggregatedPortletUsageRecord> aggregationUtility = new AggregationUtility<AggregatedPortletUsageRecord>(this);
|
||||||
|
|
||||||
aggregationUtility.aggregate(record);
|
aggregationUtility.aggregate(record);
|
||||||
} catch(NotAggregatableRecordsExceptions e){
|
} catch(NotAggregatableRecordsExceptions e){
|
||||||
throw e; */
|
throw e;
|
||||||
} catch(Exception ex){
|
} catch(Exception ex){
|
||||||
throw new NotAggregatableRecordsExceptions(ex);
|
throw new NotAggregatableRecordsExceptions(ex);
|
||||||
}
|
}
|
||||||
//return this;
|
return this;
|
||||||
|
|
||||||
throw new UnsupportedOperationException();
|
//throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedPortletUsageRecord aggregate(PortletUsageRecord record)
|
public AggregatedPortletUsageRecord aggregate(PortletUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
|
@ -141,6 +181,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public Class<PortletUsageRecord> getAggregable() {
|
public Class<PortletUsageRecord> getAggregable() {
|
||||||
return PortletUsageRecord.class;
|
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.RequiredField;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
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
|
* This Class is for library internal use only
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="ServiceUsageRecord")
|
||||||
public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord implements AggregatedUsageRecord<AggregatedServiceUsageRecord, 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;
|
private static final long serialVersionUID = 6387584974618335623L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@AggregatedField
|
@AggregatedField
|
||||||
public static final String DURATION = AbstractServiceUsageRecord.DURATION;
|
public static final String DURATION = AbstractServiceUsageRecord.DURATION;
|
||||||
|
|
||||||
|
@ -56,28 +62,35 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
this.setEndTime(creationTime);
|
this.setEndTime(creationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public int getOperationCount() {
|
public int getOperationCount() {
|
||||||
return super.getOperationCount();
|
return super.getOperationCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||||
super.setOperationCount(operationCount);
|
super.setOperationCount(operationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getMaxInvocationTime() {
|
public long getMaxInvocationTime() {
|
||||||
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
||||||
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getMinInvocationTime() {
|
public long getMinInvocationTime() {
|
||||||
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
||||||
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
||||||
}
|
}
|
||||||
|
@ -85,6 +98,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getStartTime() {
|
public Calendar getStartTime() {
|
||||||
return super.getStartTimeAsCalendar();
|
return super.getStartTimeAsCalendar();
|
||||||
|
@ -93,6 +107,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||||
super.setStartTime(startTime);
|
super.setStartTime(startTime);
|
||||||
|
@ -101,6 +116,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getEndTime() {
|
public Calendar getEndTime() {
|
||||||
return super.getEndTimeAsCalendar();
|
return super.getEndTimeAsCalendar();
|
||||||
|
@ -109,11 +125,29 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||||
super.setEndTime(endTime);
|
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){
|
protected long durationWeightedAverage(AggregatedServiceUsageRecord record){
|
||||||
long thisDuration = this.getDuration() * this.getOperationCount();
|
long thisDuration = this.getDuration() * this.getOperationCount();
|
||||||
long recordDuration = record.getDuration() * record.getOperationCount();
|
long recordDuration = record.getDuration() * record.getOperationCount();
|
||||||
|
@ -125,6 +159,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedServiceUsageRecord aggregate(AggregatedServiceUsageRecord record)
|
public AggregatedServiceUsageRecord aggregate(AggregatedServiceUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
|
@ -160,6 +195,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedServiceUsageRecord aggregate(ServiceUsageRecord record)
|
public AggregatedServiceUsageRecord aggregate(ServiceUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
|
@ -174,6 +210,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAggregable(AggregatedServiceUsageRecord record)
|
public boolean isAggregable(AggregatedServiceUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
|
@ -184,6 +221,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAggregable(ServiceUsageRecord record)
|
public boolean isAggregable(ServiceUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
|
@ -200,6 +238,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public Class<ServiceUsageRecord> getAggregable() {
|
public Class<ServiceUsageRecord> getAggregable() {
|
||||||
return ServiceUsageRecord.class;
|
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.aggregation.AggregationUtility;
|
||||||
import org.gcube.documentstore.records.implementation.AggregatedField;
|
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
|
* This Class is for library internal use only
|
||||||
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="StorageStatusRecord")
|
||||||
public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord implements AggregatedUsageRecord<AggregatedStorageStatusRecord, StorageStatusRecord> {
|
public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord implements AggregatedUsageRecord<AggregatedStorageStatusRecord, StorageStatusRecord> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,11 +54,13 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
||||||
this.setEndTime(creationTime);
|
this.setEndTime(creationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public int getOperationCount() {
|
public int getOperationCount() {
|
||||||
return super.getOperationCount();
|
return super.getOperationCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||||
super.setOperationCount(operationCount);
|
super.setOperationCount(operationCount);
|
||||||
|
@ -63,6 +69,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getStartTime() {
|
public Calendar getStartTime() {
|
||||||
return super.getStartTimeAsCalendar();
|
return super.getStartTimeAsCalendar();
|
||||||
|
@ -71,6 +78,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||||
super.setStartTime(startTime);
|
super.setStartTime(startTime);
|
||||||
|
@ -79,6 +87,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getEndTime() {
|
public Calendar getEndTime() {
|
||||||
return super.getEndTimeAsCalendar();
|
return super.getEndTimeAsCalendar();
|
||||||
|
@ -87,15 +96,33 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||||
super.setEndTime(endTime);
|
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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedStorageStatusRecord aggregate(
|
public AggregatedStorageStatusRecord aggregate(
|
||||||
AggregatedStorageStatusRecord record)
|
AggregatedStorageStatusRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
|
@ -117,6 +144,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedStorageStatusRecord aggregate(StorageStatusRecord record)
|
public AggregatedStorageStatusRecord aggregate(StorageStatusRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
|
@ -157,6 +185,7 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public Class<StorageStatusRecord> getAggregable() {
|
public Class<StorageStatusRecord> getAggregable() {
|
||||||
return StorageStatusRecord.class;
|
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.aggregation.AggregationUtility;
|
||||||
import org.gcube.documentstore.records.implementation.AggregatedField;
|
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
|
* This Class is for library internal use only
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="StorageUsageRecord")
|
||||||
public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord implements AggregatedUsageRecord<AggregatedStorageUsageRecord, StorageUsageRecord> {
|
public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord implements AggregatedUsageRecord<AggregatedStorageUsageRecord, StorageUsageRecord> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,11 +51,13 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
||||||
this.setEndTime(creationTime);
|
this.setEndTime(creationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public int getOperationCount() {
|
public int getOperationCount() {
|
||||||
return super.getOperationCount();
|
return super.getOperationCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||||
super.setOperationCount(operationCount);
|
super.setOperationCount(operationCount);
|
||||||
|
@ -60,6 +66,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getStartTime() {
|
public Calendar getStartTime() {
|
||||||
return super.getStartTimeAsCalendar();
|
return super.getStartTimeAsCalendar();
|
||||||
|
@ -76,6 +83,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getEndTime() {
|
public Calendar getEndTime() {
|
||||||
return super.getEndTimeAsCalendar();
|
return super.getEndTimeAsCalendar();
|
||||||
|
@ -84,15 +92,33 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||||
super.setEndTime(endTime);
|
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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedStorageUsageRecord aggregate(
|
public AggregatedStorageUsageRecord aggregate(
|
||||||
AggregatedStorageUsageRecord record)
|
AggregatedStorageUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
|
@ -112,6 +138,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public AggregatedStorageUsageRecord aggregate(StorageUsageRecord record)
|
public AggregatedStorageUsageRecord aggregate(StorageUsageRecord record)
|
||||||
throws NotAggregatableRecordsExceptions {
|
throws NotAggregatableRecordsExceptions {
|
||||||
try {
|
try {
|
||||||
|
@ -152,6 +179,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public Class<StorageUsageRecord> getAggregable() {
|
public Class<StorageUsageRecord> getAggregable() {
|
||||||
return StorageUsageRecord.class;
|
return StorageUsageRecord.class;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,14 @@ import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
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
|
* This Class is for library internal use only
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="AggregatedTaskUsageRecord")
|
||||||
public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implements AggregatedUsageRecord<AggregatedTaskUsageRecord, TaskUsageRecord> {
|
public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implements AggregatedUsageRecord<AggregatedTaskUsageRecord, TaskUsageRecord> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,11 +42,13 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public int getOperationCount() {
|
public int getOperationCount() {
|
||||||
return super.getOperationCount();
|
return super.getOperationCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||||
super.setOperationCount(operationCount);
|
super.setOperationCount(operationCount);
|
||||||
|
@ -51,6 +57,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getStartTime() {
|
public Calendar getStartTime() {
|
||||||
return super.getStartTimeAsCalendar();
|
return super.getStartTimeAsCalendar();
|
||||||
|
@ -59,6 +66,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||||
super.setStartTime(startTime);
|
super.setStartTime(startTime);
|
||||||
|
@ -67,6 +75,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public Calendar getEndTime() {
|
public Calendar getEndTime() {
|
||||||
return super.getEndTimeAsCalendar();
|
return super.getEndTimeAsCalendar();
|
||||||
|
@ -75,6 +84,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||||
super.setEndTime(endTime);
|
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.NotEmptyIfNotNull;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*
|
*
|
||||||
|
@ -75,6 +77,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
||||||
/**
|
/**
|
||||||
* @return the Job Id
|
* @return the Job Id
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public String getJobId() {
|
public String getJobId() {
|
||||||
return (String) this.resourceProperties.get(JOB_ID);
|
return (String) this.resourceProperties.get(JOB_ID);
|
||||||
}
|
}
|
||||||
|
@ -83,40 +86,48 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
||||||
* @param jobId Job Id
|
* @param jobId Job Id
|
||||||
* @throws InvalidValueException if fails
|
* @throws InvalidValueException if fails
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public void setJobId(String jobId) throws InvalidValueException {
|
public void setJobId(String jobId) throws InvalidValueException {
|
||||||
setResourceProperty(JOB_ID, jobId);
|
setResourceProperty(JOB_ID, jobId);
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
public String getJobQualifier() {
|
public String getJobQualifier() {
|
||||||
return (String) this.resourceProperties.get(JOB_QUALIFIER);
|
return (String) this.resourceProperties.get(JOB_QUALIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setJobQualifier(String jobQualifier) throws InvalidValueException {
|
public void setJobQualifier(String jobQualifier) throws InvalidValueException {
|
||||||
setResourceProperty(JOB_QUALIFIER, jobQualifier);
|
setResourceProperty(JOB_QUALIFIER, jobQualifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getJobName() {
|
public String getJobName() {
|
||||||
return (String) this.resourceProperties.get(JOB_NAME);
|
return (String) this.resourceProperties.get(JOB_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setJobName(String jobName) throws InvalidValueException {
|
public void setJobName(String jobName) throws InvalidValueException {
|
||||||
setResourceProperty(JOB_NAME, jobName);
|
setResourceProperty(JOB_NAME, jobName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public Calendar getJobStartTime() {
|
public Calendar getJobStartTime() {
|
||||||
long millis = (Long) this.resourceProperties.get(JOB_START_TIME);
|
long millis = (Long) this.resourceProperties.get(JOB_START_TIME);
|
||||||
return timestampToCalendar(millis);
|
return timestampToCalendar(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setJobStartTime(Calendar jobStartTime) throws InvalidValueException {
|
public void setJobStartTime(Calendar jobStartTime) throws InvalidValueException {
|
||||||
setResourceProperty(JOB_START_TIME, jobStartTime.getTimeInMillis());
|
setResourceProperty(JOB_START_TIME, jobStartTime.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public Calendar getJobEndTime() {
|
public Calendar getJobEndTime() {
|
||||||
long millis = (Long) this.resourceProperties.get(JOB_END_TIME);
|
long millis = (Long) this.resourceProperties.get(JOB_END_TIME);
|
||||||
return timestampToCalendar(millis);
|
return timestampToCalendar(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setJobEndTime(Calendar jobEndTime) throws InvalidValueException {
|
public void setJobEndTime(Calendar jobEndTime) throws InvalidValueException {
|
||||||
setResourceProperty(JOB_END_TIME, jobEndTime.getTimeInMillis());
|
setResourceProperty(JOB_END_TIME, jobEndTime.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
@ -134,6 +145,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getDuration() throws InvalidValueException {
|
public long getDuration() throws InvalidValueException {
|
||||||
Long wallDuration = (Long) this.resourceProperties.get(DURATION);
|
Long wallDuration = (Long) this.resourceProperties.get(DURATION);
|
||||||
if(wallDuration == null){
|
if(wallDuration == null){
|
||||||
|
@ -145,6 +157,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
||||||
}
|
}
|
||||||
return wallDuration;
|
return wallDuration;
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
public void setDuration(Long duration) throws InvalidValueException {
|
public void setDuration(Long duration) throws InvalidValueException {
|
||||||
setResourceProperty(DURATION, duration);
|
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.NotEmpty;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*
|
*
|
||||||
|
@ -52,26 +54,32 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
|
||||||
return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getPortletId() {
|
public String getPortletId() {
|
||||||
return (String) this.resourceProperties.get(PORTLET_ID);
|
return (String) this.resourceProperties.get(PORTLET_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setPortletId(String portletId) throws InvalidValueException {
|
public void setPortletId(String portletId) throws InvalidValueException {
|
||||||
setResourceProperty(PORTLET_ID, portletId);
|
setResourceProperty(PORTLET_ID, portletId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getOperationId() {
|
public String getOperationId() {
|
||||||
return (String) this.resourceProperties.get(OPERATION_ID);
|
return (String) this.resourceProperties.get(OPERATION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setOperationId(String operationId) throws InvalidValueException {
|
public void setOperationId(String operationId) throws InvalidValueException {
|
||||||
setResourceProperty(OPERATION_ID, operationId);
|
setResourceProperty(OPERATION_ID, operationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return (String) this.resourceProperties.get(MESSAGE);
|
return (String) this.resourceProperties.get(MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setMessage(String message) throws InvalidValueException {
|
public void setMessage(String message) throws InvalidValueException {
|
||||||
setResourceProperty(MESSAGE, message);
|
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.NotEmpty;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
|
||||||
|
public class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* 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
|
* KEY for : hostname:port of the Hosting Node made the service call
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RequiredField @NotEmpty
|
@RequiredField @NotEmpty
|
||||||
public static final String CALLER_HOST = "callerHost";
|
public static final String CALLER_HOST = "callerHost";
|
||||||
|
|
||||||
|
@ -91,63 +94,76 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
protected String giveMeRecordType() {
|
protected String giveMeRecordType() {
|
||||||
return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getCallerHost() {
|
public String getCallerHost() {
|
||||||
return (String) this.resourceProperties.get(CALLER_HOST);
|
return (String) this.resourceProperties.get(CALLER_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setCallerHost(String callerHost) throws InvalidValueException {
|
public void setCallerHost(String callerHost) throws InvalidValueException {
|
||||||
setResourceProperty(CALLER_HOST, callerHost);
|
setResourceProperty(CALLER_HOST, callerHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return (String) this.resourceProperties.get(HOST);
|
return (String) this.resourceProperties.get(HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setHost(String host) throws InvalidValueException {
|
public void setHost(String host) throws InvalidValueException {
|
||||||
setResourceProperty(HOST, host);
|
setResourceProperty(HOST, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getServiceClass() {
|
public String getServiceClass() {
|
||||||
return (String) this.resourceProperties.get(SERVICE_CLASS);
|
return (String) this.resourceProperties.get(SERVICE_CLASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setServiceClass(String serviceClass) throws InvalidValueException {
|
public void setServiceClass(String serviceClass) throws InvalidValueException {
|
||||||
setResourceProperty(SERVICE_CLASS, serviceClass);
|
setResourceProperty(SERVICE_CLASS, serviceClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getServiceName() {
|
public String getServiceName() {
|
||||||
return (String) this.resourceProperties.get(SERVICE_NAME);
|
return (String) this.resourceProperties.get(SERVICE_NAME);
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
public void setServiceName(String serviceName) throws InvalidValueException {
|
public void setServiceName(String serviceName) throws InvalidValueException {
|
||||||
setResourceProperty(SERVICE_NAME, serviceName);
|
setResourceProperty(SERVICE_NAME, serviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getCalledMethod() {
|
public String getCalledMethod() {
|
||||||
return (String) this.resourceProperties.get(CALLED_METHOD);
|
return (String) this.resourceProperties.get(CALLED_METHOD);
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
public void setCalledMethod(String calledMethod) throws InvalidValueException {
|
public void setCalledMethod(String calledMethod) throws InvalidValueException {
|
||||||
setResourceProperty(CALLED_METHOD, calledMethod);
|
setResourceProperty(CALLED_METHOD, calledMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public Long getDuration() {
|
public Long getDuration() {
|
||||||
return (Long) this.resourceProperties.get(DURATION);
|
return (Long) this.resourceProperties.get(DURATION);
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
public void setDuration(Long duration) throws InvalidValueException {
|
public void setDuration(Long duration) throws InvalidValueException {
|
||||||
setResourceProperty(DURATION, duration);
|
setResourceProperty(DURATION, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Add a new field*/
|
@JsonIgnore
|
||||||
public String getCallerQualifier() {
|
public String getCallerQualifier() {
|
||||||
return (String) this.resourceProperties.get(CALLERQUALIFIER);
|
return (String) this.resourceProperties.get(CALLERQUALIFIER);
|
||||||
}
|
}
|
||||||
|
@JsonIgnore
|
||||||
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
||||||
setResourceProperty(CALLERQUALIFIER, callerQualifier);
|
setResourceProperty(CALLERQUALIFIER, callerQualifier);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,15 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
|
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.accounting.datamodel.validations.annotations.ValidURI;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
import org.gcube.documentstore.records.implementation.RequiredField;
|
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
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
|
* @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
|
* The value is a controlled dictionary by
|
||||||
* {@link #StorageStatusRecord.DataType}
|
* {@link #StorageStatusRecord.DataType}
|
||||||
*/
|
*/
|
||||||
@RequiredField @ValidDataType
|
@RequiredField @ValidDataTypeVolume
|
||||||
public static final String DATA_TYPE = "dataType";
|
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, "");
|
return AbstractStorageStatusRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getDataVolume() {
|
public long getDataVolume() {
|
||||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public DataType getDataType() {
|
public DataType getDataType() {
|
||||||
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataType(DataType dataType) throws InvalidValueException {
|
public void setDataType(DataType dataType) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_TYPE, dataType);
|
setResourceProperty(DATA_TYPE, dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getDataCount() {
|
public long getDataCount() {
|
||||||
return (Long) this.resourceProperties.get(DATA_COUNT);
|
return (Long) this.resourceProperties.get(DATA_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataCount(long dataCount) throws InvalidValueException {
|
public void setDataCount(long dataCount) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_COUNT, dataCount);
|
setResourceProperty(DATA_COUNT, dataCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getDataServiceClass() {
|
public String getDataServiceClass() {
|
||||||
return (String) this.resourceProperties.get(DATA_SERVICECLASS);
|
return (String) this.resourceProperties.get(DATA_SERVICECLASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataServiceClass(String dataServiceClass) throws InvalidValueException {
|
public void setDataServiceClass(String dataServiceClass) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_SERVICECLASS, dataServiceClass);
|
setResourceProperty(DATA_SERVICECLASS, dataServiceClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getDataServiceName() {
|
public String getDataServiceName() {
|
||||||
return (String) this.resourceProperties.get(DATA_SERVICENAME);
|
return (String) this.resourceProperties.get(DATA_SERVICENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataServiceName(String dataServiceName) throws InvalidValueException {
|
public void setDataServiceName(String dataServiceName) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_SERVICENAME, dataServiceName);
|
setResourceProperty(DATA_SERVICENAME, dataServiceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getDataServiceId() {
|
public String getDataServiceId() {
|
||||||
return (String) this.resourceProperties.get(DATA_SERVICEID);
|
return (String) this.resourceProperties.get(DATA_SERVICEID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataServiceId(String dataServiceId) throws InvalidValueException {
|
public void setDataServiceId(String dataServiceId) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_SERVICEID, dataServiceId);
|
setResourceProperty(DATA_SERVICEID, dataServiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public URI getProviderId() {
|
public URI getProviderId() {
|
||||||
return (URI) this.resourceProperties.get(PROVIDER_ID);
|
return (URI) this.resourceProperties.get(PROVIDER_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setProviderId(URI provideId) throws InvalidValueException {
|
public void setProviderId(URI provideId) throws InvalidValueException {
|
||||||
setResourceProperty(PROVIDER_ID, provideId);
|
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.NotEmptyIfNotNull;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @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 storage resource owner
|
||||||
* @return the identity id of the accounting owner
|
* @return the identity id of the accounting owner
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public String getResourceOwner() {
|
public String getResourceOwner() {
|
||||||
return (String) this.resourceProperties.get(RESOURCE_OWNER);
|
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
|
* @param owner the identity id of the storage resource owner
|
||||||
* @throws InvalidValueException
|
* @throws InvalidValueException
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public void setResourceOwner(String owner) throws InvalidValueException {
|
public void setResourceOwner(String owner) throws InvalidValueException {
|
||||||
setResourceProperty(RESOURCE_OWNER, owner);
|
setResourceProperty(RESOURCE_OWNER, owner);
|
||||||
}
|
}
|
||||||
|
@ -132,6 +136,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
||||||
* Return the scope of the storage resource
|
* Return the scope of the storage resource
|
||||||
* @return The scope id of the storage resource
|
* @return The scope id of the storage resource
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public String getResourceScope() {
|
public String getResourceScope() {
|
||||||
return (String) this.resourceProperties.get(RESOURCE_SCOPE);
|
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
|
* @param scope the scope of the storage resource
|
||||||
* @throws InvalidValueException
|
* @throws InvalidValueException
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public void setResourceScope(String scope) throws InvalidValueException {
|
public void setResourceScope(String scope) throws InvalidValueException {
|
||||||
setResourceProperty(RESOURCE_SCOPE, scope);
|
setResourceProperty(RESOURCE_SCOPE, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public URI getProviderURI() {
|
public URI getProviderURI() {
|
||||||
return (URI) this.resourceProperties.get(PROVIDER_URI);
|
return (URI) this.resourceProperties.get(PROVIDER_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setProviderURI(URI providerURI) throws InvalidValueException {
|
public void setProviderURI(URI providerURI) throws InvalidValueException {
|
||||||
setResourceProperty(PROVIDER_URI, providerURI);
|
setResourceProperty(PROVIDER_URI, providerURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public URI getResourceURI() {
|
public URI getResourceURI() {
|
||||||
return (URI) this.resourceProperties.get(RESOURCE_URI);
|
return (URI) this.resourceProperties.get(RESOURCE_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setResourceURI(URI resourceURI) throws InvalidValueException {
|
public void setResourceURI(URI resourceURI) throws InvalidValueException {
|
||||||
setResourceProperty(RESOURCE_URI, resourceURI);
|
setResourceProperty(RESOURCE_URI, resourceURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public OperationType getOperationType() {
|
public OperationType getOperationType() {
|
||||||
return (OperationType) this.resourceProperties.get(OPERATION_TYPE);
|
return (OperationType) this.resourceProperties.get(OPERATION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setOperationType(OperationType operationType) throws InvalidValueException {
|
public void setOperationType(OperationType operationType) throws InvalidValueException {
|
||||||
setResourceProperty(OPERATION_TYPE, operationType);
|
setResourceProperty(OPERATION_TYPE, operationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public DataType getDataType() {
|
public DataType getDataType() {
|
||||||
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataType(DataType dataType) throws InvalidValueException {
|
public void setDataType(DataType dataType) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_TYPE, dataType);
|
setResourceProperty(DATA_TYPE, dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getDataVolume() {
|
public long getDataVolume() {
|
||||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getQualifier() {
|
public String getQualifier() {
|
||||||
return (String) this.resourceProperties.get(QUALIFIER);
|
return (String) this.resourceProperties.get(QUALIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setQualifier(String qualifier) throws InvalidValueException {
|
public void setQualifier(String qualifier) throws InvalidValueException {
|
||||||
setResourceProperty(QUALIFIER, qualifier);
|
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.NotEmptyIfNotNull;
|
||||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +30,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -2208425042550641240L;
|
private static final long serialVersionUID = -2208425042550641240L;
|
||||||
|
|
||||||
|
|
||||||
@RequiredField @NotEmpty
|
@RequiredField @NotEmpty
|
||||||
public static final String TASK_ID = "taskId";
|
public static final String TASK_ID = "taskId";
|
||||||
@NotEmptyIfNotNull
|
@NotEmptyIfNotNull
|
||||||
|
@ -37,9 +41,9 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
@NotEmptyIfNotNull
|
@NotEmptyIfNotNull
|
||||||
public static final String REF_HOSTING_NODE_ID = "refHostingNodeId";
|
public static final String REF_HOSTING_NODE_ID = "refHostingNodeId";
|
||||||
|
|
||||||
@ValidLong
|
@ValidLong @RequiredField
|
||||||
public static final String TASK_START_TIME = "taskStartTime";
|
public static final String TASK_START_TIME = "taskStartTime";
|
||||||
@ValidLong
|
@ValidLong @RequiredField
|
||||||
public static final String TASK_END_TIME = "taskEndTime";
|
public static final String TASK_END_TIME = "taskEndTime";
|
||||||
|
|
||||||
@RequiredField @ComputedField(action=CalculateTaskWallDurationAction.class) @ValidLong
|
@RequiredField @ComputedField(action=CalculateTaskWallDurationAction.class) @ValidLong
|
||||||
|
@ -69,6 +73,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
/**
|
/**
|
||||||
* @return the Task Id
|
* @return the Task Id
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public String getTaskId() {
|
public String getTaskId() {
|
||||||
return (String) this.resourceProperties.get(TASK_ID);
|
return (String) this.resourceProperties.get(TASK_ID);
|
||||||
}
|
}
|
||||||
|
@ -77,6 +82,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
* @param taskId Task Id
|
* @param taskId Task Id
|
||||||
* @throws InvalidValueException if fails
|
* @throws InvalidValueException if fails
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public void setTaskId(String taskId) throws InvalidValueException {
|
public void setTaskId(String taskId) throws InvalidValueException {
|
||||||
setResourceProperty(TASK_ID, taskId);
|
setResourceProperty(TASK_ID, taskId);
|
||||||
}
|
}
|
||||||
|
@ -84,6 +90,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
/**
|
/**
|
||||||
* @return the Referenced Job Id
|
* @return the Referenced Job Id
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public String getRefJobId() {
|
public String getRefJobId() {
|
||||||
return (String) this.resourceProperties.get(REF_JOB_ID);
|
return (String) this.resourceProperties.get(REF_JOB_ID);
|
||||||
}
|
}
|
||||||
|
@ -92,40 +99,49 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
* @param refJobId Referenced Job Id
|
* @param refJobId Referenced Job Id
|
||||||
* @throws InvalidValueException if fails
|
* @throws InvalidValueException if fails
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
public void setRefJobId(String refJobId) throws InvalidValueException {
|
public void setRefJobId(String refJobId) throws InvalidValueException {
|
||||||
setResourceProperty(REF_JOB_ID, refJobId);
|
setResourceProperty(REF_JOB_ID, refJobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return (String) this.resourceProperties.get(HOST);
|
return (String) this.resourceProperties.get(HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setHost(String host) throws InvalidValueException {
|
public void setHost(String host) throws InvalidValueException {
|
||||||
setResourceProperty(HOST, host);
|
setResourceProperty(HOST, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getRefHostingNodeId() {
|
public String getRefHostingNodeId() {
|
||||||
return (String) this.resourceProperties.get(REF_HOSTING_NODE_ID);
|
return (String) this.resourceProperties.get(REF_HOSTING_NODE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setRefHostingNodeId(String refHostingNodeId) throws InvalidValueException {
|
public void setRefHostingNodeId(String refHostingNodeId) throws InvalidValueException {
|
||||||
setResourceProperty(REF_HOSTING_NODE_ID, refHostingNodeId);
|
setResourceProperty(REF_HOSTING_NODE_ID, refHostingNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public Calendar getTaskStartTime() {
|
public Calendar getTaskStartTime() {
|
||||||
long millis = (Long) this.resourceProperties.get(TASK_START_TIME);
|
long millis = (Long) this.resourceProperties.get(TASK_START_TIME);
|
||||||
return timestampToCalendar(millis);
|
return timestampToCalendar(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setTaskStartTime(Calendar startTime) throws InvalidValueException {
|
public void setTaskStartTime(Calendar startTime) throws InvalidValueException {
|
||||||
setResourceProperty(TASK_START_TIME, startTime.getTimeInMillis());
|
setResourceProperty(TASK_START_TIME, startTime.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public Calendar getTaskEndTime() {
|
public Calendar getTaskEndTime() {
|
||||||
long millis = (Long) this.resourceProperties.get(TASK_END_TIME);
|
long millis = (Long) this.resourceProperties.get(TASK_END_TIME);
|
||||||
return timestampToCalendar(millis);
|
return timestampToCalendar(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setTaskEndTime(Calendar endTime) throws InvalidValueException {
|
public void setTaskEndTime(Calendar endTime) throws InvalidValueException {
|
||||||
setResourceProperty(TASK_END_TIME, endTime.getTimeInMillis());
|
setResourceProperty(TASK_END_TIME, endTime.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
@ -142,6 +158,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public long getWallDuration() throws InvalidValueException {
|
public long getWallDuration() throws InvalidValueException {
|
||||||
Long wallDuration = (Long) this.resourceProperties.get(WALL_DURATION);
|
Long wallDuration = (Long) this.resourceProperties.get(WALL_DURATION);
|
||||||
if(wallDuration == null){
|
if(wallDuration == null){
|
||||||
|
@ -154,11 +171,19 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||||
return wallDuration;
|
return wallDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setWallDuration(Long duration) throws InvalidValueException {
|
||||||
|
setResourceProperty(WALL_DURATION, duration);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@JsonIgnore
|
||||||
public Map<String, Serializable> getInputParameters(){
|
public Map<String, Serializable> getInputParameters(){
|
||||||
return (HashMap<String, Serializable>) getResourceProperty(INPUT_PARAMETERS);
|
return (HashMap<String, Serializable>) getResourceProperty(INPUT_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public void setInputParameters(HashMap<String, Serializable> inputParameters) throws InvalidValueException{
|
public void setInputParameters(HashMap<String, Serializable> inputParameters) throws InvalidValueException{
|
||||||
setResourceProperty(INPUT_PARAMETERS, inputParameters);
|
setResourceProperty(INPUT_PARAMETERS, inputParameters);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
||||||
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
|
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="NotAggregateJobUsageRecord")
|
||||||
public class JobUsageRecord extends AbstractJobUsageRecord {
|
public class JobUsageRecord extends AbstractJobUsageRecord {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
||||||
import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord;
|
import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="NotAggregatePortletUsageRecord")
|
||||||
public class PortletUsageRecord extends AbstractPortletUsageRecord {
|
public class PortletUsageRecord extends AbstractPortletUsageRecord {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
||||||
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
|
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="NotAggregateServiceUsageRecord")
|
||||||
public class ServiceUsageRecord extends AbstractServiceUsageRecord {
|
public class ServiceUsageRecord extends AbstractServiceUsageRecord {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,10 +5,13 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
|
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
/**
|
/**
|
||||||
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="NotAggregateStorageStatusRecord")
|
||||||
public class StorageStatusRecord extends AbstractStorageStatusRecord {
|
public class StorageStatusRecord extends AbstractStorageStatusRecord {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
||||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="NotAggregateStorageUsageRecord")
|
||||||
public class StorageUsageRecord extends AbstractStorageUsageRecord {
|
public class StorageUsageRecord extends AbstractStorageUsageRecord {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,9 +6,12 @@ import java.util.Map;
|
||||||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@JsonTypeName(value="TaskUsageRecord")
|
||||||
public class TaskUsageRecord extends AbstractTaskUsageRecord {
|
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 java.io.Serializable;
|
||||||
|
|
||||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
|
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
|
||||||
|
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
import org.gcube.documentstore.records.Record;
|
import org.gcube.documentstore.records.Record;
|
||||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
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();
|
getAccountingPersistence().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class AccountingPersistenceFactory {
|
||||||
public static void initAccountingPackages(){
|
public static void initAccountingPackages(){
|
||||||
PersistenceBackendFactory.addRecordPackage(ServiceUsageRecord.class.getPackage());
|
PersistenceBackendFactory.addRecordPackage(ServiceUsageRecord.class.getPackage());
|
||||||
PersistenceBackendFactory.addRecordPackage(AggregatedServiceUsageRecord.class.getPackage());
|
PersistenceBackendFactory.addRecordPackage(AggregatedServiceUsageRecord.class.getPackage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -48,6 +49,7 @@ public class AccountingPersistenceFactory {
|
||||||
PersistenceBackendFactory.flushAll(timeout, timeUnit);
|
PersistenceBackendFactory.flushAll(timeout, timeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void shutDown(long timeout, TimeUnit timeUnit){
|
public static void shutDown(long timeout, TimeUnit timeUnit){
|
||||||
//flush all and shutdown connection and thread
|
//flush all and shutdown connection and thread
|
||||||
PersistenceBackendFactory.flushAll(timeout, timeUnit);
|
PersistenceBackendFactory.flushAll(timeout, timeUnit);
|
||||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.accounting.datamodel.aggregation;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecordTest;
|
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecordTest;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.accounting.datamodel.aggregation;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecordTest;
|
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecordTest;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
|
@ -5,7 +5,6 @@ package org.gcube.accounting.datamodel.aggregation;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord;
|
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecordTest;
|
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecordTest;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
import org.gcube.documentstore.exception.InvalidValueException;
|
||||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.accounting.datamodel.aggregation;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecordTest;
|
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecordTest;
|
||||||
import org.gcube.documentstore.exception.InvalidValueException;
|
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;
|
package org.gcube.testutility;
|
||||||
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
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.AccountingPersistence;
|
||||||
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.documentstore.records.DSMapper;
|
||||||
import org.gcube.documentstore.records.Record;
|
import org.gcube.documentstore.records.Record;
|
||||||
import org.gcube.documentstore.records.RecordUtility;
|
import org.gcube.documentstore.records.RecordUtility;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class MyTest {
|
public class MyTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MyTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(MyTest.class);
|
||||||
|
@ -35,39 +36,31 @@ public class MyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception{
|
public void testFull() throws Exception{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AccountingPersistence apq= AccountingPersistenceFactory.getPersistence();
|
AccountingPersistence apq= AccountingPersistenceFactory.getPersistence();
|
||||||
|
|
||||||
//Record record=TestUsageRecord.createTestServiceUsageRecord();
|
//Record record=TestUsageRecord.createTestServiceUsageRecord();//ok verificato
|
||||||
//Record record2=TestUsageRecord.createTestServiceUsageRecord();
|
//Record record=TestUsageRecord.createTestStorageUsageRecord();//ok verificato
|
||||||
|
//Record record=TestUsageRecord.createTestStorageVolumeUsageRecord();//ok verificato
|
||||||
|
//Record record=TestUsageRecord.createTestPortletUsageRecord();//ok verificato
|
||||||
Record record=TestUsageRecord.createTestStorageVolumeUsageRecord();
|
Record record=TestUsageRecord.createTestTaskUsageRecord();//ok verificato
|
||||||
|
//Record record=TestUsageRecord.createTestJobUsageRecord();//ok
|
||||||
logger.debug("----record:{}",record);
|
logger.debug("----record:{}",record);
|
||||||
apq.account(record);
|
apq.account(record);
|
||||||
//apq.account(record);
|
Thread.sleep(1500);
|
||||||
//apq.account(record2);
|
apq.flush(1500, TimeUnit.MILLISECONDS);
|
||||||
Thread.sleep(3000);
|
|
||||||
|
|
||||||
apq.flush(3000, TimeUnit.MILLISECONDS);
|
|
||||||
|
|
||||||
logger.debug("end flush");
|
logger.debug("end flush");
|
||||||
|
|
||||||
|
|
||||||
File elaborationFile = new File("/home/pieve/_gcube_devNext.fallback.log");
|
File elaborationFile = new File("/home/pieve/_gcube_devNext.fallback.log");
|
||||||
|
|
||||||
|
|
||||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
|
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
|
||||||
for(String line; (line = br.readLine()) != null; ) {
|
for(String line; (line = br.readLine()) != null; ) {
|
||||||
try {
|
try {
|
||||||
//Record r =DSMapper.unmarshal(Record.class, line);
|
//Record r =DSMapper.unmarshal(Record.class, line);
|
||||||
|
|
||||||
Record r = RecordUtility.getRecord( line);
|
Record r = RecordUtility.getRecord( line);
|
||||||
logger.debug("{}", r);
|
logger.debug("--record:{}", r);
|
||||||
|
|
||||||
} catch(Exception e){
|
} 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);
|
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) {
|
} catch (FileNotFoundException e) {
|
||||||
logger.error("File non trovato", e);
|
logger.error("File non trovato", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException ei) {
|
||||||
logger.error("IOException", e);
|
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,9 +3,19 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.testutility;
|
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.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)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
@ -13,11 +23,71 @@ import org.junit.Before;
|
||||||
*/
|
*/
|
||||||
public class ScopedTest {
|
public class ScopedTest {
|
||||||
|
|
||||||
@Before
|
|
||||||
public void before() throws Exception{
|
|
||||||
SecurityTokenProvider.instance.reset();
|
|
||||||
|
|
||||||
SecurityTokenProvider.instance.set("");
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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 {
|
try {
|
||||||
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
||||||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||||
|
|
||||||
usageRecord.setCallerHost(TEST_CALLER_HOST);
|
usageRecord.setCallerHost(TEST_CALLER_HOST);
|
||||||
usageRecord.setHost(TEST_HOST);
|
usageRecord.setHost(TEST_HOST);
|
||||||
usageRecord.setCallerQualifier(TEST_CALLER_QUALIFIER);
|
usageRecord.setCallerQualifier(TEST_CALLER_QUALIFIER);
|
||||||
|
@ -183,6 +182,7 @@ public class TestUsageRecord {
|
||||||
|
|
||||||
usageRecord.setJobId(TEST_JOB_ID);
|
usageRecord.setJobId(TEST_JOB_ID);
|
||||||
usageRecord.setJobName(TEST_JOB_NAME);
|
usageRecord.setJobName(TEST_JOB_NAME);
|
||||||
|
usageRecord.setJobQualifier("212505");
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
endTime.setTimeInMillis(startTime.getTimeInMillis() + HALF_DURATION);
|
endTime.setTimeInMillis(startTime.getTimeInMillis() + HALF_DURATION);
|
||||||
|
@ -209,7 +209,7 @@ public class TestUsageRecord {
|
||||||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||||
|
|
||||||
usageRecord.setTaskId(TEST_TASK_ID);
|
usageRecord.setTaskId(TEST_TASK_ID);
|
||||||
usageRecord.setTaskId(TEST_JOB_ID);
|
//usageRecord.setTaskId(TEST_JOB_ID);
|
||||||
usageRecord.setHost(TEST_HOST);
|
usageRecord.setHost(TEST_HOST);
|
||||||
|
|
||||||
usageRecord.setRefHostingNodeId(UUID.randomUUID().toString());
|
usageRecord.setRefHostingNodeId(UUID.randomUUID().toString());
|
||||||
|
@ -222,10 +222,14 @@ public class TestUsageRecord {
|
||||||
usageRecord.setTaskStartTime(startTime);
|
usageRecord.setTaskStartTime(startTime);
|
||||||
usageRecord.setTaskEndTime(endTime);
|
usageRecord.setTaskEndTime(endTime);
|
||||||
|
|
||||||
|
usageRecord.setResourceProperty("finalState", "DONE") ;
|
||||||
|
usageRecord.setResourceProperty("ESEMpio", "PLUTO") ;
|
||||||
|
|
||||||
HashMap<String, Serializable> inputParameters = new HashMap<>();
|
HashMap<String, Serializable> inputParameters = new HashMap<>();
|
||||||
inputParameters.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
inputParameters.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||||
inputParameters.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
inputParameters.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||||
|
|
||||||
|
|
||||||
HashMap<String, Serializable> parameter = new HashMap<>();
|
HashMap<String, Serializable> parameter = new HashMap<>();
|
||||||
parameter.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
parameter.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||||
parameter.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
parameter.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||||
|
@ -234,6 +238,7 @@ public class TestUsageRecord {
|
||||||
|
|
||||||
usageRecord.setInputParameters(inputParameters);
|
usageRecord.setInputParameters(inputParameters);
|
||||||
|
|
||||||
|
|
||||||
} catch (InvalidValueException e) {
|
} catch (InvalidValueException e) {
|
||||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", 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