public override IEnumerable <MP.Mapping> getOwnedMappings(MP.MappingNode targetRootNode) { var foundMappings = new List <MP.Mapping>(); //get the mappings using trace relations //TODO: is this fast enough? foreach (var trace in this.sourceElement.getRelationships <TSF_EA.Abstraction>().Where(x => x.target is TSF_EA.Element && x.stereotypes.Any(y => y.name == "trace"))) { //get the mappings based on traces var mapping = MappingFactory.getMapping(this, trace, (MappingNode)targetRootNode); if (mapping != null) { foundMappings.Add(mapping); } } //also add the base mappings foundMappings.AddRange(base.getOwnedMappings(targetRootNode)); return(foundMappings); }
List <Mapping> getMappings() { //get the connector mappings //check if the package has a trace to another package ElementWrapper targetRootElement = null; var packageTrace = this.wrappedPackage.relationships.OfType <Abstraction>().FirstOrDefault(x => x.target is Element && x.stereotypes.Any(y => y.name == "trace")); if (packageTrace != null) { targetRootElement = packageTrace.target as ElementWrapper; } List <Mapping> returnedMappings = new List <Mapping>(); foreach (var classElement in wrappedPackage.ownedElements.OfType <ElementWrapper>()) { returnedMappings.AddRange(MappingFactory.createOwnedMappings(classElement, wrappedPackage.name + "." + classElement.name, targetRootElement, true)); } return(returnedMappings); }
public override IEnumerable <MP.Mapping> getOwnedMappings(MP.MappingNode targetRootNode) { //the mappings are stored in a tagged value var foundMappings = new List <MP.Mapping>(); //Mappings are stored in tagged values foreach (var mappingTag in this.sourceAssociation.taggedValues.Where(x => x.name == this.settings.linkedAttributeTagName)) { var mapping = MappingFactory.getMapping(this, (TSF_EA.TaggedValue)mappingTag, (MappingNode)targetRootNode); if (mapping != null) { foundMappings.Add(mapping); } } //loop subNodes foreach (MappingNode childNode in this.allChildNodes) { foundMappings.AddRange(childNode.getOwnedMappings(targetRootNode)); } return(foundMappings); }
public override IEnumerable <MP.Mapping> getOwnedMappings(MP.MappingNode targetRootNode) { var foundMappings = new List <MP.Mapping>(); //TODO: is this fast enough? foreach (var trace in this.sourceElement.relationships.OfType <TSF_EA.Abstraction>().Where(x => x.target is TSF_EA.Element && x.stereotypes.Any(y => y.name == "trace"))) { //check if this trace represents a mappingNode to somewhere in in the targetNode //get the mapping path var mapping = MappingFactory.getMapping(this, trace, (MappingNode)targetRootNode); if (mapping != null) { foundMappings.Add(mapping); } } //loop subNodes foreach (MappingNode childNode in this.allChildNodes) { foundMappings.AddRange(childNode.getOwnedMappings(targetRootNode)); } return(foundMappings); }
public MappingNode createMappingNode(List <string> mappingPath) { //if the path is empty we return this node if (!mappingPath.Any()) { return(this); } //check if the first node corresponds to this node if (mappingPath[0] == this.source.uniqueID) { //pop the first node mappingPath.RemoveAt(0); //if this was the last guid then also return this if (!mappingPath.Any()) { return(this); } //get the element corresponding to the (now) first guid. var subElement = this._source.model.getItemFromGUID(mappingPath[0]) as UML.Classes.Kernel.NamedElement; //check if a childNode for the given subElement is already present var childNode = this.allChildNodes.FirstOrDefault(x => x.source.uniqueID == subElement?.uniqueID) as MappingNode; //create new new node if not already present if (childNode == null) { //TODO: check if subElement is actually somehow linked to this node? childNode = MappingFactory.createMappingNode(subElement, this, this.settings); } return(childNode?.createMappingNode(mappingPath)); } else { //the first GUID indicates that it does not below in this node this.mappingPath.Clear(); return(this); } }
public static List <Mapping> createRootMappings(ElementWrapper root, string basepath) { //get the owned mappings var returnedMappings = MappingFactory.createOwnedMappings(root, basepath, false); //get the mappings of all associated elements foreach (var assocation in root.relationships .OfType <Association>() .Where(x => x.source.Equals(root))) { var targetElement = assocation.target as ElementWrapper; if (targetElement != null) { returnedMappings.AddRange(createRootMappings(targetElement, basepath + "." + getConnectorString(assocation))); } } //get the owned mappings of all owned elements foreach (var ownedElement in root.ownedElements.OfType <ElementWrapper>()) { returnedMappings.AddRange(createRootMappings(ownedElement, basepath + "." + ownedElement.name)); } return(returnedMappings); }
List <Mapping> getMappings() { return(MappingFactory.createRootMappings(this.wrappedElement, this.wrappedElement.name)); }