Skip to content

Commit

Permalink
Added DiseaseDetails Rights
Browse files Browse the repository at this point in the history
  • Loading branch information
daveotengo committed Oct 29, 2024
1 parent 8b4b9a9 commit abd7f51
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public enum FeatureType {
CONTACT_TRACING },
null,
ImmutableMap.of(FeatureTypeProperty.S2S_SHARING, Boolean.FALSE)),
DISEASE_DETAILS(false, true, null, null, null);
DISEASE_DETAILS(true, false, null, null, null);

public static final FeatureType[] SURVEILLANCE_FEATURE_TYPES = {
FeatureType.CASE_SURVEILANCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public Set<UserRight> getDefaultUserRights() {
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_ARCHIVE,
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_DELETE,
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EXPORT,
DISEASE_DETAILS_VIEW,
PERSON_VIEW,
PERSON_EDIT,
PERSON_DELETE,
Expand Down Expand Up @@ -1329,6 +1330,7 @@ public Set<UserRight> getDefaultUserRights() {
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_ARCHIVE,
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_DELETE,
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EXPORT,
DISEASE_DETAILS_VIEW,
PERSON_VIEW,
PERSON_EDIT,
PERSON_DELETE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public enum UserRight {
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_DELETE(UserRightGroup.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION),
ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EXPORT(UserRightGroup.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION),

DISEASE_DETAILS_VIEW(UserRightGroup.DISEASE_DETAILS_VIEW),

PERSON_VIEW(UserRightGroup.PERSON),
PERSON_EDIT(UserRightGroup.PERSON, UserRight._PERSON_VIEW),
PERSON_DELETE(UserRightGroup.PERSON, UserRight._PERSON_VIEW, UserRight._VISIT_DELETE),
Expand Down Expand Up @@ -531,6 +533,7 @@ public enum UserRight {
public static final String _EXTERNAL_EMAIL_SEND = "EXTERNAL_EMAIL_SEND";
public static final String _EXTERNAL_EMAIL_ATTACH_DOCUMENTS = "EXTERNAL_EMAIL_ATTACH_DOCUMENTS";
public static final String _CUSTOMIZABLE_ENUM_MANAGEMENT = "CUSTOMIZABLE_ENUM_MANAGEMENT";
public static final String _DISEASE_DETAILS_VIEW ="DISEASE_DETAILS_VIEW" ;

private static final Map<UserRight, Set<UserRight>> userRightDependencies = buildUserRightDependencies();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public enum UserRightGroup {

EXPORT,
CONFIGURATION,
EXTERNAL;
EXTERNAL,
DISEASE_DETAILS_VIEW;

@Override
public String toString() {
Expand Down
2 changes: 2 additions & 0 deletions sormas-api/src/main/resources/enum.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,7 @@ UserRight.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EDIT = Edit existing adverse eve
UserRight.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_DELETE = Delete adverse events following immunization from the system
UserRight.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_ARCHIVE = Archive adverse events following immunization
UserRight.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EXPORT = Export adverse events following immunization
UserRight.DISEASE_DETAILS_VIEW = View details of selected disease
UserRight.PERSON_EXPORT = Export persons
UserRight.CONTACT_MERGE = Merge contacts
UserRight.EVENTGROUP_CREATE = Create new event groups
Expand Down Expand Up @@ -1790,6 +1791,7 @@ UserRight.Desc.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EDIT = Able to edit existin
UserRight.Desc.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_DELETE = Able to delete adverse events following immunization from the system
UserRight.Desc.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_ARCHIVE = Able to archive adverse events following immunization
UserRight.Desc.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EXPORT = Able to export adverse events following immunization
UserRight.Desc.DISEASE_DETAILS_VIEW = Able to View details of selected disease
UserRight.Desc.PERSON_EXPORT = Able to export persons
UserRight.Desc.CONTACT_MERGE = Able to merge contacts
UserRight.Desc.EVENTGROUP_CREATE = Able to create new event groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ public List<DiseaseBurdenDto> getDiseaseBurden(
}

@Override
@RightsAllowed({UserRight._DISEASE_DETAILS_VIEW})
public DiseaseBurdenDto getDiseaseForDashboard(
RegionReferenceDto region,
DistrictReferenceDto district,
Expand Down Expand Up @@ -875,6 +876,8 @@ public DiseaseBurdenDto getDiseaseForDashboard(
}

@Override
@RightsAllowed({
UserRight._DISEASE_DETAILS_VIEW})
public DiseaseBurdenDto getDiseaseGridForDashboard(
RegionReferenceDto region,
DistrictReferenceDto district,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ public Predicate buildCriteriaFilter(OutbreakCriteria criteria, CriteriaBuilder
filter = CriteriaBuilderHelper.and(cb, filter, from.get(Outbreak.DISEASE).in(criteria.getDiseases()));
}
if (criteria.getDistrict() != null) {
filter = CriteriaBuilderHelper.and(cb, filter, cb.equal(from.join(Outbreak.DISTRICT, JoinType.LEFT).get(District.UUID), criteria.getDistrict().getUuid()));
filter = CriteriaBuilderHelper
.and(cb, filter, cb.equal(from.join(Outbreak.DISTRICT, JoinType.LEFT).get(District.UUID), criteria.getDistrict().getUuid()));
}
if (criteria.getRegion() != null) {
filter = CriteriaBuilderHelper.and(
Expand All @@ -194,7 +195,8 @@ public Predicate buildCriteriaFilter(OutbreakCriteria criteria, CriteriaBuilder
filter = CriteriaBuilderHelper.and(cb, filter, activeFilter);
}
if (criteria.getReportedDateFrom() != null || criteria.getReportedDateTo() != null) {
filter = CriteriaBuilderHelper.and(cb, filter, cb.between(from.get(Outbreak.REPORT_DATE), criteria.getReportedDateFrom(), criteria.getReportedDateTo()));
filter = CriteriaBuilderHelper
.and(cb, filter, cb.between(from.get(Outbreak.REPORT_DATE), criteria.getReportedDateFrom(), criteria.getReportedDateTo()));
}

return filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,11 @@
<group-name>DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VIEW</group-name>
</security-role-mapping>

<security-role-mapping>
<role-name>DISEASE_DETAILS_VIEW</role-name>
<group-name>DISEASE_DETAILS_VIEW</group-name>
</security-role-mapping>

<security-role-mapping>
<role-name>CASE_CLINICIAN_VIEW</role-name>
<group-name>CASE_CLINICIAN_VIEW</group-name>
Expand Down
5 changes: 5 additions & 0 deletions sormas-backend/src/main/resources/sql/sormas_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13668,4 +13668,9 @@ INSERT INTO userroles_userrights (userrole_id, userright) SELECT id, 'ADVERSE_EV
INSERT INTO userroles_userrights (userrole_id, userright) SELECT id, 'ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_EXPORT' FROM public.userroles WHERE userroles.linkeddefaultuserrole in ('ADMIN','NATIONAL_USER');

INSERT INTO schema_version (version_number, comment) VALUES (552, 'Adverse Events Following Immunization (AEFI) - Entities #12634');

-- Assign DISEASE_DETAILS_VIEW user rights to default admin and national_user user roles
INSERT INTO userroles_userrights (userrole_id, userright) SELECT id, 'DISEASE_DETAILS_VIEW' FROM public.userroles WHERE userroles.linkeddefaultuserrole in ('ADMIN','NATIONAL_USER');

INSERT INTO schema_version (version_number, comment) VALUES (553, 'Dashboard Diseases Details View - #12880');
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***
5 changes: 5 additions & 0 deletions sormas-rest/src/main/webapp/WEB-INF/glassfish-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@
<group-name>DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VIEW</group-name>
</security-role-mapping>

<security-role-mapping>
<role-name>DISEASE_DETAILS_VIEW</role-name>
<group-name>DISEASE_DETAILS_VIEW</group-name>
</security-role-mapping>

<security-role-mapping>
<role-name>CASE_CLINICIAN_VIEW</role-name>
<group-name>CASE_CLINICIAN_VIEW</group-name>
Expand Down
4 changes: 4 additions & 0 deletions sormas-rest/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@
<role-name>DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VIEW</role-name>
</security-role>

<security-role>
<role-name>DISEASE_DETAILS_VIEW</role-name>
</security-role>

<security-role>
<role-name>CASE_CLINICIAN_VIEW</role-name>
</security-role>
Expand Down
4 changes: 4 additions & 0 deletions sormas-ui/src/main/java/de/symeda/sormas/ui/MainScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ private static boolean aefiDashboardPermitted() {
UserRight.DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VIEW);
}

private static boolean diseaseDetailsDashboardPermitted() {
return permitted(EnumSet.of(FeatureType.DISEASE_DETAILS),UserRight.DISEASE_DETAILS_VIEW);
}

private static Set<String> initKnownViews() {
final Set<String> views = new HashSet<>(
Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected AbstractDashboardView(String viewName) {
dashboardSwitcher.setItemCaption(DashboardType.CAMPAIGNS, I18nProperties.getEnumCaption(DashboardType.CAMPAIGNS));
}

if (permitted(FeatureType.DISEASE_DETAILS)) {
if (permitted(FeatureType.DISEASE_DETAILS , UserRight.DISEASE_DETAILS_VIEW) ) {
dashboardSwitcher.addItem(DashboardType.DISEASE);
dashboardSwitcher.setItemCaption(DashboardType.DISEASE, I18nProperties.getEnumCaption(DashboardType.DISEASE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void registerViews(Navigator navigator) {
navigator.addView(SampleDashboardView.VIEW_NAME, SampleDashboardView.class);
}

if (permitted(FeatureType.DISEASE_DETAILS)) {
if (permitted(FeatureType.DISEASE_DETAILS, UserRight.DISEASE_DETAILS_VIEW)) {
navigator.addView(DiseaseDetailsView.VIEW_NAME, DiseaseDetailsView.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import de.symeda.sormas.ui.dashboard.DashboardDataProvider;
import de.symeda.sormas.ui.utils.ButtonHelper;
import com.vaadin.ui.themes.ValoTheme;
import de.symeda.sormas.api.feature.FeatureType;
import de.symeda.sormas.api.user.UserRight;
import static de.symeda.sormas.ui.UiUtil.permitted;

public class DiseaseTileComponent extends VerticalLayout {

Expand Down Expand Up @@ -153,7 +156,7 @@ private void addTopLayout(Disease disease, Long casesCount, Long previousCasesCo
addComponent(layout);
}

private void addStatsLayout(DiseaseBurdenDto diseaseBurden,DashboardDataProvider dashboardDataProvider) {
private void addStatsLayout(DiseaseBurdenDto diseaseBurden, DashboardDataProvider dashboardDataProvider) {
Long fatalities = diseaseBurden.getCaseDeathCount();
Long events = diseaseBurden.getEventCount();
String district = diseaseBurden.getLastReportedDistrictName();
Expand All @@ -166,22 +169,27 @@ private void addStatsLayout(DiseaseBurdenDto diseaseBurden,DashboardDataProvider
layout.addStyleName(CssStyles.BACKGROUND_HIGHLIGHT);

StatsItem lastReportItem =
new StatsItem.Builder(Captions.dashboardLastReport, district.isEmpty() ? I18nProperties.getString(Strings.none) : district)
new StatsItem.Builder(Captions.dashboardLastReport, district.length() == 0 ? I18nProperties.getString(Strings.none) : district)
.singleColumn(true)
.build();
lastReportItem.addStyleName(CssStyles.VSPACE_TOP_4);
layout.addComponent(lastReportItem);

StatsItem fatality = new StatsItem.Builder(Captions.dashboardFatalities, fatalities).critical(fatalities > 0).build();
fatality.addStyleName(CssStyles.HSPACE_LEFT_5);
if (permitted(FeatureType.DISEASE_DETAILS , UserRight.DISEASE_DETAILS_VIEW) ) {
fatality.addStyleName(CssStyles.HSPACE_LEFT_5);
}

layout.addComponent(fatality);

StatsItem noOfEventsItem = new StatsItem.Builder(Captions.DiseaseBurden_eventCount, events).build();
noOfEventsItem.addStyleName(CssStyles.VSPACE_4);
layout.addComponent(noOfEventsItem);

Button component = addDiseaseButton(disease, dashboardDataProvider);
layout.addComponent(component);
if (permitted(FeatureType.DISEASE_DETAILS , UserRight.DISEASE_DETAILS_VIEW) ) {
Button component = addDiseaseButton(disease, dashboardDataProvider);
layout.addComponent(component);
}

addComponent(layout);
}
Expand Down
7 changes: 6 additions & 1 deletion sormas-ui/src/main/webapp/WEB-INF/glassfish-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,12 @@

<security-role-mapping>
<role-name>DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VIEW</role-name>
<group-name>DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VIEW</group-name>
<group-name>DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VI+EW</group-name>
</security-role-mapping>

<security-role-mapping>
<role-name>DISEASE_DETAILS_VIEW</role-name>
<group-name>DISEASE_DETAILS_VIEW</group-name>
</security-role-mapping>

<security-role-mapping>
Expand Down
4 changes: 4 additions & 0 deletions sormas-ui/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@
<role-name>DASHBOARD_ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_VIEW</role-name>
</security-role>

<security-role>
<role-name>DISEASE_DETAILS_VIEW</role-name>
</security-role>

<security-role>
<role-name>CASE_CLINICIAN_VIEW</role-name>
</security-role>
Expand Down

0 comments on commit abd7f51

Please sign in to comment.