package authoritymanager.client;

public class ClientConfiguration {
	public static final String PERSON_TAG		=	"Person" ;
	public static final String MOVIE_TAG		=	"Movie" ;
	public static final String CORPORATION_TAG	=	"Corporate body" ;
	public static final String ITEM_TAG			=	"Digital item" ;
	
	private static final String[] itemTypes = { 
		MOVIE_TAG, PERSON_TAG, CORPORATION_TAG, ITEM_TAG
	} ;
	private static final String [][] idTag = {
		{MOVIE_TAG, "avcreation"}, {PERSON_TAG, "person"},
		{CORPORATION_TAG, "corporate"}, {ITEM_TAG, "nonavcreation"}
	} ;
	private static final String[][][] searchView = { 
		{ {MOVIE_TAG, "efgIdentifier"}, {"List Film Titles which:label:$:$:newline",
			"$:listbox{" + Query.BEGINS_WITH + ", " + Query.CONTAINS + "}:" + Query.RELATIONSHIP + ":name:sameline",
			"$:editbox:efgTitle/efgTitleText:name:sameline"},
			{"List Film Items from provider:label:$:$:newline",
			"$:listbox{" + Query.ANY + ", DIF, DFI}:efgRecordSource/efgRecordSourceProvider:provider:sameline"} },
		{ {PERSON_TAG, "efgIdentifier"}, {"List Person Names with name which:label:$:$:newline",
			"$:listbox{" + Query.BEGINS_WITH + ", " + Query.CONTAINS + "}:" + Query.RELATIONSHIP + ":name:sameline",
			"$:editbox:efgPersonForename OR efgPersonSurname:name:sameline"} },
		{ {CORPORATION_TAG, "efgIdentifier"}, {"List Corporate Bodies with name which:label:$:$:newline",
			"$:listbox{" + Query.BEGINS_WITH + ", " + Query.CONTAINS + "}:" + Query.RELATIONSHIP + ":name:sameline",
			"$:editbox:efgName/efgNameText:name:sameline"} },
		{ {ITEM_TAG, "efgIdentifier"}, {"List Non-Film Items with title which:label:none",
			"$:listbox{" + Query.BEGINS_WITH + ", " + Query.CONTAINS + "}:" + Query.RELATIONSHIP + ":name:newline",
			"$:editbox:title:sameline",
			"$:listbox{IMAGE, TEXT, SOUND, OTHER}:type:sameline",
			"List all Non-Film Items from provider:label:none:newline",
			"$:listbox{" + Query.ANY + ", DIF, DFI}:efgRecordSource/efgRecordSourceProvider:sameline" } }				
	} ;
	private static final String[][][] searchResults = { 
		{ {MOVIE_TAG, "efgIdentifier"}, 
				{"efgIdentifier", "efgCountryOfReference", "efgTitle"} },
		{ {PERSON_TAG, "efgIdentifier"}, 
				{"efgIdentifier", "efgPersonForename", "efgPersonSurname", "efgTypeOfActivity"} },
		{ {CORPORATION_TAG, "efgIdentifier"}, 
				{"efgIdentifier", "efgName", "efgTypeOfActivity"} },
		{ {ITEM_TAG, "efgIdentifier"}, {} }
	} ;
	
	private static final String[][][] searchBasicView = {		
		{{MOVIE_TAG, "efgIdentifier"}, {"efgTitle.efgTitleText:Title:240px", 
			"efgTitle.efgTitleRelation:Title type:90px", 
			"efgCountryOfReference:Country:60px", 
			"efgProductionYear:Year:60px", 
		 	"type:Category:90px"}},		
		{{PERSON_TAG, "efgIdentifier"}, {"efgPersonForename:Forename:120px", 
			 "efgPersonSurname:Surname:160px", 
			 "efgTypeOfActivity:Activity:60px", 
			 "efgProductionYear:Year:60px", 
			 "type:Category:90px"}},
		{{CORPORATION_TAG, "efgIdentifier"}, {"name:Name", "regionbase:Based in", 
			"region:Country"}}
	} ;
	
