Is there a way to import multiple enumerands in IBM Rhapsody?

38 Views Asked by At

I have an enumerand of around 150 entries, which I need to get into IBM Rhapsody.

Doing this by hand is clearly lengthy and error prone. I have google extensively but found only things that tell me how to edit the generated code -- not go the other way.

The question is: How is this done? And if there is no way -- please someone post that as an answer.

2

There are 2 best solutions below

0
bauhaus9 On

David, I would jump into the Java API (plugin subsystem) and do it that way. If you haven't learned how to use the API, there is a bit of a learning curve. There are two ways to go about it: Implement a Java (or your favorite JVM language--I use Scala) app that realizes the Rhapsody Plugin framework and then you choose to package it up and deploy it so that it gets loaded when you load your model, or, if it is a one off job, do everything up to the point of packaging it up and then run it from within your IDE and you are done. If you are comfortable with Scala, I can post some code.

0
David Boshton On

So what I did in the end was I edited the relevant .sbs file, used a small python program to generate the items I required, and then update the length of the array accordingly.

all_the_literals = ["enum_name = 0x4e", enum_name2 = 0xF2", ... ,]
for field1, waste, field1_value in map(lambda x: x.split(" "),
                                                   all_the_literals):
    literal_string  = f"""                              {{ IEnumerationLiteral 
                                        - _id = GUID {uuid.uuid4()};
                                        - _name = \"{field1}\";
                                        - codeUpdateCGTime = 5.16.2022::19:24:18;
                                        - _modifiedTimeWeak = 5.16.2022::19:24:18;
                                        - _value = \"{field1_value}\";
                                }}"""
    print(literal_string)

Note the above "code" snippet purely prints the items, which you then copy-paste into the relevant field in the sbs file. YMMV -- this was the correct format for an enum in Rhapsody (and note how I fudged the update time, but it worked successfully, so you'll need to do the same if you use this answer).

Also note it's probably better to use bauhaus9's answer, but I definitely didn't have time for it.