Re: [Dhis2-devs] [Dhis2-users] UID generation

2016-09-29 Thread Morten Olav Hansen
A third alternative is to just get it from DHIS2 itself,

https://play.dhis2.org/dev/api/system/id.json?limit=1000
https://play.dhis2.org/dev/api/system/id.xml?limit=1000
https://play.dhis2.org/dev/api/system/id.csv?limit=1000

-- 
Morten Olav Hansen
Senior Engineer, DHIS 2
University of Oslo
http://www.dhis2.org

On Thu, Sep 29, 2016 at 5:00 PM, Arun Paul  wrote:

> Thanks Lars, Jason for the quick response !
> That solution worked for me.
>
> ​Regards
> ,
> - Arun Paul
>
> On Thu, Sep 29, 2016 at 2:55 PM, Jason Pickering <
> jason.p.picker...@gmail.com> wrote:
>
>> If you are using Postgres to inject the data directly, you can use this
>>
>> https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/uid.sql
>>
>> Regards,
>> Jason
>>
>> On Thu, Sep 29, 2016 at 11:23 AM, Lars Helge Øverland 
>> wrote:
>>
>>> In fact,  generateCode(); will do.
>>>
>>> Lars
>>>
>>>
>>> On Thu, Sep 29, 2016 at 11:23 AM, Lars Helge Øverland 
>>> wrote:
>>>
 Hi Arun,

 if you are using the DHIS 2 Java service layers there is no need to
 manually generate and set UIDs. They will be automatically set before the
 object is saved.

 To generate UIDs you should use this class: 
 org.hisp.dhis.commonCodeGenerator
 -> generateCode( 11 );

 Javadoc:

 http://ci.dhis2.org/job/dhis2-2.24-javadoc/javadoc/org/hisp/
 dhis/common/CodeGenerator.html



 regards,

 Lars


 On Thu, Sep 29, 2016 at 11:17 AM, Arun Paul 
 wrote:

> Hello everyone,
>
> I am trying to import legacy data into a new DHIS2 installation using
> custom code.
>
> While adding new entries into a database table, I need to assign new
> UID values. What is the algorithm I should use to generated these IDs ? I
> tried using a postgresql extension called uuid-ossp and the
> function uuid_generate_v1() that comes with that extension. But it
> generates uuid of the format ebe87e56-8624-11e6-a4ce-040157be4e01 and
> it's bigger than what CHARACTER VARYING(11) can hold. Any idea what
> strategy should I follow here to easily generate UIDs while inserting
> database entries?
>
> Thanks in advance.
> - Arun Paul
>
> ___
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-us...@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>


 --
 Lars Helge Øverland
 Lead developer, DHIS 2
 University of Oslo
 Skype: larshelgeoverland
 l...@dhis2.org
 http://www.dhis2.org 


>>>
>>>
>>> --
>>> Lars Helge Øverland
>>> Lead developer, DHIS 2
>>> University of Oslo
>>> Skype: larshelgeoverland
>>> l...@dhis2.org
>>> http://www.dhis2.org 
>>>
>>>
>>> ___
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to : dhis2-devs@lists.launchpad.net
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>> --
>> Jason P. Pickering
>> email: jason.p.picker...@gmail.com
>> tel:+46764147049
>>
>
>
> ___
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-us...@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] UID generation

2016-09-29 Thread Arun Paul
Thanks Lars, Jason for the quick response !
That solution worked for me.

​Regards
,
- Arun Paul

On Thu, Sep 29, 2016 at 2:55 PM, Jason Pickering <
jason.p.picker...@gmail.com> wrote:

