package eu.dnetlib.r2d2.neo4j;

import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface BeanDao<B extends Neo4jBean> {
	
	@Transactional
	public void init();
	
	public B newBean();
	
	public B newBean(String id);

	public void deleteBean(String beanId);

	public B getBean(String beanId);
	
	/**
	 * Returns the type of bean with the given id
	 * @param beanId the id of the bean
	 * @return The class of the bean with the given Id, null if bean with the 
	 * given id exists
	 * 
	 * @throws ClassNotFoundException, if the property Neo4jBean.Prefix of the 
	 * node 
	 */
	public Class<? extends Neo4jBean> getNodeType(String beanId);
	
	public boolean beanExists(String id);

	@Deprecated
	public String saveBean(B bean);

	public Iterable<B> search(String term);

	public Iterable<B> search(String term, String... fields);

	public Iterable<B> getAll();
	
	public SearchResults<B> search(int from, int size, String term);
	
	public SearchResults<B> search(int from, int size, String term, String... fields);
	
	public SearchResults<B> getAll(int from, int size);
}