Restructure SortColumn Filter

pull/48/head
Rushdi Mohamed 2 years ago
parent ce911b1d26
commit da20730353

@ -177,6 +177,25 @@ public class PaginationRequest {
public List<String> getSortColumns() { return sortColumns; }
/**
* Convert SortColumns field parameter and splitting string into columnName and sortType
*
* @param sortColumns which is separated by a colon(:) and first will be the columnNane and the second will be type ASC or DESC
* @return sortColumnList as a list of sortColumn
*/
public static List<SortColumn> convertToSortColumn(List<String> sortColumns) {
List<SortColumn> sortColumnList = new ArrayList<>();
for (String sortBy: sortColumns) {
SortColumn sortColumn = new SortColumn();
String[] sorting = sortBy.split(":");
sortColumn.setName(sorting[0]);
sortColumn.setType(sorting.length >= 2 && (sorting[1].equalsIgnoreCase("desc"))
? SortColumn.types.DESC : SortColumn.types.ASC);
sortColumnList.add(sortColumn);
}
return sortColumnList;
}
@Override
public String toString() {
return "Device type '" + this.deviceType + "' Device Name '" + this.deviceName + "' row count: " + this.rowCount

@ -59,7 +59,6 @@ import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.GroupPaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.SortColumn;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.EnrollmentConfiguration;
@ -1285,23 +1284,4 @@ public final class DeviceManagerUtil {
+ deviceGroup.getGroupId();
}
}
/**
* Convert SortColumns field parameter and splitting string into columnName and sortType
*
* @param sortColumns which is separated by a colon(:) and first will be the columnNane and the second will be type ASC or DESC
* @return sortColumnList as a list of sortColumn
*/
public static List<SortColumn> convertToSortColumn(List<String> sortColumns) {
List<SortColumn> sortColumnList = new ArrayList<>();
for (String sortBy: sortColumns) {
SortColumn sortColumn = new SortColumn();
String[] sorting = sortBy.split(":");
sortColumn.setName(sorting[0]);
sortColumn.setType(sorting.length >= 2 && (sorting[1].equalsIgnoreCase("desc"))
? SortColumn.types.DESC : SortColumn.types.ASC);
sortColumnList.add(sortColumn);
}
return sortColumnList;
}
}

Loading…
Cancel
Save