Exemplo n.º 1
0
def RedefinitionGenAdd(redefElem,redefName,redefSt,Props,property,gen,newassoc,RedAdd,GenAdd):
    #gl.log("********Do we even get into this script**********"+redefName)
    #gl.log("******The property Name====>"+property.getQualifiedName())
    check=0
    for l in redefElem:
        if isinstance(l,Property) and check==0:
            #NameR=l.getName().strip()
            NameR=l.getName().replace("Abstract","")
            NameR=NameR.strip()
            #gl.log("the name of the redefined element=====>"+NameR.replace("Astract","").strip()+"     and the name of the redefinition=====>"+redefName)  # this is not a good check here at all
            #if isinstance(l,Property):
            #gl.log("*******====>"+l.getName())
            #probelm here with this name matching....state variable...does not match variable
            if property.getType()!=None and l.getType()!=None:
                if NameR==redefName or StereotypesHelper.getStereotypes(property.getType())==StereotypesHelper.getStereotypes(l.getType()):
                    gl.log("******Adding the appropriate redefinition! To the Property=====>"+property.getQualifiedName())
                    check=1
                    Props.add(l)
                    RedAdd+=1
                    if len(Props)==1:
                        Props[0].setName(NameR)
                        if gen==True:
                            csAssoc=l.getAssociation()
                            CreateGeneralization(csAssoc,newassoc)
                            GenAdd+=1
                        if redefSt !=None:
                            #gl.log("------------------------HEY------------------"+redefSt.getName())
                            StereotypesHelper.addStereotype(property,redefSt)
                        break

                
    return RedAdd,GenAdd
Exemplo n.º 2
0
def copyStereotypes(a, b):
    for s in StereotypesHelper.getStereotypes(a):
        if not StereotypesHelper.hasStereotypeOrDerived(b, s):
            StereotypesHelper.addStereotype(b, s)
        smap = StereotypesHelper.getPropertiesIncludingParents(s)
        for sp in smap.keySet():
            props = smap.get(sp)
            for p in props:
                values = StereotypesHelper.getStereotypePropertyValue(
                    a, s, p.getName())
                if len(values) == 1:
                    StereotypesHelper.setStereotypePropertyValue(
                        b, s, p.getName(), values.get(0))
                elif len(values) > 1:
                    StereotypesHelper.setStereotypePropertyValue(
                        b, s, p.getName(), values)
Exemplo n.º 3
0
def createCustomization(stereotypeName, owner):
	MDcustPackage = filter(lambda element: isinstance(element, Package) and element.getName() == "MD Customization for SysML", datapack.getOwnedElement())[0]
	syscustPackage = filter(lambda element: isinstance(element, Package) and element.getName() == "customizations", MDcustPackage.getOwnedElement())[0]
	new = ef.createClassInstance()
	new.setOwner(owner)
	new.setName(stereotypeName)
	StereotypesHelper.addStereotype(new, StereotypesHelper.getStereotype(project, "Customization"))
	ster = StereotypesHelper.getStereotype(project, stereotypeName)
    #get ster generalizations:
	sterGen = filter(lambda element: isinstance(element, Generalization), ster.get_directedRelationshipOfSource())
	for s in sterGen:
		cust = filter(lambda element: element.getName().replace(" ","") == s.getGeneral().getName().replace(" ",""), syscustPackage.getOwnedElement())
		if len(cust) !=0:
			cust = cust[0]
			newgen = ef.createGeneralizationInstance()
			newgen.setGeneral(cust)
			newgen.setSpecific(new)
			newgen.setOwner(new)
	return new
Exemplo n.º 4
0
def createStereotype(owner, element, stereotypePackage):
	'''append Package to any package element, this is an OpsRev naming convention '''
	if isinstance(element, Package):
	 	package = element.getName().find("Package")
	 	if package == -1:
			element.setName(element.getName() + " Package")   
	'''stereotypes should not be made for enumeration literals'''         
	if not isinstance(element, EnumerationLiteral):
	    eSter = StereotypesHelper.getAllAssignedStereotypes([element])
	    elementSterName = propertyCheck(element)
	    newSter = StereotypesHelper.createStereotype(owner, elementSterName, [StereotypesHelper.getBaseClass(element)])
	    StereotypesHelper.addStereotype(element, newSter)
	    for e in eSter:
	    	if StereotypesHelper.getProfileForStereotype(e) == StereotypesHelper.getProfile(project, "SysML") or StereotypesHelper.getProfileForStereotype(e) == StereotypesHelper.getProfile(project, "additional_stereotypes"):
		    	newgen = ef.createGeneralizationInstance()
		        newgen.setGeneral(e)
		        newgen.setSpecific(newSter)
		        newgen.setOwner(newSter)
		    	icon = filter(lambda element: isinstance(element, Image), e.getOwnedElement())
		    	if icon:
		    		icon = icon[0]
		    		newicon= ef.createImageInstance()
		    		newicon.setLocation(icon.getLocation())
		    		newicon.setContent(icon.getContent())
		    		newicon.setFormat(icon.getFormat())
		    		newicon.setOwner(newSter)
	        if isinstance(element, Class) and e.getOwner() == stereotypePackage:
		    	newgen = ef.createGeneralizationInstance()
		    	newgen.setGeneral(e)
		    	newgen.setSpecific(newSter)
		    	newgen.setOwner(newSter)
		    	icon = filter(lambda element: isinstance(element, Image), e.getOwnedElement())
		    	if icon:
		    		icon = icon[0]
		    		newicon = ef.createImageInstance()
		    		newicon.setLocation(icon.getLocation())
		    		newicon.setContent(icon.getContent())
		    		newicon.setFormat(icon.getFormat())
		    		newicon.setOwner(newSter)
	return
Exemplo n.º 5
0
def createCustomization(stereotypeName, owner):
	new = ef.createClassInstance()
	new.setOwner(owner)
	new.setName(stereotypeName)
	StereotypesHelper.addStereotype(new, StereotypesHelper.getStereotype(project, "Customization"))
	return new
Exemplo n.º 6
0
def stereotypesForElements(modelPackage, validateOnly, elementType, stereotypesIgnore, packagesIgnore):
	if not stereotypesIgnore:
		stereotypesIgnore=[]
	profilePackage = profilePackCheck(modelPackage)
	if not profilePackage: return ['no Profile Package', 'no Profile Package', 'no Profile Package', 'no Profile Package']
	infraPack = filter(lambda element: isinstance(element, Package) and "_"==element.getName(), profilePackage.getOwnedElement())
	if len(infraPack)>0: infraPack = infraPack[0]
	else: return['no underscore pacakage, no underscore pacakage,no underscore pacakage,no underscore pacakage']
	stereotypePackage=packageCheck(profilePackage, infraPack, validateOnly, "_Stereotypes")
	if not stereotypePackage: return ['no Stereotype Package', 'no Stereotype Package', 'no Stereotype Package', 'no Stereotype Package']
	baseClass = getElements(getEverything(modelPackage), profilePackage)
	baseClass = filter(lambda element: "_" not in element.getName(), baseClass)
	if not isinstance(modelPackage, Profile): baseClass.append(modelPackage)
