package eu.dnetlib.clients.data.espas;

import eu.dnetlib.api.data.espas.DataProviderService;
import eu.dnetlib.clients.ws.DriverWebService;
import eu.dnetlib.domain.data.espas.HarvestHistory;
import eu.dnetlib.domain.data.espas.HarvestSchedule;

import javax.jws.WebMethod;
import javax.jws.WebService;
import java.util.Date;
import java.util.List;

/**
 * Created by antleb on 6/23/14.
 */

@WebService
public interface DataProviderWebService extends DriverWebService<DataProviderService> {

	/**
	 * Starts a harvesting process (for full description @see  <code>{@link eu.dnetlib.api.data.espas.DataProviderService#harvest(java.util.List, java.util.Date, java.util.Date, String)}</code>)
	 */
	@WebMethod(operationName = "harvest")
	public void harvest(List<String> types, Date dateFrom, Date dateTo, String dataProviderId) throws DataProviderWebServiceException;

	/**
	 * Schedules a periodic harvesting process. (for full description @see  <code>{@link eu.dnetlib.api.data.espas.DataProviderService#scheduleHarvest(java.util.List, java.util.Date, String, String)}</code>)
	 */
	@WebMethod(operationName = "scheduleHarvest")
	public String scheduleHarvest(List<String> types, Date initialModificationDate, String dataProviderId,
								  String cronExpression) throws DataProviderWebServiceException;

	/**
	 * Updates an existing schedule of a harvesting process. (for full description @see <code>{@link eu.dnetlib.api.data.espas.DataProviderService#updateHarvestSchedule(String, java.util.List, String, String)}</code>)
	 */
	@WebMethod(operationName = "updateHarvestSchedule")
	public void updateHarvestSchedule(String scheduleId, List<String> types, String dataProviderId, String cronExpression) throws DataProviderWebServiceException;

	/**
	 * Cancels the scheduling and deletes a harvesting process. (for full description @see <code>{@link eu.dnetlib.api.data.espas.DataProviderService#cancelHarvestSchedule(String)}</code>)
	 */
	@WebMethod(operationName = "cancelHarvestSchedule")
	public void cancelHarvestSchedule(String scheduleId) throws DataProviderWebServiceException;

	/**
	 * Pauses the harvesting process without deleting it from the service (for full description @see <code>{@link eu.dnetlib.api.data.espas.DataProviderService#pauseHarvestSchedule(String)}</code>)
	 */
	@WebMethod(operationName = "pauseHarvestSchedule")
	public void pauseHarvestSchedule(String scheduleId) throws DataProviderWebServiceException;

	/**
	 * Resumes a previously paused harvesting process (for full description @see <code>{@link eu.dnetlib.api.data.espas.DataProviderService#resumeHarvestSchedule(String)}</code>)
	 */
	@WebMethod(operationName = "resumeHarvestSchedule")
	public void resumeHarvestSchedule(String scheduleId) throws DataProviderWebServiceException;

	/**
	 * Returns all the scheduled harvesting process for a data provider (for full description @see  {@link eu.dnetlib.api.data.espas.DataProviderService#getHarvestSchedules(String)})
	 */
	@WebMethod(operationName = "getHarvestSchedules")
	public List<HarvestSchedule> getHarvestSchedules(String dataProviderId) throws DataProviderWebServiceException;

	/**
	 * Returns the history of all harvesting process that have been executed for a data provider. (for full description @see  {@link eu.dnetlib.api.data.espas.DataProviderService#getHarvestHistory(String)})
	 */
	@WebMethod(operationName = "getHarvestHistory")
	public List<HarvestHistory> getHarvestHistory(String dataProviderId) throws DataProviderWebServiceException;

	/**
	 * Removes the history of all harvesting process that have been executed for a data provider for a given period. (for full description @see  {@link eu.dnetlib.api.data.espas.DataProviderService#deleteHarvestHistory(String, java.util.Date, java.util.Date)})
	 */
	@WebMethod(operationName = "deleteHarvestHistoryByDates")
	public void deleteHarvestHistory(String dataProviderId, Date from, Date to) throws DataProviderWebServiceException;

	/**
	 * Removes the history of harvesting processes that have been executed. (for full description @see  {@link eu.dnetlib.api.data.espas.DataProviderService#deleteHarvestHistory(java.util.List)})
	 */
	@WebMethod(operationName = "deleteHarvestHistoryById")
	public void deleteHarvestHistory(List<String> harvestIds) throws DataProviderWebServiceException;
}