2017-09-05 17:13:50 +02:00
|
|
|
package org.gcube.accounting.aggregator.persist;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
2024-02-06 12:31:38 +01:00
|
|
|
import org.gcube.accounting.aggregator.persistence.AggregatorPersistenceFactory;
|
|
|
|
import org.gcube.accounting.aggregator.persistence.AggregatorPersistenceSrc;
|
2017-09-05 17:13:50 +02:00
|
|
|
import org.gcube.accounting.aggregator.status.AggregationState;
|
|
|
|
import org.gcube.accounting.aggregator.status.AggregationStatus;
|
2021-05-06 13:13:30 +02:00
|
|
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
import org.gcube.documentstore.records.DSMapper;
|
2017-09-05 17:13:50 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
|
|
|
public class DeleteDocument extends DocumentElaboration {
|
|
|
|
|
2021-05-06 13:13:30 +02:00
|
|
|
public DeleteDocument(AggregationStatus aggregationStatus, File file){
|
|
|
|
super(aggregationStatus, AggregationState.DELETED, file, aggregationStatus.getOriginalRecordsNumber());
|
2017-09-05 17:13:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void elaborateLine(String line) throws Exception {
|
2021-05-06 13:13:30 +02:00
|
|
|
JsonNode jsonNode = DSMapper.asJsonNode(line);
|
|
|
|
String id = jsonNode.get(ID).asText();
|
2021-11-08 14:57:35 +01:00
|
|
|
logger.trace("Going to delete record with id {}", id);
|
2024-02-06 12:31:38 +01:00
|
|
|
AggregatorPersistenceSrc aggregatorPersistenceSrc = AggregatorPersistenceFactory.getAggregatorPersistenceSrc();
|
|
|
|
aggregatorPersistenceSrc.deleteRecord(jsonNode);
|
2017-09-05 17:13:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void afterElaboration() {
|
|
|
|
// Nothing to do
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|