From 511f1a8d2bab1f97222c79de495dea1c3771a083 Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Mon, 9 Jun 2025 04:22:35 +0530 Subject: [PATCH 1/3] REPORT-913: Migrate to OpenMRS Platform 2.4.0 (#262) * Migrate to 2.4.0 * Move api-1.9 * Merge old api modules to the main * Set the scope of reportingcompatibility to provided (cherry picked from commit e4022f6a54ff5f4f2c0ddd0fdaf810a2f0b8d890) --- .github/workflows/maven.yml | 3 +- api-1.10/.gitignore | 4 - api-1.10/pom.xml | 88 ---- .../BuiltInCohortDefinitionLibrary1_10.java | 49 --- ...uiltInCohortDefinitionLibrary1_10Test.java | 57 --- api-1.9/.gitignore | 1 - api-1.9/pom.xml | 80 ---- .../service/db/MappedDefinitionType.java | 209 --------- .../report/service/db/PropertiesType.java | 142 ------ .../report/service/db/RenderingModeType.java | 166 ------- .../service/db/ReportDefinitionType.java | 118 ----- .../DataExportDataSetPersisterTest.java | 170 ------- api-2.0/.gitignore | 1 - api-2.0/pom.xml | 80 ---- .../service/db/MappedDefinitionType.java | 208 --------- .../report/service/db/PropertiesType.java | 143 ------ .../report/service/db/RenderingModeType.java | 166 ------- .../service/db/ReportDefinitionType.java | 119 ----- api-2.2/.gitignore | 5 - api-2.2/pom.xml | 103 ----- .../BuiltInCohortDefinitionLibrary2_2.java | 43 -- ...BuiltInCohortDefinitionLibrary2_2Test.java | 57 --- api-2.4/.gitignore | 1 - api-2.4/pom.xml | 80 ---- api-tests-2.4/.gitignore | 1 - api-tests-2.4/pom.xml | 124 ------ .../PatientDataCalculationBehaviorTest.java | 5 +- ...onditionCohortDefinitionEvaluatorTest.java | 0 ...rugOrderCohortDefinitionEvaluatorTest.java | 14 +- .../BuiltInCohortDefinitionLibraryTest.java | 17 + .../OrderForVisitDataEvaluatorTest.java | 6 +- .../EvaluationProfilerTest24On.java | 0 ...onCohortDefinitionEvaluatorTestDataSet.xml | 0 .../include/DrugOrderCohortEvaluationData.xml | 6 +- .../definition/ConditionCohortDefinition.java | 5 +- .../definition/DrugOrderCohortDefinition.java | 5 +- .../ConditionCohortDefinitionEvaluator.java | 5 +- .../DrugOrderCohortDefinitionEvaluator.java | 14 +- .../BuiltInCohortDefinitionLibrary.java | 16 + .../DataExportDataSetDefinition.java | 0 .../evaluator/DataExportDataSetEvaluator.java | 30 +- .../DataExportDataSetDefinitionPersister.java | 0 .../service/db/MappedDefinitionType.java | 416 +++++++++--------- .../report/service/db/PropertiesType.java | 287 ++++++------ .../report/service/db/RenderingModeType.java | 332 +++++++------- .../service/db/ReportDefinitionType.java | 240 +++++----- pom.xml | 31 +- 47 files changed, 731 insertions(+), 2916 deletions(-) delete mode 100644 api-1.10/.gitignore delete mode 100644 api-1.10/pom.xml delete mode 100644 api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10.java delete mode 100644 api-1.10/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10Test.java delete mode 100644 api-1.9/.gitignore delete mode 100644 api-1.9/pom.xml delete mode 100644 api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java delete mode 100644 api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java delete mode 100644 api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java delete mode 100644 api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java delete mode 100644 api-1.9/src/test/java/org/openmrs/module/reporting/dataset/DataExportDataSetPersisterTest.java delete mode 100644 api-2.0/.gitignore delete mode 100644 api-2.0/pom.xml delete mode 100644 api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java delete mode 100644 api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java delete mode 100644 api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java delete mode 100644 api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java delete mode 100644 api-2.2/.gitignore delete mode 100644 api-2.2/pom.xml delete mode 100644 api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2.java delete mode 100644 api-2.2/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2Test.java delete mode 100644 api-2.4/.gitignore delete mode 100644 api-2.4/pom.xml delete mode 100644 api-tests-2.4/.gitignore delete mode 100644 api-tests-2.4/pom.xml rename {api-2.2 => api-tests}/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluatorTest.java (100%) rename {api-1.10 => api-tests}/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluatorTest.java (100%) rename {api-tests-2.4 => api-tests}/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java (100%) rename {api-2.2 => api-tests}/src/test/resources/org/openmrs/module/reporting/include/ConditionCohortDefinitionEvaluatorTestDataSet.xml (100%) rename {api-1.10 => api-tests}/src/test/resources/org/openmrs/module/reporting/include/DrugOrderCohortEvaluationData.xml (96%) rename {api-2.2 => api}/src/main/java/org/openmrs/module/reporting/cohort/definition/ConditionCohortDefinition.java (97%) rename {api-1.10 => api}/src/main/java/org/openmrs/module/reporting/cohort/definition/DrugOrderCohortDefinition.java (99%) rename {api-2.2 => api}/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluator.java (96%) rename {api-1.10 => api}/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluator.java (98%) rename {api-1.9 => api}/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java (100%) rename {api-1.9 => api}/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/DataExportDataSetEvaluator.java (81%) rename {api-1.9 => api}/src/main/java/org/openmrs/module/reporting/dataset/definition/persister/DataExportDataSetDefinitionPersister.java (100%) rename {api-2.4 => api}/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java (94%) rename {api-2.4 => api}/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java (95%) rename {api-2.4 => api}/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java (91%) rename {api-2.4 => api}/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java (96%) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b92a7acf6a..df6445a783 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -14,7 +14,6 @@ jobs: matrix: platform: [ ubuntu-latest ] java-version: [ 8 ] - profile: [ 1.10, 1.11, 1.12, 2.0, 2.1, 2.2, 2.3, 2.4 ] runs-on: ${{ matrix.platform }} env: @@ -36,5 +35,5 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - name: Build with Maven - run: mvn clean install -P ${{ matrix.profile }} --batch-mode --show-version --file pom.xml + run: mvn clean install --batch-mode --show-version --file pom.xml diff --git a/api-1.10/.gitignore b/api-1.10/.gitignore deleted file mode 100644 index c277ec4914..0000000000 --- a/api-1.10/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/.settings -/.classpath -/.project -/target diff --git a/api-1.10/pom.xml b/api-1.10/pom.xml deleted file mode 100644 index bdab2db9ee..0000000000 --- a/api-1.10/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - 4.0.0 - - - org.openmrs.module - reporting - 1.28.0-SNAPSHOT - - - reporting-api-1.10 - jar - reporting Module api 1.10 - 1.10 api project for reporting - - - 1.10.6 - - - - - ${project.parent.groupId} - ${project.parent.artifactId}-api - ${project.parent.version} - provided - - - - ${project.parent.groupId} - ${project.parent.artifactId}-api-tests - ${project.parent.version} - test-jar - test - - - - org.openmrs.api - openmrs-api - ${openMRSVersion} - provided - - - - org.openmrs.api - openmrs-api - test-jar - ${openMRSVersion} - test - - - - org.openmrs.test - openmrs-test - ${openMRSVersion} - pom - test - - - - - - - - src/main/resources - true - - - - - - src/test/resources - - **/*.properties - **/*.xml - - true - - - src/test/resources - - **/*.properties - **/*.xml - - false - - - - - diff --git a/api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10.java b/api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10.java deleted file mode 100644 index 6efb85e780..0000000000 --- a/api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10.java +++ /dev/null @@ -1,49 +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.cohort.definition.library; - -import org.openmrs.Concept; -import org.openmrs.CareSetting; -import org.openmrs.Drug; -import org.openmrs.module.reporting.common.Match; -import org.openmrs.module.reporting.cohort.definition.CohortDefinition; -import org.openmrs.module.reporting.cohort.definition.DrugOrderCohortDefinition; -import org.openmrs.module.reporting.cohort.definition.library.BuiltInCohortDefinitionLibrary; -import org.openmrs.module.reporting.definition.library.DocumentedDefinition; -import org.openmrs.module.reporting.evaluation.parameter.Parameter; -import org.springframework.stereotype.Component; - -import java.util.Date; -import java.util.List; - -/** - * Basic set of cohort definitions - */ -@Component -public class BuiltInCohortDefinitionLibrary1_10 extends BuiltInCohortDefinitionLibrary { - - - - @DocumentedDefinition("drugOrderSearch") - public CohortDefinition getDrugOrderSearch() { - CohortDefinition drugOrderCohortDefinition = new DrugOrderCohortDefinition(); - drugOrderCohortDefinition.addParameter(new Parameter("which", "reporting.parameter.which", Match.class)); - drugOrderCohortDefinition.addParameter(new Parameter("drugConcepts", "reporting.parameter.drugConcepts", Concept.class, List.class, null)); - drugOrderCohortDefinition.addParameter(new Parameter("drugSets", "reporting.parameter.drugSets", Concept.class, List.class, null)); - drugOrderCohortDefinition.addParameter(new Parameter("activatedOnOrBefore", "reporting.parameter.activatedOnOrBefore", Date.class)); - drugOrderCohortDefinition.addParameter(new Parameter("activatedOnOrAfter", "reporting.parameter.activatedOnOrAfter", Date.class)); - drugOrderCohortDefinition.addParameter(new Parameter("activeOnOrBefore", "reporting.parameter.activeOnOrBefore", Date.class)); - drugOrderCohortDefinition.addParameter(new Parameter("activeOnOrAfter", "reporting.parameter.activeOnOrAfter", Date.class)); - drugOrderCohortDefinition.addParameter(new Parameter("activeOnDate", "reporting.parameter.activeOnDate", Date.class)); - drugOrderCohortDefinition.addParameter(new Parameter("careSetting", "reporting.parameter.careSetting", CareSetting.class)); - drugOrderCohortDefinition.addParameter(new Parameter("drugs", "reporting.parameter.drugs", Drug.class, List.class, null)); - return drugOrderCohortDefinition; - } -} diff --git a/api-1.10/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10Test.java b/api-1.10/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10Test.java deleted file mode 100644 index f975d8e06e..0000000000 --- a/api-1.10/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary1_10Test.java +++ /dev/null @@ -1,57 +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.cohort.definition.library; - -import org.junit.Before; -import org.junit.Test; -import org.openmrs.CareSetting; -import org.openmrs.Concept; -import org.openmrs.Drug; -import org.openmrs.module.reporting.common.Match; -import org.openmrs.module.reporting.cohort.definition.CohortDefinition; -import org.openmrs.module.reporting.cohort.definition.DrugOrderCohortDefinition; - -import java.util.Date; -import java.util.List; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.openmrs.module.reporting.common.ReportingMatchers.hasParameter; - -/** - * - */ -public class BuiltInCohortDefinitionLibrary1_10Test { - - private BuiltInCohortDefinitionLibrary1_10 library; - - @Before - public void setUp() throws Exception { - library = new BuiltInCohortDefinitionLibrary1_10(); - } - - @Test - public void testgetDrugOrderSearch() throws Exception { - CohortDefinition drugOrderCohortDefinition = library.getDrugOrderSearch(); - assertTrue(DrugOrderCohortDefinition.class.isAssignableFrom(drugOrderCohortDefinition.getClass())); - assertThat(drugOrderCohortDefinition, hasParameter("which", Match.class)); - assertThat(drugOrderCohortDefinition, hasParameter("drugConcepts", Concept.class, List.class)); - assertThat(drugOrderCohortDefinition, hasParameter("drugSets", Concept.class, List.class)); - assertThat(drugOrderCohortDefinition, hasParameter("activatedOnOrBefore", Date.class)); - assertThat(drugOrderCohortDefinition, hasParameter("activatedOnOrAfter", Date.class)); - assertThat(drugOrderCohortDefinition, hasParameter("activeOnOrBefore", Date.class)); - assertThat(drugOrderCohortDefinition, hasParameter("activeOnOrAfter", Date.class)); - assertThat(drugOrderCohortDefinition, hasParameter("activeOnDate", Date.class)); - assertThat(drugOrderCohortDefinition, hasParameter("careSetting", CareSetting.class)); - assertThat(drugOrderCohortDefinition, hasParameter("drugs", Drug.class, List.class)); - } - -} diff --git a/api-1.9/.gitignore b/api-1.9/.gitignore deleted file mode 100644 index b83d22266a..0000000000 --- a/api-1.9/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/api-1.9/pom.xml b/api-1.9/pom.xml deleted file mode 100644 index f9f4b777f7..0000000000 --- a/api-1.9/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - 4.0.0 - - - org.openmrs.module - reporting - 1.28.0-SNAPSHOT - - - reporting-api-1.9 - jar - reporting Module api 1.9 - 1.9 api project for reporting - - - 1.9.9 - - - - - ${project.parent.groupId} - ${project.parent.artifactId}-api - ${project.parent.version} - provided - - - - org.openmrs.api - openmrs-api - ${openMRSVersion} - provided - - - - org.openmrs.api - openmrs-api - test-jar - ${openMRSVersion} - test - - - - org.openmrs.test - openmrs-test - ${openMRSVersion} - pom - test - - - - - - - - src/main/resources - true - - - - - - src/test/resources - - **/*.properties - **/*.xml - - true - - - src/test/resources - - **/*.properties - **/*.xml - - false - - - - - \ No newline at end of file diff --git a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java b/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java deleted file mode 100644 index 7a214dd25f..0000000000 --- a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java +++ /dev/null @@ -1,209 +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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.commons.lang.StringUtils; -import org.hibernate.Hibernate; -import org.hibernate.HibernateException; -import org.hibernate.engine.SessionImplementor; -import org.hibernate.type.Type; -import org.hibernate.usertype.CompositeUserType; -import org.hibernate.usertype.ParameterizedType; -import org.hibernate.usertype.UserType; -import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.common.HibernateUtil; -import org.openmrs.module.reporting.definition.DefinitionContext; -import org.openmrs.module.reporting.evaluation.Definition; -import org.openmrs.module.reporting.evaluation.parameter.Mapped; -import org.openmrs.module.reporting.evaluation.parameter.Parameterizable; -import org.openmrs.module.reporting.serializer.ReportingSerializer; - -/** - * Custom User-Type for storing Mapped objects in a single table within 2 columns - * This type takes in 2 properties and 1 parameter in the form: - *
- *		
- *			
- *			
- *			
- *				org.openmrs.module.reporting.report.definition.ReportDefinition
- *			
- *		
- * 
- */ -@SuppressWarnings({"rawtypes", "unchecked"}) -public class MappedDefinitionType implements CompositeUserType, ParameterizedType { - - /** - * Property via ParameterizedType for storing the type of the Mapped Parameterizable - */ - private Class mappedType; - - /** - * @see CompositeUserType#returnedClass() - */ - public Class returnedClass() { - return Mapped.class; - } - - /** - * @see CompositeUserType#getPropertyNames() - */ - public String[] getPropertyNames() { - return new String[] {"definition", "parameterMappings"}; - } - - /** - * @see CompositeUserType#getPropertyTypes() - */ - public Type[] getPropertyTypes() { - return new Type[] { HibernateUtil.standardType("STRING"), HibernateUtil.standardType("TEXT") }; - } - - /** - * @see CompositeUserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see CompositeUserType#getPropertyValue(java.lang.Object, int) - */ - public Object getPropertyValue(Object component, int property) throws HibernateException { - Mapped m = (Mapped) component; - return (property == 0 ? m.getParameterizable() : m.getParameterMappings()); - } - - /** - * @see CompositeUserType#setPropertyValue(java.lang.Object, int, java.lang.Object) - */ - public void setPropertyValue(Object component, int property, Object value) throws HibernateException { - Mapped m = (Mapped) component; - if (property == 0) { - m.setParameterizable((Parameterizable)value); - } - else { - m.setParameterMappings((Map)value); - } - } - - /** - * @see CompositeUserType#deepCopy(java.lang.Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value == null) return null; - Mapped toCopy = (Mapped) value; - Mapped m = new Mapped(); - m.setParameterizable(toCopy.getParameterizable()); - m.setParameterMappings(new HashMap(toCopy.getParameterMappings())); - return m; - } - - /** - * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { - String parameterizableUuid = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[0], session, owner); - if (StringUtils.isEmpty(parameterizableUuid)) { return null; } - String serializedMappings = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); - Definition d = DefinitionContext.getDefinitionByUuid(mappedType, parameterizableUuid); - Map mappings = new HashMap(); - if (StringUtils.isNotBlank(serializedMappings)) { - try { - mappings = Context.getSerializationService().deserialize(serializedMappings, Map.class, ReportingSerializer.class); - } - catch (Exception e) { - throw new HibernateException("Unable to deserialize parameter mappings for definition", e); - } - } - return new Mapped(d, mappings); - } - - /** - * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - String definitionUuid = null; - String serializedMappings = null; - if (value != null) { - Mapped m = (Mapped) value; - if (m.getParameterizable() != null) { - definitionUuid = m.getParameterizable().getUuid(); - if (m.getParameterMappings() != null && !m.getParameterMappings().isEmpty()) { - try { - serializedMappings = Context.getSerializationService().serialize(m.getParameterMappings(), ReportingSerializer.class); - } - catch (Exception e) { - throw new HibernateException("Unable to serialize mappings for definition", e); - } - } - } - } - HibernateUtil.standardType("STRING").nullSafeSet(st, definitionUuid, index, session); - HibernateUtil.standardType("STRING").nullSafeSet(st, serializedMappings, index+1, session); - } - - /** - * @see CompositeUserType#replace(Object, Object, SessionImplementor, Object) - */ - public Object replace(Object original, Object target, SessionImplementor session, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see CompositeUserType#disassemble(Object, SessionImplementor) - */ - public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException { - return (Serializable) deepCopy(value); - } - - /** - * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) - */ - public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { - return deepCopy(cached); - } - - /** - * @see ParameterizedType#setParameterValues(Properties) - */ - public void setParameterValues(Properties parameters) { - String mappedTypeStr = parameters.getProperty("mappedType"); - try { - mappedType = (Class)Context.loadClass(mappedTypeStr); - } - catch (Exception e) { - throw new HibernateException("Error setting the mappedType property to " + mappedTypeStr, e); - } - } -} \ No newline at end of file diff --git a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java b/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java deleted file mode 100644 index 1f5a014233..0000000000 --- a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java +++ /dev/null @@ -1,142 +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.report.service.db; - -import org.hibernate.HibernateException; -import org.hibernate.usertype.UserType; - -import java.io.IOException; -import java.io.Serializable; -import java.io.StringReader; -import java.io.StringWriter; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map; -import java.util.Properties; - -import static java.sql.Types.VARCHAR; - -/** - * A report definition type - */ -public class PropertiesType implements UserType { - - /** - * @see UserType#assemble(Serializable, Object) - */ - public Object assemble(Serializable cached, Object owner) throws HibernateException { - if (cached == null) { - return null; - } - try { - String s = (String) cached; - Properties p = new Properties(); - p.load(new StringReader(s)); - return p; - } - catch (IOException e) { - throw new IllegalArgumentException("Unable to load properties from string", e); - } - } - - /** - * @see UserType#deepCopy(Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value != null) { - Properties val = (Properties) value; - Properties copy = new Properties(); - for ( Map.Entry e : val.entrySet() ) { - copy.setProperty((String) e.getKey(), (String) e.getValue()); - } - return copy; - } else { - return null; - } - } - - /** - * @see UserType#disassemble(Object) - */ - public Serializable disassemble(Object value) throws HibernateException { - if (value == null) { - return null; - } - try { - Properties props = (Properties) value; - StringWriter sw = new StringWriter(); - props.store(sw, null); - return sw.toString(); - } - catch (IOException e) { - throw new IllegalArgumentException("Unable to store properties as string", e); - } - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see UserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see UserType#nullSafeGet(ResultSet, String[], Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { - String s = rs.getString(names[0]); - return assemble(s, null); - } - - /** - * @see UserType#nullSafeSet(PreparedStatement, Object, int) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { - String val = (String) disassemble(value); - st.setString(index, val); - } - - /** - * @see UserType#replace(Object, Object, Object) - */ - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#returnedClass() - */ - @SuppressWarnings("unchecked") - public Class returnedClass() { - return Properties.class; - } - - /** - * @see UserType#sqlTypes() - */ - public int[] sqlTypes() { - return new int[] { VARCHAR }; - } -} diff --git a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java b/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java deleted file mode 100644 index 3c344c3f66..0000000000 --- a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java +++ /dev/null @@ -1,166 +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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.hibernate.HibernateException; -import org.hibernate.engine.SessionImplementor; -import org.hibernate.type.Type; -import org.hibernate.usertype.CompositeUserType; -import org.hibernate.usertype.UserType; -import org.openmrs.module.reporting.common.HibernateUtil; -import org.openmrs.module.reporting.report.renderer.RenderingMode; -import org.openmrs.module.reporting.report.renderer.ReportRenderer; - -/** - * Custom User-Type for storing RenderingModes in a single table within 2 columns - * This type takes in 2 properties in the form: - *
- *   
- *     
- *     
- *   
- * 
- */ -@SuppressWarnings({"rawtypes"}) -public class RenderingModeType implements CompositeUserType { - - /** - * @see CompositeUserType#returnedClass() - */ - public Class returnedClass() { - return RenderingMode.class; - } - - /** - * @see CompositeUserType#getPropertyNames() - */ - public String[] getPropertyNames() { - return new String[] {"renderer", "argument"}; - } - - /** - * @see CompositeUserType#getPropertyTypes() - */ - public Type[] getPropertyTypes() { - return new Type[] { HibernateUtil.standardType("CLASS"), HibernateUtil.standardType("STRING") }; - } - - /** - * @see CompositeUserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see CompositeUserType#getPropertyValue(java.lang.Object, int) - */ - public Object getPropertyValue(Object component, int property) throws HibernateException { - RenderingMode m = (RenderingMode) component; - return (property == 0 ? m.getRenderer().getClass() : m.getArgument()); - } - - /** - * @see CompositeUserType#setPropertyValue(java.lang.Object, int, java.lang.Object) - */ - public void setPropertyValue(Object component, int property, Object value) throws HibernateException { - RenderingMode m = (RenderingMode) component; - if (property == 0) { - ReportRenderer r = null; - if (value != null) { - try { - r = (ReportRenderer)((Class) value).newInstance(); - } - catch (Exception e) { - throw new HibernateException("Error instantiating a new reporting renderer from " + value, e); - } - } - m.setRenderer(r); - } - else { - m.setArgument((String)value); - } - } - - /** - * @see CompositeUserType#deepCopy(java.lang.Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value == null) return null; - RenderingMode toCopy = (RenderingMode) value; - return new RenderingMode(toCopy.getRenderer(), toCopy.getLabel(), toCopy.getArgument(), toCopy.getSortWeight()); - } - - /** - * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { - Class rendererClass = (Class) HibernateUtil.standardType("CLASS").nullSafeGet(rs, names[0], session, owner); - if (rendererClass == null) { return null; } - String argument = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); - ReportRenderer r = null; - try { - r = (ReportRenderer)((Class) rendererClass).newInstance(); - } - catch (Exception e) { - throw new HibernateException("Error instantiating a new reporting renderer from " + rendererClass, e); - } - return new RenderingMode(r, r.getClass().getSimpleName(), argument, null); - } - - /** - * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - RenderingMode mode = (RenderingMode) value; - HibernateUtil.standardType("CLASS").nullSafeSet(st, mode == null ? null : mode.getRenderer().getClass(), index, session); - HibernateUtil.standardType("STRING").nullSafeSet(st, mode == null ? null : mode.getArgument(), index+1, session); - } - - /** - * @see CompositeUserType#replace(java.lang.Object, java.lang.Object, org.hibernate.engine.SessionImplementor, java.lang.Object) - */ - public Object replace(Object original, Object target, SessionImplementor session, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see CompositeUserType#disassemble(Object, SessionImplementor) - */ - public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException { - return (Serializable) deepCopy(value); - } - - /** - * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) - */ - public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { - return deepCopy(cached); - } -} \ No newline at end of file diff --git a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java b/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java deleted file mode 100644 index b83c9cf328..0000000000 --- a/api-1.9/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java +++ /dev/null @@ -1,118 +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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; - -import org.hibernate.HibernateException; -import org.hibernate.usertype.UserType; -import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.report.definition.ReportDefinition; -import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; - -/** - * A report definition type - */ -public class ReportDefinitionType implements UserType { - - /** - * @see UserType#assemble(Serializable, Object) - */ - public Object assemble(Serializable cached, Object owner) throws HibernateException { - if(cached == null){ - return null; - } - return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(cached.toString()); - } - - /** - * @see UserType#deepCopy(Object) - */ - public Object deepCopy(Object value) throws HibernateException { - return value; - } - - /** - * @see UserType#disassemble(Object) - */ - public Serializable disassemble(Object value) throws HibernateException { - if (value == null) { - return null; - } - return ((ReportDefinition)value).getUuid(); - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see UserType#isMutable() - */ - public boolean isMutable() { - return false; - } - - /** - * @see UserType#nullSafeGet(ResultSet, String[], Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { - String uuid = rs.getString(names[0]); - if (uuid == null) { - return null; - } - return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(uuid); - } - - /** - * @see UserType#nullSafeSet(PreparedStatement, Object, int) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { - ReportDefinition d = (ReportDefinition) value; - String val = (d == null ? null : d.getUuid()); - st.setString(index, val); - } - - /** - * @see UserType#replace(Object, Object, Object) - */ - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#returnedClass() - */ - @SuppressWarnings("rawtypes") - public Class returnedClass() { - return ReportDefinition.class; - } - - /** - * @see UserType#sqlTypes() - */ - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; - } -} diff --git a/api-1.9/src/test/java/org/openmrs/module/reporting/dataset/DataExportDataSetPersisterTest.java b/api-1.9/src/test/java/org/openmrs/module/reporting/dataset/DataExportDataSetPersisterTest.java deleted file mode 100644 index 3ec2cb10f7..0000000000 --- a/api-1.9/src/test/java/org/openmrs/module/reporting/dataset/DataExportDataSetPersisterTest.java +++ /dev/null @@ -1,170 +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; - -import java.util.List; - -import org.junit.Assert; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.dataset.definition.DataExportDataSetDefinition; -import org.openmrs.module.reporting.dataset.definition.DataSetDefinition; -import org.openmrs.module.reporting.dataset.definition.persister.DataExportDataSetDefinitionPersister; -import org.openmrs.module.reporting.dataset.definition.persister.DataSetDefinitionPersister; -import org.openmrs.reporting.ReportObjectService; -import org.openmrs.reporting.export.DataExportReportObject; -import org.openmrs.test.BaseModuleContextSensitiveTest; -import org.openmrs.test.StartModule; - -/** - * Test of the Data Export Data Set Persister - */ -@SuppressWarnings("deprecation") -@StartModule( { "org/openmrs/module/reporting/include/reportingcompatibility-1.5.3.omod" }) -@Ignore -public class DataExportDataSetPersisterTest extends BaseModuleContextSensitiveTest { - - protected static Log log = LogFactory.getLog(DataExportDataSetPersisterTest.class); - - @Before - public void setupInitialData() throws Exception { - { - DataExportReportObject ro = new DataExportReportObject(); - ro.setName("Test Last Weight"); - ro.setDescription("Description 1"); - ro.addSimpleColumn("patientId", "patientId"); - ro.addConceptColumn("weight", "LAST", 1, "5089", null); - Context.getReportObjectService().saveReportObject(ro); - } - { - DataExportReportObject ro = new DataExportReportObject(); - ro.setName("Test CD4"); - ro.setDescription("Description 2"); - ro.addSimpleColumn("patientId", "patientId"); - ro.addConceptColumn("cd4", "LAST", 1, "5497", null); - Context.getReportObjectService().saveReportObject(ro); - } - { - DataExportReportObject ro = new DataExportReportObject(); - ro.setName("Test Name"); - ro.setDescription("Description 3"); - ro.addSimpleColumn("patientId", "patientId"); - ro.addSimpleColumn("name", "personName"); - Context.getReportObjectService().saveReportObject(ro); - } - { - DataExportReportObject ro = new DataExportReportObject(); - ro.setName("Test First 3 Weights"); - ro.setDescription("Description 4"); - ro.addSimpleColumn("patientId", "patientId"); - ro.addConceptColumn("weight", "FIRST", 3, "5089", null); - Context.getReportObjectService().saveReportObject(ro); - } - { - DataExportReportObject ro = new DataExportReportObject(); - ro.setName("Test Gender"); - ro.setDescription("Description 5"); - ro.addSimpleColumn("patientId", "patientId"); - ro.addSimpleColumn("gender", "patient.gender"); - Context.getReportObjectService().saveReportObject(ro); - } - } - - @Test - public void shouldReturnDataSetDefinitionIfExists() throws Exception { - // big time hack: this test only works if it's first, because I'm creating the Data Exports programmatically, and each run they get new autonumbered ids. - // if the initial data gets set up via executing an xml dataset instead, then this test can be anywhere in the class - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - DataSetDefinition def = persister.getDefinition(1); - Assert.assertNotNull("Should return dataset definition if exists", def); - } - - /** - * Tests whether the persister returns all dataset definitions. - * - * @throws Exception - */ - @Test - public void shouldGetAllDataSetDefinitions() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - List list = persister.getAllDefinitions(false); - Assert.assertEquals("Should return all dataset definitions", 5, list.size()); - } - - @Test - public void shouldReturnAllDatasetDefinitionsIncludingRetired() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - List list = persister.getAllDefinitions(true); - Assert.assertEquals("Should return all dataset definitions, including retired", 5, list.size()); - } - - @Test - public void shouldReturnAllDatasetDefinitionsExcludingRetired() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - List list = persister.getAllDefinitions(false); - Assert.assertEquals("Should return all dataset definitions, excluding retired", 5, list.size()); - } - - @Test - public void shouldReturnNullIfNotExist() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - DataSetDefinition def = persister.getDefinition(999); - Assert.assertNull("Should return null if not exists", def); - } - @Test - public void shouldReturnNullIfNameDoesNotMatch() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - List def = - persister.getDefinitions("Dataset definition that does not exist", true); - Assert.assertEquals(0, def.size()); - } - - @Test - public void shouldReturnDataSetDefinitionIfNameMatches() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - List def = - persister.getDefinitions("Test First 3 Weights", true); - Assert.assertEquals(1, def.size()); - } - - @Test(expected=UnsupportedOperationException.class) - public void shouldNotBeAbleToModifyUnderlyingDataExport() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - DataSetDefinition datasetDefinition = persister.getDefinitions("Test First 3 Weights", true).get(0); - datasetDefinition.setName("My Data Set Definition"); - } - - @Test - public void shouldSetIdentifierAfterSave() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - DataExportReportObject dataExport = (DataExportReportObject) Context.getService(ReportObjectService.class).getReportObject(45); - dataExport.setReportObjectId(null); - dataExport.setName("My Data Set Definition"); - // Save an existing data set definition - DataSetDefinition datasetDefinition = new DataExportDataSetDefinition(dataExport); - datasetDefinition = persister.saveDefinition(datasetDefinition); - Assert.assertNotNull("Should set identifier after saving dataset definition", datasetDefinition.getId()); - } - - @Test - public void shouldRemoveDataSetDefintion() throws Exception { - DataSetDefinitionPersister persister = new DataExportDataSetDefinitionPersister(); - DataSetDefinition beforePurge = persister.getDefinitions("Test First 3 Weights", true).get(0); - int idBefore = beforePurge.getId(); - persister.purgeDefinition(beforePurge); - DataSetDefinition afterPurge = persister.getDefinition(idBefore); - Assert.assertNull(afterPurge); - } -} diff --git a/api-2.0/.gitignore b/api-2.0/.gitignore deleted file mode 100644 index b83d22266a..0000000000 --- a/api-2.0/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/api-2.0/pom.xml b/api-2.0/pom.xml deleted file mode 100644 index 5490a194ad..0000000000 --- a/api-2.0/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - 4.0.0 - - - org.openmrs.module - reporting - 1.28.0-SNAPSHOT - - - reporting-api-2.0 - jar - reporting Module api 2.0 - 2.0 api project for reporting - - - 2.0.0-alpha - - - - - ${project.parent.groupId} - ${project.parent.artifactId}-api - ${project.parent.version} - provided - - - - org.openmrs.api - openmrs-api - ${openMRSVersion} - provided - - - - org.openmrs.api - openmrs-api - test-jar - ${openMRSVersion} - test - - - - org.openmrs.test - openmrs-test - ${openMRSVersion} - pom - test - - - - - - - - src/main/resources - true - - - - - - src/test/resources - - **/*.properties - **/*.xml - - true - - - src/test/resources - - **/*.properties - **/*.xml - - false - - - - - diff --git a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java b/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java deleted file mode 100644 index 2354ae0d79..0000000000 --- a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java +++ /dev/null @@ -1,208 +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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.commons.lang.StringUtils; -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.type.Type; -import org.hibernate.usertype.CompositeUserType; -import org.hibernate.usertype.ParameterizedType; -import org.hibernate.usertype.UserType; -import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.common.HibernateUtil; -import org.openmrs.module.reporting.definition.DefinitionContext; -import org.openmrs.module.reporting.evaluation.Definition; -import org.openmrs.module.reporting.evaluation.parameter.Mapped; -import org.openmrs.module.reporting.evaluation.parameter.Parameterizable; -import org.openmrs.module.reporting.serializer.ReportingSerializer; - -/** - * Custom User-Type for storing Mapped objects in a single table within 2 columns - * This type takes in 2 properties and 1 parameter in the form: - *
- *		
- *			
- *			
- *			
- *				org.openmrs.module.reporting.report.definition.ReportDefinition
- *			
- *		
- * 
- */ -@SuppressWarnings({"rawtypes", "unchecked"}) -public class MappedDefinitionType implements CompositeUserType, ParameterizedType { - - /** - * Property via ParameterizedType for storing the type of the Mapped Parameterizable - */ - private Class mappedType; - - /** - * @see CompositeUserType#returnedClass() - */ - public Class returnedClass() { - return Mapped.class; - } - - /** - * @see CompositeUserType#getPropertyNames() - */ - public String[] getPropertyNames() { - return new String[] {"definition", "parameterMappings"}; - } - - /** - * @see CompositeUserType#getPropertyTypes() - */ - public Type[] getPropertyTypes() { - return new Type[] { HibernateUtil.standardType("STRING"), HibernateUtil.standardType("TEXT") }; - } - - /** - * @see CompositeUserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see CompositeUserType#getPropertyValue(java.lang.Object, int) - */ - public Object getPropertyValue(Object component, int property) throws HibernateException { - Mapped m = (Mapped) component; - return (property == 0 ? m.getParameterizable() : m.getParameterMappings()); - } - - /** - * @see CompositeUserType#setPropertyValue(java.lang.Object, int, java.lang.Object) - */ - public void setPropertyValue(Object component, int property, Object value) throws HibernateException { - Mapped m = (Mapped) component; - if (property == 0) { - m.setParameterizable((Parameterizable)value); - } - else { - m.setParameterMappings((Map)value); - } - } - - /** - * @see CompositeUserType#deepCopy(java.lang.Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value == null) return null; - Mapped toCopy = (Mapped) value; - Mapped m = new Mapped(); - m.setParameterizable(toCopy.getParameterizable()); - m.setParameterMappings(new HashMap(toCopy.getParameterMappings())); - return m; - } - - /** - * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { - String parameterizableUuid = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[0], session, owner); - if (StringUtils.isEmpty(parameterizableUuid)) { return null; } - String serializedMappings = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); - Definition d = DefinitionContext.getDefinitionByUuid(mappedType, parameterizableUuid); - Map mappings = new HashMap(); - if (StringUtils.isNotBlank(serializedMappings)) { - try { - mappings = Context.getSerializationService().deserialize(serializedMappings, Map.class, ReportingSerializer.class); - } - catch (Exception e) { - throw new HibernateException("Unable to deserialize parameter mappings for definition", e); - } - } - return new Mapped(d, mappings); - } - - /** - * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - String definitionUuid = null; - String serializedMappings = null; - if (value != null) { - Mapped m = (Mapped) value; - if (m.getParameterizable() != null) { - definitionUuid = m.getParameterizable().getUuid(); - if (m.getParameterMappings() != null && !m.getParameterMappings().isEmpty()) { - try { - serializedMappings = Context.getSerializationService().serialize(m.getParameterMappings(), ReportingSerializer.class); - } - catch (Exception e) { - throw new HibernateException("Unable to serialize mappings for definition", e); - } - } - } - } - HibernateUtil.standardType("STRING").nullSafeSet(st, definitionUuid, index, session); - HibernateUtil.standardType("STRING").nullSafeSet(st, serializedMappings, index+1, session); - } - - /** - * @see CompositeUserType#replace(Object, Object, SessionImplementor, Object) - */ - public Object replace(Object original, Object target, SessionImplementor session, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see CompositeUserType#disassemble(Object, SessionImplementor) - */ - public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException { - return (Serializable) deepCopy(value); - } - - /** - * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) - */ - public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { - return deepCopy(cached); - } - - /** - * @see ParameterizedType#setParameterValues(Properties) - */ - public void setParameterValues(Properties parameters) { - String mappedTypeStr = parameters.getProperty("mappedType"); - try { - mappedType = (Class)Context.loadClass(mappedTypeStr); - } - catch (Exception e) { - throw new HibernateException("Error setting the mappedType property to " + mappedTypeStr, e); - } - } -} \ No newline at end of file diff --git a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java b/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java deleted file mode 100644 index 8ae4703616..0000000000 --- a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java +++ /dev/null @@ -1,143 +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.report.service.db; - -import static java.sql.Types.VARCHAR; - -import java.io.IOException; -import java.io.Serializable; -import java.io.StringReader; -import java.io.StringWriter; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map; -import java.util.Properties; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.usertype.UserType; - -/** - * A report definition type - */ -public class PropertiesType implements UserType { - - /** - * @see UserType#assemble(Serializable, Object) - */ - public Object assemble(Serializable cached, Object owner) throws HibernateException { - if (cached == null) { - return null; - } - try { - String s = (String) cached; - Properties p = new Properties(); - p.load(new StringReader(s)); - return p; - } - catch (IOException e) { - throw new IllegalArgumentException("Unable to load properties from string", e); - } - } - - /** - * @see UserType#deepCopy(Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value != null) { - Properties val = (Properties) value; - Properties copy = new Properties(); - for ( Map.Entry e : val.entrySet() ) { - copy.setProperty((String) e.getKey(), (String) e.getValue()); - } - return copy; - } else { - return null; - } - } - - /** - * @see UserType#disassemble(Object) - */ - public Serializable disassemble(Object value) throws HibernateException { - if (value == null) { - return null; - } - try { - Properties props = (Properties) value; - StringWriter sw = new StringWriter(); - props.store(sw, null); - return sw.toString(); - } - catch (IOException e) { - throw new IllegalArgumentException("Unable to store properties as string", e); - } - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see UserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see UserType#nullSafeGet(ResultSet, String[], Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { - String s = rs.getString(names[0]); - return assemble(s, null); - } - - /** - * @see UserType#nullSafeSet(PreparedStatement, Object, int) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - String val = (String) disassemble(value); - st.setString(index, val); - } - - /** - * @see UserType#replace(Object, Object, Object) - */ - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#returnedClass() - */ - @SuppressWarnings("unchecked") - public Class returnedClass() { - return Properties.class; - } - - /** - * @see UserType#sqlTypes() - */ - public int[] sqlTypes() { - return new int[] { VARCHAR }; - } -} diff --git a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java b/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java deleted file mode 100644 index bd7058d629..0000000000 --- a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java +++ /dev/null @@ -1,166 +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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.type.Type; -import org.hibernate.usertype.CompositeUserType; -import org.hibernate.usertype.UserType; -import org.openmrs.module.reporting.common.HibernateUtil; -import org.openmrs.module.reporting.report.renderer.RenderingMode; -import org.openmrs.module.reporting.report.renderer.ReportRenderer; - -/** - * Custom User-Type for storing RenderingModes in a single table within 2 columns - * This type takes in 2 properties in the form: - *
- *   
- *     
- *     
- *   
- * 
- */ -@SuppressWarnings({"rawtypes"}) -public class RenderingModeType implements CompositeUserType { - - /** - * @see CompositeUserType#returnedClass() - */ - public Class returnedClass() { - return RenderingMode.class; - } - - /** - * @see CompositeUserType#getPropertyNames() - */ - public String[] getPropertyNames() { - return new String[] {"renderer", "argument"}; - } - - /** - * @see CompositeUserType#getPropertyTypes() - */ - public Type[] getPropertyTypes() { - return new Type[] { HibernateUtil.standardType("CLASS"), HibernateUtil.standardType("STRING") }; - } - - /** - * @see CompositeUserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see CompositeUserType#getPropertyValue(java.lang.Object, int) - */ - public Object getPropertyValue(Object component, int property) throws HibernateException { - RenderingMode m = (RenderingMode) component; - return (property == 0 ? m.getRenderer().getClass() : m.getArgument()); - } - - /** - * @see CompositeUserType#setPropertyValue(java.lang.Object, int, java.lang.Object) - */ - public void setPropertyValue(Object component, int property, Object value) throws HibernateException { - RenderingMode m = (RenderingMode) component; - if (property == 0) { - ReportRenderer r = null; - if (value != null) { - try { - r = (ReportRenderer)((Class) value).newInstance(); - } - catch (Exception e) { - throw new HibernateException("Error instantiating a new reporting renderer from " + value, e); - } - } - m.setRenderer(r); - } - else { - m.setArgument((String)value); - } - } - - /** - * @see CompositeUserType#deepCopy(java.lang.Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value == null) return null; - RenderingMode toCopy = (RenderingMode) value; - return new RenderingMode(toCopy.getRenderer(), toCopy.getLabel(), toCopy.getArgument(), toCopy.getSortWeight()); - } - - /** - * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { - Class rendererClass = (Class) HibernateUtil.standardType("CLASS").nullSafeGet(rs, names[0], session, owner); - if (rendererClass == null) { return null; } - String argument = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); - ReportRenderer r = null; - try { - r = (ReportRenderer)((Class) rendererClass).newInstance(); - } - catch (Exception e) { - throw new HibernateException("Error instantiating a new reporting renderer from " + rendererClass, e); - } - return new RenderingMode(r, r.getClass().getSimpleName(), argument, null); - } - - /** - * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - RenderingMode mode = (RenderingMode) value; - HibernateUtil.standardType("CLASS").nullSafeSet(st, mode == null ? null : mode.getRenderer().getClass(), index, session); - HibernateUtil.standardType("STRING").nullSafeSet(st, mode == null ? null : mode.getArgument(), index+1, session); - } - - /** - * @see CompositeUserType#replace(java.lang.Object, java.lang.Object, org.hibernate.engine.SessionImplementor, java.lang.Object) - */ - public Object replace(Object original, Object target, SessionImplementor session, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see CompositeUserType#disassemble(Object, SessionImplementor) - */ - public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException { - return (Serializable) deepCopy(value); - } - - /** - * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) - */ - public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { - return deepCopy(cached); - } -} \ No newline at end of file diff --git a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java b/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java deleted file mode 100644 index 5dd4336231..0000000000 --- a/api-2.0/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java +++ /dev/null @@ -1,119 +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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.usertype.UserType; -import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.report.definition.ReportDefinition; -import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; - -/** - * A report definition type - */ -public class ReportDefinitionType implements UserType { - - /** - * @see UserType#assemble(Serializable, Object) - */ - public Object assemble(Serializable cached, Object owner) throws HibernateException { - if(cached == null){ - return null; - } - return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(cached.toString()); - } - - /** - * @see UserType#deepCopy(Object) - */ - public Object deepCopy(Object value) throws HibernateException { - return value; - } - - /** - * @see UserType#disassemble(Object) - */ - public Serializable disassemble(Object value) throws HibernateException { - if (value == null) { - return null; - } - return ((ReportDefinition)value).getUuid(); - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see UserType#isMutable() - */ - public boolean isMutable() { - return false; - } - - /** - * @see UserType#nullSafeGet(ResultSet, String[], Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { - String uuid = rs.getString(names[0]); - if (uuid == null) { - return null; - } - return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(uuid); - } - - /** - * @see UserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - ReportDefinition d = (ReportDefinition) value; - String val = (d == null ? null : d.getUuid()); - st.setString(index, val); - } - - /** - * @see UserType#replace(Object, Object, Object) - */ - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#returnedClass() - */ - @SuppressWarnings("rawtypes") - public Class returnedClass() { - return ReportDefinition.class; - } - - /** - * @see UserType#sqlTypes() - */ - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; - } -} diff --git a/api-2.2/.gitignore b/api-2.2/.gitignore deleted file mode 100644 index 0b40cb3336..0000000000 --- a/api-2.2/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/.settings -/.classpath -/.project -/target -/bin/ diff --git a/api-2.2/pom.xml b/api-2.2/pom.xml deleted file mode 100644 index bbdb2557cf..0000000000 --- a/api-2.2/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - 4.0.0 - - - org.openmrs.module - reporting - 1.28.0-SNAPSHOT - - - reporting-api-2.2 - jar - reporting Module api 2.2 - 2.2 api project for reporting - - - 2.2.0 - - - - - ${project.parent.groupId} - ${project.parent.artifactId}-api - ${project.parent.version} - provided - - - ${project.parent.groupId} - ${project.parent.artifactId}-api-tests - ${project.parent.version} - test-jar - test - - - - org.openmrs.test - openmrs-test - pom - test - ${openMRSVersion} - - - org.openmrs.api - openmrs-api - ${openMRSVersion} - - - - org.openmrs.api - openmrs-api - test-jar - test - ${openMRSVersion} - - - - org.openmrs.module - reportingcompatibility-api - ${reportingCompatibilityVersion} - test - - - cglib - cglib-nodep - 2.2 - test - - - org.codehaus.jackson - jackson-core-asl - 1.9.13 - test - - - - - - - src/main/resources - true - - - - - - src/test/resources - - **/*.properties - **/*.xml - - true - - - src/test/resources - - **/*.properties - **/*.xml - - false - - - - - diff --git a/api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2.java b/api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2.java deleted file mode 100644 index c742ed349a..0000000000 --- a/api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2.java +++ /dev/null @@ -1,43 +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.cohort.definition.library; - -import org.openmrs.Concept; -import org.openmrs.CareSetting; -import org.openmrs.Drug; -import org.openmrs.module.reporting.common.Match; -import org.openmrs.module.reporting.cohort.definition.CohortDefinition; -import org.openmrs.module.reporting.cohort.definition.ConditionCohortDefinition; -import org.openmrs.module.reporting.cohort.definition.library.BuiltInCohortDefinitionLibrary2_2; -import org.openmrs.module.reporting.definition.library.DocumentedDefinition; -import org.openmrs.module.reporting.evaluation.parameter.Parameter; -import org.springframework.stereotype.Component; - -import java.util.Date; -import java.util.List; - -@Component -public class BuiltInCohortDefinitionLibrary2_2 extends BuiltInCohortDefinitionLibrary { - - @DocumentedDefinition("conditonSearchAdvanced") - public CohortDefinition getConditonSearchAdvanced() { - ConditionCohortDefinition cd = new ConditionCohortDefinition(); - cd.addParameter(new Parameter("conditionCoded", "reporting.parameter.conditionCoded", Concept.class)); - cd.addParameter(new Parameter("conditionNonCoded", "reporting.parameter.conditionNonCoded", String.class)); - cd.addParameter(new Parameter("onsetDateOnOrBefore", "reporting.parameter.onsetDateOnOrBefore", Date.class)); - cd.addParameter(new Parameter("onsetDateOnOrAfter", "reporting.parameter.onsetDateOnOrAfter", Date.class)); - cd.addParameter(new Parameter("endDateOnOrBefore", "reporting.parameter.endDateOnOrBefore", Date.class)); - cd.addParameter(new Parameter("endDateOnOrAfter", "reporting.parameter.endDateOnOrAfter", Date.class)); - cd.addParameter(new Parameter("createdOnOrBefore", "reporting.parameter.createdOnOrBefore", Date.class)); - cd.addParameter(new Parameter("createdOnOrAfter", "reporting.parameter.createdOnOrAfter", Date.class)); - cd.addParameter(new Parameter("activeOnDate", "reporting.parameter.activeOnDate", Date.class)); - return cd; - } -} diff --git a/api-2.2/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2Test.java b/api-2.2/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2Test.java deleted file mode 100644 index 60000944db..0000000000 --- a/api-2.2/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary2_2Test.java +++ /dev/null @@ -1,57 +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.cohort.definition.library; -/** - * 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. - */ -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import java.util.Date; - -import org.junit.Before; -import org.junit.Test; -import org.openmrs.Concept; -import org.openmrs.module.reporting.cohort.definition.CohortDefinition; -import org.openmrs.module.reporting.cohort.definition.ConditionCohortDefinition; -import org.openmrs.module.reporting.cohort.definition.library.BuiltInCohortDefinitionLibrary2_2; - -import static org.openmrs.module.reporting.common.ReportingMatchers.hasParameter; - - -public class BuiltInCohortDefinitionLibrary2_2Test { - - private BuiltInCohortDefinitionLibrary2_2 library; - - @Before - public void setUp() throws Exception { - library = new BuiltInCohortDefinitionLibrary2_2(); - } - - @Test - public void testGetConditonSearchAdavanced() throws Exception { - CohortDefinition cd = library.getConditonSearchAdvanced(); - assertTrue(ConditionCohortDefinition.class.isAssignableFrom(cd.getClass())); - assertThat(cd, hasParameter("onsetDateOnOrBefore", Date.class)); - assertThat(cd, hasParameter("onsetDateOnOrAfter", Date.class)); - assertThat(cd, hasParameter("endDateOnOrBefore", Date.class)); - assertThat(cd, hasParameter("endDateOnOrAfter", Date.class)); - assertThat(cd, hasParameter("createdOnOrBefore", Date.class)); - assertThat(cd, hasParameter("createdOnOrAfter", Date.class)); - assertThat(cd, hasParameter("activeOnDate", Date.class)); - assertThat(cd, hasParameter("conditionNonCoded", String.class)); - assertThat(cd, hasParameter("conditionCoded", Concept.class)); - } -} diff --git a/api-2.4/.gitignore b/api-2.4/.gitignore deleted file mode 100644 index b83d22266a..0000000000 --- a/api-2.4/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/api-2.4/pom.xml b/api-2.4/pom.xml deleted file mode 100644 index 478db21a8a..0000000000 --- a/api-2.4/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - 4.0.0 - - - org.openmrs.module - reporting - 1.28.0-SNAPSHOT - - - reporting-api-2.4 - jar - reporting Module api 2.4 - 2.4 api project for reporting - - - 2.4.0 - - - - - ${project.parent.groupId} - ${project.parent.artifactId}-api - ${project.parent.version} - provided - - - - org.openmrs.api - openmrs-api - ${openMRSVersion} - provided - - - - org.openmrs.api - openmrs-api - test-jar - ${openMRSVersion} - test - - - - org.openmrs.test - openmrs-test - ${openMRSVersion} - pom - test - - - - - - - - src/main/resources - true - - - - - - src/test/resources - - **/*.properties - **/*.xml - - true - - - src/test/resources - - **/*.properties - **/*.xml - - false - - - - - diff --git a/api-tests-2.4/.gitignore b/api-tests-2.4/.gitignore deleted file mode 100644 index ea8c4bf7f3..0000000000 --- a/api-tests-2.4/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/api-tests-2.4/pom.xml b/api-tests-2.4/pom.xml deleted file mode 100644 index c6f594f099..0000000000 --- a/api-tests-2.4/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - 4.0.0 - - - org.openmrs.module - reporting - 1.28.0-SNAPSHOT - - - reporting-api-tests-2.4 - jar - reporting API Tests for 2.4+ - API tests for reporting - - - - org.openmrs.module - reporting-api - ${project.parent.version} - - - org.openmrs.module - reporting-api - ${project.parent.version} - tests - - - javassist - javassist - - - - - org.openmrs.module - ${reportingApiConditionalArtifactId} - ${project.parent.version} - - - org.openmrs.module - reporting-api-tests - ${project.parent.version} - test-jar - test - - - - org.openmrs.api - openmrs-api - ${openMRSVersion} - - - javassist - javassist - - - - - org.openmrs.api - openmrs-api - ${openMRSVersion} - tests - - - javassist - javassist - - - - - org.openmrs.test - openmrs-test - ${openMRSVersion} - pom - - - javassist - javassist - - - - - org.openmrs.web - openmrs-web - ${openMRSVersion} - - - - - - - src/main/resources - true - - - - - src/test/resources - true - - **/*.xml - **/*.txt - **/*.properties - - - - src/test/resources - false - - **/*.xml - **/*.txt - **/*.properties - - - - - - - ${project.parent.artifactId} - ${project.parent.name} - ${project.parent.version} - ${project.parent.groupId}.${project.parent.artifactId} - - - diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/calculation/PatientDataCalculationBehaviorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/calculation/PatientDataCalculationBehaviorTest.java index 5cbe226399..341cffdf90 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/calculation/PatientDataCalculationBehaviorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/calculation/PatientDataCalculationBehaviorTest.java @@ -12,6 +12,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -47,8 +48,8 @@ public void setup() throws Exception { public void evaluate_shouldEvaluateAPatientCalculation() throws Exception { Integer patientId1 = 2; Integer patientId2 = 7; - Set identifiers1 = ps.getPatient(patientId1).getIdentifiers(); - Set identifiers2 = ps.getPatient(patientId2).getIdentifiers(); + Set identifiers1 = new HashSet<>(ps.getPatient(patientId1).getIdentifiers()); + Set identifiers2 = new HashSet<>(ps.getPatient(patientId2).getIdentifiers()); PatientDataCalculation calculation = new PatientDataCalculationProvider().getCalculation( "org.openmrs.module.reporting.data.patient.definition.PatientIdentifierDataDefinition", null); Map parameters = new HashMap(); diff --git a/api-2.2/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluatorTest.java similarity index 100% rename from api-2.2/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluatorTest.java rename to api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluatorTest.java diff --git a/api-1.10/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluatorTest.java similarity index 100% rename from api-1.10/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluatorTest.java rename to api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluatorTest.java index ec30196cdf..d0510ce9bc 100644 --- a/api-1.10/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluatorTest.java @@ -10,26 +10,26 @@ package org.openmrs.module.reporting.cohort.definition.evaluator; -import java.util.ArrayList; -import java.util.List; -import java.util.Date; +import org.apache.commons.lang3.time.DateUtils; import org.junit.After; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.openmrs.CareSetting; import org.openmrs.Cohort; import org.openmrs.Concept; -import org.openmrs.CareSetting; import org.openmrs.Drug; import org.openmrs.api.OrderService; import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.common.Match; import org.openmrs.module.reporting.cohort.definition.DrugOrderCohortDefinition; import org.openmrs.module.reporting.cohort.definition.service.CohortDefinitionService; import org.openmrs.module.reporting.common.DateUtil; +import org.openmrs.module.reporting.common.Match; import org.openmrs.test.BaseModuleContextSensitiveTest; -import org.apache.commons.lang3.time.DateUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; public class DrugOrderCohortDefinitionEvaluatorTest extends BaseModuleContextSensitiveTest { diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibraryTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibraryTest.java index 641aa69a77..31aecdbec4 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibraryTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibraryTest.java @@ -11,10 +11,12 @@ import org.junit.Before; import org.junit.Test; +import org.openmrs.Concept; import org.openmrs.EncounterType; import org.openmrs.module.reporting.cohort.definition.AgeCohortDefinition; import org.openmrs.module.reporting.cohort.definition.BirthAndDeathCohortDefinition; import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.ConditionCohortDefinition; import org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition; import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition; import org.openmrs.module.reporting.cohort.definition.MappedParametersCohortDefinition; @@ -143,4 +145,19 @@ public void testGetDiedDuringPeriod() throws Exception { assertThat(cd, hasParameter("startDate", Date.class)); assertThat(cd, hasParameter("endDate", Date.class)); } + + @Test + public void testGetConditonSearchAdavanced() throws Exception { + CohortDefinition cd = library.getConditonSearchAdvanced(); + assertTrue(ConditionCohortDefinition.class.isAssignableFrom(cd.getClass())); + assertThat(cd, hasParameter("onsetDateOnOrBefore", Date.class)); + assertThat(cd, hasParameter("onsetDateOnOrAfter", Date.class)); + assertThat(cd, hasParameter("endDateOnOrBefore", Date.class)); + assertThat(cd, hasParameter("endDateOnOrAfter", Date.class)); + assertThat(cd, hasParameter("createdOnOrBefore", Date.class)); + assertThat(cd, hasParameter("createdOnOrAfter", Date.class)); + assertThat(cd, hasParameter("activeOnDate", Date.class)); + assertThat(cd, hasParameter("conditionNonCoded", String.class)); + assertThat(cd, hasParameter("conditionCoded", Concept.class)); + } } diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/OrderForVisitDataEvaluatorTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/OrderForVisitDataEvaluatorTest.java index a9cd62c794..674364710b 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/OrderForVisitDataEvaluatorTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/OrderForVisitDataEvaluatorTest.java @@ -10,6 +10,7 @@ package org.openmrs.module.reporting.data.visit.evaluator; import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.junit.Assert; @@ -34,6 +35,7 @@ import org.openmrs.module.reporting.query.visit.VisitIdSet; import org.openmrs.test.BaseContextSensitiveTest; import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.SkipBaseSetup; import org.openmrs.util.OpenmrsConstants; import org.springframework.beans.factory.annotation.Autowired; @@ -66,7 +68,6 @@ public class OrderForVisitDataEvaluatorTest extends BaseModuleContextSensitiveTe */ @Before public void setup() throws Exception { - if (ModuleUtil.compareVersion(OpenmrsConstants.OPENMRS_VERSION, "1.10") < 0) { setup1_9(); } else { @@ -117,6 +118,7 @@ private void setup1_10() throws Exception { */ @Test public void evaluate_shouldReturnAllOrdersForAVisit() throws Exception { + OrderType orderType = orderService.getOrderType(1); VisitEvaluationContext context = new VisitEvaluationContext(); context.setBaseVisits(new VisitIdSet(1)); @@ -140,7 +142,7 @@ public void evaluate_shouldFilterByType() throws Exception { OrderForVisitDataDefinition d = new OrderForVisitDataDefinition(); - d.setTypes(Arrays.asList(orderService.getOrderType(1))); + d.setTypes(Collections.singletonList(orderService.getOrderType(1))); EvaluatedVisitData vd = Context.getService(VisitDataService.class).evaluate(d, context); Assert.assertEquals(expectedOrdersWithType.intValue(), ((List) vd.getData().get(1)).size()); diff --git a/api-tests-2.4/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java b/api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java similarity index 100% rename from api-tests-2.4/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java rename to api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java diff --git a/api-2.2/src/test/resources/org/openmrs/module/reporting/include/ConditionCohortDefinitionEvaluatorTestDataSet.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ConditionCohortDefinitionEvaluatorTestDataSet.xml similarity index 100% rename from api-2.2/src/test/resources/org/openmrs/module/reporting/include/ConditionCohortDefinitionEvaluatorTestDataSet.xml rename to api-tests/src/test/resources/org/openmrs/module/reporting/include/ConditionCohortDefinitionEvaluatorTestDataSet.xml diff --git a/api-1.10/src/test/resources/org/openmrs/module/reporting/include/DrugOrderCohortEvaluationData.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/DrugOrderCohortEvaluationData.xml similarity index 96% rename from api-1.10/src/test/resources/org/openmrs/module/reporting/include/DrugOrderCohortEvaluationData.xml rename to api-tests/src/test/resources/org/openmrs/module/reporting/include/DrugOrderCohortEvaluationData.xml index 4bf9879a5f..a0da3b8819 100644 --- a/api-1.10/src/test/resources/org/openmrs/module/reporting/include/DrugOrderCohortEvaluationData.xml +++ b/api-tests/src/test/resources/org/openmrs/module/reporting/include/DrugOrderCohortEvaluationData.xml @@ -74,10 +74,10 @@ - + - - + + diff --git a/api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/ConditionCohortDefinition.java b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/ConditionCohortDefinition.java similarity index 97% rename from api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/ConditionCohortDefinition.java rename to api/src/main/java/org/openmrs/module/reporting/cohort/definition/ConditionCohortDefinition.java index 252ea4eba2..e2e4818b6e 100644 --- a/api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/ConditionCohortDefinition.java +++ b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/ConditionCohortDefinition.java @@ -10,15 +10,14 @@ */ package org.openmrs.module.reporting.cohort.definition; -import java.util.Date; - import org.openmrs.Concept; -import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; 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 java.util.Date; + @Caching(strategy = ConfigurationPropertyCachingStrategy.class) @Localized("reporting.ConditionCohortDefinition") public class ConditionCohortDefinition extends BaseCohortDefinition { diff --git a/api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/DrugOrderCohortDefinition.java b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/DrugOrderCohortDefinition.java similarity index 99% rename from api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/DrugOrderCohortDefinition.java rename to api/src/main/java/org/openmrs/module/reporting/cohort/definition/DrugOrderCohortDefinition.java index f73c89cc84..3f5427244b 100644 --- a/api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/DrugOrderCohortDefinition.java +++ b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/DrugOrderCohortDefinition.java @@ -10,12 +10,11 @@ package org.openmrs.module.reporting.cohort.definition; -import org.openmrs.Concept; import org.openmrs.CareSetting; +import org.openmrs.Concept; import org.openmrs.Drug; - -import org.openmrs.module.reporting.common.Match; import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.common.Match; import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty; import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; import org.openmrs.module.reporting.evaluation.caching.Caching; diff --git a/api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluator.java similarity index 96% rename from api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluator.java rename to api/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluator.java index 297132acd4..a9b13598e9 100644 --- a/api-2.2/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluator.java +++ b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/ConditionCohortDefinitionEvaluator.java @@ -9,20 +9,19 @@ */ package org.openmrs.module.reporting.cohort.definition.evaluator; -import java.util.List; - import org.openmrs.Cohort; import org.openmrs.Condition; import org.openmrs.annotation.Handler; import org.openmrs.module.reporting.cohort.EvaluatedCohort; import org.openmrs.module.reporting.cohort.definition.CohortDefinition; import org.openmrs.module.reporting.cohort.definition.ConditionCohortDefinition; -import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; import org.openmrs.module.reporting.evaluation.EvaluationContext; import org.openmrs.module.reporting.evaluation.querybuilder.HqlQueryBuilder; import org.openmrs.module.reporting.evaluation.service.EvaluationService; import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; + @Handler(supports = { ConditionCohortDefinition.class }) public class ConditionCohortDefinitionEvaluator implements CohortDefinitionEvaluator { diff --git a/api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluator.java similarity index 98% rename from api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluator.java rename to api/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluator.java index 58b7a19fc8..f6ac3c19f6 100644 --- a/api-1.10/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluator.java +++ b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/evaluator/DrugOrderCohortDefinitionEvaluator.java @@ -10,22 +10,20 @@ package org.openmrs.module.reporting.cohort.definition.evaluator; -import org.apache.commons.lang3.time.DateUtils; import org.openmrs.Cohort; import org.openmrs.DrugOrder; +import org.openmrs.annotation.Handler; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.DrugOrderCohortDefinition; +import org.openmrs.module.reporting.common.Match; +import org.openmrs.module.reporting.common.ObjectUtil; import org.openmrs.module.reporting.evaluation.EvaluationContext; import org.openmrs.module.reporting.evaluation.querybuilder.HqlQueryBuilder; import org.openmrs.module.reporting.evaluation.service.EvaluationService; -import org.openmrs.module.reporting.cohort.EvaluatedCohort; -import org.openmrs.module.reporting.cohort.definition.DrugOrderCohortDefinition; -import org.openmrs.module.reporting.common.ObjectUtil; -import org.openmrs.module.reporting.common.Match; -import org.openmrs.annotation.Handler; - import org.springframework.beans.factory.annotation.Autowired; + import java.util.List; -import java.util.Date; @Handler(supports = { DrugOrderCohortDefinition.class }) public class DrugOrderCohortDefinitionEvaluator implements CohortDefinitionEvaluator { diff --git a/api/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary.java b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary.java index 248830b7e9..fc0eb2791c 100644 --- a/api/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary.java +++ b/api/src/main/java/org/openmrs/module/reporting/cohort/definition/library/BuiltInCohortDefinitionLibrary.java @@ -19,6 +19,7 @@ import org.openmrs.module.reporting.cohort.definition.AgeCohortDefinition; import org.openmrs.module.reporting.cohort.definition.BirthAndDeathCohortDefinition; import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.ConditionCohortDefinition; import org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition; import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition; import org.openmrs.module.reporting.cohort.definition.InProgramCohortDefinition; @@ -272,4 +273,19 @@ public CohortDefinition getPatientsInState() { cd.addParameter(new Parameter("onDate", "reporting.parameter.date", Date.class)); return cd; } + + @DocumentedDefinition("conditonSearchAdvanced") + public CohortDefinition getConditonSearchAdvanced() { + ConditionCohortDefinition cd = new ConditionCohortDefinition(); + cd.addParameter(new Parameter("conditionCoded", "reporting.parameter.conditionCoded", Concept.class)); + cd.addParameter(new Parameter("conditionNonCoded", "reporting.parameter.conditionNonCoded", String.class)); + cd.addParameter(new Parameter("onsetDateOnOrBefore", "reporting.parameter.onsetDateOnOrBefore", Date.class)); + cd.addParameter(new Parameter("onsetDateOnOrAfter", "reporting.parameter.onsetDateOnOrAfter", Date.class)); + cd.addParameter(new Parameter("endDateOnOrBefore", "reporting.parameter.endDateOnOrBefore", Date.class)); + cd.addParameter(new Parameter("endDateOnOrAfter", "reporting.parameter.endDateOnOrAfter", Date.class)); + cd.addParameter(new Parameter("createdOnOrBefore", "reporting.parameter.createdOnOrBefore", Date.class)); + cd.addParameter(new Parameter("createdOnOrAfter", "reporting.parameter.createdOnOrAfter", Date.class)); + cd.addParameter(new Parameter("activeOnDate", "reporting.parameter.activeOnDate", Date.class)); + return cd; + } } diff --git a/api-1.9/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java similarity index 100% rename from api-1.9/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java rename to api/src/main/java/org/openmrs/module/reporting/dataset/definition/DataExportDataSetDefinition.java diff --git a/api-1.9/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 similarity index 81% rename from api-1.9/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/DataExportDataSetEvaluator.java rename to api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/DataExportDataSetEvaluator.java index 460ba2cf56..c7b1ab0237 100644 --- a/api-1.9/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 @@ -9,10 +9,6 @@ */ package org.openmrs.module.reporting.dataset.definition.evaluator; -import java.io.File; -import java.util.HashMap; -import java.util.Map; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.annotation.Handler; @@ -28,6 +24,10 @@ 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 @@ -55,7 +55,7 @@ public DataSet evaluate(DataSetDefinition definition, EvaluationContext context) try { DataExportDataSetDefinition dataExportDefinition = (DataExportDataSetDefinition) definition; DataExportReportObject dataExport = dataExportDefinition.getDataExport(); - DataExportUtil.generateExport(dataExport, context.getBaseCohort(), null); + DataExportUtil.generateExport(dataExport, convertCohort(context.getBaseCohort()), null); File dataFile = DataExportUtil.getGeneratedFile(dataExportDefinition.getDataExport()); @@ -89,4 +89,24 @@ public DataSet evaluate(DataSetDefinition definition, EvaluationContext context) } return dataSet; } + + private org.openmrs.cohort.Cohort convertCohort(org.openmrs.Cohort cohort) { + org.openmrs.cohort.Cohort c = new org.openmrs.cohort.Cohort(); + c.setCohortId(cohort.getId()); + c.setName(cohort.getName()); + c.setDescription(cohort.getDescription()); + c.setMemberIds(cohort.getMemberIds()); + + c.setUuid(cohort.getUuid()); + c.setCreator(cohort.getCreator()); + c.setDateCreated(cohort.getDateCreated()); + c.setChangedBy(cohort.getChangedBy()); + c.setDateChanged(cohort.getDateChanged()); + c.setVoided(cohort.getVoided()); + c.setVoidedBy(cohort.getVoidedBy()); + c.setDateVoided(cohort.getDateVoided()); + c.setVoidReason(cohort.getVoidReason()); + + return c; + } } diff --git a/api-1.9/src/main/java/org/openmrs/module/reporting/dataset/definition/persister/DataExportDataSetDefinitionPersister.java b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/persister/DataExportDataSetDefinitionPersister.java similarity index 100% rename from api-1.9/src/main/java/org/openmrs/module/reporting/dataset/definition/persister/DataExportDataSetDefinitionPersister.java rename to api/src/main/java/org/openmrs/module/reporting/dataset/definition/persister/DataExportDataSetDefinitionPersister.java diff --git a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java b/api/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java similarity index 94% rename from api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java rename to api/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java index b6d3744c8c..be83b0e291 100644 --- a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/db/MappedDefinitionType.java @@ -1,209 +1,209 @@ -/** - * 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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.commons.lang.StringUtils; -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.Type; -import org.hibernate.usertype.CompositeUserType; -import org.hibernate.usertype.ParameterizedType; -import org.hibernate.usertype.UserType; -import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.common.HibernateUtil; -import org.openmrs.module.reporting.definition.DefinitionContext; -import org.openmrs.module.reporting.evaluation.Definition; -import org.openmrs.module.reporting.evaluation.parameter.Mapped; -import org.openmrs.module.reporting.evaluation.parameter.Parameterizable; -import org.openmrs.module.reporting.serializer.ReportingSerializer; - -/** - * Custom User-Type for storing Mapped objects in a single table within 2 columns - * This type takes in 2 properties and 1 parameter in the form: - *
- *		
- *			
- *			
- *			
- *				org.openmrs.module.reporting.report.definition.ReportDefinition
- *			
- *		
- * 
- */ -@SuppressWarnings({"rawtypes", "unchecked"}) -public class MappedDefinitionType implements CompositeUserType, ParameterizedType { - - /** - * Property via ParameterizedType for storing the type of the Mapped Parameterizable - */ - private Class mappedType; - - /** - * @see CompositeUserType#returnedClass() - */ - public Class returnedClass() { - return Mapped.class; - } - - /** - * @see CompositeUserType#getPropertyNames() - */ - public String[] getPropertyNames() { - return new String[] {"definition", "parameterMappings"}; - } - - /** - * @see CompositeUserType#getPropertyTypes() - */ - public Type[] getPropertyTypes() { - return new Type[] { HibernateUtil.standardType("STRING"), HibernateUtil.standardType("TEXT") }; - } - - /** - * @see CompositeUserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see CompositeUserType#getPropertyValue(java.lang.Object, int) - */ - public Object getPropertyValue(Object component, int property) throws HibernateException { - Mapped m = (Mapped) component; - return (property == 0 ? m.getParameterizable() : m.getParameterMappings()); - } - - /** - * @see CompositeUserType#setPropertyValue(java.lang.Object, int, java.lang.Object) - */ - public void setPropertyValue(Object component, int property, Object value) throws HibernateException { - Mapped m = (Mapped) component; - if (property == 0) { - m.setParameterizable((Parameterizable)value); - } - else { - m.setParameterMappings((Map)value); - } - } - - /** - * @see CompositeUserType#deepCopy(java.lang.Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value == null) return null; - Mapped toCopy = (Mapped) value; - Mapped m = new Mapped(); - m.setParameterizable(toCopy.getParameterizable()); - m.setParameterMappings(new HashMap(toCopy.getParameterMappings())); - return m; - } - - /** - * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { - String parameterizableUuid = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[0], session, owner); - if (StringUtils.isEmpty(parameterizableUuid)) { return null; } - String serializedMappings = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); - Definition d = DefinitionContext.getDefinitionByUuid(mappedType, parameterizableUuid); - Map mappings = new HashMap(); - if (StringUtils.isNotBlank(serializedMappings)) { - try { - mappings = Context.getSerializationService().deserialize(serializedMappings, Map.class, ReportingSerializer.class); - } - catch (Exception e) { - throw new HibernateException("Unable to deserialize parameter mappings for definition", e); - } - } - return new Mapped(d, mappings); - } - - /** - * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - String definitionUuid = null; - String serializedMappings = null; - if (value != null) { - Mapped m = (Mapped) value; - if (m.getParameterizable() != null) { - definitionUuid = m.getParameterizable().getUuid(); - if (m.getParameterMappings() != null && !m.getParameterMappings().isEmpty()) { - try { - serializedMappings = Context.getSerializationService().serialize(m.getParameterMappings(), ReportingSerializer.class); - } - catch (Exception e) { - throw new HibernateException("Unable to serialize mappings for definition", e); - } - } - } - } - HibernateUtil.standardType("STRING").nullSafeSet(st, definitionUuid, index, session); - HibernateUtil.standardType("STRING").nullSafeSet(st, serializedMappings, index+1, session); - } - - /** - * @see CompositeUserType#replace(Object, Object, SessionImplementor, Object) - */ - public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see CompositeUserType#disassemble(Object, SessionImplementor) - */ - public Serializable disassemble(Object value, SharedSessionContractImplementor session) throws HibernateException { - return (Serializable) deepCopy(value); - } - - /** - * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) - */ - public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException { - return deepCopy(cached); - } - - /** - * @see ParameterizedType#setParameterValues(Properties) - */ - public void setParameterValues(Properties parameters) { - String mappedTypeStr = parameters.getProperty("mappedType"); - try { - mappedType = (Class)Context.loadClass(mappedTypeStr); - } - catch (Exception e) { - throw new HibernateException("Error setting the mappedType property to " + mappedTypeStr, e); - } - } +/** + * 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.report.service.db; + +import org.apache.commons.lang.StringUtils; +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.type.Type; +import org.hibernate.usertype.CompositeUserType; +import org.hibernate.usertype.ParameterizedType; +import org.hibernate.usertype.UserType; +import org.openmrs.api.context.Context; +import org.openmrs.module.reporting.common.HibernateUtil; +import org.openmrs.module.reporting.definition.DefinitionContext; +import org.openmrs.module.reporting.evaluation.Definition; +import org.openmrs.module.reporting.evaluation.parameter.Mapped; +import org.openmrs.module.reporting.evaluation.parameter.Parameterizable; +import org.openmrs.module.reporting.serializer.ReportingSerializer; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * Custom User-Type for storing Mapped objects in a single table within 2 columns + * This type takes in 2 properties and 1 parameter in the form: + *
+ *		
+ *			
+ *			
+ *			
+ *				org.openmrs.module.reporting.report.definition.ReportDefinition
+ *			
+ *		
+ * 
+ */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class MappedDefinitionType implements CompositeUserType, ParameterizedType { + + /** + * Property via ParameterizedType for storing the type of the Mapped Parameterizable + */ + private Class mappedType; + + /** + * @see CompositeUserType#returnedClass() + */ + public Class returnedClass() { + return Mapped.class; + } + + /** + * @see CompositeUserType#getPropertyNames() + */ + public String[] getPropertyNames() { + return new String[] {"definition", "parameterMappings"}; + } + + /** + * @see CompositeUserType#getPropertyTypes() + */ + public Type[] getPropertyTypes() { + return new Type[] { HibernateUtil.standardType("STRING"), HibernateUtil.standardType("TEXT") }; + } + + /** + * @see CompositeUserType#isMutable() + */ + public boolean isMutable() { + return true; + } + + /** + * @see CompositeUserType#getPropertyValue(Object, int) + */ + public Object getPropertyValue(Object component, int property) throws HibernateException { + Mapped m = (Mapped) component; + return (property == 0 ? m.getParameterizable() : m.getParameterMappings()); + } + + /** + * @see CompositeUserType#setPropertyValue(Object, int, Object) + */ + public void setPropertyValue(Object component, int property, Object value) throws HibernateException { + Mapped m = (Mapped) component; + if (property == 0) { + m.setParameterizable((Parameterizable)value); + } + else { + m.setParameterMappings((Map)value); + } + } + + /** + * @see CompositeUserType#deepCopy(Object) + */ + public Object deepCopy(Object value) throws HibernateException { + if (value == null) return null; + Mapped toCopy = (Mapped) value; + Mapped m = new Mapped(); + m.setParameterizable(toCopy.getParameterizable()); + m.setParameterMappings(new HashMap(toCopy.getParameterMappings())); + return m; + } + + /** + * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) + */ + public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { + String parameterizableUuid = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[0], session, owner); + if (StringUtils.isEmpty(parameterizableUuid)) { return null; } + String serializedMappings = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); + Definition d = DefinitionContext.getDefinitionByUuid(mappedType, parameterizableUuid); + Map mappings = new HashMap(); + if (StringUtils.isNotBlank(serializedMappings)) { + try { + mappings = Context.getSerializationService().deserialize(serializedMappings, Map.class, ReportingSerializer.class); + } + catch (Exception e) { + throw new HibernateException("Unable to deserialize parameter mappings for definition", e); + } + } + return new Mapped(d, mappings); + } + + /** + * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) + */ + public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { + String definitionUuid = null; + String serializedMappings = null; + if (value != null) { + Mapped m = (Mapped) value; + if (m.getParameterizable() != null) { + definitionUuid = m.getParameterizable().getUuid(); + if (m.getParameterMappings() != null && !m.getParameterMappings().isEmpty()) { + try { + serializedMappings = Context.getSerializationService().serialize(m.getParameterMappings(), ReportingSerializer.class); + } + catch (Exception e) { + throw new HibernateException("Unable to serialize mappings for definition", e); + } + } + } + } + HibernateUtil.standardType("STRING").nullSafeSet(st, definitionUuid, index, session); + HibernateUtil.standardType("STRING").nullSafeSet(st, serializedMappings, index+1, session); + } + + /** + * @see CompositeUserType#replace(Object, Object, SessionImplementor, Object) + */ + public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner) throws HibernateException { + return original; + } + + /** + * @see UserType#equals(Object, Object) + */ + public boolean equals(Object x, Object y) throws HibernateException { + return x != null && x.equals(y); + } + + /** + * @see UserType#hashCode(Object) + */ + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + /** + * @see CompositeUserType#disassemble(Object, SessionImplementor) + */ + public Serializable disassemble(Object value, SharedSessionContractImplementor session) throws HibernateException { + return (Serializable) deepCopy(value); + } + + /** + * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) + */ + public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException { + return deepCopy(cached); + } + + /** + * @see ParameterizedType#setParameterValues(Properties) + */ + public void setParameterValues(Properties parameters) { + String mappedTypeStr = parameters.getProperty("mappedType"); + try { + mappedType = (Class)Context.loadClass(mappedTypeStr); + } + catch (Exception e) { + throw new HibernateException("Error setting the mappedType property to " + mappedTypeStr, e); + } + } } \ No newline at end of file diff --git a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java b/api/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java similarity index 95% rename from api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java rename to api/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java index a39f3f5c2b..55faf26a12 100644 --- a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/db/PropertiesType.java @@ -1,144 +1,143 @@ -/** - * 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.report.service.db; - -import static java.sql.Types.VARCHAR; - -import java.io.IOException; -import java.io.Serializable; -import java.io.StringReader; -import java.io.StringWriter; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map; -import java.util.Properties; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.usertype.UserType; - -/** - * A report definition type - */ -public class PropertiesType implements UserType { - - /** - * @see UserType#assemble(Serializable, Object) - */ - public Object assemble(Serializable cached, Object owner) throws HibernateException { - if (cached == null) { - return null; - } - try { - String s = (String) cached; - Properties p = new Properties(); - p.load(new StringReader(s)); - return p; - } - catch (IOException e) { - throw new IllegalArgumentException("Unable to load properties from string", e); - } - } - - /** - * @see UserType#deepCopy(Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value != null) { - Properties val = (Properties) value; - Properties copy = new Properties(); - for ( Map.Entry e : val.entrySet() ) { - copy.setProperty((String) e.getKey(), (String) e.getValue()); - } - return copy; - } else { - return null; - } - } - - /** - * @see UserType#disassemble(Object) - */ - public Serializable disassemble(Object value) throws HibernateException { - if (value == null) { - return null; - } - try { - Properties props = (Properties) value; - StringWriter sw = new StringWriter(); - props.store(sw, null); - return sw.toString(); - } - catch (IOException e) { - throw new IllegalArgumentException("Unable to store properties as string", e); - } - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see UserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see UserType#nullSafeGet(ResultSet, String[], Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { - String s = rs.getString(names[0]); - return assemble(s, null); - } - - /** - * @see UserType#nullSafeSet(PreparedStatement, Object, int) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - String val = (String) disassemble(value); - st.setString(index, val); - } - - /** - * @see UserType#replace(Object, Object, Object) - */ - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#returnedClass() - */ - @SuppressWarnings("unchecked") - public Class returnedClass() { - return Properties.class; - } - - /** - * @see UserType#sqlTypes() - */ - public int[] sqlTypes() { - return new int[] { VARCHAR }; - } -} +/** + * 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.report.service.db; + +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.usertype.UserType; + +import java.io.IOException; +import java.io.Serializable; +import java.io.StringReader; +import java.io.StringWriter; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Map; +import java.util.Properties; + +import static java.sql.Types.VARCHAR; + +/** + * A report definition type + */ +public class PropertiesType implements UserType { + + /** + * @see UserType#assemble(Serializable, Object) + */ + public Object assemble(Serializable cached, Object owner) throws HibernateException { + if (cached == null) { + return null; + } + try { + String s = (String) cached; + Properties p = new Properties(); + p.load(new StringReader(s)); + return p; + } + catch (IOException e) { + throw new IllegalArgumentException("Unable to load properties from string", e); + } + } + + /** + * @see UserType#deepCopy(Object) + */ + public Object deepCopy(Object value) throws HibernateException { + if (value != null) { + Properties val = (Properties) value; + Properties copy = new Properties(); + for ( Map.Entry e : val.entrySet() ) { + copy.setProperty((String) e.getKey(), (String) e.getValue()); + } + return copy; + } else { + return null; + } + } + + /** + * @see UserType#disassemble(Object) + */ + public Serializable disassemble(Object value) throws HibernateException { + if (value == null) { + return null; + } + try { + Properties props = (Properties) value; + StringWriter sw = new StringWriter(); + props.store(sw, null); + return sw.toString(); + } + catch (IOException e) { + throw new IllegalArgumentException("Unable to store properties as string", e); + } + } + + /** + * @see UserType#equals(Object, Object) + */ + public boolean equals(Object x, Object y) throws HibernateException { + return x != null && x.equals(y); + } + + /** + * @see UserType#hashCode(Object) + */ + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + /** + * @see UserType#isMutable() + */ + public boolean isMutable() { + return true; + } + + /** + * @see UserType#nullSafeGet(ResultSet, String[], Object) + */ + public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { + String s = rs.getString(names[0]); + return assemble(s, null); + } + + /** + * @see UserType#nullSafeSet(PreparedStatement, Object, int) + */ + public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { + String val = (String) disassemble(value); + st.setString(index, val); + } + + /** + * @see UserType#replace(Object, Object, Object) + */ + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } + + /** + * @see UserType#returnedClass() + */ + @SuppressWarnings("unchecked") + public Class returnedClass() { + return Properties.class; + } + + /** + * @see UserType#sqlTypes() + */ + public int[] sqlTypes() { + return new int[] { VARCHAR }; + } +} diff --git a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java b/api/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java similarity index 91% rename from api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java rename to api/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java index 008ab123f9..bfce0700c1 100644 --- a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/db/RenderingModeType.java @@ -1,167 +1,167 @@ -/** - * 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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.Type; -import org.hibernate.usertype.CompositeUserType; -import org.hibernate.usertype.UserType; -import org.openmrs.module.reporting.common.HibernateUtil; -import org.openmrs.module.reporting.report.renderer.RenderingMode; -import org.openmrs.module.reporting.report.renderer.ReportRenderer; - -/** - * Custom User-Type for storing RenderingModes in a single table within 2 columns - * This type takes in 2 properties in the form: - *
- *   
- *     
- *     
- *   
- * 
- */ -@SuppressWarnings({"rawtypes"}) -public class RenderingModeType implements CompositeUserType { - - /** - * @see CompositeUserType#returnedClass() - */ - public Class returnedClass() { - return RenderingMode.class; - } - - /** - * @see CompositeUserType#getPropertyNames() - */ - public String[] getPropertyNames() { - return new String[] {"renderer", "argument"}; - } - - /** - * @see CompositeUserType#getPropertyTypes() - */ - public Type[] getPropertyTypes() { - return new Type[] { HibernateUtil.standardType("CLASS"), HibernateUtil.standardType("STRING") }; - } - - /** - * @see CompositeUserType#isMutable() - */ - public boolean isMutable() { - return true; - } - - /** - * @see CompositeUserType#getPropertyValue(java.lang.Object, int) - */ - public Object getPropertyValue(Object component, int property) throws HibernateException { - RenderingMode m = (RenderingMode) component; - return (property == 0 ? m.getRenderer().getClass() : m.getArgument()); - } - - /** - * @see CompositeUserType#setPropertyValue(java.lang.Object, int, java.lang.Object) - */ - public void setPropertyValue(Object component, int property, Object value) throws HibernateException { - RenderingMode m = (RenderingMode) component; - if (property == 0) { - ReportRenderer r = null; - if (value != null) { - try { - r = (ReportRenderer)((Class) value).newInstance(); - } - catch (Exception e) { - throw new HibernateException("Error instantiating a new reporting renderer from " + value, e); - } - } - m.setRenderer(r); - } - else { - m.setArgument((String)value); - } - } - - /** - * @see CompositeUserType#deepCopy(java.lang.Object) - */ - public Object deepCopy(Object value) throws HibernateException { - if (value == null) return null; - RenderingMode toCopy = (RenderingMode) value; - return new RenderingMode(toCopy.getRenderer(), toCopy.getLabel(), toCopy.getArgument(), toCopy.getSortWeight()); - } - - /** - * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { - Class rendererClass = (Class) HibernateUtil.standardType("CLASS").nullSafeGet(rs, names[0], session, owner); - if (rendererClass == null) { return null; } - String argument = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); - ReportRenderer r = null; - try { - r = (ReportRenderer)((Class) rendererClass).newInstance(); - } - catch (Exception e) { - throw new HibernateException("Error instantiating a new reporting renderer from " + rendererClass, e); - } - return new RenderingMode(r, r.getClass().getSimpleName(), argument, null); - } - - /** - * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - RenderingMode mode = (RenderingMode) value; - HibernateUtil.standardType("CLASS").nullSafeSet(st, mode == null ? null : mode.getRenderer().getClass(), index, session); - HibernateUtil.standardType("STRING").nullSafeSet(st, mode == null ? null : mode.getArgument(), index+1, session); - } - - /** - * @see CompositeUserType#replace(java.lang.Object, java.lang.Object, org.hibernate.engine.SessionImplementor, java.lang.Object) - */ - public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see CompositeUserType#disassemble(Object, SessionImplementor) - */ - public Serializable disassemble(Object value, SharedSessionContractImplementor session) throws HibernateException { - return (Serializable) deepCopy(value); - } - - /** - * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) - */ - public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException { - return deepCopy(cached); - } +/** + * 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.report.service.db; + +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.type.Type; +import org.hibernate.usertype.CompositeUserType; +import org.hibernate.usertype.UserType; +import org.openmrs.module.reporting.common.HibernateUtil; +import org.openmrs.module.reporting.report.renderer.RenderingMode; +import org.openmrs.module.reporting.report.renderer.ReportRenderer; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Custom User-Type for storing RenderingModes in a single table within 2 columns + * This type takes in 2 properties in the form: + *
+ *   
+ *     
+ *     
+ *   
+ * 
+ */ +@SuppressWarnings({"rawtypes"}) +public class RenderingModeType implements CompositeUserType { + + /** + * @see CompositeUserType#returnedClass() + */ + public Class returnedClass() { + return RenderingMode.class; + } + + /** + * @see CompositeUserType#getPropertyNames() + */ + public String[] getPropertyNames() { + return new String[] {"renderer", "argument"}; + } + + /** + * @see CompositeUserType#getPropertyTypes() + */ + public Type[] getPropertyTypes() { + return new Type[] { HibernateUtil.standardType("CLASS"), HibernateUtil.standardType("STRING") }; + } + + /** + * @see CompositeUserType#isMutable() + */ + public boolean isMutable() { + return true; + } + + /** + * @see CompositeUserType#getPropertyValue(Object, int) + */ + public Object getPropertyValue(Object component, int property) throws HibernateException { + RenderingMode m = (RenderingMode) component; + return (property == 0 ? m.getRenderer().getClass() : m.getArgument()); + } + + /** + * @see CompositeUserType#setPropertyValue(Object, int, Object) + */ + public void setPropertyValue(Object component, int property, Object value) throws HibernateException { + RenderingMode m = (RenderingMode) component; + if (property == 0) { + ReportRenderer r = null; + if (value != null) { + try { + r = (ReportRenderer)((Class) value).newInstance(); + } + catch (Exception e) { + throw new HibernateException("Error instantiating a new reporting renderer from " + value, e); + } + } + m.setRenderer(r); + } + else { + m.setArgument((String)value); + } + } + + /** + * @see CompositeUserType#deepCopy(Object) + */ + public Object deepCopy(Object value) throws HibernateException { + if (value == null) return null; + RenderingMode toCopy = (RenderingMode) value; + return new RenderingMode(toCopy.getRenderer(), toCopy.getLabel(), toCopy.getArgument(), toCopy.getSortWeight()); + } + + /** + * @see CompositeUserType#nullSafeGet(ResultSet, String[], SessionImplementor, Object) + */ + public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { + Class rendererClass = (Class) HibernateUtil.standardType("CLASS").nullSafeGet(rs, names[0], session, owner); + if (rendererClass == null) { return null; } + String argument = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); + ReportRenderer r = null; + try { + r = (ReportRenderer)((Class) rendererClass).newInstance(); + } + catch (Exception e) { + throw new HibernateException("Error instantiating a new reporting renderer from " + rendererClass, e); + } + return new RenderingMode(r, r.getClass().getSimpleName(), argument, null); + } + + /** + * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) + */ + public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { + RenderingMode mode = (RenderingMode) value; + HibernateUtil.standardType("CLASS").nullSafeSet(st, mode == null ? null : mode.getRenderer().getClass(), index, session); + HibernateUtil.standardType("STRING").nullSafeSet(st, mode == null ? null : mode.getArgument(), index+1, session); + } + + /** + * @see CompositeUserType#replace(Object, Object, org.hibernate.engine.SessionImplementor, Object) + */ + public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner) throws HibernateException { + return original; + } + + /** + * @see UserType#equals(Object, Object) + */ + public boolean equals(Object x, Object y) throws HibernateException { + return x != null && x.equals(y); + } + + /** + * @see UserType#hashCode(Object) + */ + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + /** + * @see CompositeUserType#disassemble(Object, SessionImplementor) + */ + public Serializable disassemble(Object value, SharedSessionContractImplementor session) throws HibernateException { + return (Serializable) deepCopy(value); + } + + /** + * @see CompositeUserType#assemble(Serializable, SessionImplementor, Object) + */ + public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException { + return deepCopy(cached); + } } \ No newline at end of file diff --git a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java b/api/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java similarity index 96% rename from api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java rename to api/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java index 5f2a1be77f..4caeb1dca3 100644 --- a/api-2.4/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDefinitionType.java @@ -1,120 +1,120 @@ -/** - * 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.report.service.db; - -import java.io.Serializable; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.usertype.UserType; -import org.openmrs.api.context.Context; -import org.openmrs.module.reporting.report.definition.ReportDefinition; -import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; - -/** - * A report definition type - */ -public class ReportDefinitionType implements UserType { - - /** - * @see UserType#assemble(Serializable, Object) - */ - public Object assemble(Serializable cached, Object owner) throws HibernateException { - if(cached == null){ - return null; - } - return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(cached.toString()); - } - - /** - * @see UserType#deepCopy(Object) - */ - public Object deepCopy(Object value) throws HibernateException { - return value; - } - - /** - * @see UserType#disassemble(Object) - */ - public Serializable disassemble(Object value) throws HibernateException { - if (value == null) { - return null; - } - return ((ReportDefinition)value).getUuid(); - } - - /** - * @see UserType#equals(Object, Object) - */ - public boolean equals(Object x, Object y) throws HibernateException { - return x != null && x.equals(y); - } - - /** - * @see UserType#hashCode(Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** - * @see UserType#isMutable() - */ - public boolean isMutable() { - return false; - } - - /** - * @see UserType#nullSafeGet(ResultSet, String[], Object) - */ - public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { - String uuid = rs.getString(names[0]); - if (uuid == null) { - return null; - } - return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(uuid); - } - - /** - * @see UserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) - */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - ReportDefinition d = (ReportDefinition) value; - String val = (d == null ? null : d.getUuid()); - st.setString(index, val); - } - - /** - * @see UserType#replace(Object, Object, Object) - */ - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } - - /** - * @see UserType#returnedClass() - */ - @SuppressWarnings("rawtypes") - public Class returnedClass() { - return ReportDefinition.class; - } - - /** - * @see UserType#sqlTypes() - */ - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; - } -} +/** + * 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.report.service.db; + +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.usertype.UserType; +import org.openmrs.api.context.Context; +import org.openmrs.module.reporting.report.definition.ReportDefinition; +import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; + +/** + * A report definition type + */ +public class ReportDefinitionType implements UserType { + + /** + * @see UserType#assemble(Serializable, Object) + */ + public Object assemble(Serializable cached, Object owner) throws HibernateException { + if(cached == null){ + return null; + } + return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(cached.toString()); + } + + /** + * @see UserType#deepCopy(Object) + */ + public Object deepCopy(Object value) throws HibernateException { + return value; + } + + /** + * @see UserType#disassemble(Object) + */ + public Serializable disassemble(Object value) throws HibernateException { + if (value == null) { + return null; + } + return ((ReportDefinition)value).getUuid(); + } + + /** + * @see UserType#equals(Object, Object) + */ + public boolean equals(Object x, Object y) throws HibernateException { + return x != null && x.equals(y); + } + + /** + * @see UserType#hashCode(Object) + */ + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + /** + * @see UserType#isMutable() + */ + public boolean isMutable() { + return false; + } + + /** + * @see UserType#nullSafeGet(ResultSet, String[], Object) + */ + public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { + String uuid = rs.getString(names[0]); + if (uuid == null) { + return null; + } + return Context.getService(ReportDefinitionService.class).getDefinitionByUuid(uuid); + } + + /** + * @see UserType#nullSafeSet(PreparedStatement, Object, int, SessionImplementor) + */ + public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { + ReportDefinition d = (ReportDefinition) value; + String val = (d == null ? null : d.getUuid()); + st.setString(index, val); + } + + /** + * @see UserType#replace(Object, Object, Object) + */ + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } + + /** + * @see UserType#returnedClass() + */ + @SuppressWarnings("rawtypes") + public Class returnedClass() { + return ReportDefinition.class; + } + + /** + * @see UserType#sqlTypes() + */ + public int[] sqlTypes() { + return new int[] { Types.VARCHAR }; + } +} diff --git a/pom.xml b/pom.xml index b45ff644e8..1a06fa1776 100644 --- a/pom.xml +++ b/pom.xml @@ -33,23 +33,17 @@ api - api-1.9 - api-1.10 - api-2.0 - api-2.2 - api-2.4 api-tests omod - 1.9.9 + 2.4.1 2.0.6 - 1.9 + 2.4 1.7.2 0.2.14 1.2 - 1.5.0 2.1.1 3.12 1.8.7 @@ -107,19 +101,6 @@ - - org.codehaus.jackson - jackson-core-asl - ${jacksonVersion} - provided - - - - org.codehaus.jackson - jackson-mapper-asl - ${jacksonVersion} - provided - org.codehaus.groovy @@ -469,8 +450,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.6 - 1.6 + 1.8 + 1.8 @@ -485,10 +466,10 @@ org.apache.maven.plugins maven-surefire-plugin - 2.5 + 3.5.3 - -Xmx1024m -Xms1024m -XX:MaxPermSize=512m -Duser.language=en -Duser.region=US -Djdk.net.URLClassPath.disableClassPathURLCheck=true + -Xmx1024m -Xms1024m -Duser.language=en -Duser.region=US -Djdk.net.URLClassPath.disableClassPathURLCheck=true ${java.io.tmpdir} From 942799a5756d879ddc9df3083766c8b80502a660 Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Wed, 18 Jun 2025 21:08:13 +0530 Subject: [PATCH 2/3] Remove reporting compatability module --- api-tests/pom.xml | 5 - api/pom.xml | 10 +- .../DataExportDataSetDefinition.java | 102 -------------- .../evaluator/DataExportDataSetEvaluator.java | 112 --------------- .../DataExportDataSetDefinitionPersister.java | 130 ------------------ omod/src/main/resources/config.xml | 24 ---- pom.xml | 8 -- 7 files changed, 1 insertion(+), 390 deletions(-) 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/api-tests/pom.xml b/api-tests/pom.xml index e37cf08cd4..67ca717cf0 100644 --- a/api-tests/pom.xml +++ b/api-tests/pom.xml @@ -30,11 +30,6 @@ - - org.openmrs.module - ${reportingApiConditionalArtifactId} - ${project.parent.version} - org.openmrs.api diff --git a/api/pom.xml b/api/pom.xml index f3621e24f2..f69f2a14cb 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -11,13 +11,5 @@ 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/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index 23e6193693..f3c08faf57 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,4 @@ 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..8dfe206602 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,6 @@ 2.4.1 - 2.0.6 2.4 1.7.2 0.2.14 @@ -55,7 +54,6 @@ Reporting ${project.parent.version} ${project.parent.groupId}.${project.parent.artifactId} - reporting-api-1.9 @@ -367,13 +365,7 @@ 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 From db9746d922a46bdfde775ade049619b270af0393 Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Wed, 18 Jun 2025 21:08:28 +0530 Subject: [PATCH 3/3] Remove old datasets --- .../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.2.xml | 574 ------------------ .../include/ReportTestDataset-openmrs-2.3.xml | 574 ------------------ 8 files changed, 4517 deletions(-) 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.2.xml delete mode 100644 api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.3.xml 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.2.xml b/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.2.xml deleted file mode 100644 index e89f14375f..0000000000 --- a/api-tests/src/test/resources/org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.2.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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -