package eu.dnetlib.functionality.webInterface.app;

import java.util.List;
import java.util.Map;
import java.util.Set;

import eu.dnetlib.domain.functionality.DocumentDescription;
import eu.dnetlib.domain.functionality.DocumentField;
import eu.dnetlib.domain.functionality.Searchable;
import eu.dnetlib.domain.functionality.WebInterfaceLayout;
import eu.dnetlib.domain.functionality.DocumentDescription.View;
import gr.uoa.di.webui.search.BrowseDataReader;
import gr.uoa.di.webui.search.CriteriaManager;
import gr.uoa.di.webui.search.DocumentReader;

public interface WebLayoutManager {

	/**
	 * Initialize the web interface layout manager. The lists returned by
	 * {@link #getDetailFields()}, {@link #getSearchFields()}, and
	 * {@link #getSummaryFields()} are also updated.
	 */
	public void init();

	/**
	 * Returns the web layout 
	 * @return
	 */
	public WebInterfaceLayout getLayout();

	/**
	 * Return all the {@link Searchable} searchables. The current layout is 
	 * specified by calling {@link #initialize(String)}.
	 *
	 * @return The detail fields, ordered by {@link Searchable#getDetailedRank()}
	 */
	public List<Searchable> getAllFields();
	
	/**
	 * Return all the {@link Searchable} searchables in the current layout where
	 * {@link Searchable#isInSearch()} returns <code>true</code>. The
	 * current layout is specified by calling {@link #initialize(String)}.
	 *
	 * @return The detail fields, ordered by {@link Searchable#getSearchRank()}
	 */
	public List<Searchable> getSearchFields();

	/**
	 * Return all the {@link Searchable} searchables in the current layout where
	 * {@link Searchable#isInRefine()} returns <code>true</code>. The
	 * current layout is specified by calling {@link #initialize(String)}.
	 *
	 * @return The detail fields, ordered by {@link Searchable#getSearchRank()}
	 */
	public List<Searchable> getRefineFields();

	/**
	 * Return all the {@link DocumentField} document fields in the current layout
	 * that are defined in {@link DocumentDescription}}.
	 *
	 * @return All the fields used to describe documents
	 */
	public List<DocumentField> getResultFields();
	
	/**
	 * Return all the {@link Searchable} searchables in the current layout. The
	 * current layout is specified by calling {@link #initialize(String)}.
	 *
	 * @return All searchables specified in web interface layout
	 */
	public Map<String, Searchable> getLabelMap();

	/**
	 * Return all the {@link Searchable} searchables in the current layout. The
	 * current layout is specified by calling {@link #initialize(String)}. The 
	 * key is the index type 
	 *
	 * @return All searchables specified in web interface layout
	 */	
	public Map<String, Searchable> getIndexMap();
	
	/**
	 * Return all vocabulary names that are needed by {@link CriteriaManager} CriteriaManager.
	 * The current layout is specified by calling {@link #initialize(String)}.
	 * @return
	 */
	public Map<String,String> getSearchVocabularies();
	
	/**
	 * Return all vocabulary names that are needed by {@link BrowseDataReader} BrowseDataReader.
	 * The current layout is specified by calling {@link #initialize(String)}.
	 * @return
	 */
	public Map<String,String> getBrowseVocabularies();
	
	/**
	 * Return all vocabulary names that are needed by {@link DocumentReader} DocumentReader.
	 * The current layout is specified by calling {@link #initialize(String)}.
	 * @return
	 */
	public Map<String,String> getDocumentFieldVocabularies();
	
	/**
	 * Return the DocumentDescription {@link DocumentDescription} with
	 * the given View {@link View}. If a DocumentDescription of the given
	 * View does not exist, the DocumentDescription with SUMMARY_VIEW is 
	 * returned
	 * @param view The given View{@link View}
	 * 
	 * @return {@link DocumentDescription}
	 */
	public DocumentDescription getDescription(View view);
	
	public List<Searchable> getBrowseFields();
	
	public Set<String> getVocabularyResults();

}

