-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12668 from SORMAS-Foundation/change-10796-sync_di…
…alog_entities_shown Change 10796 sync dialog entities shown
- Loading branch information
Showing
5 changed files
with
568 additions
and
218 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
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
40 changes: 30 additions & 10 deletions
40
sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DtoUserRightsHelper.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 |
---|---|---|
@@ -1,37 +1,57 @@ | ||
/* | ||
* SORMAS® - Surveillance Outbreak Response Management & Analysis System | ||
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) | ||
* | ||
* 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 de.symeda.sormas.app.backend.common; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import de.symeda.sormas.api.feature.FeatureType; | ||
import de.symeda.sormas.api.user.DtoViewAndEditRights; | ||
import de.symeda.sormas.api.user.UserRight; | ||
import de.symeda.sormas.app.backend.config.ConfigProvider; | ||
|
||
public class DtoUserRightsHelper { | ||
|
||
public static boolean isViewAllowed(Class clazz) { | ||
UserRight userRightView = DtoViewAndEditRights.getUserRightView(clazz); | ||
return userRightView == null || ConfigProvider.hasUserRight(userRightView); | ||
public static boolean isViewAllowed(Class<?> clazz) { | ||
Set<UserRight> userRightsView = DtoViewAndEditRights.getUserRightsView(clazz); | ||
return userRightsView == null || userRightsView.stream().anyMatch(ConfigProvider::hasUserRight); | ||
} | ||
|
||
public static boolean isViewAllowedWithFeatureDependencies(Class<?> clazz, Map<UserRight, FeatureType> featureDependencies) { | ||
Set<UserRight> userRightsView = DtoViewAndEditRights.getUserRightsView(clazz); | ||
return userRightsView == null | ||
|| userRightsView.stream() | ||
.anyMatch( | ||
r -> ConfigProvider.hasUserRight(r) | ||
&& (!featureDependencies.containsKey(r) | ||
|| DatabaseHelper.getFeatureConfigurationDao().isFeatureEnabled(featureDependencies.get(r)))); | ||
} | ||
|
||
public static boolean isEditAllowed(Class<?> clazz) { | ||
Set<UserRight> userRightsEdit = DtoViewAndEditRights.getUserRightsEdit(clazz); | ||
return userRightsEdit == null || userRightsEdit.stream().anyMatch(ConfigProvider::hasUserRight); | ||
} | ||
|
||
public static boolean isEditAllowed(Class clazz) { | ||
UserRight userRightEdit = DtoViewAndEditRights.getUserRightEdit(clazz); | ||
return userRightEdit == null || ConfigProvider.hasUserRight(userRightEdit); | ||
public static boolean isEditAllowedWithFeatureDependencies(Class<?> clazz, Map<UserRight, FeatureType> featureDependencies) { | ||
Set<UserRight> userRightsEdit = DtoViewAndEditRights.getUserRightsEdit(clazz); | ||
return userRightsEdit == null | ||
|| userRightsEdit.stream() | ||
.anyMatch( | ||
r -> ConfigProvider.hasUserRight(r) | ||
&& (!featureDependencies.containsKey(r) | ||
|| DatabaseHelper.getFeatureConfigurationDao().isFeatureEnabled(featureDependencies.get(r)))); | ||
} | ||
} |
Oops, something went wrong.