diff --git a/src/main/java/tech/ailef/dbadmin/external/dto/AutocompleteSearchResult.java b/src/main/java/tech/ailef/dbadmin/external/dto/AutocompleteSearchResult.java
index 034698b..d23d4fe 100644
--- a/src/main/java/tech/ailef/dbadmin/external/dto/AutocompleteSearchResult.java
+++ b/src/main/java/tech/ailef/dbadmin/external/dto/AutocompleteSearchResult.java
@@ -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;
- }
-
}
diff --git a/src/main/java/tech/ailef/dbadmin/external/dto/FragmentContext.java b/src/main/java/tech/ailef/dbadmin/external/dto/FragmentContext.java
deleted file mode 100644
index 5515743..0000000
--- a/src/main/java/tech/ailef/dbadmin/external/dto/FragmentContext.java
+++ /dev/null
@@ -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 .
-// */
-//
-//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
-//}
diff --git a/src/main/java/tech/ailef/dbadmin/external/dto/LogsSearchRequest.java b/src/main/java/tech/ailef/dbadmin/external/dto/LogsSearchRequest.java
index 07bc2d7..916e866 100644
--- a/src/main/java/tech/ailef/dbadmin/external/dto/LogsSearchRequest.java
+++ b/src/main/java/tech/ailef/dbadmin/external/dto/LogsSearchRequest.java
@@ -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;
}
diff --git a/src/main/java/tech/ailef/dbadmin/external/dto/PaginatedResult.java b/src/main/java/tech/ailef/dbadmin/external/dto/PaginatedResult.java
index b073f7b..f1545de 100644
--- a/src/main/java/tech/ailef/dbadmin/external/dto/PaginatedResult.java
+++ b/src/main/java/tech/ailef/dbadmin/external/dto/PaginatedResult.java
@@ -41,18 +41,34 @@ public class PaginatedResult {
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 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();
}
diff --git a/src/main/java/tech/ailef/dbadmin/external/dto/PaginationInfo.java b/src/main/java/tech/ailef/dbadmin/external/dto/PaginationInfo.java
index 8bf9763..e5a6716 100644
--- a/src/main/java/tech/ailef/dbadmin/external/dto/PaginationInfo.java
+++ b/src/main/java/tech/ailef/dbadmin/external/dto/PaginationInfo.java
@@ -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;
}
@@ -75,7 +78,11 @@ public class PaginationInfo {
public void setCurrentPage(int currentPage) {
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 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 params = FilterRequest.empty();
@@ -132,22 +162,26 @@ public class PaginationInfo {
return Utils.getQueryString(params);
}
+ /**
+ * Returns the pages before the current one
+ * @return
+ */
public List 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 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;
}