Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Cannot Apply SysML Stereotypes(Unable to apply stereotypes from SysML profiles but applying stereotypes from custom profile works well)
Cannot Apply SysML Stereotypes [message #1403459] Wed, 23 July 2014 20:17 Go to next message
Hann Wu is currently offline Hann WuFriend
Messages: 2
Registered: July 2014
Junior Member
Hey everybody,

I am facing a bit of a problem here, i cannot apply stereotypes from SysML package.
I can apply the profiles and all that, but applying a stereotype doesn't work at all.
Besides SysML i am using another profile package, wich works like a charm.

For example, the stereotypeSut is from the custom profile that is loaded, while Blocks belongs to SysML.
val Class sut = syspack.createOwnedClass("SystemUnderTest", false)
		sut.applyStereotype(stereotypeBlock)
		sut.applyStereotype(stereotypeSut)


When is ask for the applicable stereotypes for classSut, i am presented with this output:
Check the applicable stereotypes for SystemUnderTest:
Stereotype: Block
Stereotype: PropertySpecificType
Stereotype: SYSTEM
Stereotype: SUT
Stereotype: TE
Stereotype: SUT2TE
Stereotype: TE2SUT
Stereotype: interface
Check the applied stereotypes for SystemUnderTest:
Stereotype: SUT


As far as i understand it, the SysML profile has been applied successfully and the stereotypes are recognized, but applying them fails and returns null.

I hope you can help me out, i tried various thing suggested from other threads (and i am willing to try even more) but nothing worked so far.

The language used is Xtend, but since it's just a little enhancement to java i hope that wont be a problem (answers in Java are appreciated!)


package de.hub.uml2.rtt.transformation

import de.fokus.fraunhofer.mbt.productlines.loaders.savers.umlmodel.UMLModelLoader
import de.hub.uml2.helper.transformation.HelperFunctions
import java.util.Map
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EPackage
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage
import org.eclipse.papyrus.sysml.SysmlPackage
import org.eclipse.papyrus.sysml.blocks.BlocksPackage
import org.eclipse.papyrus.sysml.portandflows.PortandflowsPackage
import org.eclipse.uml2.uml.AggregationKind
import org.eclipse.uml2.uml.Class
import org.eclipse.uml2.uml.DataType
import org.eclipse.uml2.uml.Element
import org.eclipse.uml2.uml.Enumeration
import org.eclipse.uml2.uml.EnumerationLiteral
import org.eclipse.uml2.uml.Model
import org.eclipse.uml2.uml.NamedElement
import org.eclipse.uml2.uml.Package
import org.eclipse.uml2.uml.Port
import org.eclipse.uml2.uml.Profile
import org.eclipse.uml2.uml.Property
import org.eclipse.uml2.uml.Stereotype
import org.eclipse.uml2.uml.UMLFactory
import org.eclipse.uml2.uml.UMLPackage
import org.eclipse.uml2.uml.VisibilityKind
import org.eclipse.uml2.uml.resource.UMLResource

class RTTModelTransformator {
	static boolean DEBUG = true;
	
	/**
	 * Expects an input path from where the model is loaded and an 
	 * output path to store the output model. The output model is stored 
	 * for future reference and debugging purposes.
	 * 
	 * @param filePath: source file of the UML model
	 *
	 */
	def static Model transformModel( String filePath) {
		//load the helper functions
		val helperFunctions = new HelperFunctions;
		
		//create the new model
		val Model newModel = UMLFactory.eINSTANCE.createModel
		val Package syspack = newModel.createNestedPackage("SYSTEM")
		syspack.setVisibility(VisibilityKind.PUBLIC_LITERAL)
		
		//create the blocks profile with the block stereotype
		val Profile profileBlocks = loadSysmlProfile( "Blocks" )
		syspack.applyProfile(profileBlocks)
		val Stereotype stereotypeBlock = profileBlocks.getOwnedMember( "Block" ) as Stereotype
		val Profile profilePortAndFlows = loadSysmlProfile( "PortAndFlows" )
		syspack.applyProfile(profilePortAndFlows)
		if(DEBUG){
			System.out.println("URI of profile Blocks: "+profileBlocks.URI)
			System.out.println("URI of profile PortAndFlows: "+profilePortAndFlows.URI)
		}
		val Stereotype stereotypeFlowPort = profilePortAndFlows.getOwnedMember("FlowPort") as Stereotype
		val Enumeration enumerationFlowDirection = profilePortAndFlows.getOwnedMember("FlowDirection") as Enumeration
		val EnumerationLiteral enumliteralFlowDirectionIn = enumerationFlowDirection.getOwnedLiteral("in")
		val EnumerationLiteral enumliteralFlowDirectionOut = enumerationFlowDirection.getOwnedLiteral("out")
		if(DEBUG){
			System.out.println("The stereotype "+stereotypeFlowPort.name+"... ")
			for(Property p : stereotypeFlowPort.ownedAttributes){
				System.out.println("...has property "+p.name)
			}
			System.out.println("The stereotype "+stereotypeBlock.name+"... ")
			for(Property p : stereotypeBlock.ownedAttributes){
				System.out.println("...has property "+p.name)
			}
		}
		
		//create profile for the stereotypes that are used in RTT
		val Profile profileRtt = loadProfile("platform:/plugin/de.hub.uml2.rtt/src/RTT-MBTProfile/model.profile.uml")
		syspack.applyProfile(profileRtt)
		val Stereotype stereotypeSystem = profileRtt.getOwnedMember("SYSTEM") as Stereotype
		val Stereotype stereotypeSut = profileRtt.getOwnedMember("SUT") as Stereotype
		val Stereotype stereotypeTe = profileRtt.getOwnedMember("TE") as Stereotype

		syspack.applyStereotype(stereotypeSystem)
		if(DEBUG){
			System.out.println("Check the applicable stereotypes for "+syspack.name+":")
			for( Stereotype s : syspack.applicableStereotypes){
				System.out.println("Stereotype: "+s.name)
			}
			System.out.println("Check the applied stereotypes for "+syspack.name+":")
			for( Stereotype s : syspack.appliedStereotypes){
				System.out.println("Stereotype: "+s.name)
			}
		}
		

		val Class sut = syspack.createOwnedClass("SystemUnderTest", false)
		if(DEBUG){
			System.out.println("Owned elements of the "+syspack.name+" package:")
			for( NamedElement e : syspack.members){
				System.out.println("Element: "+ e.name)
			}
			System.out.println("Applied profiles of the "+syspack.name+" package:")
			for( Profile e : syspack.allAppliedProfiles){
				System.out.println("Profile: "+ e.name)
			}
			System.out.println("Check the applicable stereotypes for "+sut.name+":")
			for( Stereotype s : sut.applicableStereotypes){
				System.out.println("Stereotype: "+s.name)
			}
		}
		sut.applyStereotype(stereotypeBlock)
		sut.applyStereotype(stereotypeSut)
		if(DEBUG){
			System.out.println("Check the applied stereotypes for "+sut.name+":")
			for( Stereotype s : sut.appliedStereotypes){
				System.out.println("Stereotype: "+s.name)
			}
		}
		val Class te = syspack.createOwnedClass("TestEnviroment", false)
		te.applyStereotype(stereotypeBlock)
		te.applyStereotype(stereotypeTe)
		
		return newModel
	}
	
	def static Profile createProfile(String name) {
		val Profile profile = UMLFactory.eINSTANCE.createProfile()
        profile.setName(name)
        profile.setVisibility(VisibilityKind.PUBLIC_LITERAL)
        
		return profile;
    }
    
    def static ResourceSet loadResourceSet(){
    	val ResourceSet resourceSet =  new ResourceSetImpl();
		resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(UMLPackage.eCONTENT_TYPE, UMLPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(UMLPackage.eNAME, UMLPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(UMLPackage.eNS_PREFIX, UMLPackage.eINSTANCE);
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
	
		EPackage.Registry.INSTANCE.put("http://www.eclipse.org/uml2/2.0.0/UML", EPackage.Registry.INSTANCE.get(UMLPackage.eINSTANCE.getNsURI()));
		EPackage.Registry.INSTANCE.put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
		EPackage.Registry.INSTANCE.put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
		EPackage.Registry.INSTANCE.put(PortandflowsPackage.eNS_URI, PortandflowsPackage.eINSTANCE);
		Ecore2XMLPackage.eINSTANCE.getEClassifiers();
		
		val Map uriMap = resourceSet.getURIConverter().getURIMap();
		val URI urii = URI.createURI("jar:platform:/plugin/de.hub.uml2.rtt/lib/org.eclipse.uml2.uml.resources_4.1.0.v20140202-2055.jar!/");
		uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), urii.appendSegment("libraries").appendSegment(""));
		uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), urii.appendSegment("metamodels").appendSegment(""));
		uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), urii.appendSegment("profiles").appendSegment(""));
		return resourceSet
    }
    

    def static Profile loadProfile( String uri ) {
		val ResourceSet resourceSet = loadResourceSet()			
		val Resource resource = resourceSet.getResource(URI.createURI(uri), true)
		resource.load(null)
		val Profile p = EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.PROFILE) as Profile
	  	
	  	return p
    }
    
    def static Profile loadSysmlProfile(String profilename ) {
		val ResourceSet resourceSet = loadResourceSet()
		//val Resource resource = resourceSet.getResource(URI.createURI("pathmap://SysML_PROFILES/SysML.profile.uml"), true)
		val Resource resource = resourceSet.getResource(URI.createURI("platform:/plugin/de.hub.uml2.rtt/src/profiles/SysML.profile.uml"), true)
		resource.load(null)
		
		val Profile sysMlProfile = EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.PROFILE) as Profile		
		if(DEBUG){
			System.out.println("sysMlProfile: "+sysMlProfile.name+" with URI "+sysMlProfile.URI)
		}
		val Profile p = sysMlProfile.getOwnedMember(profilename) as Profile
	  	if(DEBUG){
			System.out.println("Called profile: "+p.name+" with URI "+p.URI+" and owned elements: ")
			for(Element e : p.allOwnedElements ){
				System.out.println("Element with name: "+e.toString)
			}
		}
	  	return p
    }
	
	def static Stereotype createStereotype(Profile profile, String name, boolean isAbstract){
		val Stereotype stereo = profile.createOwnedStereotype(name, isAbstract)
		stereo.setVisibility(VisibilityKind.PUBLIC_LITERAL)
		
		return stereo
	}
	
	def static Enumeration createEnumeration(Package pack, String name){
		val Enumeration enuma = pack.createOwnedEnumeration(name)
		enuma.setVisibility(VisibilityKind.PUBLIC_LITERAL)
		
		return enuma
	}
	
}

