• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-core / 26773559161

01 Jun 2026 06:21PM UTC coverage: 63.376% (-0.01%) from 63.389%
26773559161

push

github

web-flow
TRUNK-6429: Create application events for service method calls and entity changes (#6084)

272 of 504 new or added lines in 27 files covered. (53.97%)

5 existing lines in 2 files now uncovered.

23598 of 37235 relevant lines covered (63.38%)

0.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/api/src/main/java/org/openmrs/event/EntityEvent.java
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.event;
11

12
import org.jspecify.annotations.Nullable;
13
import org.springframework.core.ResolvableType;
14
import org.springframework.core.ResolvableTypeProvider;
15

16
import java.util.HashSet;
17
import java.util.Set;
18

19
/**
20
 * It can be implemented to publish application events related to an entity.
21
 * <p>
22
 * Entity events may be put in a transactional outbox. If there is a listener annotated with
23
 * {@link org.openmrs.event.outbox.OutboxEventListener} for an event, the event needs to be 
24
 * serializable to JSON with Jackson {@link com.fasterxml.jackson.databind.ObjectMapper} or
25
 * implement {@link org.openmrs.event.outbox.OutboxEventPayload}.
26
 * <p>
27
 * Entity events contain autopopulated sessionId to group events happening in the same session.
28
 * <p>
29
 * They may also contain tags to use them e.g. as listener conditions 
30
 * or include additional information for listeners.
31
 * 
32
 * @param <T> the related entity
33
 *     
34
 * @since 2.9.x
35
 */
36
        public abstract class EntityEvent<T> extends BaseEvent implements ResolvableTypeProvider {
37

38
        protected T entity;
39
        
NEW
40
        public EntityEvent() {
×
NEW
41
        }
×
42
        
43
        public EntityEvent(T entity) {
44
                this(entity, new HashSet<>());
1✔
45
        }
1✔
46
         
47
        public EntityEvent(T entity, Set<String> tags) {
48
                super(entity, tags);
1✔
49
                this.entity = entity;
1✔
50
        }
1✔
51

52
        public T getEntity() {
NEW
53
                return entity;
×
54
        }
55
        
56
        public void setEntity(T entity) {
NEW
57
                this.entity = entity;
×
NEW
58
                this.source = entity;
×
NEW
59
        }
×
60

61
        @Override
62
        public @Nullable ResolvableType getResolvableType() {
63
                if (entity != null && getClass().getTypeParameters().length == 1) {
1✔
64
                        return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forInstance(entity));
1✔
65
                } else {
NEW
66
                        return ResolvableType.forClass(getClass());
×
67
                }
68
        }
69
        
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc