예제 #1
0
        /// <summary>
        /// タグ付き値の更新前、更新後の情報をログファイルに出力
        /// </summary>
        /// <param name="tgv">対象のEA.TaggedValueオブジェクト</param>
        /// <param name="afterUpdateFlag">更新前/更新後を示す(true=後)</param>
        private static void writeUpdateLogTaggedValue(EA.TaggedValue tgv, bool afterUpdateFlag)
        {
            try
            {
                StreamWriter sw = new StreamWriter(@"C:\ea-artifacts\DiffViewerUpdate.log", true);

                if (afterUpdateFlag)
                {
                    sw.WriteLine("■タグ付き値の書き込みが完了しました(ID={0}, GUID={1})。", tgv.PropertyID, tgv.PropertyGUID);
                }
                else
                {
                    sw.WriteLine("〇タグ付き値の更新前情報を表示します(ID={0}, GUID={1})。", tgv.PropertyID, tgv.PropertyGUID);
                }

                sw.WriteLine("  PropertyID = " + tgv.PropertyID);
                sw.WriteLine("  PropertyGUID = " + tgv.PropertyGUID);
                sw.WriteLine("  Name = " + tgv.Name);
                sw.WriteLine("  Notes = " + tgv.Notes);
                sw.WriteLine("  Value = " + tgv.Value);
                sw.WriteLine("");

                sw.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 /// <summary>
 /// Set Tagged Value with 'Name' to a value. If tagged value doesn't exists a new one is created.
 /// </summary>
 /// <param name="el"></param>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static EA.TaggedValue SetTaggedValue(EA.Element el, string name, string value)
 {
     EA.TaggedValue tg = AddTaggedValue(el, name);
     tg.Value = value;
     tg.Update();
     return(tg);
 }
        /// <summary>
        /// Create Tagged Value with 'Name'. It return the TaggedValue
        /// </summary>
        /// <param name="el"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static EA.TaggedValue CreateTaggedValue(EA.Element el, string name)
        {
            EA.TaggedValue tg = Add(el, name);
            tg.Update();

            return(tg);
        }
예제 #4
0
        private bool SynchronizeUmlItemTags(UML.Classes.Interfaces.Interface interfaceItem, ref string TagName, ref string TagValue, ref string TagNotes)
        {
            if (HasSterotype(C_ExtStereotypes.funptr, interfaceItem.stereotypes))
            {
                FunptrInterface funptr = new FunptrInterface(interfaceItem);
                string          defaultTypeSynonymsTag = interfaceItem.name;
                EA.Element      eaElem         = (interfaceItem as UTF_EA.ElementWrapper).WrappedElement;
                bool            changedElement = false;

                // Synchronize tagged values
                for (short i = 0; i < eaElem.TaggedValues.Count; ++i)
                {
                    EA.TaggedValue currentTag = eaElem.TaggedValues.GetAt(i) as EA.TaggedValue;
                    bool           changedTag = false;
                    switch (currentTag.Name)
                    {
                    case C_ExtTags.typeSynonyms:
                        if (currentTag.Value != defaultTypeSynonymsTag)
                        {
                            currentTag.Value = defaultTypeSynonymsTag;
                            changedTag       = true;
                        }
                        break;

                    case C_ExtTags.static_:
                        if ((currentTag.Value == "false") &&
                            !((interfaceItem.owner is UML.Classes.Kernel.Class) ||
                              (interfaceItem.owner is UML.Classes.Interfaces.Interface)))
                        {
                            TagValue   = "true";
                            changedTag = true;
                        }
                        break;
                    }
                    if (changedTag)
                    {
                        currentTag.Update();
                        eaElem.TaggedValues.Refresh();
                        changedElement = true;
                    }
                }

                // Synchronize element Alias
                string alias = funptr.GetAliasFromTags(TagName, TagValue);
                if (eaElem.Alias != alias)
                {
                    eaElem.Alias   = alias;
                    changedElement = true;
                }

                if (changedElement)
                {
                    eaElem.Update();
                }
                return(changedElement);
            }

            return(false);
        }
예제 #5
0
        private void SynchronizeTaggedValues(EAAPI.Element originalElement, EAAPI.Element referenceElement)
        {
            for (short tagCount = 0; tagCount < originalElement.TaggedValues.Count; tagCount++)
            {
                EAAPI.TaggedValue taggedValue = originalElement.TaggedValues.GetAt(tagCount) as EAAPI.TaggedValue;

                referenceElement.SetTaggedValueString(taggedValue.Name, taggedValue.Value, false);
            }
        }
        private static TaggedValueVO getTaggedValueFromEAObject(EA.TaggedValue eaTagObj)
        {
            TaggedValueVO tvvo = new TaggedValueVO();

            tvvo.name     = excludeSpecialChar(eaTagObj.Name);
            tvvo.guid     = eaTagObj.PropertyGUID;
            tvvo.tagValue = excludeSpecialChar(eaTagObj.Value);
            tvvo.notes    = eaTagObj.Notes;
            tvvo.changed  = ' ';
            return(tvvo);
        }
예제 #7
0
 /// <summary>
 /// Copy tagged values - except direction and ASIL Level - from client port to supplier port.
 /// </summary>
 /// <param name="client">The client port.</param>
 /// <param name="supplier">The supplier port.</param>
 private void CopyTaggedValuesFromClientToSupplierPort(EAShared.Element client, EAShared.Element supplier)
 {
     for (short i = 0; i < client.TaggedValues.Count; i++)
     {
         EAShared.TaggedValue clientTag = client.TaggedValues.GetAt(i) as EAShared.TaggedValue;
         if (clientTag != null && (clientTag.Name != "direction" && clientTag.Name != "ASIL Level"))
         {
             supplier.SetTaggedValueString(clientTag.Name, clientTag.Value, false);
         }
     }
 }
        /// <summary>
        /// Make a memo field out of the current TaggedValue
        /// </summary>
        /// <param name="el"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static EA.TaggedValue MakeMemo(EA.Element el, string name)
        {
            EA.TaggedValue tg    = Add(el, name);
            string         value = tg.Value;

            if (value.ToLower() == MemoString)
            {
                return(tg);
            }
            tg.Value = MemoString;
            tg.Notes = value;
            tg.Update();
            return(tg);
        }
        /// <summary>
        /// Get Tagged Value with 'Name'. If tagged value doesn't exists than create a new one. Don't forget to write the value and update.
        /// </summary>
        /// <param name="el"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static EA.TaggedValue Add(EA.Element el, string name)
        {
            foreach (EA.TaggedValue taggedValue in el.TaggedValues)
            {
                if (taggedValue.Name == name)
                {
                    return(taggedValue);
                }
            }

            // create tagged value
            EA.TaggedValue tg = (EA.TaggedValue)el.TaggedValues.AddNew(name, "Tag");
            el.TaggedValues.Refresh();

            return(tg);
        }
예제 #10
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();
        }
예제 #11
0
        public object MgtGenTags(Repository repository, object array)
        {
            string tags        = "";
            string elementGuid = ((string[])array)[0];

            EA.Element element = repository.GetElementByGuid(elementGuid);
            for (short idx = 0; idx < element.TaggedValues.Count; idx++)
            {
                EA.TaggedValue taggedValue = element.TaggedValues.GetAt(idx);
                if (taggedValue.FQName == null || taggedValue.FQName == "")
                {
                    string tagval = "Tag\n{\nname = \"" + taggedValue.Name + "\"\nvalue = \"" + taggedValue.Value + "\"\n}";
                    tags = tags + "\n" + tagval;
                }
            }
            tags = tags + "\n";
            return(tags);
        }
 /// <summary>
 /// Get Tagged Value with 'Name'. If tagged value doesn't exists a new one is created
 /// </summary>
 /// <param name="el"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public static EA.TaggedValue AddTaggedValue(EA.Element el, string name)
 {
     EA.TaggedValue tagStart = null;
     foreach (EA.TaggedValue taggedValue in el.TaggedValues)
     {
         if (taggedValue.Name == name)
         {
             tagStart = taggedValue;
             break;
         }
     }
     if (tagStart == null)
     {
         // create tagged value
         tagStart = (EA.TaggedValue)el.TaggedValues.AddNew(name, "Tag");
         el.TaggedValues.Refresh();
     }
     return(tagStart);
 }
예제 #13
0
        public object CgtGenTags(Repository repository, object array)
        {
            string tags        = "[";
            string elementGuid = ((string[])array)[0];
            string blockIndent = ((string[])array)[1];
            string indent      = ((string[])array)[2];

            EA.Element element = repository.GetElementByGuid(elementGuid);
            for (short idx = 0; idx < element.TaggedValues.Count; idx++)
            {
                EA.TaggedValue taggedValue = element.TaggedValues.GetAt(idx);
                if (taggedValue.FQName == null || taggedValue.FQName == "")
                {
                    string tagval = blockIndent + indent + "{\"Key\" : \"" + taggedValue.Name + "\", \"Value\" : \"" + taggedValue.Value + "\"}";
                    tags = tags + "\n" + tagval;
                }
            }
            tags = tags + "\n" + blockIndent + "]";
            return(tags);
        }
예제 #14
0
        public void Generate_otTaggedValues_content(Repository m_Repository, string TOI_GUID, string TOI_Name, out EA_TaggedValueStore myTVS)
        {
            EA.Element ParentElement = (EA.Element)m_Repository.GetElementByGuid(TOI_GUID);
            myTVS = new Models.EA_TaggedValueStore();
            myTVS.ParentElementName = ParentElement.Name;
            myTVS.ParentElementGUID = ParentElement.ElementGUID;


            for (short i = 0; i < ParentElement.TaggedValues.Count; i++)
            {
                EA.TaggedValue TagValue = (EA.TaggedValue)ParentElement.TaggedValues.GetAt(i);



                if (TagValue.Name == TOI_Name)
                {
                    if (myTVS.TaggedDictionary.ContainsKey(TagValue.Name) == false)
                    {
                        myTVS.TaggedDictionary.Add(TagValue.Name, TagValue.Value);
                    }
                }
            }
        }
 /// <summary>
 /// Set Tagged Value with 'Name' to a value. It handles long memo fields.
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static void SetTaggedValue(EA.TaggedValue tag, string value)
 {
     tag.Value = value.Length > 255 ? MemoString : value;
     tag.Notes = value;
     tag.Update();
 }
 /// <summary>
 /// Get the value of an element tagged value. It handles Memo field with a lang of > 255
 /// </summary>
 /// <param name="tg"></param>
 /// <returns></returns>
 public static string GetTaggedValue(EA.TaggedValue tg)
 {
     return(tg.Value == MemoString ? tg.Notes : tg.Value);
 }
 /// <summary>
 /// Set Tagged Value with 'Name' to a value. If tagged value doesn't exists a new one is created. If the
 /// </summary>
 /// <param name="el"></param>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static EA.TaggedValue SetUpdate(EA.Element el, string name, string value)
 {
     EA.TaggedValue tg = Add(el, name);
     SetTaggedValue(tg, value);
     return(tg);
 }
예제 #18
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));
                }
            }
        }
