createOwnedMappings() public static method

public static createOwnedMappings ( ElementWrapper ownerElement, string basepath ) : List
ownerElement ElementWrapper
basepath string
return List
Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }