package eu.dnetlib.client.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.google.inject.Singleton;

import eu.dnetlib.efg1914.authoring.components.Archive;
import eu.dnetlib.efg1914.authoring.components.Configuration;
import eu.dnetlib.efg1914.authoring.components.DeletedComponent;
import eu.dnetlib.efg1914.authoring.components.Frame;
import eu.dnetlib.efg1914.authoring.components.Item;
import eu.dnetlib.efg1914.authoring.components.Permit;
import eu.dnetlib.efg1914.authoring.components.Theme;
import eu.dnetlib.efg1914.authoring.components.Topic;
import eu.dnetlib.efg1914.authoring.users.User;

@SuppressWarnings("serial")
@Singleton
public class StartUpComponents implements Serializable {

	private String serverPath;
	private String previewPage;
	 
	private Integer reloadTime;
	private  HashMap<String, Item> allItems = new HashMap<String, Item>();
	private HashMap<String, Frame> allFrames = new HashMap<String, Frame>();
	private HashMap<String, Topic> allTopics = new HashMap<String, Topic>();
	private HashMap<String, Theme> allThemes = new HashMap<String, Theme>();
	private HashMap<String, String> curators = new HashMap<String, String>();
	private HashMap<String, Archive> archives = new HashMap<String, Archive>();
	private HashMap<String, Permit> Permissions = new HashMap<String, Permit>();
	private List<DeletedComponent> deletedComponents= new ArrayList<DeletedComponent>();  
	private HashMap<String, String> aliasIds = new HashMap<String,String>();

	private User user;
 	private Configuration configuration = new Configuration();
 	private ArrayList<String> myLockedComponentList=new ArrayList<String>();
 	public StartUpComponents() {
	};

	// TODO SOS SOS add syncronized to getters and setters

	public void clearLists() {
		this.allFrames.clear();
		this.allTopics.clear();
		this.allItems.clear();
		this.allThemes.clear();

		this.archives.clear();
		this.curators.clear();
		this.Permissions.clear();

		System.gc();
		System.gc();

	}

	public String getServerPath() {
		return serverPath;
	}

	public void setServerPath(String serverPath) {
		this.serverPath = serverPath;
	}

	 
	public synchronized  HashMap<String, Item> getAllItems() {
		return allItems;
	}

	public synchronized void setAllItems(HashMap<String, Item> allItems) {
		this.allItems = allItems;
	}

	public HashMap<String, Frame> getAllFrames() {
		return allFrames;
	}

	public void setAllFrames(HashMap<String, Frame> allFrames) {
		this.allFrames = allFrames;
	}

	public HashMap<String, Topic> getAllTopics() {
		return allTopics;
	}

	public void setAllTopics(HashMap<String, Topic> allTopics) {
		this.allTopics = allTopics;
	}

	public HashMap<String, Theme> getAllThemes() {
		return allThemes;
	}

	public void setAllThemes(HashMap<String, Theme> allThemes) {
		this.allThemes = allThemes;
	}

	public HashMap<String, Archive> getArchives() {
		return archives;
	}

	public void setArchives(HashMap<String, Archive> archives) {
		this.archives = archives;
	}

	public HashMap<String, String> getCurators() {
		return curators;
	}

	public void setCurators(HashMap<String, String> curators) {
		this.curators = curators;
 	} 
 
	// public SortedSet<Entry<String, Archive>> getArchives() {
	// return archives;
	// }
	//
	// public void setArchives(HashMap<String, Archive> archives) {
	// this.archives.clear();
	// this.archives.addAll(archives.entrySet());
	// }
	//
	// public SortedSet<Entry<String, String>> getCurators() {
	// return curators;
	// }
	//
	// public void setCurators(HashMap<String, String> curators) {
	// this.curators.clear();
	// this.curators.addAll(curators.entrySet());
	// }

	public User getUser() {
		return user;
	}

	public void setUser(User user) {

		this.user = user;

	}

	public HashMap<String, Permit> getPermissions() {
		return Permissions;
	}

	public void setPermissions(HashMap<String, Permit> permissions) {
		Permissions = permissions;
	}
 

	public Configuration getConfiguration() {
		return configuration;
	}

	public void setConfiguration(Configuration configuration) {
		this.configuration = configuration;
	}

	public List<DeletedComponent> getDeletedComponents() {
		return deletedComponents;
	}

	public void setDeletedComponents(List<DeletedComponent> deletedComponents) {
		this.deletedComponents = deletedComponents;
	}

	public Integer getReloadTime() {
		return reloadTime;
	}

	public void setReloadTime(Integer reloadTime) {
		this.reloadTime = reloadTime;
	}

	public String getPreviewPage() {
		return previewPage;
	}

	public void setPreviewPage(String previewPage) {
		this.previewPage = previewPage;
	}

 

	public ArrayList<String> getMyLockedComponentList() {
		return myLockedComponentList;
	}

	public void setMyLockedComponentList(ArrayList<String> myLockedComponentList) {
		this.myLockedComponentList = myLockedComponentList;
	}

	public HashMap<String, String> getAliasIds() {
		return aliasIds;
	}

	public void setAliasIds(HashMap<String, String> aliasIds) {
		this.aliasIds = aliasIds;
	}
	
}
