package eu.dnetlib.contract.similarity.mocks;

import java.util.Collection;

import org.apache.log4j.Logger;

import pl.edu.icm.yadda.service2.exception.ServiceException;
import pl.edu.icm.yadda.service2.session.ISessionFacade;
import pl.edu.icm.yadda.service2.similarity.ISimilarityIndexFacade;
import pl.edu.icm.yadda.service2.similarity.SimilarityDocument;

/**
 * {@link ISimilarityIndexFacade} mock.
 * Actually does nothing, should be used as a plug.
 * @author mhorst
 *
 */
public class SimilarityIndexFacadeMock implements ISimilarityIndexFacade {

	/* (non-Javadoc)
	 * @see pl.edu.icm.yadda.service2.similarity.ISimilarityIndexFacade#connect(java.lang.String, java.lang.String)
	 */
	@Override
	public ISessionFacade<SimilarityDocument> connect(String arg0, String arg1)
			throws ServiceException {
//		does nothing
		return new ISessionFacade<SimilarityDocument>() {
			Logger log = Logger.getLogger(this.getClass());
			@Override
			public void add(Collection<SimilarityDocument> arg0)
					throws ServiceException {
				log.info("added documents count:" + 
						(arg0!=null?arg0.size():"0"));
			}
			@Override
			public void commit() throws ServiceException {
				log.info("operations commited!");
			}
			@Override
			public void delete(Collection<String> arg0) throws ServiceException {
				log.info("deleted documents count:" + 
						(arg0!=null?arg0.size():"0"));
			}
			@Override
			public void rollback() throws ServiceException {
				log.info("operations rolled back!");
			}
		};
	}

	/* (non-Javadoc)
    	 * @see pl.edu.icm.yadda.service2.similarity.ISimilarityIndexFacade#connect()
         */
	public ISessionFacade<SimilarityDocument> connect() throws ServiceException {
	    return null;
	}

	/* (non-Javadoc)
	 * @see pl.edu.icm.yadda.service2.similarity.ISimilarityIndexFacade#dropAllDocuments()
	 */
	@Override
	public void dropAllDocuments() throws ServiceException {
//		does nothing
	}

	/* (non-Javadoc)
	 * @see pl.edu.icm.yadda.service2.similarity.ISimilarityIndexFacade#dropDocuments(java.lang.String, java.lang.String)
	 */
	@Override
	public void dropDocuments(String arg0, String arg1) throws ServiceException {
//		does nothing
	}

	/* (non-Javadoc)
	 * @see pl.edu.icm.yadda.service2.IYaddaServiceFacade#checkVersion()
	 */
	@Override
	public void checkVersion() {
//		does nothing
	}

}
