mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-09 05:48:20 +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;
|
package tech.ailef.dbadmin.external.dto;
|
||||||
|
|
||||||
|
import tech.ailef.dbadmin.external.controller.rest.AutocompleteController;
|
||||||
import tech.ailef.dbadmin.external.dbmapping.DbObject;
|
import tech.ailef.dbadmin.external.dbmapping.DbObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object to hold autocomplete results returned from the
|
* An object to hold autocomplete results returned from the {@linkplain AutocompleteController}.
|
||||||
* respective AutocompleteController
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AutocompleteSearchResult {
|
public class AutocompleteSearchResult {
|
||||||
|
|
||||||
private Object id;
|
private Object id;
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
@ -39,20 +40,19 @@ public class AutocompleteSearchResult {
|
|||||||
this.value = o.getDisplayName();
|
this.value = o.getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the primary key for the object
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public Object getId() {
|
public Object getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Object id) {
|
/**
|
||||||
this.id = id;
|
* Returns the readable name for the object
|
||||||
}
|
* @return
|
||||||
|
*/
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
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;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the page for this request
|
||||||
|
* @param page
|
||||||
|
*/
|
||||||
public void setPage(int page) {
|
public void setPage(int page) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
@ -124,6 +128,10 @@ public class LogsSearchRequest implements FilterRequest {
|
|||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the page size for this request
|
||||||
|
* @param pageSize
|
||||||
|
*/
|
||||||
public void setPageSize(int pageSize) {
|
public void setPageSize(int pageSize) {
|
||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
}
|
}
|
||||||
@ -143,11 +151,15 @@ public class LogsSearchRequest implements FilterRequest {
|
|||||||
/**
|
/**
|
||||||
* Returns the requested sort order, possibly null
|
* Returns the requested sort order, possibly null
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getSortOrder() {
|
public String getSortOrder() {
|
||||||
return sortOrder;
|
return sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the sort order for this request
|
||||||
|
*
|
||||||
|
* @param sortOrder
|
||||||
|
*/
|
||||||
public void setSortOrder(String sortOrder) {
|
public void setSortOrder(String sortOrder) {
|
||||||
this.sortOrder = sortOrder;
|
this.sortOrder = sortOrder;
|
||||||
}
|
}
|
||||||
|
@ -41,18 +41,34 @@ public class PaginatedResult<T> {
|
|||||||
this.results = page;
|
this.results = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pagination settings used to produce this output
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public PaginationInfo getPagination() {
|
public PaginationInfo getPagination() {
|
||||||
return pagination;
|
return pagination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of results in the current page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public List<T> getResults() {
|
public List<T> getResults() {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the results are empty
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return results.isEmpty();
|
return results.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of results for the current page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public int getNumberOfResults() {
|
public int getNumberOfResults() {
|
||||||
return getResults().size();
|
return getResults().size();
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ public class PaginationInfo {
|
|||||||
private static final int PAGE_RANGE = 3;
|
private static final int PAGE_RANGE = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current page of results
|
* The current requested page
|
||||||
*/
|
*/
|
||||||
private int currentPage;
|
private int currentPage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last page for which there are results
|
* The last page for which there are results available
|
||||||
*/
|
*/
|
||||||
private int maxPage;
|
private int maxPage;
|
||||||
|
|
||||||
@ -68,6 +68,9 @@ public class PaginationInfo {
|
|||||||
this.filterRequest = request;
|
this.filterRequest = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current requested page
|
||||||
|
*/
|
||||||
public int getCurrentPage() {
|
public int getCurrentPage() {
|
||||||
return currentPage;
|
return currentPage;
|
||||||
}
|
}
|
||||||
@ -76,6 +79,10 @@ public class PaginationInfo {
|
|||||||
this.currentPage = currentPage;
|
this.currentPage = currentPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the last page for which there are results available
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public int getMaxPage() {
|
public int getMaxPage() {
|
||||||
return maxPage;
|
return maxPage;
|
||||||
}
|
}
|
||||||
@ -84,6 +91,10 @@ public class PaginationInfo {
|
|||||||
this.maxPage = maxPage;
|
this.maxPage = maxPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current number of elements per page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public int getPageSize() {
|
public int getPageSize() {
|
||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
@ -92,10 +103,22 @@ public class PaginationInfo {
|
|||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the total count of elements for all pages
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public long getMaxElement() {
|
public long getMaxElement() {
|
||||||
return maxElement;
|
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) {
|
public String getSortedPageLink(String sortKey, String sortOrder) {
|
||||||
MultiValueMap<String, String> params = FilterRequest.empty();
|
MultiValueMap<String, String> params = FilterRequest.empty();
|
||||||
|
|
||||||
@ -115,6 +138,13 @@ public class PaginationInfo {
|
|||||||
return Utils.getQueryString(params);
|
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) {
|
public String getLink(int page) {
|
||||||
MultiValueMap<String, String> params = FilterRequest.empty();
|
MultiValueMap<String, String> params = FilterRequest.empty();
|
||||||
|
|
||||||
@ -132,22 +162,26 @@ public class PaginationInfo {
|
|||||||
return Utils.getQueryString(params);
|
return Utils.getQueryString(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pages before the current one
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public List<Integer> getBeforePages() {
|
public List<Integer> getBeforePages() {
|
||||||
return IntStream.range(Math.max(currentPage - PAGE_RANGE, 1), currentPage).boxed().collect(Collectors.toList());
|
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() {
|
public List<Integer> getAfterPages() {
|
||||||
return IntStream.range(currentPage + 1, Math.min(currentPage + PAGE_RANGE, maxPage + 1)).boxed().collect(Collectors.toList());
|
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() {
|
public boolean isLastPage() {
|
||||||
return currentPage == maxPage;
|
return currentPage == maxPage;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user