Skip to content

Commit

Permalink
Merge branch 'release/12.0' of https://github.com/axonivy-market/portal
Browse files Browse the repository at this point in the history
… into feature/IVYPORTAL-18026-Long-loading-time-for-accessing-case-details-V12
  • Loading branch information
lttung-axonivy committed Jan 13, 2025
2 parents e7776f3 + e250410 commit e77a672
Show file tree
Hide file tree
Showing 28 changed files with 174 additions and 171 deletions.
2 changes: 1 addition & 1 deletion AxonIvyPortal/PortalKitTestHelper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>12.0.3-SNAPSHOT</version>
<packaging>iar</packaging>
<properties>
<ivy.engine.version>12.0.2</ivy.engine.version>
<ivy.engine.version>12.0.3</ivy.engine.version>
<build.plugin.version>12.0.0</build.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion AxonIvyPortal/portal-components/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</snapshotRepository>
</distributionManagement>
<properties>
<ivy.engine.version>12.0.2</ivy.engine.version>
<ivy.engine.version>12.0.3</ivy.engine.version>
<build.plugin.version>12.0.0</build.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ private void buildQueryToSearchCriteria() {
.isEqual(businessEntityId);
criteria.setCustomCaseQuery(caseQuery);
}

criteria.setFinalCaseQuery(criteria.createQuery());
}

public String getBusinessEntityId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.apache.commons.lang.StringUtils;

import com.axonivy.portal.components.enums.CaseSortField;