###intialize counts
	sterCreate = 0
	nameChange = 0
	unapply = 0
	apply = 0
###
	if elementType != 'Misc':
		baseClass = filter(lambda element: isinstance(element, elementType), baseClass)
		for s in stereotypesIgnore: baseClass = filter(lambda element: StereotypesHelper.hasStereotypeOrDerived(element, s) == False, baseClass)
		ignoredPackEls = []
		for i in packagesIgnore: baseClass = filter(lambda element: element not in getEverything(i), baseClass)
		result = getMissing(baseClass, filter(lambda element: isinstance(element, NamedElement),stereotypePackage.getOwnedElement()))
		bNoSter = result[0]
		bWrongSter = result[1]
		bWrongMeta = result[2]
		applySter = []
		for n in noApply:
			if n not in bWrongSter and n not in bWrongMeta and n in baseClass: applySter.append(n)
		if validateOnly!=True:
			('[FIXING]:' + str(elementType))
			successful = []
			bWS = []
			bWM=[]
			noFix=[]
			for b in bNoSter:
				bStillMissing = getMissing([b], filter(lambda element: isinstance(element, NamedElement), stereotypePackage.getOwnedElement()))
				bWS = bStillMissing[1]
				bWM = bStillMissing[2]
				if bStillMissing[0]:
					###check if any local stereotype is applied
					bLocalSter =  filter(lambda element: element.getOwner() == stereotypePackage, StereotypesHelper.getStereotypes(b))
					if len(bLocalSter)>0:
						for bL in bLocalSter:
							localSterApply = filter(lambda element:  bL in StereotypesHelper.getStereotypes(element), getElements(getEverything(profilePackage), profilePackage))
							if len(localSterApply)==1:
								###if local stereotype is applied to only this element in the base class then change the name of stereotype. Otherwise create new ster and unapply this one.
								bL.setName(propertyCheck(b))
								gl.log('[FIX]:Stereotype name was changed to match applied element name: ' + b.getQualifiedName())
								nameChange+=1
							elif filter(lambda element: propertyCheck(element) == bL.getName(), getElements(getEverything(profilePackage), profilePackage)):
								createStereotype(stereotypePackage, b, stereotypePackage)
								unapplyStereotypes([b])
								gl.log('[FIX]:Stereotype Created ' +b.getName())
								gl.log('\t\t Location = ' + b.getQualifiedName())	
								sterCreate+=1
							else:
								###get sysml extension, unapply stereotype and apply sysml extension
								bLgeneralizations = getGeneralizationTree(bL)
								bLSysGen = filter(lambda element: StereotypesHelper.getProfileForStereotype(element) == StereotypesHelper.getProfile(project, "SysML") or StereotypesHelper.getProfileForStereotype(element) == StereotypesHelper.getProfile(project, "additional_stereotypes"), bLgeneralizations)
								unapplyStereotypes([b])
								if bLSysGen:
									StereotypesHelper.addStereotype(b, bLSysGen[0])
								gl.log('[FIX]:Stereotype applied to multiple elements, none with matching name.  Unapplied stereotype:' + bL.getName())
								unapply+=1
								createStereotype(stereotypePackage, b, stereotypePackage)
								unapplyStereotypes([b])
								gl.log('[FIX]:Stereotype Created ' +b.getName())
								gl.log('\t\t Location = ' + b.getQualifiedName())
								sterCreate+=1
					else:
						createStereotype(stereotypePackage, b, stereotypePackage)
						unapplyStereotypes([b])
						gl.log('[FIX]:Stereotype Created ' +b.getName())
						gl.log('\t\t Location = ' + b.getQualifiedName())
						sterCreate+=1
			for b in bWS:
				if not isinstance(b, Interface) and StereotypesHelper.getBaseClassAsClasses(b)[0] == Port:
					if b.getName().find("part property")==0:
						bPort = filter(lambda element: element.getName() == b.getName() + " port", filter(lambda element: isinstance(element, NamedElement), stereotypePackage.getOwnedElement()))
						if len(bPort)!=0:
							bApplied = filter(lambda element: StereotypesHelper.isElementStereotypedBy(element, b.getName())==True, baseClass)
							for f in bApplied:
								StereotypesHelper.removeStereotypes(f, [b])
								StereotypesHelper.addStereotype(f, bPort)
			###Apply applicable stereotypes
			for b in noApply:
				if b not in bWrongSter and b not in bWrongMeta and b not in bWS and b not in bWM and b in baseClass:
					if StereotypesHelper.getBaseClasses(noApply[b])[0].getName() != 'Element':
						StereotypesHelper.addStereotype(b, noApply[b])
						unapplyStereotypes([b])
						gl.log('[FIX]: Stereotype Applied ' + b.getName())
						gl.log('\t\t Location = '+b.getQualifiedName())
						apply+=1
			if len(bWrongSter)>0: gl.log('[UNFIXABLE]: Inheritance Mismatch (see validation log for details)')
			for b in bWrongMeta:
					gl.log('[UNFIXABLE]: Metaclass Mismatch: '+ b.getQualifiedName())
#		if elementType == Classifier and validateOnly!=True: localGeneralizations(modelPackage, validateOnly, True)
###Messages Log
		if apply!=0 or sterCreate!=0 or nameChange !=0 or unapply!=0:
			gl.log('[FIX SUMMARY]:')
			gl.log(str(apply) + " existing stereotype(s) applied")
			gl.log(str(sterCreate) + " stereotypes created")
			gl.log(str(nameChange) + " stereotype names changed")
			gl.log(str(unapply) + " stereotypes unapplied")
		else: gl.log('No Fixes Needed')
		if len(bWrongSter)!=0 or bWrongMeta!=0: 
			gl.log('[UNFIXABLE SUMMARY]:')
			if len(bWrongSter)>0: gl.log(str(len(bWrongSter))+ " stereotype inheritance mismatch")
			if len(bWrongMeta)>0: gl.log(str(len(bWrongMeta))+ " stereotype metaclasses and element types not matching")
		else: gl.log('No modeler fixes needed')
