Migrate PreviewExtendDataCommand to Jackson
This commit is contained in:
parent
c80001a642
commit
c98ae0dcf6
@ -45,9 +45,8 @@ import javax.servlet.ServletException;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.google.refine.commands.Command;
|
import com.google.refine.commands.Command;
|
||||||
import com.google.refine.model.Cell;
|
import com.google.refine.model.Cell;
|
||||||
import com.google.refine.model.Column;
|
import com.google.refine.model.Column;
|
||||||
@ -94,18 +93,18 @@ public class PreviewExtendDataCommand extends Command {
|
|||||||
String jsonString = request.getParameter("extension");
|
String jsonString = request.getParameter("extension");
|
||||||
DataExtensionConfig config = DataExtensionConfig.reconstruct(jsonString);
|
DataExtensionConfig config = DataExtensionConfig.reconstruct(jsonString);
|
||||||
|
|
||||||
JSONArray rowIndices = ParsingUtilities.evaluateJsonStringToArray(rowIndicesString);
|
List<Integer> rowIndices = ParsingUtilities.mapper.readValue(rowIndicesString, new TypeReference<List<Integer>>() {});
|
||||||
int length = rowIndices.length();
|
int length = rowIndices.size();
|
||||||
Column column = project.columnModel.getColumnByName(columnName);
|
Column column = project.columnModel.getColumnByName(columnName);
|
||||||
int cellIndex = column.getCellIndex();
|
int cellIndex = column.getCellIndex();
|
||||||
|
|
||||||
// get the endpoint to extract data from
|
// get the endpoint to extract data from
|
||||||
String endpoint = null;
|
String endpoint = null;
|
||||||
ReconConfig cfg = column.getReconConfig();
|
ReconConfig cfg = column.getReconConfig();
|
||||||
if (cfg != null &&
|
if (cfg != null &&
|
||||||
cfg instanceof StandardReconConfig) {
|
cfg instanceof StandardReconConfig) {
|
||||||
StandardReconConfig scfg = (StandardReconConfig)cfg;
|
StandardReconConfig scfg = (StandardReconConfig)cfg;
|
||||||
endpoint = scfg.service;
|
endpoint = scfg.service;
|
||||||
} else {
|
} else {
|
||||||
respond(response, "{ \"code\" : \"error\", \"message\" : \"This column has not been reconciled with a standard service.\" }");
|
respond(response, "{ \"code\" : \"error\", \"message\" : \"This column has not been reconciled with a standard service.\" }");
|
||||||
return;
|
return;
|
||||||
@ -116,7 +115,7 @@ public class PreviewExtendDataCommand extends Command {
|
|||||||
List<String> topicIds = new ArrayList<String>();
|
List<String> topicIds = new ArrayList<String>();
|
||||||
Set<String> ids = new HashSet<String>();
|
Set<String> ids = new HashSet<String>();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
int rowIndex = rowIndices.getInt(i);
|
int rowIndex = rowIndices.get(i);
|
||||||
if (rowIndex >= 0 && rowIndex < project.rows.size()) {
|
if (rowIndex >= 0 && rowIndex < project.rows.size()) {
|
||||||
Row row = project.rows.get(rowIndex);
|
Row row = project.rows.get(rowIndex);
|
||||||
Cell cell = row.getCell(cellIndex);
|
Cell cell = row.getCell(cellIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user