Topic
  • 1 reply
  • Latest Post - ‏2013-05-15T12:22:43Z by Haskamp
Haskamp
Haskamp
2 Posts

Pinned topic Rhapsody API: Access "ImplementationProlog" during post-simplification

‏2013-05-15T07:10:35Z |

Hi,

I am trying to  modify the "implementationprolog" of an operation during post-simplification. I.e. I created a Rhapsody plugin based on the IBM example and could successfully modify e.g. the body of an operation after the basic simplification done by Rhapsody.

But how do I access/modify the "prolog" part as defined in property C_CG.Operation.ImplementationProlog?

- I see the applied prolog in  IRPOperation.getImplementationSignature() but this has no corresponding set-function.

- Modification of the property "ImplementationProlog" has no effect at postsimplification.

- I don't see another obvious set-function which might modify the prolog.

 

Any ideas?

 

Thanks,

Florian

  • Haskamp
    Haskamp
    2 Posts
    ACCEPTED ANSWER

    Re: Rhapsody API: Access "ImplementationProlog" during post-simplification

    ‏2013-05-15T12:22:43Z  

    Okay, found a solution myself... If anyone is interested:

     

    When enabling C_CG::Configuration::ShowCgSimplifiedModelPackage, the "simplified" model becomes visible and it can be seen that the property "ImplementationProlog" is converted into a comment during the simplification process.

    I.e. when modifying this comment during post-simplification, the prolog/epilog content can be modified like this :

    protected void onPostSimplification(IRPModelElement userElement, IRPModelElement mainSimplifiedElement,    String simplificationRequested) {
            if (mainSimplifiedElement instanceof IRPOperation) {
                IRPOperation simpleOperation =(IRPOperation)mainSimplifiedElement;
                String operationName =  simpleOperation.getName();
               
                IRPCollection allAnnotations = simpleOperation.getAnnotations();
                int count = allAnnotations.getCount();

                for (int i=1; i<=count; i++)
                {
                    Object o = allAnnotations.getItem(i);
                    if (o instanceof IRPComment)
                    {
                        IRPComment c = (IRPComment)o;
                         
                        c.setBody(c.getBody().replace("$name", operationName ));
                    }
                }
                

                
                
                
            }
        }

    Here a $name in the operation's prolog is replaced with the name of the operation itself.

     

    Florian

  • Haskamp
    Haskamp
    2 Posts

    Re: Rhapsody API: Access "ImplementationProlog" during post-simplification

    ‏2013-05-15T12:22:43Z  

    Okay, found a solution myself... If anyone is interested:

     

    When enabling C_CG::Configuration::ShowCgSimplifiedModelPackage, the "simplified" model becomes visible and it can be seen that the property "ImplementationProlog" is converted into a comment during the simplification process.

    I.e. when modifying this comment during post-simplification, the prolog/epilog content can be modified like this :

    protected void onPostSimplification(IRPModelElement userElement, IRPModelElement mainSimplifiedElement,    String simplificationRequested) {
            if (mainSimplifiedElement instanceof IRPOperation) {
                IRPOperation simpleOperation =(IRPOperation)mainSimplifiedElement;
                String operationName =  simpleOperation.getName();
               
                IRPCollection allAnnotations = simpleOperation.getAnnotations();
                int count = allAnnotations.getCount();

                for (int i=1; i<=count; i++)
                {
                    Object o = allAnnotations.getItem(i);
                    if (o instanceof IRPComment)
                    {
                        IRPComment c = (IRPComment)o;
                         
                        c.setBody(c.getBody().replace("$name", operationName ));
                    }
                }
                

                
                
                
            }
        }

    Here a $name in the operation's prolog is replaced with the name of the operation itself.

     

    Florian