################
		return [bNoSter, bWrongSter, bWrongMeta, applySter]
	else:
		baseClass = filter(lambda element: not isinstance(element, Class), baseClass)
		baseClass = filter(lambda element: not isinstance(element, Package), baseClass)
		baseClass = filter(lambda element: not isinstance(element, Property), baseClass)
		baseClass = filter(lambda element: not isinstance(element, Operation), baseClass)
		baseClass = filter(lambda element: not isinstance(element, Diagram), baseClass)
		baseClass = filter(lambda element: not isinstance(element, Dependency), baseClass)
		for s in stereotypesIgnore: baseClass = filter(lambda element: StereotypesHelper.hasStereotypeOrDerived(element, s) == False, baseClass)
		ignoredPackEls = []
		for i in packagesIgnore: baseClass = filter(lambda element: element not in getEverything(i), baseClass)
		resultMisc = getMissing(baseClass, stereotypePackage.getOwnedElement())
		mNoSter = resultMisc[0]
		mWrongSter = resultMisc[1]
		mWrongMeta = resultMisc[2]
		applySter = []
		for n in noApply:
			if n not in mWrongSter and n not in mWrongMeta and n in baseClass: applySter.append(n)
		if validateOnly!=True:
			gl.log('[FIX]:' + str(elementType))
			successful = []
			for b in mNoSter:
				mStillMissing = getMissing([b], stereotypePackage.getOwnedElement())
				if mStillMissing[0]:
					createStereotype(stereotypePackage, b, stereotypePackage)
					unapplyStereotypes([b])
			    	gl.log('\t Stereotype Created ' +b.getName())
			    	gl.log('\t\t Location = ' + b.getQualifiedName())
			for b in noApply:
				if b not in mWrongSter and b not in mWrongMeta and n in baseClass:
					StereotypesHelper.addStereotype(b, noApply[b])
					unapplyStereotypes([b])
					gl.log('\t Stereotype Applied ' + b.getName())
					gl.log('\t\t Location = '+b.getQualifiedName())
			if len(mWrongSter)>0: gl.log('UNFIXABLE: Inheritance Mismatch (see validation log for details)')
			if len(mWrongMeta)>0: gl.log('UNFIXABLE: Metaclass Mismatch (see validation log for details)')
		return [mNoSter, mWrongSter, mWrongMeta, applySter]
Exemplo n.º 7
0
def addStereotypes(element, stereotypes):
    for stereotype in stereotypes:
        StereotypesHelper.addStereotype(element, stereotype)
Exemplo n.º 8
0
def StateEventTimelineCreation(package,checkOnly):
    Elements=package.getOwnedElement()
    GenError=0
    redError=0
    asscError=0
    MultState=0
    MultEvent=0
    StateTimelineError=0
    EventError=0
    GenAdd=0
    StateAdd=0
    EventAdd=0
    AssocAdd=0
    RedAdd=0
    StAdd=0
    AbsAdd=0
    AbsError=0
    constError=0
    constAdd=0
    checkDiag=0
    mappingSys={}
    redefCs={}
    litError=0
    litEventAdd=0
    abs=False
    
                #newEv=PC.elementCreate(csElements, newPack)
                        #mappingSys[EventIns]==newElement
                        #options={"checkOnly":False, "mapping":mappingSys, 'fixforOpsrev':True,'fixRedefName': True,'fixAll': False}
                        #Specialize.generalize(newElement, options)
                
#    if abs==True:
#        return GenError,redError,StateTimelineError,EventError,GenAdd,EventAdd,StateAdd,AssocAdd,RedAdd,asscError,StAdd,AbsAdd,MultState,MultEvent,mappingReqState,AbsError,constError,constAdd                
    gl.log("--------------------Working on Validation of Relationships to State, Event, Constraint-------------------")
    for e in Elements:
        gl.log("-------------State Variable Working On-------------------"+e.getQualifiedName())
        valueS=0;
        valueE=0;
        create1=False
        get1=False
        create2=False
        if StereotypesHelper.hasStereotype(e,StateVariableStereotype):
            absSv=e.isAbstract()
            if absSv==False:
                AbsError+=1
            if checkOnly != True:
                #gl.log("Note: Fixing the Abstract")
                AbsAdd+=1
                e.setAbstract(True)
            ###Need to check if element has association from State Timeline
            ##Need to check the general of E here and set it to CSStateVariableType if not 
            #get CS StateVariable Element
            
            #instead of control service generalization here we want to do generalization to the state timeline from the base you are constructing from##
            
            #see where the state variable is generalizing from?
            genSvs=e.getGeneral()
            genCheck=0
            for genSv in genSvs:
                #gl.log(genSv.getName())
            #now check to see if the element is in the CSAF, if it's not then, assume that is the base, if it is and there is no other base element, then we can assume the base is the csaf
                if genSv not in allCS:
                    genSvElem=genSv
                    genCheck=1
                    #gl.log("The name of the good generalization element====>"+genSv.getName())
                if genCheck==1:
                    break
            if genCheck==0:
                genSvElem=genSv
                
            genElem=genSvElem.getOwner().getOwner()
            CSProf=genElem
            
            #gl.log("General State Variable Element======>"+genSvElem.getQualifiedName())
            
            StateTlCS=ControlServiceGeneralization(genSvElem,e,StateTLPackStereotype,StateTimelineStereotype,False)
            #gl.log("statetlcs===>"+StateTlCS.getQualifiedName())
            StTlPack=StateTlCS.getOwner()
            svPack=StTlPack.getNestedPackage()
            for packs in svPack:
                if StereotypesHelper.hasStereotype(packs,svPackStereotype):
                    #gl.log("******hey did we get here****"+packs.getQualifiedName())
                    svElems=packs.getOwnedElement()
                    for svElem in svElems:
                        if StereotypesHelper.hasStereotype(svElem,StateVariableStereotype):
                            csSVElem=svElem
        
#            generalSV=e.getGeneral()
#            if len(generalSV)==0:
#                gl.log("*****ERROR*****The Element Does not have the correct generalization to CS")
#                GenError+=1
#                if checkOnly != True:
#                    gl.log("*******Adding the Generalization to the System Under Control SV*******========>"+e.getName())
#                    GenAdd+=1
#                    #put function here
#                    CreateGeneralization(csSVElem,e)
#            elif generalSV==csSVElem:
#                gl.log("The Correct Generalization is made to the CS State Variable Type Element")
                
            
            propE=e.get_typedElementOfType()
            #rela=filter(lambda element: isinstance(element,Class),rela)
            for k in propE:
                blockE=k.getOwner()
                #elemR=k.getTarget()
                #gl.log("yoyoyo===>"+str(len(blockE)))
                #elemR=filter(lambda element: isinstance(element,Class),elemR)
                if isinstance(blockE,Class):
                    #gl.log("element name===>" + blockE.getName())
                    if StereotypesHelper.hasStereotype(blockE,StateTimelineStereotype):
                        valueS+=1
                        #gl.log("This is the element that has the stateTimelineStereotype=====>"+blockE.getQualifiedName())
                        eventS=blockE
                    if StereotypesHelper.hasStereotype(blockE,eventStereotype):
                        valueE+=1
                        eventG=blockE
            gl.log("This is the value of the State Timeline Count:======>"+str(valueS))
            gl.log("This is the value of the Event Count:======>"+str(valueE))            
            
            if valueS>1:
                gl.log("*****ERROR******There is more than one State Timeline connected to the State Variable Type====>"+str(valueS))
                MultState+=1
                #when this happens....can still check event rule but hard to say what new is
            if valueE>1:
                gl.log("*****ERROR*****There is more than one Event connected to the State Variable Type====>"+str(valueE))
                MultEvent+=1
            
            ##Creating the Events
            if valueS==0 and valueE==1:
                propEvents=eventG.get_typedElementOfType()
                blah=ControlServiceGeneralization(genSvElem,eventG,StateTLPackStereotype,StateTimelineStereotype,get1)
                happy=0
                if len(propEvents)!=0:
                    for propEvent in propEvents:
                        stateBlock=propEvent.getOwner()
