IBM Support

How to use Gateway OTScript with IBM Rational Rhapsody

Question & Answer


Question

How do you extract properties from the model using Gateway OTScript with IBM Rational Rhapsody?

Cause

You have found that model properties are not made available in the Gateway "Rhapsody" types. Nor can they be extracted from the intermediate file using regular expressions or XML conditions.

Answer

You will have to use OTScript to access model data via the IBM Rational Rhapsody API.


METHOD Rhapsody.ModelElement.asOperation() : { class_ := CLASS(Rhapsody.Operation); THIS[EACH ISA Rhapsody.Operation]; };

ATTRIBUTE Rhapsody.Operation.visibility : String;

METHOD Rhapsody.postprocessOperationVisibility(aDocument : Document, reloadedDocuments : Document) : {
postprocess(aDocument); // Call predefined post-process method

aDocument $< reloadedDocuments
IF TRUE: {
// retrieve the PreDeclarationModifier attribute we defined in our Rhapsody type
TMP PreDeclarationModifierAttribute := aDocument.documentType.findType("PreDeclarationModifier")[elementClass = Attribute];
TMP VisibilityAttribute := aDocument.documentType.findType("Visibility")[elementClass = Attribute];
$SOME(PreDeclarationModifierAttribute) AND $SOME(VisibilityAttribute)
IF TRUE: {
TMP rhpPrj := GETOBJECT(Rhapsody.Application,"").activeProject;
TMP operationTypes := aDocument.documentType.findType("Operation" $+ "Constructor" $+ "Destructor" $+ "TriggeredOperation" $+ "PrimitiveOperation" $+ "Reception");
operationTypes += aDocument.documentType.types[$SOME(superType) AND superType $< operationTypes];

aDocument.entities[type $< operationTypes].{

TMP visibility := rhpPrj.findElementByGUID(guid)[metaClass = "Operation"].asOperation.visibility;
$SOME(visibility) IF TRUE: newAttribute(VisibilityAttribute, visibility);

// look up the PreDeclarationModifier property value
TMP PreDeclarationModifierKey := "CPP_CG.Operation.PreDeclarationModifier";
TMP PreDeclarationModifierValue := rhpPrj.findElementByGUID(guid)[metaClass = "Operation"].asOperation.getPropertyValue(PreDeclarationModifierKey);
$SOME(PreDeclarationModifierValue) IF TRUE: newAttribute(PreDeclarationModifierAttribute, PreDeclarationModifierValue);
};
}
}
}


 
Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General Information","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"8.0;8.0.1;8.0.2;8.0.3;8.0.4;8.0.5;8.0.6;8.1;8.1.1;8.1.2;8.1.2.1;8.1.3;8.1.4;8.1.5","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21994842