mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
Code cleaning and javadoc
This commit is contained in:
parent
53b9bdc528
commit
913f1bb05f
@ -19,14 +19,15 @@
|
||||
|
||||
package tech.ailef.dbadmin.external.dto;
|
||||
|
||||
import tech.ailef.dbadmin.external.controller.rest.AutocompleteController;
|
||||
import tech.ailef.dbadmin.external.dbmapping.DbObject;
|
||||
|
||||
/**
|
||||
* An object to hold autocomplete results returned from the
|
||||
* respective AutocompleteController
|
||||
* An object to hold autocomplete results returned from the {@linkplain AutocompleteController}.
|
||||
*
|
||||
*/
|
||||
public class AutocompleteSearchResult {
|
||||
|
||||
private Object id;
|
||||
|
||||
private String value;
|
||||
@ -39,20 +40,19 @@ public class AutocompleteSearchResult {
|
||||
this.value = o.getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for the object
|
||||
* @return
|
||||
*/
|
||||
public Object getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Object id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the readable name for the object
|
||||
* @return
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
// * Spring Boot Database Admin - An automatically generated CRUD admin UI for Spring Boot apps
|
||||
// * Copyright (C) 2023 Ailef (http://ailef.tech)
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//package tech.ailef.dbadmin.external.dto;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Some fragments might need to be rendered differently depending
|
||||
// * on their context. For example a TEXT field is usually rendered
|
||||
// * as a text area, but if it has to fit in the faceted search right
|
||||
// * bar it's rendered as a normal input type "text" field for space
|
||||
// * reasons (and because the user just needs to search with a short
|
||||
// * query).
|
||||
// *
|
||||
// * This enum indicates the possible contexts and it is passed to the
|
||||
// * getFragmentName() method which determines which actual fragment
|
||||
// * to use.
|
||||
// *
|
||||
// */
|
||||
//public enum FragmentContext {
|
||||
// DEFAULT,
|
||||
// CREATE,
|
||||
// SEARCH
|
||||
//}
|
@ -112,6 +112,10 @@ public class LogsSearchRequest implements FilterRequest {
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the page for this request
|
||||
* @param page
|
||||
*/
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
@ -124,6 +128,10 @@ public class LogsSearchRequest implements FilterRequest {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the page size for this request
|
||||
* @param pageSize
|
||||
*/
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
@ -143,11 +151,15 @@ public class LogsSearchRequest implements FilterRequest {
|
||||
/**
|
||||
* Returns the requested sort order, possibly null
|
||||
*/
|
||||
|
||||
public String getSortOrder() {
|
||||
return sortOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sort order for this request
|
||||
*
|
||||
* @param sortOrder
|
||||
*/
|
||||
public void setSortOrder(String sortOrder) {
|
||||
this.sortOrder = sortOrder;
|
||||
}
|
||||
|
@ -41,18 +41,34 @@ public class PaginatedResult<T> {
|
||||
this.results = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pagination settings used to produce this output
|
||||
* @return
|
||||
*/
|
||||
public PaginationInfo getPagination() {
|
||||
return pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of results in the current page
|
||||
* @return
|
||||
*/
|
||||
public List<T> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the results are empty
|
||||
* @return
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return results.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of results for the current page
|
||||
* @return
|
||||
*/
|
||||
public int getNumberOfResults() {
|
||||
return getResults().size();
|
||||
}
|
||||
|
@ -39,12 +39,12 @@ public class PaginationInfo {
|
||||
private static final int PAGE_RANGE = 3;
|
||||
|
||||
/**
|
||||
* The current page of results
|
||||
* The current requested page
|
||||
*/
|
||||
private int currentPage;
|
||||
|
||||
/**
|
||||
* The last page for which there are results
|
||||
* The last page for which there are results available
|
||||
*/
|
||||
private int maxPage;
|
||||
|
||||
@ -68,6 +68,9 @@ public class PaginationInfo {
|
||||
this.filterRequest = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current requested page
|
||||
*/
|
||||
public int getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
@ -76,6 +79,10 @@ public class PaginationInfo {
|
||||
this.currentPage = currentPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last page for which there are results available
|
||||
* @return
|
||||
*/
|
||||
public int getMaxPage() {
|
||||
return maxPage;
|
||||
}
|
||||
@ -84,6 +91,10 @@ public class PaginationInfo {
|
||||
this.maxPage = maxPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current number of elements per page
|
||||
* @return
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
@ -92,10 +103,22 @@ public class PaginationInfo {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total count of elements for all pages
|
||||
* @return
|
||||
*/
|
||||
public long getMaxElement() {
|
||||
return maxElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to the current page by preserving all the other
|
||||
* filtering parameters but changing the sort order.
|
||||
*
|
||||
* @param sortKey the field to use for sorting
|
||||
* @param sortOrder the order, DESC or ASC
|
||||
* @return a link to change the sort order for the current page
|
||||
*/
|
||||
public String getSortedPageLink(String sortKey, String sortOrder) {
|
||||
MultiValueMap<String, String> params = FilterRequest.empty();
|
||||
|
||||
@ -115,6 +138,13 @@ public class PaginationInfo {
|
||||
return Utils.getQueryString(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to the specified page by preserving all the other
|
||||
* filtering parameters
|
||||
*
|
||||
* @param page the page to generate the link for
|
||||
* @return
|
||||
*/
|
||||
public String getLink(int page) {
|
||||
MultiValueMap<String, String> params = FilterRequest.empty();
|
||||
|
||||
@ -132,22 +162,26 @@ public class PaginationInfo {
|
||||
return Utils.getQueryString(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pages before the current one
|
||||
* @return
|
||||
*/
|
||||
public List<Integer> getBeforePages() {
|
||||
return IntStream.range(Math.max(currentPage - PAGE_RANGE, 1), currentPage).boxed().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pages after the current one
|
||||
* @return
|
||||
*/
|
||||
public List<Integer> getAfterPages() {
|
||||
return IntStream.range(currentPage + 1, Math.min(currentPage + PAGE_RANGE, maxPage + 1)).boxed().collect(Collectors.toList());
|
||||
}
|
||||
//
|
||||
// public String getSortKey() {
|
||||
// return sortKey;
|
||||
// }
|
||||
//
|
||||
// public String getSortOrder() {
|
||||
// return sortOrder;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns whether the current page is the last one
|
||||
* @return
|
||||
*/
|
||||
public boolean isLastPage() {
|
||||
return currentPage == maxPage;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user