#                        gl.log("the state timeline block is????"+stateBlock.getQualifiedName())
#                        #if isinstance(stateBlock,Class):
                        if StereotypesHelper.hasStereotype(stateBlock,StateTimelineStereotype):
                            gl.log("*****ERROR******: There is a State Timeline Connected, but not directly to State Variable Type")
                            gl.log("*****ERROR******: No Association between State Variable and State Timeline")
                            asscError+=1
                            if checkOnly != True:
                                [newProp,newassoc]=CreateAssociation(stateBlock,e,kind)
                                AssocAdd+=1
                            #now setting the variable properties
                                CSState=blah.getOwnedElement()
                                props=newProp.getRedefinedProperty()
                                [RedAdd,GenAdd]=RedefinitionGenAdd(CSState,"variable",svStereotype,props,newProp,True,newassoc,RedAdd,GenAdd)
                            valueS=1
                            eventS=stateBlock
                                        
                                        
            if valueS==0:
                gl.log("*****ERROR****:This element has no association to state====>"+e.getName())
                StateTimelineError+=1
            ###Creating the State Timelines
                if checkOnly != True:
                    new = ef.createClassInstance()
                    StateAdd+=1
                    new.setAbstract(True)
                    AbsAdd+=1
                    new.setOwner(StateTimelinePackage)
                    StereotypesHelper.addStereotype(new,StateTimelineStereotype)
                    StAdd+=1
                    new.setName(e.getName())
                    #gl.log("The System Shall Provide a State Timeline=>  "+new.getName()+"  that represents state variable type=>  "+e.getName())
                    create1=True
                    blah=ControlServiceGeneralization(genSvElem,new,StateTLPackStereotype,StateTimelineStereotype,create1)
                    GenAdd+=1
                    mappingSys[blah]=new
                    kind=AggregationKindEnum.COMPOSITE
                    [newProp,newassoc]=CreateAssociation(new,e,kind)
                    AssocAdd+=1
                    #now setting the variable properties
                    CSState=blah.getOwnedElement()
                    props=newProp.getRedefinedProperty()
                    [RedAdd,GenAdd]=RedefinitionGenAdd(CSState,"variable",svStereotype,props,newProp,True,newassoc,RedAdd,GenAdd)
                    valueS=1
                    eventS=new
                            
                            
                
            if valueS==1 and valueE==0:
                #add a check here to see if the timeline has an event associated.....if it has an event....but the variable type did not then hook that shit up
                new=eventS
                #eventS.setName(e.getName())
                varTypeAttrs=eventS.getOwnedAttribute()
                for varTypeAttr in varTypeAttrs:
                    if StereotypesHelper.hasStereotype(varTypeAttr.getType(),eventStereotype):
                        gl.log("*****ERROR*****There is an event associated to the Timeline but not to the variable....remedy this situation=====>")
                        eventElem=varTypeAttr.getType()
                        if checkOnly != True:
                            blah2=ControlServiceGeneralization(genSvElem,eventElem,sucEventPackStereotype,eventStereotype,False)
                            CSEvent=blah2.getOwnedElement()
                            gl.log("*******Adding the Shared Association between event and State Variable*******========>")
                            kindSh=AggregationKindEnum.SHARED
                            [newPropSh,newassocSh]=CreateAssociation(eventElem,e,kindSh)
                            AssocAdd+=1
                            propsSh=newPropSh.getRedefinedProperty()
                            [RedAdd,GenAdd]=RedefinitionGenAdd(CSEvent,"variable",svStereotype,propsSh,newPropSh,True,newassocSh,RedAdd,GenAdd)
                            valueE=1
                            eventG=eventElem
                        
                kind=AggregationKindEnum.COMPOSITE
                get1=False
                blah=ControlServiceGeneralization(genSvElem,eventS,StateTLPackStereotype,StateTimelineStereotype,get1)
                CSState=blah.getOwnedElement()
                absS=eventS.isAbstract()
                if absS==False:
                    AbsError+=1
                    if checkOnly != True:
                        gl.log("Note: Fixing the Abstract")
                        AbsAdd+=1
                        eventS.setAbstract(True)
                
                generalST=eventS.getGeneral()
                #gl.log("*****The Correct State Timeline is associated====>"+eventS.getQualifiedName())
                
                if len(generalST)==0:
                    gl.log("*****ERROR*****The State Timeline generalization is not correct")
                    GenError+=1
                    if checkOnly != True:
                        #gl.log(str(GenError))
                        #gl.log("see what blah and eventS are===>   "+blah.getQualifiedName()+"  ==>  "+ eventS.getQualifiedName())
                        CreateGeneralization(blah,eventS)
                        GenAdd+=1
                        mappingSys[blah]=eventS
                elif generalST[0]==blah:
                    gl.log("The generalization is correct for element====>"+eventS.getQualifiedName())
                
                redefName="variable"
                [redError,RedAdd,StAdd,GenAdd,GenError,redefCs]=RedefinedCheck(e,StateTimelineStereotype,CSState,svStereotype,redefName,checkOnly,redError,RedAdd,StAdd,GenAdd,GenError,redefCs)

                            
            
            if valueE==0:
            ##looking for event package
                gl.log("*****ERROR*****:There is no Event associated with the State Variable======>"+e.getName())
                EventError+=1
                tlPacks=StateTimelinePackage.getNestedPackage()
                for t in tlPacks:
                    #gl.log("Just checking the value of the packages we are finding here====>"+t.getQualifiedName())
                    if StereotypesHelper.hasStereotype(t,sucEventPackStereotype):
                        #gl.log("what is happening here?")
                        if checkOnly != True:
                            newEvent = ef.createClassInstance()
                            newEvent.setAbstract(True)
                            AbsAdd+=1
                            EventAdd+=1
                            newEvent.setOwner(t)
                            StereotypesHelper.addStereotype(newEvent,eventStereotype)
                            StAdd+=1
                            newEvent.setName(e.getName())
                            create1=True
                        #gl.log(str(create1))
                            blah2=ControlServiceGeneralization(genSvElem,newEvent,sucEventPackStereotype,eventStereotype,create1) #this is not going to work
                            GenAdd+=1
                            mappingSys[blah2]=newEvent
                            gl.log("*******Adding the Composition between event and State Timeline*******========>")
                            [newPropEv,newassocEv]=CreateAssociation(eventS,newEvent,AggregationKindEnum.COMPOSITE)
                            AssocAdd+=1
                            propsEv=newPropEv.getRedefinedProperty()
                        #now setting the generalization up
                            CSEvent=blah2.getOwnedElement()
                        #gl.log("the Control Service Event================================>"+blah2.getName())
                            blah=ControlServiceGeneralization(genSvElem,eventS,StateTLPackStereotype,StateTimelineStereotype,get1)
                            CSState=blah.getOwnedElement()
                            
                            [RedAdd,GenAdd]=RedefinitionGenAdd(CSState,"Event",None,propsEv,newPropEv,True,newassocEv,RedAdd,GenAdd)
                if checkOnly != True:
                    gl.log("*******Adding the Shared Association between event and State Variable*******========>")
                    kindSh=AggregationKindEnum.SHARED
                    [newPropSh,newassocSh]=CreateAssociation(newEvent,e,kindSh)
                    AssocAdd+=1
                    propsSh=newPropSh.getRedefinedProperty()
                    [RedAdd,GenAdd]=RedefinitionGenAdd(CSEvent,"variable",svStereotype,propsSh,newPropSh,True,newassocSh,RedAdd,GenAdd)
                    valueE=1
                    eventG=newEvent
            
            if valueE==1:
                ##Check for the association to the state timeline, if its not there then add it, if there is a state timeline
                
                #since there is an event associated need to check and see if there is constraint with appropriate redefinition
                #[redError,RedAdd,StAdd,GenAdd,GenError]=RedefinedCheck(eventG,StateTimelineStereotype,CSState,None,"State Event",checkOnly,redError,RedAdd,StAdd,GenAdd,GenError)
                new=eventG
                #eventG.setName(e.getName())
                
                absE=eventG.isAbstract()
                if absE==False:
                    AbsError+=1
                    if checkOnly != True:
                        #gl.log("Note: Fixing the Abstract")
                        AbsAdd+=1
                        eventG.setAbstract(True)
                        #need to add an abs count
                        
                    
                #gl.log("The Event we are working on ====================>"+new.getQualifiedName())
                propEvents=new.get_typedElementOfType()
                blah=ControlServiceGeneralization(genSvElem,new,StateTLPackStereotype,StateTimelineStereotype,get1)
                happy=0
                if valueS==1:
                    for propEvent in propEvents:
                        stateBlock=propEvent.getOwner()
