refs #3253: Couchdb does not support documents with object key starting with _

https://support.d4science.org/issues/3253

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@128059 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-04-13 14:44:22 +00:00
parent c9a03adfac
commit 7c07bee695
11 changed files with 100 additions and 7 deletions

View File

@ -18,7 +18,7 @@ public class MoveToConsumerIdAction implements FieldAction {
NotEmptyIfNotNullValidator neinnv = new NotEmptyIfNotNullValidator();
value = neinnv.validate(key, value, record);
record.setResourceProperty(UsageRecord.CONSUMER_ID, (String) value);
return null;
return null; //Returning null the initial key is removed from Record
}
}

View File

@ -0,0 +1,16 @@
/**
*
*/
package org.gcube.accounting.datamodel.backwardcompatibility;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@FieldDecorator(action=MoveToJobWallDurationAction.class)
public @interface MoveToJobWallDuration { }

View File

@ -0,0 +1,24 @@
/**
*
*/
package org.gcube.accounting.datamodel.backwardcompatibility;
import java.io.Serializable;
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.Record;
import org.gcube.documentstore.records.implementation.FieldAction;
import org.gcube.documentstore.records.implementation.validations.validators.NotEmptyIfNotNullValidator;
public class MoveToJobWallDurationAction implements FieldAction {
@Override
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
NotEmptyIfNotNullValidator neinnv = new NotEmptyIfNotNullValidator();
value = neinnv.validate(key, value, record);
record.setResourceProperty(JobUsageRecord.WALL_DURATION, (String) value);
return null; //Returning null the initial key is removed from Record
}
}

View File

@ -26,7 +26,7 @@ public class MoveToOperationResultAction implements FieldAction {
ValidOperationResultValidator vorv = new ValidOperationResultValidator();
value = vorv.validate(key, value, record);
record.setResourceProperty(UsageRecord.OPERATION_RESULT, (OperationResult) value);
return null;
return null; //Returning null the initial key is removed from Record
}
}

View File

@ -16,7 +16,7 @@ public class MoveToRecordTypeAction implements FieldAction {
if(value instanceof String && value!= null && !((String) value).isEmpty()){
record.setResourceProperty(Record.RECORD_TYPE, value);
}
return null;
return null; //Returning null the initial key is removed from Record
}
}

View File

@ -24,7 +24,7 @@ public class MoveToTaskEndTimeAction implements FieldAction {
Serializable value, Record record)
throws InvalidValueException {
record.setResourceProperty(AbstractTaskUsageRecord.TASK_END_TIME, value);
return null;
return null; //Returning null the initial key is removed from Record
}
}

View File

@ -24,7 +24,7 @@ public class MoveToTaskStartTimeAction implements FieldAction {
Serializable value, Record record)
throws InvalidValueException {
record.setResourceProperty(AbstractTaskUsageRecord.TASK_START_TIME, value);
return null;
return null; //Returning null the initial key is removed from Record
}
}

View File

@ -0,0 +1,16 @@
/**
*
*/
package org.gcube.accounting.datamodel.backwardcompatibility;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@FieldDecorator(action=MoveToTaskWallDurationAction.class)
public @interface MoveToTaskWallDuration { }

View File

@ -0,0 +1,24 @@
/**
*
*/
package org.gcube.accounting.datamodel.backwardcompatibility;
import java.io.Serializable;
import org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.Record;
import org.gcube.documentstore.records.implementation.FieldAction;
import org.gcube.documentstore.records.implementation.validations.validators.NotEmptyIfNotNullValidator;
public class MoveToTaskWallDurationAction implements FieldAction {
@Override
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
NotEmptyIfNotNullValidator neinnv = new NotEmptyIfNotNullValidator();
value = neinnv.validate(key, value, record);
record.setResourceProperty(TaskUsageRecord.WALL_DURATION, (String) value);
return null; //Returning null the initial key is removed from Record
}
}

View File

@ -8,6 +8,8 @@ import java.util.Calendar;
import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToJobWallDuration;
import org.gcube.accounting.datamodel.deprecationmanagement.DeprecatedWarning;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.ComputedField;
import org.gcube.documentstore.records.implementation.RequiredField;
@ -38,8 +40,12 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
public static final String JOB_START_TIME = "jobStartTime";
@ValidLong
public static final String JOB_END_TIME = "jobEndTime";
@DeprecatedWarning @MoveToJobWallDuration
protected static final String _WALL_DURATION = "_wallDuration";
@RequiredField @ComputedField(action=CalculateJobWallDurationAction.class) @ValidLong
public static final String WALL_DURATION = "_wallDuration";
public static final String WALL_DURATION = "wallDuration";
public AbstractJobUsageRecord(){
super();

View File

@ -9,6 +9,9 @@ import java.util.HashMap;
import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToConsumerId;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToTaskWallDuration;
import org.gcube.accounting.datamodel.deprecationmanagement.DeprecatedWarning;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.ComputedField;
import org.gcube.documentstore.records.implementation.RequiredField;
@ -41,8 +44,12 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
public static final String TASK_START_TIME = "taskStartTime";
@ValidLong
public static final String TASK_END_TIME = "taskEndTime";
@DeprecatedWarning @MoveToTaskWallDuration
protected static final String _WALL_DURATION = "_wallDuration";
@RequiredField @ComputedField(action=CalculateTaskWallDurationAction.class) @ValidLong
public static final String WALL_DURATION = "_wallDuration";
public static final String WALL_DURATION = "wallDuration";