> If you are using Postgres to inject the data directly, you can use this
>
> https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/uid.sql
>
> Regards,
> Jason
>
> On Thu, Sep 29, 2016 at 11:23 AM, Lars Helge Øverland 
> wrote:
>
>> In fact,  generateCode(); will do.
>>
>> Lars
>>
>>
>> On Thu, Sep 29, 2016 at 11:23 AM, Lars Helge Øverland 
>> wrote:
>>
>>> Hi Arun,
>>>
>>> if you are using the DHIS 2 Java service layers there is no need to
>>> manually generate and set UIDs. They will be automatically set before the
>>> object is saved.
>>>
>>> To generate UIDs you should use this class: 
>>> org.hisp.dhis.commonCodeGenerator
>>> -> generateCode( 11 );
>>>
>>> Javadoc:
>>>
>>> http://ci.dhis2.org/job/dhis2-2.24-javadoc/javadoc/org/hisp/
>>> dhis/common/CodeGenerator.html
>>>
>>>
>>>
>>> regards,
>>>
>>> Lars
>>>
>>>
>>> On Thu, Sep 29, 2016 at 11:17 AM, Arun Paul  wrote:
>>>
 Hello everyone,

 I am trying to import legacy data into a new DHIS2 installation using
 custom code.

 While adding new entries into a database table, I need to assign new
 UID values. What is the algorithm I should use to generated these IDs ? I
 tried using a postgresql extension called uuid-ossp and the
 function uuid_generate_v1() that comes with that extension. But it
 generates uuid of the format ebe87e56-8624-11e6-a4ce-040157be4e01 and
 it's bigger than what CHARACTER VARYING(11) can hold. Any idea what
 strategy should I follow here to easily generate UIDs while inserting
 database entries?

 Thanks in advance.
 - Arun Paul

 ___
 Mailing list: https://launchpad.net/~dhis2-users
 Post to : dhis2-us...@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-users
 More help   : https://help.launchpad.net/ListHelp


>>>
>>>
>>> --
>>> Lars Helge Øverland
>>> Lead developer, DHIS 2
>>> University of Oslo
>>> Skype: larshelgeoverland
>>> l...@dhis2.org
>>> http://www.dhis2.org 
>>>
>>>
>>
>>
>> --
>> Lars Helge Øverland
>> Lead developer, DHIS 2
>> University of Oslo
>> Skype: larshelgeoverland
>> l...@dhis2.org
>> http://www.dhis2.org 
>>
>>
>> ___
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to : dhis2-devs@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
>
> --
> Jason P. Pickering
> email: jason.p.picker...@gmail.com
> tel:+46764147049
>
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] UID generation

2016-09-29 Thread Jason Pickering
If you are using Postgres to inject the data directly, you can use this

https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/uid.sql

Regards,
Jason

On Thu, Sep 29, 2016 at 11:23 AM, Lars Helge Øverland 
wrote:

> In fact,  generateCode(); will do.
>
> Lars
>
>
> On Thu, Sep 29, 2016 at 11:23 AM, Lars Helge Øverland 
> wrote:
>
>> Hi Arun,
>>
>> if you are using the DHIS 2 Java service layers there is no need to
>> manually generate and set UIDs. They will be automatically set before the
>> object is saved.
>>
>> To generate UIDs you should use this class: org.hisp.dhis.commonCodeGenerator
>> -> generateCode( 11 );
>>
>> Javadoc:
>>
>> http://ci.dhis2.org/job/dhis2-2.24-javadoc/javadoc/org/hisp/
>> dhis/common/CodeGenerator.html
>>
>>
>>
>> regards,
>>
>> Lars
>>
>>
>> On Thu, Sep 29, 2016 at 11:17 AM, Arun Paul  wrote:
>>
>>> Hello everyone,
>>>
>>> I am trying to import legacy data into a new DHIS2 installation using
>>> custom code.
>>>
>>> While adding new entries into a database table, I need to assign new UID
>>> values. What is the algorithm I should use to generated these IDs ? I tried
>>> using a postgresql extension called uuid-ossp and the
>>> function uuid_generate_v1() that comes with that extension. But it
>>> generates uuid of the format ebe87e56-8624-11e6-a4ce-040157be4e01 and
>>> it's bigger than what CHARACTER VARYING(11) can hold. Any idea what
>>> strategy should I follow here to easily generate UIDs while inserting
>>> database entries?
>>>
>>> Thanks in advance.
>>> - Arun Paul
>>>
>>> ___
>>> Mailing list: https://launchpad.net/~dhis2-users
>>> Post to : dhis2-us...@lists.launchpad.net
>>> Unsubscribe : https://launchpad.net/~dhis2-users
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>> --
>> Lars Helge Øverland
>> Lead developer, DHIS 2
>> University of Oslo
>> Skype: larshelgeoverland
>> l...@dhis2.org
>> http://www.dhis2.org 
>>
>>
>
>
> --
> Lars Helge Øverland
> Lead developer, DHIS 2
> University of Oslo
> Skype: larshelgeoverland
> l...@dhis2.org
> http://www.dhis2.org 
>
>
> ___
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to : dhis2-devs@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Jason P. Pickering
email: jason.p.picker...@gmail.com
tel:+46764147049
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] UID generation