#                        gl.log("the state timeline block is????"+stateBlock.getQualifiedName())
#                        #if isinstance(stateBlock,Class):
                        if StereotypesHelper.hasStereotype(stateBlock,StateTimelineStereotype):
                            #gl.log("The Correct Association!!!!!!!!!!!WHOOO")
                            happy=1
                    if happy !=1:
                        gl.log("ERROR:  There is not an association between the State Timeline======>"+eventS.getName()+"    and Event=====>:"+eventG.getQualifiedName())
                        asscError+=1
                        if checkOnly != True:
                            [newPropEv,newassocEv]=CreateAssociation(eventS,eventG,kind)
                            propsEv=newPropEv.getRedefinedProperty()
                            AssocAdd+=1
                            CSState=blah.getOwnedElement()
                            [RedAdd,GenAdd]=RedefinitionGenAdd(CSState,"Event",None,propsEv,newPropEv,True,newassocEv,RedAdd,GenAdd)
                                   
                else:
                    gl.log("*****ERROR*****: There is not a state timeline associated with this event=======>"+new.getQualifiedName())
                    
                kind=AggregationKindEnum.COMPOSITE
                get1=False
                blah2=ControlServiceGeneralization(genSvElem,new,sucEventPackStereotype,eventStereotype,get1)
                CSEvent=blah2.getOwnedElement()
                evAttrs=eventG.getOwnedAttribute()
                csEvAttrs=blah2.getOwnedAttribute()
                checkConst=0
                #gl.log("What event are we on?====>"+eventG.getName())
                if evAttrs:
                    for evAttr in evAttrs:
                        evAttrType=evAttr.getType()
                        #gl.log("What is the type of the event attribute?===>"+evAttrType.getName())
                        evAttrTypeSt=StereotypesHelper.getStereotypes(evAttrType)
                        if SUCeventSpecSt in evAttrTypeSt:
                            checkRedefConst=evAttrType
                            evCProp=evAttr.getRedefinedProperty() #event constraint property, its redefined property should be the cs event attribute property