	private static final String[][][] searchDetailsView = {
		{{MOVIE_TAG}, {"EFG ID:#$efgIdentifier#\n#@efgRecordSource#Record provider:#", 
			"$efgRecordSourceProvider#\n#Local ID:#$efgRecordSourceID#@#\n#\n#",
			"@efgTitle#$efgTitleText# (#$efgTitleRelation#)#@#\n#\n#",
			"@efgAvManifestation#$efgAvManifestationType#\n#$",
			"$efgAvManifestationDuration#  #$efgAvManifestationLanguage#  #",
			"$efgAvManifestationIdentifier#@#\n#\n#",
			"@efgNote#Notes#\n#$noteText#\n#"}},
		{{PERSON_TAG}, {}},
		{{CORPORATION_TAG}, {}}
	} ;
	
	private static final String [] [] [] insertView = {
		{ 
			{MOVIE_TAG, "efgIdentifier"}, {
				"*.vpanel{ " +
				"	*.hpanel{ *.label.Title.220, *.label.Title type.120, *.label.Language.120, *.label.Time.120, *.label.Region.120 }.*.*," +
				"   efgTitle.+{ efgTitleText.edit.*.220, efgTitleRelation.list{url://langrel.txt}.*.120, " +
				"				efgTitleLang.list{url://lang.txt}.*.120," +
				"				efgTitleTime.edit.*.120," +
				"			    efgTitleGeographicScope.hpanel{efgTitleGeographicScopePlace.edit.*.120}.*.120 " +
				"	}.*.*, " +
				"   efgKeywords.+{*.label.Keywords:.100, keywordsTerm.hpanel{keywordsTermText.edit.*.160}.*.160, " +
				"                 *.label.Language:.100, keywordsLang.list{url://langrel.txt}.*.120, " +
				"				  *.label.Type:.100, keywordsType.list{url://keywordtype.txt}.*.120" +
				"   }.*.*, " +
				"   efgNote.+{*.label.Notes:.100, noteText.edit.*.300" +
				"					 " +
				"   }.*.*, " +
				"   efgDescription.+{*.label.Description:.100, descriptionText.edit.*.300," +
				"					 *.label.Language:.100, descriptionLang.list{url://langrel.txt}.*.120" +
				"   }.*.* " +
				"}.*.*"
			},
			{PERSON_TAG, "efgIdentifier"}, {
				"*.vpanel{ " +
				"	*.hpanel{ *.label.Title.220, *.label.Title type.120, *.label.Language.120, *.label.Time.120, *.label.Region.120 }.*.*," +
				"   efgTitle.+{ efgTitleText.edit.*.220, efgTitleRelation.list{url://langrel.txt}.*.120, " +
				"				efgTitleLang.list{url://lang.txt}.*.120," +
				"				efgTitleTime.edit.*.120," +
				"			    efgTitleGeographicScope.hpanel{efgTitleGeographicScopePlace.edit.*.120}.*.120 " +
				"	}.*.*, " +
				"   efgKeywords.+{*.label.Keywords:.100, keywordsTerm.hpanel{keywordsTermText.edit.*.160}.*.160, " +
				"                 *.label.Language:.100, keywordsLang.list{url://langrel.txt}.*.120, " +
				"				  *.label.Type:.100, keywordsType.list{url://keywordtype.txt}.*.120" +
				"   }.*.*, " +
				"   efgNote.+{*.label.Notes:.100, noteText.edit.*.300" +
				"					 " +
				"   }.*.*, " +
				"   efgDescription.+{*.label.Description:.100, descriptionText.edit.*.300," +
				"					 *.label.Language:.100, descriptionLang.list{url://langrel.txt}.*.120" +
				"   }.*.* " +
				"}.*.*"
			},
			{CORPORATION_TAG, "efgIdentifier"}, {
				"*.label.Text.100"
			},
			{ITEM_TAG, "efgIdentifier"}, {
				"*.label.Text.100"
			}
		}
	} ;
	private static final String[][][] insertView2 = {
			{ {MOVIE_TAG}, {"Title:label:none:sameline:180x20",
					"Title type:label:none:sameline:180x20",
					"Language:label:none:sameline:120x20",
					"Time:label:none:sameline:90x20",
					"Region:label:none:sameline:90x20",
					"block-start:newline:$",
					"$:editbox:title*:sameline:180x25",
					"$:listbox{Original title, Other title}:titletype*:sameline:180x25",
					"$:listbox{n/a, English, German, Italian}:language*:sameline:120x25",
					"$:editbox:year*:sameline:90x25",
					"$:listbox{n/a, EN, DE, IT}:region*:sameline:90x25",
					"block-end:sameline:$",					
					"block-start:newline:$",
					"Category:label:none:newline:120x25",
					"$:listbox{n/a, Action, Horror, Comedy}:category*:sameline:180x25",
					"block-end:sameline:$",
					"Year:label:none:newline:120x25",
					"$:editbox:year:sameline:120x25",
					"Derived from:label:none:sameline:120x25",
					"$:editbox:derived:sameline:120x25",
					"Country:label:none:newline:120x25",
					"$:listbox{n/a, EN, DE, IT}:country:sameline:120x25",
					"block-start:newline:$",
					"Keywords:label:none:sameline:120x25",
					"$:editbox:keywords*:sameline:120x25",
					"Language:label:none:sameline:90x25",
					"$:listbox{n/a, English, German, Italian}:languagekeyword*:sameline:90x25",
					"Type:label:none:sameline:60x25",
					"$:listbox{n/a, Important, Other}:keywordtype*:sameline:60x25",
					"block-end:sameline:$",
					"block-start:newline:$",
					"Description:label:none:sameline:120x25",
					"$:editbox:description*:sameline:500x25",
					"Language:label:none:sameline:90x25",
					"$:listbox{n/a, English, German, Italian}:languagedescription*:sameline:60x25",
					"block-end:sameline:$",
					"Notes:label:none:newline:120x25",
					"$:editbox:notes:sameline:500x25"}
			},
			{ {PERSON_TAG}, {"Name prefix:label:none:sameline:90x20",
				"Forename(s):label:none:sameline:180x20",
				"Family:label:none:sameline:180x20",
				"Name suffix:label:none:sameline:90x20",
				"Name type:label:none:sameline:180x20",
				"Time:label:none:sameline:120x20",
				"Region:label:none:sameline:90x20",
				"block-start:newline:$",
				"$:editbox:nameprefix*:sameline:90x25",
				"$:editbox:forename*:sameline:180x25",
				"$:editbox:family*:sameline:180x25",
				"$:editbox:namesuffix*:sameline:90x25",
				"$:listbox{Preffered name, Official name}:nametype*:sameline:180x25",				
				"$:editbox:time*:sameline:120x25",
				"$:listbox{n/a, EN, DE, IT}:region*:sameline:90x25",
				"block-end:sameline:$",
				"Sex:label:none:newline:120x25",
				"$:listbox{Unknown, Male, Female }:sex:sameline:120x25",
				"Born:label:none:newline:120x25",
				"$:editbox:dateborn:sameline:180x25",
				"Place of birth:label:none:sameline:160x25",
				"$:editbox:placebirth:sameline:180x25",
				"Language:label:none:sameline:120x25",
				"$:listbox{n/a, English, French, Italian, German }:birthlanguage:sameline:160x25",
				"Died:label:none:newline:120x25",
				"$:editbox:datedead:sameline:180x25",
				"Place of death:label:none:sameline:160x25",
				"$:editbox:placedeath:sameline:180x25",
				"Language:label:none:sameline:120x25",
				"$:listbox{n/a, English, French, Italian, German }:deathlanguage:sameline:160x25",
				"Activity:label:none:newline:90x25",
				"Search activity beginning with:label:none:newline:200x25",
				"Activity:label:none:newline:170x25",
				"block-start:newline:$",
				"$:editbox:searchactivity:sameline:120x25",
				"<SMALL>Check</SMALL>:button<>:checkactivity:sameline:50x25",
				"$:label:activity:sameline:120x25",
				"block-end:sameline:$",
				"block-start:newline:$",
				"Add new activity:editbox:newactivity:newline:140x25",
				"<SMALL>OK</SMALL>:button<>:oknewactivity:sameline:50x25",
				"$:label:newactivity:sameline:120x25",
				"block-end:sameline:$",
				"block-start:newline:$",
				"Countries:label:none:sameline:70x25",
				"$:label:countries:sameline:100x25",
				"block-end:sameline:$",
				"Years of activity:label:none:sameline:90x25",
				"$:editbox:yearsactivity:sameline:100x25",
				"Notes:label:none:newline:120x25",
				"$:editbox:notes:sameline:500x25",
				"Language:label:none:sameline:90x25",
				"$:listbox{n/a, English, German, Italian}:languagedescription*:sameline:60x25"}
			},
			{ {CORPORATION_TAG}, {"Name:label:none:sameline:180x20",
				"Name type:label:none:sameline:120x20",
				"Time:label:none:sameline:120x20",
				"Region:label:none:sameline:90x20",				
				"block-start:newline:$",
				"$:editbox:name*:sameline:180x25",
				"$:listbox{Preffered name, Official name}:nametype*:sameline:120x25",
				"$:editbox:time*:sameline:120x25",
				"$:listbox{n/a, EN, DE, IT}:region*:sameline:90x25",
				"block-end:sameline:$",
				"block-start:newline:$",
				"Type of activity:label:none:sameline:120x25",
				"$:listbox{Production company, other}:typeactivity*:sameline:120x25",
				"in:label:none:sameline:120x25",
				"$:editbox:timeactivity*:sameline:120x25",				
				"block-end:sameline:$",
				"Place/Domicile:label:none:newline:120x25",
				"$:editbox:place:sameline:160x25",
				"Countries:label:none:sameline:120x25",
				"$:editbox:countries:sameline:180x25",
				"Founded:label:none:newline:120x25",
				"$:editbox:founded:sameline:120x25",
				"Dissolved:label:none:newline:120x25",
				"$:editbox:dissolved:sameline:120x25",
				"Notes:label:none:sameline:120x25",
				"$:editbox:dissolved:sameline:300x25",
				"Language:label:none:sameline:120x25",				
				"$:listbox{n/a, English, French, Italian, German }:language:sameline:160x25"}
			}
		};
	
