コード例 #1
0
        public List <Node> GetAllHierarchies()
        {
            List <Node> result = new List <Node>();

            EAAPI.Collection searchResult = _repository.GetElementsByQuery("SpecificationPackages", "");

            if (searchResult.Count > 0)
            {
                for (short counter = 0; counter < searchResult.Count; counter++)
                {
                    EAAPI.Element packageElement = searchResult.GetAt(counter) as EAAPI.Element;

                    EAAPI.Package package = _repository.GetPackageByGuid(packageElement.ElementGUID);

                    CachedDataProvider eaCacheDataProvider = new CachedDataProvider(_repository);

                    EADM.Element specificationPackageElement = eaCacheDataProvider.GetCachedSpecification(package);

                    Node rootNode = new Node();

                    ConvertEaDataToSpecifNodeRecursively(specificationPackageElement, rootNode);

                    result = rootNode.Nodes;
                }
            }

            return(result);
        }
コード例 #2
0
 private void PrintPackage(EA.Package package)
 {
     Trace(package.Name);
     EA.Collection packages = package.Packages;
     for (short ip = 0; ip < packages.Count; ip++)
     {
         EA.Package child = (EA.Package)packages.GetAt(ip);
         PrintPackage(child);
     }
 }
コード例 #3
0
        /// <summary>
        /// Make EA.DiagramObject list from collection
        /// </summary>
        /// <param name="col"></param>
        /// <returns></returns>
        public static List <EA.DiagramObject> MakeObjectListFrmCollection(EA.Collection col)
        {
            List <EA.DiagramObject> lDiaObj = new List <EA.DiagramObject>();

            foreach (EA.DiagramObject diaObj in col)
            {
                lDiaObj.Add(diaObj);
            }

            return(lDiaObj);
        }
