public void getBuilderDataColumnList(ModelMap map, Writer writer, @RequestParam("appId") String appId, @RequestParam(required = false) String appVersion, @RequestParam String id, @RequestParam String binderId, HttpServletRequest request) throws Exception {
AppDefinition appDef = appService.getAppDefinition(appId, appVersion);
JSONObject jsonObject = new JSONObject();
// get data list
DataList dataList = new DataList();
// parse JSON from request if available
dataList = parseFromJsonParameter(map, dataList, id, request);
// get binder from request
DataListBinder binder = createDataListBinderFromRequestInternal(appDef, id, binderId, request);
if (binder != null) {
dataList.setBinder(binder);
}
DataListColumn[] sourceColumns = (binder != null) ? binder.getColumns() : new DataListColumn[0];
// sort columns by label
List<DataListColumn> binderColumnList = Arrays.asList(sourceColumns);
Collections.sort(binderColumnList, new Comparator<DataListColumn>() {
public int compare(DataListColumn o1, DataListColumn o2) {
return o1.getLabel().toLowerCase().compareTo(o2.getLabel().toLowerCase());
}
});
Collection<String> columnNameList = new HashSet<String>();
DataListColumn[] targetColumns = dataList.getColumns();
if (targetColumns != null) {
for (DataListColumn selectedColumn : targetColumns) {
columnNameList.add(selectedColumn.getName());
}
}
for (Iterator i = binderColumnList.iterator(); i.hasNext();) {
DataListColumn column = (DataListColumn) i.next();
if (columnNameList.contains(column.getName())) {
i.remove();
}
}
sourceColumns = (DataListColumn[]) binderColumnList.toArray(new DataListColumn[0]);
DataList sourceDataList = new DataList();
sourceDataList.setColumns(sourceColumns);
Collection<Object> collection = new ArrayList<Object>();
for (DataListColumn sourceColumn : sourceColumns) {
HashMap hm = new HashMap();
hm.put("name", sourceColumn.getName());