Check the applicable stereotypes for SystemUnderTest:
Stereotype: Block
Stereotype: PropertySpecificType
Stereotype: SYSTEM
Stereotype: SUT
Stereotype: TE
Stereotype: SUT2TE
Stereotype: TE2SUT
Stereotype: interface
Check the applied stereotypes for SystemUnderTest:
Stereotype: SUT
Re: Cannot Apply SysML Stereotypes [message #1403718 is a reply to message #1403459] Fri, 25 July 2014 14:18 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

See some replies in-line, below.

HTH,

Christian


On 2014-07-24 13:50:02 +0000, Hann Wu said:

> Hey everybody,
>
> I am facing a bit of a problem here, i cannot apply stereotypes from
> SysML package.
> I can apply the profiles and all that, but applying a stereotype
> doesn't work at all.

What does "doesn't work at all" mean? Is there an exception thrown?
If so, the message and stack trace should tell you what the problem is.

Are you able to apply this stereotype in the UML Editor? Or does the
UML Editor simply not show the stereotype applied, but without some
error dialog appearing? Does the UML Editor not even present the
stereotype in the list of stereotypes that may be applied?


> Besides SysML i am using another profile package, wich works like a charm.

Lots of profiles have been known to work. Profiles that don't are
usually broken in some way.


> For example, the stereotypeSut is from the custom profile that is
> loaded, while Blocks belongs to SysML.
> val Class sut = syspack.createOwnedClass("SystemUnderTest", false)
> sut.applyStereotype(stereotypeBlock)
> sut.applyStereotype(stereotypeSut)
>
> When is ask for the applicable stereotypes for classSut, i am presented
> with this output:
> Check the applicable stereotypes for SystemUnderTest:
> Stereotype: Block
> Stereotype: PropertySpecificType
> Stereotype: SYSTEM
> Stereotype: SUT
> Stereotype: TE
> Stereotype: SUT2TE
> Stereotype: TE2SUT
> Stereotype: interface
> Check the applied stereotypes for SystemUnderTest:
> Stereotype: SUT
>
> As far as i understand it, the SysML profile has been applied
> successfully and the stereotypes are recognized, but applying them
> fails and returns null.

What fails? What returns null? The
Element::applyStereotype(Stereotype) operation? Or something else?


> I hope you can help me out, i tried various thing suggested from other
> threads (and i am willing to try even more) but nothing worked so far.

Have you tried stepping through
ElementOperations::applyStereotype(Element, Stereotype) and its call
tree in the debugger to see where it goes off the rails?


> The language used is Xtend, but since it's just a little enhancement to
> java i hope that wont be a problem (answers in Java are appreciated!)

Xtend just compiles to Java, so that shouldn't be a concern.

But I don't know what your SysML profile is. Evidently it's not the
one provided by Papyrus, because this problems hasn't been reported for
that profile.


> package de.hub.uml2.rtt.transformation
>
> import
> de.fokus.fraunhofer.mbt.productlines.loaders.savers.umlmodel.UMLModelLoader
>
> import de.hub.uml2.helper.transformation.HelperFunctions
> import java.util.Map
> import org.eclipse.emf.common.util.URI
> import org.eclipse.emf.ecore.EPackage
> import org.eclipse.emf.ecore.resource.Resource
> import org.eclipse.emf.ecore.resource.ResourceSet
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
> import org.eclipse.emf.ecore.util.EcoreUtil
> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage
> import org.eclipse.papyrus.sysml.SysmlPackage
> import org.eclipse.papyrus.sysml.blocks.BlocksPackage
> import org.eclipse.papyrus.sysml.portandflows.PortandflowsPackage
> import org.eclipse.uml2.uml.AggregationKind
> import org.eclipse.uml2.uml.Class
> import org.eclipse.uml2.uml.DataType
> import org.eclipse.uml2.uml.Element
> import org.eclipse.uml2.uml.Enumeration
> import org.eclipse.uml2.uml.EnumerationLiteral
> import org.eclipse.uml2.uml.Model
> import org.eclipse.uml2.uml.NamedElement
> import org.eclipse.uml2.uml.Package
> import org.eclipse.uml2.uml.Port
> import org.eclipse.uml2.uml.Profile
> import org.eclipse.uml2.uml.Property
> import org.eclipse.uml2.uml.Stereotype
> import org.eclipse.uml2.uml.UMLFactory
> import org.eclipse.uml2.uml.UMLPackage
> import org.eclipse.uml2.uml.VisibilityKind
> import org.eclipse.uml2.uml.resource.UMLResource
>
> class RTTModelTransformator {
> static boolean DEBUG = true;
>
> /**
> * Expects an input path from where the model is loaded and an *
> output path to store the output model. The output model is stored *
> for future reference and debugging purposes.
> * * @param filePath: source file of the UML model
> *
> */
> def static Model transformModel( String filePath) {
> //load the helper functions
> val helperFunctions = new HelperFunctions;
>
> //create the new model
> val Model newModel = UMLFactory.eINSTANCE.createModel
> val Package syspack = newModel.createNestedPackage("SYSTEM")
> syspack.setVisibility(VisibilityKind.PUBLIC_LITERAL)
>
> //create the blocks profile with the block stereotype
> val Profile profileBlocks = loadSysmlProfile( "Blocks" )
> syspack.applyProfile(profileBlocks)
> val Stereotype stereotypeBlock = profileBlocks.getOwnedMember(
> "Block" ) as Stereotype
> val Profile profilePortAndFlows = loadSysmlProfile( "PortAndFlows" )
> syspack.applyProfile(profilePortAndFlows)
> if(DEBUG){
> System.out.println("URI of profile Blocks: "+profileBlocks.URI)
> System.out.println("URI of profile PortAndFlows: "+profilePortAndFlows.URI)
> }
> val Stereotype stereotypeFlowPort =
> profilePortAndFlows.getOwnedMember("FlowPort") as Stereotype
> val Enumeration enumerationFlowDirection =
> profilePortAndFlows.getOwnedMember("FlowDirection") as Enumeration
> val EnumerationLiteral enumliteralFlowDirectionIn =
> enumerationFlowDirection.getOwnedLiteral("in")
> val EnumerationLiteral enumliteralFlowDirectionOut =
> enumerationFlowDirection.getOwnedLiteral("out")
> if(DEBUG){
> System.out.println("The stereotype "+stereotypeFlowPort.name+"... ")
> for(Property p : stereotypeFlowPort.ownedAttributes){
> System.out.println("...has property "+p.name)
> }
> System.out.println("The stereotype "+stereotypeBlock.name+"... ")
> for(Property p : stereotypeBlock.ownedAttributes){
> System.out.println("...has property "+p.name)
> }
> }
>
> //create profile for the stereotypes that are used in RTT
> val Profile profileRtt =
> loadProfile("platform:/plugin/de.hub.uml2.rtt/src/RTT-MBTProfile/model.profile.uml")
>
> syspack.applyProfile(profileRtt)
> val Stereotype stereotypeSystem = profileRtt.getOwnedMember("SYSTEM")
> as Stereotype
> val Stereotype stereotypeSut = profileRtt.getOwnedMember("SUT") as Stereotype
> val Stereotype stereotypeTe = profileRtt.getOwnedMember("TE") as Stereotype
>
> syspack.applyStereotype(stereotypeSystem)
> if(DEBUG){
> System.out.println("Check the applicable stereotypes for "+syspack.name+":")
> for( Stereotype s : syspack.applicableStereotypes){
> System.out.println("Stereotype: "+s.name)
> }
> System.out.println("Check the applied stereotypes for "+syspack.name+":")
> for( Stereotype s : syspack.appliedStereotypes){
> System.out.println("Stereotype: "+s.name)
> }
> }
>
>
> val Class sut = syspack.createOwnedClass("SystemUnderTest", false)
> if(DEBUG){
> System.out.println("Owned elements of the "+syspack.name+" package:")
> for( NamedElement e : syspack.members){
> System.out.println("Element: "+ e.name)
> }
> System.out.println("Applied profiles of the "+syspack.name+" package:")
> for( Profile e : syspack.allAppliedProfiles){
> System.out.println("Profile: "+ e.name)
> }
> System.out.println("Check the applicable stereotypes for "+sut.name+":")
> for( Stereotype s : sut.applicableStereotypes){
> System.out.println("Stereotype: "+s.name)
> }
> }
> sut.applyStereotype(stereotypeBlock)
> sut.applyStereotype(stereotypeSut)
> if(DEBUG){
> System.out.println("Check the applied stereotypes for "+sut.name+":")
> for( Stereotype s : sut.appliedStereotypes){
> System.out.println("Stereotype: "+s.name)
> }
> }
> val Class te = syspack.createOwnedClass("TestEnviroment", false)
> te.applyStereotype(stereotypeBlock)
> te.applyStereotype(stereotypeTe)
>
> return newModel
> }
>
> def static Profile createProfile(String name) {
> val Profile profile = UMLFactory.eINSTANCE.createProfile()
> profile.setName(name)
> profile.setVisibility(VisibilityKind.PUBLIC_LITERAL)
> return profile;
> }
> def static ResourceSet loadResourceSet(){
> val ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(UMLPackage.eCONTENT_TYPE,
> UMLPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(UMLPackage.eNAME, UMLPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_PREFIX,
> UMLPackage.eINSTANCE);
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
>
>
> EPackage.Registry.INSTANCE.put("http://www.eclipse.org/uml2/2.0.0/UML",
> EPackage.Registry.INSTANCE.get(UMLPackage.eINSTANCE.getNsURI()));
> EPackage.Registry.INSTANCE.put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
> EPackage.Registry.INSTANCE.put(BlocksPackage.eNS_URI,
> BlocksPackage.eINSTANCE);
> EPackage.Registry.INSTANCE.put(PortandflowsPackage.eNS_URI,
> PortandflowsPackage.eINSTANCE);
> Ecore2XMLPackage.eINSTANCE.getEClassifiers();
>
> val Map uriMap = resourceSet.getURIConverter().getURIMap();
> val URI urii =
> URI.createURI("jar:platform:/plugin/de.hub.uml2.rtt/lib/org.eclipse.uml2.uml.resources_4.1.0.v20140202-2055.jar!/");
>
> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
> urii.appendSegment("libraries").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
> urii.appendSegment("metamodels").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
> urii.appendSegment("profiles").appendSegment(""));
> return resourceSet
> }
>
> def static Profile loadProfile( String uri ) {
> val ResourceSet resourceSet = loadResourceSet()
> val Resource resource = resourceSet.getResource(URI.createURI(uri), true)
> resource.load(null)
> val Profile p = EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.PROFILE) as Profile
>
> return p
> }
> def static Profile loadSysmlProfile(String profilename ) {
> val ResourceSet resourceSet = loadResourceSet()
> //val Resource resource =
> resourceSet.getResource(URI.createURI("pathmap://SysML_PROFILES/SysML.profile.uml"),
> true)
> val Resource resource =
> resourceSet.getResource(URI.createURI("platform:/plugin/de.hub.uml2.rtt/src/profiles/SysML.profile.uml"),
> true)
> resource.load(null)
>
> val Profile sysMlProfile =
> EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.PROFILE) as Profile
> if(DEBUG){
> System.out.println("sysMlProfile: "+sysMlProfile.name+" with URI
> "+sysMlProfile.URI)
> }
> val Profile p = sysMlProfile.getOwnedMember(profilename) as Profile
> if(DEBUG){
> System.out.println("Called profile: "+p.name+" with URI "+p.URI+"
> and owned elements: ")
> for(Element e : p.allOwnedElements ){
> System.out.println("Element with name: "+e.toString)
> }
> }
> return p
> }
>
> def static Stereotype createStereotype(Profile profile, String name,
> boolean isAbstract){
> val Stereotype stereo = profile.createOwnedStereotype(name, isAbstract)
> stereo.setVisibility(VisibilityKind.PUBLIC_LITERAL)
>
> return stereo
> }
>
> def static Enumeration createEnumeration(Package pack, String name){
> val Enumeration enuma = pack.createOwnedEnumeration(name)
> enuma.setVisibility(VisibilityKind.PUBLIC_LITERAL)
>
> return enuma
> }
>
> }
>
> Check the applicable stereotypes for SystemUnderTest:
> Stereotype: Block
> Stereotype: PropertySpecificType
> Stereotype: SYSTEM
> Stereotype: SUT
> Stereotype: TE
> Stereotype: SUT2TE
> Stereotype: TE2SUT
> Stereotype: interface
> Check the applied stereotypes for SystemUnderTest:
> Stereotype: SUT
Re: Cannot Apply SysML Stereotypes [message #1403722 is a reply to message #1403718] Fri, 25 July 2014 14:39 Go to previous message
Hann Wu is currently offline Hann WuFriend
Messages: 2
Registered: July 2014
Junior Member
I see, i should have written this more detailed, sorry about that.
With 'doesnt work at all' i wanted to express, that nothing happens. No exception is thrown, but a null-object returned and the code continues (up to the point where i try to set a property of the applied stereotype, that crashes with an IllegalArgumentException since the requested stereotype is not applied).

In the list of applicable stereotypes the stereotype is listed, so it's not unknown and it exists (more or less i think), but every try to apply it results in the problem described above. By the way i didn't use the UML Editor because the code is intended to be a plugin to transform another model. But using the SysML-Profile with the editor works well.

Quote:
What fails? What returns null? The
Element::applyStereotype(Stereotype) operation? Or something else?


Yeah, this one.


Quote:
But I don't know what your SysML profile is. Evidently it's not the
one provided by Papyrus, because this problems hasn't been reported for
that profile.


That's the part i don't understand either. It actually is the profile from Papyrus, directly taken from the .jar/model/.

Thanks for your help!


############################################################
Since i don't have much time left to complete the project i used a workaround suggested by a friend. I know it doesn't solve the problem or explains why this happened to me, but maybe someone else runs into a similar problem and finds this helpful:
I created a template model, that contains the root package. The profiles in question were directly applied. This way the stereotype problem doens't occure and i start the transformation with editing the template.
Previous Topic:Documentation of the UML2/EMF codegen
Next Topic:UML 2.4 schema
Goto Forum:
  


Current Time: Thu Apr 25 10:27:23 GMT 2024

Powered by FUDForum. Page generated in 0.03298 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top