#                            csEventPack=blah2.getOwner()
#                            csEventSpecs=csEventPack.getNestedPackage()
#                            csEventSpecPack=filter(lambda element: StereotypesHelper.hasStereotype(element,eventSpecsSt),csEventSpecs)
#                            gl.log(csEventSpecPack[0].getQualifiedName())
                            CSConst=ControlServiceGeneralization(genSvElem,None,eventSpecsSt,SUCeventSpecSt,False)
                            if CSConst!=None:
                                CSConst=CSConst.getOwnedElement()
                            #gl.log("the control service constraint?===>"+CSConst.getQualifiedName())
                            redefName="constraint"
                            [redError,RedAdd,StAdd,GenAdd,GenError,redefCs]=RedefinedCheck(evAttrType,eventStereotype,CSEvent,None,redefName,checkOnly,redError,RedAdd,StAdd,GenAdd,GenError,redefCs)
                            
                            for csEvAttr in csEvAttrs:
                                #gl.log("The name of the control service attribute...."+csEvAttr.getQualifiedName())
                                csEvAttrType=csEvAttr.getType()
                                if csEvAttrType !=None:
                                    #gl.log("The name of the Control Service Event...."+csEvAttrType.getQualifiedName())
                                    csEvAttrTypeSt=StereotypesHelper.getStereotypes(csEvAttrType)
                                    if SUCeventSpecSt in csEvAttrTypeSt:
                                        if csEvAttr in evCProp:
                                            checkConst=1
                                            break
                                if checkConst==1:
                                    break
                else:
                    gl.log("*****ERROR*****The event has no attributes")
                    checkConst=1
                        
                #gl.log("What is the event?====>"+eventG.getName())
                general=eventG.getGeneral()
                #gl.log("What is general?====>"+general[0].getName())
                #gl.log("What is blah?=====>"+blah2.getName())
                
                if len(general)==0:
                    gl.log("*****ERROR*****:The generalization is not correct!")
                    GenError+=1
                    if checkOnly != True:
                        gl.log("*******Adding the Generalization to the New Element*******========>"+eventG.getQualifiedName()+"     Generalizing from CS Element =======>" +blah2.getName())
                        GenAdd+=1
                        CreateGeneralization(blah2,eventG)
                        mappingSys[blah2]=eventG
                elif general[0]==blah2:
                    gl.log("The generalization is correct for element====>"+eventG.getQualifiedName())
                    
                CSState=blah.getOwnedElement()
                CSEvent=blah2.getOwnedElement()
                #gl.log("*****The Correct EVENT is associated")
                #propE=e.get_typedElementOfType()
                #rela=filter(lambda element: isinstance(element,Class),rela)
                redefName="variable"
                [redError,RedAdd,StAdd,GenAdd,GenError,redefCs]=RedefinedCheck(e,eventStereotype,CSEvent,svStereotype,redefName,checkOnly,redError,RedAdd,StAdd,GenAdd,GenError,redefCs)
                #gl.log("The Redefinition Error count!!!!!!"+str(redError))
                
            if valueE==1 and valueS==1:
                absE=eventG.isAbstract()
                absS=eventS.isAbstract()
                mappingReqState[e]=eventS
                #eventG.setName(e.getName())
                #eventS.setName(e.getName())
                        #need to add in a count here
                blah=ControlServiceGeneralization(genSvElem,new,StateTLPackStereotype,StateTimelineStereotype,get1)
                CSState=blah.getOwnedElement()
                blah2=ControlServiceGeneralization(genSvElem,new,sucEventPackStereotype,eventStereotype,get1)
                CSEvent=blah2.getOwnedElement()
                #means that there is an event and state timeline for the state variable, just need to check the association now and its redefinition
                if StereotypesHelper.hasStereotype(eventG,eventStereotype):
                    
                    [redError,RedAdd,StAdd,GenAdd,GenError,redefCs]=RedefinedCheck(eventG,StateTimelineStereotype,CSState,None,"Event",checkOnly,redError,RedAdd,StAdd,GenAdd,GenError,redefCs)
            
                csEvent=ControlServiceGeneralization(genSvElem,eventG,sucEventPackStereotype,eventStereotype,get1)
                csEventPack=csEvent.getOwner()
                csEventSpecs=csEventPack.getNestedPackage()
                for csEventSpecPack in csEventSpecs:
                    checkPort=0
                    if StereotypesHelper.hasStereotype(csEventSpecPack,eventSpecsSt):
                        #need to fix this
                        #CsConst=ControlServiceGeneralization(CSProf,None,csEventSpecPack,SUCeventSpecSt,False) #this will give the constraint block in the CS
                        #insConst=ControlServiceGeneralization(csEvent.getOwner().getOwner(),None,csEventSpecPack,SUCeventSpecSt,False)
                        test=e.getOwner().getOwner().getOwner()
                        EventSpecPack=findPackage(eventSpecsSt,e.getOwner().getOwner(),True)
                        EventSpecs=EventSpecPack.getOwnedElement()
                        csEventSpecs=csEventSpecPack.getOwnedElement()
                        csEventSpecs=filter(lambda element: StereotypesHelper.hasStereotype(element,SUCeventSpecSt),csEventSpecs)
                        EventSpecs=filter(lambda element: StereotypesHelper.hasStereotype(element,SUCeventSpecSt),EventSpecs)
                        #when we do this, need to add in association to the event
                        for constraint in EventSpecs:
                            ports=constraint.getRole()
                            for port in ports:
                                if port.getType()==e:
    #                                gl.log("port name===>"+port.getName())
    #                                gl.log("port type===>"+port.getType().getName())
    #                                gl.log("sv name===>"+e.getName())
                                    checkPort=1
                        if checkPort!=1:
                            gl.log("******ERROR******There is not a constraint separately defined for this state variable type=====>"+e.getName())
                            constError+=1
                            if checkOnly != True:
                                gl.log("*******Adding the Constraint Port for the State Variable*******")
                                newC=ef.createClassInstance()
                                newC.setOwner(EventSpecPack)
                                newC.setName(e.getName())
                                newC.setAbstract(True)
                                StereotypesHelper.addStereotype(newC,SUCeventSpecSt)
                                [newPropEC,newassocEC]=CreateAssociation(eventG,newC,AggregationKindEnum.COMPOSITE)  # I think this should be from the event to the new thing 
                                AssocAdd+=1
                                propsEC=newPropEC.getRedefinedProperty()
                                [RedAdd,GenAdd]=RedefinitionGenAdd(CSEvent,"Event Constraint",None,propsEC,newPropEC,True,newassocEC,RedAdd,GenAdd)
                                for constraintCS in csEventSpecs:
                                    genConstAttrs=csEvent.getOwnedAttribute()
                                    if StereotypesHelper.hasStereotype(constraintCS,SUCeventSpecSt):  #this alone is not good enough anymore, need to check the relations as well
                                        for genConstAttr in genConstAttrs:
                                            if genConstAttr.getType()==constraintCS:
                                                CreateGeneralization(constraintCS,newC)
                                                portCS=constraintCS.getRole()
                                                if len(portCS)!=0:
                                                    portCS=portCS[0]
                                                    newport=ef.createPortInstance()
                                                    newport.setOwner(newC)
                                                    portConst=newport.getRedefinedPort()
                                                    portConst.add(portCS)
                                                    newport.setType(e)
                                                    newport.setName(e.getName())
                                
                                constAdd+=1

    gl.log("--------------------Working State Variable Types with Literals-------------------")
    for e in Elements:
        if StereotypesHelper.hasStereotype(e,StateVariableStereotype) and isinstance(e,Enumeration):
            #gl.log("What state variable are we on====>"+e.getName())
            stlPack=e.getOwner().getOwner()
            diags=stlPack.getOwnedDiagram()
            literals=e.getOwnedLiteral()
            EventIns=None
            constOwn=None
            if literals:
                abs=True
                ######DONT NEED DIAGRAM STUFF RIGHT NOW