コード例 #4
0
 ///
 /// returns true if a project is currently opened
 ///
 /// <param name="Repository" />the repository
 /// true if a project is opened in EA
 bool IsProjectOpen(EA.Repository Repository)
 {
     try
     {
         EA.Collection c = Repository.Models;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #5
0
ファイル: KzgAddinClass.cs プロジェクト: Zagii/EAkzg
 ///
 /// returns true if a project is currently opened
 ///
 /// <param name="Repository" />the repository
 /// true if a project is opened in EA
 bool IsProjectOpen(EA.Repository Repository)
 {
     try
     {
         EA.Collection c = Repository.Models;
         EAUtils.zapiszNazweModelu(EAUtils.dajModelPR(ref Repository).Name);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #6
0
 /// <summary>
 /// Get tree selected elements. These are the selected elements or the selected package
 /// </summary>
 private void GetTreeSelected()
 {
     EA.Collection col = _rep.GetTreeSelectedElements();
     if (col.Count == 0)
     {
         TreeSelectedPackage = _rep.GetTreeSelectedPackage();
     }
     else
     {
         foreach (EA.Element c in col)
         {
             TreeSelectedElements.Add(c);
         }
     }
 }
コード例 #7
0
 public bool PrintModel()
 {
     if (Repository == null)
     {
         Trace(String.Format("Repository unavailable for pid {0}", m_ProcessID));
         return(false);
     }
     Trace(String.Format("Target repository process pid {0}", m_ProcessID));
     EA.Collection packages = Repository.Models;
     for (short ip = 0; ip < packages.Count; ip++)
     {
         EA.Package child = (EA.Package)packages.GetAt(ip);
         PrintPackage(child);
     }
     return(true);
 }
コード例 #8
0
        private Dictionary <String, EAAPI.Element> ConvertEAElementsToDictionary(EAAPI.Collection eaElements)
        {
            Dictionary <String, EAAPI.Element> dicElements = new Dictionary <string, EAAPI.Element>();

            for (short nIndex = 0; nIndex < eaElements.Count; nIndex++)
            {
                EAAPI.Element element = (EAAPI.Element)eaElements.GetAt(nIndex);

                if (false == dicElements.ContainsKey(element.Alias))
                {
                    dicElements.Add(element.Alias, element);
                }
            }

            return(dicElements);
        }
コード例 #9
0
        private void AddOrUpdateElements(EAAPI.Package parentPackage, EAAPI.Element parentElement, EAAPI.Diagram lifeCycleDiagram, ref Dictionary <String, EAAPI.Element> elements)
        {
            // Get the Tagged Values from the parent diagram.
            EAAPI.Collection taggedValues = parentElement.TaggedValues;

            foreach (Utility.Element element in diagramConfig.Elements.Element.AsQueryable())
            {
                String elementName = element.Name;
                String elementType = element.Type;
                String elementText = element.Text;

                if (!String.IsNullOrEmpty(elementText) && true == elementText.Contains("@TAGVALUE"))
                {
                    // Get the value from the TaggedValues
                    String[]          keyValuePair = elementText.Split(':');
                    EAAPI.TaggedValue taggedValue  = (EAAPI.TaggedValue)taggedValues.GetByName(keyValuePair[1]);

                    elementText = taggedValue.Value;

                    // If there is an associated Map then use that.
                    if (!String.IsNullOrEmpty(element.TextMap))
                    {
                        // Get the text map to use from the Configuration
                        Utility.Map mapValues = (from t in diagramConfig.Configuration.Map
                                                 where t.Name.Contains(element.TextMap)
                                                 select t).First();

                        // Map the key to the value and that is the string to add on the diagram.
                        elementText = (from t in mapValues.MapValue
                                       where t.Key.Contains(elementText)
                                       select t.Value).First();
                    }
                }

                // Add the elements to the Repository.
                // Update only the text if it is already in the Repository.
                AddOrUpdateElement(
                    parentPackage,
                    ref elements,
                    FormatDiagramElementAlias(lifeCycleDiagram.DiagramID, elementName),
                    elementType,
                    elementText,
                    element.BackColor);
            }

            parentPackage.Elements.Refresh();
        }
コード例 #10
0
        //
        public bool InventoryDesignInterfaces()
        {
            // Get all interfaces
            // 'object_id' has to be included in select
            string sql = $@"select object_id, name
            from t_object 
            where object_type = 'Interface' AND
            package_id in ( { _designPackagedIds} )
            order by 2";

            EA.Collection interfaceList = Rep.GetElementSet(sql, 2);
            foreach (EA.Element el in interfaceList)
            {
                InterfaceItem ifItem = (InterfaceItem)_designFiles.Add($"{el.Name}.h");
                ifItem.El = el;

                foreach (EA.Method m in el.Methods)
                {
                    // create function
                    FunctionItem functionItem = new FunctionItem(m.Name, m.ReturnType, m.IsStatic, new List <ParameterItem>(), ifItem, m);
                    if (_designFunctions.FunctionList.ContainsKey(m.Name))
                    {
                        var function = _designFunctions.FunctionList[m.Name];
                        MessageBox.Show($"Interface:\t{function.Interface?.Name}\r\nModule:\t{function.Module?.Name}",
                                        $"Duplicated Function {m.Name}, skipped!");
                    }
                    else
                    {
                        _designFunctions.FunctionList.Add(m.Name, functionItem);
                    }

                    // update interface
                    ifItem.ProvidedFunctions.Add(functionItem);
                }
            }

            // Show deleted Interface
            var deletedInterfaces = from s in _designFiles.FileList
                                    where !_files.FileList.Any(t => (s.Value.Name == t.Value.Name) &&
                                                               t.Value.GetType().Name.Equals(typeof(InterfaceItem).Name))
                                    select s.Value.El;

            var createdInterfaces = from s in _files.FileList
                                    where !_designFiles.FileList.All(t => (s.Value.Name == t.Value.Name) &&
                                                                     t.Value.GetType().Name.Equals(typeof(InterfaceItem).Name))
                                    select s.Value.El;

            _deletedInterfaces = 0;
            string deleteMe = "DeleteMe";

            foreach (var el in deletedInterfaces)
            {
                if (!el.Name.EndsWith(deleteMe))
                {
                    el.Name = el.Name + deleteMe;
                    el.Update();
                }
                _deletedInterfaces++;
            }
            _createdInterfaces = createdInterfaces.Count();

            return(true);
        }
コード例 #11
0
        private void AddOrUpdateElementsOnDiagram(EAAPI.Element parentElement, EAAPI.Diagram lifeCycleDiagram, ref Dictionary <String, EAAPI.Element> elements)
        {
            String alias;
            int    elementID;

            // Get all of the diagram elements on the existing diagram into a list that is easier to search.
            Dictionary <String, int> preExistingObjects = new Dictionary <String, int>();

            foreach (EAAPI.DiagramObject digObject in lifeCycleDiagram.DiagramObjects)
            {
                EAAPI.Element packageElement = eaRepo.GetElementByID(digObject.ElementID);

                alias     = packageElement.Alias;
                elementID = packageElement.ElementID;

                if (!String.IsNullOrEmpty(alias))
                {
                    preExistingObjects.Add(packageElement.Alias, packageElement.ElementID);
                }
            }

            int    topDef;
            int    leftDef;
            int    heightDef;
            int    widthDef;
            String elementName;
            int    top;
            int    left;
            int    right;
            int    bottom;

            int row;
            int column;

            topDef    = SafeToInt(diagramConfig.Configuration.Position.DefaultTop, 0);
            leftDef   = SafeToInt(diagramConfig.Configuration.Position.DefalutLeft, 0);
            heightDef = SafeToInt(diagramConfig.Configuration.Position.DefaultHeight, 0);
            widthDef  = SafeToInt(diagramConfig.Configuration.Position.DefaultWidth, 0);

            String backColor;

            // Get the parent diagram. This contains the Tagged Values.
            EAAPI.Collection taggedValues = parentElement.TaggedValues;

            // Ad or update the diagram elements.
            foreach (Utility.Element element in diagramConfig.Elements.Element.AsQueryable())
            {
                elementName = FormatDiagramElementAlias(lifeCycleDiagram.DiagramID, element.Name);
                elementID   = elements[elementName].ElementID;

                row    = SafeToInt(element.Cell.Row, 0);
                column = SafeToInt(element.Cell.Column, 0);

                top    = topDef + ((row - 1) * heightDef) + SafeToInt(element.PositionOffset.Top, 0);
                left   = leftDef + ((column - 1) * widthDef) + SafeToInt(element.PositionOffset.Left, 0);
                right  = widthDef + left + SafeToInt(element.PositionOffset.Width, 0);
                bottom = heightDef + top + SafeToInt(element.PositionOffset.Height, 0);

                backColor = element.BackColor;

                if (!String.IsNullOrEmpty(backColor) && true == backColor.Contains("@TAGVALUE"))
                {
                    // Get the value from the TaggedValues
                    String[]          keyValuePair = backColor.Split(':');
                    EAAPI.TaggedValue taggedValue  = (EAAPI.TaggedValue)taggedValues.GetByName(keyValuePair[1]);

                    // Get the color map to use
                    Utility.TaggedValueColorMap mapValues = (from t in diagramConfig.Configuration.TaggedValueColorMap
                                                             where t.Name.Contains(element.ColorMap)
                                                             select t).First();

                    backColor = MapColor(mapValues.Color, taggedValue.Value);
                }

                if (!preExistingObjects.ContainsKey(elements[elementName].Alias))
                {
                    AddElementToDiagram(
                        lifeCycleDiagram, elementID, element.Type, left, right, top, bottom,
                        MapFont(diagramConfig.Configuration.FontMap.Font, element.Font),
                        MapColor(diagramConfig.Configuration.ColorMap.Color, backColor));
                }
                else
                {
                    UpdateElementOnDiagram(
                        lifeCycleDiagram, preExistingObjects[elementName], MapColor(diagramConfig.Configuration.ColorMap.Color, backColor));
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Write the EA dependencies according to ReqIF between the requirements
        /// </summary>
        public bool WriteRelations()
        {
            // Read all requirements
            string stereotypePredicate = _settings.Stereotype == "" ? "" : $" AND stereotype = '{_settings.Stereotype}' ";
            string sql = $@"select *
                    from t_object o
                    inner join t_package pkg on pkg.package_id = o.package_id 
                    where pkg.ea_guid in ( {_settings.PackageGuidCommaList} ) AND
                           o.object_type = '{_settings.ObjectType}' 
                           {stereotypePredicate}";

            EA.Collection reqCol = _rep.GetElementSet(sql, 2);
            foreach (EA.Element req in reqCol)
            {
                _requirements.Add(req);
            }


            // All EA requirements and their target
            try
            {
                // check not existing references
                var notExistingTargets = (from r in _reqIf.CoreContent[0].SpecRelations
                                          join eaRS in _requirements on r.Source.Identifier ?? "" equals eaRS.Multiplicity ?? ""
                                          where r.Target == null
                                          select $"{eaRS.Multiplicity}:{eaRS.Name}").ToArray();
                if (notExistingTargets.Length > 0)
                {
                    MessageBox.Show($@"{String.Join("\r\n", notExistingTargets)}", @"Target Requirements for Link not available, skip links");
                }


                var relations = from r in _reqIf.CoreContent[0].SpecRelations
                                join eaRS in _requirements on r.Source?.Identifier ?? "" equals eaRS.Multiplicity ?? ""
                                join eaRT in _requirements on r.Target?.Identifier ?? "" equals eaRT.Multiplicity ?? ""
                                orderby r.Source?.Identifier ?? ""
                                select new
                {
                    SourceReq = eaRS,
                    TargetReq = eaRT,
                    SObjectId = r.Source.Identifier ?? "",
                    TObjectId = r.Target.Identifier ?? "",
                };



                // Create the relations
                EA.Element el = null;
                foreach (var rel in relations)
                {
                    if (el != rel.SourceReq)
                    {
                        el = rel.SourceReq;
                        if (el != null)
                        {
                            DeleteDependencies(el, _settings.PackageGuidList);
                        }
                    }

                    EA.Connector con = (EA.Connector)el.Connectors.AddNew("", "Dependency");
                    con.Stereotype = _settings.StereotypeDependency;
                    con.ClientID   = rel.TargetReq.ElementID;
                    con.SupplierID = rel.SourceReq.ElementID;
                    con.Update();

                    el.Connectors.Refresh();
                    el.Update();
                }

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show($@"Related link to requirement not available

File:
'{_settings.InputFile}'

{e}", @"Can't write ReqIF relations in EA, skip relations!");
                return(false);
            }
        }