From a01efd68ced11c98d5bfa192ad0794736a5087a7 Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 10:45:50 +0000 Subject: [PATCH 1/8] chore: Reenable disabled tests and clean up --- .../hisp/dhis/test/e2e/dto/ApiResponse.java | 7 +- .../dhis/merge/CategoryOptionMergeTest.java | 5 +- .../hisp/dhis/merge/DataElementMergeTest.java | 88 +++--- .../hisp/dhis/merge/IndicatorMergeTest.java | 294 ++++++++++-------- .../dhis/merge/IndicatorTypeMergeTest.java | 136 ++++---- 5 files changed, 293 insertions(+), 237 deletions(-) diff --git a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java index 3a0568e0f417..15bea0cbd9d6 100644 --- a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java +++ b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java @@ -66,7 +66,12 @@ public String extractUid() { return uid; } - return extractString("response.importSummaries.reference[0]"); + uid = extractString("response.importSummaries.reference[0]"); + if (!StringUtils.isEmpty(uid)) { + return uid; + } + + return extractString("response.typeReports[0].objectReports[0].uid"); } /** Extracts uids from import summaries. Use when more than one object was created. */ diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java index ef31d1cdb97a..b279e5a9b849 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java @@ -45,7 +45,6 @@ import org.hisp.dhis.test.e2e.dto.ApiResponse; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -85,7 +84,6 @@ public void setup() { } @Test - @Disabled("Started failing in GitHub (Not Jenkins) for no obvious reason") @DisplayName( "Valid CategoryOption merge completes successfully with all source CategoryOption refs replaced with target CategoryOption") void validDataElementMergeTest() { @@ -153,11 +151,10 @@ void validDataElementMergeTest() { } private void setupMetadata() { - metadataActions.post(metadata()).validateStatus(200); + metadataActions.importMetadata(metadata()).validateStatus(200); } @Test - @Disabled("Started failing in GitHub (Not Jenkins) for no obvious reason") @DisplayName("CategoryOption merge fails when user has not got the required authority") void testDataElementMergeNoRequiredAuth() { userActions.addUserFull("basic", "User", "basicUser", "Test1234!", "NO_AUTH"); diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java index c66af88bf65f..21aa404928ed 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java @@ -44,7 +44,6 @@ import org.hisp.dhis.test.e2e.dto.ApiResponse; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -52,7 +51,7 @@ class DataElementMergeTest extends ApiTest { private RestApiActions dataElementApiActions; private RestApiActions datasetApiActions; - private MetadataActions metadataApiActions; + private MetadataActions metadataActions; private RestApiActions minMaxActions; private UserActions userActions; private LoginActions loginActions; @@ -66,7 +65,7 @@ public void before() { loginActions = new LoginActions(); dataElementApiActions = new RestApiActions("dataElements"); datasetApiActions = new RestApiActions("dataSets"); - metadataApiActions = new MetadataActions(); + metadataActions = new MetadataActions(); minMaxActions = new RestApiActions("minMaxDataElements"); loginActions.loginAsSuperUser(); @@ -124,8 +123,6 @@ void validDataElementMergeTest() { } @Test - @Disabled( - "setup started failing on GitHub only 409 response, reason not known, e2e all passing locally") @DisplayName("DataElement merge fails when min max DE DB unique key constraint met") void dbConstraintMinMaxTest() { // given @@ -295,14 +292,14 @@ void testDataElementMergeNoRequiredAuth() { } private String setupDataElement(String uniqueChar, String valueType, String domainType) { - return dataElementApiActions - .post(createDataElement("source 1" + uniqueChar, valueType, domainType)) - .validateStatus(201) + return metadataActions + .importMetadata(createDataElement("source 1" + uniqueChar, valueType, domainType)) + .validateStatus(200) .extractUid(); } private void setupDataSet(String sourceUid1, String sourceUid2, String targetUid) { - datasetApiActions.post(createDataset(sourceUid1, sourceUid2, targetUid)).extractUid(); + metadataActions.importMetadata(createDataset(sourceUid1, sourceUid2, targetUid)).extractUid(); } private JsonObject getMergeBody( @@ -320,16 +317,25 @@ private JsonObject getMergeBody( private void setupProgramStageDataElements( String sourceUid1, String sourceUid2, String targetUid) { - metadataApiActions + metadataActions .importMetadata(programWithStageAndDataElements(sourceUid1, sourceUid2, targetUid)) .validateStatus(200); } private void setupMinMaxDataElements(String sourceUid1, String sourceUid2, String targetUid) { - metadataApiActions.importMetadata(metadata()).validateStatus(200); - minMaxActions.post(minMaxDataElements("OrgUnit0Z91", sourceUid1, "CatOptComZ3")); - minMaxActions.post(minMaxDataElements("OrgUnit0Z91", sourceUid2, "CatOptComZ3")); - minMaxActions.post(minMaxDataElements("OrgUnit0Z91", targetUid, "CatOptComZ3")); + metadataActions.importMetadata(metadata()).validateStatus(200); + String mmde1 = + minMaxActions + .post(minMaxDataElements("OrgUnit0Z91", sourceUid1, "CatOptComZ3")) + .getAsString(); + String mmde2 = + minMaxActions + .post(minMaxDataElements("OrgUnit0Z91", sourceUid2, "CatOptComZ3")) + .getAsString(); + String mmde3 = + minMaxActions + .post(minMaxDataElements("OrgUnit0Z91", targetUid, "CatOptComZ3")) + .getAsString(); } private String programWithStageAndDataElements( @@ -485,13 +491,17 @@ private String minMaxDataElements(String orgUnit, String de, String coc) { private String createDataElement(String name, String valueType, String domainType) { return """ { - "aggregationType": "DEFAULT", - "domainType": "%s", - "name": "%s", - "shortName": "%s", - "displayName": "%s", - "valueType": "%s" - } + "dataElements":[ + { + "aggregationType": "DEFAULT", + "domainType": "%s", + "name": "%s", + "shortName": "%s", + "displayName": "%s", + "valueType": "%s" + } + ] + } """ .formatted(domainType, name, name, name, valueType); } @@ -499,24 +509,28 @@ private String createDataElement(String name, String valueType, String domainTyp private String createDataset(String dataEl1, String dataEl2, String dataEl3) { return """ { - "name": "ds1", - "shortName": "ds1", - "periodType": "Daily", - "dataSetElements": [ - { - "dataElement": { - "id": "%s" - } - }, - { - "dataElement": { - "id": "%s" - } - }, + "dataSets": [ { - "dataElement": { - "id": "%s" + "name": "ds1", + "shortName": "ds1", + "periodType": "Daily", + "dataSetElements": [ + { + "dataElement": { + "id": "%s" + } + }, + { + "dataElement": { + "id": "%s" + } + }, + { + "dataElement": { + "id": "%s" + } } + ] } ] } diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorMergeTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorMergeTest.java index 2d20c732dd32..edff0eddb895 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorMergeTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorMergeTest.java @@ -44,6 +44,7 @@ import org.hisp.dhis.test.e2e.actions.LoginActions; import org.hisp.dhis.test.e2e.actions.RestApiActions; import org.hisp.dhis.test.e2e.actions.UserActions; +import org.hisp.dhis.test.e2e.actions.metadata.MetadataActions; import org.hisp.dhis.test.e2e.dto.ApiResponse; import org.hisp.dhis.test.e2e.helpers.QueryParamsBuilder; import org.junit.jupiter.api.BeforeAll; @@ -53,6 +54,7 @@ class IndicatorMergeTest extends ApiTest { + private MetadataActions metadataActions; private RestApiActions indicatorApiActions; private RestApiActions indicatorTypeApiActions; private RestApiActions formsActions; @@ -81,6 +83,7 @@ class IndicatorMergeTest extends ApiTest { @BeforeAll public void before() { + metadataActions = new MetadataActions(); userActions = new UserActions(); loginActions = new LoginActions(); indicatorApiActions = new RestApiActions("indicators"); @@ -332,111 +335,112 @@ void testIndicatorMergeAllAuth() { private void setupIndicatorData() { // indicator types String indTypeUid1 = - indicatorTypeApiActions - .post(createIndicatorType("D", 98, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("D", 98, true)) + .validateStatus(200) .extractUid(); String indTypeUid2 = - indicatorTypeApiActions - .post(createIndicatorType("E", 99, false)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("E", 99, false)) + .validateStatus(200) .extractUid(); String indTypeUid3 = - indicatorTypeApiActions - .post(createIndicatorType("F", 100, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("F", 100, true)) + .validateStatus(200) .extractUid(); // indicators (2 x source & 1 target) sourceUid1 = - indicatorApiActions - .post(createIndicator("Ind source 1", indTypeUid1)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind source 1", indTypeUid1)) + .validateStatus(200) .extractUid(); sourceUid2 = - indicatorApiActions - .post(createIndicator("Ind source 2", indTypeUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind source 2", indTypeUid2)) + .validateStatus(200) .extractUid(); targetUid = - indicatorApiActions - .post(createIndicator("Ind target 3", indTypeUid3)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind target 3", indTypeUid3)) + .validateStatus(200) .extractUid(); // indicators containing refs to other indicators in numerator/denominator // indicator with numerator and denominator x 2 ind4WithIndRef = - indicatorApiActions - .post(createIndicatorWithRefs("Ind 4", indTypeUid2, sourceUid1, sourceUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorWithRefs("Ind 4", indTypeUid2, sourceUid1, sourceUid2)) + .validateStatus(200) .extractUid(); ind5WithIndRef = - indicatorApiActions - .post(createIndicatorWithRefs("Ind 5", indTypeUid3, targetUid, sourceUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorWithRefs("Ind 5", indTypeUid3, targetUid, sourceUid2)) + .validateStatus(200) .extractUid(); indWithoutSourceRef = - indicatorApiActions - .post(createIndicatorWithRefs("Ind 6", indTypeUid3, targetUid, "Uid45678901")) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorWithRefs("Ind 6", indTypeUid3, targetUid, "Uid45678901")) + .validateStatus(200) .extractUid(); // 2 data entry forms containing indicator refs in html code formWithSources = - formsActions - .post(createDataEntryForm("custom form 1", sourceUid2, sourceUid1)) - .validateStatus(201) + metadataActions + .importMetadata(createDataEntryForm("custom form 1", sourceUid2, sourceUid1)) + .validateStatus(200) .extractUid(); formWithoutSources = - formsActions - .post(createDataEntryForm("custom form 2", targetUid, "Uid45678901")) - .validateStatus(201) + metadataActions + .importMetadata(createDataEntryForm("custom form 2", targetUid, "Uid45678901")) + .validateStatus(200) .extractUid(); // datasets (have 1 part of a source and 1 not) datasetWithSources = - dataSetActions - .post(createDataSet("Data set 1", sourceUid1, sourceUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createDataSet("Data set 1", sourceUid1, sourceUid2)) + .validateStatus(200) .extractUid(); datasetWithoutSources = - dataSetActions - .post(createDataSet("Data set 2", ind4WithIndRef, ind5WithIndRef)) - .validateStatus(201) + metadataActions + .importMetadata(createDataSet("Data set 2", ind4WithIndRef, ind5WithIndRef)) + .validateStatus(200) .extractUid(); // indicator groups (have 1 part of a source and 1 not) indGroupWithSources = - indicatorGroupActions - .post(createIndicatorGroup("Group 1", sourceUid1, sourceUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorGroup("Group 1", sourceUid1, sourceUid2)) + .validateStatus(200) .extractUid(); indGroupWithNoSources = - indicatorGroupActions - .post(createIndicatorGroup("Group 2", ind4WithIndRef, ind5WithIndRef)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorGroup("Group 2", ind4WithIndRef, ind5WithIndRef)) + .validateStatus(200) .extractUid(); // sections (have 1 reference a source and 1 not) sectionWithSources = - sectionActions - .post(createSection("Group 1", datasetWithSources, sourceUid1, sourceUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createSection("Group 1", datasetWithSources, sourceUid1, sourceUid2)) + .validateStatus(200) .extractUid(); sectionWithoutSources = - sectionActions - .post(createSection("Group 2", datasetWithoutSources, ind4WithIndRef, ind5WithIndRef)) - .validateStatus(201) + metadataActions + .importMetadata( + createSection("Group 2", datasetWithoutSources, ind4WithIndRef, ind5WithIndRef)) + .validateStatus(200) .extractUid(); // and a visualization exists with data dimension items (indicators) visUid = - visualizationActions - .post(getVisualization(sourceUid1, sourceUid2)) - .validateStatus(201) + metadataActions + .importMetadata(getVisualization(sourceUid1, sourceUid2)) + .validateStatus(200) .extractUid(); // set config indicators @@ -446,55 +450,59 @@ private void setupIndicatorData() { private String getVisualization(String sourceUid1, String sourceUid2) { return """ { - "name": "vis test 1", - "dataDimensionItems": [ - { - "indicator": { - "id": "%s" - }, - "dataDimensionItemType": "INDICATOR" - }, - { - "indicator": { - "id": "%s" - }, - "dataDimensionItemType": "INDICATOR" - } - ], - "type": "COLUMN", - "numberType": "VALUE", - "columns": [ + "visualizations": [ { - "items": [ + "name": "vis test 1", + "dataDimensionItems": [ { - "id": "%s" + "indicator": { + "id": "%s" + }, + "dataDimensionItemType": "INDICATOR" }, { - "id": "%s" + "indicator": { + "id": "%s" + }, + "dataDimensionItemType": "INDICATOR" } ], - "dimension": "dx" - }, - { - "items": [ + "type": "COLUMN", + "numberType": "VALUE", + "columns": [ { - "name": "CHP", - "id": "uYxK4wmcPqA", - "displayName": "CHP", - "displayShortName": "CHP", - "dimensionItemType": "ORGANISATION_UNIT_GROUP" - } + "items": [ + { + "id": "%s" + }, + { + "id": "%s" + } + ], + "dimension": "dx" + }, + { + "items": [ + { + "name": "CHP", + "id": "uYxK4wmcPqA", + "displayName": "CHP", + "displayShortName": "CHP", + "dimensionItemType": "ORGANISATION_UNIT_GROUP" + } + ], + "dimension": "%s" + } ], - "dimension": "%s" - } - ], - "sorting": [ - { - "dimension": "%s", - "direction": "ASC" + "sorting": [ + { + "dimension": "%s", + "direction": "ASC" + } + ], + "displayName": "vis test 1" } - ], - "displayName": "vis test 1" + ] } """ .formatted(sourceUid1, sourceUid2, sourceUid1, sourceUid2, sourceUid1, sourceUid1); @@ -504,8 +512,12 @@ private String createDataEntryForm(String name, String indUid1, String indUid2) // language json return """ { - "name": "%s", - "htmlCode": "\\r\\n\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\r\\n\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\r\\n
Child registration form
First name
Last name
Gender
\\r\\n\\r\\n

 

" + "dataEntryForms":[ + { + "name": "%s", + "htmlCode": "\\r\\n\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\r\\n\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\r\\n\\t\\t\\t\\r\\n\\t\\t\\r\\n\\t\\r\\n
Child registration form
First name
Last name
Gender
\\r\\n\\r\\n

 

" + } + ] } """ .formatted(name, indUid1, indUid2); @@ -527,14 +539,18 @@ private String createIndicatorWithRefs( String name, String indicatorType, String indicatorRef1, String indicatorRef2) { return """ { - "name": "test indicator %s", - "shortName": "test short %s", - "dimensionItemType": "INDICATOR", - "numerator": "#{%s}", - "denominator": "#{%s}", - "indicatorType": { - "id": "%s" - } + "indicators":[ + { + "name": "test indicator %s", + "shortName": "test short %s", + "dimensionItemType": "INDICATOR", + "numerator": "#{%s}", + "denominator": "#{%s}", + "indicatorType": { + "id": "%s" + } + } + ] } """ .formatted(name, name, indicatorRef1, indicatorRef2, indicatorType); @@ -543,16 +559,20 @@ private String createIndicatorWithRefs( private String createDataSet(String name, String indicatorUid1, String indicatorUid2) { return """ { - "name": "%s", - "shortName": "%s", - "periodType": "Daily", - "indicators":[ - { - "id": "%s" - }, - { - "id": "%s" - } + "dataSets":[ + { + "name": "%s", + "shortName": "%s", + "periodType": "Daily", + "indicators":[ + { + "id": "%s" + }, + { + "id": "%s" + } + ] + } ] } """ @@ -562,15 +582,19 @@ private String createDataSet(String name, String indicatorUid1, String indicator private String createIndicatorGroup(String name, String indicatorUid1, String indicatorUid2) { return """ { - "name": "%s", - "shortName": "%s", - "indicators":[ - { - "id": "%s" - }, - { - "id": "%s" - } + "indicatorGroups":[ + { + "name": "%s", + "shortName": "%s", + "indicators":[ + { + "id": "%s" + }, + { + "id": "%s" + } + ] + } ] } """ @@ -581,18 +605,22 @@ private String createSection( String name, String dataSet, String indicatorUid1, String indicatorUid2) { return """ { - "name": "%s", - "shortName": "%s", - "dataSet": { - "id": "%s" - }, - "indicators":[ - { + "sections": [ + { + "name": "%s", + "shortName": "%s", + "dataSet": { "id": "%s" }, - { - "id": "%s" - } + "indicators":[ + { + "id": "%s" + }, + { + "id": "%s" + } + ] + } ] } """ diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorTypeMergeTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorTypeMergeTest.java index 53826638b3ac..8be9627837de 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorTypeMergeTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/IndicatorTypeMergeTest.java @@ -37,6 +37,7 @@ import org.hisp.dhis.test.e2e.actions.LoginActions; import org.hisp.dhis.test.e2e.actions.RestApiActions; import org.hisp.dhis.test.e2e.actions.UserActions; +import org.hisp.dhis.test.e2e.actions.metadata.MetadataActions; import org.hisp.dhis.test.e2e.dto.ApiResponse; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -46,6 +47,7 @@ class IndicatorTypeMergeTest extends ApiTest { private RestApiActions indicatorTypeApiActions; private RestApiActions indicatorApiActions; + private MetadataActions metadataActions; private LoginActions loginActions; private UserActions userActions; @@ -56,6 +58,7 @@ public void before() { indicatorApiActions = new RestApiActions("indicators"); userActions = new UserActions(); loginActions.loginAsSuperUser(); + metadataActions = new MetadataActions(); } @Test @@ -107,36 +110,37 @@ void testValidMergeKeepSources() { // given 3 indicators and 3 indicator types exist // indicator types String indTypeUid1 = - indicatorTypeApiActions - .post(createIndicatorType("A", 98, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("A", 98, true)) + .validateStatus(200) .extractUid(); + String indTypeUid2 = - indicatorTypeApiActions - .post(createIndicatorType("B", 99, false)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("B", 99, false)) + .validateStatus(200) .extractUid(); String indTypeUid3 = - indicatorTypeApiActions - .post(createIndicatorType("C", 100, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("C", 100, true)) + .validateStatus(200) .extractUid(); // indicators referencing the indicator types String i1 = - indicatorApiActions - .post(createIndicator("Ind1", indTypeUid1)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind1", indTypeUid1)) + .validateStatus(200) .extractUid(); String i2 = - indicatorApiActions - .post(createIndicator("Ind2", indTypeUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind2", indTypeUid2)) + .validateStatus(200) .extractUid(); String i3 = - indicatorApiActions - .post(createIndicator("Ind3", indTypeUid3)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind3", indTypeUid3)) + .validateStatus(200) .extractUid(); // when an indicator type merge request is submitted, keeping sources @@ -187,36 +191,36 @@ void testValidMergeDeleteSources() { // given 3 indicators and 3 indicator types exist // indicator types String indTypeUid1 = - indicatorTypeApiActions - .post(createIndicatorType("D", 98, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("D", 98, true)) + .validateStatus(200) .extractUid(); String indTypeUid2 = - indicatorTypeApiActions - .post(createIndicatorType("E", 99, false)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("E", 99, false)) + .validateStatus(200) .extractUid(); String indTypeUid3 = - indicatorTypeApiActions - .post(createIndicatorType("F", 100, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("F", 100, true)) + .validateStatus(200) .extractUid(); // indicators String i1 = - indicatorApiActions - .post(createIndicator("Ind4", indTypeUid1)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind4", indTypeUid1)) + .validateStatus(200) .extractUid(); String i2 = - indicatorApiActions - .post(createIndicator("Ind5", indTypeUid2)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind5", indTypeUid2)) + .validateStatus(200) .extractUid(); String i3 = - indicatorApiActions - .post(createIndicator("Ind6", indTypeUid3)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicator("Ind6", indTypeUid3)) + .validateStatus(200) .extractUid(); // when an indicator type merge request is submitted, deleting sources @@ -265,9 +269,9 @@ void testValidMergeDeleteSources() { void testInvalidMergeNoSources() { // given a target indicator type exists String indTypeUid1 = - indicatorTypeApiActions - .post(createIndicatorType("G", 98, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("G", 98, true)) + .validateStatus(200) .extractUid(); // when a merge request with no sources is sent @@ -296,9 +300,9 @@ void testInvalidMergeNoSources() { void testInvalidMergeNoTarget() { // given a valid source indicator type exists String indTypeUid1 = - indicatorTypeApiActions - .post(createIndicatorType("H", 98, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("H", 98, true)) + .validateStatus(200) .extractUid(); // when a merge request with no target is sent @@ -327,19 +331,19 @@ void testInvalidMergeNoTarget() { void testInvalidMergeTargetInSources() { // given indicator types exist String indTypeUid1 = - indicatorTypeApiActions - .post(createIndicatorType("J", 98, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("J", 98, true)) + .validateStatus(200) .extractUid(); String indTypeUid2 = - indicatorTypeApiActions - .post(createIndicatorType("K", 99, false)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("K", 99, false)) + .validateStatus(200) .extractUid(); String indTypeUid3 = - indicatorTypeApiActions - .post(createIndicatorType("L", 100, true)) - .validateStatus(201) + metadataActions + .importMetadata(createIndicatorType("L", 100, true)) + .validateStatus(200) .extractUid(); // when a merge request has the target contained in the sources @@ -445,9 +449,13 @@ private String getMergeBodyNoTarget(String target, boolean deleteSources) { static String createIndicatorType(String name, int factor, boolean isNumber) { return """ { - "name": "test indicator type %s", - "factor": "%d", - "number": "%b" + "indicatorTypes":[ + { + "name": "test indicator type %s", + "factor": "%d", + "number": "%b" + } + ] } """ .formatted(name, factor, isNumber); @@ -456,14 +464,18 @@ static String createIndicatorType(String name, int factor, boolean isNumber) { static String createIndicator(String name, String indicatorType) { return """ { - "name": "test indicator %s", - "shortName": "test short %s", - "dimensionItemType": "INDICATOR", - "numerator": "#{fbfJHSPpUQD}", - "denominator": "#{h0xKKjijTdI}", - "indicatorType": { - "id": "%s" - } + "indicators": [ + { + "name": "test indicator %s", + "shortName": "test short %s", + "dimensionItemType": "INDICATOR", + "numerator": "#{fbfJHSPpUQD}", + "denominator": "#{h0xKKjijTdI}", + "indicatorType": { + "id": "%s" + } + } + ] } """ .formatted(name, name, indicatorType); From 7d24b67f232fd702db4c8dd53ae1aecac690007a Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 11:13:18 +0000 Subject: [PATCH 2/8] chore: clean up after each test --- .../java/org/hisp/dhis/merge/CategoryOptionMergeTest.java | 7 +++++++ .../java/org/hisp/dhis/merge/DataElementMergeTest.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java index b279e5a9b849..7c63f874653f 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/CategoryOptionMergeTest.java @@ -38,11 +38,13 @@ import com.google.gson.JsonObject; import io.restassured.response.ValidatableResponse; import org.hisp.dhis.ApiTest; +import org.hisp.dhis.helpers.TestCleanUp; import org.hisp.dhis.test.e2e.actions.LoginActions; import org.hisp.dhis.test.e2e.actions.RestApiActions; import org.hisp.dhis.test.e2e.actions.UserActions; import org.hisp.dhis.test.e2e.actions.metadata.MetadataActions; import org.hisp.dhis.test.e2e.dto.ApiResponse; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -83,6 +85,11 @@ public void setup() { setupMetadata(); } + @AfterEach + public void cleanup() { + new TestCleanUp().deleteCreatedEntities(); + } + @Test @DisplayName( "Valid CategoryOption merge completes successfully with all source CategoryOption refs replaced with target CategoryOption") diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java index 21aa404928ed..7f50366d09d1 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/merge/DataElementMergeTest.java @@ -37,11 +37,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.hisp.dhis.ApiTest; +import org.hisp.dhis.helpers.TestCleanUp; import org.hisp.dhis.test.e2e.actions.LoginActions; import org.hisp.dhis.test.e2e.actions.RestApiActions; import org.hisp.dhis.test.e2e.actions.UserActions; import org.hisp.dhis.test.e2e.actions.metadata.MetadataActions; import org.hisp.dhis.test.e2e.dto.ApiResponse; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -85,6 +87,11 @@ public void setup() { loginActions.loginAsSuperUser(); } + @AfterEach + public void cleanup() { + new TestCleanUp().deleteCreatedEntities(); + } + @Test @DisplayName( "Valid DataElement merge completes successfully with all source DataElement refs replaced with target DataElement") From 870d93ca55495f2845ea073f38a0411cf05a85c6 Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 11:45:05 +0000 Subject: [PATCH 3/8] chore: add debug --- .../java/org/hisp/dhis/scheduling/RecordingJobProgress.java | 2 +- .../dhis/dxf2/metadata/DefaultMetadataImportService.java | 2 ++ .../metadata/objectbundle/DefaultObjectBundleService.java | 3 +++ .../dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java | 6 ++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java index c1f5eb712d25..bd961b254db4 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java @@ -214,7 +214,7 @@ private RuntimeException cancellationException(boolean failedPostCondition) { if (skipRecording && cause instanceof RuntimeException rex) throw rex; CancellationException ex = failedPostCondition - ? new CancellationException("Non-null post-condition failed") + ? new CancellationException("Non-null post-condition failed: " + cause.getMessage()) : new CancellationException(); ex.initCause(cause); return ex; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java index 6f7d7ffaa0b8..6cbf444a3dc7 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java @@ -98,10 +98,12 @@ public ImportReport importMetadata( handleDeprecationIfEventReport(bundleParams); progress.startingStage("Creating bundle"); + log.info("OBP: " + bundleParams); ObjectBundle bundle = progress.nonNullStagePostCondition( progress.runStage(() -> objectBundleService.create(bundleParams))); + log.info("OB after nonnull stage: " + (bundle != null)); progress.startingStage("Running postCreateBundle"); progress.runStage(() -> postCreateBundle(bundle, bundleParams)); diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java index caa0899f17e1..7c8978bce2e3 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java @@ -107,8 +107,11 @@ public ObjectBundle create(ObjectBundleParams params) { Preheat preheat = preheatService.preheat(preheatParams); ObjectBundle bundle = new ObjectBundle(params, preheat, params.getObjects()); + log.info("OB state 1: " + (bundle != null)); bundle.setObjectBundleStatus(ObjectBundleStatus.CREATED); + log.info("OB state 2: " + (bundle != null)); bundle.setObjectReferences(preheatService.collectObjectReferences(params.getObjects())); + log.info("OB state 3: " + (bundle != null)); return bundle; } diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java index 87503c63cacd..e27f2cc307bf 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java @@ -34,6 +34,7 @@ import org.hisp.dhis.helpers.extensions.MetadataSetupExtension; import org.hisp.dhis.test.e2e.actions.LoginActions; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; @@ -51,4 +52,9 @@ public void afterAll() { new LoginActions().loginAsDefaultUser(); new TestCleanUp().deleteCreatedEntities(); } + + @AfterEach + public void cleanup() { + new TestCleanUp().deleteCreatedEntities(); + } } From f92034a2bbf36ea2b424fda5eefdaaa1ca1739cf Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 12:45:31 +0000 Subject: [PATCH 4/8] chore: add debug --- .../hisp/dhis/importexport/ObjectBundle.java | 394 ++++++++ .../dhis/importexport/ObjectBundleFail.java | 3 + .../dhis/importexport/ObjectBundleParams.java | 95 ++ .../dhis/importexport/ObjectBundleResult.java | 3 + .../dhis/importexport/ObjectBundleStatus.java | 12 + .../org/hisp/dhis/scheduling/JobProgress.java | 11 + .../dhis/scheduling/RecordingJobProgress.java | 3 +- .../AnalyticalObjectImportHandler.java | 2 +- .../DefaultAnalyticalObjectImportHandler.java | 2 +- .../DefaultMetadataImportService.java | 10 +- .../DefaultObjectBundleService.java | 38 +- .../DefaultObjectBundleValidationService.java | 2 + .../EventReportCompatibilityGuard.java | 1 + .../metadata/objectbundle/ObjectBundle.java | 850 +++++++++--------- .../objectbundle/ObjectBundleHook.java | 1 + .../objectbundle/ObjectBundleParams.java | 250 +++--- .../objectbundle/ObjectBundleService.java | 5 +- .../objectbundle/ObjectBundleStatus.java | 20 +- .../ObjectBundleValidationService.java | 1 + .../hooks/AbstractObjectBundleHook.java | 2 +- ...AggregateDataExchangeObjectBundleHook.java | 2 +- .../AnalyticalObjectObjectBundleHook.java | 2 +- .../AnalyticsTableHookObjectBundleHook.java | 2 +- .../hooks/AttributeObjectBundleHook.java | 2 +- .../hooks/CategoryComboObjectBundleHook.java | 2 +- .../hooks/CategoryObjectBundleHook.java | 2 +- .../CategoryOptionComboObjectBundleHook.java | 2 +- .../hooks/DataElementObjectBundleHook.java | 2 +- .../DataInputPeriodObjectBundleHook.java | 2 +- .../hooks/DataSetObjectBundleHook.java | 2 +- .../hooks/DocumentObjectBundleHook.java | 2 +- .../hooks/EmbeddedObjectObjectBundleHook.java | 2 +- .../hooks/EventHookObjectBundleHook.java | 2 +- ...pressionDimensionItemObjectBundleHook.java | 2 +- .../hooks/IdentifiableObjectBundleHook.java | 2 +- .../JobConfigurationObjectBundleHook.java | 2 +- .../hooks/OptionObjectBundleHook.java | 2 +- .../hooks/OptionSetObjectBundleHook.java | 2 +- .../OrganisationUnitObjectBundleHook.java | 2 +- .../hooks/PeriodTypeObjectBundleHook.java | 2 +- .../hooks/PredictorObjectBundleHook.java | 2 +- ...mNotificationTemplateObjectBundleHook.java | 2 +- .../hooks/ProgramObjectBundleHook.java | 2 +- .../ProgramRuleActionObjectBundleHook.java | 2 +- .../hooks/ProgramRuleObjectBundleHook.java | 2 +- .../ProgramRuleVariableObjectBundleHook.java | 2 +- ...ogramStageDataElementObjectBundleHook.java | 2 +- .../hooks/ProgramStageObjectBundleHook.java | 2 +- ...ogramStageWorkingListObjectBundleHook.java | 2 +- ...rackedEntityAttributeObjectBundleHook.java | 2 +- .../RelationshipTypeObjectBundleHook.java | 2 +- .../hooks/RouteObjectBundleHook.java | 2 +- .../hooks/SectionObjectBundleHook.java | 2 +- .../hooks/SmsCommandObjectBundleHook.java | 2 +- .../hooks/SortableObjectBundleHook.java | 2 +- ...rackedEntityAttributeObjectBundleHook.java | 2 +- .../TrackedEntityTypeObjectBundleHook.java | 2 +- .../hooks/UserGroupObjectBundleHook.java | 2 +- .../hooks/UserObjectBundleHook.java | 2 +- .../hooks/UserRoleBundleHook.java | 2 +- .../VersionedObjectObjectBundleHook.java | 2 +- .../validation/CreationCheck.java | 2 +- .../validation/DashboardCheck.java | 2 +- .../validation/DeletionCheck.java | 2 +- .../validation/DuplicateIdsCheck.java | 2 +- .../validation/GeoJsonAttributesCheck.java | 2 +- .../validation/MandatoryAttributesCheck.java | 2 +- .../validation/MetadataAttributeCheck.java | 2 +- .../validation/NotOwnerReferencesCheck.java | 2 +- .../validation/ObjectValidationCheck.java | 2 +- .../validation/ReferencesCheck.java | 2 +- .../objectbundle/validation/SchemaCheck.java | 2 +- .../validation/SecurityCheck.java | 2 +- .../validation/TranslationsCheck.java | 2 +- .../validation/UidFormatCheck.java | 2 +- .../validation/UniqueAttributesCheck.java | 2 +- .../UniqueMultiPropertiesCheck.java | 2 +- .../validation/UniquenessCheck.java | 2 +- .../objectbundle/validation/UpdateCheck.java | 2 +- .../validation/ValidationCheck.java | 2 +- .../validation/ValidationFactory.java | 2 +- .../validation/ValidationHooksCheck.java | 2 +- .../validation/ValidationRunner.java | 2 +- .../validation/ValidationUtils.java | 2 +- .../attribute/GeoJsonAttributesCheckTest.java | 2 +- .../attribute/MetadataAttributeCheckTest.java | 2 +- ...egateDataExchangeObjectBundleHookTest.java | 2 +- .../hooks/EmbeddedObjectBundleHookTest.java | 2 +- .../hooks/OptionObjectBundleHookTest.java | 2 +- ...ogramRuleVariableObjectBundleHookTest.java | 2 +- .../ProgramStageObjectBundleHookTest.java | 2 +- ...mStageWorkingListObjectBundleHookTest.java | 2 +- ...TrackedEntityTypeObjectBundleHookTest.java | 2 +- .../objectbundle/validation/DummyCheck.java | 2 +- .../ValidatingEventCheckerTest.java | 2 +- .../SMSCommandObjectBundleServiceTest.java | 2 +- .../validation/ReferencesCheckTest.java | 2 +- .../org/hisp/dhis/tracker/TrackerTest.java | 2 +- .../TrackerProgramRuleBundleServiceTest.java | 2 +- ...leEngineSideEffectsHandlerServiceTest.java | 2 +- .../ProgramRuleAssignActionTest.java | 2 +- .../imports/programrule/ProgramRuleTest.java | 2 +- .../export/IdSchemeExportControllerTest.java | 2 +- ...ackedEntitiesChangeLogsControllerTest.java | 2 +- 104 files changed, 1206 insertions(+), 667 deletions(-) create mode 100644 dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundle.java create mode 100644 dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleFail.java create mode 100644 dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleParams.java create mode 100644 dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleResult.java create mode 100644 dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleStatus.java diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundle.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundle.java new file mode 100644 index 000000000000..2aa363bb0c50 --- /dev/null +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundle.java @@ -0,0 +1,394 @@ +package org.hisp.dhis.importexport; + +import static java.util.Collections.emptyList; + +import com.google.common.collect.Iterables; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.apache.commons.lang3.StringUtils; +import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.dxf2.metadata.AtomicMode; +import org.hisp.dhis.dxf2.metadata.FlushMode; +import org.hisp.dhis.dxf2.metadata.UserOverrideMode; +import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; +import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; +import org.hisp.dhis.feedback.ObjectIndexProvider; +import org.hisp.dhis.feedback.TypedIndexedObjectContainer; +import org.hisp.dhis.hibernate.HibernateProxyUtils; +import org.hisp.dhis.preheat.Preheat; +import org.hisp.dhis.preheat.PreheatIdentifier; +import org.hisp.dhis.preheat.PreheatMode; +import org.hisp.dhis.user.User; + +public final class ObjectBundle implements ObjectIndexProvider, ObjectBundleResult { + /** User to use for import job (important for threaded imports). */ + private final User user; + + /** + * How should the user property be handled, by default it is left as is. You can override this to + * use current user, or a selected user instead (not yet supported). + */ + private final UserOverrideMode userOverrideMode; + + /** User to use for override, can be current or a selected user. */ + private User overrideUser; + + /** Should import be imported or just validated. */ + private final ObjectBundleMode objectBundleMode; + + /** What identifiers to match on. */ + private final PreheatIdentifier preheatIdentifier; + + /** Preheat mode to use (default is REFERENCE and should not be changed). */ + private final PreheatMode preheatMode; + + /** Sets import strategy (create, update, etc). */ + private final ImportStrategy importMode; + + /** Adjust hows objects imported should be reported (all objects, only errors etc) */ + private final ImportReportMode importReportMode; + + /** Should import be treated as a atomic import (all or nothing). */ + private final AtomicMode atomicMode; + + /** Flush for every object or per type. */ + private final FlushMode flushMode; + + /** Internal preheat bundle. */ + private final Preheat preheat; + + /** Should sharing be considered when importing objects. */ + private final boolean skipSharing; + + /** Should translation be considered when importing objects. */ + private final boolean skipTranslation; + + /** Skip validation of objects (not recommended). */ + private final boolean skipValidation; + + /** Is this import request from MetadataSync service; */ + private final boolean metadataSyncImport; + + /** Current status of object bundle. */ + private ObjectBundleStatus objectBundleStatus = ObjectBundleStatus.CREATED; + + /** Objects to import. */ + private final Map, List> + persistedObjects = new HashMap<>(); + + private final Map, List> + nonPersistedObjects = new HashMap<>(); + + /** Contains the indexes of the objects to be imported grouped by their type. */ + private final TypedIndexedObjectContainer typedIndexedObjectContainer = + new TypedIndexedObjectContainer(); + + /** Pre-scanned map of all object references (mainly used for object book hundle). */ + private Map, Map>> objectReferences = new HashMap<>(); + + /** + * Simple class => uid => object map to store extra info about an object. Especially useful for + * object hooks as they can be working on more than one object at a time, and needs to be + * stateless. + */ + private Map, Map>> extras = new HashMap<>(); + + public ObjectBundle( + ObjectBundleParams params, + Preheat preheat, + Map, List> objectMap) { + this.user = params.getUser(); + this.userOverrideMode = params.getUserOverrideMode(); + this.overrideUser = params.getOverrideUser(); + this.objectBundleMode = params.getObjectBundleMode(); + this.preheatIdentifier = params.getPreheatIdentifier(); + this.importMode = params.getImportStrategy(); + this.importReportMode = params.getImportReportMode(); + this.atomicMode = params.getAtomicMode(); + this.preheatMode = params.getPreheatMode(); + this.flushMode = params.getFlushMode(); + this.skipSharing = params.isSkipSharing(); + this.skipTranslation = params.isSkipTranslation(); + this.skipValidation = params.isSkipValidation(); + this.preheat = preheat; + this.metadataSyncImport = params.isMetadataSyncImport(); + + addObject(objectMap); + } + + public User getUser() { + return user; + } + + public UserOverrideMode getUserOverrideMode() { + return userOverrideMode; + } + + public User getOverrideUser() { + return overrideUser; + } + + public void setOverrideUser(User overrideUser) { + this.overrideUser = overrideUser; + } + + public String getUsername() { + return user != null ? user.getUsername() : "system-process"; + } + + public ObjectBundleMode getObjectBundleMode() { + return objectBundleMode; + } + + public PreheatIdentifier getPreheatIdentifier() { + return preheatIdentifier; + } + + public PreheatMode getPreheatMode() { + return preheatMode; + } + + public ImportStrategy getImportMode() { + return importMode; + } + + public ImportReportMode getImportReportMode() { + return importReportMode; + } + + public AtomicMode getAtomicMode() { + return atomicMode; + } + + public FlushMode getFlushMode() { + return flushMode; + } + + public boolean isSkipSharing() { + return skipSharing; + } + + public boolean isSkipTranslation() { + return skipTranslation; + } + + public boolean isSkipValidation() { + return skipValidation; + } + + public boolean isMetadataSyncImport() { + return metadataSyncImport; + } + + public ObjectBundleStatus getObjectBundleStatus() { + return objectBundleStatus; + } + + public void setObjectBundleStatus(ObjectBundleStatus objectBundleStatus) { + this.objectBundleStatus = objectBundleStatus; + } + + public Preheat getPreheat() { + return preheat; + } + + @Nonnull + @Override + public Integer mergeObjectIndex(@Nonnull IdentifiableObject object) { + return typedIndexedObjectContainer.mergeObjectIndex(object); + } + + /** + * Returns if the object bundle container contains the specified object. + * + * @param object the object that should be checked. + * @return true if this object container contains the specified object, false + * otherwise. + */ + public boolean containsObject(@Nullable IdentifiableObject object) { + if (object == null) { + return false; + } + return typedIndexedObjectContainer.containsObject(object); + } + + @SuppressWarnings({"unchecked"}) + private void addObject(IdentifiableObject object) { + if (object == null) { + return; + } + + Class realClass = HibernateProxyUtils.getRealClass(object); + + if (isPersisted(object)) { + persistedObjects.computeIfAbsent(realClass, key -> new ArrayList<>()).add(object); + } else { + nonPersistedObjects.computeIfAbsent(realClass, key -> new ArrayList<>()).add(object); + } + + typedIndexedObjectContainer.add(object); + } + + private void addObject(List objects) { + objects.forEach(this::addObject); + } + + private void addObject( + Map, List> objects) { + objects.values().forEach(this::addObject); + } + + public void forEach(Consumer objectConsumer) { + persistedObjects.values().forEach(list -> list.forEach(objectConsumer)); + nonPersistedObjects.values().forEach(list -> list.forEach(objectConsumer)); + } + + public boolean hasObjects(Class klass) { + return persistedObjects.containsKey(klass) || nonPersistedObjects.containsKey(klass); + } + + public int getObjectsCount(Class klass) { + List none = emptyList(); + return persistedObjects.getOrDefault(klass, none).size() + + nonPersistedObjects.getOrDefault(klass, none).size(); + } + + @SuppressWarnings("unchecked") + public Iterable getObjects(Class klass) { + List persistedObjectsOfType = persistedObjects.get(klass); + if (persistedObjectsOfType == null || persistedObjectsOfType.isEmpty()) { + return (Iterable) nonPersistedObjects.getOrDefault(klass, emptyList()); + } + List nonPersistedObjectsOfType = nonPersistedObjects.get(klass); + if (nonPersistedObjectsOfType == null || nonPersistedObjectsOfType.isEmpty()) { + return (Iterable) persistedObjectsOfType; + } + return (Iterable) Iterables.concat(persistedObjectsOfType, nonPersistedObjectsOfType); + } + + public Map, List> getObjects( + boolean persisted) { + return persisted ? persistedObjects : nonPersistedObjects; + } + + @SuppressWarnings("unchecked") + public List getObjects(Class klass, boolean persisted) { + List identifiableObjects = null; + + if (persisted) { + if (persistedObjects.containsKey(klass)) { + identifiableObjects = (List) persistedObjects.get(klass); + } + } else { + if (nonPersistedObjects.containsKey(klass)) { + identifiableObjects = (List) nonPersistedObjects.get(klass); + } + } + + return identifiableObjects != null ? identifiableObjects : emptyList(); + } + + public Map> getObjectReferences(Class klass) { + return objectReferences.get(klass); + } + + public Map, Map>> getObjectReferences() { + return objectReferences; + } + + public void setObjectReferences( + Map, Map>> objectReferences) { + this.objectReferences = objectReferences; + } + + @SuppressWarnings({"unchecked"}) + public void putExtras(IdentifiableObject identifiableObject, String key, Object object) { + if (identifiableObject == null + || StringUtils.isEmpty(identifiableObject.getUid()) + || object == null) { + return; + } + + Class realClass = + HibernateProxyUtils.getRealClass(identifiableObject); + + extras.computeIfAbsent(realClass, k -> new HashMap<>()); + + extras + .get(realClass) + .computeIfAbsent(identifiableObject.getUid(), s -> new HashMap<>()) + .put(key, object); + } + + @SuppressWarnings({"unchecked"}) + public Object getExtras(IdentifiableObject identifiableObject, String key) { + if (identifiableObject == null || StringUtils.isEmpty(identifiableObject.getUid())) { + return null; + } + + Class realClass = + HibernateProxyUtils.getRealClass(identifiableObject); + + if (!extras.containsKey(realClass)) { + return null; + } + + if (!extras.get(realClass).containsKey(identifiableObject.getUid())) { + return null; + } + + return extras.get(realClass).get(identifiableObject.getUid()).get(key); + } + + @SuppressWarnings({"unchecked"}) + public boolean hasExtras(IdentifiableObject identifiableObject, String key) { + if (identifiableObject == null || StringUtils.isEmpty(identifiableObject.getUid())) { + return false; + } + + Class realClass = + HibernateProxyUtils.getRealClass(identifiableObject); + + if (!extras.containsKey(realClass)) { + return false; + } + + if (!extras.get(realClass).containsKey(identifiableObject.getUid())) { + return false; + } + + return extras.get(realClass).get(identifiableObject.getUid()).containsKey(key); + } + + @SuppressWarnings({"unchecked"}) + public void removeExtras(IdentifiableObject identifiableObject, String key) { + if (identifiableObject == null + || StringUtils.isEmpty(identifiableObject.getUid()) + || !hasExtras(identifiableObject, key)) { + return; + } + + Class realClass = + HibernateProxyUtils.getRealClass(identifiableObject); + + extras.get(realClass).get(identifiableObject.getUid()).remove(key); + + if (extras.get(realClass).get(identifiableObject.getUid()).isEmpty()) { + extras.get(realClass).remove(identifiableObject.getUid()); + } + + if (extras.get(realClass).isEmpty()) { + extras.remove(realClass); + } + } + + public boolean isPersisted(IdentifiableObject object) { + IdentifiableObject cachedObject = preheat.get(preheatIdentifier, object); + return !(cachedObject == null || cachedObject.getId() == 0); + } +} diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleFail.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleFail.java new file mode 100644 index 000000000000..a633b4204587 --- /dev/null +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleFail.java @@ -0,0 +1,3 @@ +package org.hisp.dhis.importexport; + +public record ObjectBundleFail(Exception e) implements ObjectBundleResult {} diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleParams.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleParams.java new file mode 100644 index 000000000000..e235a0d4f15f --- /dev/null +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleParams.java @@ -0,0 +1,95 @@ +package org.hisp.dhis.importexport; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; +import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.dxf2.metadata.AtomicMode; +import org.hisp.dhis.dxf2.metadata.FlushMode; +import org.hisp.dhis.dxf2.metadata.UserOverrideMode; +import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; +import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; +import org.hisp.dhis.hibernate.HibernateProxyUtils; +import org.hisp.dhis.preheat.PreheatIdentifier; +import org.hisp.dhis.preheat.PreheatMode; +import org.hisp.dhis.preheat.PreheatParams; +import org.hisp.dhis.user.User; + +@Getter +@Setter +@Accessors(chain = true) +@ToString +public class ObjectBundleParams { + + @ToString.Exclude private User user; + + @ToString.Exclude private User overrideUser; + + @ToString.Exclude + private Map, List> objects = + new HashMap<>(); + + private UserOverrideMode userOverrideMode = UserOverrideMode.NONE; + private ObjectBundleMode objectBundleMode = ObjectBundleMode.COMMIT; + private PreheatIdentifier preheatIdentifier = PreheatIdentifier.UID; + private PreheatMode preheatMode = PreheatMode.REFERENCE; + private ImportStrategy importStrategy = ImportStrategy.CREATE_AND_UPDATE; + private AtomicMode atomicMode = AtomicMode.ALL; + private FlushMode flushMode = FlushMode.AUTO; + private ImportReportMode importReportMode = ImportReportMode.ERRORS; + + private boolean skipSharing; + private boolean skipTranslation; + private boolean skipValidation; + private boolean metadataSyncImport; + + public Map, List> getObjects() { + return objects; + } + + public ObjectBundleParams setObjects( + Map, List> objects) { + this.objects = objects; + return this; + } + + public ObjectBundleParams addObject( + Class klass, IdentifiableObject object) { + if (object == null) { + return this; + } + + if (!objects.containsKey(klass)) { + objects.put(klass, new ArrayList<>()); + } + + objects.get(klass).add(object); + + return this; + } + + @SuppressWarnings({"unchecked"}) + public ObjectBundleParams addObject(IdentifiableObject object) { + if (object == null) { + return this; + } + + Class realClass = HibernateProxyUtils.getRealClass(object); + + objects.computeIfAbsent(realClass, k -> new ArrayList<>()).add(object); + + return this; + } + + public PreheatParams getPreheatParams() { + PreheatParams params = new PreheatParams(); + params.setPreheatIdentifier(preheatIdentifier); + params.setPreheatMode(preheatMode); + return params; + } +} diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleResult.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleResult.java new file mode 100644 index 000000000000..3b290820dc52 --- /dev/null +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleResult.java @@ -0,0 +1,3 @@ +package org.hisp.dhis.importexport; + +public sealed interface ObjectBundleResult permits ObjectBundle, ObjectBundleFail {} diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleStatus.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleStatus.java new file mode 100644 index 000000000000..7e1aa912468d --- /dev/null +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ObjectBundleStatus.java @@ -0,0 +1,12 @@ +package org.hisp.dhis.importexport; + +public enum ObjectBundleStatus { + /** ObjectBundle has been created but not validated or committed. */ + CREATED, + + /** ObjectBundle has been created and validated, but not yet committed. */ + VALIDATED, + + /** ObjectBundle has been created, validated and committed. */ + COMMITTED +} diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java index 6cad6f4f1776..48c92dcb4df4 100644 --- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java @@ -63,6 +63,9 @@ import lombok.experimental.Accessors; import org.hisp.dhis.common.OpenApi; import org.hisp.dhis.feedback.ErrorCode; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleFail; +import org.hisp.dhis.importexport.ObjectBundleResult; import org.hisp.dhis.tracker.imports.validation.ValidationCode; import org.slf4j.helpers.MessageFormatter; @@ -252,6 +255,14 @@ void startingStage(@Nonnull String description, int workItems, @Nonnull FailureP */ @Nonnull default T nonNullStagePostCondition(@CheckForNull T value) throws CancellationException { + if (value instanceof ObjectBundleResult obr) { + if (obr instanceof ObjectBundle) { + return value; + } else if (obr instanceof ObjectBundleFail obf) { + throw new CancellationException("Post-condition was null: " + obf.e().getMessage()); + } + } + if (value == null) throw new CancellationException("Post-condition was null"); return value; } diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java index bd961b254db4..a9aa5b3ba241 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java @@ -40,6 +40,7 @@ import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.hisp.dhis.feedback.ErrorCode; +import org.hisp.dhis.importexport.ObjectBundleResult; import org.hisp.dhis.message.MessageService; import org.hisp.dhis.tracker.imports.validation.ValidationCode; import org.hisp.dhis.user.CurrentUserUtil; @@ -288,7 +289,7 @@ public void startingStage( @Override public T nonNullStagePostCondition(@CheckForNull T value) throws CancellationException { observer.run(); - if (value == null) throw cancellationException(true); + if (value instanceof ObjectBundleResult) if (value == null) throw cancellationException(true); return value; } diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/AnalyticalObjectImportHandler.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/AnalyticalObjectImportHandler.java index 7f0b64d03c8f..0783d654936a 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/AnalyticalObjectImportHandler.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/AnalyticalObjectImportHandler.java @@ -29,7 +29,7 @@ import jakarta.persistence.EntityManager; import org.hisp.dhis.common.BaseAnalyticalObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.schema.Schema; public interface AnalyticalObjectImportHandler { diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultAnalyticalObjectImportHandler.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultAnalyticalObjectImportHandler.java index ba462b1ae350..018d5e5d6d09 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultAnalyticalObjectImportHandler.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultAnalyticalObjectImportHandler.java @@ -40,7 +40,7 @@ import org.hisp.dhis.common.DimensionalItemObject; import org.hisp.dhis.common.DimensionalObject; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.legend.LegendSet; import org.hisp.dhis.period.RelativePeriodEnum; import org.hisp.dhis.period.RelativePeriods; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java index 6cbf444a3dc7..731fd32848d9 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetadataImportService.java @@ -44,15 +44,16 @@ import org.hisp.dhis.commons.timer.Timer; import org.hisp.dhis.dxf2.metadata.feedback.ImportReport; import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleCommitReport; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.feedback.Status; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; +import org.hisp.dhis.importexport.ObjectBundleResult; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.preheat.PreheatMode; import org.hisp.dhis.scheduling.JobProgress; @@ -99,11 +100,12 @@ public ImportReport importMetadata( progress.startingStage("Creating bundle"); log.info("OBP: " + bundleParams); - ObjectBundle bundle = + ObjectBundleResult bundleResult = progress.nonNullStagePostCondition( progress.runStage(() -> objectBundleService.create(bundleParams))); - log.info("OB after nonnull stage: " + (bundle != null)); + ObjectBundle bundle = (ObjectBundle) bundleResult; + progress.startingStage("Running postCreateBundle"); progress.runStage(() -> postCreateBundle(bundle, bundleParams)); diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java index 7c8978bce2e3..cdb1d2822147 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleService.java @@ -57,6 +57,11 @@ import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.feedback.TypeReport; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleFail; +import org.hisp.dhis.importexport.ObjectBundleParams; +import org.hisp.dhis.importexport.ObjectBundleResult; +import org.hisp.dhis.importexport.ObjectBundleStatus; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatParams; import org.hisp.dhis.preheat.PreheatService; @@ -93,25 +98,28 @@ public class DefaultObjectBundleService implements ObjectBundleService { @Override @Transactional(readOnly = true) - public ObjectBundle create(ObjectBundleParams params) { - PreheatParams preheatParams = params.getPreheatParams(); + public ObjectBundleResult create(ObjectBundleParams params) { + ObjectBundle bundle; + try { - User currentUser = userService.getUserByUsername(CurrentUserUtil.getCurrentUsername()); - if (params.getUser() == null) { - params.setUser(currentUser); - } + PreheatParams preheatParams = params.getPreheatParams(); - preheatParams.setUser(params.getUser()); - preheatParams.setObjects(params.getObjects()); + User currentUser = userService.getUserByUsername(CurrentUserUtil.getCurrentUsername()); + if (params.getUser() == null) { + params.setUser(currentUser); + } - Preheat preheat = preheatService.preheat(preheatParams); + preheatParams.setUser(params.getUser()); + preheatParams.setObjects(params.getObjects()); - ObjectBundle bundle = new ObjectBundle(params, preheat, params.getObjects()); - log.info("OB state 1: " + (bundle != null)); - bundle.setObjectBundleStatus(ObjectBundleStatus.CREATED); - log.info("OB state 2: " + (bundle != null)); - bundle.setObjectReferences(preheatService.collectObjectReferences(params.getObjects())); - log.info("OB state 3: " + (bundle != null)); + Preheat preheat = preheatService.preheat(preheatParams); + + bundle = new ObjectBundle(params, preheat, params.getObjects()); + bundle.setObjectBundleStatus(ObjectBundleStatus.CREATED); + bundle.setObjectReferences(preheatService.collectObjectReferences(params.getObjects())); + } catch (Exception e) { + return new ObjectBundleFail(e); + } return bundle; } diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleValidationService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleValidationService.java index 12e1e8ea2aed..607ad289e9d8 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleValidationService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/DefaultObjectBundleValidationService.java @@ -39,6 +39,8 @@ import org.hisp.dhis.dxf2.metadata.AtomicMode; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.ValidationFactory; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleStatus; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.schema.SchemaService; import org.springframework.stereotype.Service; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/EventReportCompatibilityGuard.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/EventReportCompatibilityGuard.java index aeee94a5431b..5f2d321c624b 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/EventReportCompatibilityGuard.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/EventReportCompatibilityGuard.java @@ -36,6 +36,7 @@ import java.util.Map; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.eventreport.EventReport; +import org.hisp.dhis.importexport.ObjectBundleParams; /** * This is simple class responsible for ensuring that the necessary attributes are correctly mapped diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundle.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundle.java index a8e95c64a867..c937c78c6590 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundle.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundle.java @@ -1,424 +1,426 @@ -/* - * Copyright (c) 2004-2022, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.hisp.dhis.dxf2.metadata.objectbundle; - -import static java.util.Collections.emptyList; - -import com.google.common.collect.Iterables; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.apache.commons.lang3.StringUtils; -import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.AtomicMode; -import org.hisp.dhis.dxf2.metadata.FlushMode; -import org.hisp.dhis.dxf2.metadata.UserOverrideMode; -import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; -import org.hisp.dhis.feedback.ObjectIndexProvider; -import org.hisp.dhis.feedback.TypedIndexedObjectContainer; -import org.hisp.dhis.hibernate.HibernateProxyUtils; -import org.hisp.dhis.importexport.ImportStrategy; -import org.hisp.dhis.preheat.Preheat; -import org.hisp.dhis.preheat.PreheatIdentifier; -import org.hisp.dhis.preheat.PreheatMode; -import org.hisp.dhis.user.User; - -/** - * @author Morten Olav Hansen - */ -public class ObjectBundle implements ObjectIndexProvider { - /** User to use for import job (important for threaded imports). */ - private final User user; - - /** - * How should the user property be handled, by default it is left as is. You can override this to - * use current user, or a selected user instead (not yet supported). - */ - private final UserOverrideMode userOverrideMode; - - /** User to use for override, can be current or a selected user. */ - private User overrideUser; - - /** Should import be imported or just validated. */ - private final ObjectBundleMode objectBundleMode; - - /** What identifiers to match on. */ - private final PreheatIdentifier preheatIdentifier; - - /** Preheat mode to use (default is REFERENCE and should not be changed). */ - private final PreheatMode preheatMode; - - /** Sets import strategy (create, update, etc). */ - private final ImportStrategy importMode; - - /** Adjust hows objects imported should be reported (all objects, only errors etc) */ - private final ImportReportMode importReportMode; - - /** Should import be treated as a atomic import (all or nothing). */ - private final AtomicMode atomicMode; - - /** Flush for every object or per type. */ - private final FlushMode flushMode; - - /** Internal preheat bundle. */ - private final Preheat preheat; - - /** Should sharing be considered when importing objects. */ - private final boolean skipSharing; - - /** Should translation be considered when importing objects. */ - private final boolean skipTranslation; - - /** Skip validation of objects (not recommended). */ - private final boolean skipValidation; - - /** Is this import request from MetadataSync service; */ - private final boolean metadataSyncImport; - - /** Current status of object bundle. */ - private ObjectBundleStatus objectBundleStatus = ObjectBundleStatus.CREATED; - - /** Objects to import. */ - private final Map, List> - persistedObjects = new HashMap<>(); - - private final Map, List> - nonPersistedObjects = new HashMap<>(); - - /** Contains the indexes of the objects to be imported grouped by their type. */ - private final TypedIndexedObjectContainer typedIndexedObjectContainer = - new TypedIndexedObjectContainer(); - - /** Pre-scanned map of all object references (mainly used for object book hundle). */ - private Map, Map>> objectReferences = new HashMap<>(); - - /** - * Simple class => uid => object map to store extra info about an object. Especially useful for - * object hooks as they can be working on more than one object at a time, and needs to be - * stateless. - */ - private Map, Map>> extras = new HashMap<>(); - - public ObjectBundle( - ObjectBundleParams params, - Preheat preheat, - Map, List> objectMap) { - this.user = params.getUser(); - this.userOverrideMode = params.getUserOverrideMode(); - this.overrideUser = params.getOverrideUser(); - this.objectBundleMode = params.getObjectBundleMode(); - this.preheatIdentifier = params.getPreheatIdentifier(); - this.importMode = params.getImportStrategy(); - this.importReportMode = params.getImportReportMode(); - this.atomicMode = params.getAtomicMode(); - this.preheatMode = params.getPreheatMode(); - this.flushMode = params.getFlushMode(); - this.skipSharing = params.isSkipSharing(); - this.skipTranslation = params.isSkipTranslation(); - this.skipValidation = params.isSkipValidation(); - this.preheat = preheat; - this.metadataSyncImport = params.isMetadataSyncImport(); - - addObject(objectMap); - } - - public User getUser() { - return user; - } - - public UserOverrideMode getUserOverrideMode() { - return userOverrideMode; - } - - public User getOverrideUser() { - return overrideUser; - } - - public void setOverrideUser(User overrideUser) { - this.overrideUser = overrideUser; - } - - public String getUsername() { - return user != null ? user.getUsername() : "system-process"; - } - - public ObjectBundleMode getObjectBundleMode() { - return objectBundleMode; - } - - public PreheatIdentifier getPreheatIdentifier() { - return preheatIdentifier; - } - - public PreheatMode getPreheatMode() { - return preheatMode; - } - - public ImportStrategy getImportMode() { - return importMode; - } - - public ImportReportMode getImportReportMode() { - return importReportMode; - } - - public AtomicMode getAtomicMode() { - return atomicMode; - } - - public FlushMode getFlushMode() { - return flushMode; - } - - public boolean isSkipSharing() { - return skipSharing; - } - - public boolean isSkipTranslation() { - return skipTranslation; - } - - public boolean isSkipValidation() { - return skipValidation; - } - - public boolean isMetadataSyncImport() { - return metadataSyncImport; - } - - public ObjectBundleStatus getObjectBundleStatus() { - return objectBundleStatus; - } - - public void setObjectBundleStatus(ObjectBundleStatus objectBundleStatus) { - this.objectBundleStatus = objectBundleStatus; - } - - public Preheat getPreheat() { - return preheat; - } - - @Nonnull - @Override - public Integer mergeObjectIndex(@Nonnull IdentifiableObject object) { - return typedIndexedObjectContainer.mergeObjectIndex(object); - } - - /** - * Returns if the object bundle container contains the specified object. - * - * @param object the object that should be checked. - * @return true if this object container contains the specified object, false - * otherwise. - */ - public boolean containsObject(@Nullable IdentifiableObject object) { - if (object == null) { - return false; - } - return typedIndexedObjectContainer.containsObject(object); - } - - @SuppressWarnings({"unchecked"}) - private void addObject(IdentifiableObject object) { - if (object == null) { - return; - } - - Class realClass = HibernateProxyUtils.getRealClass(object); - - if (isPersisted(object)) { - persistedObjects.computeIfAbsent(realClass, key -> new ArrayList<>()).add(object); - } else { - nonPersistedObjects.computeIfAbsent(realClass, key -> new ArrayList<>()).add(object); - } - - typedIndexedObjectContainer.add(object); - } - - private void addObject(List objects) { - objects.forEach(this::addObject); - } - - private void addObject( - Map, List> objects) { - objects.values().forEach(this::addObject); - } - - public void forEach(Consumer objectConsumer) { - persistedObjects.values().forEach(list -> list.forEach(objectConsumer)); - nonPersistedObjects.values().forEach(list -> list.forEach(objectConsumer)); - } - - public boolean hasObjects(Class klass) { - return persistedObjects.containsKey(klass) || nonPersistedObjects.containsKey(klass); - } - - public int getObjectsCount(Class klass) { - List none = emptyList(); - return persistedObjects.getOrDefault(klass, none).size() - + nonPersistedObjects.getOrDefault(klass, none).size(); - } - - @SuppressWarnings("unchecked") - public Iterable getObjects(Class klass) { - List persistedObjectsOfType = persistedObjects.get(klass); - if (persistedObjectsOfType == null || persistedObjectsOfType.isEmpty()) { - return (Iterable) nonPersistedObjects.getOrDefault(klass, emptyList()); - } - List nonPersistedObjectsOfType = nonPersistedObjects.get(klass); - if (nonPersistedObjectsOfType == null || nonPersistedObjectsOfType.isEmpty()) { - return (Iterable) persistedObjectsOfType; - } - return (Iterable) Iterables.concat(persistedObjectsOfType, nonPersistedObjectsOfType); - } - - public Map, List> getObjects( - boolean persisted) { - return persisted ? persistedObjects : nonPersistedObjects; - } - - @SuppressWarnings("unchecked") - public List getObjects(Class klass, boolean persisted) { - List identifiableObjects = null; - - if (persisted) { - if (persistedObjects.containsKey(klass)) { - identifiableObjects = (List) persistedObjects.get(klass); - } - } else { - if (nonPersistedObjects.containsKey(klass)) { - identifiableObjects = (List) nonPersistedObjects.get(klass); - } - } - - return identifiableObjects != null ? identifiableObjects : emptyList(); - } - - public Map> getObjectReferences(Class klass) { - return objectReferences.get(klass); - } - - public Map, Map>> getObjectReferences() { - return objectReferences; - } - - public void setObjectReferences( - Map, Map>> objectReferences) { - this.objectReferences = objectReferences; - } - - @SuppressWarnings({"unchecked"}) - public void putExtras(IdentifiableObject identifiableObject, String key, Object object) { - if (identifiableObject == null - || StringUtils.isEmpty(identifiableObject.getUid()) - || object == null) { - return; - } - - Class realClass = - HibernateProxyUtils.getRealClass(identifiableObject); - - extras.computeIfAbsent(realClass, k -> new HashMap<>()); - - extras - .get(realClass) - .computeIfAbsent(identifiableObject.getUid(), s -> new HashMap<>()) - .put(key, object); - } - - @SuppressWarnings({"unchecked"}) - public Object getExtras(IdentifiableObject identifiableObject, String key) { - if (identifiableObject == null || StringUtils.isEmpty(identifiableObject.getUid())) { - return null; - } - - Class realClass = - HibernateProxyUtils.getRealClass(identifiableObject); - - if (!extras.containsKey(realClass)) { - return null; - } - - if (!extras.get(realClass).containsKey(identifiableObject.getUid())) { - return null; - } - - return extras.get(realClass).get(identifiableObject.getUid()).get(key); - } - - @SuppressWarnings({"unchecked"}) - public boolean hasExtras(IdentifiableObject identifiableObject, String key) { - if (identifiableObject == null || StringUtils.isEmpty(identifiableObject.getUid())) { - return false; - } - - Class realClass = - HibernateProxyUtils.getRealClass(identifiableObject); - - if (!extras.containsKey(realClass)) { - return false; - } - - if (!extras.get(realClass).containsKey(identifiableObject.getUid())) { - return false; - } - - return extras.get(realClass).get(identifiableObject.getUid()).containsKey(key); - } - - @SuppressWarnings({"unchecked"}) - public void removeExtras(IdentifiableObject identifiableObject, String key) { - if (identifiableObject == null - || StringUtils.isEmpty(identifiableObject.getUid()) - || !hasExtras(identifiableObject, key)) { - return; - } - - Class realClass = - HibernateProxyUtils.getRealClass(identifiableObject); - - extras.get(realClass).get(identifiableObject.getUid()).remove(key); - - if (extras.get(realClass).get(identifiableObject.getUid()).isEmpty()) { - extras.get(realClass).remove(identifiableObject.getUid()); - } - - if (extras.get(realClass).isEmpty()) { - extras.remove(realClass); - } - } - - public boolean isPersisted(IdentifiableObject object) { - IdentifiableObject cachedObject = preheat.get(preheatIdentifier, object); - return !(cachedObject == null || cachedObject.getId() == 0); - } -} +/// * +// * Copyright (c) 2004-2022, University of Oslo +// * All rights reserved. +// * +// * Redistribution and use in source and binary forms, with or without +// * modification, are permitted provided that the following conditions are met: +// * Redistributions of source code must retain the above copyright notice, this +// * list of conditions and the following disclaimer. +// * +// * Redistributions in binary form must reproduce the above copyright notice, +// * this list of conditions and the following disclaimer in the documentation +// * and/or other materials provided with the distribution. +// * Neither the name of the HISP project nor the names of its contributors may +// * be used to endorse or promote products derived from this software without +// * specific prior written permission. +// * +// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +// * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// */ +// package org.hisp.dhis.dxf2.metadata.objectbundle; +// +// import static java.util.Collections.emptyList; +// +// import com.google.common.collect.Iterables; +// import java.util.ArrayList; +// import java.util.HashMap; +// import java.util.List; +// import java.util.Map; +// import java.util.function.Consumer; +// import javax.annotation.Nonnull; +// import javax.annotation.Nullable; +// import org.apache.commons.lang3.StringUtils; +// import org.hisp.dhis.common.IdentifiableObject; +// import org.hisp.dhis.dxf2.metadata.AtomicMode; +// import org.hisp.dhis.dxf2.metadata.FlushMode; +// import org.hisp.dhis.dxf2.metadata.UserOverrideMode; +// import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; +// import org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.ObjectBundleResult; +// import org.hisp.dhis.feedback.ObjectIndexProvider; +// import org.hisp.dhis.feedback.TypedIndexedObjectContainer; +// import org.hisp.dhis.hibernate.HibernateProxyUtils; +// import org.hisp.dhis.importexport.ImportStrategy; +// import org.hisp.dhis.preheat.Preheat; +// import org.hisp.dhis.preheat.PreheatIdentifier; +// import org.hisp.dhis.preheat.PreheatMode; +// import org.hisp.dhis.user.User; +// +/// ** +// * @author Morten Olav Hansen +// */ +// public final class ObjectBundle implements ObjectIndexProvider, ObjectBundleResult { +// /** User to use for import job (important for threaded imports). */ +// private final User user; +// +// /** +// * How should the user property be handled, by default it is left as is. You can override this +// to +// * use current user, or a selected user instead (not yet supported). +// */ +// private final UserOverrideMode userOverrideMode; +// +// /** User to use for override, can be current or a selected user. */ +// private User overrideUser; +// +// /** Should import be imported or just validated. */ +// private final ObjectBundleMode objectBundleMode; +// +// /** What identifiers to match on. */ +// private final PreheatIdentifier preheatIdentifier; +// +// /** Preheat mode to use (default is REFERENCE and should not be changed). */ +// private final PreheatMode preheatMode; +// +// /** Sets import strategy (create, update, etc). */ +// private final ImportStrategy importMode; +// +// /** Adjust hows objects imported should be reported (all objects, only errors etc) */ +// private final ImportReportMode importReportMode; +// +// /** Should import be treated as a atomic import (all or nothing). */ +// private final AtomicMode atomicMode; +// +// /** Flush for every object or per type. */ +// private final FlushMode flushMode; +// +// /** Internal preheat bundle. */ +// private final Preheat preheat; +// +// /** Should sharing be considered when importing objects. */ +// private final boolean skipSharing; +// +// /** Should translation be considered when importing objects. */ +// private final boolean skipTranslation; +// +// /** Skip validation of objects (not recommended). */ +// private final boolean skipValidation; +// +// /** Is this import request from MetadataSync service; */ +// private final boolean metadataSyncImport; +// +// /** Current status of object bundle. */ +// private ObjectBundleStatus objectBundleStatus = ObjectBundleStatus.CREATED; +// +// /** Objects to import. */ +// private final Map, List> +// persistedObjects = new HashMap<>(); +// +// private final Map, List> +// nonPersistedObjects = new HashMap<>(); +// +// /** Contains the indexes of the objects to be imported grouped by their type. */ +// private final TypedIndexedObjectContainer typedIndexedObjectContainer = +// new TypedIndexedObjectContainer(); +// +// /** Pre-scanned map of all object references (mainly used for object book hundle). */ +// private Map, Map>> objectReferences = new HashMap<>(); +// +// /** +// * Simple class => uid => object map to store extra info about an object. Especially useful for +// * object hooks as they can be working on more than one object at a time, and needs to be +// * stateless. +// */ +// private Map, Map>> extras = new HashMap<>(); +// +// public ObjectBundle( +// ObjectBundleParams params, +// Preheat preheat, +// Map, List> objectMap) { +// this.user = params.getUser(); +// this.userOverrideMode = params.getUserOverrideMode(); +// this.overrideUser = params.getOverrideUser(); +// this.objectBundleMode = params.getObjectBundleMode(); +// this.preheatIdentifier = params.getPreheatIdentifier(); +// this.importMode = params.getImportStrategy(); +// this.importReportMode = params.getImportReportMode(); +// this.atomicMode = params.getAtomicMode(); +// this.preheatMode = params.getPreheatMode(); +// this.flushMode = params.getFlushMode(); +// this.skipSharing = params.isSkipSharing(); +// this.skipTranslation = params.isSkipTranslation(); +// this.skipValidation = params.isSkipValidation(); +// this.preheat = preheat; +// this.metadataSyncImport = params.isMetadataSyncImport(); +// +// addObject(objectMap); +// } +// +// public User getUser() { +// return user; +// } +// +// public UserOverrideMode getUserOverrideMode() { +// return userOverrideMode; +// } +// +// public User getOverrideUser() { +// return overrideUser; +// } +// +// public void setOverrideUser(User overrideUser) { +// this.overrideUser = overrideUser; +// } +// +// public String getUsername() { +// return user != null ? user.getUsername() : "system-process"; +// } +// +// public ObjectBundleMode getObjectBundleMode() { +// return objectBundleMode; +// } +// +// public PreheatIdentifier getPreheatIdentifier() { +// return preheatIdentifier; +// } +// +// public PreheatMode getPreheatMode() { +// return preheatMode; +// } +// +// public ImportStrategy getImportMode() { +// return importMode; +// } +// +// public ImportReportMode getImportReportMode() { +// return importReportMode; +// } +// +// public AtomicMode getAtomicMode() { +// return atomicMode; +// } +// +// public FlushMode getFlushMode() { +// return flushMode; +// } +// +// public boolean isSkipSharing() { +// return skipSharing; +// } +// +// public boolean isSkipTranslation() { +// return skipTranslation; +// } +// +// public boolean isSkipValidation() { +// return skipValidation; +// } +// +// public boolean isMetadataSyncImport() { +// return metadataSyncImport; +// } +// +// public ObjectBundleStatus getObjectBundleStatus() { +// return objectBundleStatus; +// } +// +// public void setObjectBundleStatus(ObjectBundleStatus objectBundleStatus) { +// this.objectBundleStatus = objectBundleStatus; +// } +// +// public Preheat getPreheat() { +// return preheat; +// } +// +// @Nonnull +// @Override +// public Integer mergeObjectIndex(@Nonnull IdentifiableObject object) { +// return typedIndexedObjectContainer.mergeObjectIndex(object); +// } +// +// /** +// * Returns if the object bundle container contains the specified object. +// * +// * @param object the object that should be checked. +// * @return true if this object container contains the specified object, false +// * otherwise. +// */ +// public boolean containsObject(@Nullable IdentifiableObject object) { +// if (object == null) { +// return false; +// } +// return typedIndexedObjectContainer.containsObject(object); +// } +// +// @SuppressWarnings({"unchecked"}) +// private void addObject(IdentifiableObject object) { +// if (object == null) { +// return; +// } +// +// Class realClass = HibernateProxyUtils.getRealClass(object); +// +// if (isPersisted(object)) { +// persistedObjects.computeIfAbsent(realClass, key -> new ArrayList<>()).add(object); +// } else { +// nonPersistedObjects.computeIfAbsent(realClass, key -> new ArrayList<>()).add(object); +// } +// +// typedIndexedObjectContainer.add(object); +// } +// +// private void addObject(List objects) { +// objects.forEach(this::addObject); +// } +// +// private void addObject( +// Map, List> objects) { +// objects.values().forEach(this::addObject); +// } +// +// public void forEach(Consumer objectConsumer) { +// persistedObjects.values().forEach(list -> list.forEach(objectConsumer)); +// nonPersistedObjects.values().forEach(list -> list.forEach(objectConsumer)); +// } +// +// public boolean hasObjects(Class klass) { +// return persistedObjects.containsKey(klass) || nonPersistedObjects.containsKey(klass); +// } +// +// public int getObjectsCount(Class klass) { +// List none = emptyList(); +// return persistedObjects.getOrDefault(klass, none).size() +// + nonPersistedObjects.getOrDefault(klass, none).size(); +// } +// +// @SuppressWarnings("unchecked") +// public Iterable getObjects(Class klass) { +// List persistedObjectsOfType = persistedObjects.get(klass); +// if (persistedObjectsOfType == null || persistedObjectsOfType.isEmpty()) { +// return (Iterable) nonPersistedObjects.getOrDefault(klass, emptyList()); +// } +// List nonPersistedObjectsOfType = nonPersistedObjects.get(klass); +// if (nonPersistedObjectsOfType == null || nonPersistedObjectsOfType.isEmpty()) { +// return (Iterable) persistedObjectsOfType; +// } +// return (Iterable) Iterables.concat(persistedObjectsOfType, nonPersistedObjectsOfType); +// } +// +// public Map, List> getObjects( +// boolean persisted) { +// return persisted ? persistedObjects : nonPersistedObjects; +// } +// +// @SuppressWarnings("unchecked") +// public List getObjects(Class klass, boolean persisted) { +// List identifiableObjects = null; +// +// if (persisted) { +// if (persistedObjects.containsKey(klass)) { +// identifiableObjects = (List) persistedObjects.get(klass); +// } +// } else { +// if (nonPersistedObjects.containsKey(klass)) { +// identifiableObjects = (List) nonPersistedObjects.get(klass); +// } +// } +// +// return identifiableObjects != null ? identifiableObjects : emptyList(); +// } +// +// public Map> getObjectReferences(Class klass) { +// return objectReferences.get(klass); +// } +// +// public Map, Map>> getObjectReferences() { +// return objectReferences; +// } +// +// public void setObjectReferences( +// Map, Map>> objectReferences) { +// this.objectReferences = objectReferences; +// } +// +// @SuppressWarnings({"unchecked"}) +// public void putExtras(IdentifiableObject identifiableObject, String key, Object object) { +// if (identifiableObject == null +// || StringUtils.isEmpty(identifiableObject.getUid()) +// || object == null) { +// return; +// } +// +// Class realClass = +// HibernateProxyUtils.getRealClass(identifiableObject); +// +// extras.computeIfAbsent(realClass, k -> new HashMap<>()); +// +// extras +// .get(realClass) +// .computeIfAbsent(identifiableObject.getUid(), s -> new HashMap<>()) +// .put(key, object); +// } +// +// @SuppressWarnings({"unchecked"}) +// public Object getExtras(IdentifiableObject identifiableObject, String key) { +// if (identifiableObject == null || StringUtils.isEmpty(identifiableObject.getUid())) { +// return null; +// } +// +// Class realClass = +// HibernateProxyUtils.getRealClass(identifiableObject); +// +// if (!extras.containsKey(realClass)) { +// return null; +// } +// +// if (!extras.get(realClass).containsKey(identifiableObject.getUid())) { +// return null; +// } +// +// return extras.get(realClass).get(identifiableObject.getUid()).get(key); +// } +// +// @SuppressWarnings({"unchecked"}) +// public boolean hasExtras(IdentifiableObject identifiableObject, String key) { +// if (identifiableObject == null || StringUtils.isEmpty(identifiableObject.getUid())) { +// return false; +// } +// +// Class realClass = +// HibernateProxyUtils.getRealClass(identifiableObject); +// +// if (!extras.containsKey(realClass)) { +// return false; +// } +// +// if (!extras.get(realClass).containsKey(identifiableObject.getUid())) { +// return false; +// } +// +// return extras.get(realClass).get(identifiableObject.getUid()).containsKey(key); +// } +// +// @SuppressWarnings({"unchecked"}) +// public void removeExtras(IdentifiableObject identifiableObject, String key) { +// if (identifiableObject == null +// || StringUtils.isEmpty(identifiableObject.getUid()) +// || !hasExtras(identifiableObject, key)) { +// return; +// } +// +// Class realClass = +// HibernateProxyUtils.getRealClass(identifiableObject); +// +// extras.get(realClass).get(identifiableObject.getUid()).remove(key); +// +// if (extras.get(realClass).get(identifiableObject.getUid()).isEmpty()) { +// extras.get(realClass).remove(identifiableObject.getUid()); +// } +// +// if (extras.get(realClass).isEmpty()) { +// extras.remove(realClass); +// } +// } +// +// public boolean isPersisted(IdentifiableObject object) { +// IdentifiableObject cachedObject = preheat.get(preheatIdentifier, object); +// return !(cachedObject == null || cachedObject.getId() == 0); +// } +// } diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleHook.java index c88f37a161ae..9f39a1fa1c88 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleHook.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; /** * Contains hooks for object bundle commit phase. diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleParams.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleParams.java index ab8ecf1b4c95..94118db14dc7 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleParams.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleParams.java @@ -1,125 +1,125 @@ -/* - * Copyright (c) 2004-2022, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.hisp.dhis.dxf2.metadata.objectbundle; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import lombok.experimental.Accessors; -import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.AtomicMode; -import org.hisp.dhis.dxf2.metadata.FlushMode; -import org.hisp.dhis.dxf2.metadata.UserOverrideMode; -import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; -import org.hisp.dhis.hibernate.HibernateProxyUtils; -import org.hisp.dhis.importexport.ImportStrategy; -import org.hisp.dhis.preheat.PreheatIdentifier; -import org.hisp.dhis.preheat.PreheatMode; -import org.hisp.dhis.preheat.PreheatParams; -import org.hisp.dhis.user.User; - -/** - * @author Morten Olav Hansen - */ -@Getter -@Setter -@Accessors(chain = true) -@ToString -public class ObjectBundleParams { - - @ToString.Exclude private User user; - - @ToString.Exclude private User overrideUser; - - @ToString.Exclude - private Map, List> objects = - new HashMap<>(); - - private UserOverrideMode userOverrideMode = UserOverrideMode.NONE; - private ObjectBundleMode objectBundleMode = ObjectBundleMode.COMMIT; - private PreheatIdentifier preheatIdentifier = PreheatIdentifier.UID; - private PreheatMode preheatMode = PreheatMode.REFERENCE; - private ImportStrategy importStrategy = ImportStrategy.CREATE_AND_UPDATE; - private AtomicMode atomicMode = AtomicMode.ALL; - private FlushMode flushMode = FlushMode.AUTO; - private ImportReportMode importReportMode = ImportReportMode.ERRORS; - - private boolean skipSharing; - private boolean skipTranslation; - private boolean skipValidation; - private boolean metadataSyncImport; - - public Map, List> getObjects() { - return objects; - } - - public ObjectBundleParams setObjects( - Map, List> objects) { - this.objects = objects; - return this; - } - - public ObjectBundleParams addObject( - Class klass, IdentifiableObject object) { - if (object == null) { - return this; - } - - if (!objects.containsKey(klass)) { - objects.put(klass, new ArrayList<>()); - } - - objects.get(klass).add(object); - - return this; - } - - @SuppressWarnings({"unchecked"}) - public ObjectBundleParams addObject(IdentifiableObject object) { - if (object == null) { - return this; - } - - Class realClass = HibernateProxyUtils.getRealClass(object); - - objects.computeIfAbsent(realClass, k -> new ArrayList<>()).add(object); - - return this; - } - - public PreheatParams getPreheatParams() { - PreheatParams params = new PreheatParams(); - params.setPreheatIdentifier(preheatIdentifier); - params.setPreheatMode(preheatMode); - return params; - } -} +/// * +// * Copyright (c) 2004-2022, University of Oslo +// * All rights reserved. +// * +// * Redistribution and use in source and binary forms, with or without +// * modification, are permitted provided that the following conditions are met: +// * Redistributions of source code must retain the above copyright notice, this +// * list of conditions and the following disclaimer. +// * +// * Redistributions in binary form must reproduce the above copyright notice, +// * this list of conditions and the following disclaimer in the documentation +// * and/or other materials provided with the distribution. +// * Neither the name of the HISP project nor the names of its contributors may +// * be used to endorse or promote products derived from this software without +// * specific prior written permission. +// * +// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +// * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// */ +// package org.hisp.dhis.dxf2.metadata.objectbundle; +// +// import java.util.ArrayList; +// import java.util.HashMap; +// import java.util.List; +// import java.util.Map; +// import lombok.Getter; +// import lombok.Setter; +// import lombok.ToString; +// import lombok.experimental.Accessors; +// import org.hisp.dhis.common.IdentifiableObject; +// import org.hisp.dhis.dxf2.metadata.AtomicMode; +// import org.hisp.dhis.dxf2.metadata.FlushMode; +// import org.hisp.dhis.dxf2.metadata.UserOverrideMode; +// import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; +// import org.hisp.dhis.hibernate.HibernateProxyUtils; +// import org.hisp.dhis.importexport.ImportStrategy; +// import org.hisp.dhis.preheat.PreheatIdentifier; +// import org.hisp.dhis.preheat.PreheatMode; +// import org.hisp.dhis.preheat.PreheatParams; +// import org.hisp.dhis.user.User; +// +/// ** +// * @author Morten Olav Hansen +// */ +// @Getter +// @Setter +// @Accessors(chain = true) +// @ToString +// public class ObjectBundleParams { +// +// @ToString.Exclude private User user; +// +// @ToString.Exclude private User overrideUser; +// +// @ToString.Exclude +// private Map, List> objects = +// new HashMap<>(); +// +// private UserOverrideMode userOverrideMode = UserOverrideMode.NONE; +// private ObjectBundleMode objectBundleMode = ObjectBundleMode.COMMIT; +// private PreheatIdentifier preheatIdentifier = PreheatIdentifier.UID; +// private PreheatMode preheatMode = PreheatMode.REFERENCE; +// private ImportStrategy importStrategy = ImportStrategy.CREATE_AND_UPDATE; +// private AtomicMode atomicMode = AtomicMode.ALL; +// private FlushMode flushMode = FlushMode.AUTO; +// private ImportReportMode importReportMode = ImportReportMode.ERRORS; +// +// private boolean skipSharing; +// private boolean skipTranslation; +// private boolean skipValidation; +// private boolean metadataSyncImport; +// +// public Map, List> getObjects() { +// return objects; +// } +// +// public ObjectBundleParams setObjects( +// Map, List> objects) { +// this.objects = objects; +// return this; +// } +// +// public ObjectBundleParams addObject( +// Class klass, IdentifiableObject object) { +// if (object == null) { +// return this; +// } +// +// if (!objects.containsKey(klass)) { +// objects.put(klass, new ArrayList<>()); +// } +// +// objects.get(klass).add(object); +// +// return this; +// } +// +// @SuppressWarnings({"unchecked"}) +// public ObjectBundleParams addObject(IdentifiableObject object) { +// if (object == null) { +// return this; +// } +// +// Class realClass = HibernateProxyUtils.getRealClass(object); +// +// objects.computeIfAbsent(realClass, k -> new ArrayList<>()).add(object); +// +// return this; +// } +// +// public PreheatParams getPreheatParams() { +// PreheatParams params = new PreheatParams(); +// params.setPreheatIdentifier(preheatIdentifier); +// params.setPreheatMode(preheatMode); +// return params; +// } +// } diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleService.java index 283937e5b0d3..54033c735680 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleService.java @@ -28,6 +28,9 @@ package org.hisp.dhis.dxf2.metadata.objectbundle; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleCommitReport; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; +import org.hisp.dhis.importexport.ObjectBundleResult; import org.hisp.dhis.scheduling.JobProgress; /** @@ -40,7 +43,7 @@ public interface ObjectBundleService { * @param params Params object for this bundle. * @return Configured ObjectBundle instance */ - ObjectBundle create(ObjectBundleParams params); + ObjectBundleResult create(ObjectBundleParams params); /** * Commits objects from bundle into persistence store if bundle mode COMMIT is enabled. diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleStatus.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleStatus.java index 91c8940c675f..d20e82694482 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleStatus.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleStatus.java @@ -30,13 +30,13 @@ /** * @author Morten Olav Hansen */ -public enum ObjectBundleStatus { - /** ObjectBundle has been created but not validated or committed. */ - CREATED, - - /** ObjectBundle has been created and validated, but not yet committed. */ - VALIDATED, - - /** ObjectBundle has been created, validated and committed. */ - COMMITTED -} +// public enum ObjectBundleStatus { +// /** ObjectBundle has been created but not validated or committed. */ +// CREATED, +// +// /** ObjectBundle has been created and validated, but not yet committed. */ +// VALIDATED, +// +// /** ObjectBundle has been created, validated and committed. */ +// COMMITTED +// } diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleValidationService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleValidationService.java index 1bd70e3e8f56..ce7f38dd949b 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleValidationService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleValidationService.java @@ -28,6 +28,7 @@ package org.hisp.dhis.dxf2.metadata.objectbundle; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; +import org.hisp.dhis.importexport.ObjectBundle; /** * @author Morten Olav Hansen diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AbstractObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AbstractObjectBundleHook.java index aa2e37618e67..fe038e4bdb42 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AbstractObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AbstractObjectBundleHook.java @@ -33,9 +33,9 @@ import java.util.function.Consumer; import org.hibernate.Session; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleHook; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatService; import org.hisp.dhis.schema.MetadataMergeService; import org.hisp.dhis.schema.SchemaService; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHook.java index 4c81d40f8f41..f33b3f616bcd 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHook.java @@ -39,9 +39,9 @@ import org.hisp.dhis.dataexchange.aggregate.Api; import org.hisp.dhis.dataexchange.aggregate.SourceRequest; import org.hisp.dhis.dataexchange.aggregate.TargetType; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.jasypt.encryption.pbe.PooledPBEStringEncryptor; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticalObjectObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticalObjectObjectBundleHook.java index 7d0c7ea05d66..64c4d50d8827 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticalObjectObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticalObjectObjectBundleHook.java @@ -31,8 +31,8 @@ import org.hisp.dhis.common.AnalyticalObject; import org.hisp.dhis.common.BaseAnalyticalObject; import org.hisp.dhis.dxf2.metadata.AnalyticalObjectImportHandler; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.hibernate.HibernateProxyUtils; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.schema.Schema; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticsTableHookObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticsTableHookObjectBundleHook.java index 922b355ef5a8..636c4f5cadf0 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticsTableHookObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AnalyticsTableHookObjectBundleHook.java @@ -32,9 +32,9 @@ import lombok.AllArgsConstructor; import org.hisp.dhis.analytics.AnalyticsTableHook; import org.hisp.dhis.analytics.AnalyticsTableHookService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; @Component diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AttributeObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AttributeObjectBundleHook.java index af9a2e46d8f3..6d2aedf56474 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AttributeObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AttributeObjectBundleHook.java @@ -30,7 +30,7 @@ import lombok.AllArgsConstructor; import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.attribute.AttributeService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; @Component diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryComboObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryComboObjectBundleHook.java index 2abd8c1ca722..0f6a055d4332 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryComboObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryComboObjectBundleHook.java @@ -32,9 +32,9 @@ import org.hisp.dhis.category.CategoryCombo; import org.hisp.dhis.category.CategoryOptionCombo; import org.hisp.dhis.category.CategoryService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ConflictException; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; @Component diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryObjectBundleHook.java index 9c7acdadf3bc..179a10ea2fcf 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryObjectBundleHook.java @@ -32,9 +32,9 @@ import org.hisp.dhis.category.Category; import org.hisp.dhis.category.CategoryOptionCombo; import org.hisp.dhis.category.CategoryService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ConflictException; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; @Component diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryOptionComboObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryOptionComboObjectBundleHook.java index 759ffd22ca2c..6c2b0cef3ead 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryOptionComboObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/CategoryOptionComboObjectBundleHook.java @@ -32,10 +32,10 @@ import org.hisp.dhis.category.CategoryCombo; import org.hisp.dhis.category.CategoryOptionCombo; import org.hisp.dhis.category.CategoryService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ConflictException; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; @Component diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataElementObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataElementObjectBundleHook.java index 91dcb119acc4..cd9cfdfe12b2 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataElementObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataElementObjectBundleHook.java @@ -35,9 +35,9 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.textpattern.TextPatternParser; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataInputPeriodObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataInputPeriodObjectBundleHook.java index 51fa29046e91..7903c2af4580 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataInputPeriodObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataInputPeriodObjectBundleHook.java @@ -29,7 +29,7 @@ import lombok.AllArgsConstructor; import org.hisp.dhis.dataset.DataInputPeriod; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataSetObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataSetObjectBundleHook.java index b63ff14b9d8f..b10ace42f8e7 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataSetObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DataSetObjectBundleHook.java @@ -37,9 +37,9 @@ import org.hisp.dhis.dataset.DataInputPeriod; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.Section; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.util.ObjectUtils; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DocumentObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DocumentObjectBundleHook.java index 505aaf10aec1..bd1aec031551 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DocumentObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/DocumentObjectBundleHook.java @@ -32,12 +32,12 @@ import lombok.AllArgsConstructor; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.document.Document; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.fileresource.FileResource; import org.hisp.dhis.fileresource.FileResourceDomain; import org.hisp.dhis.fileresource.FileResourceService; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectObjectBundleHook.java index 8c278ffe5410..a24633786f96 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectObjectBundleHook.java @@ -34,9 +34,9 @@ import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.dxf2.metadata.DefaultAnalyticalObjectImportHandler; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.hibernate.HibernateProxyUtils; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.schema.Property; import org.hisp.dhis.schema.PropertyType; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EventHookObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EventHookObjectBundleHook.java index 77c850cec5d7..ced42228cf2b 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EventHookObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EventHookObjectBundleHook.java @@ -29,10 +29,10 @@ import java.util.List; import lombok.AllArgsConstructor; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.eventhook.EventHook; import org.hisp.dhis.eventhook.EventHookSecretManager; import org.hisp.dhis.eventhook.ReloadEventHookListeners; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ExpressionDimensionItemObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ExpressionDimensionItemObjectBundleHook.java index 0a938b0aa32b..12ab90eba663 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ExpressionDimensionItemObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ExpressionDimensionItemObjectBundleHook.java @@ -30,10 +30,10 @@ import java.util.function.Consumer; import lombok.AllArgsConstructor; import org.hisp.dhis.dxf2.expressiondimensionitem.ExpressionDimensionItemService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.expressiondimensionitem.ExpressionDimensionItem; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.security.acl.AclService; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/IdentifiableObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/IdentifiableObjectBundleHook.java index fccb2aa89ab9..519ceadd26ea 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/IdentifiableObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/IdentifiableObjectBundleHook.java @@ -36,8 +36,8 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectUtils; import org.hisp.dhis.common.SortableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.hibernate.HibernateProxyUtils; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.schema.Property; import org.hisp.dhis.schema.Schema; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/JobConfigurationObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/JobConfigurationObjectBundleHook.java index 548dc2db5e71..a8c226aadd78 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/JobConfigurationObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/JobConfigurationObjectBundleHook.java @@ -38,9 +38,9 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.hisp.dhis.commons.util.DebugUtils; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.scheduling.JobConfiguration; import org.hisp.dhis.scheduling.JobConfigurationService; import org.hisp.dhis.scheduling.JobParameters; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHook.java index 5ffac1735b54..0ac98d654306 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHook.java @@ -30,10 +30,10 @@ import java.util.function.Consumer; import lombok.AllArgsConstructor; import org.apache.commons.lang3.ObjectUtils; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorMessage; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.option.Option; import org.hisp.dhis.option.OptionService; import org.hisp.dhis.option.OptionSet; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionSetObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionSetObjectBundleHook.java index 31393d0b9ad7..12b585fe991f 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionSetObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionSetObjectBundleHook.java @@ -28,7 +28,7 @@ package org.hisp.dhis.dxf2.metadata.objectbundle.hooks; import java.util.Objects; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.option.OptionSet; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OrganisationUnitObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OrganisationUnitObjectBundleHook.java index 78245d6c75f0..94b0bb41a838 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OrganisationUnitObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OrganisationUnitObjectBundleHook.java @@ -32,9 +32,9 @@ import java.util.Objects; import java.util.function.Consumer; import lombok.AllArgsConstructor; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitParentCountComparator; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PeriodTypeObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PeriodTypeObjectBundleHook.java index 5af2d7c140d4..7e90b6ebe2b8 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PeriodTypeObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PeriodTypeObjectBundleHook.java @@ -29,8 +29,8 @@ import lombok.AllArgsConstructor; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.hibernate.HibernateProxyUtils; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.schema.Property; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PredictorObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PredictorObjectBundleHook.java index a305864f6ab6..c53085aa2fee 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PredictorObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/PredictorObjectBundleHook.java @@ -27,8 +27,8 @@ */ package org.hisp.dhis.dxf2.metadata.objectbundle.hooks; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.expression.Expression; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.predictor.Predictor; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramNotificationTemplateObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramNotificationTemplateObjectBundleHook.java index 6da9e4da6389..9fdfb1fbd0d1 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramNotificationTemplateObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramNotificationTemplateObjectBundleHook.java @@ -33,7 +33,7 @@ import java.util.function.Function; import org.hisp.dhis.common.DeliveryChannel; import org.hisp.dhis.common.ValueType; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.notification.ProgramNotificationRecipient; import org.hisp.dhis.program.notification.ProgramNotificationTemplate; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramObjectBundleHook.java index 673fbed73f1b..3b6059622c92 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramObjectBundleHook.java @@ -32,9 +32,9 @@ import java.util.function.Consumer; import lombok.AllArgsConstructor; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.program.Enrollment; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleActionObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleActionObjectBundleHook.java index d9e6c0aa6f8d..7b9e3ba309bb 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleActionObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleActionObjectBundleHook.java @@ -31,8 +31,8 @@ import java.util.function.Consumer; import javax.annotation.Nonnull; import lombok.extern.slf4j.Slf4j; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.notification.ProgramNotificationTemplate; import org.hisp.dhis.programrule.ProgramRuleAction; import org.hisp.dhis.programrule.ProgramRuleActionType; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleObjectBundleHook.java index 3388b47065a3..08aa8e228ab4 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleObjectBundleHook.java @@ -30,9 +30,9 @@ import java.util.List; import java.util.function.Consumer; import lombok.RequiredArgsConstructor; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.Program; import org.hisp.dhis.programrule.ProgramRule; import org.hisp.dhis.programrule.ProgramRuleService; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHook.java index a7d7bbec12d8..0b331e2012fa 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHook.java @@ -39,10 +39,10 @@ import org.apache.commons.lang3.StringUtils; import org.hibernate.query.Query; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.programrule.ProgramRuleVariable; import org.hisp.dhis.programrule.ProgramRuleVariableSourceType; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageDataElementObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageDataElementObjectBundleHook.java index 12d48318d46b..1b1eff45515d 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageDataElementObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageDataElementObjectBundleHook.java @@ -29,9 +29,9 @@ import java.util.function.Consumer; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.render.DeviceRenderTypeMap; import org.hisp.dhis.render.type.ValueTypeRenderingObject; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHook.java index 615373928fa2..afe51a570937 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHook.java @@ -34,9 +34,9 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramStage; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHook.java index f078578bfa3d..284b156097a7 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHook.java @@ -38,9 +38,9 @@ import org.hisp.dhis.common.OrganisationUnitSelectionMode; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.programstagefilter.DateFilterPeriod; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramTrackedEntityAttributeObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramTrackedEntityAttributeObjectBundleHook.java index c02d99402c13..0841f4e5dfce 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramTrackedEntityAttributeObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramTrackedEntityAttributeObjectBundleHook.java @@ -28,9 +28,9 @@ package org.hisp.dhis.dxf2.metadata.objectbundle.hooks; import java.util.function.Consumer; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.render.DeviceRenderTypeMap; import org.hisp.dhis.render.type.ValueTypeRenderingObject; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RelationshipTypeObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RelationshipTypeObjectBundleHook.java index 34f783666a20..c311819f312c 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RelationshipTypeObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RelationshipTypeObjectBundleHook.java @@ -41,9 +41,9 @@ import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStage; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RouteObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RouteObjectBundleHook.java index c4c6557ac5e5..108cb4e6c67b 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RouteObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/RouteObjectBundleHook.java @@ -33,7 +33,7 @@ import org.hisp.dhis.common.auth.ApiTokenAuth; import org.hisp.dhis.common.auth.Auth; import org.hisp.dhis.common.auth.HttpBasicAuth; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.route.Route; import org.jasypt.encryption.pbe.PBEStringCleanablePasswordEncryptor; import org.springframework.beans.factory.annotation.Qualifier; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SectionObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SectionObjectBundleHook.java index a7989e4a6233..e05319655169 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SectionObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SectionObjectBundleHook.java @@ -32,7 +32,7 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataset.Section; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.util.ObjectUtils; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SmsCommandObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SmsCommandObjectBundleHook.java index bd525c52a4af..15ee6d96a83d 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SmsCommandObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SmsCommandObjectBundleHook.java @@ -33,7 +33,7 @@ import org.hisp.dhis.category.CategoryOptionCombo; import org.hisp.dhis.category.CategoryService; import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.sms.command.SMSCommand; import org.hisp.dhis.sms.command.code.SMSCode; import org.hisp.dhis.sms.parse.ParserType; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SortableObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SortableObjectBundleHook.java index 7a7ae6acc71c..043776188bd9 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SortableObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SortableObjectBundleHook.java @@ -28,7 +28,7 @@ package org.hisp.dhis.dxf2.metadata.objectbundle.hooks; import org.hisp.dhis.common.SortableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; @Component diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityAttributeObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityAttributeObjectBundleHook.java index 720cb62d881f..9cb0faeb1695 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityAttributeObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityAttributeObjectBundleHook.java @@ -30,9 +30,9 @@ import java.util.function.Consumer; import org.hisp.dhis.common.Objects; import org.hisp.dhis.common.ValueType; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.textpattern.TextPattern; import org.hisp.dhis.textpattern.TextPatternParser; import org.hisp.dhis.textpattern.TextPatternValidationUtils; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHook.java index 500f303cc67b..0a6dddc23681 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHook.java @@ -30,9 +30,9 @@ import java.util.List; import java.util.Objects; import java.util.function.Consumer; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityType; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserGroupObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserGroupObjectBundleHook.java index c1ce46b84735..912f6824844c 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserGroupObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserGroupObjectBundleHook.java @@ -27,7 +27,7 @@ */ package org.hisp.dhis.dxf2.metadata.objectbundle.hooks; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.user.UserGroup; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserObjectBundleHook.java index 952d9104ea65..2860e8f80165 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserObjectBundleHook.java @@ -37,7 +37,6 @@ import org.apache.commons.lang3.StringUtils; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.adapter.BaseIdentifiableObject_; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.external.conf.ConfigurationKey; import org.hisp.dhis.external.conf.DhisConfigurationProvider; import org.hisp.dhis.feedback.BadRequestException; @@ -47,6 +46,7 @@ import org.hisp.dhis.feedback.NotFoundException; import org.hisp.dhis.fileresource.FileResource; import org.hisp.dhis.fileresource.FileResourceService; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.security.acl.AclService; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserRoleBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserRoleBundleHook.java index 4b94f396b1fc..817ca05e33c1 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserRoleBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/UserRoleBundleHook.java @@ -31,7 +31,7 @@ import java.util.Set; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.user.User; import org.hisp.dhis.user.UserRole; import org.hisp.dhis.user.UserService; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/VersionedObjectObjectBundleHook.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/VersionedObjectObjectBundleHook.java index d83294a371e8..a068962e5268 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/VersionedObjectObjectBundleHook.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/VersionedObjectObjectBundleHook.java @@ -34,7 +34,7 @@ import org.hisp.dhis.common.VersionedObject; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.Section; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.option.Option; import org.hisp.dhis.option.OptionSet; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/CreationCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/CreationCheck.java index e16f512cbe61..67f04609f05e 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/CreationCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/CreationCheck.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DashboardCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DashboardCheck.java index abdb40bf21ce..ab8ee2612bff 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DashboardCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DashboardCheck.java @@ -37,11 +37,11 @@ import org.hisp.dhis.dashboard.DashboardItem; import org.hisp.dhis.dashboard.design.Column; import org.hisp.dhis.dashboard.design.Layout; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.security.acl.AclService; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DeletionCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DeletionCheck.java index 410e6569e76d..211bff0b0684 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DeletionCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DeletionCheck.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DuplicateIdsCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DuplicateIdsCheck.java index 88fda1831419..a47572998d12 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DuplicateIdsCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DuplicateIdsCheck.java @@ -34,11 +34,11 @@ import java.util.Map; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/GeoJsonAttributesCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/GeoJsonAttributesCheck.java index ec4fac35e797..12ecee43556e 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/GeoJsonAttributesCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/GeoJsonAttributesCheck.java @@ -56,11 +56,11 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.ValueType; import org.hisp.dhis.commons.util.DebugUtils; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.schema.Schema; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MandatoryAttributesCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MandatoryAttributesCheck.java index ff12ed78b8ba..69db3b948b80 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MandatoryAttributesCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MandatoryAttributesCheck.java @@ -37,11 +37,11 @@ import java.util.stream.Collectors; import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.schema.Schema; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MetadataAttributeCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MetadataAttributeCheck.java index e10b2e4867c0..c766b9e4d16b 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MetadataAttributeCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/MetadataAttributeCheck.java @@ -39,12 +39,12 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.ValueType; import org.hisp.dhis.common.adapter.BaseIdentifiableObject_; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.attribute.AttributeValidator; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.schema.Schema; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/NotOwnerReferencesCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/NotOwnerReferencesCheck.java index c860a7b1eb03..ef558b304435 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/NotOwnerReferencesCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/NotOwnerReferencesCheck.java @@ -36,12 +36,12 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.dxf2.metadata.AtomicMode; import org.hisp.dhis.dxf2.metadata.feedback.ImportReportMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.hibernate.HibernateProxyUtils; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatErrorReport; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.schema.Property; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ObjectValidationCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ObjectValidationCheck.java index 80908cf8c8db..febd4d42bc37 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ObjectValidationCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ObjectValidationCheck.java @@ -30,10 +30,10 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; /** * Base interface for a {@link ValidationCheck} that only checks objects and creates {@link diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ReferencesCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ReferencesCheck.java index f8bc3f892acb..239a11f03aac 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ReferencesCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ReferencesCheck.java @@ -38,12 +38,12 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.collection.CollectionUtils; import org.hisp.dhis.dxf2.metadata.AtomicMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.hibernate.HibernateProxyUtils; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.preheat.Preheat; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SchemaCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SchemaCheck.java index 84b05ad37231..c8389a0452c7 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SchemaCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SchemaCheck.java @@ -32,10 +32,10 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SecurityCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SecurityCheck.java index bae5ec1beffb..2e55aa258515 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SecurityCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/SecurityCheck.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.user.User; import org.hisp.dhis.user.UserRole; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/TranslationsCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/TranslationsCheck.java index ee702d959a2e..b289051b4928 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/TranslationsCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/TranslationsCheck.java @@ -33,11 +33,11 @@ import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.collection.CollectionUtils; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.schema.Schema; import org.hisp.dhis.translation.Translation; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UidFormatCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UidFormatCheck.java index 5b4730c274b4..d12db987862e 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UidFormatCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UidFormatCheck.java @@ -33,11 +33,11 @@ import java.util.function.Consumer; import org.hisp.dhis.common.CodeGenerator; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** Validate UID format for creation of new object only. */ diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueAttributesCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueAttributesCheck.java index 0cbd38c6ab70..ffb083bad792 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueAttributesCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueAttributesCheck.java @@ -39,11 +39,11 @@ import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectUtils; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueMultiPropertiesCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueMultiPropertiesCheck.java index 527e9a3ce285..cd26a84d5c4f 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueMultiPropertiesCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniqueMultiPropertiesCheck.java @@ -39,10 +39,10 @@ import java.util.function.Function; import java.util.stream.Collectors; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.schema.Schema; import org.springframework.stereotype.Component; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniquenessCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniquenessCheck.java index 591d88f2bf7d..2d46aa7eb0da 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniquenessCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UniquenessCheck.java @@ -37,12 +37,12 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.hibernate.HibernateProxyUtils; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.schema.Property; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UpdateCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UpdateCheck.java index 31dec0fad1a3..23b54171e8a7 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UpdateCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/UpdateCheck.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationCheck.java index 9446c9fb93aa..0182c0e0540a 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationCheck.java @@ -30,9 +30,9 @@ import java.util.Collections; import java.util.List; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; /** * This interface is implemented by classes that can validate an {@see ObjectBundle} diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationFactory.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationFactory.java index 376b2e93fd28..a866b61d8db2 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationFactory.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationFactory.java @@ -30,9 +30,9 @@ import java.util.List; import lombok.AllArgsConstructor; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleHooks; import org.hisp.dhis.feedback.TypeReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.schema.SchemaService; import org.hisp.dhis.schema.validation.SchemaValidator; import org.hisp.dhis.security.acl.AclService; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationHooksCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationHooksCheck.java index 4f53f61918b1..c020ce0f2ea5 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationHooksCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationHooksCheck.java @@ -33,11 +33,11 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleHook; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; /** diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationRunner.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationRunner.java index 1ee19f7a3bd5..383f2f7d188a 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationRunner.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationRunner.java @@ -31,9 +31,9 @@ import java.util.Map; import lombok.RequiredArgsConstructor; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.springframework.stereotype.Component; @Component diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationUtils.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationUtils.java index dafb99dcdb1f..068a79b7fba1 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationUtils.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidationUtils.java @@ -34,9 +34,9 @@ import java.util.stream.Stream; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectUtils; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; +import org.hisp.dhis.importexport.ObjectBundle; /** * @author Luciano Fiandesio diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/GeoJsonAttributesCheckTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/GeoJsonAttributesCheckTest.java index a7a57ed76697..718274be1e3c 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/GeoJsonAttributesCheckTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/GeoJsonAttributesCheckTest.java @@ -39,12 +39,12 @@ import org.apache.commons.collections4.CollectionUtils; import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.common.ValueType; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.GeoJsonAttributesCheck; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.ValidationContext; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.schema.Property; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/MetadataAttributeCheckTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/MetadataAttributeCheckTest.java index b07d0158b6ed..a4be0257b64a 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/MetadataAttributeCheckTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/attribute/MetadataAttributeCheckTest.java @@ -42,7 +42,6 @@ import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.common.ValueType; import org.hisp.dhis.common.adapter.BaseIdentifiableObject_; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.MetadataAttributeCheck; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.ValidationContext; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.attribute.DefaultAttributeValidator; @@ -50,6 +49,7 @@ import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.fileresource.FileResource; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.schema.Property; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHookTest.java index fe629e16c19a..54f432baf5fc 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/AggregateDataExchangeObjectBundleHookTest.java @@ -39,9 +39,9 @@ import org.hisp.dhis.dataexchange.aggregate.Source; import org.hisp.dhis.dataexchange.aggregate.Target; import org.hisp.dhis.dataexchange.aggregate.TargetType; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java index 32686bdb7ba1..35fc7e18d7eb 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java @@ -33,10 +33,10 @@ import static org.mockito.Mockito.when; import java.util.Map; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.eventvisualization.EventRepetition; import org.hisp.dhis.eventvisualization.EventVisualization; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.program.Program; import org.hisp.dhis.schema.Property; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java index 43a88cd4be51..ed247c0eb037 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java @@ -35,10 +35,10 @@ import java.util.List; import java.util.Map; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.option.Option; import org.hisp.dhis.option.OptionService; import org.hisp.dhis.option.OptionSet; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHookTest.java index 3a6f69ce9103..414f02077e9c 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramRuleVariableObjectBundleHookTest.java @@ -40,9 +40,9 @@ import java.util.List; import org.hibernate.Session; import org.hibernate.query.Query; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.Program; import org.hisp.dhis.programrule.ProgramRuleVariable; import org.junit.jupiter.api.BeforeEach; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java index e268312a0915..0e06f937c131 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java @@ -30,10 +30,10 @@ import java.util.Collections; import java.util.List; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java index 774b8a513ef3..0424b7f4a957 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java @@ -47,9 +47,9 @@ import org.hisp.dhis.common.OrganisationUnitSelectionMode; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.ErrorReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.preheat.Preheat; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHookTest.java index 59a645f21f6f..e04aced6e100 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/TrackedEntityTypeObjectBundleHookTest.java @@ -35,7 +35,7 @@ import java.util.Arrays; import java.util.Collections; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DummyCheck.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DummyCheck.java index 8b280140a5de..a1832f020674 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DummyCheck.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/DummyCheck.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.function.Consumer; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; /** * @author Luciano Fiandesio diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java index c98fdd039e03..6b6f8c0118f6 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java @@ -39,10 +39,10 @@ import java.util.Map; import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleHooks; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.TypeReport; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.schema.SchemaService; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java index e57a0c0809a0..a4aeed08f064 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java @@ -37,13 +37,13 @@ import org.hisp.dhis.category.CategoryService; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; import org.hisp.dhis.sms.command.SMSCommand; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java index 0a10077551a5..5b08542a1c2c 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java @@ -35,7 +35,6 @@ import java.util.List; import java.util.Map; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleHooks; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.ReferencesCheck; @@ -45,6 +44,7 @@ import org.hisp.dhis.feedback.ObjectReport; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorType; import org.hisp.dhis.preheat.Preheat; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java index 652a2029bb52..d477c4f60da6 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java @@ -34,12 +34,12 @@ import java.util.Map; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; import org.hisp.dhis.test.integration.PostgresIntegrationTestBase; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerProgramRuleBundleServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerProgramRuleBundleServiceTest.java index 8bcff964ea8d..84dd523636ac 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerProgramRuleBundleServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerProgramRuleBundleServiceTest.java @@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.notification.NotificationTrigger; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java index b6128a3fa326..0ba1f8ae6286 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java @@ -37,13 +37,13 @@ import java.util.concurrent.TimeUnit; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.feedback.Assertions; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.program.notification.ProgramNotificationInstance; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java index 723b1cfdbb2a..0bec0f1775f5 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java @@ -40,8 +40,8 @@ import java.util.List; import org.hisp.dhis.common.UID; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.eventdatavalue.EventDataValue; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.program.Event; import org.hisp.dhis.program.Program; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleTest.java index 7c558d98229a..d50951e02541 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleTest.java @@ -42,7 +42,7 @@ import org.hisp.dhis.constant.Constant; import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramStage; diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java index 96f8bb02364f..7f6d9d9f7af5 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java @@ -53,7 +53,6 @@ import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.common.collection.CollectionUtils; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; @@ -62,6 +61,7 @@ import org.hisp.dhis.eventdatavalue.EventDataValue; import org.hisp.dhis.http.HttpStatus; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.jsontree.JsonList; import org.hisp.dhis.jsontree.JsonObject; import org.hisp.dhis.program.Event; diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java index 5d28ecba8ff2..8a83a83f844d 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java @@ -41,7 +41,6 @@ import java.util.Map; import java.util.function.Supplier; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; @@ -49,6 +48,7 @@ import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.http.HttpStatus; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; import org.hisp.dhis.jsontree.JsonList; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; From c4ae7dadd35ba2e04c29687078866504b26b8b22 Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 12:47:28 +0000 Subject: [PATCH 5/8] chore: add debug --- .../java/org/hisp/dhis/scheduling/RecordingJobProgress.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java index a9aa5b3ba241..9e01da50795f 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/RecordingJobProgress.java @@ -215,7 +215,7 @@ private RuntimeException cancellationException(boolean failedPostCondition) { if (skipRecording && cause instanceof RuntimeException rex) throw rex; CancellationException ex = failedPostCondition - ? new CancellationException("Non-null post-condition failed: " + cause.getMessage()) + ? new CancellationException("Non-null post-condition failed") : new CancellationException(); ex.initCause(cause); return ex; From c1a31db0b293b4f4ed083c7f53b92fb8c668b1c2 Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 13:17:02 +0000 Subject: [PATCH 6/8] chore: add debug --- .../objectbundle/ObjectBundleTest.java | 2 + .../hooks/EmbeddedObjectBundleHookTest.java | 2 +- .../hooks/OptionObjectBundleHookTest.java | 2 +- .../ProgramStageObjectBundleHookTest.java | 2 +- ...mStageWorkingListObjectBundleHookTest.java | 2 +- .../ValidatingEventCheckerTest.java | 2 +- .../e2e/actions/metadata/MetadataActions.java | 3 +- .../ObjectBundleServiceAttributesTest.java | 12 +- .../ObjectBundleServiceFavoritesTest.java | 10 +- ...jectBundleServiceImportReportModeTest.java | 6 +- .../ObjectBundleServiceProgramTest.java | 30 ++--- .../objectbundle/ObjectBundleServiceTest.java | 104 +++++++++--------- .../ObjectBundleServiceUserTest.java | 26 +++-- .../SMSCommandObjectBundleServiceTest.java | 4 +- .../validation/ReferencesCheckTest.java | 2 +- .../org/hisp/dhis/tracker/TrackerTest.java | 6 +- ...leEngineSideEffectsHandlerServiceTest.java | 4 +- .../export/IdSchemeExportControllerTest.java | 4 +- ...ackedEntitiesChangeLogsControllerTest.java | 4 +- 19 files changed, 121 insertions(+), 106 deletions(-) diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleTest.java index c59982cdf6b9..3f7787e89849 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleTest.java @@ -34,6 +34,8 @@ import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.category.Category; import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; import org.junit.jupiter.api.Assertions; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java index 35fc7e18d7eb..41823a70e560 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/EmbeddedObjectBundleHookTest.java @@ -33,10 +33,10 @@ import static org.mockito.Mockito.when; import java.util.Map; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.eventvisualization.EventRepetition; import org.hisp.dhis.eventvisualization.EventVisualization; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.program.Program; import org.hisp.dhis.schema.Property; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java index ed247c0eb037..b2f4b3cff03d 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/OptionObjectBundleHookTest.java @@ -35,10 +35,10 @@ import java.util.List; import java.util.Map; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.option.Option; import org.hisp.dhis.option.OptionService; import org.hisp.dhis.option.OptionSet; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java index 0e06f937c131..f46e55f21d52 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageObjectBundleHookTest.java @@ -30,10 +30,10 @@ import java.util.Collections; import java.util.List; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java index 0424b7f4a957..fdbef5366f99 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramStageWorkingListObjectBundleHookTest.java @@ -47,9 +47,9 @@ import org.hisp.dhis.common.OrganisationUnitSelectionMode; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.ErrorReport; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.preheat.Preheat; diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java index 6b6f8c0118f6..c85d78fbea35 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/validation/ValidatingEventCheckerTest.java @@ -40,9 +40,9 @@ import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleHooks; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.preheat.Preheat; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.schema.SchemaService; diff --git a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/MetadataActions.java b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/MetadataActions.java index ff4dd188e290..a0f6d6f7c187 100644 --- a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/MetadataActions.java +++ b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/MetadataActions.java @@ -79,7 +79,8 @@ public MetadataApiResponse importMetadataWithContentType( public MetadataApiResponse importMetadata(JsonObject object, String... queryParams) { QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder(); queryParamsBuilder.addAll(queryParams); - queryParamsBuilder.addAll("atomicMode=OBJECT", "importReportMode=FULL"); + queryParamsBuilder.addAll( + "atomicMode=OBJECT", "importReportMode=FULL", "metadataSyncImport=true"); ApiResponse response = post(object, queryParamsBuilder); response.validate().statusCode(200); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceAttributesTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceAttributesTest.java index 1a533b1e16b5..cbf6d08ec5c2 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceAttributesTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceAttributesTest.java @@ -48,6 +48,8 @@ import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.option.Option; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -95,7 +97,7 @@ void testCreateSimpleMetadataAttributeValuesUID() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle); assertFalse(validationReport.hasErrorReports()); transactionTemplate.execute( @@ -164,7 +166,7 @@ void testValidateMetadataAttributeValuesMandatory() throws IOException { ObjectBundleParams params = new ObjectBundleParams(); params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle); TypeReport typeReport = validationReport.getTypeReport(DataElement.class); assertNotNull(typeReport); @@ -183,7 +185,7 @@ void testValidateMetadataAttributeValuesMandatoryFromPayload() throws IOExceptio ObjectBundleParams params = new ObjectBundleParams(); params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle); TypeReport typeReport = validationReport.getTypeReport(DataElement.class); assertNotNull(typeReport); @@ -202,7 +204,7 @@ void testValidateMetadataAttributeValuesUnique() throws IOException { ObjectBundleParams params = new ObjectBundleParams(); params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle); TypeReport typeReport = validationReport.getTypeReport(DataElement.class); assertNotNull(typeReport); @@ -220,7 +222,7 @@ void testValidateMetadataAttributeValuesUniqueFromPayload() throws IOException { ObjectBundleParams params = new ObjectBundleParams(); params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle); assertNotNull(validationReport.getTypeReport(DataElement.class)); assertEquals( diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceFavoritesTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceFavoritesTest.java index a6cee962aba3..4f51f7beba83 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceFavoritesTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceFavoritesTest.java @@ -41,6 +41,8 @@ import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.legend.LegendSet; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.render.RenderFormat; @@ -86,7 +88,7 @@ void testCreateMetadataWithVisualization() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -138,7 +140,7 @@ void testCreateMetadataWithVisualizationsWithPeriods() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -165,7 +167,7 @@ void testCreateLegendSets() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -187,7 +189,7 @@ void testDeleteLegendSet() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceImportReportModeTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceImportReportModeTest.java index 7cccd877d72e..71f2d1a84b28 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceImportReportModeTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceImportReportModeTest.java @@ -39,6 +39,8 @@ import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; import org.hisp.dhis.test.integration.PostgresIntegrationTestBase; @@ -74,7 +76,7 @@ void testImportReportModeErrorNotOwner() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); metadata = @@ -86,7 +88,7 @@ void testImportReportModeErrorNotOwner() throws IOException { params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setImportReportMode(ImportReportMode.ERRORS_NOT_OWNER); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertTrue(validate.hasErrorReports()); assertEquals(4, validate.getErrorReportsCount()); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceProgramTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceProgramTest.java index 5fded2c97cc2..2bad7cd55bbf 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceProgramTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceProgramTest.java @@ -42,6 +42,8 @@ import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramStage; @@ -91,7 +93,7 @@ void testCreateSimpleProgramNoReg() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -128,7 +130,7 @@ void testCreateSimpleProgramWithSectionsNoReg() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -167,7 +169,7 @@ void testCreateSimpleProgramReg() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -202,7 +204,7 @@ void testProgramRuleCreation() throws IOException { params1.setObjectBundleMode(ObjectBundleMode.COMMIT); params1.setImportStrategy(ImportStrategy.CREATE); params1.setObjects(metadata1); - ObjectBundle bundle1 = objectBundleService.create(params1); + ObjectBundle bundle1 = (ObjectBundle) objectBundleService.create(params1); ObjectBundleValidationReport validate1 = objectBundleValidationService.validate(bundle1); assertTrue(validate1.hasErrorReports()); assertEquals(1, validate1.getErrorReportsCount(ErrorCode.E4057)); @@ -219,7 +221,7 @@ void testProgramRuleUpdate() throws IOException { params1.setObjectBundleMode(ObjectBundleMode.COMMIT); params1.setImportStrategy(ImportStrategy.UPDATE); params1.setObjects(metadata1); - ObjectBundle bundle1 = objectBundleService.create(params1); + ObjectBundle bundle1 = (ObjectBundle) objectBundleService.create(params1); ObjectBundleValidationReport validate1 = objectBundleValidationService.validate(bundle1); assertFalse(validate1.hasErrorReports()); } @@ -236,7 +238,7 @@ void testInvalidProgramRuleAction() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertTrue(validate.hasErrorReports()); assertTrue(validate.hasErrorReport(report -> report.getErrorCode() == ErrorCode.E4047)); @@ -254,7 +256,7 @@ void testValidProgramRuleAction() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); } @@ -269,7 +271,7 @@ void testCreateSimpleProgramRegNextScheduleDate() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -281,7 +283,7 @@ void testCreateSimpleProgramRegNextScheduleDate() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); validate = objectBundleValidationService.validate(bundle); assertTrue(validate.hasErrorReports()); } @@ -296,7 +298,7 @@ void testValidateTrackedEntityAttributeSecurityNotShared() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -325,7 +327,7 @@ void testValidateTrackedEntityAttributeSecurityNotShared() throws IOException { params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setUser(testUser); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); validate = objectBundleValidationService.validate(bundle); assertTrue(validate.hasErrorReports()); } @@ -340,7 +342,7 @@ void testValidateTrackedEntityAttributeSecurityShared() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -375,7 +377,7 @@ void testValidateTrackedEntityAttributeSecurityShared() throws IOException { params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); params.setUser(testUser); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); } @@ -390,7 +392,7 @@ private void createProgramRuleMetadata() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); validate.forEachErrorReport(errorReport -> log.error("Error report:" + errorReport)); assertFalse(validate.hasErrorReports()); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceTest.java index 4b68a1b78b41..1e61a349f571 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceTest.java @@ -60,6 +60,8 @@ import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -106,7 +108,7 @@ void setUp() { @Test void testCreateObjectBundle() { ObjectBundleParams params = new ObjectBundleParams(); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertNotNull(bundle); } @@ -117,7 +119,7 @@ void testCreateDoesPreheating() { ObjectBundleParams params = new ObjectBundleParams(); params.setPreheatMode(PreheatMode.REFERENCE); params.addObject(dataElementGroup); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertNotNull(bundle); assertFalse(bundle.getPreheat().isEmpty()); assertFalse(bundle.getPreheat().isEmpty(PreheatIdentifier.UID)); @@ -138,7 +140,7 @@ void testObjectBundleShouldAddToObjectAndPreheat() { ObjectBundleParams params = new ObjectBundleParams(); params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.addObject(dataElementGroup); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); bundle.getPreheat().put(bundle.getPreheatIdentifier(), dataElementGroup); assertTrue( StreamSupport.stream(bundle.getObjects(DataElementGroup.class).spliterator(), false) @@ -158,7 +160,7 @@ void testPreheatValidations() throws IOException { params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.isEmpty()); assertTrue(validate.hasErrorReports()); @@ -193,7 +195,7 @@ void testPreheatValidationsWithCatCombo() throws IOException { params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); } @@ -207,7 +209,7 @@ void testCreatePreheatValidationsInvalidObjects() throws IOException { params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertTrue(validate.hasErrorReports()); assertEquals(1, validate.getErrorReportsCountByCode(DataElement.class, ErrorCode.E5002)); @@ -223,7 +225,7 @@ void testUpdatePreheatValidationsInvalidObjects() throws IOException { params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertTrue(validate.hasErrorReports()); assertEquals(3, validate.getErrorReportsCountByCode(DataElement.class, ErrorCode.E5001)); @@ -239,7 +241,7 @@ void testUpdateRequiresValidReferencesUID() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.UID); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(3, validate.getTypeReport(DataElement.class).getObjectReportsCount()); } @@ -256,7 +258,7 @@ void testUpdateWithPersistedObjectsRequiresValidReferencesUID() throws IOExcepti params.setImportStrategy(ImportStrategy.UPDATE); params.setAtomicMode(NONE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCountByCode(DataElement.class, ErrorCode.E5001)); assertNotEquals(0, validate.getErrorReportsCountByCode(DataElement.class, ErrorCode.E4000)); @@ -273,7 +275,7 @@ void testUpdateRequiresValidReferencesCODE() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.CODE); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertTrue(validate.getTypeReport(DataElement.class).hasObjectReports()); assertEquals(3, validate.getErrorReportsCountByCode(DataElement.class, ErrorCode.E5001)); @@ -289,7 +291,7 @@ void testDeleteRequiresValidReferencesUID() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.UID); params.setImportStrategy(ImportStrategy.DELETE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertTrue(validate.getTypeReport(DataElement.class).hasObjectReports()); assertEquals(3, validate.getErrorReportsCountByCode(DataElement.class, ErrorCode.E5001)); @@ -305,7 +307,7 @@ void testDeleteRequiresValidReferencesCODE() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.CODE); params.setImportStrategy(ImportStrategy.DELETE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertTrue(validate.getTypeReport(DataElement.class).hasObjectReports()); assertEquals(3, validate.getErrorReportsCountByCode(DataElement.class, ErrorCode.E5001)); @@ -320,7 +322,7 @@ void testPreheatValidationsIncludingMerge() throws IOException { ObjectBundleParams params = new ObjectBundleParams(); params.setObjectBundleMode(ObjectBundleMode.VALIDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertNotNull(validate); } @@ -336,7 +338,7 @@ void testSimpleDataElementDeleteUID() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.DELETE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); List dataElements = manager.getAll(DataElement.class); @@ -356,7 +358,7 @@ void testSimpleDataElementDeleteCODE() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.CODE); params.setImportStrategy(ImportStrategy.DELETE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); List dataElements = manager.getAll(DataElement.class); @@ -373,7 +375,7 @@ void testCreateSimpleMetadataUID() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); List organisationUnits = manager.getAll(OrganisationUnit.class); @@ -417,7 +419,7 @@ void testCreateDataSetsWithUgaUID() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); List organisationUnits = manager.getAll(OrganisationUnit.class); @@ -444,7 +446,7 @@ void testCreateAndUpdateDataSetsWithUgaUID() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -456,7 +458,7 @@ void testCreateAndUpdateDataSetsWithUgaUID() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -489,7 +491,7 @@ void testUpdateDataElementsUID() throws IOException { UserGroup userGroup = manager.get(UserGroup.class, "ugabcdefghA"); assertEquals(4, dataElementMap.size()); assertNotNull(userGroup); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); DataElement dataElementA = dataElementMap.get("deabcdefghA"); @@ -537,7 +539,7 @@ void testUpdateDataElementsCODE() throws IOException { UserGroup userGroup = manager.get(UserGroup.class, "ugabcdefghA"); assertEquals(4, dataElementMap.size()); assertNotNull(userGroup); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); DataElement dataElementA = dataElementMap.get("deabcdefghA"); @@ -580,7 +582,7 @@ void testCreateDataSetWithSections() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -617,7 +619,7 @@ void testCreateDataSetWithSectionsAndGreyedFields() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -672,7 +674,7 @@ void testUpdateDataSetWithSectionsAndGreyedFields() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -696,7 +698,7 @@ void testUpdateDataSetWithSectionsAndGreyedFields() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); DataElement dataElement = manager.get(DataElement.class, "nHwIqKAudKN"); assertNotNull(dataElement); validate = objectBundleValidationService.validate(bundle); @@ -757,7 +759,7 @@ void testCreateDataSetNoDSEDefaults() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -779,7 +781,7 @@ void testCreateMetadataWithIndicator() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -801,7 +803,7 @@ void testCreateMetadataWithValidationRules() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -835,7 +837,7 @@ void testUpdateMetadataWithValidationRules() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -847,7 +849,7 @@ void testUpdateMetadataWithValidationRules() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); validate = objectBundleValidationService.validate(bundle); validate.forEachErrorReport(errorReport -> log.error("Error report:" + errorReport)); @@ -883,7 +885,7 @@ void testCreateMetadataWithInvalidExpressionValidationRules() throws IOException params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCount()); assertTrue( @@ -903,7 +905,7 @@ void testUpdateMetadataWithMissingExpressionValidationRules() throws IOException params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCount()); assertTrue( @@ -928,7 +930,7 @@ void testCreateAndUpdateMetadata1() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport objectBundleValidationReport = objectBundleValidationService.validate(bundle); assertFalse(objectBundleValidationReport.hasErrorReports()); @@ -978,7 +980,7 @@ void testCreateAndUpdateMetadata2() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); DataElement dataElementA = manager.get(DataElement.class, "deabcdefghA"); @@ -1028,7 +1030,7 @@ void testCreateAndUpdateMetadata3() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); DataElement dataElementE = manager.get(DataElement.class, "deabcdefghE"); @@ -1050,7 +1052,7 @@ void testCreateMetadataWithSuperuserRoleInjected() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.isEmpty()); assertEquals(1, validate.getErrorReportsCountByCode(UserRole.class, ErrorCode.E5003)); @@ -1068,7 +1070,7 @@ void testCreateMetadataWithDuplicateDataElementCode() throws IOException { params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setAtomicMode(NONE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); assertEquals(1, manager.getAll(DataElement.class).size()); @@ -1089,7 +1091,7 @@ void testCreateMetadataWithDuplicateDataElementUid() throws IOException { params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setAtomicMode(NONE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); assertEquals(1, manager.getAll(DataElement.class).size()); @@ -1109,7 +1111,7 @@ void testCreateMetadataWithDuplicateDataElementUidALL() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); assertEquals(0, manager.getAll(DataElement.class).size()); @@ -1125,7 +1127,7 @@ void testCreateOrgUnitWithLevels() throws IOException { params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setAtomicMode(AtomicMode.ALL); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); OrganisationUnit root = manager.get(OrganisationUnit.class, "inVD5SdytkT"); @@ -1143,7 +1145,7 @@ void testCreateAndUpdateDataSetWithSections() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -1155,7 +1157,7 @@ void testCreateAndUpdateDataSetWithSections() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); validate = objectBundleValidationService.validate(bundle); assertFalse(validate.hasErrorReports()); objectBundleService.commit(bundle); @@ -1197,7 +1199,7 @@ void testCreateOrgUnitWithPersistedParent() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); assertEquals(3, manager.getAll(OrganisationUnit.class).size()); @@ -1221,7 +1223,7 @@ void testCreateOrgUnitWithTranslations() throws IOException { params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setAtomicMode(AtomicMode.ALL); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); OrganisationUnit root = manager.get(OrganisationUnit.class, "inVD5SdytkT"); @@ -1240,7 +1242,7 @@ void testSetDefaultCategoryCombo() throws IOException { params.setImportStrategy(ImportStrategy.CREATE); params.setAtomicMode(AtomicMode.ALL); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); List dataElements = manager.getAll(DataElement.class); @@ -1261,7 +1263,7 @@ void testMetadataWithoutDefaults() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); } @@ -1278,7 +1280,7 @@ void testInvalidDefaults() throws IOException { params.setPreheatMode(PreheatMode.REFERENCE); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertEquals(3, objectBundleValidationService.validate(bundle).getErrorReportsCount()); } @@ -1293,7 +1295,7 @@ void testCreateUpdateOrgUnitUsingCODE() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.CODE); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); List organisationUnits = manager.getAll(OrganisationUnit.class); @@ -1311,7 +1313,7 @@ void testCreateUpdateOrgUnitUsingCODE() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.CODE); params.setImportStrategy(ImportStrategy.UPDATE); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); organisationUnits = manager.getAll(OrganisationUnit.class); @@ -1332,7 +1334,7 @@ void testCreateOrUpdateOrgUnitUsingCODE() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.CODE); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); List organisationUnits = manager.getAll(OrganisationUnit.class); @@ -1350,7 +1352,7 @@ void testCreateOrUpdateOrgUnitUsingCODE() throws IOException { params.setPreheatIdentifier(PreheatIdentifier.CODE); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); assertFalse(objectBundleValidationService.validate(bundle).hasErrorReports()); objectBundleService.commit(bundle); organisationUnits = manager.getAll(OrganisationUnit.class); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceUserTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceUserTest.java index 8f335f2757bc..7d987fe12f3f 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceUserTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/ObjectBundleServiceUserTest.java @@ -40,6 +40,8 @@ import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.feedback.ErrorCode; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.preheat.PreheatIdentifier; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; @@ -81,7 +83,7 @@ void testCreateUsers() throws IOException { ObjectBundleParams params = createBundleParams( ObjectBundleMode.COMMIT, ImportStrategy.CREATE, AtomicMode.NONE, "dxf2/users.json"); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCountByCode(UserRole.class, ErrorCode.E5003)); objectBundleService.commit(bundle); @@ -106,7 +108,7 @@ void testUpdateUsers() throws IOException { ObjectBundleParams params = createBundleParams( ObjectBundleMode.COMMIT, ImportStrategy.CREATE, AtomicMode.NONE, "dxf2/users.json"); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCountByCode(UserRole.class, ErrorCode.E5003)); objectBundleService.commit(bundle); @@ -116,7 +118,7 @@ void testUpdateUsers() throws IOException { ImportStrategy.UPDATE, AtomicMode.NONE, "dxf2/users_update.json"); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCountByCode(UserRole.class, ErrorCode.E5001)); objectBundleService.commit(bundle); @@ -135,7 +137,7 @@ void testUpdateUsersRunsSchemaValidation() throws IOException { ObjectBundleParams params = createBundleParams( ObjectBundleMode.COMMIT, ImportStrategy.CREATE, AtomicMode.NONE, "dxf2/users.json"); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCountByCode(UserRole.class, ErrorCode.E5003)); objectBundleService.commit(bundle); @@ -145,7 +147,7 @@ void testUpdateUsersRunsSchemaValidation() throws IOException { ImportStrategy.UPDATE, AtomicMode.NONE, "dxf2/users_illegal_update.json"); - bundle = objectBundleService.create(params); + bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport report = objectBundleValidationService.validate(bundle); assertEquals(1, report.getErrorReportsCountByCode(User.class, ErrorCode.E4003)); assertTrue(report.hasErrorReport(error -> "email".equals(error.getErrorProperty()))); @@ -159,7 +161,7 @@ void testCreateMetadataWithDuplicateUsername() throws IOException { ImportStrategy.CREATE_AND_UPDATE, AtomicMode.NONE, "dxf2/user_duplicate_username.json"); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); assertEquals(3, manager.getAll(User.class).size()); @@ -173,7 +175,7 @@ void testCreateMetadataWithDuplicateUsernameAndInjectedUser() throws IOException ImportStrategy.CREATE_AND_UPDATE, AtomicMode.NONE, "dxf2/user_duplicate_username.json"); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleValidationService.validate(bundle); objectBundleService.commit(bundle); assertEquals(3, manager.getAll(User.class).size()); @@ -184,7 +186,7 @@ void testUpdateAdminUser() throws IOException { ObjectBundleParams params = createBundleParams( ObjectBundleMode.COMMIT, ImportStrategy.UPDATE, AtomicMode.ALL, "dxf2/user_admin.json"); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertEquals(0, objectBundleValidationService.validate(bundle).getErrorReportsCount()); } @@ -196,7 +198,7 @@ void testCreateUsersWithInvalidPasswords() throws IOException { ImportStrategy.CREATE, AtomicMode.ALL, "dxf2/users_passwords.json"); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); assertEquals(1, validate.getErrorReportsCountByCode(User.class, ErrorCode.E4005)); } @@ -209,7 +211,7 @@ void testUpdateUserWithNoAccessUserRole() throws IOException { ImportStrategy.CREATE_AND_UPDATE, AtomicMode.ALL, "dxf2/user_userrole.json"); - ObjectBundle bundle1 = objectBundleService.create(params); + ObjectBundle bundle1 = (ObjectBundle) objectBundleService.create(params); objectBundleService.commit(bundle1); User userB = manager.get(User.class, "MwhEJUnTHkn"); User userA = manager.get(User.class, "sPWjoHSY03y"); @@ -233,7 +235,7 @@ void testUpdateUserWithNoAccessUserRole() throws IOException { ImportStrategy.CREATE_AND_UPDATE, AtomicMode.ALL, "dxf2/user_userrole_update.json"); - ObjectBundle bundle2 = objectBundleService.create(params); + ObjectBundle bundle2 = (ObjectBundle) objectBundleService.create(params); objectBundleService.commit(bundle2); assertEquals(2, userA.getUserRoles().size()); assertEquals(2, userB.getUserRoles().size()); @@ -248,7 +250,7 @@ void testCreateUserRoleWithCode() throws IOException { AtomicMode.ALL, "dxf2/user_userrole_code.json"); params.setPreheatIdentifier(PreheatIdentifier.CODE); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); objectBundleService.commit(bundle); User userA = manager.get(User.class, "sPWjoHSY03y"); assertNotNull(userA); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java index a4aeed08f064..99158fa7390a 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java @@ -38,12 +38,12 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; import org.hisp.dhis.sms.command.SMSCommand; @@ -85,7 +85,7 @@ public void textCreateSMSCommandWithCorrectCOCId() throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle); validate.forEachErrorReport(System.out::println); assertFalse(validate.hasErrorReports()); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java index 5b08542a1c2c..9dbf45411db7 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/validation/ReferencesCheckTest.java @@ -36,7 +36,6 @@ import java.util.Map; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleHooks; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.ReferencesCheck; import org.hisp.dhis.dxf2.metadata.objectbundle.validation.ValidationContext; import org.hisp.dhis.feedback.ErrorCode; @@ -45,6 +44,7 @@ import org.hisp.dhis.feedback.TypeReport; import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorType; import org.hisp.dhis.preheat.Preheat; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java index d477c4f60da6..d2dc5f33e03f 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/TrackerTest.java @@ -35,11 +35,11 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; import org.hisp.dhis.test.integration.PostgresIntegrationTestBase; @@ -77,7 +77,7 @@ protected ObjectBundle setUpMetadata(String path) throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertNoErrors(objectBundleValidationService.validate(bundle)); objectBundleService.commit(bundle); return bundle; @@ -91,7 +91,7 @@ protected ObjectBundle setUpMetadata(String path, User user) throws IOException params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); params.setUser(user); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertNoErrors(objectBundleValidationService.validate(bundle)); objectBundleService.commit(bundle); return bundle; diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java index 0ba1f8ae6286..21a2e78cd894 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/TrackerRuleEngineSideEffectsHandlerServiceTest.java @@ -38,12 +38,12 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.feedback.Assertions; import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.program.notification.ProgramNotificationInstance; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; @@ -103,7 +103,7 @@ protected ObjectBundle setUpMetadata(String path) throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); Assertions.assertNoErrors(objectBundleValidationService.validate(bundle)); objectBundleService.commit(bundle); return bundle; diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java index 7f6d9d9f7af5..934c8f67d890 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/IdSchemeExportControllerTest.java @@ -54,7 +54,6 @@ import org.hisp.dhis.common.collection.CollectionUtils; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; @@ -62,6 +61,7 @@ import org.hisp.dhis.http.HttpStatus; import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.jsontree.JsonList; import org.hisp.dhis.jsontree.JsonObject; import org.hisp.dhis.program.Event; @@ -117,7 +117,7 @@ protected ObjectBundle setUpMetadata(String path) throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertNoErrors(objectBundleValidationService.validate(bundle)); objectBundleService.commit(bundle); return bundle; diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java index 8a83a83f844d..db388649cb42 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntitiesChangeLogsControllerTest.java @@ -42,13 +42,13 @@ import java.util.function.Supplier; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleMode; -import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleService; import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleValidationService; import org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport; import org.hisp.dhis.http.HttpStatus; import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.importexport.ObjectBundle; +import org.hisp.dhis.importexport.ObjectBundleParams; import org.hisp.dhis.jsontree.JsonList; import org.hisp.dhis.render.RenderFormat; import org.hisp.dhis.render.RenderService; @@ -295,7 +295,7 @@ private ObjectBundle setUpMetadata(String path) throws IOException { params.setObjectBundleMode(ObjectBundleMode.COMMIT); params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE); params.setObjects(metadata); - ObjectBundle bundle = objectBundleService.create(params); + ObjectBundle bundle = (ObjectBundle) objectBundleService.create(params); assertNoMetadataErrors(objectBundleValidationService.validate(bundle)); objectBundleService.commit(bundle); return bundle; From 19e4f062d8d393481715c3b930aad69382faaf73 Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 13:33:54 +0000 Subject: [PATCH 7/8] chore: add debug --- .../src/main/java/org/hisp/dhis/scheduling/JobProgress.java | 1 + 1 file changed, 1 insertion(+) diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java index 48c92dcb4df4..31d4badf1706 100644 --- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobProgress.java @@ -259,6 +259,7 @@ default T nonNullStagePostCondition(@CheckForNull T value) throws Cancellati if (obr instanceof ObjectBundle) { return value; } else if (obr instanceof ObjectBundleFail obf) { + obf.e().printStackTrace(); throw new CancellationException("Post-condition was null: " + obf.e().getMessage()); } } From d5316306c0ea6ea7c88f447aea7b133e9e089926 Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Wed, 11 Dec 2024 13:54:15 +0000 Subject: [PATCH 8/8] chore: add debug --- .../dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java index e27f2cc307bf..87503c63cacd 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/ApiTest.java @@ -34,7 +34,6 @@ import org.hisp.dhis.helpers.extensions.MetadataSetupExtension; import org.hisp.dhis.test.e2e.actions.LoginActions; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; @@ -52,9 +51,4 @@ public void afterAll() { new LoginActions().loginAsDefaultUser(); new TestCleanUp().deleteCreatedEntities(); } - - @AfterEach - public void cleanup() { - new TestCleanUp().deleteCreatedEntities(); - } }