package com.cogeco.csmp.gwt.server.datasource;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;

import com.cogeco.csmp.gwt.client.User;
import com.cogeco.csmp.gwt.server.GwtServerHelper;
import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DSResponse;
import com.smartgwt.client.data.Record;

public class UserDmi {
	private static Logger logger = Logger
			.getLogger(UserDmi.class.getName());

	public UserDmi() {
	}

	public DSResponse fetch(DSRequest dsRequest, HttpServletRequest request)
			throws Exception {
		User user = GwtServerHelper.getUser(request);
		logger.info("UserDmi.fetch = "+user.toString());
		
		DSResponse dsResponse = new DSResponse();
		List<User> rows = new ArrayList<User>(1);
		rows.add(user);
		
        dsResponse.setTotalRows(1);  
        dsResponse.setStartRow(0);  
        dsResponse.setEndRow(0);  
		dsResponse.setData(rows);
		
		logger.info("UserDmi.fetch completed");
		return dsResponse;
	}
}
