2018-05-11 17:50:37 +02:00
|
|
|
package org.gcube.dataharvest.harvester;
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
2018-09-04 11:13:16 +02:00
|
|
|
import java.time.Instant;
|
|
|
|
import java.util.Calendar;
|
2018-05-11 17:50:37 +02:00
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
|
2018-09-04 11:13:16 +02:00
|
|
|
import org.gcube.accounting.accounting.summary.access.model.internal.Dimension;
|
|
|
|
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
|
2018-05-11 17:50:37 +02:00
|
|
|
import org.gcube.common.authorization.client.Constants;
|
|
|
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
2019-12-03 16:46:46 +01:00
|
|
|
import org.gcube.dataharvest.AccountingDashboardHarvesterPlugin;
|
2018-09-04 11:13:16 +02:00
|
|
|
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
2018-05-28 15:22:59 +02:00
|
|
|
import org.gcube.dataharvest.utils.DateUtils;
|
2018-05-11 17:50:37 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-05-18 12:00:10 +02:00
|
|
|
public abstract class BasicHarvester {
|
2018-05-17 17:21:08 +02:00
|
|
|
|
2018-05-11 17:50:37 +02:00
|
|
|
private static Logger logger = LoggerFactory.getLogger(BasicHarvester.class);
|
2018-05-17 17:21:08 +02:00
|
|
|
|
2018-09-04 11:13:16 +02:00
|
|
|
protected final Date start;
|
|
|
|
protected final Date end;
|
|
|
|
protected final Instant instant;
|
2018-05-17 17:21:08 +02:00
|
|
|
|
2018-05-11 17:50:37 +02:00
|
|
|
public BasicHarvester(Date start, Date end) throws ParseException {
|
2018-05-28 15:22:59 +02:00
|
|
|
this.start = start;
|
|
|
|
this.end = end;
|
|
|
|
|
2018-09-04 11:13:16 +02:00
|
|
|
Calendar toSetOnDB = DateUtils.dateToCalendar(start);
|
|
|
|
toSetOnDB.add(Calendar.DAY_OF_MONTH, 15);
|
|
|
|
instant = toSetOnDB.toInstant();
|
|
|
|
|
2018-05-28 15:22:59 +02:00
|
|
|
logger.debug("Creating {} for the period {} {} ", this.getClass().getSimpleName(), DateUtils.format(start), DateUtils.format(end));
|
2018-05-11 17:50:37 +02:00
|
|
|
}
|
2018-05-18 14:17:54 +02:00
|
|
|
|
2018-09-04 11:13:16 +02:00
|
|
|
public abstract List<AccountingRecord> getAccountingRecords() throws Exception;
|
|
|
|
|
|
|
|
public Dimension getDimension(HarvestedDataKey harvestedDataKey) {
|
2019-12-03 16:46:46 +01:00
|
|
|
return AccountingDashboardHarvesterPlugin.getDimension(harvestedDataKey.getKey());
|
2018-09-04 11:13:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-11 17:50:37 +02:00
|
|
|
|
|
|
|
}
|