public EA.Attribute getOrCreateAttribute(SQLElement parentClass, MocaNode attributeNode)
        {
            String oldGuid = attributeNode.getAttributeOrCreate(Main.GuidStringName).Value;

            EA.Attribute attribute = repository.GetAttributeByGuid(oldGuid);
            if (attribute == null)
            {
                attribute = parentClass.getRealElement().Attributes.AddNew(attributeNode.getAttributeOrCreate("name").Value, "") as EA.Attribute;
                attribute.Update();
                repository.Execute("update t_attribute set ea_guid = '" + oldGuid + "' where ea_guid = '" + attribute.AttributeGUID + "'");
                attribute = repository.GetAttributeByGuid(oldGuid);
            }
            return(attribute);
        }
 public override void Load(EA.Repository rep)
 {
     _attr       = rep.GetAttributeByGuid(Guid);
     Name        = _attr.Name;
     Description = _attr.Notes;
     Stereotype  = _attr.StereotypeEx;
 }
Exemple #3
0
 public override void load(EA.Repository rep)
 {
     _attr        = rep.GetAttributeByGuid(GUID);
     _Name        = _attr.Name;
     _Description = _attr.Notes;
     _Stereotype  = _attr.StereotypeEx;
 }
Exemple #4
0
        public void showObjectProperties(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            eaObjectType.Text = ot.ToString();
            eaObjectName.Text = "?";
            switch (ot)
            {
            case EA.ObjectType.otAttribute:
                EA.Attribute attribute = Repository.GetAttributeByGuid(GUID);
                currentEaObject             = attribute;
                currentEaObjectCollections  = null;
                eaObjectName.Text           = attribute.Name;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;

            case EA.ObjectType.otElement:
                EA.Element element = Repository.GetElementByGuid(GUID);
                currentEaObject             = element;
                currentEaObjectCollections  = new EAElementCollections(element);
                eaObjectName.Text           = element.Name;
                showEmbeddedObjects.Enabled = true;
                break;

            case EA.ObjectType.otMethod:
                EA.Method method = Repository.GetMethodByGuid(GUID);
                currentEaObject             = method;
                currentEaObjectCollections  = null;
                eaObjectName.Text           = method.Name;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;

            case EA.ObjectType.otPackage:
                EA.Package package = Repository.GetPackageByGuid(GUID);
                currentEaObject             = package;
                currentEaObjectCollections  = new EAPackageCollections(package);
                eaObjectName.Text           = package.Name;
                showEmbeddedObjects.Enabled = true;
                break;

            case EA.ObjectType.otConnector:
                EA.Connector connector = Repository.GetConnectorByGuid(GUID);
                currentEaObject             = connector;
                currentEaObjectCollections  = null;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;

            default:
                currentEaObject             = null;
                currentEaObjectCollections  = null;
                propertyGrid.SelectedObject = null;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;
            }
            SynchPropertyGridSelection();
        }
Exemple #5
0
 /// <summary>
 /// GUIDによりEAから属性オブジェクトを取得
 /// </summary>
 /// <param name="attributeGuid"></param>
 /// <returns></returns>
 private EA.Attribute getAttributeByGuid(string attributeGuid)
 {
     EA.Repository repo    = ProjectSetting.getVO().eaRepo;
     EA.Attribute  attrObj = (EA.Attribute)repo.GetAttributeByGuid(attributeGuid);
     if (attrObj != null)
     {
         return(attrObj);
     }
     else
     {
         return(null);
     }
 }
Exemple #6
0
        internal void EA_OnNotifyContextItemModified(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            if (!initialConnectionAvailable)
            {
                return;
            }

            //EA_OnNotifyContextItemModified notifies Add-Ins that the current context item has been modified.
            //This event occurs when a user has modified the context item. Add-Ins that require knowledge of when
            // an item has been modified can subscribe to this broadcast function.
            // See also: http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/ea_onnotifycontextitemmodified.html

            ModificationChange change = new ModificationChange();

            change.internalID = GUID;

            switch (ot)
            {
            case EA.ObjectType.otPackage:
                EA.Package eaPackage = Repository.GetPackageByGuid(GUID);
                change.elementType = ElementType.PACKAGE;
                change.name        = eaPackage.Name;
                break;

            case EA.ObjectType.otElement:
                EA.Element eaElement = Repository.GetElementByGuid(GUID);
                change.elementType = ElementType.ELEMENT;
                change.name        = eaElement.Name;
                break;

            case EA.ObjectType.otConnector:
                EA.Connector eaConnector = Repository.GetConnectorByGuid(GUID);
                change.elementType = ElementType.CONNECTOR;
                change.name        = eaConnector.Name;
                break;

            case EA.ObjectType.otAttribute:
                EA.Attribute method = Repository.GetAttributeByGuid(GUID);
                change.elementType = ElementType.ATTRIBUTE;
                change.name        = method.Name;
                break;

            case EA.ObjectType.otMethod:
                EA.Method attribute = Repository.GetMethodByGuid(GUID);
                change.elementType = ElementType.METHOD;
                change.name        = attribute.Name;
                break;
            }

            sendObject(change);
        }
        void EASelectObjectToolStripMenuItemClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            if (repo != null)
            {
                // 選択された属性に対する更新処理
                if (selectedAttribute != null)
                {
                    EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);
                    if (attr != null)
                    {
                        repo.ShowInProjectView(attr);
                    }
                    else
                    {
                        // 属性がGUIDで空振りしたら要素GUIDで再検索
                        EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                        if (elem != null)
                        {
                            repo.ShowInProjectView(elem);
                        }
                    }
                }

                // 選択された操作に対する更新処理
                if (selectedMethod != null)
                {
                    EA.Method mth = (EA.Method)repo.GetMethodByGuid(selectedMethod.guid);
                    if (mth != null)
                    {
                        repo.ShowInProjectView(mth);
                    }
                    else
                    {
                        // 操作がGUIDで空振りしたら要素GUIDで再検索
                        EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                        if (elem != null)
                        {
                            repo.ShowInProjectView(elem);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("EAにアタッチしていないため、選択できません");
            }
        }
Exemple #8
0
 /// <summary>
 /// 属性をEAに向けて更新実行する
 /// </summary>
 /// <param name="repo"></param>
 /// <param name="selectedAttribute"></param>
 void execUpdateAttribute(EA.Repository repo, AttributeVO selectedAttribute)
 {
     EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);
     if (attr == null)
     {
         EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
         if (elem == null)
         {
             return;
         }
         attr = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, "String");
     }
     attr.AttributeGUID = selectedAttribute.guid;
     attr.Alias         = selectedAttribute.alias;
     attr.StereotypeEx  = selectedAttribute.stereoType;
     attr.Notes         = selectedAttribute.notes;
     attr.Update();
 }
