Remaping attribute values

Hello,

I was task with updating existing attributes 300+ Modules and was wondering if anyone had a script to perform this type of activity? If not how would you go about remaping them using DXL?

Thank you,
Jim
SystemAdmin - Thu Oct 27 07:55:48 EDT 2011

Re: Remaping attribute values
OurGuest - Thu Oct 27 12:48:19 EDT 2011

You might help us if you define what remaping means in your mind.

Re: Remaping attribute values
SystemAdmin - Thu Oct 27 13:37:31 EDT 2011

OurGuest - Thu Oct 27 12:48:19 EDT 2011
You might help us if you define what remaping means in your mind.

Hello,

I am trying to remaping existing values to new values within an attribute that is of type enum with a drop down list of:
A
BC
D
E

and would like to updated the values in the list and the actual value assigned to it currently with out losing the data I would like to reasign it to the remap values.

Existing values:
A
BC
D
E

Update(remaping)
A -> A
BC -> D
D -> F
E (deleted)
Thank you,
Jim

Re: Remaping attribute values
OurGuest - Thu Oct 27 13:40:51 EDT 2011

SystemAdmin - Thu Oct 27 13:37:31 EDT 2011
Hello,

I am trying to remaping existing values to new values within an attribute that is of type enum with a drop down list of:
A
BC
D
E

and would like to updated the values in the list and the actual value assigned to it currently with out losing the data I would like to reasign it to the remap values.

Existing values:
A
BC
D
E

Update(remaping)
A -> A
BC -> D
D -> F
E (deleted)
Thank you,
Jim

Changing Types has been discuss frequently and you can find these discussions on changing types by search. However, I don't think anyone has documented a robust solution to the problem.

Re: Remaping attribute values
llandale - Thu Oct 27 15:28:14 EDT 2011

SystemAdmin - Thu Oct 27 13:37:31 EDT 2011
Hello,

I am trying to remaping existing values to new values within an attribute that is of type enum with a drop down list of:
A
BC
D
E

and would like to updated the values in the list and the actual value assigned to it currently with out losing the data I would like to reasign it to the remap values.

Existing values:
A
BC
D
E

Update(remaping)
A -> A
BC -> D
D -> F
E (deleted)
Thank you,
Jim

Searching for "+modify +enumeration" I found this thread although I recall there are more 'robust' ones for changing enumerations.

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14611389&#14611389

Since you will end up with 3 enumerations you will start with a few parellel arrays all of exactly size 3. Lets print two of them vertically:

Index    Old    New[]   Map[]   Comment
0       A       A       0       maps to previous A
1       BC      D       1       maps to previous BC
2       D       F       2       maps to previous D
3       E


You will add your own "values", "colors", and "descriptions" arrays, although perhaps they just have zeros and null strings.

The main key here is the undocumented version of "modify" that accepts the mapping array. Since position 3 is not in your mapping array, old value "E" is lost (which is in old position 3). It doesn't matter that both old and new have value "D" in different positions not mapped to each other.

There is also a Skip list based version which is a lot easier when you are dynamically determining new values and old mappings.

Once you can modify a single module then its just opening them all up, there are other posts for how to get all the modules in a project or folder.

For reasons I don't quite understand you will need to "refresh" all the objects in the module so they display the correct data: for obj in entire mod do{obj.NameAttr = obj.NameAttr}

 

 

  • Louie


Yes, there are no 'robust' solutions for changing the type of an attribute, say from "string" to "text"; although there is a tolerable one.

 

 

Re: Remaping attribute values
SystemAdmin - Wed Nov 02 18:00:28 EDT 2011

llandale - Thu Oct 27 15:28:14 EDT 2011

Searching for "+modify +enumeration" I found this thread although I recall there are more 'robust' ones for changing enumerations.

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14611389&#14611389

Since you will end up with 3 enumerations you will start with a few parellel arrays all of exactly size 3. Lets print two of them vertically:

Index    Old    New[]   Map[]   Comment
0       A       A       0       maps to previous A
1       BC      D       1       maps to previous BC
2       D       F       2       maps to previous D
3       E


You will add your own "values", "colors", and "descriptions" arrays, although perhaps they just have zeros and null strings.

