1+ /**
2+ * This Source Code Form is subject to the terms of the Mozilla Public License,
3+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+ * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5+ * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6+ *
7+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8+ * graphic logo is a trademark of OpenMRS Inc.
9+ */
10+ package org .openmrs .module .referenceapplication .administrativenotification ;
11+
12+ import java .util .List ;
13+ import java .util .Arrays ;
14+
15+ import org .openmrs .api .context .Context ;
16+ import org .openmrs .module .appframework .factory .AdministrativeNotificationProducer ;
17+ import org .openmrs .module .appframework .domain .AdministrativeNotification ;
18+ import org .springframework .stereotype .Component ;
19+
20+ @ Component
21+ public class DuplicateConceptNotification implements AdministrativeNotificationProducer {
22+
23+
24+
25+ @ Override
26+ public List <AdministrativeNotification > generateNotifications () {
27+
28+
29+ if (!Context .hasPrivilege ("Manage Concepts" )) {
30+ return null ;
31+ }
32+
33+ AdministrativeNotification notification = new AdministrativeNotification ();
34+
35+
36+ // checking whether concepts 1 and 2 exist in the system
37+
38+ if ( Context .getConceptService ().getConcept (1 )==null || Context .getConceptService ().getConcept (2 )==null
39+ ) {
40+ return null ;
41+ }
42+
43+ notification .setId ("DuplicateConcepts.id" );
44+ notification .setIcon ("icon-info-sign" );
45+ notification .setCssClass ("success" );
46+ notification .setLabel ("DuplicateConcepts.label" );
47+ notification .setRequiredPrivilege ("Manage Concepts" );
48+
49+
50+
51+ return Arrays .asList (notification );
52+ }
53+ }
0 commit comments