#                for diag in diags:
#                    if diag.getName()==e.getName()+" View":
#                        checkDiag=1
#                if checkDiag==0 and checkOnly!=True:
#                    gl.log("Creating Concrete Diagram for State Variable")
#                    d=mem.createDiagram("SysML Block Definition Diagram", stlPack)
#                    d.setName(e.getName()+" View")
#                    d.setOwner(stlPack)
#                elif checkDiag==0 and checkOnly==True:
#                    gl.log("Error there is no diagram for the Concrete State Variable===>"+e.getName())
                #if checkOnly!=True:  #we can take this out
                    #CSEvent=ControlServiceGeneralization(CSProf,e,sucEventPackStereotype,eventStereotype,False) # I don't know that i need this
                propEs=e.get_typedElementOfType()
                for propE in propEs:
                    #gl.log("properties====>" +propE.getQualifiedName())
                    blockE=propE.getOwner()
                    if isinstance(blockE,Class):
                        #gl.log("the Class,====>"+blockE.getQualifiedName())
                        if StereotypesHelper.hasStereotype(blockE,eventStereotype) and e.getName()==blockE.getName():
                            #gl.log("should be the event,====>"+blockE.getQualifiedName())
                            #need this to be more specific
                            EventIns=blockE
                            #gl.log("the event again====>"+EventIns.getQualifiedName())
                            csEvAttr=EventIns.getOwnedAttribute()
                            #element.getType().getOwner().getOwner()==EventIns.getOwner()
                            ConstAttr=filter(lambda element: StereotypesHelper.hasStereotype(element.getType(),SUCeventSpecSt) and element.getType().getName()!="Event Constraint",csEvAttr)
                            if len(ConstAttr)!=0:
                                #gl.log("The constraint attribute====>"+ConstAttr[0].getQualifiedName())
                                csEvConst= ConstAttr[0].getType()
                                #gl.log("The Event Constraint====>"+csEvConst.getQualifiedName())
                            else:
                                gl.log("ERROR....There is not an Event Constraint connected to the Event ")
                            #gl.log("Constraint======>"+csEvConst.getQualifiedName())
                litMap={}
                check=0
                if EventIns!=None and csEvConst!=None:
                    packOwn=EventIns.getOwner()
                    constOwn=csEvConst.getOwner()  #this is wrong here
                    #gl.log("Lets look at the constraint Owner=====>"+constOwn.getQualifiedName())
                    #gl.log("the CS Event Constraint===>"+csEvConst.getQualifiedName())
                    #checkEnum=isinstance(blockE,Enumeration)
                else:
                    packS=stlPack.getNestedPackage()
                    for pack in packS:
                        if StereotypesHelper.hasStereotype(pack,sucEventPackStereotype):
                            packOwn=pack
                evElems=packOwn.getOwnedElement()
                #evElems=filter(lambda element: element.getName(),evElems)
                #literals=filter(lambda element: element.getName() is in evElems.getName(),literals)
                
                for m in evElems:
                    for l in literals:
                        string=l.getName()+" Event"
                        #gl.log("hey====>"+string+"   ===>"+m.getName())
                        if string==m.getName():
                            litMap[l]=1
                            #gl.log(evName)
                constCheck=0
                for l in literals:
                    if l not in litMap:
                        gl.log("*****ERROR*****:There is a literal in the SV without an Event and Equals Constraint=====>"+l.getQualifiedName())
                        litError+=1
                        if checkOnly!=True and constOwn!=None:
                            newElement = VP.createElement(eventStereotype, packOwn, False)
                            litEventAdd+=1
                            newElement.setName(l.getName()+" Event")
                            newElement.setOwner(packOwn)
                            StereotypesHelper.addStereotype(newElement,eventStereotype)
                            CreateGeneralization(EventIns,newElement)
                            if check==0:
                                ##need to check here if we need to create a constraint or not
                                ConstE=constOwn.getOwnedElement()
                                for Const in ConstE:
                                    if Const.getName()==e.getName()+" Equals Constraint":
                                        newConst=Const
                                        constCheck=1
                                if constCheck==0:
                                    newConst=VP.createElement(SUCeventSpecSt,constOwn,False)
                                    newConst.setName(e.getName()+" Equals Constraint")
                                    newConst.setOwner(constOwn)
                                    StereotypesHelper.addStereotype(newConst,SUCeventSpecSt)
                                    CreateGeneralization(csEvConst,newConst)
                                    newConstr=ef.createConstraintInstance()
                            #need to create opaque expression first
                                    cPort=ef.createPortInstance()
                                    cPort.setType(e)
                                    cPort.setOwner(newConst)
                                    cPort.setName("value")
                                    oE=ef.createOpaqueExpressionInstance()
                                    bodyOE=oE.getBody()
                                    bodyOE.add(e.getName() +"  ==  value")
                                    newConstr.setOwner(newConst)
                                    oE.setOwner(newConstr)
                                    newConstr.setSpecification(oE)
                                    constElem=newConstr.getConstrainedElement()
                                    constElem.add(newConst)
                                    check=1
                                    StereotypesHelper.addStereotype(cPort,constParamSt)
                        
                        #now create Association for event and sv
                            [newPropEv,newassocEv]=CreateAssociation(newElement,e,AggregationKindEnum.COMPOSITE)
                            newPropEv.setReadOnly(True)
                            newPropEv.setStatic(True)
                            newPropEv.setName("value")
                        #need to create a composite association between the event created and the equals constraint, that redefines from what it inherits
                            [newPropEC,newassocEC]=CreateAssociation(newElement,newConst,AggregationKindEnum.COMPOSITE)  # I think this should be from the event to the new thing 
                            AssocAdd+=1
                            propsEC=newPropEC.getRedefinedProperty()
                        #gl.log("The event ins=====>"+EventIns.getName())
                        
                            [RedAdd,GenAdd]=RedefinitionGenAdd(EventIns.getOwnedElement(),"Event Constraint",None,propsEC,newPropEC,True,newassocEC,RedAdd,GenAdd)
        
        
        options={"checkOnly":False, "mapping":mappingSys, 'fixforOpsrev':True,'fixRedefName': True,'fixAll': False, 'fixWrongValueType':False, 'fixWrongRedef':False}
        for m in mappingSys:
            newElement = mappingSys[m]
            Specialize.generalize(newElement, options)
    return GenError,redError,StateTimelineError,EventError,GenAdd,EventAdd,StateAdd,AssocAdd,RedAdd,asscError,StAdd,AbsAdd,MultState,MultEvent,mappingReqState,AbsError,constError,constAdd,litError,litEventAdd,redefCs