2016-09-29 Thread Lars Helge Øverland
In fact,  generateCode(); will do.

Lars


On Thu, Sep 29, 2016 at 11:23 AM, Lars Helge Øverland 
wrote:

> Hi Arun,
>
> if you are using the DHIS 2 Java service layers there is no need to
> manually generate and set UIDs. They will be automatically set before the
> object is saved.
>
> To generate UIDs you should use this class: org.hisp.dhis.commonCodeGenerator
> -> generateCode( 11 );
>
> Javadoc:
>
> http://ci.dhis2.org/job/dhis2-2.24-javadoc/javadoc/org/hisp/
> dhis/common/CodeGenerator.html
>
>
>
> regards,
>
> Lars
>
>
> On Thu, Sep 29, 2016 at 11:17 AM, Arun Paul  wrote:
>
>> Hello everyone,
>>
>> I am trying to import legacy data into a new DHIS2 installation using
>> custom code.
>>
>> While adding new entries into a database table, I need to assign new UID
>> values. What is the algorithm I should use to generated these IDs ? I tried
>> using a postgresql extension called uuid-ossp and the
>> function uuid_generate_v1() that comes with that extension. But it
>> generates uuid of the format ebe87e56-8624-11e6-a4ce-040157be4e01 and
>> it's bigger than what CHARACTER VARYING(11) can hold. Any idea what
>> strategy should I follow here to easily generate UIDs while inserting
>> database entries?
>>
>> Thanks in advance.
>> - Arun Paul
>>
>> ___
>> Mailing list: https://launchpad.net/~dhis2-users
>> Post to : dhis2-us...@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~dhis2-users
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
>
> --
> Lars Helge Øverland
> Lead developer, DHIS 2
> University of Oslo
> Skype: larshelgeoverland
> l...@dhis2.org
> http://www.dhis2.org 
>
>


-- 
Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
l...@dhis2.org
http://www.dhis2.org 
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] UID generation

2016-09-29 Thread Lars Helge Øverland
Hi Arun,

if you are using the DHIS 2 Java service layers there is no need to
manually generate and set UIDs. They will be automatically set before the
object is saved.

To generate UIDs you should use this
class: org.hisp.dhis.commonCodeGenerator -> generateCode( 11 );

Javadoc:

http://ci.dhis2.org/job/dhis2-2.24-javadoc/javadoc/org/hisp/dhis/common/CodeGenerator.html



regards,

Lars


On Thu, Sep 29, 2016 at 11:17 AM, Arun Paul  wrote:

> Hello everyone,
>
> I am trying to import legacy data into a new DHIS2 installation using
> custom code.
>
> While adding new entries into a database table, I need to assign new UID
> values. What is the algorithm I should use to generated these IDs ? I tried
> using a postgresql extension called uuid-ossp and the
> function uuid_generate_v1() that comes with that extension. But it
> generates uuid of the format ebe87e56-8624-11e6-a4ce-040157be4e01 and
> it's bigger than what CHARACTER VARYING(11) can hold. Any idea what
> strategy should I follow here to easily generate UIDs while inserting
> database entries?
>
> Thanks in advance.
> - Arun Paul
>
> ___
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-us...@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
l...@dhis2.org
http://www.dhis2.org 
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp