← Back to team overview

dhis2-devs team mailing list archive

Re: Assigning org unit to program via API

 

Try removing not-null="true" (or removing the whole property) from
ProgramStage.hbm.xml on the sortOrder property, not sure if its enough
though..

You can see the current ProgramStage.hbm.xml (from trunk) here:
http://bazaar.launchpad.net/~dhis2-devs-core/dhis2/trunk/view/head:/dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml

Not sure if something else also has changed related to this

--
Morten


On Tue, Aug 26, 2014 at 5:41 PM, Mahendra Kariya <
mahendra.kariya@xxxxxxxxxxxxxxxx> wrote:

> We are on revision 14711
> <http://bazaar.launchpad.net/~tw-msf/dhis2/dhis2/revision/14711> of
> tw-trunk branch. We are going live in a couple of weeks and it is not
> feasible for us to merge our branch to trunk at this stage. We will be
> merging to trunk for the next release.
>
> Could you please point us to the code that could help us just fix this bug
> on our branch?
>
>
> Thanks!
>
>
>
> On Tue, Aug 26, 2014 at 3:45 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
> wrote:
>
>> Hi
>>
>> What version of dhis are you using? and what revision? there have been
>> changes to this in 2.16 vs trunk, which can cause issues like that (your db
>> will only be valid with either 2.16 or trunk, you can't switch between them)
>>
>> Also make sure that you are using newest trunk or newest 2.16, since
>> there have been updates related to program in the last few days
>>
>> --
>> Morten
>>
>>
>> On Tue, Aug 26, 2014 at 5:08 PM, Mahendra Kariya <
>> mahendra.kariya@xxxxxxxxxxxxxxxx> wrote:
>>
>>> Thanks for the prompt reply Morten!
>>>
>>> But when we are trying to PUT the object to /api/programs/id, we are
>>> getting null constraint violation for sort_order column. The payload
>>> that we are PUTting is below. (We simply added one more org unit to the
>>> response that we received from GET.)
>>>
>>> {
>>>   "id": "adb81a4bc13",
>>>   "created": "2014-08-26T05:59:08.835+0000",
>>>   "name": "ABCD",
>>>   "href": "http://localhost:8080/api/programs/adb81a4bc13";,
>>>   "lastUpdated": "2014-08-26T08:50:39.622+0000",
>>>   "type": 3,
>>>   "kind": "SINGLE_EVENT_WITHOUT_REGISTRATION",
>>>   "version": 1,
>>>   "description": "ABCD",
>>>   "onlyEnrollOnce": false,
>>>   "externalAccess": false,
>>>   "displayIncidentDate": true,
>>>   "dateOfIncidentDescription": "Incident Date",
>>>   "displayOnAllOrgunit": true,
>>>   "publicAccess": "rw------",
>>>   "registration": false,
>>>   "selectEnrollmentDatesInFuture": false,
>>>   "dataEntryMethod": false,
>>>   "singleEvent": true,
>>>   "ignoreOverdueEvents": false,
>>>   "relationshipFromA": false,
>>>   "displayName": "ABCD",
>>>   "selectIncidentDatesInFuture": false,
>>>   "access": {
>>>     "update": true,
>>>     "externalize": false,
>>>     "delete": true,
>>>     "write": true,
>>>     "read": true,
>>>     "manage": true
>>>   },
>>>   "user": {
>>>     "id": "SZ3QccaOLXH",
>>>     "name": "admin admin",
>>>     "created": "2014-08-26T05:58:00.992+0000",
>>>     "lastUpdated": "2014-08-26T05:59:12.686+0000"
>>>   },
>>>   "validationCriterias": [],
>>>   "programStages": [
>>>     {
>>>       "id": "a29be1d359a",
>>>       "name": "ABCD Stage",
>>>       "created": "2014-08-26T05:59:08.903+0000",
>>>       "lastUpdated": "2014-08-26T05:59:10.896+0000"
>>>     }
>>>   ],
>>>   "instanceReminders": [],
>>>   "organisationUnits": [
>>>     {
>>>       "id": "b876de81d4e",
>>>       "name": "A Test Country",
>>>       "created": "2014-06-13T05:11:18.804+0000",
>>>       "lastUpdated": "2014-08-26T05:58:58.563+0000"
>>>     },
>>>     {
>>>       "id": "a2cf79e8f13",
>>>       "name": "Aother Test Country",
>>>       "created": "2014-06-13T05:11:18.804+0000",
>>>       "lastUpdated": "2014-08-26T05:58:58.563+0000"
>>>     },
>>>     {
>>>     "id": "a420aa7ff4d"
>>>     }
>>>   ],
>>>   "programTrackedEntityAttributes": [],
>>>   "userRoles": [
>>>     {
>>>       "id": "Sd32f0f1336",
>>>       "name": "user1",
>>>       "created": "2014-06-13T05:11:18.804+0000",
>>>       "lastUpdated": "2014-08-26T05:58:58.563+0000"
>>>     },
>>>     {
>>>       "id": "N3f8TR7HAZS",
>>>       "name": "Superuser",
>>>       "created": "2014-06-13T05:10:15.913+0000",
>>>       "lastUpdated": "2014-08-26T05:58:58.595+0000"
>>>     }
>>>   ],
>>>   "userGroupAccesses": []
>>> }
>>>
>>>
>>>
>>> Thanks,
>>> Mahendra
>>> *Thought*Works
>>>
>>>
>>> On Tue, Aug 26, 2014 at 2:50 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
>>> wrote:
>>>
>>>> Hi Mahendra
>>>>
>>>> If you want to update a program, you need to use a PUT request to the
>>>> /api/programs/id
>>>>
>>>> It's saying "Object already exists" because the uid already exists in
>>>> the system.
>>>>
>>>> Btw, you need to send the full payload, we don't support partial
>>>> updates.
>>>>
>>>> --
>>>> Morten
>>>>
>>>>
>>>> On Tue, Aug 26, 2014 at 4:06 PM, Mahendra Kariya <
>>>> mahendra.kariya@xxxxxxxxxxxxxxxx> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> We are trying to assign org units to an existing Program via web api.
>>>>>
>>>>> We tried the posting the below payload to /api/programs, but it is
>>>>> throwing an error "Object already exists".
>>>>>
>>>>> {
>>>>>   "id": "adb81a4bc13"
>>>>>   "organisationUnits": [
>>>>>     {
>>>>>       "id": "a2cf79e8f13"
>>>>>     },
>>>>>     {
>>>>>       "id": "b876de81d4e"
>>>>>     }
>>>>>   ]
>>>>> }
>>>>>
>>>>> We tried posting the following payload to /api/metadata, but it is
>>>>> throwing constraint violation error.
>>>>>  {
>>>>>   "programs": [
>>>>>     {
>>>>>       "id": "adb81a4bc13",
>>>>>       "organisationUnits": [
>>>>>         {
>>>>>           "id": "a2cf79e8f13"
>>>>>         },
>>>>>         {
>>>>>           "id": "b876de81d4e"
>>>>>         }
>>>>>       ]
>>>>>     }
>>>>>   ]
>>>>> }
>>>>>
>>>>> Could you guys point us to the correct payload format?
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Mahendra
>>>>> *Thought*Works
>>>>>
>>>>
>>>>
>>>
>>
>

References