Search in sources :

Example 1 with OrderBy

use of org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy in project OpenOLAT by OpenOLAT.

the class RepositoryEntryAuthorQueriesTest method searchViews_orderBy.

@Test
public void searchViews_orderBy() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("view-");
    dbInstance.commit();
    Roles roles = securityManager.getRoles(id);
    SearchAuthorRepositoryEntryViewParams params = new SearchAuthorRepositoryEntryViewParams(id, roles);
    params.setMarked(Boolean.TRUE);
    for (OrderBy orderBy : OrderBy.values()) {
        params.setOrderBy(orderBy);
        params.setOrderByAsc(true);
        List<RepositoryEntryAuthorView> viewAsc = repositoryEntryAuthorViewQueries.searchViews(params, 0, 10);
        Assert.assertNotNull(viewAsc);
        params.setOrderByAsc(false);
        List<RepositoryEntryAuthorView> viewDesc = repositoryEntryAuthorViewQueries.searchViews(params, 0, 10);
        Assert.assertNotNull(viewDesc);
    }
}
Also used : OrderBy(org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy) RepositoryEntryAuthorView(org.olat.repository.RepositoryEntryAuthorView) Roles(org.olat.core.id.Roles) Identity(org.olat.core.id.Identity) SearchAuthorRepositoryEntryViewParams(org.olat.repository.model.SearchAuthorRepositoryEntryViewParams) Test(org.junit.Test)

Example 2 with OrderBy

use of org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy in project OpenOLAT by OpenOLAT.

the class AuthoringEntryDataSource method getRows.

@Override
public final ResultInfos<AuthoringEntryRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
    if (filters != null && filters.size() > 0) {
        String filter = filters.get(0).getFilter();
        if (StringHelper.containsNonWhitespace(filter)) {
            searchParams.setResourceTypes(Collections.singletonList(filter));
        } else {
            searchParams.setResourceTypes(null);
        }
    } else if (useFilters) {
        searchParams.setResourceTypes(null);
    }
    if (orderBy != null && orderBy.length > 0 && orderBy[0] != null) {
        OrderBy o = OrderBy.valueOf(orderBy[0].getKey());
        searchParams.setOrderBy(o);
        searchParams.setOrderByAsc(orderBy[0].isAsc());
    }
    if (StringHelper.containsNonWhitespace(query)) {
        searchParams.setIdRefsAndTitle(query);
    } else {
        searchParams.setIdRefsAndTitle(null);
    }
    List<RepositoryEntryAuthorView> views = repositoryService.searchAuthorView(searchParams, firstResult, maxResults);
    List<AuthoringEntryRow> rows = processViewModel(views);
    ResultInfos<AuthoringEntryRow> results = new DefaultResultInfos<>(firstResult + rows.size(), -1, rows);
    if (firstResult == 0 && views.size() < maxResults) {
        count = new Integer(views.size());
    }
    return results;
}
Also used : OrderBy(org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy) DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) RepositoryEntryAuthorView(org.olat.repository.RepositoryEntryAuthorView)

Example 3 with OrderBy

use of org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy in project openolat by klemens.

the class AuthoringEntryDataSource method getRows.

@Override
public final ResultInfos<AuthoringEntryRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
    if (filters != null && filters.size() > 0) {
        String filter = filters.get(0).getFilter();
        if (StringHelper.containsNonWhitespace(filter)) {
            searchParams.setResourceTypes(Collections.singletonList(filter));
        } else {
            searchParams.setResourceTypes(null);
        }
    } else if (useFilters) {
        searchParams.setResourceTypes(null);
    }
    if (orderBy != null && orderBy.length > 0 && orderBy[0] != null) {
        OrderBy o = OrderBy.valueOf(orderBy[0].getKey());
        searchParams.setOrderBy(o);
        searchParams.setOrderByAsc(orderBy[0].isAsc());
    }
    if (StringHelper.containsNonWhitespace(query)) {
        searchParams.setIdRefsAndTitle(query);
    } else {
        searchParams.setIdRefsAndTitle(null);
    }
    List<RepositoryEntryAuthorView> views = repositoryService.searchAuthorView(searchParams, firstResult, maxResults);
    List<AuthoringEntryRow> rows = processViewModel(views);
    ResultInfos<AuthoringEntryRow> results = new DefaultResultInfos<>(firstResult + rows.size(), -1, rows);
    if (firstResult == 0 && views.size() < maxResults) {
        count = new Integer(views.size());
    }
    return results;
}
Also used : OrderBy(org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy) DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) RepositoryEntryAuthorView(org.olat.repository.RepositoryEntryAuthorView)

Example 4 with OrderBy

use of org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy in project OpenOLAT by OpenOLAT.

the class RepositoryEntryAuthorQueries method appendAuthorViewOrderBy.

