dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38124
Re: TrackedEntityAttribute update - add optionSet
I removed it from the JSON, and when the update was complete, there was no
longer a reference to it.
--
Morten
On Fri, Jun 19, 2015 at 1:35 PM, Alan Hill <ahill@xxxxxxxxxx> wrote:
> Hi Morten....when you say 'removing the option set completely', do you
> mean removing from the JSON or deleting from the database?
>
> Thanks
>
> A
>
> On Thu, Jun 18, 2015 at 11:26 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
> wrote:
>
>> Hi
>>
>> I made a small change to the actions that power the UI, so it should work
>> properly there now. As for trough the web-api, I was successfully able to
>> update a TEA from being a optionSet type to a simple text type by simply
>> removing the optionSet completely and setting valueType to text.
>>
>> curl -X PUT -d @tea.json -u admin:district -H "Content-type:
>> application/json" "
>> http://localhost:8080/api/trackedEntityAttributes/wSHRkXNPeED?mergeStrategy=REPLACE"
>> -v
>>
>> --
>> Morten
>>
>> On Fri, Jun 19, 2015 at 11:46 AM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
>> wrote:
>>
>>> Ok, I will need to look more into it then, it should have worked with
>>> mergeStrategy=REPLACE
>>>
>>> --
>>> Morten
>>>
>>> On Fri, Jun 19, 2015 at 11:26 AM, Alan Hill <ahill@xxxxxxxxxx> wrote:
>>>
>>>> Hi Morten
>>>>
>>>> Many thanks for the response.
>>>>
>>>> Yes, remove the OptionSet assignment from the TrackedEntityAttribute.
>>>>
>>>> I have tried as suggested with the following JSON and it does not
>>>> remove the assignment:
>>>>
>>>> {
>>>> "id":"z4fdyQtgja3",
>>>> "created":"2015-06-18T22:28:48.352+0000",
>>>> "name":"DHS 2010 - Median month of interview",
>>>> "href":"http://localhost:8000/api/trackedEntityAttributes/z4fdyQtgja3",
>>>> "lastUpdated":"2015-06-19T04:20:31.641+0000",
>>>> "code":"DHS 2010 - inter_month",
>>>> "shortName":"DHS 2010 - Median month of interview",
>>>> "displayDescription":"Median month of interview",
>>>> "unique":false,
>>>> "programScope":false,
>>>> "displayInListNoProgram":false,
>>>> "orgunitScope":false,
>>>> "displayOnVisitSchedule":false,
>>>> "dataDimension":true,
>>>> "description":"Median month of interview",
>>>> "externalAccess":false,
>>>> "valueType":"int",
>>>> "confidential":false,
>>>> "publicAccess":"rw------",
>>>> "allItems":false,
>>>> "inherit":false,
>>>> "dimension":"z4fdyQtgja3",
>>>> *"optionSetValue":false,*
>>>> "displayName":"DHS 2010 - Median month of interview",
>>>> "displayShortName":"DHS 2010 - Median month of interview",
>>>> *"optionSet":null,*
>>>> "name":"DHS 2010 - Median month of interview",
>>>> "code":"DHS 2010 - inter_month",
>>>> "created":"2015-06-18T22:28:48.253+0000",
>>>> "lastUpdated":"2015-06-18T23:52:01.383+0000",
>>>> "href":"http://localhost:8000/api/optionSets/X61RbMAvsTj"},
>>>> "access":{"update":true,
>>>> "externalize":false,
>>>> "write":true,
>>>> "delete":true,
>>>> "read":true,
>>>> "manage":true},
>>>> "user":{"id":"M4XhsWJlIhk",
>>>> "name":"admin admin",
>>>> "created":"2015-06-18T15:26:06.062+0000",
>>>> "lastUpdated":"2015-06-18T16:07:29.473+0000",
>>>> "href":"http://localhost:8000/api/users/M4XhsWJlIhk"},
>>>> "attributeValues":[],
>>>> "items":[],
>>>> "userGroupAccesses":[]
>>>> }
>>>>
>>>> Note also that updating through the UI, i.e. change from optionSet ->
>>>> number, the optionSet still appears on the form when reloading.
>>>>
>>>> Many thanks
>>>>
>>>> Alan
>>>>
>>>>
>>>> On Thu, Jun 18, 2015 at 6:52 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx
>>>> > wrote:
>>>>
>>>>> So you want to clear out the optionset completely? try and set it over
>>>>> as optionSet: null, and set merge strategy to REPLACE
>>>>>
>>>>> --
>>>>> Morten
>>>>>
>>>>> On Thu, Jun 18, 2015 at 10:17 PM, Alan Hill <ahill@xxxxxxxxxx> wrote:
>>>>>
>>>>>> Hi Morten
>>>>>>
>>>>>> I have tried this with trunk (build # 19453) and assigning the
>>>>>> optionSet now seems to function correctly.
>>>>>>
>>>>>> However, removing the optionSet is still not possible.
>>>>>>
>>>>>> Should I be using any specific strategy / mergeStrategy for the
>>>>>> remove to function?
>>>>>>
>>>>>> Many thanks for the quick turn around.
>>>>>>
>>>>>> Alan
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Jun 17, 2015 at 6:39 PM, Morten Olav Hansen <
>>>>>> mortenoh@xxxxxxxxx> wrote:
>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> Please try again with the latest version of 2.19 or trunk.
>>>>>>>
>>>>>>> --
>>>>>>> Morten
>>>>>>>
>>>>>>> On Thu, Jun 18, 2015 at 1:22 AM, Alan Hill <ahill@xxxxxxxxxx> wrote:
>>>>>>>
>>>>>>>> Hi there
>>>>>>>>
>>>>>>>> I have a TrackedEntityAttribute created through the web api and
>>>>>>>> want to perform an update to both add and remove an optionSet assignment.
>>>>>>>>
>>>>>>>> I have attempted to do this using a PUT, supplying the JSON
>>>>>>>> previously retrieved via a GET and adding/remove the option set and setting
>>>>>>>> the valueType accordingly.
>>>>>>>>
>>>>>>>> Here are the relevant JSON fields:
>>>>>>>>
>>>>>>>> *Assign*
>>>>>>>>
>>>>>>>> ...
>>>>>>>> valueType: "optionSet",
>>>>>>>> optionSet: {id: "<id>"},
>>>>>>>> optionSetValue: true,
>>>>>>>> ...
>>>>>>>>
>>>>>>>> *Remove*
>>>>>>>>
>>>>>>>> ...
>>>>>>>> valueType: "number",
>>>>>>>> optionSetValue: false,
>>>>>>>> ...
>>>>>>>>
>>>>>>>>
>>>>>>>> However, this seems to make no difference to the attribute.
>>>>>>>>
>>>>>>>> If I try through the UI to change an attribute valueType from
>>>>>>>> optionSet -> number, it still has the optionSet assignment so perhaps this
>>>>>>>> is not possible...?
>>>>>>>>
>>>>>>>> Any advice greatly appreciated.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Alan
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Mailing list: https://launchpad.net/~dhis2-devs
>>>>>>>> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>>>>>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>>>>>>> More help : https://help.launchpad.net/ListHelp
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
Follow ups
References