import java.util.HashMap;
import java.util.Map;

import com.isomorphic.datasource.BasicDataSource;
import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DSResponse;


public class MultiUploadMasterServlet extends BasicDataSource {
	
	public DSResponse executeAdd(DSRequest req) throws Exception {  
        Map createdRecord = createRecord(req.getValues());  
        return new DSResponse(createdRecord);  
    }  
	
	public DSResponse executeUpdate(DSRequest req) throws Exception {  
		Map updatedRecord = updateRecord(req.getValues());  
		return new DSResponse(updatedRecord);  
	}  
	
    public DSResponse executeFetch(DSRequest req) throws Exception {  
        Map record = fetchRecord(req.getCriteria());  
        return new DSResponse(record);  
    }
    
    private Map createRecord (Map values) {  
        System.out.println("Saving form! returning PK");
    	Map<String, Integer> m = new HashMap<>();
    	m.put("id", 1);
        return m;  
    } 
  
    private Map fetchRecord (Map criteria) {  
    	
    	System.out.println("Fetching primary key!");
    	Map<String, Integer> m = new HashMap<>();
    	m.put("id", 1);
        return m;  
    }
    
    private Map updateRecord (Map values) {  
    	System.out.println("Update form called!");
        return values;
    }  
}
