Skip to content

Commit 8c84a04

Browse files
committed
RA-429 : create a class that produces the administration notification when duplicate concepts exists
RA-429 : Modiied the condition for displaying the Notification , to suit all diferent locales
1 parent a9a47b2 commit 8c84a04

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.openmrs.module.referenceapplication.administrativenotification;
2+
3+
import java.util.List;
4+
import java.util.Arrays;
5+
6+
import org.openmrs.api.context.Context;
7+
import org.openmrs.module.appframework.factory.AdministrativeNotificationProducer;
8+
import org.openmrs.module.appframework.domain.AdministrativeNotification;
9+
import org.springframework.stereotype.Component;
10+
11+
@Component
12+
public class DuplicateConceptNotification implements AdministrativeNotificationProducer{
13+
14+
15+
16+
@Override
17+
public List<AdministrativeNotification> generateNotifications() {
18+
19+
20+
if (!Context.hasPrivilege("Manage Concepts")) {
21+
return null;
22+
}
23+
24+
AdministrativeNotification notification = new AdministrativeNotification();
25+
26+
27+
// checking whether concepts 1 and 2 exist in the system
28+
try {
29+
Integer concept1 = Context.getConceptService().getConcept(1).getConceptId();
30+
Integer concept2 = Context.getConceptService().getConcept(2).getConceptId();
31+
}catch (NullPointerException e) {
32+
return null;
33+
}
34+
35+
36+
notification.setId("DuplicateConcepts.id");
37+
notification.setIcon("icon-info-sign");
38+
notification.setCssClass("success");
39+
notification.setLabel("DuplicateConcepts.label");
40+
notification.setRequiredPrivilege("Manage Concepts");
41+
42+
43+
44+
return Arrays.asList(notification);
45+
}
46+
}

api/src/main/resources/messages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,6 @@ referenceapplication.formentryapp.manageforms.label=Manage Forms
107107

108108
general.auditInfo=Audit Info
109109

110+
DuplicateConcepts.label= Duplicate concepts exist. Please Upgrade to the latest version of reference Metadata Module
111+
DuplicateConcepts.id = Duplicate
112+

0 commit comments

Comments
 (0)