← Back to team overview

dhis2-devs team mailing list archive

Re: Shortname too short

 

2009/4/17 Knut Staring <knutst@xxxxxxxxx>:
> On Fri, Apr 17, 2009 at 5:09 PM, Saptarshi Purkayastha <sunbiz@xxxxxxxxx>
> wrote:
>>>
>>> When importing dataelements, it becomes a problem that shornames have to
>>> be both unique AND max 25 characters. I think we should loosen the second
>>> requirement in the db. It must be up to the users to make their shortnames
>>> sufficiently short, not a db constraint.
>>
>> I disagree, it makes more sense to keep it the way it is... a reason its
>> called short name ;-)
>> and building boundaries on the data model is a best practice of sorts.
>
> Yes, that is exactly why we made it the way it is.
>>
>> Some other solution may just be able to solve the problem??
>
> Let me describe the issue in some more detail: We want to import a database
> which has 3000 data elements (survey questions), most of them considerably
> longer than 25 characters, and many very similar, often differing mainly in
> a few characters at the end. Shortname is restricted to be required, unique
> and 25 characters. One possibility is to just use the dataelementid as
> shortname, but that of course would mean it is completely useless, just a
> filler to enable data to be imported.
> We are now putting a high priority on import (of hierarchies, data elements,
> and data) from a spreadsheet, and the import process could perhaps contain
> intelligence suggesting possible shortnames, but it is quite hard to come up
> with something generic that will make sense in most cases. One strategy is
> to just take the 25 first characters of the name, and if the result exists
> already, substitute a number for the last two characters (alternatively do
> this for all). This is sort of workable, but it would in that case be
> desirable to also mark the data element so that someone can go through
> manually afterwards.
> Another option would be to the uniquenesscheck in the spreadsheet first - or
> go through all dataelements with length over 25 characters manually before
> importing. It is actually easier to do it in the spreadsheet than in DHIS 2
> - but we don't have that import functionality yet.
> Knut

>From fs/namei.c in linux kernel source:
/*
 * Given a valid longname, create a unique shortname.  Make sure the
 * shortname does not exist
 * Returns negative number on error, 0 for a normal
 * return, and 1 for valid shortname
 */
static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
				 wchar_t *uname, int ulen,
				 unsigned char *name_res, unsigned char *lcase)

The algorithm is pretty short and could probably be pretty easily
replicated in java or perhaps better still as a spreadsheet macro.
But beware of patents - ask TomTom :-)  I guess this is what you have
in mind for your first option.

Seriously though, I have to agree with Saptarshi here.  The point of a
short name is that it should be bounded.  (I'm not sure a survey
question is a suitable candidate as a data element name anyway but
thats another issue).

I presume you won't lose the full name on import?  We have
'description' which holds an arbitrary amount of text.  So I would opt
to import the full question in here and do some sort of fat truncation
trick for the short names which are too long.  How many of them go
over the limit?  3000 is a lot but if you are talking 200 over the
limit it might be doable to manually edit them after the fact and make
them more meaningful.

Bob

>
>>
>> ---
>> Regards,
>> Saptarshi PURKAYASTHA
>> Director R & D, HISP India
>> Health Information Systems Programme
>>
>> My Tech Blog:  http://sunnytalkstech.blogspot.com
>> You Live by CHOICE, Not by CHANCE
>>
>>>
>>> Knut
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>>
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Cheers,
> Knut Staring
>
> _______________________________________________
> 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