Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated changes in ICT4H repo #6

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b263327
Neha | using the request's headers to figure out the scheme of the ur…
Apr 12, 2016
98c55b2
Neha | refactoring url formation logic.
Apr 14, 2016
79dcf95
Neha | removing autowiring of url util.
Apr 14, 2016
295419e
[maven-release-plugin] prepare release openmrs-atomfeed-2.5.1
angshu Feb 1, 2016
14c5967
[maven-release-plugin] prepare for next development iteration
angshu Feb 1, 2016
07394d2
upgrading dependency to atomfeed 1.9.2
angshu Apr 21, 2016
1b217c1
[maven-release-plugin] prepare release openmrs-atomfeed-2.5.2
angshu Apr 21, 2016
bb14f12
[maven-release-plugin] prepare for next development iteration
angshu Apr 21, 2016
1606a6b
[maven-release-plugin] rollback the release of openmrs-atomfeed-2.5.2
angshu Apr 21, 2016
8eebf01
removing pushchanges
angshu Apr 21, 2016
b68e082
[maven-release-plugin] prepare release openmrs-atomfeed-2.5.2
angshu Apr 21, 2016
5a22ae6
[maven-release-plugin] prepare for next development iteration
angshu Apr 21, 2016
632a159
angshu | adding migration for default population of chunking_history …
angshu Jun 3, 2016
9b0f381
changing atomfeed dependency version
angshu Jul 8, 2016
cc284cc
Sanjit, Jaswanth | #1977 | Add interceptor for relationship save
aj-jaswanth Jul 11, 2016
157d692
Merge pull request #4 from aj-jaswanth/master
angshu Jul 12, 2016
fb43cfa
adding tags in event_records table and updated dependency
angshu Jul 8, 2016
814373f
Pankaj, Koushik | #1978 | Added Interceptor for Patient Program Changes
pankajladhar Jul 14, 2016
e0a5015
Merge pull request #5 from pankajladhar/master
angshu Jul 14, 2016
ad124b8
removing underscrore from the program enrollment category
angshu Jul 18, 2016
165d5d2
updating dependency of atomfeed core library to 1.9.3 release
angshu Jul 18, 2016
200da35
[maven-release-plugin] prepare release openmrs-atomfeed-2.5.3
angshu Jul 18, 2016
781230d
[maven-release-plugin] prepare for next development iteration
angshu Jul 18, 2016
07544b0
Preethi, Angshu | Creating transaction manager and event service on d…
preethi29 Aug 5, 2016
7fd5bc5
[maven-release-plugin] prepare release openmrs-atomfeed-2.5.4
angshu Aug 5, 2016
d4d67ce
[maven-release-plugin] prepare for next development iteration
angshu Aug 5, 2016
46affeb
Preethi, Gaurav | Changes required for openmrs 2.0
preethi29 Sep 16, 2016
e2f8ef3
Preethi | Added legacyui as a dependency to start before this module
preethi29 Sep 26, 2016
03f7a80
[maven-release-plugin] prepare release openmrs-atomfeed-2.5.5
angshu Nov 7, 2017
2bece53
[maven-release-plugin] prepare for next development iteration
angshu Nov 7, 2017
a9f53f7
Updating for openmrs api and legacy UI changes.
angshu Nov 9, 2017
44bef20
[maven-release-plugin] prepare release openmrs-atomfeed-2.5.6
angshu Nov 9, 2017
23060f7
[maven-release-plugin] prepare for next development iteration
angshu Nov 9, 2017
1491953
Allow this OMOD to load on 2.4.0+
ibacher Sep 17, 2021
975d33c
Merge pull request #7 from ibacher/omrs-2.4.0
angshu Sep 23, 2021
6bb7d21
Upgrade to Atomfeed core libs 1.10.0 (#8)
angshu Feb 21, 2022
cba62e4
Added Profile for release
angshu Feb 21, 2022
c13de3f
Uping version to bring in fix for memory appender done in atomfeed co…
angshu Feb 23, 2022
512a9d2
Uping dev version
angshu Feb 23, 2022
5da2c70
BAH-1467 - | Rohit | - Upgrades openmrs version to 2.4.0 and spring v…
rohit-yawalkar May 11, 2022
ceda309
releasing 2.6.2 - upgrade log4j 2.17, Spring 5.2.x, OMRS 2.4.2+
angshu Nov 15, 2022
3364fbd
Uping dev version to 2.6.3-SNAPSHOT
angshu Nov 15, 2022
3bf024d
BAH-3706 |Updated to resolve issue with event not getting generated f…
deepthi-mantena Apr 3, 2024
786ad7a
Release 2.6.3: Minor feature added to raise events for INVESTIGATION …
angshu Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions openmrs-atomfeed-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.ict4h.openmrs</groupId>
<artifactId>openmrs-atomfeed</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.3</version>
</parent>

<artifactId>openmrs-atomfeed-api</artifactId>
Expand All @@ -17,14 +17,25 @@
<dependency>
<groupId>org.ict4h</groupId>
<artifactId>atomfeed-server</artifactId>
<version>${atomfeed.version}</version>
</dependency>

<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<type>jar</type>
</dependency>


<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>

<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.openmrs.module.atomfeed;

import groovy.lang.GroovyClassLoader;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openmrs.module.atomfeed.advice.EncounterSaveAdvice;
import org.openmrs.module.atomfeed.filter.DefaultEventPublishFilter;
import org.openmrs.module.atomfeed.filter.EventPublishFilter;
Expand All @@ -14,7 +15,7 @@

public class EventPublishFilterHook {

private static final Logger log = Logger.getLogger(EncounterSaveAdvice.class);
private static final Logger log = LogManager.getLogger(EncounterSaveAdvice.class);
private static GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
private static Map<String, EventPublishFilter> eventPublishFilterMap = new HashMap<String, EventPublishFilter>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.ict4h.atomfeed.server.service.EventService;
import org.ict4h.atomfeed.server.service.EventServiceImpl;
import org.ict4h.atomfeed.transaction.AFTransactionWorkWithoutResult;
import org.joda.time.DateTime;
import org.openmrs.api.context.Context;
import org.openmrs.module.atomfeed.EventPublishFilterHook;
import org.openmrs.module.atomfeed.transaction.support.AtomFeedSpringTransactionManager;
Expand All @@ -17,6 +16,7 @@
import java.lang.reflect.Method;
import java.net.URI;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

Expand Down Expand Up @@ -46,7 +46,7 @@ public void afterReturning(Object returnValue, Method method, Object[] args, Obj
if (method.getName().equals(SAVE_METHOD)) {
Object encounterUuid = PropertyUtils.getProperty(returnValue, "encounterUuid");
String url = String.format(ENCOUNTER_REST_URL, encounterUuid);
final Event event = new Event(UUID.randomUUID().toString(), TITLE, DateTime.now(), (URI) null, url, CATEGORY);
final Event event = new Event(UUID.randomUUID().toString(), TITLE, LocalDateTime.now(), (URI) null, url, CATEGORY);
if (EventPublishFilterHook.shouldPublish(returnValue, args, "EncounterPublishCondition.groovy")) {
atomFeedSpringTransactionManager.executeWithTransaction(
new AFTransactionWorkWithoutResult() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package org.openmrs.module.atomfeed.advice;


import org.ict4h.atomfeed.server.repository.AllEventRecordsQueue;
import org.ict4h.atomfeed.server.repository.jdbc.AllEventRecordsQueueJdbcImpl;
import org.ict4h.atomfeed.server.service.Event;
import org.ict4h.atomfeed.server.service.EventService;
import org.ict4h.atomfeed.server.service.EventServiceImpl;
import org.ict4h.atomfeed.transaction.AFTransactionWorkWithoutResult;
import org.openmrs.Encounter;
import org.openmrs.api.context.Context;
import org.openmrs.module.atomfeed.EventPublishFilterHook;
import org.openmrs.module.atomfeed.transaction.support.AtomFeedSpringTransactionManager;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.transaction.PlatformTransactionManager;

import java.lang.reflect.Method;
import java.net.URI;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

public class EncounterServiceSaveAdvice implements AfterReturningAdvice {

public static final String ENCOUNTER_REST_URL = getEncounterFeedUrl();
public static final String TITLE = "Encounter";
public static final String CATEGORY = "Encounter";
private final AtomFeedSpringTransactionManager atomFeedSpringTransactionManager;

private static final String SAVE_METHOD = "saveEncounter";
private static final String ENCOUNTER_TYPE_INVESTIGATION = "INVESTIGATION";

private EventService eventService;

public EncounterServiceSaveAdvice() throws SQLException {
PlatformTransactionManager platformTransactionManager = getSpringPlatformTransactionManager();
atomFeedSpringTransactionManager = new AtomFeedSpringTransactionManager(platformTransactionManager);
AllEventRecordsQueue allEventRecordsQueue = new AllEventRecordsQueueJdbcImpl(atomFeedSpringTransactionManager);
this.eventService = new EventServiceImpl(allEventRecordsQueue);
}


@Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object encounterService) throws Throwable {
if (method.getName().equals(SAVE_METHOD)) {
Encounter encounter = (Encounter) args[0]; // Assuming encounter is the first argument
String encounterType = encounter.getEncounterType().getName(); // Assuming encounterType is a string
if (ENCOUNTER_TYPE_INVESTIGATION.equals(encounterType)) {

String url = String.format(ENCOUNTER_REST_URL, encounter.getUuid());
final Event event = new Event(UUID.randomUUID().toString(), TITLE, LocalDateTime.now(), (URI) null, url, CATEGORY);
if (EventPublishFilterHook.shouldPublish(returnValue, args, "EncounterPublishCondition.groovy")) {
atomFeedSpringTransactionManager.executeWithTransaction(
new AFTransactionWorkWithoutResult() {
@Override
protected void doInTransaction() {
eventService.notify(event);
}

@Override
public PropagationDefinition getTxPropagationDefinition() {
return PropagationDefinition.PROPAGATION_REQUIRED;
}
}
);
}
}
}
}

private static String getEncounterFeedUrl() {
return Context.getAdministrationService().getGlobalProperty("encounter.feed.publish.url");
}

private PlatformTransactionManager getSpringPlatformTransactionManager() {
List<PlatformTransactionManager> platformTransactionManagers = Context.getRegisteredComponents(PlatformTransactionManager.class);
return platformTransactionManagers.get(0);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.ict4h.atomfeed.server.service.EventService;
import org.ict4h.atomfeed.server.service.EventServiceImpl;
import org.ict4h.atomfeed.transaction.AFTransactionWorkWithoutResult;
import org.joda.time.DateTime;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
import org.openmrs.module.atomfeed.transaction.support.AtomFeedSpringTransactionManager;
Expand All @@ -16,6 +15,7 @@
import java.lang.reflect.Method;
import java.net.URI;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

Expand All @@ -38,7 +38,7 @@ public PatientAdvice() throws SQLException {
public void afterReturning(Object returnValue, Method method, Object[] arguments, Object target) throws Throwable {
if (method.getName().equals(SAVE_PATIENT_METHOD)) {
String contents = String.format(TEMPLATE, ((Patient) returnValue).getUuid());
final Event event = new Event(UUID.randomUUID().toString(), TITLE, DateTime.now(), (URI) null, contents, CATEGORY);
final Event event = new Event(UUID.randomUUID().toString(), TITLE, LocalDateTime.now(), (URI) null, contents, CATEGORY);

atomFeedSpringTransactionManager.executeWithTransaction(
new AFTransactionWorkWithoutResult() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package org.openmrs.module.atomfeed.advice;

import org.ict4h.atomfeed.server.repository.jdbc.AllEventRecordsQueueJdbcImpl;
import org.ict4h.atomfeed.server.service.Event;
import org.ict4h.atomfeed.server.service.EventService;
import org.ict4h.atomfeed.server.service.EventServiceImpl;
import org.ict4h.atomfeed.transaction.AFTransactionWorkWithoutResult;
import org.openmrs.PatientProgram;
import org.openmrs.api.context.Context;
import org.openmrs.module.atomfeed.transaction.support.AtomFeedSpringTransactionManager;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.transaction.PlatformTransactionManager;

import java.lang.reflect.Method;
import java.net.URI;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

public class PatientProgramAdvice implements AfterReturningAdvice {
private static final String CATEGORY = "programenrollment";
private static final String TITLE = "Progam Enrollment";
private static final String SAVE_PATIENT_PROGRAM_METHOD = "savePatientProgram";
private static final String RAISE_PATIENT_PROGRAM_EVENT_GLOBAL_PROPERTY = "atomfeed.publish.eventsForPatientProgramStateChange";
private static final String PATIENT_PROGRAM_EVENT_URL_PATTERN_GLOBAL_PROPERTY = "atomfeed.event.urlPatternForProgramStateChange";
private static final String DEFAULT_PATIENT_PROGRAM_URL_PATTERN = "/openmrs/ws/rest/v1/programenrollment/{uuid}?v=full";
private AtomFeedSpringTransactionManager atomFeedSpringTransactionManager;
private EventService eventService;
private final Object eventServiceMonitor = new Object();
private final Object txManagerMonitor = new Object();

public PatientProgramAdvice() throws SQLException {

}

@Override
public void afterReturning(Object returnValue, Method method, Object[] arguments, Object target) throws Throwable {
if (method.getName().equals(SAVE_PATIENT_PROGRAM_METHOD) && shouldRaiseRelationshipEvent()) {
String contents = getUrlPattern().replace("{uuid}",((PatientProgram) returnValue).getUuid());
final Event event = new Event(UUID.randomUUID().toString(), TITLE, LocalDateTime.now(), (URI) null, contents, CATEGORY);

getAFTxManager().executeWithTransaction(
new AFTransactionWorkWithoutResult() {
@Override
protected void doInTransaction() {
getEventService().notify(event);
}

@Override
public PropagationDefinition getTxPropagationDefinition() {
return PropagationDefinition.PROPAGATION_REQUIRED;
}
}
);
}
}

private EventService getEventService() {
if (eventService == null) { // Single Checked
synchronized (eventServiceMonitor) {
if (eventService == null) { // Double checked
this.eventService = new EventServiceImpl(new AllEventRecordsQueueJdbcImpl(getAFTxManager()));
}
}
}
return this.eventService;
}

private AtomFeedSpringTransactionManager getAFTxManager() {
if (this.atomFeedSpringTransactionManager == null) {
synchronized (txManagerMonitor) {
if(this.atomFeedSpringTransactionManager == null) {
this.atomFeedSpringTransactionManager = new AtomFeedSpringTransactionManager(getSpringPlatformTransactionManager());
}
}
}
return this.atomFeedSpringTransactionManager;
}

private boolean shouldRaiseRelationshipEvent() {
String raiseEvent = Context.getAdministrationService().getGlobalProperty(RAISE_PATIENT_PROGRAM_EVENT_GLOBAL_PROPERTY);
return Boolean.valueOf(raiseEvent);
}

private String getUrlPattern() {
String urlPattern = Context.getAdministrationService().getGlobalProperty(PATIENT_PROGRAM_EVENT_URL_PATTERN_GLOBAL_PROPERTY);
if (urlPattern == null || urlPattern.equals("")) {
return DEFAULT_PATIENT_PROGRAM_URL_PATTERN;
}
return urlPattern;
}

private PlatformTransactionManager getSpringPlatformTransactionManager() {
List<PlatformTransactionManager> platformTransactionManagers = Context.getRegisteredComponents(PlatformTransactionManager.class);
return platformTransactionManagers.get(0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.openmrs.module.atomfeed.advice;

import org.ict4h.atomfeed.server.repository.AllEventRecordsQueue;
import org.ict4h.atomfeed.server.repository.jdbc.AllEventRecordsQueueJdbcImpl;
import org.ict4h.atomfeed.server.service.Event;
import org.ict4h.atomfeed.server.service.EventService;
import org.ict4h.atomfeed.server.service.EventServiceImpl;
import org.ict4h.atomfeed.transaction.AFTransactionWorkWithoutResult;
import org.openmrs.Relationship;
import org.openmrs.api.context.Context;
import org.openmrs.module.atomfeed.transaction.support.AtomFeedSpringTransactionManager;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.transaction.PlatformTransactionManager;

import java.lang.reflect.Method;
import java.net.URI;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

public class PersonRelationshipAdvice implements AfterReturningAdvice {
private static final String CATEGORY = "relationship";
private static final String TITLE = "Relationship";
private static final String SAVE_RELATIONSHIP_METHOD = "saveRelationship";
private static final String RAISE_RELATIONSHIP_EVENT_GLOBAL_PROPERTY = "atomfeed.publish.eventsForPatientRelationshipChange";
private static final String RELATIONSHIP_EVENT_URL_PATTERN_GLOBAL_PROPERTY = "atomfeed.event.urlPatternForPatientRelationshipChange";
private static final String DEFAULT_RELATIONSHIP_URL_PATTERN = "/openmrs/ws/rest/v1/relationship/%s";
private final AtomFeedSpringTransactionManager atomFeedSpringTransactionManager;
private final EventService eventService;

public PersonRelationshipAdvice() throws SQLException {
atomFeedSpringTransactionManager = new AtomFeedSpringTransactionManager(getSpringPlatformTransactionManager());
AllEventRecordsQueue allEventRecordsQueue = new AllEventRecordsQueueJdbcImpl(atomFeedSpringTransactionManager);
this.eventService = new EventServiceImpl(allEventRecordsQueue);
}

@Override
public void afterReturning(Object returnValue, Method method, Object[] arguments, Object target) throws Throwable {
if (method.getName().equals(SAVE_RELATIONSHIP_METHOD) && shouldRaiseRelationshipEvent()) {
String contents = String.format(getUrlPattern(), ((Relationship) returnValue).getUuid());
final Event event = new Event(UUID.randomUUID().toString(), TITLE, LocalDateTime.now(), (URI) null, contents, CATEGORY);

atomFeedSpringTransactionManager.executeWithTransaction(
new AFTransactionWorkWithoutResult() {
@Override
protected void doInTransaction() {
eventService.notify(event);
}

@Override
public PropagationDefinition getTxPropagationDefinition() {
return PropagationDefinition.PROPAGATION_REQUIRED;
}
}
);
}
}

private boolean shouldRaiseRelationshipEvent() {
String raiseEvent = Context.getAdministrationService().getGlobalProperty(RAISE_RELATIONSHIP_EVENT_GLOBAL_PROPERTY);
return Boolean.valueOf(raiseEvent);
}

private String getUrlPattern() {
String urlPattern = Context.getAdministrationService().getGlobalProperty(RELATIONSHIP_EVENT_URL_PATTERN_GLOBAL_PROPERTY);
if (urlPattern == null || urlPattern.equals("")) {
return DEFAULT_RELATIONSHIP_URL_PATTERN;
}
return urlPattern;
}

private PlatformTransactionManager getSpringPlatformTransactionManager() {
List<PlatformTransactionManager> platformTransactionManagers = Context.getRegisteredComponents(PlatformTransactionManager.class);
return platformTransactionManagers.get(0);
}
}
Loading