file [Solved] Export XMI issue

5 years 1 day ago #2902 by ebr
Hi Jean Claude,

Please find below a script able to find stereotypes without owner and taggedValues having a defintion (tagType) without owner.
In fact XMI export did not work when it found these kind of elements (a fix will be deliver in the next version).
def getFullName(element):
	name = element.getName() 
 	if(name ==""):
  		name = "??? " + element.getUuid().toString()
  	name = element.getMClass().getName() + " " + name
  	return name
  
def getName(element):
 	name = element.getName() 
  	if(name ==""):
  		name = "??? "
  	name = element.getMClass().getName() + " " + name + " " 
  	return name
    	
elements = modelingSession.findByClass(ModelElement)
for e in elements:
	sters = e.getExtension()
	for ster in sters:
		owner = ster.getOwner()
		if (owner is None):
			print "Element name: " + getName(e) + " Stereotype name: " + getFullName(ster)
#			ster.delete()
	
	tags = e.getTag()
	for tag in tags.toArray():
		if  not(tag is None):
			tagType = tag.getDefinition()
			ownerSter = tagType.getOwnerStereotype()
			ownerRef = tagType.getOwnerReference()
			if ((ownerSter is None) and (ownerRef is None)):
				print "Element name: " + getName(e) + " TaggedValue name: " + getName(tag)
#				tag.delete()
#       tagType.delete()
				

Hoping it helps,

Regards,

EBR
The following user(s) said Thank You: jcantoniochamp

Please Log in or Create an account to join the conversation.

5 years 1 day ago #2903 by jcantoniochamp
Excellent,

It did the job, thanks.

JClaude

Please Log in or Create an account to join the conversation.

Moderators: tmaebr
Time to create page: 0.037 seconds
^ Back to Top