package eu.dnetlib.data.information;

import javax.xml.ws.wsaddressing.W3CEndpointReference;

import eu.dnetlib.data.information.DataSink;
import eu.dnetlib.data.mdstore.IMDStoreService;

/**
 * Mdstore data sink implementation.
 *
 * @author jochen, marko
 *
 */
public class MDStoreDataSinkImpl implements DataSink {

	private IMDStoreService mdStoreService;
	private String mdId;
	private String storingType;

	public void setMdStore(final IMDStoreService mdStoreService, final String mdId, final String storingType){
		this.mdStoreService = mdStoreService;
		this.mdId = mdId;
		this.storingType = storingType;
	}

	@Override
	public void store(final W3CEndpointReference rsEpr) throws DataSinkSourceException {
		try{
			mdStoreService.storeMDRecordsFromRS(mdId, rsEpr, storingType);			
		}catch(Exception e){
			throw new DataSinkSourceException(e);
		}
	}

	protected IMDStoreService getMdStoreService() {
		return mdStoreService;
	}

	protected void setMdStoreService(IMDStoreService mdStoreService) {
		this.mdStoreService = mdStoreService;
	}

	public String getMdId() {
		return mdId;
	}

	public void setMdId(String mdId) {
		this.mdId = mdId;
	}

	protected String getStoringType() {
		return storingType;
	}

	protected void setStoringType(String storingType) {
		this.storingType = storingType;
	}

}