import ch.ivyteam.ivy.workflow.CaseState;
import ch.ivyteam.ivy.workflow.query.CaseQuery;
import ch.ivyteam.ivy.workflow.query.CaseQuery.IFilterQuery;
Expand All @@ -39,11 +40,9 @@ public class CaseSearchCriteria {
private boolean isNewQueryCreated;
private boolean isSorted = true;
private CaseQuery customCaseQuery;

private CaseQuery finalCaseQuery;

private boolean isGlobalSearchScope;

@SuppressWarnings("deprecation")
public CaseQuery createQuery() {
CaseQuery finalQuery;
if (isBusinessCase) {
Expand All @@ -56,7 +55,7 @@ public CaseQuery createQuery() {

setNewQueryCreated(isNewQueryCreated() || customCaseQuery == null || hasCaseId());
if (!isNewQueryCreated()) {
finalQuery.where().andOverall(CaseQuery.fromJson(customCaseQuery.asJson())); // clone to keep the original custom query
finalQuery.where().andOverall(customCaseQuery);
}

if (hasIncludedStates()) {
Expand Down Expand Up @@ -377,17 +376,6 @@ public boolean hasInvolvedUsername() {
return StringUtils.isNotBlank(involvedUsername);
}

public CaseQuery getFinalCaseQuery() {
if (finalCaseQuery == null) {
finalCaseQuery = createQuery();
}
return finalCaseQuery;
}

public void setFinalCaseQuery(CaseQuery finalCaseQuery) {
this.finalCaseQuery = finalCaseQuery;
}

public boolean isCaseOwnerEnabled() {
return isCaseOwnerEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public IvyCaseResultDTO countCasesByCriteria(CaseSearchCriteria criteria) {
}

private CaseQuery extendQuery(CaseSearchCriteria criteria) {
CaseQuery finalQuery = criteria.getFinalCaseQuery();
CaseQuery clonedQuery = CaseQuery.fromJson(finalQuery.asJson()); // clone to keep the final query in CaseSearchCriteria
CaseQuery clonedQuery = criteria.createQuery();

if (!criteria.isAdminQuery()) {
clonedQuery.where().and(queryForCurrentUser(criteria.isTechnicalCase(), criteria.isCaseOwnerEnabled()));
Expand Down
2 changes: 1 addition & 1 deletion AxonIvyPortal/portal-migration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>12.0.3-SNAPSHOT</version>
<packaging>iar</packaging>
<properties>
<ivy.engine.version>12.0.2</ivy.engine.version>
<ivy.engine.version>12.0.3</ivy.engine.version>
<build.plugin.version>12.0.0</build.plugin.version>
</properties>
<build>
Expand Down
2 changes: 1 addition & 1 deletion AxonIvyPortal/portal-selenium-test/customized_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<packaging>iar</packaging>
<properties>
<build.plugin.version>12.0.0</build.plugin.version>
<ivy.engine.version>12.0.2</ivy.engine.version>
<ivy.engine.version>12.0.3</ivy.engine.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<packaging>pom</packaging>
<properties>
<build.plugin.version>12.0.0</build.plugin.version>
<ivy.engine.version>12.0.2</ivy.engine.version>
<ivy.engine.version>12.0.3</ivy.engine.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
Expand Down
2 changes: 1 addition & 1 deletion AxonIvyPortal/portal-selenium-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>12.0.3-SNAPSHOT</version>
<packaging>iar</packaging>
<properties>
<ivy.engine.version>12.0.2</ivy.engine.version>
<ivy.engine.version>12.0.3</ivy.engine.version>
<build.plugin.version>12.0.0</build.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion AxonIvyPortal/portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</snapshotRepository>
</distributionManagement>
<properties>
<ivy.engine.version>12.0.2</ivy.engine.version>
<ivy.engine.version>12.0.3</ivy.engine.version>
<build.plugin.version>12.0.0</build.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import ch.ivyteam.ivy.workflow.CaseState;
import ch.ivyteam.ivy.workflow.ICase;
import ch.ivyteam.ivy.workflow.query.CaseQuery;
import ch.ivyteam.ivy.workflow.query.CaseQuery.IFilterQuery;

public class CaseLazyDataModel extends LazyDataModel<ICase> {
public static final String DESCRIPTION = "DESCRIPTION";
Expand Down Expand Up @@ -338,46 +337,10 @@ protected void buildQueryToSearchCriteria() {
criteria.setIncludedStates(filterContainer.getStateFilter().getSelectedFilteredStates());
}
}
buildSort();
CaseQuery caseQuery = buildCaseQuery();
extendSort(caseQuery);
this.criteria.setFinalCaseQuery(caseQuery);
}
criteria.setLegacyFilters(selectedFilters);

/**
* <p>
* If your customized case list has new columns/fields, please extend the {@code caseQuery} parameter with the sort
* query for these fields.
* </p>
* <p>
* <b>Example: </b> <code><pre>
* if ("CustomerName".equalsIgnoreCase(criteria.getSortField())) {
* if (criteria.isSortDescending()) {
* caseQuery.orderBy().customField().stringField("CustomerName").descending();
* } else {
* caseQuery.orderBy().customField().stringField("CustomerName");
* }
* }
* </pre></code>
* </p>
*
* @param caseQuery case query {@link CaseQuery}
*/
public void extendSort(@SuppressWarnings("unused") CaseQuery caseQuery) {
// Placeholder for customization
}

private CaseQuery buildCaseQuery() {
CaseQuery caseQuery = criteria.createQuery();
IFilterQuery filterQuery = caseQuery.where();
selectedFilters.forEach(selectedFilter -> {
CaseQuery subQuery = selectedFilter.buildQuery();
if (subQuery != null) {
filterQuery.and(subQuery);
}
});
buildSort();
storeCaseFiltersIntoSession();
return caseQuery;
}

private void storeCaseFiltersIntoSession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import ch.ivyteam.ivy.workflow.ITask;
import ch.ivyteam.ivy.workflow.TaskState;
import ch.ivyteam.ivy.workflow.query.TaskQuery;
import ch.ivyteam.ivy.workflow.query.TaskQuery.IFilterQuery;

public class TaskLazyDataModel extends LazyDataModel<ITask> {
public static final String DESCRIPTION = "DESCRIPTION";
Expand Down Expand Up @@ -323,29 +322,6 @@ private boolean isSortedDescendingByDefault() {
return !SortFieldUtil.isAscendingSort(SortDirection.DESC.name());
}

/**
* <p>
* If your customized task list has new columns/fields, please extend the {@code taskQuery}
* parameter with the sort query for these fields.
* </p>
* <p>
* <b>Example: </b> <code><pre>
* if ("CustomerType".equalsIgnoreCase(criteria.getSortField())) {
* if (criteria.isSortDescending()) {
* taskQuery.orderBy().customField().stringField("CustomerType").descending();
* } else {
* taskQuery.orderBy().customField().stringField("CustomerType");
* }
* }
* </pre></code>
* </p>
*
* @param taskQuery task query {@link TaskQuery}
*/
public void extendSort(@SuppressWarnings("unused") TaskQuery taskQuery) {
// Placeholder for customization
}

public void setSortField(String sortField, boolean sortDescending) {
updateSortCriteria(sortField, sortDescending, true);
}
Expand Down Expand Up @@ -567,7 +543,7 @@ public boolean hasReadAllTasksPermisson() {
}

/**
* Builds and converts TaskQuery to JsonQuery and put it into TaskSearchCriteria.
* Builds TaskQuery and put it into TaskSearchCriteria.
*/
protected void buildQueryToSearchCriteria() {
if (criteria.getCustomTaskQuery() == null) {
Expand All @@ -586,9 +562,8 @@ protected void buildQueryToSearchCriteria() {
}
}

TaskQuery taskQuery = buildTaskQuery();
extendSort(taskQuery);
criteria.setFinalTaskQuery(taskQuery);
criteria.setLegacyFilters(selectedFilters);
storeTaskFiltersIntoSession();
}

protected void setValuesForStateFilter(TaskSearchCriteria criteria, TaskFilterContainer filterContainer) {
Expand All @@ -600,19 +575,6 @@ protected void setValuesForStateFilter(TaskSearchCriteria criteria, TaskFilterCo
}
}

protected TaskQuery buildTaskQuery() {
TaskQuery taskQuery = criteria.createQuery();
IFilterQuery filterQuery = taskQuery.where();
selectedFilters.forEach(selectedFilter -> {
TaskQuery subQuery = selectedFilter.buildQuery();
if (subQuery != null) {
filterQuery.and(subQuery);
}
});
storeTaskFiltersIntoSession();
return taskQuery;
}

private void storeTaskFiltersIntoSession() {
if (shouldSaveAndLoadSessionFilters()) {
UserUtils.setSessionSelectedDefaultTaskFilterSetAttribute(isSelectedDefaultFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ private UIComponent findRelatedCaseComponent() {

private void initializedDataModel() {
data.clear();
criteria.setFinalCaseQuery(null);
}

private int getCaseCount(CaseSearchCriteria criteria) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ protected int getTaskCount(TaskSearchCriteria criteria) {

private void initializedDataModel() {
data.clear();
criteria.setFinalTaskQuery(null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public enum PortalPage {
ERROR_PAGE,
CASE_DETAIL_FROM_TASK,
SEARCH_RESULTS,
TASK_LIST,
DASHBOARD;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CaseCategorySearchCriteria {
public CaseQuery createQuery() {
CaseQuery finalQuery = CaseUtils.createBusinessCaseQuery();
if (customCaseQuery != null) {
finalQuery = CaseQuery.fromJson(customCaseQuery.asJson()); // clone to keep the original custom query
finalQuery.where().andOverall(customCaseQuery);
}

if (hasIncludedStates()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.axonivy.portal.enums.SearchScopeCaseField;

import ch.ivy.addon.portalkit.casefilter.CaseFilter;
import ch.ivy.addon.portalkit.enums.CaseSortField;
import ch.ivyteam.ivy.workflow.CaseState;
import ch.ivyteam.ivy.workflow.caze.CaseBusinessState;
Expand Down Expand Up @@ -44,12 +45,12 @@ public class CaseSearchCriteria {
private boolean isNewQueryCreated;
private boolean isSorted = true;
private CaseQuery customCaseQuery;

private CaseQuery finalCaseQuery;

private boolean isGlobalSearch;
private boolean isGlobalSearchScope;
private List<SearchScopeCaseField> searchScopeCaseFields;

private List<CaseFilter> legacyFilters;

public CaseQuery createQuery() {
CaseQuery finalQuery;
Expand All @@ -63,7 +64,7 @@ public CaseQuery createQuery() {

setNewQueryCreated(isNewQueryCreated() || customCaseQuery == null || hasCaseId());
if (!isNewQueryCreated()) {
finalQuery.where().andOverall(CaseQuery.fromJson(customCaseQuery.asJson())); // clone to keep the original custom query
finalQuery.where().andOverall(customCaseQuery);
}

if (hasIncludedStates()) {
Expand All @@ -82,6 +83,8 @@ public CaseQuery createQuery() {
finalQuery.where().and(queryForCategory(getCategory()));
}

queryLegacyFilters(finalQuery);

if (isSorted) {
CaseSortingQueryAppender appender = new CaseSortingQueryAppender(finalQuery);
finalQuery = appender.appendSorting(this).toQuery();
Expand All @@ -98,6 +101,17 @@ private CaseQuery queryForStates(List<CaseState> states) {
return stateFieldQuery;
}

private void queryLegacyFilters(CaseQuery finalQuery) {
if (CollectionUtils.isNotEmpty(legacyFilters)) {
for (CaseFilter filter : legacyFilters) {
CaseQuery subQuery = filter.buildQuery();
if (subQuery != null) {
finalQuery.where().and(subQuery);
}
}
}
}

private CaseQuery queryForKeyword(String keyword) {
String containingKeyword = String.format("%%%s%%", keyword.trim());
CaseQuery filterByKeywordQuery = newCaseQuery();
Expand Down Expand Up @@ -375,17 +389,6 @@ public void setNewQueryCreated(boolean isNewQueryCreated) {
this.isNewQueryCreated = isNewQueryCreated;
}

public CaseQuery getFinalCaseQuery() {
if (finalCaseQuery == null) {
finalCaseQuery = createQuery();
}
return finalCaseQuery;
}

public void setFinalCaseQuery(CaseQuery finalCaseQuery) {
this.finalCaseQuery = finalCaseQuery;
}

public List<SearchScopeCaseField> getSearchScopeCaseFields() {
return searchScopeCaseFields;
}
Expand All @@ -409,4 +412,12 @@ public void setGlobalSearchScope(boolean isGlobalSearchScope) {
this.isGlobalSearchScope = isGlobalSearchScope;
}

public List<CaseFilter> getLegacyFilters() {
return legacyFilters;
}

public void setLegacyFilters(List<CaseFilter> legacyFilters) {
this.legacyFilters = legacyFilters;
}

}
Loading

0 comments on commit e77a672

Please sign in to comment.