예제 #19
0
        //ELEMENT CONTENT
        public void Generate_otElement_content(
            Repository m_Repository,
            string TOI_GUID,
            out List <string> listOfDiagrams,
            out List <string> listOfDiagramsNames,
            out List <string> ListOfConnectors,
            out List <string> ListOfConnectorNames,
            out Dictionary <string, string> elementAttributes,
            out EA_TaggedValueStore myTVS)
        {
            listOfDiagrams       = new List <string>();
            listOfDiagramsNames  = new List <string>();
            ListOfConnectors     = new List <string>();
            ListOfConnectorNames = new List <string>();
            elementAttributes    = new Dictionary <string, string>();
            myTVS = new EA_TaggedValueStore();


            EA.Element MyEle = (EA.Element)m_Repository.GetElementByGuid(TOI_GUID);

            elementAttributes.Add("Name", MyEle.Name);
            elementAttributes.Add("Notes", MyEle.Notes);
            elementAttributes.Add("Author", MyEle.Author);
            elementAttributes.Add("DataCreated", MyEle.Created.ToString());
            elementAttributes.Add("Version", MyEle.Version);
            elementAttributes.Add("Status", MyEle.Status);
            elementAttributes.Add("GUID", MyEle.ElementGUID);


            //CONNECTORS
            foreach (EA.Connector MyConnector in MyEle.Connectors)
            {
                string GUID = MyConnector.ConnectorGUID;
                string Name = MyConnector.Name;
                string Type = MyConnector.ObjectType.ToString();

                ListOfConnectorNames.Add(Name);
                ListOfConnectors.Add(Name + "|otConnector|" + GUID);
            }


            //TAGGED VALUES
            for (short i = 0; i < MyEle.TaggedValues.Count; i++)
            {
                EA.TaggedValue TagValue = (EA.TaggedValue)MyEle.TaggedValues.GetAt(i);

                //Only add the key if it does not exist
                if (myTVS.TaggedDictionary.ContainsKey(TagValue.Name) == false)
                {
                    myTVS.TaggedDictionary.Add(TagValue.Name, TagValue.Value);
                }
            }

            myTVS.ParentElementName = MyEle.Name;
            myTVS.ParentElementGUID = MyEle.ElementGUID;



            //DIAGRAMS
            foreach (EA.Diagram DiagramLoop in MyEle.Diagrams)
            {
                listOfDiagrams.Add(DiagramLoop.Name + "|" + DiagramLoop.ObjectType + "|" + DiagramLoop.DiagramGUID);
                listOfDiagramsNames.Add(DiagramLoop.Name);
            }
        }