@@ -0,0 +1,1853 @@
+package org.intermine.webservice.server.output;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.intermine.api.InterMineAPI;%0Aimport org.intermine.api.LinkRedirectManager;%0Aimport org.intermine.api.results.ResultElement;%0Aimport org.intermine.model.InterMineObject;%0Aimport org.intermine.web.logic.PortalHelper;%0Aimport org.json.JSONObject;%0A%0Apublic class TableCellFormatter%0A%7B%0A%0A    private static final String CELL_KEY_URL = %22url%22;%0A    private static final String CELL_KEY_VALUE = %22value%22;%0A    private static final String CELL_KEY_CLASS = %22class%22;%0A    private static final String CELL_KEY_ID = %22id%22;%0A%0A    private final LinkRedirectManager redirector;%0A    private final InterMineAPI im;%0A    %0A    public TableCellFormatter(InterMineAPI im) %7B%0A        this.im = im;%0A        this.redirector = im.getLinkRedirector();%0A    %7D%0A%0A    /**%0A     * Get the JSONObject that represents each cell in the results row%0A     * @param cell The result element with the data%0A     * @return A JSONObject%0A     */%0A    public JSONObject toJSON(ResultElement cell) %7B%0A        Map%3CString, Object%3E mapping = new HashMap%3CString, Object%3E();%0A        if (cell == null %7C%7C cell.getId() == null) %7B%0A            mapping.put(CELL_KEY_URL, null);%0A            mapping.put(CELL_KEY_VALUE, null);%0A        %7D else %7B%0A            String link = null;%0A            if (redirector != null) %7B%0A                link = redirector.generateLink(im, (InterMineObject) cell.getObject());%0A            %7D%0A            if (link == null) %7B%0A                link = PortalHelper.generateReportPath(cell);%0A            %7D%0A            mapping.put(CELL_KEY_URL, link);%0A            mapping.put(CELL_KEY_CLASS, cell.getType());%0A            mapping.put(CELL_KEY_ID, cell.getId());%0A            mapping.put(CELL_KEY_VALUE, cell.getField());%0A        %7D%0A        JSONObject ret = new JSONObject(mapping);%0A        return ret;%0A    %7D%0A%7D%0A

Refactor json cell formatting into own class