use of org.eclipse.sw360.portal.common.datatables.data.DataTablesParameters in project sw360portal by sw360.
the class DataTablesParserTest method testName.
@Test
public void testName() throws Exception {
Map<String, String[]> parameterMap = getTestParameterMap();
DataTablesParameters parameters = DataTablesParser.parametersFrom(parameterMap);
assertThat(parameters, is(not(nullValue())));
assertThat(parameters.getDraw(), is(1));
assertThat(parameters.getLength(), is(10));
assertThat(parameters.getStart(), is(5));
DataTablesSearch search = parameters.getSearch();
assertThat(search, is(equalTo(new DataTablesSearch("lookingFor", false))));
List<DataTablesColumn> columns = parameters.getColumns();
assertThat(columns, hasSize(1));
DataTablesColumn column1 = columns.get(0);
assertThat(column1.isSearchable(), is(true));
assertThat(column1.getSearch(), is(equalTo(new DataTablesSearch("col0Sear", true))));
List<DataTablesOrder> orders = parameters.getOrders();
assertThat(columns, hasSize(1));
DataTablesOrder order = orders.get(0);
assertThat(order.getColumn(), is(0));
assertThat(order.isAscending(), is(true));
}
use of org.eclipse.sw360.portal.common.datatables.data.DataTablesParameters in project sw360portal by sw360.
the class FossologyAwarePortlet method serveFossologyStatus.
protected void serveFossologyStatus(ResourceRequest request, ResourceResponse response) throws IOException {
DataTablesParameters parameters = DataTablesParser.parametersFrom(request);
Release release = getReleaseForFossologyStatus(request);
Map<String, FossologyStatus> fossologyStatus = getFossologyStatus(release);
JSONObject jsonResponse = JSONFactoryUtil.createJSONObject();
JSONArray data = JSONFactoryUtil.createJSONArray();
for (Map.Entry<String, FossologyStatus> entry : fossologyStatus.entrySet()) {
JSONObject row = JSONFactoryUtil.createJSONObject();
row.put("0", entry.getKey());
row.put("1", ThriftEnumUtils.enumToString(entry.getValue()));
data.put(row);
}
jsonResponse.put("attachment", getFossologyUploadableAttachment(release));
jsonResponse.put("data", data);
jsonResponse.put("draw", parameters.getDraw());
jsonResponse.put("recordsTotal", fossologyStatus.size());
jsonResponse.put("recordsFiltered", fossologyStatus.size());
writeJSON(request, response, jsonResponse);
}
use of org.eclipse.sw360.portal.common.datatables.data.DataTablesParameters in project sw360portal by sw360.
the class DataTablesParser method parametersFrom.
protected static DataTablesParameters parametersFrom(Map<String, String[]> parameterMap) {
int draw = getSimpleInt(parameterMap, "draw");
int length = getSimpleInt(parameterMap, "length");
int start = getSimpleInt(parameterMap, "start");
List<DataTablesOrder> orders = getOrders(parameterMap);
List<DataTablesColumn> columns = getColumns(parameterMap);
DataTablesSearch search = getSearch(parameterMap, "search");
return new DataTablesParameters(draw, length, start, orders, columns, search);
}
Aggregations