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);
};
}
}
}
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 Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21994842