	private static final String [] [] [] manageBasicView = {
			{ {MOVIE_TAG}, 
				{"efgCountryOfReference:Country:3,efgRecordSource.efgRecordSourceProvider:Provider:3," +
						"efgTitle.efgTitleText:Title:1,efgDescription.descriptionText:Description:1,efgKeywords.keywordsTerm.keywordsTermText:Keywords:5"
				}
			} ,
			{ {PERSON_TAG},
				{"efgCountryOfReference:Country:3,efgRecordSource.efgRecordSourceProvider:Provider:3," +
						"efgTitle.efgTitleText:Title:1,efgDescription.descriptionText:Description:1,efgKeywords.keywordsTerm.keywordsTermText:Keywords:5"
				}
			} ,
			{ {CORPORATION_TAG},
				{"efgCountryOfReference:Country:3,efgRecordSource.efgRecordSourceProvider:Provider:3," +
						"efgTitle.efgTitleText:Title:1,efgDescription.descriptionText:Description:1,efgKeywords.keywordsTerm.keywordsTermText:Keywords:5"
				}
			} ,
	}; 
	
	public static String [] [] getSearchBasicView(String itemType) {
		return getConfiguration(itemType, searchBasicView) ;
	}

	public static String[][] getInsertView(String itemType) {
		return getConfiguration(itemType, insertView) ;
	}
	public static int getIndexItemType(String itemType, String [] [] [] view) {
		for (int iView = 0 ; iView < view.length ; iView ++) {
			if (view [iView] [0] [0].equals(itemType)) {
				return iView ;
			}
		}
		return -1 ;
	}
	public static String [] [] getConfiguration(String itemType, String [] [] [] view) {
		for (int iView = 0 ; iView < view.length ; iView ++) {
			if (view [iView] [0] [0].equals(itemType)) {
				return view [iView] ;
			}
		}
		return null ;
	}
	public static String [] [] getSearchView(String itemType) {
		return getConfiguration(itemType, searchView) ;
	}
	
	public static String[] getItemTypes() {
		return itemTypes ;
	}

	public static String [] getSearchResults(String itemType) {
		for (int iFieldSearch = 0 ; iFieldSearch < searchView.length ; iFieldSearch ++) {
			if (searchResults [iFieldSearch] [0] [0].equals(itemType)) {
				return searchResults [iFieldSearch] [1] ;
			}
		}
		return null ;
	}

	public static String [] [] getSearchDetailView(String itemType) {
		return getConfiguration(itemType, searchDetailsView) ;		
	}
	
	public static String getIDTag(String itemType) {
		for (int i = 0 ; i < idTag.length ; i ++) {
			if (idTag [i] [0].equals(itemType)) {
				return idTag [i] [1] ;
			}
		}
		return "" ;
	}

	public static String[][] getManageBasicView(String pageType) {
		return getConfiguration(pageType, manageBasicView) ;
	}
}
