JavaScript Macro error: ModelHelper.setSupplierElement is no

Starting point for “ask and learn more about MagicDraw”

Moderator: Moderators

JavaScript Macro error: ModelHelper.setSupplierElement is no

Postby tammy.bogart@g2-ops.com » Tue Jan 28, 2020 3:04 pm

Please help, below is a snippet of my code, everything is working but the last 2 lines. I have changed a few things to "test" for security. But the rest is just like my code. Can you tell me why setSupplierElement() is not considered a function?

***************************************************************macro: JS**********************************************************
var CollectionsAndFiles = new JavaImporter (
com.nomagic.magicdraw.core.Application,

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Relationship,
com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element,
com.nomagic.magicdraw.openapi.uml.SessionManager,
com.nomagic.uml2.ext.jmi.helpers.ModelHelper,
com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper,
com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency,
com.nomagic.uml2.ext.magicdraw.classes.mdkernel,
com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class,
com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package,
com.nomagic.uml2.ext.magicdraw.components.mdbasiccomponents.Component,
com.nomagic.uml2.ext.magicdraw.mdprofiles.Stereotype,
com.nomagic.uml2.impl.ElementsFactory,
com.nomagic.uml2.ext.jmi.helpers.CoreHelper,
com.nomagic.uml2.ext.magicdraw.classes.mddependencies, //needed for abstractionclass
com.nomagic.magicdraw.diff.ElementDifference,
com.nomagic.magicdraw.diff.mdextensions,
com.nomagic.magicdraw.uml.Finder,
com.nomagic.magicdraw.openapi.uml,
com.nomagic.magicdraw.core,
com.nomagic.magicdraw.core.project,
com.nomagic.magicdraw.uml,
com.nomagic.magicdraw.uml.Finder.ByTypeRecursivelyFinder,
java.io.File,
java.io.IOException,
java.net.URI,
java.util.ArrayList,
java.util.Collection,
java.util.List,
java.lang,
java.lang.String,
java.lang.Class,
java.lang.object,
javax.script,
com.nomagic.reportwizard.tools.script.JavaScriptTool );

with (CollectionsAndFiles){

var project = Application.getInstance().getProject();
var req = project.getElementsFactory().createClassInstance();
var reqStereotype = StereotypesHelper.getStereotype(project, "Requirement", "SysML");
var requirement_st = StereotypesHelper.getStereotype(project, "FunctionalRequirement");
var sofiaRequirement_st = StereotypesHelper.getStereotype(project, "SOFIA_Requirement");
var derived_st = StereotypesHelper.getStereotype(project, "DeriveReqt");
var reqPackage = project.getElementByID("_19_0_2_19cb0468_1580241930489_365408_1421");
var functionalReq_package = project.getElementByID("_19_0_2_154d0403_1577472893555_973266_4712");

req.setName("TESTTEST");
req.setOwner(reqPackage);
StereotypesHelper.addStereotype(req, requirement_st);
StereotypesHelper.setStereotypePropertyValue(req, requirement_st, "Text", "THIS IS A TEST", false, false);
StereotypesHelper.setStereotypePropertyValue(req, reqStereotype,"Id", 8517);
StereotypesHelper.addStereotype(req, sofiaRequirement_st);
//create derived relationship
relationD = project.getElementsFactory().createAbstractionInstance();
relationD.setOwner(functionalReq_package);
StereotypesHelper.addStereotype(relationD, derived_st);
ModelHelper.setSupplierElement(relationD,reqPackage);
ModelHelper.setClientElement(relationD, req);
}
tammy.bogart@g2-ops.com
Forum Newbie
Forum Newbie
 
Posts: 16
Posts Rating:0
Joined: Wed Oct 09, 2019 9:11 am

Re: JavaScript Macro error: ModelHelper.setSupplierElement is no

Postby jwedding » Fri Jun 12, 2020 12:31 pm

jwedding
Forum Newbie
Forum Newbie
 
Posts: 7
Posts Rating:1
Joined: Mon Aug 11, 2014 11:05 am


Return to New to MagicDraw

Who is online

Users browsing this forum: No registered users and 0 guests

cron