Exemple #9
0
        /// <summary>
        /// コンテキストメニュー:EAで選択のクリックイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void EASelectObjectToolStripMenuItemClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            if (repo != null)
            {
                // メニューを開くために右クリックされたコントロールを取得
                Control source = contextMenuStrip1.SourceControl;
                if (source != null)
                {
                    if (source.Tag is AttributeVO)
                    {
                        AttributeVO att = (AttributeVO)source.Tag;

                        // EAでGUIDをキーとして対象属性の取得を試み、取れたらプロジェクトブラウザーで選択する
                        EA.Attribute attrObj = (EA.Attribute)repo.GetAttributeByGuid(att.guid);
                        if (attrObj != null)
                        {
                            repo.ShowInProjectView(attrObj);
                        }
                    }
                    else if (source.Tag is MethodVO)
                    {
                        MethodVO mth = (MethodVO)source.Tag;

                        // EAでGUIDをキーとして対象操作の取得を試み、取れたらプロジェクトブラウザーで選択する
                        EA.Method mthObj = (EA.Method)repo.GetMethodByGuid(mth.guid);
                        if (mthObj != null)
                        {
                            repo.ShowInProjectView(mthObj);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("EAにアタッチしていないため、選択できません");
            }
        }
 public FindAndReplaceItemAttribute(EA.Repository rep, string guid)  : base(rep, guid)
 {
     _attr = rep.GetAttributeByGuid(guid);
     Load(rep);
 }
Exemple #11
0
        /// <summary>
        /// Extension Method EA.Repository to get:
        /// - EA Object
        /// - EA.ObjectType
        /// from Object Type in Table and GUID
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="sqlObjectType"></param>
        /// <param name="guid"></param>
        /// <param name="objectType"></param>
        /// <returns></returns>
        public static object GetEaObject(this EA.Repository rep, string sqlObjectType, string guid, out EA.ObjectType objectType)
        {
            objectType = EA.ObjectType.otNone;

            // eaObjectType found in dictionary
            if (EaObjectTypes.TryGetValue(sqlObjectType, out EA.ObjectType eaObjectType))
            {
                switch (eaObjectType)
                {
                case EA.ObjectType.otElement:
                    objectType = eaObjectType;
                    return(rep.GetElementByGuid(guid));

                case EA.ObjectType.otDiagram:
                    objectType = eaObjectType;
                    return((object)rep.GetDiagramByGuid(guid));

                case EA.ObjectType.otPackage:
                    objectType = eaObjectType;
                    return(rep.GetPackageByGuid(guid));

                case EA.ObjectType.otAttribute:
                    objectType = eaObjectType;
                    return(rep.GetAttributeByGuid(guid));

                case EA.ObjectType.otMethod:
                    objectType = eaObjectType;
                    return(rep.GetMethodByGuid(guid));

                case EA.ObjectType.otConnector:
                    objectType = eaObjectType;
                    return(rep.GetConnectorByGuid(guid));

                default:
                    break;
                }
            }
            else
            {
                // by SQL
                string where = $"where ea_guid = '{ guid}'";
                string sql = $"select 'OBJECT'  as object_type from t_object  {where}      UNION " +
                             $"select 'DIAGRAM'                from t_diagram {where}            ";
                XElement x     = XElement.Parse(rep.SQLQuery(sql));
                var      oType = (from t in x.Descendants("object_type")
                                  select t).FirstOrDefault();
                if (oType == null)
                {
                    MessageBox.Show($"GUID:'{guid}'", @"GUID not found, Break!!!!");
                    return(null);
                }
                string type = oType.Value;
                switch (type)
                {
                case "OBJECT":
                    objectType = EA.ObjectType.otElement;
                    return(rep.GetElementByGuid(guid));

                case "DIAGRAM":
                    objectType = EA.ObjectType.otDiagram;
                    return(rep.GetDiagramByGuid(guid));

                default:
                    MessageBox.Show($"GUID searched in object, diagram:'{guid}'", @"GUID not found in Repository, Break!!!!");
                    return(null);
                }
            }
            return(null);
        }
Exemple #12
0
 public FindAndReplaceItemAttribute(EA.Repository rep, string GUID)  : base(rep, GUID)
 {
     this._attr = rep.GetAttributeByGuid(GUID);
     this.load(rep);
 }