← Back to team overview

dhis2-devs team mailing list archive

Re: Issues importing ProgramStageSection

 

Hello Morten,

Program creation is fine.
But ProgramStage and ProgramStageSection creation is failing. See details
below.

*"Program Stage":*

*Input:*

{
    "programStages": [{
        "programStageDataElements": [{
            "displayInReports": true,
            "dataElement": {
                "id": "034dcb18fe3",
                "name": "Age"
            },
            "allowProvidedElsewhere": false,
            "compulsory": false,
            "allowDateInFuture": false
        }],
        "description": "Desc",
        "program": {
            "id": "625b2495e79",
            "name": "Prog1"
        },
        "id": "b17f8e7729b",
        "name": "Stage1"
    }]
}

*Error:*

Problem accessing /api/metadata. Reason:

    java.util.HashSet cannot be cast to java.util.List

Caused by:

java.lang.ClassCastException: java.util.HashSet cannot be cast to java.util.List
	at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter$NonIdentifiableObjects.extractProgramStageDataElements(DefaultIdentifiableObjectImporter.java:460)
	at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter$NonIdentifiableObjects.extract(DefaultIdentifiableObjectImporter.java:174)
	at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.newObject(DefaultIdentifiableObjectImporter.java:570)
	at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.startImport(DefaultIdentifiableObjectImporter.java:830)
	at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObjectLocal(DefaultIdentifiableObjectImporter.java:785)
	at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObjects(DefaultIdentifiableObjectImporter.java:743)
	at org.hisp.dhis.dxf2.metadata.DefaultImportService.doImport(DefaultImportService.java:261)
	at org.hisp.dhis.dxf2.metadata.DefaultImportService.importMetaData(DefaultImportService.java:178)
	at sun.reflect.GeneratedMethodAccessor450.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)




*"Program Stage Section":*

Program stage for this JSON was created using DHIS UI.

*Input:*
{
    "programStageSections": [{
            "programStageDataElements": [{
                    "displayInReports": false,
                    "dataElement": {
                        "id": "034dcb18fe3",
                        "name": "Age"
                    },
                    "allowProvidedElsewhere": false,
                    "compulsory": false,
                    "allowDateInFuture": false
                }],
            "name": "name",
            "sortOrder": 1,
            "programStage": {
                "id": "UGl8auROT9M",
                "name": "Single-Event Stage1"
            }
        }]
}


*Error:*

Caused by: org.h2.jdbc.JdbcSQLException: NULL not allowed for column
"PROGRAMSTAGEID"; SQL statement:
insert into programstage_dataelements (compulsory,
allowprovidedelsewhere, sort_order, displayInReports,
allowDateInFuture, programstageid, dataelementid) values (?, ?, ?, ?,
?, ?, ?) [23502-173]



On Thu, Jun 12, 2014 at 3:28 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
wrote:

> Hi
>
> There was a few missing pieces to the programStageSection and
> programDataElements classes. Please try again, but remember that the format
> has changed, so I would create a new section in dhis and export it.. to
> look at the format.
>
> Also remember that programStage is the "owning" side of that relationship,
> so to attach it, you would also send a programStage update in the same
> metadata body.
>
> --
> Morten
>
>
> On Thu, Jun 12, 2014 at 11:34 AM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
> wrote:
>
>> That sounds weird. Abyor or Tran, could you have a look at it?
>>
>> --
>> Morten
>>
>>
>> On Thu, Jun 12, 2014 at 11:26 AM, Mansi Singhal <
>> msinghal@xxxxxxxxxxxxxxxx> wrote:
>>
>>> Hey Morten,
>>>
>>> Thanks for that.
>>>
>>> I just wanted a clarification on one more thing:
>>>
>>> We created a Program say "Program1" and then "Program Stage" under it.
>>> This stage has approximately 20 "ProgramStageDataElements".
>>>
>>> On "Event Capture screen", after selecting relevant fields ("Program1"
>>> as program and "orgUnit" as organization Unit), on clicking "Register
>>> Event", I am able to see only few "ProgramStageDataElements" (around 10)
>>> and not all of them.
>>>
>>> Is it the expected behavior or its a bug?
>>>
>>>
>>>
>>> On Thu, Jun 12, 2014 at 2:28 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> The tracker metadata web-api should still be considered wip (it's new
>>>> for 2.16). I haven't tested with programStageSections at all.
>>>>
>>>> I will have a look at it.
>>>>
>>>> --
>>>> Morten
>>>>
>>>>
>>>> On Thu, Jun 12, 2014 at 10:49 AM, Mansi Singhal <
>>>> msinghal@xxxxxxxxxxxxxxxx> wrote:
>>>>
>>>>> Hello All,
>>>>>
>>>>> We were trying to create "Program", "Program Stage" and "Program Stage
>>>>> Section" using "/metadata" api.
>>>>>
>>>>> We are facing issues creating "Program Stage Section".
>>>>> *Status : 409 Conflict*
>>>>>
>>>>> When we tried debugging the issue, we got some ClassCastExceptions for
>>>>> "List to Set" and "Set to List" in "extractProgramStageDataElements" and
>>>>> "saveProgramStageDataElements" methods in
>>>>> "DefaultIdentifiableObjectImporter" class under "dhis-services-dxf2".
>>>>>
>>>>> We tried fixing it, and we got some more exceptions (Constraint
>>>>> Violation Exception)
>>>>>
>>>>> *Input to the api "/metadata"*:
>>>>>
>>>>> {
>>>>>     "programStageSections": [
>>>>>         {
>>>>>             "name": "SomeName",
>>>>>             "programStageDataElements": [
>>>>>                 {
>>>>>                     "allowDateInFuture": false,
>>>>>                     "allowProvidedElsewhere": false,
>>>>>                     "compulsory": false,
>>>>>                     "dataElement": {
>>>>>                         "id": "DataElementId",
>>>>>                         "name": "DataElementName"
>>>>>                     },
>>>>>                     "displayInReports": false
>>>>>                 }
>>>>>             ],
>>>>>             "sortOrder": 1
>>>>>         }
>>>>>     ]
>>>>> }
>>>>>
>>>>> Can you please have a look onto this and fix it if needed.
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Thanks,
>>>>> Mansi Singhal
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Regards,
>>> Mansi Singhal
>>>
>>>
>>
>


-- 
Regards,
Mansi Singhal

+91 9900246052

Follow ups

References