package com.fircosoft.cdb.client.api.application.test;

import java.util.ArrayList;
import java.util.List;

import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.grid.ListGridRecord;

public class SearchResultGrid extends ComponentGrid<SearchResultsPopupItem>{

	private static final String FIELD_RECORD = "RECORD";
		
	public SearchResultGrid() {
		super();
		
		setSortDirection(SortDirection.ASCENDING);
		setSortField(FIELD_ID);
	}

	@Override
	public void updateRecordComponent(ListGridRecord record, SearchResultsPopupItem component) {
		component.initialize(record.getAttributeAsRecord(FIELD_RECORD));
	}

	@Override
	public SearchResultsPopupItem createNewRecordComponent(ListGridRecord record) {
		
		SearchResultsPopupItem item = new SearchResultsPopupItem(/*getRecordComponentHeight()*/);
		item.initialize(record.getAttributeAsRecord(FIELD_RECORD));
		
		return item;
	}
	
	public void addRecords(List<Record> records){
		for (Record record : records) {

			ListGridRecord gridRecord = new ListGridRecord();
			gridRecord.setAttribute(FIELD_RECORD, record);
			addRecordToGrid(gridRecord);
		}
	}

	public static class Data {
		
		
		public static List<Record> getData(){
			
			List<Record> toAdds = new ArrayList<Record>();
			
			Record toAdd = new Record();
			toAdd.setAttribute("label", "Y Y, 5O0G5BV - TEST-IND-2110");
			toAdd.setAttribute("url", "firco://ds/cif_customer/2211");
			toAdd.setAttribute("description", "acc. number: TEST-BK-2111-1 - account type: Deposit - access: Payee");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label"," ,HAAR7G M, QK7FIDXWVDP9XEJB9HTF4531J2PXT ?AILJV - TEST-ENT-1104");
			toAdd.setAttribute("url", "firco://ds/cif_customer/4687");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1114-1 - account type: Annuity contract - access: Payee");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "?N8E5GI V00?EZEJPMFM5T82,5J6HICIELXEL, CI28ZATCI?ZQDI1, - TEST-IND-109");
			toAdd.setAttribute("url", "firco://ds/cif_customer/540");
			toAdd.setAttribute("description", "acc. number: TEST-BK-111-2 - account type: Deposit - access: Payee");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "?V53B8 LGTMK3ZB1CB0VVZLIW2?VV0B0T1AU7IC1ARTUSKCQCGTD0 - TEST-ENT-1114");
			toAdd.setAttribute("url", "firco://ds/cif_customer/4697");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1116-2 - account type: Annuity contract - access: Payee");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "1JK3,PK,OZ, AE,3XLZK,. - TEST-IND-1113");
			toAdd.setAttribute("url", "firco://ds/cif_customer/1405");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1115-1 - account type: Custodial accounts - access: Beneficial Owner");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "28YZS7 - TEST-ENT-4110");
			toAdd.setAttribute("url", "firco://ds/cif_customer/4485");
			toAdd.setAttribute("description", "acc. number: TEST-BK-4111-1 - account type: Debt or equity accounts - access: Power of Attorney");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "41HVQFZ0,5DKR3JJWE U7UXZ0.Z7RHRWVVCBT5GGUKQEQOERIRH0F334GVF3J, O - TEST-IND-1110");
			toAdd.setAttribute("url", "firco://ds/cif_customer/1400");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1111-1 - account type: Annuity contract - access: Guarantor");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "5DH416 C94LIE3COTMO5P4QHK8H3BNP24H0?Z62B75R5B2?SMYF6DIBB2OO4OS - TEST-ENT-1117");
			toAdd.setAttribute("url", "firco://ds/cif_customer/4699");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1119-1 - account type: Debt or equity accounts - access: Guarantor");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "5QZJLYIE7P.KCEUD2Q5S?HFK6P6X.ULS8?B69CK0QK0XQ?K, AI - TEST-IND-1111");
			toAdd.setAttribute("url", "firco://ds/cif_customer/1402");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1112-0 - account type: Custodial accounts - access: Beneficial Owner");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "9JET5KKM3VN4Z 7POFE60UPD.NLKNRZ3I VS67I5, JFNJDJ - TEST-IND-1109");
			toAdd.setAttribute("url", "firco://ds/cif_customer/1410");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1110-0 - account type: Debt or equity accounts - access: Guarantor");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "FPY0,3,U?PKHG9YM9H5BS.Q,56X,39WIQDV.Y MU,?, 6Y?Z1EWWN,1IP.CN?UCA??W 1C3N5.ZCDL,LGZ - TEST-ENT-1116");
			toAdd.setAttribute("url", "firco://ds/cif_customer/4701");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1117-1 - account type: Custodial accounts - access: Power of Attorney");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label","MCDT4OA05..7U6BMG8C.F727SXTD, D5I87PENDP - TEST-IND-1112");
			toAdd.setAttribute("url", "firco://ds/cif_customer/1404");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1113-2 - account type: Cash value insurance and annuity contract accounts - access: Power of Attorney");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "N4PUYJTV46IGNAKH6,L05D8IQ8XGGJWX0D?, 9FH96KN,45, - TEST-IND-1115");
			toAdd.setAttribute("url", "firco://ds/cif_customer/1399");
			toAdd.setAttribute("description", "acc. number: TEST-BK-1118-1 - account type: Custodial accounts - access: Guarantor");
			toAdds.add(toAdd);
			toAdd = new Record();
			toAdd.setAttribute("label", "Q5KLBTU9SSZ 5WVA8QFY4AQ5JTQG08, A4S2,9IH3CSOTCWV7QI - TEST-IND-3107");
			toAdd.setAttribute("url", "firco://ds/cif_customer/897");
			toAdd.setAttribute("description", "acc. number: TEST-BK-3111-1 - account type: Cash value insurance and annuity contract accounts - access: Payee");
			toAdds.add(toAdd);
			
			return toAdds;
		}

	}
}