Exemplo n.º 9
0
def ProxyResolver(profile):
    proxies = proxyMan.getProxies()  #returns all registered proxies
    count = 0
    StereoCollect = []
    listPort = {}
    listProp = {}
    #StereoMap = open("StereoMap.dat","w")
    fileStereo = open("GoodStereo.csv", "w")
    filePort = open("GoodPort.csv", "w")
    fileProperty = open("GoodProp.csv", "w")
    #GoodStereo=(fileStereo,delimiter=',',quoting=csv.QUOTE_ALL)
    ##trying to filter proxies for only msaf ones
    proxies = StereotypesHelper.filterByProfile(proxies, profile)
    for proxy in proxies:
        #first need to check if orphan proxy
        #only want to work on proxies in the msaf m  lkn

        if True == proxyMan.isGhostProxy(proxy):
            disposeOrphanProxy = False
            #(need to build in cases here of things we want to dispose)
            ProxyId = proxy.getID()
            #gl.log("what up what up the id of the proxy is===>"+str(ProxyId))
            if isinstance(proxy, Generalization):  #this works
                count += 1
                disposeOrphanProxy = True
                gl.log("Removing orphan generalizations")
            if isinstance(proxy, Stereotype):
                gl.log("The name of the orphaned stereotype=====>" +
                       proxy.getQualifiedName())
                elemSt = StereotypesHelper.getExtendedElements(proxy)
                #stereos=
                #get control service framework
                for elem in elemSt:
                    gl.log("This element==>  " + elem.getQualifiedName() +
                           "   is using the orphan proxy===>  " +
                           proxy.getQualifiedName())
                stereo = MDUtils.getUserSelections(
                    [Stereotype], wModel, False,
                    'Select Stereotype to Replace Orphan Stereotype==>' +
                    proxy.getName(), [Stereotype, Package, Profile])
                for elem in elemSt:
                    if stereo is not None:
                        #StereoCollect[proxyID]=stereo.getID()
                        gl.log(
                            "This element is using an orphaned stereotype====>"
                            + elem.getQualifiedName() +
                            "  and will be replaced with selected Stereotype===>"
                            + stereo.getQualifiedName())
                        StereotypesHelper.removeStereotype(elem, proxy)
                        StereotypesHelper.addStereotype(elem, stereo)
                        fileStereo.write(
                            str(ProxyId) + "," + str(stereo.getID()) + "\n")
                    else:
                        #StereoCollect[proxyID]=None
                        gl.log(
                            "Cancel was selected for the Stereotype, so the element will be left alone======>"
                            + elem.getQualifiedName())
                        StereotypesHelper.removeStereotype(elem, proxy)
                        fileStereo.write(str(ProxyId) + "," + "0" + "\n")
                        #need to add flag here
                disposeOrphanProxy = True
            if isinstance(proxy, Port):
                portRedef = proxy.get_portOfRedefinedPort()
                portNew = list(portRedef)
                for port in portNew:

                    gl.log("This port==>  " + port.getQualifiedName() +
                           "   is using the orphan proxy===>  " +
                           proxy.getQualifiedName())
                portSelect = MDUtils.getUserSelections(
                    [Port], wModel, False,
                    'Select Port to Replace Orphan Port (used in redefintion)==>'
                    + proxy.getQualifiedName(),
                    [Port, Package, Class, Interface, Profile])
                for port in portNew:
                    #gl.log("I just want to see what ports we are getting here====>"+port.getQualifiedName())
                    #this gets all ports that are using the orphan port as a redefinition
                    redefList = port.getRedefinedPort()
                    redefList.remove(proxy)
                    if portSelect is not None:
                        #StereoCollect[proxyID]=stereo.getID()
                        gl.log(
                            "This port is using an orphaned port for redefinition====>"
                            + port.getQualifiedName() +
                            "  and will be replaced with selected port===>" +
                            portSelect.getQualifiedName())
                        redefList.add(portSelect)
                        filePort.write(
                            str(ProxyId) + "," + str(portSelect.getID()) +
                            "\n")
                    else:
                        #StereoCollect[proxyID]=None
                        gl.log(
                            "Cancel was selected for the Port Selection, so the port will be deleted======>"
                            + port.getQualifiedName())
                        #StereotypesHelper.removeStereotype(elem,proxy)
                        filePort.write(str(ProxyId) + "," + "0" + "\n")
                        #need to add flag here
                        if port.isEditable():
                            listPort[port] = port.getQualifiedName()
                            mem.removeElement(port)
                        else:
                            gl.log(
                                "Error the element you are trying to delete is not editable"
                            )
                disposeOrphanProxy = True
            if isinstance(proxy, Property) and not isinstance(proxy, Port):
                propertyRedef = proxy.get_propertyOfRedefinedProperty()
                propNew = list(propertyRedef)
                for prop in propNew:
                    gl.log("This property==>  " + prop.getQualifiedName() +
                           "   is using the orphan proxy===>  " +
                           proxy.getQualifiedName())
                propSelect = MDUtils.getUserSelections(
                    [Property], wModel, False,
                    'Select Property to Replace Orphan Property (used in redefinition)==>'
                    + proxy.getQualifiedName(),
                    [Property, Package, Class, Interface, Profile])
                for prop in propNew:
                    #gl.log("I just want to see what ports we are getting here====>"+port.getQualifiedName())
                    #this gets all ports that are using the orphan port as a redefinition
                    redefList = prop.getRedefinedProperty()
                    redefList.remove(proxy)
                    if propSelect is not None:
                        #StereoCollect[proxyID]=stereo.getID()
                        gl.log(
                            "This property is using an orphaned property for redefinition====>"
                            + prop.getQualifiedName() +
                            "  and will be replaced with selected property===>"
                            + propSelect.getQualifiedName())
                        redefList.add(propSelect)
                        fileProperty.write(
                            str(ProxyId) + "," + str(propSelect.getID()) +
                            "\n")
                    else:
                        #StereoCollect[proxyID]=None
                        gl.log(
                            "Cancel was selected for the Port Selection, so the port will be deleted======>"
                            + prop.getQualifiedName())
                        #StereotypesHelper.removeStereotype(elem,proxy)
                        fileProperty.write(str(ProxyId) + "," + "0" + "\n")
                        #need to add flag here
                        if prop.isEditable():
                            listProp[prop] = prop.getQualifiedName()
                            mem.removeElement(prop)
                        else:
                            gl.log(
                                "Error the element you are trying to delete is not editable"
                            )
                disposeOrphanProxy = True
            if isinstance(proxy, Package):
                p = proxy
                packSelect = MDUtils.getUserSelections(
                    [Package], wModel, False,
                    'Select Package to Replace Orphan Package (used in redefinition)==>'
                    + proxy.getQualifiedName(),
                    [Package, Package, Class, Interface, Profile])
                if packSelect is not None:
                    #StereoCollect[proxyID]=stereo.getID()
                    gl.log("This package is orphaned" + proxy.getName() +
                           "  and will be replaced with selected package===>" +
                           packSelect.getQualifiedName())
                    redefList.add(packSelect)
                    fileProperty.write(
                        str(ProxyId) + "," + str(packSelect.getID()) + "\n")
                    proxy.dispose()
                else:
                    #StereoCollect[proxyID]=None
                    gl.log(
                        "Cancel was selected for the Package Selection, so the package will be deleted======>"
                        + proxy.getName())
                    #StereotypesHelper.removeStereotype(elem,proxy)
                    fileProperty.write(str(ProxyId) + "," + "0" + "\n")
                    #need to add flag here
                    #mem.removeElement(p)

                    #need to add how to handle ports properties associations...whatever we can get

                    #get all elements that are stereotyped this
                    #check to make sure you have lock on full project
                    #first created, creates you a mapping
                    #remember what to replace with and what to delete and re-run with lists of items
                    # if disposeOrphanProxy==True:
                    #decide whether or not we want to dispose of orphan proxy
                    #gl.log("***********************If we come here we will dispose of an orphan")
                    proxy.dispose()
                    #mem.removeElement(proxy)================>This does not work


#            else: #if we are not just getting rid of orphan need to have the fix cases
#                gl.log("if we come here we will make something not a proxy anymore")
#                #proxyMan.makeNotProxy(proxy) ------this does very scary things
    gl.log(
        "************************LIST OF PROPERTIES DELETED**********************"
    )
    for p in listProp:
        gl.log("Property Deleted===>  " + listProp[p])
    gl.log(
        "************************LIST OF PORTS DELETED**********************")
    for q in listPort:
        gl.log("Port Deleted===>  " + listPort[q])

    #now do the jason dump and the file write
    #strStereo=json.dumps([StereoCollect])
    #StereoMap.write(strStereo)
    fileStereo.close()
    filePort.close()
    fileProperty.close()

    #    redefs = p.getRedefinedProperty()
    #    if len(redefs) > 0:
    #        redef = redefs[0]
    #        type = redef.getType()
    #        if type is not None:
    #            for g in type.get_generalizationOfGeneral():
    #                potential = g.getSpecific()
    #                if potential.getName().endswith("Fix Me!"):
    #                    return potential
    return None