Hi,
How do I set or create a value property for an empty Classifier block programmatic-ally?
The block already exists within the project. I want my code to dynamically generate value properties for it.
Thanks!
Moderator: Moderators
while(it.hasNext()) {
String field = it.next();
ElementsFactory factory = Application.getInstance().getProject().getElementsFactory();
//Locate and assign the classifier block sent to method via method parameters
Classifier blockClassifier = ClassifierFinder.findClassifierOrDataType(project, blockClassifierName, null, baseClassifierPackage);
//Create a new property instance
Property property = factory.createPropertyInstance();
//Locate the profile within the project that houses the required stereotype
Profile profile = StereotypesHelper.getProfile(project, "MD Customization for SysML");
//Assign the ValueProperty stereotype to the newly created stereotype
Stereotype stereotype = StereotypesHelper.getStereotype(project, "ValueProperty", profile);
//Add the stereotype to the property
StereotypesHelper.addStereotype(property, stereotype);
DataType type = factory.createDataTypeInstance();
property.setName(field);
property.setClassifier(blockClassifier);
}
Project project = Application.getInstance().getProject()
ElementsFactory factory = project.getElementsFactory();
//Locate and assign the classifier block sent to method via method parameters
Classifier blockClassifier = ClassifierFinder.findClassifierOrDataType(project, blockClassifierName, null, baseClassifierPackage);
//Create a new property instance
Property property = factory.createPropertyInstance();
//Locate the profile within the project that houses the required stereotype
Stereotype stereotype = MDCustomizationForSysMLProfile.getInstance(project).getValueProperty()
//Add the stereotype to the property
StereotypesHelper.addStereotype(property, stereotype);
property.setName(field);
property.setOwner(blockClassifier);
Type type = MDCustomizationForSysMLProfile.getInstance(project).getDataType("String");
property.setType(type);
gfazzino@tietronix.com wrote:I've the same issue. Working on MD 2021xRefresh 1 and can't find SysMLProfile class in the jars. If someone can help.
Return to Programmatic Extendibility
Users browsing this forum: No registered users and 0 guests