package com.github.jmchilton.blend4j.galaxy;

import com.github.jmchilton.blend4j.galaxy.beans.TabularToolDataTable;
import com.sun.jersey.api.client.ClientResponse;
import org.codehaus.jackson.type.TypeReference;

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

public class ToolDataClientImpl extends Client implements ToolDataClient {

    ToolDataClientImpl(GalaxyInstanceImpl galaxyInstance) {
        super(galaxyInstance, "tool_data");
    }

    public ClientResponse showDataTableRequest(String dataTableId) {
        return super.show(dataTableId, ClientResponse.class);
    }

    public ClientResponse deleteDataTableRequest(final String dataTableId, final List<String> values) {
        Map<String,String> requestEntity = new HashMap<String,String>();
        
        String joinedValues = null;
        if (values != null && values.size() > 0) {
	        joinedValues = values.get(0);
	        for (int i = 1; i < values.size(); i++) {
	        	joinedValues += "\t" + values.get(i);
	        }
        }
        
        requestEntity.put("values", joinedValues);
        return deleteResponse(getWebResource(dataTableId), requestEntity);
    }

    public List<TabularToolDataTable> getDataTables() {
        return get(new TypeReference<List<TabularToolDataTable>>() {});
    }

    public ClientResponse reloadDataTableRequest(final String dataTableId) {
        return getResponse(getWebResource(dataTableId).path("reload"));
    }

    public TabularToolDataTable showDataTable(final String dataTableId) {
        return super.show(dataTableId, TabularToolDataTable.class);
    }
}

@@ -720,31 +720,16 @@
      Map
-%3CString,String%3E
  request
@@ -752,290 +752,11 @@
 hMap
-%3CString,String%3E();%0A        %0A        String joinedValues = null;%0A        if (values != null && values.size() %3E 0) %7B%0A%09        joinedValues = values.get(0);%0A%09        for (int i = 1; i %3C values.size(); i++) %7B%0A%09        %09joinedValues += %22%5Ct%22 + values.get(i);%0A%09        %7D%0A        %7D%0A        
+();
 %0A   
@@ -792,21 +792,34 @@
 s%22, 
-joinedV
+String.join(%22%5Ct%22, v
 alues)
+)
 ;%0A  

Revert "Updated code to work with Java 6"