2015-06-09 14:03:59 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-12-01 14:37:23 +01:00
|
|
|
package org.gcube.accounting.datamodel.backwardcompatibility;
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
|
|
import org.gcube.accounting.datamodel.UsageRecord;
|
|
|
|
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
|
|
|
import org.gcube.accounting.datamodel.validations.validators.ValidOperationResultValidator;
|
2015-12-18 17:09:05 +01:00
|
|
|
import org.gcube.documentstore.exception.InvalidValueException;
|
2015-12-21 11:50:09 +01:00
|
|
|
import org.gcube.documentstore.records.Record;
|
|
|
|
import org.gcube.documentstore.records.implementation.FieldAction;
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
/**
|
2016-10-12 14:15:28 +02:00
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
2015-06-09 14:03:59 +02:00
|
|
|
*
|
|
|
|
*/
|
2015-06-09 17:36:38 +02:00
|
|
|
public class MoveToOperationResultAction implements FieldAction {
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2016-01-28 18:29:11 +01:00
|
|
|
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
2015-06-09 14:03:59 +02:00
|
|
|
ValidOperationResultValidator vorv = new ValidOperationResultValidator();
|
2015-12-21 11:50:09 +01:00
|
|
|
value = vorv.validate(key, value, record);
|
|
|
|
record.setResourceProperty(UsageRecord.OPERATION_RESULT, (OperationResult) value);
|
2016-04-13 16:44:22 +02:00
|
|
|
return null; //Returning null the initial key is removed from Record
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|