//var emfTool = new Native("org.eclipse.epsilon.emc.emf.tools.EmfTool"); //var ecoreUtil = emfTool.ecoreUtil; var implicitbminus = true; //var emfTool = new Native("org.eclipse.epsilon.emc.emf.tools.EmfTool"); //var ecoreUtil = emfTool.ecoreUtil; //var out = new bpmnOutModel!BpmnDiagram; //BaseModel.allContents().println(); //AspectModel.allContents().println(); " - Weave - ".println(); JoinPointModel.allContents().println(); bpmnOutModel.allContents().println(); run(); operation run(){ var bkeep : Set; var bminus : Set; var bupdate : Set; var dangling : Map; var cloned : Map; var aaddNodeGlobal : Set; var aaddNodePerJoinPoint : Set; var aaddNodePerScope : Set; var aaddNodeOnDemand : Set; var aupdateNodeGlobal : Set; var aupdateNodePerJoinPoint : Set; var aupdateNodePerScope : Set; var aupdateNodeOnDemand : Set; var aaddReference : Set; var aupdateReference : Set; var aaddOnDemandReference : Set; var aupdateOnDemandReference : Set; markB(bkeep,bminus,bupdate); //marks B_keep, B_- and B_update sets "\n".println(); "-end Mark B-".println(); "-start cloner-".println(); cloner(bkeep,bminus,dangling,cloned); // copies B_keep and sets dangling edges to B_kepp "\n".println(); "-end cloner-".println(); "-Start Mark A-".println(); // markA(aaddNodeGlobal, aaddNodePerJoinPoint, aaddNodePerScope, aaddNodeOnDemand, // aupdateNodeGlobal, aupdateNodePerJoinPoint, aupdateNodePerScope, aupdateNodeOnDemand, // aaddReference, aupdateReference, aaddOnDemandReference, aupdateOnDemandReference); //marks A sets, all 12 of them, it should be 16 "\n".println(); "-end Mark A-".println(); "-Start Weave-".println(); // weave(bkeep, aaddNodeGlobal, aaddNodePerJoinPoint, aaddNodeOnDemand, aupdateNodeGlobal, aupdateNodePerJoinPoint, aupdateNodeOnDemand, aaddReference, aupdateReference, aaddOnDemandReference, aupdateOnDemandReference,cloned, dangling); "-end Weave-".println(); } operation markB(bkeep : Set, bminus : Set, bupdate : Set){ //var baseM = BaseModel.allContents().println(); var baseM = (JoinPointModel.allContents().selectOne(i|i.isKindOf(JoinPointModel!JoinPoint))).baseRoot.println(); var bmark : Set; ".".print(); for(a in JoinPointModel.allContents().select(i|i.isKindOf(JoinPointModel!Pair)) ){ bmark.add(a.base); // a.pc.eClass().getEAllReferences().println(); " ,".print(); if(a.pc.eClass().getEStructuralFeature("toAdvice").isDefined() and not a.pc.toAdvice.isEmpty() ){ bupdate.add(a.base); " |".print(); }else{ bminus.add(a.base); " -".print(); } } var bminusTwo = bmark.clone(); var temp : Set; var keep = true; "\n.".print(); for(a in baseM){ " ,".print(); for(b in bminusTwo){ " ++".print(); -- a.println(); -- a.println(); -- b.println(); -- if (a = b){ -- "equals".println(); -- } -- a.eClass().getEIDAttribute().isDefined().println(); -- b.eClass().getEIDAttribute().isDefined().println(); //if( a.type() == b.type().println() and a.eGet(a.eClass().getEIDAttribute()) == b.eGet(b.eClass().getEIDAttribute().println()) ){ if (a = b){ "+".print(); temp.add(b); keep = false; break; } } bminusTwo.removeAll(temp); if(keep){ " +".print(); bkeep.add(a); } keep = true; } } operation cloner(sourceSet : Set, bminus : Set, dangling : Map, cloned : Map){ //var cloned : Map; var unprocessed : Set; var unprocessedCol : Set; var result : Set; " =".print(); for(i in sourceSet){ " ==".print(); // var temp = ecoreUtil.copy(i); // bpmnOutModel.contents.add(temp); var temp = bpmnOutModel.createInstance(i.type().name); ".".print(); //guard for plugin execution temp.eSetClass(i.eClass()); cloned.put(i,temp); ",".print(); // // for(a in i.eClass().getEAllAttributes().select(e| i.eIsSet(e) and not temp.eIsSet(e))){ " ==-".print(); temp.eSet(a, i.eGet(a)); } ".".print(); for(a in i.eClass().getEAllReferences()){ // temp.eSet(a,null); " ===".print(); if(a.container = true){ " ===-".print(); continue; } if(a.upperBound == 1){ " ====".print(); var item : OrderedSet; item.add(a);//reference type item.add(i.eGet(a));//old reference target item.add(temp);//new reference source unprocessed.add(item); }else{ " ====-".print(); var item : OrderedSet; var itemoze : Set; /* for(j in i.eGet(a)){ item.add(a);//reference type item.add(j);//old reference target item.add(temp);//new reference source unprocessed.add(item); }*/ if( i.eGet(a).size() >0){ " =====".print(); item.add(a);//reference type item.add(i.eGet(a));//old reference target item.add(temp);//new reference source unprocessedCol.add(item); } } } } " !".print(); for(i in unprocessed){ " !-".print(); if(cloned.containsKey(i.at(1))){ //if it connects to other B_keep " !!".print(); /* if(i.at(0).upperBound == 1){ i.at(2).eGet(i.at(0)).println();*/ // //dynamic instance present in plugin runtime // var two = (i.at(2)); // two.dynamicSet(two.eDerivedStructuralFeatureID(i.at(0)),cloned.get(i.at(1))); i.at(2).eSet(i.at(0), cloned.get(i.at(1)) ); /* "U - ".print(); i.at(0).println(); "0 - ".print(); i.at(2).println(); i.at(0).println(); }else{ var temper : Sequence; temper = i.at(2).eGet(i.at(0)); "0 - ".print(); i.at(2).println(); i.at(0).println(); "1 - ".print(); temper.println(); //temp.type().println; //i.at(0).println; //cloned.get(i.at(1)).println(); temper.add(cloned.get(i.at(1))); temper.println(); // i.at(2).eSet(i.at(0), temp ); // i.at(2).eSet(i.at(0), temp ); i.at(2).eGet(i.at(0)).println(); }*/ }else{ " !!-".print(); if(implicitbminus or bminus.excludes(j) ){//not in Bminus " !!!".print(); //add to dangling var item : OrderedSet; var refs : Set; // item.add(i.at(0));//reference type // item.add(i.at(1));//old reference target // item.add(i.at(2));//new reference source if(dangling.containsKey(i.at(1))){ " !!!-".print(); refs = dangling.get(i.at(1)); ".".print(); } //refs.add(item); refs.add(i); dangling.put(i.at(1),refs); } } } " /".print(); /* for(i in unprocessedCol){ " /-".print(); var itemize : Sequence; for(j in i.at(1)){ " //".print(); if(cloned.containsKey(j)){ //if it connects to other B_keep " //-".print(); itemize.add(cloned.get(j)); }else{ " ///".print(); if(implicitbminus or bminus.excludes(j) ){//not in Bminus " ///-".print(); var item : OrderedSet; var refs : Set; item.add(i.at(0));//reference type item.add(j);//old reference target item.add(i.at(2));//new reference source if(dangling.containsKey(j)){ " ////".print(); refs = dangling.get(j); ":".print(); } refs.add(item); //dangling.add(item); //add to dangling dangling.put(j,refs); } } } // "".println(); // itemize.println(); // i.at(0).println(); // i.at(1).println(); // i.at(2).println(); i.at(2).eSet(i.at(0), itemize); }*/ } operation markA(//aadd : Set, aupdate : Set){ aaddNodeGlobal : Set, aaddNodePerJoinPoint : Set, aaddNodePerScope : Set, aaddNodeOnDemand : Set, aupdateNodeGlobal : Set, aupdateNodePerJoinPoint : Set, aupdateNodePerScope : Set, aupdateNodeOnDemand : Set, /* aaddReferenceGlobal : Set, aaddReferencePerJoinPoint : Set, aaddReferencePerScope : Set, aupdateReferenceGlobal : Set, aupdateReferencePerJoinPoint : Set, aupdateReferencePerScope : Set */ aaddReference : Set, aupdateReference : Set, aaddOnDemandReference : Set, aupdateOnDemandReference : Set ){ // "".println(); // "".println(); // for(i in AspectModel.allContents()){ // i.type.name.print(); // } //for(a in AspectModel.getAllOfKind("AdvNode")){ //for(a in AspectModel.allContents().select(i|i.type.name.equals("AdvNode"))){ for(a in JoinPointModel.allContents().selectOne(i|i.isKindOf(JoinPointModel!JoinPoint)).aspectRoot.hasAdvice.hasElements.select(j|j.type.name.equals("AdvNode")) ){ //for(a in AspectModel.allContents().select(i|i.isTypeOf(AspectModel!AdvNode))){ "..".print(); //a.conditions.isDefined().print(); //var fpc = a.eClass().getEAllReferences().selectOne(r|r.name = "fromPointCut"); var fpc = a.eClass().getEStructuralFeature("fromPointCut"); //a.fromPointCut.isDefined().println(); if(not a.conditions.isDefined() or a.conditions.literal = "Global"){ ",".print(); if(fpc.isDefined() and a.fromPointCut.isDefined()){ aupdateNodeGlobal.add(a); }else{ aaddNodeGlobal.add(a); } }else if(a.conditions.literal = "PerJoinPoint"){ ";".print(); if(fpc.isDefined() and a.fromPointCut.isDefined()){ aupdateNodePerJoinPoint.add(a); }else{ aaddNodePerJoinPoint.add(a); } } else if(a.conditions.literal = "PerScope"){ ":".print(); if(fpc.isDefined() and a.fromPointCut.isDefined()){ aupdateNodePerScope.add(a); }else{ aaddNodePerScope.add(a); } } else if(a.conditions.literal = "OnDemand"){ if(fpc.isDefined() and a.fromPointCut.isDefined()){ aupdateNodeOnDemand.add(a); }else{ aaddNodeOnDemand.add(a); } } } for(a in JoinPointModel.allContents().selectOne(i|i.isKindOf(JoinPointModel!JoinPoint)).aspectRoot.hasAdvice.hasElements.select(j|j.type.name.equals("AdvReference")) ){ //for(a in AspectModel.allContents().select(i|i.type.name.equals("AdvReference"))){ //for(a in AspectModel.getAllOfKind("AdvReference")){ if(a.conditions = "OnDemand"){ if(a.fromPointCut.isDefined()){ aupdateOnDemandReference.add(a); }else{ aaddOnDemandReference.add(a); } }else{ if(a.fromPointCut.isDefined()){ aupdateReference.add(a); }else{ aaddReference.add(a); } } /* if(a.conditions = "Global"){ if(a.fromPointCut.isDefined()){ aupdateReferenceGlobal.add(a); }else{ aaddReferenceGlobal.add(a); } }else if(a.conditions = "PerJoinPoint"){ if(a.fromPointCut.isDefined()){ aupdateReferencePerJoinPoint.add(a); }else{ aaddReferencePerJoinPoint.add(a); } } else if(a.conditions = "PerScope"){ if(a.fromPointCut.isDefined()){ aupdateReferencePerScope.add(a); }else{ aaddReferencePerScope.add(a); } }*/ } "".println(); "All AA".println(); "aaddNodeGlobal ".print(); aaddNodeGlobal.println(); "aaddNodePerJoinPoint ".print(); aaddNodePerJoinPoint.println(); "aaddNodePerScope ".print(); aaddNodePerScope.println(); "aaddNodeOnDemand ".print(); aaddNodeOnDemand.println(); "aupdateNodeGlobal ".print(); aupdateNodeGlobal.println(); "aupdateNodePerJoinPoint ".print(); aupdateNodePerJoinPoint.println(); "aupdateNodePerScope ".print(); aupdateNodePerScope.println(); "aupdateNodeOnDemand ".print(); aupdateNodeOnDemand.println(); "aaddReference ".print(); aaddReference.println(); "aupdateReference ".print(); aupdateReference.println(); } operation weave(bkeep : Set, aaddNodeGlobal : Set, aaddNodePerJoinPoint : Set, aaddNodeOnDemand : Set ,aupdateNodeGlobal : Set ,aupdateNodePerJoinPoint : Set, aupdateNodeOnDemand : Set , aaddReference : Set, aupdateReference : Set, aaddOnDemandReference : Set, aupdateOnDemandReference : Set, cloned : Map, dangling : Map){ var unresolvedGlobal : Map; setAddedGlobalNodes(aaddNodeGlobal, unresolvedGlobal); setUpdatedGlobalNodes(aupdateNodeGlobal,dangling.values().asSet(),unresolvedGlobal); "".println(); "".println(); for(m in JoinPointModel.getAllOfKind("Match") ){ //if( not System.user.confirm("match this JP?", true)){ // continue; //} var unresolvedJP = unresolvedGlobal.clone(); var exclusion : Set; setAddedPerJoinPointNodes(aaddNodePerJoinPoint, unresolvedJP); // setAddedPerScopeNodes(aaddNodePerScope); setAddedOnDemandNodes(aaddNodeOnDemand, unresolvedJP, exclusion); setUpdatedPerJoinPointNodes(aupdateNodePerJoinPoint,dangling.values().asSet(),unresolvedJP,m); // setUpdatedPerScopeNodes(aupdateNodePerScope); setUpdatedOnDemandNodes(aupdateNodeOnDemand, dangling.values().asSet(), unresolvedJP, m, exclusion); setAddedReferences(aaddReference, unresolvedJP, exclusion); setUpdatedReferences(aupdateReference, unresolvedJP, m, cloned, exclusion); setAddedOnDemandReferences(aaddOnDemandReference, unresolvedJP, exclusion); setUpdatedOnDemandReferences(aupdateOnDemandReference, unresolvedJP, m, cloned, exclusion); setUnresolvedNodes(unresolvedJP.values().asSet(), cloned.values().asSet()); //should exclude resolved by dangling instead of being preformed before and then overwiriten (?) setUnresolvedDanglingEdges(aupdateNodePerJoinPoint, dangling, m, unresolvedJP); setUnresolvedDanglingEdges(aupdateNodeGlobal, dangling, m, unresolvedJP); //// setUnresolvedNodes(unresolvedGlobal.values().asSet(), cloned.values().asSet()); } } operation setUnresolvedDanglingEdges(candidates : Set, danglingEdges : Map, match : JoinPointModel!joinpoint::Match, unresolved : Map){ var globalBaseMatch = match.hasPairs.clone(); for( e in candidates){ var baseElem = globalBaseMatch.selectOne(j|j.pc = e.fromPointCut).base; if(danglingEdges.containsKey(baseElem)){ for(ref in danglingEdges.get(baseElem)){ var baseSet = ref.at(2).eGet(ref.at(0)); var newElem = unresolved.get(e); if(ref.at(0).upperBound == 1){ baseSet = newElem; //this is probabli wrong, might be with eSet }else{ baseSet.add(newElem); } //ref.at(2).eSet(ref.at(0), baseSet); // cannot do this to references!! } } } } operation setUnresolvedNodes(unresolved : Set, bkeep : Set){ var ref : EStructuralFeature; for( i in unresolved){ var k = bkeep.selectOne(j | j.eClass().getEAllContainments().exists( r| i.eClass() = r.eType or i.eClass().getEAllSuperTypes().exists(t| t = r.eType )/*r.eType.println() = i.type().println()*/ )); if(not k.isDefined()){ -- if(System.user.confirm("Containment for " + i.toString() + " should be made explicit.\n\nProceed ignoring this containment ?" ,false)){ continue; -- }else{ -- breakAll; -- } } --i.println(); --k.println(); "_".print(); ref = k.eClass().getEAllContainments().selectOne(r|i.eClass() = r.eType or i.eClass().getEAllSuperTypes().exists(t| t = r.eType )); if(ref.upperBound=1){ k.eSet(ref,i); " ?".print(); }else{ " ??".print(); k.eGet(ref).add(i); } } } //merge these two ?? operation setAddedGlobalNodes(aaddNodeGlobal : Set, unresolvedGlobal : Map){ for( i in aaddNodeGlobal ){ var temp = bpmnOutModel.createInstance(i.elemType); for(a in i.hasProperties){ //var tempP = temp.eClass().getEAllAttributes().selectOne(p|p.name = a.Name); setAttribute(temp,a.Name,a.Value); } unresolvedGlobal.put(i,temp); } } operation setAddedPerJoinPointNodes(aaddNodePerJoinPoint : Set, unresolvedJP : Map){ for( i in aaddNodePerJoinPoint ){ var temp = bpmnOutModel.createInstance(i.elemType); --temp.println(); for(a in i.hasProperties){ setAttribute(temp,a.Name,a.Value); //temp.eSet(a.Name , a.Value); } unresolvedJP.put(i,temp); } } operation setAddedOnDemandNodes(aaddNodeOnDemand : Set, unresolvedJP : Map , exclusion : Set){ for( i in aaddNodeOnDemand ){ if(System.user.confirm("Create " + i + " ?",true)){ var temp = bpmnOutModel.createInstance(i.elemType); --temp.println(); for(a in i.hasProperties){ setAttribute(temp,a.Name,a.Value); //temp.eSet(a.Name , a.Value); } unresolvedJP.put(i,temp); }else{ exclusion.add(i); } } } operation setAttribute(inObj : EObject, property : EStructuralFeature, value : String){ if(property.EType.eClass().name = "EEnum"){ inObj.eSet(property , property.EType.getEEnumLiteralByLiteral(value).getInstance()); " .".print(); }else{ switch(property.EType.name){ case "String" : inObj.eSet(property , value); " ..".print(); case "Boolean" : inObj.eSet(property , value.asBoolean()); " ...".print(); case "Integer" : inObj.eSet(property , value.asInteger()); " ....".print(); } } } operation setAttribute(inObj : EObject, propertyName : String, value : String){ inObj.println(); var property = inObj.eClass().getEAllAttributes().selectOne(p|p.name = propertyName); if(property.EType.eClass().name = "EEnum"){ // //dynamic instance present in plugin runtime // inObj.dynamicSet(inObj.eDerivedStructuralFeatureID(property),property.EType.getEEnumLiteralByLiteral(value).getInstance()); inObj.eSet(property , property.EType.getEEnumLiteralByLiteral(value).getInstance()); " ,".print(); }else{ switch(property.EType.name){ case "String" : // //dynamic instance present in plugin runtime // inObj.dynamicSet(inObj.eDerivedStructuralFeatureID(property),value); inObj.eSet(property , value); " ,,".print(); case "Boolean" : //inObj.eSet(property ,(value == "true")); // //dynamic instance present in plugin runtime // inObj.dynamicSet(inObj.eDerivedStructuralFeatureID(property),value.asBoolean()); inObj.eSet(property , value.asBoolean()); " ,,,".print(); case "Integer" : // //dynamic instance present in plugin runtime // inObj.dynamicSet(inObj.eDerivedStructuralFeatureID(property),value.asInteger()); inObj.eSet(property , value.asInteger()); " ,,,,".print(); } } } operation setUpdatedGlobalNodes(aupdateNodeGlobal : Set, dangling : Set, unresolved : Map){ var globalBaseMatch = JoinPointModel.getAllOfKind("Match").first().hasPairs.clone(); for( i in aupdateNodeGlobal ){ var temp = bpmnOutModel.createInstance(i.elemType); var baseElem = globalBaseMatch.selectOne(j|j.pc = i.fromPointCut).base; "<".print(); //var doneProperties : Map; for(a in i.hasProperties){ //var tempP = temp.eClass().getEAllAttributes().selectOne(p|p.name = a.Name); setAttribute(temp,a.Name,a.Value); // doneProperties.put(a.Name, "1"); } for(p in baseElem.eClass().getEAllAttributes().select(e| baseElem.eIsSet(e) // and not temp.eIsSet(e) // and not doneProperties.containsKey(e.name) and not temp.eIsSet(e))){ temp.eSet(p, baseElem.eGet(p)); } unresolved.put(i,temp); } } operation setUpdatedPerJoinPointNodes(aupdateNodePerJoinPoint : Set, dangling : Set, unresolved : Map, match : JoinPointModel!joinpoint::Match){ var globalBaseMatch = match.hasPairs.clone(); for( i in aupdateNodePerJoinPoint ){ var temp = bpmnOutModel.createInstance(i.elemType); var baseElem = globalBaseMatch.selectOne(j|j.pc = i.fromPointCut).base; ">".print(); //var doneProperties : Map; for(a in i.hasProperties){ //var tempP = temp.eClass().getEAllAttributes().selectOne(p|p.name = a.Name); setAttribute(temp,a.Name,a.Value); --a.println(); // doneProperties.put(a.Name, "1"); } for(p in baseElem.eClass().getEAllAttributes().select(e| baseElem.eIsSet(e) // and not temp.eIsSet(e) // and not doneProperties.containsKey(e.name) and not temp.eIsSet(e))){ temp.eSet(p, baseElem.eGet(p)); } unresolved.put(i,temp); } } operation setUpdatedOnDemandNodes(aupdateNodeOnDemand : Set, dangling : Set, unresolved : Map, match : JoinPointModel!joinpoint::Match, exclusion : Set){ var globalBaseMatch = match.hasPairs.clone(); for( i in aupdateNodeOnDemand ){ if(System.user.confirm("Create " + i + " ?",true)){ var temp = bpmnOutModel.createInstance(i.elemType); var baseElem = globalBaseMatch.selectOne(j|j.pc = i.fromPointCut).base; ">".print(); //var doneProperties : Map; for(a in i.hasProperties){ //var tempP = temp.eClass().getEAllAttributes().selectOne(p|p.name = a.Name); setAttribute(temp,a.Name,a.Value); --a.println(); // doneProperties.put(a.Name, "1"); } for(p in baseElem.eClass().getEAllAttributes().select(e| baseElem.eIsSet(e) // and not temp.eIsSet(e) // and not doneProperties.containsKey(e.name) and not temp.eIsSet(e))){ temp.eSet(p, baseElem.eGet(p)); } unresolved.put(i,temp); }else{ exclusion.add(i); } } } operation setAddedReferences(aaddReference : Set, unresolved : Map, exclusion : Set){ "\n\n.".print(); for(i in aaddReference){ ",".print(); if(exclusion.includes(i.source) or exclusion.includes(i.target)){ continue; } var source = unresolved.get(i.source); var target = unresolved.get(i.target); var property = source.eClass().getEAllReferences().selectOne(p|p.name = i.elemType); if(property.upperBound=1){ ".".print(); source.eSet(property, target); }else{ ":".print(); source.eGet(property).add(target); } i.hasProperties.size().print(); for(a in i.hasProperties){ ";".print(); setAttribute(property,a.Name,a.Value); } } "\n".println(); } operation setUpdatedReferences(aupdateReference : Set, unresolved : Map, match : JoinPointModel!joinpoint::Match, cloned : Map, exclusion : Set){ var globalBaseMatch = match.hasPairs.clone(); "\n\n.".print(); for(i in aupdateReference){ ",".print(); if(exclusion.includes(i.source) or exclusion.includes(i.target)){ continue; } var baseElem; if(i.fromPointCut.source.isDefined() and not i.fromPointCut.target.isDefined()){ "<".print(); baseElem = globalBaseMatch.selectOne(j|i.fromPointCut.source == j.pc).base; }else{ ">".print(); baseElem = globalBaseMatch.selectOne(j|i.fromPointCut == j.pc).base; } // baseElem = globalBaseMatch.selectOne(j|i.fromPointCut.print() == j.pc.println()).base; var source; var target; if(i.source.isDefined()){ ">".print(); source = unresolved.get(i.source); }else{ "<".print(); source = cloned.get(baseElem);//convert to newBaseElem produced by cloning (done) // globalBaseMatch.selectOne(j|j.base = baseElem and j.pc <> i.fromPointCut);// nice theory, but the wrong theory } if(i.target.isDefined()){ ">".print(); target = unresolved.get(i.target); }else{ "<".print(); target = cloned.get(baseElem.eGet(baseElem.eClass().getEAllReferences().selectOne(p|p.name = i.elemType))); //convert to newBaseElem produced by cloning (done) } var property = source.eClass().getEAllReferences().selectOne(p|p.name = i.elemType); if(property.upperBound=1){ ".".print(); source.eSet(property, target); }else{ ":".print(); source.eGet(property).add(target); } //i.hasProperties.size().print(); for(a in i.hasProperties){ ";".print(); setAttribute(property,a.Name,a.Value); } // for(p in baseElem.eClass().getEAllAttributes().select(e| baseElem.eIsSet(e) // // and not temp.eIsSet(e) // // and not doneProperties.containsKey(e.name) // and not temp.eIsSet(e))){ // temp.eSet(p, baseElem.eGet(p)); // } } "\n".println(); } operation setAddedOnDemandReferences(aaddOnDemandReference : Set, unresolved : Map, exclusion : Set){ "\n\n.".print(); for(i in aaddOnDemandReference){ ",".print(); if(exclusion.includes(i.source) or exclusion.includes(i.target) or not System.user.confirm("Create " + i + " ?",true)){ continue; } var source = unresolved.get(i.source); var target = unresolved.get(i.target); var property = source.eClass().getEAllReferences().selectOne(p|p.name = i.elemType); if(property.upperBound=1){ ".".print(); source.eSet(property, target); }else{ ":".print(); source.eGet(property).add(target); } i.hasProperties.size().print(); for(a in i.hasProperties){ ";".print(); setAttribute(property,a.Name,a.Value); } } "\n".println(); } operation setUpdatedOnDemandReferences(aupdateOnDemandReference : Set, unresolved : Map, match : JoinPointModel!joinpoint::Match, cloned : Map, exclusion : Set){ var globalBaseMatch = match.hasPairs.clone(); "\n\n.".print(); for(i in aupdateOnDemandReference){ ",".print(); if(exclusion.includes(i.source) or exclusion.includes(i.target) or not System.user.confirm("Create " + i + " ?",true)){ continue; } var baseElem; if(i.fromPointCut.source.isDefined() and not i.fromPointCut.target.isDefined()){ "<".print(); baseElem = globalBaseMatch.selectOne(j|i.fromPointCut.source == j.pc).base; }else{ ">".print(); baseElem = globalBaseMatch.selectOne(j|i.fromPointCut == j.pc).base; } // baseElem = globalBaseMatch.selectOne(j|i.fromPointCut.print() == j.pc.println()).base; var source; var target; if(i.source.isDefined()){ ">".print(); source = unresolved.get(i.source); }else{ "<".print(); source = cloned.get(baseElem);//convert to newBaseElem produced by cloning (done) // globalBaseMatch.selectOne(j|j.base = baseElem and j.pc <> i.fromPointCut);// nice theory, but the wrong theory } if(i.target.isDefined()){ ">".print(); target = unresolved.get(i.target); }else{ "<".print(); target = cloned.get(baseElem.eGet(baseElem.eClass().getEAllReferences().selectOne(p|p.name = i.elemType))); //convert to newBaseElem produced by cloning (done) } var property = source.eClass().getEAllReferences().selectOne(p|p.name = i.elemType); if(property.upperBound=1){ ".".print(); source.eSet(property, target); }else{ ":".print(); source.eGet(property).add(target); } //i.hasProperties.size().print(); for(a in i.hasProperties){ ";".print(); setAttribute(property,a.Name,a.Value); } // for(p in baseElem.eClass().getEAllAttributes().select(e| baseElem.eIsSet(e) // // and not temp.eIsSet(e) // // and not doneProperties.containsKey(e.name) // and not temp.eIsSet(e))){ // temp.eSet(p, baseElem.eGet(p)); // } } "\n".println(); }