From 58cbd329e545413ff572081f4d101a87c638ce4e Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Wed, 11 Jun 2025 12:27:29 +0530 Subject: [PATCH 1/3] Update to Platform 2.7.0 and Support Java 21 --- .github/workflows/maven.yml | 2 +- api-tests/pom.xml | 31 +- ...ncounterCohortDefinitionEvaluatorTest.java | 18 +- .../VisitCohortDefinitionEvaluatorTest.java | 2 +- .../PrivilegedDataConverterTest.java | 33 +- .../service/PatientDataServiceImplTest.java | 6 +- .../evaluator/VisitIdDataEvaluatorTest.java | 4 + ...peatPerTimePeriodDataSetEvaluatorTest.java | 4 +- .../EvaluationProfilerTest24On.java | 5 +- ...MappedParametersObsQueryEvaluatorTest.java | 12 +- .../evaluator/SqlObsQueryEvaluatorTest.java | 4 + .../ActiveVisitQueryEvaluatorTest.java | 12 +- .../reporting/include/PrivilegeTest.xml | 17 + .../ReportTestDataset-openmrs-1.10.xml | 543 ----------------- .../ReportTestDataset-openmrs-1.11.xml | 565 ----------------- .../ReportTestDataset-openmrs-1.12.xml | 565 ----------------- .../include/ReportTestDataset-openmrs-1.9.xml | 549 ----------------- .../include/ReportTestDataset-openmrs-2.0.xml | 573 ----------------- .../include/ReportTestDataset-openmrs-2.1.xml | 574 ------------------ .../include/ReportTestDataset-openmrs-2.3.xml | 574 ------------------ .../include/ReportTestDataset-openmrs-2.4.xml | 574 ------------------ ....xml => ReportTestDataset-openmrs-2.7.xml} | 0 api/pom.xml | 12 +- .../DataExportDataSetDefinition.java | 102 ---- .../evaluator/DataExportDataSetEvaluator.java | 112 ---- .../DataExportDataSetDefinitionPersister.java | 130 ---- .../serializer/ReportingSerializer.java | 6 + .../resources/moduleApplicationContext.xml | 2 +- omod/pom.xml | 27 +- omod/src/main/resources/config.xml | 25 +- pom.xml | 124 +--- 31 files changed, 121 insertions(+), 5086 deletions(-) create mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/PrivilegeTest.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.10.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.11.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.12.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.9.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.1.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.3.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.4.xml rename api-tests/src/test/resources/org/openmrs/module/reporting/include/{ReportTestDataset-openmrs-2.2.xml => ReportTestDataset-openmrs-2.7.xml} (100%) delete mode 100644 api/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java delete mode 100644 api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/DataExportDataSetEvaluator.java delete mode 100644 api/src/main/java/org/openmrs/module/reporting/dataset/definition/persister/DataExportDataSetDefinitionPersister.java diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index df6445a783..d4c5ce5d9d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: platform: [ ubuntu-latest ] - java-version: [ 8 ] + java-version: [ 8, 11, 17, 21, 24 ] runs-on: ${{ matrix.platform }} env: diff --git a/api-tests/pom.xml b/api-tests/pom.xml index e37cf08cd4..5eed86d7bd 100644 --- a/api-tests/pom.xml +++ b/api-tests/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module reporting - 1.28.0-SNAPSHOT + 2.0.0-SNAPSHOT reporting-api-tests @@ -30,11 +30,6 @@ - - org.openmrs.module - ${reportingApiConditionalArtifactId} - ${project.parent.version} - org.openmrs.api @@ -45,6 +40,14 @@ javassist javassist + + org.powermock + powermock-api-mockito2 + + + org.powermock + powermock-api-mockito + @@ -57,6 +60,14 @@ javassist javassist + + org.powermock + powermock-api-mockito2 + + + org.powermock + powermock-api-mockito + @@ -69,6 +80,14 @@ javassist javassist + + org.powermock + powermock-api-mockito2 + + + org.powermock + powermock-api-mockito + diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/EncounterCohortDefinitionEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/EncounterCohortDefinitionEvaluatorTest.java index 8479486659..9df515e484 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/EncounterCohortDefinitionEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/EncounterCohortDefinitionEvaluatorTest.java @@ -14,9 +14,9 @@ import java.util.Collections; import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.openmrs.Cohort; import org.openmrs.Encounter; import org.openmrs.EncounterType; @@ -34,17 +34,21 @@ import org.openmrs.module.reporting.common.TimeQualifier; import org.openmrs.module.reporting.definition.DefinitionContext; import org.openmrs.module.reporting.evaluation.EvaluationContext; -import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.SkipBaseSetup; import org.openmrs.test.Verifies; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; +@SkipBaseSetup public class EncounterCohortDefinitionEvaluatorTest extends BaseModuleContextSensitiveTest { protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/"; protected static final String XML_REPORT_TEST_DATASET = "ReportTestDataset"; - @Before + @BeforeEach public void setup() throws Exception { + initializeInMemoryDatabase(); + authenticate(); executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET)); } @@ -201,7 +205,7 @@ public void evaluate_shouldReturnCorrectPatientsWhenTimeQualifierParametersAreSe * @see EncounterCohortDefinitionEvaluator#evaluate(CohortDefinition,EvaluationContext) * @verifies return correct patients when provider parameters are set */ - @Ignore + @Disabled @Test public void evaluate_shouldReturnCorrectPatientsWhenProviderParametersAreSet() throws Exception { EncounterCohortDefinition cd = new EncounterCohortDefinition(); @@ -212,7 +216,7 @@ public void evaluate_shouldReturnCorrectPatientsWhenProviderParametersAreSet() t /** * @see {@link EncounterCohortDefinitionEvaluator#evaluate(CohortDefinition,EvaluationContext)} */ - @Ignore + @Disabled @Test @Verifies(value = "should not return voided patients", method = "evaluate(CohortDefinition,EvaluationContext)") public void evaluate_shouldNotReturnVoidedPatients() throws Exception { diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/VisitCohortDefinitionEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/VisitCohortDefinitionEvaluatorTest.java index 87d3dc7669..12db3e1db6 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/VisitCohortDefinitionEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/VisitCohortDefinitionEvaluatorTest.java @@ -68,7 +68,7 @@ public void setUp() throws Exception { @Test public void testEvaluateWithNoProperties() throws Exception { Cohort c = cohortDefinitionService.evaluate(cd, null); - assertThat(c.size(), is(2)); + assertThat(c.size(), is(3)); } @Test diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java index c6661638c0..c67f243642 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java @@ -14,15 +14,12 @@ import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.openmrs.api.context.Context; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.SkipBaseSetup; -@RunWith(PowerMockRunner.class) -@PrepareForTest(Context.class) -public class PrivilegedDataConverterTest { +@SkipBaseSetup +public class PrivilegedDataConverterTest extends BaseModuleContextSensitiveTest { public static final String INPUT = "input"; public static final String REPLACEMENT = "****"; @@ -32,16 +29,24 @@ public class PrivilegedDataConverterTest { @Before public void setUp() throws Exception { - PowerMockito.mockStatic(Context.class); - PowerMockito.when(Context.hasPrivilege(HAS_PRIV)).thenReturn(true); - PowerMockito.when(Context.hasPrivilege(DOES_NOT_HAVE_PRIV)).thenReturn(false); + initializeInMemoryDatabase(); + executeDataSet("org/openmrs/module/reporting/include/PrivilegeTest.xml"); + Context.logout(); + Context.authenticate("test", "test"); } @Test - public void testConvertWithPrivilege() throws Exception { - PrivilegedDataConverter converter = new PrivilegedDataConverter(HAS_PRIV); - converter.setReplacement(REPLACEMENT); - assertThat((String) converter.convert(INPUT), is(INPUT)); + public void testConvertWithPrivilege() { + try { + Context.addProxyPrivilege(HAS_PRIV); + Context.hasPrivilege(HAS_PRIV); + PrivilegedDataConverter converter = new PrivilegedDataConverter(HAS_PRIV); + converter.setReplacement(REPLACEMENT); + assertThat((String) converter.convert(INPUT), is(INPUT)); + } + finally { + Context.removeProxyPrivilege(HAS_PRIV); + } } @Test diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java index 4cd21f1535..8a8388116b 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java @@ -34,7 +34,7 @@ import org.openmrs.test.BaseModuleContextSensitiveTest; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Arrays; +import java.util.Collections; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; @@ -159,7 +159,7 @@ private CohortDefinition setUpTestPatientCohortDefinition(PersonAttributeType te PersonAttributeCohortDefinition cohortDefinition = new PersonAttributeCohortDefinition(); cohortDefinition.setName("Test Patients"); cohortDefinition.setAttributeType(testAttributeType); - cohortDefinition.setValues(Arrays.asList("true")); + cohortDefinition.setValues(Collections.singletonList("true")); Context.getService(CohortDefinitionService.class).saveDefinition(cohortDefinition); return cohortDefinition; } @@ -199,7 +199,7 @@ public String getKeyPrefix() { public CohortDefinition getTestPatients() { PersonAttributeCohortDefinition cohortDefinition = new PersonAttributeCohortDefinition(); cohortDefinition.setAttributeType(Context.getPersonService().getPersonAttributeTypeByUuid(TEST_PATIENT_ATTR_TYPE_UUID)); - cohortDefinition.setValues(Arrays.asList("true")); + cohortDefinition.setValues(Collections.singletonList("true")); return cohortDefinition; } diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java index 5bc097b695..99ea415a16 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java @@ -22,7 +22,9 @@ import org.openmrs.module.reporting.evaluation.context.VisitEvaluationContext; import org.openmrs.module.reporting.query.visit.VisitIdSet; import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.SkipBaseSetup; +@SkipBaseSetup public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{ protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/"; @@ -37,6 +39,8 @@ public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{ */ @Before public void setup() throws Exception { + initializeInMemoryDatabase(); + authenticate(); executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET)); } diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluatorTest.java index 41e2df6356..c99debd6f5 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluatorTest.java @@ -30,8 +30,8 @@ import java.util.HashMap; import java.util.Map; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java index 5d98991313..a4edf82f44 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java @@ -15,13 +15,14 @@ import org.junit.BeforeClass; import org.junit.Test; import org.openmrs.api.context.Context; +import org.openmrs.logging.MemoryAppender; +import org.openmrs.logging.OpenmrsLoggingUtil; import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition; import org.openmrs.module.reporting.indicator.CohortIndicator; import org.openmrs.module.reporting.indicator.service.IndicatorService; import org.openmrs.module.reporting.test.OpenmrsVersionTestListener; import org.openmrs.module.reporting.test.RequiresVersion; import org.openmrs.test.BaseModuleContextSensitiveTest; -import org.openmrs.util.MemoryAppender; import org.openmrs.util.OpenmrsUtil; import org.springframework.test.context.TestExecutionListeners; @@ -38,7 +39,7 @@ public class EvaluationProfilerTest24On extends BaseModuleContextSensitiveTest { @BeforeClass public static void beforeClass() { - appender = OpenmrsUtil.getMemoryAppender(); + appender = OpenmrsLoggingUtil.getMemoryAppender(); if (appender == null) { LoggerContext context = (LoggerContext) LogManager.getContext(false); diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/query/encounter/evaluator/MappedParametersObsQueryEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/query/encounter/evaluator/MappedParametersObsQueryEvaluatorTest.java index 091968460d..d50fce7ca2 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/query/encounter/evaluator/MappedParametersObsQueryEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/query/encounter/evaluator/MappedParametersObsQueryEvaluatorTest.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.reporting.query.encounter.evaluator; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.api.context.Context; import org.openmrs.module.reporting.common.DateUtil; import org.openmrs.module.reporting.common.TestUtil; @@ -20,7 +20,8 @@ import org.openmrs.module.reporting.query.obs.definition.BasicObsQuery; import org.openmrs.module.reporting.query.obs.definition.MappedParametersObsQuery; import org.openmrs.module.reporting.query.obs.service.ObsQueryService; -import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.SkipBaseSetup; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; import java.util.Date; import java.util.HashMap; @@ -30,14 +31,17 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +@SkipBaseSetup public class MappedParametersObsQueryEvaluatorTest extends BaseModuleContextSensitiveTest { protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/"; protected static final String XML_REPORT_TEST_DATASET = "ReportTestDataset"; - @Before + @BeforeEach public void setup() throws Exception { + initializeInMemoryDatabase(); + authenticate(); executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET)); } diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java index 1df50abe27..c338121dd7 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java @@ -24,16 +24,20 @@ import org.openmrs.module.reporting.query.obs.definition.SqlObsQuery; import org.openmrs.module.reporting.query.obs.service.ObsQueryService; import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.SkipBaseSetup; /** * Test the evaluation of the SqlObsQuery */ +@SkipBaseSetup public class SqlObsQueryEvaluatorTest extends BaseModuleContextSensitiveTest { protected static Log log = LogFactory.getLog(SqlObsQueryEvaluatorTest.class); @Before public void setup() throws Exception { + initializeInMemoryDatabase(); + authenticate(); executeDataSet("org/openmrs/module/reporting/include/" + new TestUtil().getTestDatasetFilename("ReportTestDataset")); } diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/query/visit/evaluator/ActiveVisitQueryEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/query/visit/evaluator/ActiveVisitQueryEvaluatorTest.java index 4c7b12ca68..1f7f83f632 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/query/visit/evaluator/ActiveVisitQueryEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/query/visit/evaluator/ActiveVisitQueryEvaluatorTest.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.reporting.query.visit.evaluator; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Patient; import org.openmrs.Visit; import org.openmrs.api.VisitService; @@ -22,7 +22,8 @@ import org.openmrs.module.reporting.query.visit.VisitQueryResult; import org.openmrs.module.reporting.query.visit.definition.ActiveVisitQuery; import org.openmrs.module.reporting.query.visit.service.VisitQueryService; -import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.SkipBaseSetup; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; @@ -32,6 +33,7 @@ import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; import static org.junit.Assert.assertThat; +@SkipBaseSetup public class ActiveVisitQueryEvaluatorTest extends BaseModuleContextSensitiveTest { protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/"; @@ -47,8 +49,10 @@ public class ActiveVisitQueryEvaluatorTest extends BaseModuleContextSensitiveTes @Autowired private TestDataManager data; - @Before + @BeforeEach public void setup() throws Exception { + initializeInMemoryDatabase(); + authenticate(); executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET)); } diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/PrivilegeTest.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/PrivilegeTest.xml new file mode 100644 index 0000000000..7444951a19 --- /dev/null +++ b/api-tests/src/test/resources/org/openmrs/module/reporting/include/PrivilegeTest.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.10.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.10.xml deleted file mode 100644 index 0504594c94..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.10.xml +++ /dev/null @@ -1,543 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.11.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.11.xml deleted file mode 100644 index ebe5f05ab8..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.11.xml +++ /dev/null @@ -1,565 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.12.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.12.xml deleted file mode 100644 index ebe5f05ab8..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.12.xml +++ /dev/null @@ -1,565 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.9.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.9.xml deleted file mode 100644 index 236aadb7ea..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-1.9.xml +++ /dev/null @@ -1,549 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml deleted file mode 100644 index 7d6f1e489a..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml +++ /dev/null @@ -1,573 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.1.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.1.xml deleted file mode 100644 index 60139af0ae..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.1.xml +++ /dev/null @@ -1,574 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.3.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.3.xml deleted file mode 100644 index e89f14375f..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.3.xml +++ /dev/null @@ -1,574 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.4.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.4.xml deleted file mode 100644 index e89f14375f..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.4.xml +++ /dev/null @@ -1,574 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.2.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.7.xml similarity index 100% rename from api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.2.xml rename to api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.7.xml diff --git a/api/pom.xml b/api/pom.xml index f3621e24f2..95a309e51a 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -3,21 +3,11 @@ org.openmrs.module reporting - 1.28.0-SNAPSHOT + 2.0.0-SNAPSHOT reporting-api jar Reporting API API project for Reporting - - - - org.openmrs.module - reportingcompatibility-api - ${reportingCompatibilityVersion} - provided - - - diff --git a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java deleted file mode 100644 index b7f2d861ce..0000000000 --- a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.reporting.dataset.definition; - -import org.openmrs.BaseOpenmrsMetadata; -import org.openmrs.BaseOpenmrsObject; -import org.openmrs.module.reporting.common.Localized; -import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty; -import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; -import org.openmrs.module.reporting.evaluation.caching.Caching; -import org.openmrs.reporting.export.DataExportReportObject; - -/** - * Definition of a dataset that runs a Data Export (of the sort created in the reportingcompatibility - * module. - * @see DataExportDataSetDefinition - */ -@Caching(strategy=ConfigurationPropertyCachingStrategy.class) -@SuppressWarnings("deprecation") -@Localized("reporting.DataExportDataSetDefinition") -public class DataExportDataSetDefinition extends BaseDataSetDefinition { - - public static final long serialVersionUID = -2572061676651616176L; - - //***** PROPERTIES ***** - - @ConfigurationProperty - private DataExportReportObject dataExport; - - //***** CONSTRUCTORS ***** - - /** - * Default public constructor - */ - public DataExportDataSetDefinition() { - super(); - } - - /** - * Full constructor - */ - public DataExportDataSetDefinition(DataExportReportObject dataExport) { - this.dataExport = dataExport; - } - - //***** INSTANCE METHODS ***** - - /** - * @see BaseDataSetDefinition#getId() - */ - @Override - public Integer getId() { - return (getDataExport() == null ? null : getDataExport().getId()); - } - - /** - * @see BaseOpenmrsObject#getUuid() - */ - @Override - public String getUuid() { - return (getDataExport() == null ? null : getDataExport().getUuid()); - } - - /** - * @see BaseOpenmrsMetadata#getName() - */ - @Override - public String getName() { - return (getDataExport() == null ? null : getDataExport().getName()); - } - - /** - * @see BaseOpenmrsMetadata#getDescription() - */ - @Override - public String getDescription() { - return (getDataExport() == null ? null : getDataExport().getDescription()); - } - - //***** PROPERTY ACCESS ***** - - /** - * @return the dataExport - */ - public DataExportReportObject getDataExport() { - return dataExport; - } - - /** - * @param dataExport the dataExport to set - */ - public void setDataExport(DataExportReportObject dataExport) { - this.dataExport = dataExport; - } -} diff --git a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/DataExportDataSetEvaluator.java b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/DataExportDataSetEvaluator.java deleted file mode 100644 index c7b1ab0237..0000000000 --- a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/DataExportDataSetEvaluator.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.reporting.dataset.definition.evaluator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.openmrs.annotation.Handler; -import org.openmrs.module.reporting.common.ObjectUtil; -import org.openmrs.module.reporting.dataset.DataSet; -import org.openmrs.module.reporting.dataset.DataSetColumn; -import org.openmrs.module.reporting.dataset.DataSetRow; -import org.openmrs.module.reporting.dataset.SimpleDataSet; -import org.openmrs.module.reporting.dataset.definition.DataExportDataSetDefinition; -import org.openmrs.module.reporting.dataset.definition.DataSetDefinition; -import org.openmrs.module.reporting.evaluation.EvaluationContext; -import org.openmrs.reporting.export.DataExportReportObject; -import org.openmrs.reporting.export.DataExportUtil; -import org.openmrs.util.OpenmrsUtil; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -/** - * The logic that evaluates a {@link DataExportDataSetDefinition} and produces a {@link DataSet} - * @see DataExportDataSetDefinition - * @see DataSet - */ -@Handler(supports={DataExportDataSetDefinition.class}) -@SuppressWarnings("deprecation") -public class DataExportDataSetEvaluator implements DataSetEvaluator { - - private Log log = LogFactory.getLog(this.getClass()); - - /** - * Public constructor - */ - public DataExportDataSetEvaluator() {} - - /** - * @see DataSetEvaluator#evaluate(DataSetDefinition, EvaluationContext) - * @should evaluate a DataExportDataSetDefinition - */ - public DataSet evaluate(DataSetDefinition definition, EvaluationContext context) { - - context = ObjectUtil.nvl(context, new EvaluationContext()); - SimpleDataSet dataSet = new SimpleDataSet(definition, context); - try { - DataExportDataSetDefinition dataExportDefinition = (DataExportDataSetDefinition) definition; - DataExportReportObject dataExport = dataExportDefinition.getDataExport(); - DataExportUtil.generateExport(dataExport, convertCohort(context.getBaseCohort()), null); - - File dataFile = DataExportUtil.getGeneratedFile(dataExportDefinition.getDataExport()); - - // Get contents as a string - // TODO Test whether this is faster than another approach - String contents = OpenmrsUtil.getFileAsString(dataFile); - String [] rows = contents.split("\\n"); - - // Get column names - String [] columns = rows[0].split("\\t"); - Map cols = new HashMap(); - for (String s : columns) { - DataSetColumn c = new DataSetColumn(s, s, String.class); - cols.put(s, c); - dataSet.getMetaData().addColumn(c); - } - - // Iterate over remaining rows - for (int i=1; i getAllDefinitions(boolean includeRetired) { - List dataSetDefinitions = new Vector(); - if (ModuleFactory.getStartedModulesMap().containsKey("reportingcompatibility") && - ReportingConstants.GLOBAL_PROPERTY_INCLUDE_DATA_EXPORTS()) { - ReportObjectService ros = Context.getService(ReportObjectService.class); - List dataExports = ros.getReportObjectsByType("Data Export"); - - for (AbstractReportObject obj : dataExports) { - DataExportReportObject dataExport = (DataExportReportObject) obj; - dataExport.setUuid(obj.getUuid()); // hack to get uuids into data exports - dataSetDefinitions.add(new DataExportDataSetDefinition(dataExport)); - } - } - return dataSetDefinitions; - } - - /** - * @see DataSetDefinitionPersister#getNumberOfDefinitions(boolean) - */ - public int getNumberOfDefinitions(boolean includeRetired) { - if (ModuleFactory.getStartedModulesMap().containsKey("reportingcompatibility")) { - ReportObjectService ros = Context.getService(ReportObjectService.class); - List dataExports = ros.getReportObjectsByType("Data Export"); - return dataExports.size(); - } - return 0; - } - - /** - * @see DataSetDefinitionPersister#getDefinitions(String, boolean) - */ - public List getDefinitions(String name, boolean exactMatchOnly) { - List ret = new ArrayList(); - for(DataSetDefinition dsd : getAllDefinitions(false)) { - if (dsd.getName() != null) { - if (exactMatchOnly) { - if (dsd.getName().equalsIgnoreCase(name)) { - ret.add(dsd); - } - } - else { - if (dsd.getName().toUpperCase().contains(name.toUpperCase())) { - ret.add(dsd); - } - } - } - } - return ret; - } - - /** - * @see DataSetDefinitionPersister#saveDefinition(DataSetDefinition) - */ - public DataSetDefinition saveDefinition(DataSetDefinition dataSetDefinition) { - DataExportDataSetDefinition dsd = (DataExportDataSetDefinition) dataSetDefinition; - ReportObjectService ros = Context.getService(ReportObjectService.class); - DataExportReportObject dataExport = (DataExportReportObject) ros.saveReportObject(dsd.getDataExport()); - dsd.setDataExport(dataExport); - return dsd; - } - - /** - * @see DataSetDefinitionPersister#purgeDefinition(DataSetDefinition) - */ - public void purgeDefinition(DataSetDefinition dataSetDefinition) { - DataExportDataSetDefinition dsd = (DataExportDataSetDefinition) dataSetDefinition; - Context.getService(ReportObjectService.class).purgeReportObject(dsd.getDataExport()); - } -} diff --git a/api/src/main/java/org/openmrs/module/reporting/serializer/ReportingSerializer.java b/api/src/main/java/org/openmrs/module/reporting/serializer/ReportingSerializer.java index 58b63e19f2..c356f07150 100644 --- a/api/src/main/java/org/openmrs/module/reporting/serializer/ReportingSerializer.java +++ b/api/src/main/java/org/openmrs/module/reporting/serializer/ReportingSerializer.java @@ -20,6 +20,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.api.context.Context; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.dataset.definition.CohortIndicatorAndDimensionDataSetDefinition; +import org.openmrs.module.reporting.evaluation.parameter.Mapped; +import org.openmrs.module.reporting.evaluation.parameter.Parameter; +import org.openmrs.module.reporting.report.definition.ReportDefinition; import org.openmrs.module.serialization.xstream.XStreamShortSerializer; import org.openmrs.module.serialization.xstream.mapper.CGLibMapper; import org.openmrs.module.serialization.xstream.mapper.HibernateCollectionMapper; @@ -88,6 +93,7 @@ public Object unmarshal(HierarchicalStreamReader reader, Object root) { xstream.registerConverter(new IndicatorConverter(mapper, converterLookup)); xstream.registerConverter(new ReportDefinitionConverter(mapper, converterLookup)); + xstream.allowTypes(new Class[] {Parameter.class, Mapped.class, CohortIndicatorAndDimensionDataSetDefinition.CohortIndicatorAndDimensionSpecification.class}); } @Override diff --git a/api/src/main/resources/moduleApplicationContext.xml b/api/src/main/resources/moduleApplicationContext.xml index 38a380a90d..2213b24170 100644 --- a/api/src/main/resources/moduleApplicationContext.xml +++ b/api/src/main/resources/moduleApplicationContext.xml @@ -41,7 +41,7 @@ - + diff --git a/omod/pom.xml b/omod/pom.xml index d1f7eaff0d..f3ac72d6fd 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -3,7 +3,7 @@ org.openmrs.module reporting - 1.28.0-SNAPSHOT + 2.0.0-SNAPSHOT reporting-omod jar @@ -16,31 +16,6 @@ ${project.parent.artifactId}-api ${project.parent.version} - - ${project.parent.groupId} - ${project.parent.artifactId}-api-1.10 - ${project.parent.version} - - - ${project.parent.groupId} - ${project.parent.artifactId}-api-1.9 - ${project.parent.version} - - - ${project.parent.groupId} - ${project.parent.artifactId}-api-2.0 - ${project.parent.version} - - - ${project.parent.groupId} - ${project.parent.artifactId}-api-2.2 - ${project.parent.version} - - - ${project.parent.groupId} - ${project.parent.artifactId}-api-2.4 - ${project.parent.version} - org.openmrs.module legacyui-omod diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index 23e6193693..489f4b8d8c 100644 --- a/omod/src/main/resources/config.xml +++ b/omod/src/main/resources/config.xml @@ -25,7 +25,6 @@ - org.openmrs.module.reportingcompatibility org.openmrs.module.legacyui org.openmrs.module.logic @@ -179,27 +178,5 @@ ReportRequest.hbm.xml - - - /lib/reporting-api-1.9.* - 1.9.9 - 1.12.* - - - /lib/reporting-api-1.10.* - 1.10.6 - 9.* - - - /lib/reporting-api-2.0.* - 2.0.0 - 2.3.* - - - /lib/reporting-api-2.2.* - 2.2.0 - - - /lib/reporting-api-2.4.* - 2.4.0 - - - + diff --git a/pom.xml b/pom.xml index 1a06fa1776..b4fa0ccdb8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module reporting - 1.28.0-SNAPSHOT + 2.0.0-SNAPSHOT pom Reporting Parent project for Reporting @@ -38,15 +38,13 @@ - 2.4.1 - 2.0.6 - 2.4 - 1.7.2 - 0.2.14 + 2.7.0 + 2.7 + 2.0.0-SNAPSHOT + 0.2.17-SNAPSHOT 1.2 2.1.1 3.12 - 1.8.7 2.12.5 1.1.2 1.7.0 @@ -55,7 +53,6 @@ Reporting ${project.parent.version} ${project.parent.groupId}.${project.parent.artifactId} - reporting-api-1.9 @@ -101,15 +98,6 @@ - - - org.codehaus.groovy - groovy-all - ${groovyVersion} - jar - provided - - joda-time joda-time @@ -210,27 +198,6 @@ provided - - org.openmrs.module - serialization.xstream-api-1.9 - ${serializationVersion} - provided - - - - org.openmrs.module - serialization.xstream-api-1.10 - ${serializationVersion} - provided - - - - org.openmrs.module - serialization.xstream-api-2.0 - ${serializationVersion} - provided - - org.openmrs.module htmlwidgets-api @@ -304,87 +271,6 @@ - - - 1.10 - - 1.10.2 - 1.10 - - - - 1.11 - - 1.11.3 - 1.11 - - - - 1.12 - - 1.12.0 - 1.12 - 1.9.13 - - - - 2.0 - - 2.0.0 - 2.0 - 1.9.13 - reporting-api-2.0 - - - - 2.1 - - 2.1.1 - 2.1 - 1.9.13 - reporting-api-2.0 - - - - 2.2 - - 2.2.0 - 2.2 - 1.9.13 - reporting-api-2.0 - - - - 2.3 - - 2.3.0 - 2.3 - 1.9.13 - reporting-api-2.0 - - - - 2.4 - - api - api-1.9 - api-1.10 - api-2.0 - api-2.2 - api-2.4 - api-tests - api-tests-2.4 - omod - - - - 2.4.1 - 2.4 - 1.9.13 - reporting-api-2.4 - - - From 0973e96807c47afb99bdd96ad1cc06d3d44bee75 Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Mon, 7 Jul 2025 17:32:53 +0530 Subject: [PATCH 2/3] Migrate to org.openmrs.test.jupiter.BaseModuleContextSensitiveTest --- .../PrivilegedDataConverterTest.java | 8 +- .../service/PatientDataServiceImplTest.java | 8 +- .../evaluator/VisitIdDataEvaluatorTest.java | 10 +- .../evaluation/EvaluationProfilerTest.java | 14 ++- .../EvaluationProfilerTest24On.java | 98 ------------------- .../evaluator/SqlObsQueryEvaluatorTest.java | 8 +- 6 files changed, 23 insertions(+), 123 deletions(-) delete mode 100644 api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java index c67f243642..1314afb004 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java @@ -12,11 +12,11 @@ import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.api.context.Context; -import org.openmrs.test.BaseModuleContextSensitiveTest; import org.openmrs.test.SkipBaseSetup; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; @SkipBaseSetup public class PrivilegedDataConverterTest extends BaseModuleContextSensitiveTest { @@ -27,7 +27,7 @@ public class PrivilegedDataConverterTest extends BaseModuleContextSensitiveTest public static final String HAS_PRIV = "A privilege I have"; public static final String DOES_NOT_HAVE_PRIV = "A privilege I do not have"; - @Before + @BeforeEach public void setUp() throws Exception { initializeInMemoryDatabase(); executeDataSet("org/openmrs/module/reporting/include/PrivilegeTest.xml"); diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java index 8a8388116b..ddf17348c8 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java @@ -10,8 +10,8 @@ package org.openmrs.module.reporting.data.patient.service; import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Cohort; import org.openmrs.Patient; import org.openmrs.PersonAttribute; @@ -31,7 +31,7 @@ import org.openmrs.module.reporting.definition.library.DocumentedDefinition; import org.openmrs.module.reporting.evaluation.EvaluationContext; import org.openmrs.test.BaseContextSensitiveTest; -import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; import org.springframework.beans.factory.annotation.Autowired; import java.util.Collections; @@ -59,7 +59,7 @@ public class PatientDataServiceImplTest extends BaseModuleContextSensitiveTest { * * @throws Exception */ - @Before + @BeforeEach public void setup() throws Exception { executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET)); } diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java index 99ea415a16..f5815de1a0 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java @@ -10,8 +10,8 @@ package org.openmrs.module.reporting.data.visit.evaluator; import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Cohort; import org.openmrs.api.context.Context; import org.openmrs.module.reporting.common.TestUtil; @@ -21,11 +21,11 @@ import org.openmrs.module.reporting.evaluation.EvaluationContext; import org.openmrs.module.reporting.evaluation.context.VisitEvaluationContext; import org.openmrs.module.reporting.query.visit.VisitIdSet; -import org.openmrs.test.BaseModuleContextSensitiveTest; import org.openmrs.test.SkipBaseSetup; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; @SkipBaseSetup -public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{ +public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest { protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/"; @@ -37,7 +37,7 @@ public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{ * * @throws Exception */ - @Before + @BeforeEach public void setup() throws Exception { initializeInMemoryDatabase(); authenticate(); diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest.java index 39192f318b..786c3fa0c3 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest.java @@ -9,25 +9,23 @@ */ package org.openmrs.module.reporting.evaluation; -import static org.junit.Assume.assumeTrue; - import org.apache.log4j.Appender; import org.apache.log4j.Level; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.apache.log4j.WriterAppender; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.api.context.Context; import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition; import org.openmrs.module.reporting.indicator.CohortIndicator; import org.openmrs.module.reporting.indicator.service.IndicatorService; import org.openmrs.module.reporting.test.OpenmrsVersionTestListener; import org.openmrs.module.reporting.test.RequiresVersion; -import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; import org.springframework.test.context.TestExecutionListeners; import java.io.StringWriter; @@ -52,7 +50,7 @@ public class EvaluationProfilerTest extends BaseModuleContextSensitiveTest { /** * Setup each test by configuring AOP on the relevant services and logging for the profiler class */ - @Before + @BeforeEach public void setup() { profiler1 = new EvaluationProfiler(new EvaluationContext()); profiler2 = new EvaluationProfiler(new EvaluationContext()); @@ -70,7 +68,7 @@ public void setup() { /** * Cleanup after tests by removing AOP and resetting logging */ - @After + @AfterEach public void cleanup() { logger.setLevel(startingLevel); for (Appender appender : startingAppenders) { diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java deleted file mode 100644 index a4edf82f44..0000000000 --- a/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.openmrs.module.reporting.evaluation; - -import java.util.List; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.core.LoggerContext; -import org.apache.logging.log4j.core.config.AppenderRef; -import org.apache.logging.log4j.core.config.Configuration; -import org.apache.logging.log4j.core.config.LoggerConfig; -import org.apache.logging.log4j.core.layout.PatternLayout; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openmrs.api.context.Context; -import org.openmrs.logging.MemoryAppender; -import org.openmrs.logging.OpenmrsLoggingUtil; -import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition; -import org.openmrs.module.reporting.indicator.CohortIndicator; -import org.openmrs.module.reporting.indicator.service.IndicatorService; -import org.openmrs.module.reporting.test.OpenmrsVersionTestListener; -import org.openmrs.module.reporting.test.RequiresVersion; -import org.openmrs.test.BaseModuleContextSensitiveTest; -import org.openmrs.util.OpenmrsUtil; -import org.springframework.test.context.TestExecutionListeners; - -/** - * Tests for {@link EvaluationProfiler} - */ -@TestExecutionListeners(OpenmrsVersionTestListener.class) -@RequiresVersion("2.4.* - 2.*") -public class EvaluationProfilerTest24On extends BaseModuleContextSensitiveTest { - - protected EvaluationProfiler profiler1, profiler2; - - private static MemoryAppender appender; - - @BeforeClass - public static void beforeClass() { - appender = OpenmrsLoggingUtil.getMemoryAppender(); - - if (appender == null) { - LoggerContext context = (LoggerContext) LogManager.getContext(false); - Configuration config = context.getConfiguration(); - - appender = MemoryAppender.newBuilder().setName("MEMORY_APPENDER").setLayout(PatternLayout.createDefaultLayout()) - .setConfiguration(config).build(); - appender.start(); - - config.addAppender(appender); - - AppenderRef appenderRef = AppenderRef.createAppenderRef("MEMORY_APPENDER", Level.ALL, null); - LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.ALL, EvaluationProfiler.class.getName(), null, - new AppenderRef[] { appenderRef }, null, config, null); - loggerConfig.addAppender(appender, Level.ALL, null); - config.addLogger(EvaluationProfiler.class.getName(), loggerConfig); - context.updateLoggers(); - } - - } - - @AfterClass - public static void afterClass() { - ((LoggerContext) LogManager.getContext()).updateLoggers(); - } - - /** - * Setup each test by configuring AOP on the relevant services and logging for the profiler class - */ - @Before - public void setup() { - profiler1 = new EvaluationProfiler(new EvaluationContext()); - profiler2 = new EvaluationProfiler(new EvaluationContext()); - } - - @Test - public void integration() throws EvaluationException { - GenderCohortDefinition males = new GenderCohortDefinition(); - males.setName("males"); - males.setMaleIncluded(true); - - CohortIndicator count = new CohortIndicator(); // No name, log message should use "?" - count.setCohortDefinition(males, ""); - - Context.getService(IndicatorService.class).evaluate(count, null); - - List split = appender.getLogLines(); - Assert.assertEquals(6, split.size()); - Assert.assertTrue(split.get(0).contains("EVALUATION_STARTED")); - Assert.assertTrue(split.get(1).contains(">")); - Assert.assertTrue(split.get(1).contains("CohortIndicator")); - Assert.assertTrue(split.get(2).contains(">>")); - Assert.assertTrue(split.get(2).contains("GenderCohortDefinition[males]")); - Assert.assertTrue(split.get(5).contains("EVALUATION_COMPLETED")); - } -} diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java index c338121dd7..783385ad97 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/query/obs/evaluator/SqlObsQueryEvaluatorTest.java @@ -12,8 +12,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Cohort; import org.openmrs.api.context.Context; import org.openmrs.module.reporting.common.TestUtil; @@ -23,8 +23,8 @@ import org.openmrs.module.reporting.query.obs.ObsQueryResult; import org.openmrs.module.reporting.query.obs.definition.SqlObsQuery; import org.openmrs.module.reporting.query.obs.service.ObsQueryService; -import org.openmrs.test.BaseModuleContextSensitiveTest; import org.openmrs.test.SkipBaseSetup; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; /** * Test the evaluation of the SqlObsQuery @@ -34,7 +34,7 @@ public class SqlObsQueryEvaluatorTest extends BaseModuleContextSensitiveTest { protected static Log log = LogFactory.getLog(SqlObsQueryEvaluatorTest.class); - @Before + @BeforeEach public void setup() throws Exception { initializeInMemoryDatabase(); authenticate(); From ca8eb8d67f75f7d7f4abe8480be7280d689ee949 Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Tue, 22 Jul 2025 10:32:20 +0530 Subject: [PATCH 3/3] Add the EvaluationProfilerTest24On --- .../PrivilegedDataConverterTest.java | 2 - .../EvaluationProfilerTest24On.java | 98 +++++++++++++++++++ 2 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java index 1314afb004..22a48c0a03 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java @@ -31,8 +31,6 @@ public class PrivilegedDataConverterTest extends BaseModuleContextSensitiveTest public void setUp() throws Exception { initializeInMemoryDatabase(); executeDataSet("org/openmrs/module/reporting/include/PrivilegeTest.xml"); - Context.logout(); - Context.authenticate("test", "test"); } @Test diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java new file mode 100644 index 0000000000..a4edf82f44 --- /dev/null +++ b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java @@ -0,0 +1,98 @@ +package org.openmrs.module.reporting.evaluation; + +import java.util.List; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.AppenderRef; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.LoggerConfig; +import org.apache.logging.log4j.core.layout.PatternLayout; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openmrs.api.context.Context; +import org.openmrs.logging.MemoryAppender; +import org.openmrs.logging.OpenmrsLoggingUtil; +import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition; +import org.openmrs.module.reporting.indicator.CohortIndicator; +import org.openmrs.module.reporting.indicator.service.IndicatorService; +import org.openmrs.module.reporting.test.OpenmrsVersionTestListener; +import org.openmrs.module.reporting.test.RequiresVersion; +import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.util.OpenmrsUtil; +import org.springframework.test.context.TestExecutionListeners; + +/** + * Tests for {@link EvaluationProfiler} + */ +@TestExecutionListeners(OpenmrsVersionTestListener.class) +@RequiresVersion("2.4.* - 2.*") +public class EvaluationProfilerTest24On extends BaseModuleContextSensitiveTest { + + protected EvaluationProfiler profiler1, profiler2; + + private static MemoryAppender appender; + + @BeforeClass + public static void beforeClass() { + appender = OpenmrsLoggingUtil.getMemoryAppender(); + + if (appender == null) { + LoggerContext context = (LoggerContext) LogManager.getContext(false); + Configuration config = context.getConfiguration(); + + appender = MemoryAppender.newBuilder().setName("MEMORY_APPENDER").setLayout(PatternLayout.createDefaultLayout()) + .setConfiguration(config).build(); + appender.start(); + + config.addAppender(appender); + + AppenderRef appenderRef = AppenderRef.createAppenderRef("MEMORY_APPENDER", Level.ALL, null); + LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.ALL, EvaluationProfiler.class.getName(), null, + new AppenderRef[] { appenderRef }, null, config, null); + loggerConfig.addAppender(appender, Level.ALL, null); + config.addLogger(EvaluationProfiler.class.getName(), loggerConfig); + context.updateLoggers(); + } + + } + + @AfterClass + public static void afterClass() { + ((LoggerContext) LogManager.getContext()).updateLoggers(); + } + + /** + * Setup each test by configuring AOP on the relevant services and logging for the profiler class + */ + @Before + public void setup() { + profiler1 = new EvaluationProfiler(new EvaluationContext()); + profiler2 = new EvaluationProfiler(new EvaluationContext()); + } + + @Test + public void integration() throws EvaluationException { + GenderCohortDefinition males = new GenderCohortDefinition(); + males.setName("males"); + males.setMaleIncluded(true); + + CohortIndicator count = new CohortIndicator(); // No name, log message should use "?" + count.setCohortDefinition(males, ""); + + Context.getService(IndicatorService.class).evaluate(count, null); + + List split = appender.getLogLines(); + Assert.assertEquals(6, split.size()); + Assert.assertTrue(split.get(0).contains("EVALUATION_STARTED")); + Assert.assertTrue(split.get(1).contains(">")); + Assert.assertTrue(split.get(1).contains("CohortIndicator")); + Assert.assertTrue(split.get(2).contains(">>")); + Assert.assertTrue(split.get(2).contains("GenderCohortDefinition[males]")); + Assert.assertTrue(split.get(5).contains("EVALUATION_COMPLETED")); + } +}