private void appendAuthorViewOrderBy(SearchAuthorRepositoryEntryViewParams params, StringBuilder sb) {
    OrderBy orderBy = params.getOrderBy();
    boolean asc = params.isOrderByAsc();
    if (orderBy != null) {
        switch(orderBy) {
            case key:
                sb.append(" order by v.key");
                appendAsc(sb, asc);
                break;
            case favorit:
                if (asc) {
                    sb.append(" order by marks asc, lower(v.displayname) asc");
                } else {
                    sb.append(" order by marks desc, lower(v.displayname) desc");
                }
                break;
            case type:
                sb.append(" order by res.resName");
                appendAsc(sb, asc);
                break;
            case displayname:
                sb.append(" order by lower(v.displayname)");
                appendAsc(sb, asc);
                break;
            case authors:
                sb.append(" order by lower(v.authors)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case author:
                sb.append(" order by lower(v.initialAuthor)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case location:
                sb.append(" order by lower(v.location)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case access:
                if (asc) {
                    sb.append(" order by v.membersOnly asc, v.access asc, lower(v.displayname) asc");
                } else {
                    sb.append(" order by v.membersOnly desc, v.access desc, lower(v.displayname) desc");
                }
                break;
            case ac:
                if (asc) {
                    sb.append(" order by offers asc, lower(v.displayname) asc");
                } else {
                    sb.append(" order by offers desc, lower(v.displayname) desc");
                }
                break;
            case references:
                {
                    if (asc) {
                        sb.append(" order by references asc, lower(v.displayname) asc");
                    } else {
                        sb.append(" order by references desc, lower(v.displayname) desc");
                    }
                    break;
                }
            case creationDate:
                sb.append(" order by v.creationDate ");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case lastUsage:
                sb.append(" order by v.statistics.lastUsage ");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case externalId:
                sb.append(" order by lower(v.externalId)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case externalRef:
                sb.append(" order by lower(v.externalRef)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case lifecycleLabel:
                sb.append(" order by lifecycle.label ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case lifecycleSoftkey:
                sb.append(" order by lifecycle.softKey ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case lifecycleStart:
                sb.append(" order by lifecycle.validFrom ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case lifecycleEnd:
                sb.append(" order by lifecycle.validTo ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case deletionDate:
                sb.append(" order by v.deletionDate ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case deletedBy:
                if (params.isDeleted()) {
                    sb.append(" order by deletedByUser.lastName ");
                    appendAsc(sb, asc).append(" nulls last, deletedByUser.firstName ");
                    appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                }
                break;
        }
    }
}
Also used : OrderBy(org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy)

Example 5 with OrderBy

use of org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy in project openolat by klemens.

the class RepositoryEntryAuthorQueries method appendAuthorViewOrderBy.

private void appendAuthorViewOrderBy(SearchAuthorRepositoryEntryViewParams params, StringBuilder sb) {
    OrderBy orderBy = params.getOrderBy();
    boolean asc = params.isOrderByAsc();
    if (orderBy != null) {
        switch(orderBy) {
            case key:
                sb.append(" order by v.key");
                appendAsc(sb, asc);
                break;
            case favorit:
                if (asc) {
                    sb.append(" order by marks asc, lower(v.displayname) asc");
                } else {
                    sb.append(" order by marks desc, lower(v.displayname) desc");
                }
                break;
            case type:
                sb.append(" order by res.resName");
                appendAsc(sb, asc);
                break;
            case displayname:
                sb.append(" order by lower(v.displayname)");
                appendAsc(sb, asc);
                break;
            case authors:
                sb.append(" order by lower(v.authors)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case author:
                sb.append(" order by lower(v.initialAuthor)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case location:
                sb.append(" order by lower(v.location)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case access:
                if (asc) {
                    sb.append(" order by v.membersOnly asc, v.access asc, lower(v.displayname) asc");
                } else {
                    sb.append(" order by v.membersOnly desc, v.access desc, lower(v.displayname) desc");
                }
                break;
            case ac:
                if (asc) {
                    sb.append(" order by offers asc, lower(v.displayname) asc");
                } else {
                    sb.append(" order by offers desc, lower(v.displayname) desc");
                }
                break;
            case references:
                {
                    if (asc) {
                        sb.append(" order by references asc, lower(v.displayname) asc");
                    } else {
                        sb.append(" order by references desc, lower(v.displayname) desc");
                    }
                    break;
                }
            case creationDate:
                sb.append(" order by v.creationDate ");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case lastUsage:
                sb.append(" order by v.statistics.lastUsage ");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case externalId:
                sb.append(" order by lower(v.externalId)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case externalRef:
                sb.append(" order by lower(v.externalRef)");
                appendAsc(sb, asc).append(", lower(v.displayname) asc");
                break;
            case lifecycleLabel:
                sb.append(" order by lifecycle.label ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case lifecycleSoftkey:
                sb.append(" order by lifecycle.softKey ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case lifecycleStart:
                sb.append(" order by lifecycle.validFrom ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case lifecycleEnd:
                sb.append(" order by lifecycle.validTo ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case deletionDate:
                sb.append(" order by v.deletionDate ");
                appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                break;
            case deletedBy:
                if (params.isDeleted()) {
                    sb.append(" order by deletedByUser.lastName ");
                    appendAsc(sb, asc).append(" nulls last, deletedByUser.firstName ");
                    appendAsc(sb, asc).append(" nulls last, lower(v.displayname) asc");
                }
                break;
        }
    }
}
Also used : OrderBy(org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy)

Aggregations

OrderBy (org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy)6 RepositoryEntryAuthorView (org.olat.repository.RepositoryEntryAuthorView)4 Test (org.junit.Test)2 DefaultResultInfos (org.olat.core.commons.persistence.DefaultResultInfos)2 Identity (org.olat.core.id.Identity)2 Roles (org.olat.core.id.Roles)2 SearchAuthorRepositoryEntryViewParams (org.olat.repository.model.SearchAuthorRepositoryEntryViewParams)2