Rename an existing attribute

OK, I admit it, I'm defeated.

Anyone know how to rename an existing attribute using DXL ?

No changes to the base type, or contents, just the name.

And it has to be the actual attribute name, not just the display name, or column name.

Mucho Thanko.

Andrew.
SystemAdmin - Tue May 05 08:51:50 EDT 2009

Re: Rename an existing attribute
llandale - Tue May 05 09:20:00 EDT 2009

Looks like this:
AttrDef adOld = find(mod, "MyOldName")
AttrDef adNew = modify(adOld, setName, "MyNewName")

Re: Rename an existing attribute
SystemAdmin - Wed May 06 09:03:45 EDT 2009

llandale - Tue May 05 09:20:00 EDT 2009
Looks like this:
AttrDef adOld = find(mod, "MyOldName")
AttrDef adNew = modify(adOld, setName, "MyNewName")

Hmmm, gave me an exception error in v8.3 louie (which I helpfully added to your compendium of errors in the other thread). However will play with this tomorrow again, could be I just got something else wrong.

I did find another workaround in the meantime, Just create a 'shadow' attribute of the same underlying type but with the new name, copy accross all the values, delete the original. Simplissimo.

If you are wondering why I want to do this, it's because the Word import macro that comes with DOORS (the one that adds an import icon to the word doc) can helpfully import the Word paragraph styles into DOORS, however it puts them into a string attribute called 'Paragraph Style' - however all my modules already have a 'Parargaph Style' enumerated attribute.

This is Ok most of the time, but for instance if my word doc has been to france and back (which many of mine do), then 'body text' is now 'corps something-or-other', most annoying.

So I have to rename 'my' attribute before import, let the importer do its thing with the string based 'Paragraph Style' attrib, then monkey around with a post processing script to normalise everything afterwards.

Fun fun fun.

I'll say one thing for DOORS admin work, it never gets boring.

Re: Rename an existing attribute
llandale - Wed May 06 11:57:48 EDT 2009

SystemAdmin - Wed May 06 09:03:45 EDT 2009
Hmmm, gave me an exception error in v8.3 louie (which I helpfully added to your compendium of errors in the other thread). However will play with this tomorrow again, could be I just got something else wrong.

I did find another workaround in the meantime, Just create a 'shadow' attribute of the same underlying type but with the new name, copy accross all the values, delete the original. Simplissimo.

If you are wondering why I want to do this, it's because the Word import macro that comes with DOORS (the one that adds an import icon to the word doc) can helpfully import the Word paragraph styles into DOORS, however it puts them into a string attribute called 'Paragraph Style' - however all my modules already have a 'Parargaph Style' enumerated attribute.

This is Ok most of the time, but for instance if my word doc has been to france and back (which many of mine do), then 'body text' is now 'corps something-or-other', most annoying.

So I have to rename 'my' attribute before import, let the importer do its thing with the string based 'Paragraph Style' attrib, then monkey around with a post processing script to normalise everything afterwards.

Fun fun fun.

I'll say one thing for DOORS admin work, it never gets boring.

Its working for me in v8.3. Getting null attrdef if the attr doesn't exist; getting 'no access' errors if the module is open read.

Its 'Simplyannoyingo': you have to reinsert the attribute in all the views.

I think you should change your 'Paragraph Style' attribute name in your modules and let the importer do its thing. That's sort of a 'system' attr, like 'RTF Header'.

>Louie

Re: Rename an existing attribute
SystemAdmin - Fri May 08 04:47:22 EDT 2009

llandale - Wed May 06 11:57:48 EDT 2009
Its working for me in v8.3. Getting null attrdef if the attr doesn't exist; getting 'no access' errors if the module is open read.

Its 'Simplyannoyingo': you have to reinsert the attribute in all the views.

I think you should change your 'Paragraph Style' attribute name in your modules and let the importer do its thing. That's sort of a 'system' attr, like 'RTF Header'.

>Louie

Works just fine today, obviously I had ham fists when I typed it in the other day.

Thanks Louie, and yep, I do need to go rename that attribute in my 5,000 or so modules,and then update all teh sctipts that use it, arrrrgh!

Re: Rename an existing attribute
llandale - Fri May 08 09:17:25 EDT 2009

SystemAdmin - Fri May 08 04:47:22 EDT 2009
Works just fine today, obviously I had ham fists when I typed it in the other day.

Thanks Louie, and yep, I do need to go rename that attribute in my 5,000 or so modules,and then update all teh sctipts that use it, arrrrgh!

The script to update your modules is pretty easy, and can probably finish overnight so long as you periodically close all residual open modules in the database.

Turns out searching *.dxl files using Windows Explorer stopped working for me last month. Security here says it wasn't them. Cannot find it on the Windows update site. Anyway, I played with the Registry and figured out how to make it search those files.

>Louie

Re: Rename an existing attribute
Ben_Sharples - Mon May 11 01:04:19 EDT 2009

llandale - Fri May 08 09:17:25 EDT 2009
The script to update your modules is pretty easy, and can probably finish overnight so long as you periodically close all residual open modules in the database.

Turns out searching *.dxl files using Windows Explorer stopped working for me last month. Security here says it wasn't them. Cannot find it on the Windows update site. Anyway, I played with the Registry and figured out how to make it search those files.

>Louie

