forked from kitodo/kitodo-production
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add switch to show roles of all clients available to current user
- Loading branch information
Showing
8 changed files
with
159 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Kitodo/src/main/java/org/kitodo/production/model/LazyRoleModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo project. | ||
* | ||
* It is licensed under GNU General Public License version 3 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* GPL3-License.txt file that was distributed with this source code. | ||
*/ | ||
|
||
package org.kitodo.production.model; | ||
|
||
import static java.lang.Math.toIntExact; | ||
|
||
import org.kitodo.data.database.exceptions.DAOException; | ||
import org.kitodo.production.services.data.RoleService; | ||
import org.primefaces.model.FilterMeta; | ||
import org.primefaces.model.SortOrder; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class LazyRoleModel extends LazyDTOModel { | ||
|
||
private boolean showRolesOfAllAvailableClients = false; | ||
|
||
public LazyRoleModel(RoleService roleService) { | ||
super(roleService); | ||
} | ||
|
||
public boolean isShowRolesOfAllAvailableClients() { | ||
return showRolesOfAllAvailableClients; | ||
} | ||
|
||
public void setShowRolesOfAllAvailableClients(boolean showRolesOfAllAvailableClients) { | ||
this.showRolesOfAllAvailableClients = showRolesOfAllAvailableClients; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public List<Object> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, | ||
FilterMeta> filters) { | ||
try { | ||
Map<String, Boolean> filterMap = Collections.singletonMap("allClients", showRolesOfAllAvailableClients); | ||
setRowCount(toIntExact(((RoleService) searchService).countResults(filterMap))); | ||
entities = ((RoleService) searchService).loadData(first, pageSize, sortField, sortOrder, filterMap); | ||
return entities; | ||
} catch (DAOException e) { | ||
setRowCount(0); | ||
logger.error(e.getMessage(), e); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters