package uk.ac.ebi.atlas.experimentpage;

//import com.google.common.collect.ImmutableList;
//import com.google.common.collect.ImmutableSet;
//import uk.ac.ebi.atlas.search.GeneQuery;
//import uk.ac.ebi.atlas.search.SemanticQueryTerm;
import uk.ac.ebi.atlas.web.ExperimentPageRequestPreferences;

import java.io.UnsupportedEncodingException;
import java.util.Map;

public class ExperimentPageCallbacks {

    public  <Preferences extends ExperimentPageRequestPreferences> String
    create(Preferences preferences, Map<String, String> allParameters, String originalRequestURI) {
        allParameters.put("geneQuery", preferences.getGeneQuery().toUrlEncodedJson());
        StringBuilder sourceURLBuilder = new StringBuilder(originalRequestURI.replace("/experiments", "/json/experiments").replaceFirst("\\??$","?"));
        for(Map.Entry<String, String> e: allParameters.entrySet()){
            sourceURLBuilder.append(e.getKey()).append("=").append(e.getValue()).append("&");
        }
        sourceURLBuilder.deleteCharAt(sourceURLBuilder.lastIndexOf("&"));
        return sourceURLBuilder.toString();
    }

//    public <Preferences extends ExperimentPageRequestPreferences> void
//    adjustReceivedObjects(Preferences preferences) {
//        preferences.setGeneQuery(GeneQuery.fromUrlEncodedJson(preferences.getGeneQuery()));
//    }
}

@@ -38,201 +38,8 @@
 e;%0A%0A
-//import com.google.common.collect.ImmutableList;%0A//import com.google.common.collect.ImmutableSet;%0A//import uk.ac.ebi.atlas.search.GeneQuery;%0A//import uk.ac.ebi.atlas.search.SemanticQueryTerm;%0A
 impo
@@ -100,53 +100,8 @@
 s;%0A%0A
-import java.io.UnsupportedEncodingException;%0A
 impo
@@ -870,238 +870,7 @@
    %7D
-%0A%0A//    public %3CPreferences extends ExperimentPageRequestPreferences%3E void%0A//    adjustReceivedObjects(Preferences preferences) %7B%0A//        preferences.setGeneQuery(GeneQuery.fromUrlEncodedJson(preferences.getGeneQuery()));%0A//    %7D
 %0A%7D%0A

Remove commented code