where you have a common set of attributes across many modules in the databse, it may be useful to house the attributes names within a separate dxl include file that you can reference in all you dxl programmes - saves on modifying all of them everytime an attribute name changes.

I usually define my attribute names as strings to use in the programme parts of the dxl - that way its easier to update.

Re: Rename an existing attribute
llandale - Mon May 11 12:07:18 EDT 2009

Ben_Sharples - Mon May 11 01:04:19 EDT 2009
where you have a common set of attributes across many modules in the databse, it may be useful to house the attributes names within a separate dxl include file that you can reference in all you dxl programmes - saves on modifying all of them everytime an attribute name changes.

I usually define my attribute names as strings to use in the programme parts of the dxl - that way its easier to update.

Or have a template module that has your attributes in it.

Re: Rename an existing attribute
Martin_Hunter - Thu Apr 17 02:45:00 EDT 2014

llandale - Mon May 11 12:07:18 EDT 2009
Or have a template module that has your attributes in it.

I want to rename an attribute, however I also want to update all views which contain the old attribute. 

I think I have to first rename 'old' attribute to 'new' attribute, then temporarily recreate 'old' attribute to enable me to update any affected views, after which I can delete the temporary 'old' attribute.

Or is there a simpler way?

Re: Rename an existing attribute
llandale - Thu Apr 17 10:37:36 EDT 2014

Martin_Hunter - Thu Apr 17 02:45:00 EDT 2014

I want to rename an attribute, however I also want to update all views which contain the old attribute. 

I think I have to first rename 'old' attribute to 'new' attribute, then temporarily recreate 'old' attribute to enable me to update any affected views, after which I can delete the temporary 'old' attribute.

Or is there a simpler way?

I like a template module that you fix; then use script "copyViews.dxl" to push to the rest of the modules.  the script "copyAtts.dxl" won't help you rename an attribute.  Google those scripts.

But if you want a script to fix any particular module, I don't think your approach will work.  I think (but not sure) the attr will get removed from some non-displayed view when you rename it and before you have a chance to create the old attr at the same name.  I think then you need to plow through all the views and "remember" which view has the old attribute, in which colulmn and other column attributes (width); rename the attr, then plow through the views re-inserting the new.

You could also create the new attribute, copy all the values of objects over, then plow through the views changing the column, then delete the old.  That will mess up History however; even more so then renaming the attribute.

-Louie

Re: Rename an existing attribute
llandale - Thu Apr 17 10:49:18 EDT 2014

Martin_Hunter - Thu Apr 17 02:45:00 EDT 2014

I want to rename an attribute, however I also want to update all views which contain the old attribute. 

I think I have to first rename 'old' attribute to 'new' attribute, then temporarily recreate 'old' attribute to enable me to update any affected views, after which I can delete the temporary 'old' attribute.

Or is there a simpler way?

I like a template module that you fix; then use script "copyViews.dxl" to push to the rest of the modules.  the script "copyAtts.dxl" won't help you rename an attribute.  Google those scripts.

But if you want a script to fix any particular module, I don't think your approach will work.  I think (but not sure) the attr will get removed from some non-displayed view when you rename it and before you have a chance to create the old attr at the same name.  I think then you need to plow through all the views and "remember" which view has the old attribute, in which colulmn and other column attributes (width); rename the attr, then plow through the views re-inserting the new.

You could also create the new attribute, copy all the values of objects over, then plow through the views changing the column, then delete the old.  That will mess up History however; even more so then renaming the attribute.

-Louie

Re: Rename an existing attribute
ChrisHardy68 - Thu Mar 12 17:33:53 EDT 2015

llandale - Wed May 06 11:57:48 EDT 2009
Its working for me in v8.3. Getting null attrdef if the attr doesn't exist; getting 'no access' errors if the module is open read.

Its 'Simplyannoyingo': you have to reinsert the attribute in all the views.

I think you should change your 'Paragraph Style' attribute name in your modules and let the importer do its thing. That's sort of a 'system' attr, like 'RTF Header'.

>Louie

Hi,

i had a similar issue where i had to rename a number of attributes that were all used in multiple views. Luckily the change impacted only a few modules.

I worked around the issue by:

Creating a dummy attribute

For the attribute to be renamed find the views and the related columns where it is used

For those columns replace the attribute with the dummy attribute

Save the view

Rename the attribute

For those columns replace the dummy attribute with the renamed attribute

Save the view

Not very elegant but it worked for me. I have attached the file for reference

 


Attachments

Teds Toy Box.zip

Re: Rename an existing attribute
EastPoint - Wed Jan 03 04:46:09 EST 2018

ChrisHardy68 - Thu Mar 12 17:33:53 EDT 2015

Hi,

i had a similar issue where i had to rename a number of attributes that were all used in multiple views. Luckily the change impacted only a few modules.

I worked around the issue by:

Creating a dummy attribute

For the attribute to be renamed find the views and the related columns where it is used

For those columns replace the attribute with the dummy attribute

Save the view

Rename the attribute

For those columns replace the dummy attribute with the renamed attribute

Save the view

Not very elegant but it worked for me. I have attached the file for reference

 

Hello ChrisHardy,

 

I try to rename some attributes in several modules.

I 've tested your code Teds Toy Box and it is really helpfull for me.

How can I improve it to be able to run this code on several modules ?

I have some problems with the dialog box : I cannot have any code after the show command, so I can't make a for loop ...

 

THank's for your help