Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/java/org/hisp/dhis/Dhis2.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.hisp.dhis.model.CategoryOptionGroup;
import org.hisp.dhis.model.CategoryOptionGroupSet;
import org.hisp.dhis.model.Constant;
import org.hisp.dhis.model.DataApprovalWorkflow;
import org.hisp.dhis.model.DataElement;
import org.hisp.dhis.model.DataElementGroup;
import org.hisp.dhis.model.DataElementGroupSet;
Expand Down Expand Up @@ -1658,6 +1659,30 @@ public ObjectResponse removeDataElementGroupSet(String id) {
return removeMetadataObject(MetadataEntity.DATA_ELEMENT_GROUP_SET, id);
}

// -------------------------------------------------------------------------
// DataApprovalWorkflow
// -------------------------------------------------------------------------

/**
* Retrieves a list of {@link DataApprovalWorkflow}.
*
* @param query the {@link Query}.
* @return list of {@link DataApprovalWorkflow}.
*/
public List<DataApprovalWorkflow> getDataApprovalWorkflows(Query query) {
return getMetadataList(MetadataEntity.DATA_APPROVAL_WORKFLOW, query);
}

/**
* Retrieves a {@link Metadata} of type {@link DataApprovalWorkflow}.
*
* @param query the {@link Query}.
* @return a {@link Metadata}.
*/
public Metadata<DataApprovalWorkflow> getDataApprovalWorkflowsPaged(Query query) {
return getMetadata(MetadataEntity.DATA_APPROVAL_WORKFLOW, query);
}

// -------------------------------------------------------------------------
// DataSet
// -------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/hisp/dhis/api/ApiFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ public class ApiFields {
"%1$s,organisationUnits[%2$s],workflow[%2$s],indicators[%2$s],sections[%2$s],legendSets[%2$s]",
DATA_SET_FIELDS, NAME_FIELDS);

/** Data approval workflow fields. */
public static final String DATA_APPROVAL_WORKFLOW_FIELDS =
String.format("%s,periodType,dataSets[%s]", NAME_EXT_FIELDS, NAME_FIELDS);

/** Data entry form fields. */
public static final String DATA_ENTRY_FORM_FIELDS =
String.format("%s,htmlCode,style,format", NAME_FIELDS);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/hisp/dhis/model/Dhis2Objects.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class Dhis2Objects implements Serializable {

@JsonProperty private List<DataEntryForm> dataEntryForms = new ArrayList<>();

@JsonProperty private List<DataApprovalWorkflow> dataApprovalWorkflows = new ArrayList<>();

@JsonProperty private List<DataSet> dataSets = new ArrayList<>();

@JsonProperty private List<Dimension> dimensions = new ArrayList<>();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/hisp/dhis/model/metadata/MetadataEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static org.hisp.dhis.api.ApiFields.CATEGORY_OPTION_GROUP_SET_FIELDS;
import static org.hisp.dhis.api.ApiFields.CONSTANT_FIELDS;
import static org.hisp.dhis.api.ApiFields.DASHBOARD_FIELDS;
import static org.hisp.dhis.api.ApiFields.DATA_APPROVAL_WORKFLOW_FIELDS;
import static org.hisp.dhis.api.ApiFields.DATA_ELEMENT_EXT_FIELDS;
import static org.hisp.dhis.api.ApiFields.DATA_ELEMENT_GROUP_EXT_FIELDS;
import static org.hisp.dhis.api.ApiFields.DATA_ELEMENT_GROUP_FIELDS;
Expand Down Expand Up @@ -95,6 +96,7 @@
import org.hisp.dhis.model.CategoryOptionGroup;
import org.hisp.dhis.model.CategoryOptionGroupSet;
import org.hisp.dhis.model.Constant;
import org.hisp.dhis.model.DataApprovalWorkflow;
import org.hisp.dhis.model.DataElement;
import org.hisp.dhis.model.DataElementGroup;
import org.hisp.dhis.model.DataElementGroupSet;
Expand Down Expand Up @@ -199,6 +201,12 @@ public enum MetadataEntity {
DASHBOARD_FIELDS,
"dashboards",
Dhis2Objects::getDashboards),
DATA_APPROVAL_WORKFLOW(
DataApprovalWorkflow.class,
DATA_APPROVAL_WORKFLOW_FIELDS,
DATA_APPROVAL_WORKFLOW_FIELDS,
"dataApprovalWorkflows",
Dhis2Objects::getDataApprovalWorkflows),
DATA_ELEMENT(
DataElement.class,
DATA_ELEMENT_EXT_FIELDS,
Expand Down Expand Up @@ -447,6 +455,8 @@ public static <T extends IdentifiableObject> MetadataEntity from(T object) {
return CATEGORY_OPTION_GROUP_SET;
} else if (object instanceof Dashboard) {
return DASHBOARD;
} else if (object instanceof DataApprovalWorkflow) {
return DATA_APPROVAL_WORKFLOW;
} else if (object instanceof DataElement) {
return DATA_ELEMENT;
} else if (object instanceof DataElementGroup) {
Expand Down
56 changes: 56 additions & 0 deletions src/test/java/org/hisp/dhis/model/DataApprovalWorkflowTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2004-2025, 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.model;

import static org.hisp.dhis.support.Assertions.assertSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.hisp.dhis.support.JsonClassPathFile;
import org.hisp.dhis.support.TestTags;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Tag(TestTags.UNIT)
class DataApprovalWorkflowTest {
@Test
void testDeserialize() {
DataApprovalWorkflow workflow =
JsonClassPathFile.fromJson(
"metadata/data-approval-workflow.json", DataApprovalWorkflow.class);

assertNotNull(workflow);
assertEquals("wkn0K4gtVHo", workflow.getId());
assertEquals("Malaria Approval Workflow", workflow.getName());
assertEquals("Monthly", workflow.getPeriodType());
assertSize(3, workflow.getDataSets());
assertEquals("pBOMPrpg1QX", workflow.getDataSets().get(0).getId());
assertEquals("VTdjfLXXmoi", workflow.getDataSets().get(1).getId());
assertEquals("Lpw6GcnTrmS", workflow.getDataSets().get(2).getId());
}
}
20 changes: 20 additions & 0 deletions src/test/resources/metadata/data-approval-workflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"id": "wkn0K4gtVHo",
"code": "MALARIA_WORKFLOW",
"name": "Malaria Approval Workflow",
"periodType": "Monthly",
"dataSets": [
{
"id": "pBOMPrpg1QX",
"name": "Mortality < 5 years"
},
{
"id": "VTdjfLXXmoi",
"name": "Child Health"
},
{
"id": "Lpw6GcnTrmS",
"name": "Malaria Annual Data"
}
]
}
Loading