package com.firebet.sandbox.server;

import java.util.Arrays;

import com.firebet.sandbox.shared.FieldTestPojo;
import com.isomorphic.datasource.BasicDataSource;
import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DSResponse;
import com.isomorphic.util.DataTools;

public class FieldTestDataSource extends BasicDataSource {

	/** */
	private static final long serialVersionUID = -705218281478092400L;

	@Override
	public DSResponse executeFetch(DSRequest request) throws Exception {
		
		DSResponse response = new DSResponse();
		response.setSuccess();
		response.setData(Arrays.asList(new FieldTestPojo("1", "One"), new FieldTestPojo("2", "Two")));

		return response;
	}
	
	@Override
	public DSResponse executeRemove(DSRequest request) throws Exception {
		
		final FieldTestPojo pojo = new FieldTestPojo();
		DataTools.setProperties(request.getValues(), pojo);
		// ... do delete of object
		
		final DSResponse response = new DSResponse();
		response.setSuccess();
		return response;
	}
}