The main key here is the undocumented version of "modify" that accepts the mapping array. Since position 3 is not in your mapping array, old value "E" is lost (which is in old position 3). It doesn't matter that both old and new have value "D" in different positions not mapped to each other.

There is also a Skip list based version which is a lot easier when you are dynamically determining new values and old mappings.

Once you can modify a single module then its just opening them all up, there are other posts for how to get all the modules in a project or folder.

For reasons I don't quite understand you will need to "refresh" all the objects in the module so they display the correct data: for obj in entire mod do{obj.NameAttr = obj.NameAttr}

 

 

  • Louie


Yes, there are no 'robust' solutions for changing the type of an attribute, say from "string" to "text"; although there is a tolerable one.

 

 

Hello,

Does anyone know the values for the color option?
For the Descs I tried changing "" to an actual string but didn't see it change anyone know why?

Thank you,
Jim
 

int     NewColor[] = {-1, -1, -1} // or figure out real colors; good luck with that
string  NewDescs[] = {"", "", ""}  // or add descriptions for "R - Requirement" etc
Module m = current
if (!null m)
{
    string ErrMess = ""
        m = edit(fullName m, true)
        
        //_Req Eval
        AttrDef ad = find(m, "_Req Eval")
        if(ad != null)
        {
                ErrMess = ""
                string  NewCodes[] = {"R - Requirement", "D - Description", "I - Information Only"}
                int     NewValus[] = {0, 0, 0}  // or perhaps 0,0,0,0
                int     NewColor[] = {-1, -1, -1} // or figure out real colors; good luck with that
                string  NewDescs[] = {"", "", ""}  // or add descriptions for "R - Requirement" etc
                int     NewMapping[] = {0, 1, 2}     // where '-1' is for "R - Requirement" and maps to nothing old
                
                AttrType at = find(m, ad.typeName)
                modify(at, "_Req Eval", NewCodes, NewValus, NewColor, NewDescs, NewMapping, ErrMess)
                if (!null ErrMess) { print "Error(_Req Eval): " ErrMess "\n"}
        }
}

 

 

Re: Remaping attribute values
llandale - Thu Nov 03 18:25:53 EDT 2011

SystemAdmin - Wed Nov 02 18:00:28 EDT 2011

Hello,

Does anyone know the values for the color option?
For the Descs I tried changing "" to an actual string but didn't see it change anyone know why?

Thank you,
Jim
 

int     NewColor[] = {-1, -1, -1} // or figure out real colors; good luck with that
string  NewDescs[] = {"", "", ""}  // or add descriptions for "R - Requirement" etc
Module m = current
if (!null m)
{
    string ErrMess = ""
        m = edit(fullName m, true)
        
        //_Req Eval
        AttrDef ad = find(m, "_Req Eval")
        if(ad != null)
        {
                ErrMess = ""
                string  NewCodes[] = {"R - Requirement", "D - Description", "I - Information Only"}
                int     NewValus[] = {0, 0, 0}  // or perhaps 0,0,0,0
                int     NewColor[] = {-1, -1, -1} // or figure out real colors; good luck with that
                string  NewDescs[] = {"", "", ""}  // or add descriptions for "R - Requirement" etc
                int     NewMapping[] = {0, 1, 2}     // where '-1' is for "R - Requirement" and maps to nothing old
                
                AttrType at = find(m, ad.typeName)
                modify(at, "_Req Eval", NewCodes, NewValus, NewColor, NewDescs, NewMapping, ErrMess)
                if (!null ErrMess) { print "Error(_Req Eval): " ErrMess "\n"}
        }
}

 

 

In a hurry and didn't check, but I think that array wants "real colors"; here is a list of such integer constants:

colorGrey colorRedGrey colorGrey77 colorGrey82 colorBlack colorBrown colorOrange colorWhite colorCyan colorMagenta colorGreen colorYellow colorRed colorMaroon colorBlue colorPink colorDarkTurquoise colorMediumLightBlue colorLightBlue

But you could create a sample Enyumerated list with colors, then use DXL to query their values.

The Descriptions should show extra text assocated with each enumeration, a new v9 feature. So your text should appear in the enumerated list in the GUI.

  • Louie