コード例 #1
0
        /// <summary>
        /// method adds a new connector between source and target element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="srcGUID">GUID of source element</param>
        /// <param name="targetGUID">GUID of target element</param>
        /// <param name="name">name of new connector</param>
        /// <param name="elementType">type of new connector</param>
        /// <returns>GUID of new connector</returns>
        public string addConnector(EA.Repository Repository, string srcGUID, string targetGUID, string name, int elementType)
        {
            EA.Element source = (EA.Element)Repository.GetElementByGuid(srcGUID);
            EA.Element target = (EA.Element)Repository.GetElementByGuid(targetGUID);

            EA.Connector newConnector = (EA.Connector)source.Connectors.AddNew(name, getConnectorType(elementType));

            if (elementType == 73)
            {
                newConnector.Subtype = "Includes";
                newConnector.Stereotype = "include";
            }
            else if (elementType == 74)
            {
                newConnector.Subtype = "Extends";
                newConnector.Stereotype = "extend";
            }

            newConnector.SupplierID = target.ElementID;
            newConnector.Update();
            source.Connectors.Refresh();

            BPAddIn.synchronizationWindow.addToList("Addition of " + itemTypes.getElementTypeInEnglish(elementType) + " '" + name +
                   "' between element '" + source.Name + "' and element '" + target.Name + "'");

            return newConnector.ConnectorGUID;
        }
コード例 #2
0
 /// <summary>
 /// Get element from Context element. Possible inputs are: Attribute, Operation, Element, Package
 /// </summary>
 /// <param name="rep"></param>
 /// <returns></returns>
 public static EA.Element GetElementFromContextObject(EA.Repository rep)  {
     EA.Element el = null;
     EA.ObjectType objectType = rep.GetContextItemType();
     switch (objectType)
     {
         case ObjectType.otAttribute:
             var a = (EA.Attribute)rep.GetContextObject();
             el = rep.GetElementByID(a.ParentID);
             break;
         case ObjectType.otMethod:
             var m = (Method)rep.GetContextObject();
             el = rep.GetElementByID(m.ParentID);
             break;
         case ObjectType.otElement:
             el = (EA.Element)rep.GetContextObject();
             break;
         case ObjectType.otPackage:
             EA.Package pkg  = rep.GetContextObject();
             el = rep.GetElementByGuid(pkg.PackageGUID);
             break;
         case ObjectType.otNone:
             EA.Diagram dia = rep.GetCurrentDiagram();
             if (dia?.SelectedObjects.Count == 1)
             {
                 var objSelected = (EA.DiagramObject)dia.SelectedObjects.GetAt(0);
                 el = rep.GetElementByID(objSelected.ElementID);
             }
             break;
         default:
             MessageBox.Show(@"No Element, Attribute, Operation, Package selected");
             break;
      }
     return el;
 }
コード例 #3
0
        /// <summary>
        /// method moves diagram into target element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="diagramGUID">GUID of diagram that should be moved</param>
        /// <param name="elementGUID">GUID of target element</param>
        public void moveDiagramToElement(EA.Repository Repository, string diagramGUID, string elementGUID)
        {
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);
            EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID);
            diagram.ParentID = element.ElementID;
            diagram.Update();
            element.Diagrams.Refresh();

            BPAddIn.synchronizationWindow.addToList("Movement of diagram '" + diagram.Name + "' to element '" +
                    element.Name + "'");
        }
コード例 #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();
 }
コード例 #5
0
 public static EA.Element GetBehaviorForOperation(EA.Repository repository, EA.Method method)
 {
     EA.Element returnValue = null;
     string behavior = method.Behavior;
     if (behavior.StartsWith("{", StringComparison.Ordinal) & behavior.EndsWith("}", StringComparison.Ordinal))
     {
         // get object according to behavior
         EA.Element el = repository.GetElementByGuid(behavior);
         returnValue = el;
     }
     return returnValue;
 }
コード例 #6
0
        /// <summary>
        /// method adds constraint to element
        /// </summary>
        /// <param name="repository">EA repository</param>
        /// <param name="elementGUID">GUID of changed element</param>
        /// <param name="name">name of new constraint</param>
        /// <param name="type">type of new constraint</param>
        /// <param name="elementType">type of changed element</param>
        public void addConstraint(EA.Repository repository, string elementGUID, string name, string type, int elementType)
        {
            int index = name.IndexOf("notes:=") + 7;

            EA.Element element = (EA.Element)repository.GetElementByGuid(elementGUID);
            EA.Constraint constraint = (EA.Constraint)element.Constraints.AddNew(name.Substring(0, index-8), type);
            constraint.Notes = name.Substring(index, name.Length - index);
            constraint.Update();
            element.Constraints.Refresh();

            BPAddIn.synchronizationWindow.addToList("Addition of constraint '" + name.Substring(0, index - 8) + "' of type '" + type + "' to "
               + itemTypes.getElementTypeInEnglish(elementType) + " '" + element.Name + "' (Location of element: " + itemTypes.getLocationOfItem(repository, element.PackageID, element.ParentID));
        }
        public override void load(EA.Repository rep)
        {

            _Name = _pkg.Name;
            _Description = _pkg.Notes;
            _Stereotype = _pkg.StereotypeEx;


            // Model don't have an element
            if (_pkg.ParentID != 0)
            {
                EA.Element elPkg = rep.GetElementByGuid(GUID);
                _Stereotype = elPkg.StereotypeEx;
            }
        }
コード例 #8
0
        /// <summary>
        /// method adds a new attribute into element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="elementGUID">GUID of element</param>
        /// <param name="name">name of new attribute</param>
        /// <param name="scope">scope of new attribute</param>
        /// <returns>GUID of new attribute</returns>
        public string addAttribute(EA.Repository Repository, string elementGUID, string name, string scope)
        {
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);

            EA.Attribute attribute = (EA.Attribute)element.Attributes.AddNew(name, "");
            attribute.Visibility = scope;
            attribute.Update();

            element.Attributes.Refresh();

            BPAddIn.synchronizationWindow.addToList("Addition of attribute '" + name + "' with scope '" + scope
                + "' to element '" + element.Name + "' (Location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));

            return attribute.AttributeGUID;
        }
コード例 #9
0
 public static void DisplayBehaviorForOperation(EA.Repository repository, EA.Method method)
 {
     string behavior = method.Behavior;
     if (behavior.StartsWith("{", StringComparison.Ordinal) & behavior.EndsWith("}", StringComparison.Ordinal))
     {
         // get object according to behavior
         EA.Element el = repository.GetElementByGuid(behavior);
         // Activity
         if (el == null) { }
         else
         {
             if (el.Type.Equals("Activity") || el.Type.Equals("Interaction") || el.Type.Equals("StateMachine"))
             {
                 Util.OpenBehaviorForElement(repository, el);
             }
         }
     }
 }
 public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
 {
     _pkg = rep.GetPackageByGuid(GUID);
     if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
     { _pkg.Notes = _Description; }
     if ((fieldType & (FindAndReplaceItem.FieldType.Name | FindAndReplaceItem.FieldType.Stereotype) ) > 0)
     {
         // model don't have an element
         if (_pkg.ParentID != 0)
         {
             EA.Element el = rep.GetElementByGuid(GUID);
             el.StereotypeEx = _Stereotype;
             el.Name = _Name;
             el.Update();
         }
         _pkg.Name = _Name;
     }
     _isUpdated = true;
     _pkg.Update();
 }
        public static void doRecursivePkg(EA.Repository rep, EA.Package pkg, FindAndReplace fr)
        {
            // perform package
            if (fr.isPackageSearch)
            {
                fr.FindStringInItem(EA.ObjectType.otPackage, pkg.PackageGUID);
                if (fr.isTagSearch)
                {
                    // tagged values are beneath element with the same Id
                    EA.Element el = rep.GetElementByGuid(pkg.PackageGUID);
                    if (el != null)   FindMatchingPackageTaggedValue(rep, pkg, fr);
                }

            }

            // perform diagrams of package
            if (fr.isDiagramSearch)
            {
                foreach (EA.Diagram dia in pkg.Diagrams)
                {
                    if (dia != null) fr.FindStringInItem(EA.ObjectType.otDiagram, dia.DiagramGUID);
                }
            }
            // run elements of package
            foreach (EA.Element el in pkg.Elements)
            {
                doRecursiveEl(rep, el, fr);
            }
            
            // run packages of package
            foreach (EA.Package pkgTrgt in pkg.Packages)
            {
                doRecursivePkg(rep, pkgTrgt, fr);
            }
            return;
        }
コード例 #12
0
        public void handleContextItemChange(EA.Repository repository, string GUID, ObjectType ot)
        {
            try
            {
                switch (ot)
                {
                    case ObjectType.otElement:
                        this.currentItem = repository.GetElementByGuid(GUID);

                        if (currentItem.Type == "Class")
                        {
                            currentAttributes = new Dictionary<string, EA.Attribute>();
                            foreach (EA.Attribute attr in currentItem.Attributes)
                            {
                                currentAttributes.Add(attr.AttributeGUID, attr);
                            }
                        }

                        if (currentItem.Type == "UseCase")
                        {
                            // CONSTRAINTS
                            currentConstraintsList = new List<ConstraintWrapper>();
                            foreach (EA.Constraint constraint in currentItem.Constraints)
                            {
                                currentConstraintsList.Add(new ConstraintWrapper(constraint));
                            }

                            // SCENARIOS
                            currentScenarioList = new List<ScenarioWrapper>();
                            currentScenarioStepList = new Dictionary<string, List<EA.ScenarioStep>>();
                            foreach (EA.Scenario scenario in currentItem.Scenarios)
                            {
                                currentScenarioList.Add(new ScenarioWrapper(scenario));
                                if (!currentScenarioStepList.ContainsKey(scenario.ScenarioGUID))
                                {
                                    currentScenarioStepList.Add(scenario.ScenarioGUID, new List<ScenarioStep>());
                                }

                                foreach (ScenarioStep step in scenario.Steps)
                                {
                                    currentScenarioStepList[scenario.ScenarioGUID].Add(step);
                                }
                            }
                        }

                        this.currentConnector = null;
                        this.currentDiagram = null;
                        changed = false;
                        currentAuthor = repository.GetElementByGuid(GUID).Author;
                        break;
                    case ObjectType.otPackage:
                        this.currentItem = repository.GetElementByGuid(GUID);
                        this.currentConnector = null;
                        this.currentDiagram = null;
                        changed = false;
                        currentAuthor = repository.GetElementByGuid(GUID).Author;
                        break;
                    case ObjectType.otConnector:
                        this.currentConnector = repository.GetConnectorByGuid(GUID);
                        this.currentItem = null;
                        this.currentDiagram = null;
                        changed = false;
                        break;
                    case ObjectType.otDiagram:
                        this.currentDiagram = (EA.Diagram)repository.GetDiagramByGuid(GUID);
                        this.currentConnector = null;
                        this.currentItem = null;
                        changed = false;
                        currentAuthor = ((EA.Diagram)repository.GetDiagramByGuid(GUID)).Author;
                        currentParent = currentDiagram.ParentID.ToString();

                        currentExtensionPoints = new Dictionary<string, string>();
                        currentDiagramObjectPositions = new Dictionary<int, string>();
                        foreach (EA.DiagramObject diagramObject in currentDiagram.DiagramObjects)
                        {
                            try
                            {
                                EA.Collection col = repository.GetElementSet("" + diagramObject.ElementID, 1);
                                EA.Element element = (EA.Element)col.GetAt(0);

                                if (element.Type == "UseCase")
                                {
                                    currentExtensionPoints.Add(element.ElementGUID, element.ExtensionPoints);
                                }
                            }
                            catch (Exception ex)
                            {
                            }

                            string coordinates = "";
                            coordinates += "l=" + diagramObject.left + ";";
                            coordinates += "r=" + diagramObject.right + ";";
                            coordinates += "t=" + diagramObject.top + ";";
                            coordinates += "b=" + diagramObject.bottom + ";";
                            currentDiagramObjectPositions.Add(diagramObject.ElementID, coordinates);

                        }
                        break;
                    default:
                        return;
                }
            }
            catch (NullReferenceException nEx) { }
            catch (Exception ex) { }
        }
コード例 #13
0
//        // read PDATA1
//        public static EA.Element getPDATA(EA.Repository rep, int ID)
//        {
//            EA.Element el = null;
//            string query = "";
//            query =
//                    @"select pdata1 AS PDATA1
//                      from t_object o 
//                      where Cast(op.Behaviour As Varchar2(38)) = '" + el.ElementGUID + "'";

//            if (rep.ConnectionString.Contains("DBType=3"))
//            {   // Oracle DB
//                query =
//                    @"select op.ea_guid AS EA_GUID
//                      from t_operation op 
//                      where Cast(op.Behaviour As Varchar2(38)) = '" + el.ElementGUID + "'";
//            }
//            if (rep.ConnectionString.Contains("DBType=1"))
//            // SQL Server
//            {
//                query =
//                     @"select op.ea_guid AS EA_GUID
//                        from t_operation op 
//                        where Substring(op.Behaviour,1,38) = '" + el.ElementGUID + "'";

//            }

//            if (rep.ConnectionString.Contains(".eap"))
//            // SQL Server
//            {
//                query =
//                    @"select op.ea_guid AS EA_GUID
//                        from t_operation op 
//                        where op.Behaviour = '" + el.ElementGUID + "'";

//            }
//            if ((!rep.ConnectionString.Contains("DBType=1")) &&  // SQL Server, DBType=0 MySQL
//               (!rep.ConnectionString.Contains("DBType=3")) &&  // Oracle
//               (!rep.ConnectionString.Contains(".eap")))// Access
//            {
//                query =
//                  @"select op.ea_guid AS EA_GUID
//                        from t_operation op 
//                        where op.Behaviour = '" + el.ElementGUID + "'";

//            }

//            string str = rep.SQLQuery(query);
//            XmlDocument XmlDoc = new XmlDocument();
//            XmlDoc.LoadXml(str);

//            XmlNode operationGUIDNode = XmlDoc.SelectSingleNode("//EA_GUID");
//            if (operationGUIDNode != null)
//            {
//                string GUID = operationGUIDNode.InnerText;
//                method = rep.GetMethodByGuid(GUID);
//            }
//            return method;
//        }



        public static Method GetOperationFromConnector(EA.Repository rep, EA.Connector con)
        {
            Method method = null;
            string query = "";
            if (GetConnectionString(rep).Contains("DBType=3"))
                //pdat3: 'Activity','Sequence', (..)
            {   // Oracle DB
                query =
                    @"select description AS EA_GUID
                      from t_xref x 
                      where Cast(x.client As Varchar2(38)) = '" + con.ConnectorGUID + "'" +
                                                                " AND Behavior = 'effect' ";
            }
            if (GetConnectionString(rep).Contains("DBType=1"))
            {   // SQL Server

                query =
                      @"select description AS EA_GUID
                        from t_xref x 
                        where Substring(x.client,1,38) = " + "'" + con.ConnectorGUID + "'" +
                           " AND Behavior = 'effect' "                   
                                          ;
            }
            if (GetConnectionString(rep).Contains(".eap"))
            {

                query =
                      @"select description AS EA_GUID
                        from t_xref x 
                        where client = " + "'" + con.ConnectorGUID + "'" +
                           " AND Behavior = 'effect' "
                                          ;
            }
            if ((! GetConnectionString(rep).Contains("DBType=1")) &&  // SQL Server, DBType=0 MySQL
                (! GetConnectionString(rep).Contains("DBType=3")) &&  // Oracle
                (! GetConnectionString(rep).Contains(".eap")))// Access
            {
                query =
                @"select description AS EA_GUID
                        from t_xref x 
                        where client = " + "'" + con.ConnectorGUID + "'" +
                             " AND Behavior = 'effect' "
                                            ;

            }


            string str = rep.SQLQuery(query);
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(str);

            //string type = "";
            //XmlNode pdat3Node = XmlDoc.SelectSingleNode("//PDAT3");
            //if (pdat3Node != null)
            //{
            //    type = pdat3Node.InnerText;
                
            //}
            //if ( type.EndsWith(")")) // Operation
            //{ 
            string guid = null;
                XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//EA_GUID");
                if (operationGuidNode != null)
                {
                    guid = operationGuidNode.InnerText;
                    method = rep.GetMethodByGuid(guid);
                }
                if (method == null)
                {

                     if (guid != null) OpenBehaviorForElement(rep, rep.GetElementByGuid(guid));
                }
            //}

            return method;
        }
        /// <summary>
        /// Find matching tagged values for element 
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="el"></param>
        /// <param name="fr"></param>
        private static void FindMatchingPackageTaggedValue(EA.Repository rep, EA.Package pkg, FindAndReplace fr)
        {
            EA.Element el = rep.GetElementByGuid(pkg.PackageGUID);
            foreach (EA.TaggedValue tag in el.TaggedValues)
            {
                if ((fr.tagValueNames.Length == 0) || (fr.tagValueNames.Contains(tag.Name)))
                {
                    int count = FindAndReplaceItem.findCountForType(fr.regexPattern, tag.Value);
                    if (count > 0)
                    {
                        FindAndReplaceItem frItem = fr.lastItem();
                        if ((frItem == null) || (frItem.GUID != el.ElementGUID))
                        {
                            frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otPackage, el.ElementGUID);
                            fr.l_items.Add(frItem);


                        }
                        var frItemPkg = (FindAndReplaceItemPackage)frItem;
                        frItemPkg.l_itemTag.Add(new FindAndReplaceItemTagPackage(tag));
                        frItemPkg.CountChanges = frItemPkg.CountChanges + count;


                    }
                }

            }
        }
コード例 #15
0
        //------------------------------------------------------------------------------------------------------------------------------------
        // Find the Parameter of a Activity
        //------------------------------------------------------------------------------------------------------------------------------------
        // par Parameter of Operation (only if isReturn = false)
        // act Activity
        // Parameter wird aufgrund des Alias-Namens gefunden
        //
        // 
        public static EA.Element  GetParameterFromActivity(EA.Repository rep, EA.Parameter par, EA.Element act, bool isReturn = false)
        {

            string aliasName;
            if (isReturn)
            {
                aliasName = "return:";
            }
            else
            {
                aliasName = "par_" + par.Position;
            }

            EA.Element parTrgt = null;
            string query = @"select o2.ea_guid AS CLASSIFIER_GUID
                      from t_object o1 INNER JOIN t_object o2 on ( o2.parentID = o1.object_id)
                      where o1.Object_ID = " + act.ElementID + 
                             " AND  o2.Alias like '"+ aliasName + GetWildCard(rep) + "'";
            string str = rep.SQLQuery(query); 
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(str);

            XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//CLASSIFIER_GUID");
            if (operationGuidNode != null)
            {
                string guid = operationGuidNode.InnerText;
                parTrgt = rep.GetElementByGuid(guid);
            }
            return parTrgt;
        }
コード例 #16
0
        /// <summary>
        /// method adds a new diagram into parent element or package
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="parentGUID">GUID of parent element</param>
        /// <param name="packageGUID">GUID of parent package</param>
        /// <param name="elementType">type of new diagram</param>
        /// <param name="name">name of new diagram</param>
        /// <param name="author">author of new diagram</param>
        /// <returns>GUID of new diagram</returns>
        public string addDiagram(EA.Repository Repository, string parentGUID, string packageGUID, int elementType, string name, string author)
        {
            if (getDiagramType(elementType) == "")
            {
                return "";
            }

            EA.Collection diagrams;
            if (parentGUID == "0")
            {
                diagrams = (EA.Collection)Repository.GetPackageByGuid(packageGUID).Diagrams;
            }
            else
            {
                diagrams = (EA.Collection)Repository.GetElementByGuid(parentGUID).Diagrams;
            }

            EA.Diagram newDiagram = (EA.Diagram)diagrams.AddNew(name, getDiagramType(elementType));
            newDiagram.Author = author;
            newDiagram.Update();
            diagrams.Refresh();

            EA.Package parentPackage = (EA.Package)Repository.GetPackageByGuid(packageGUID);
            if (parentGUID == "0")
            {
                BPAddIn.synchronizationWindow.addToList("Addition of " + itemTypes.getElementTypeInEnglish(elementType) + " '" + name +
                    "' to package '" + parentPackage.Name + "' - author: '" + author + "'");
            }
            else
            {
                EA.Element parentElement = (EA.Element)Repository.GetElementByGuid(parentGUID);
                BPAddIn.synchronizationWindow.addToList("Addition of " + itemTypes.getElementTypeInEnglish(elementType) + " '" + name +
                    "' to element '" + parentElement.Name + "' in package '" + parentPackage.Name + "' - author: '" + author + "'");
            }

            return newDiagram.DiagramGUID;
        }
コード例 #17
0
        /// <summary>
        /// method adds a new scenario into element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="elementGUID">GUID of element</param>
        /// <param name="name">name of new scenario</param>
        /// <param name="type">type of new scenario</param>
        /// <param name="XMLContent">all information about scenario</param>
        /// <param name="elementType">type of element</param>
        /// <returns>GUID of new scenario</returns>
        public string addScenario(EA.Repository Repository, string elementGUID, string name, string type, string XMLContent, int elementType)
        {
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);

            EA.Scenario scenario = (EA.Scenario)element.Scenarios.AddNew(name, type);
            scenario.XMLContent = XMLContent;
            scenario.Update();
            element.Scenarios.Refresh();

            BPAddIn.synchronizationWindow.addToList("Addition of scenario '" + name + "' of type '" + type + "' to "
                + itemTypes.getElementTypeInEnglish(elementType) + " '" + element.Name + "' (Location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));

            return scenario.ScenarioGUID;
        }
コード例 #18
0
        public static EA.Element GetElementFromName(EA.Repository rep, string elementName, string elementType)
        {
            EA.Element el = null;
            string query = @"select o.ea_guid AS EA_GUID
                      from t_object o 
                      where o.name = '" + elementName + "' AND " +
                            "o.Object_Type = '" + elementType + "' ";
            string str = rep.SQLQuery(query);
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(str);

            XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//EA_GUID");
            if (operationGuidNode != null)
            {
                string guid = operationGuidNode.InnerText;
                el = rep.GetElementByGuid(guid);
            }

            return el;
        }
 public  FindAndReplaceItemElement(EA.Repository rep, string GUID)  :base(rep, GUID)
 {
     this._el = rep.GetElementByGuid(GUID);
     this.load(rep);
 }
コード例 #20
0
        /// <summary>
        /// method moves element or package into target package
        /// </summary>
        /// <param name="repository">EA repository</param>
        /// <param name="itemGUID">GUID of item that should be moved</param>
        /// <param name="targetPackageGUID">GUID of target package</param>
        /// <param name="elementType">type of element</param>
        public void moveElementOrPackageToPackage(EA.Repository repository, string itemGUID, string targetPackageGUID, int elementType)
        {
            EA.Package targetPackage = (EA.Package)repository.GetPackageByGuid(targetPackageGUID);

            if (elementType == 3)
            {
                EA.Package package = (EA.Package)repository.GetPackageByGuid(itemGUID);

                if (package.ParentID != targetPackage.PackageID)
                {
                    package.ParentID = targetPackage.PackageID;
                    package.Update();
                    targetPackage.Packages.Refresh();
                    BPAddIn.synchronizationWindow.addToList("Movement of package '" + package.Name + "' to package '" +
                    targetPackage.Name + "'");
                }
            }
            else
            {
                EA.Element element = (EA.Element)repository.GetElementByGuid(itemGUID);

                if (element.ParentID != targetPackage.PackageID)
                {
                    element.PackageID = targetPackage.PackageID;
                    element.Update();
                    targetPackage.Elements.Refresh();

                    BPAddIn.synchronizationWindow.addToList("Movement of element '" + element.Name + "' to package '" +
                    targetPackage.Name + "'");
                }
            }
        }
コード例 #21
0
        /// <summary>
        /// method deletes constraint from element
        /// </summary>
        /// <param name="repository">EA repository</param>
        /// <param name="elementGUID">GUID of element owning constraint that should be deleted</param>
        /// <param name="name">name of constraint that should be deleted</param>
        /// <param name="type">type of constraint that should be deleted</param>
        public void deleteConstraint(EA.Repository repository, string elementGUID, string name, string type)
        {
            EA.Element element = (EA.Element)repository.GetElementByGuid(elementGUID);

            for (short i = 0; i < element.Constraints.Count; i++)
            {
                EA.Constraint actualConstraint = (EA.Constraint)element.Constraints.GetAt(i);
                if (actualConstraint.Name == name && actualConstraint.Type == type)
                {
                    element.Constraints.DeleteAt(i, false);
                    break;
                }
            }
            element.Constraints.Refresh();

            BPAddIn.synchronizationWindow.addToList("Deletion of constraint '" + name + "' from element '" + element.Name
                + "' (Location of element: " + itemTypes.getLocationOfItem(repository, element.PackageID, element.ParentID));
        }
コード例 #22
0
        /// <summary>
        /// method deletes scenario from element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="scenarioGUID">GUID of scenario that should be deleted</param>
        /// <param name="elementGUID">GUID of element owning scenario that should be deleted</param>
        /// <param name="elementType">type of element owning scenario that should be deleted</param>
        public void deleteScenario(EA.Repository Repository, string scenarioGUID, string elementGUID, int elementType)
        {
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);
            string name = "", type = "";
            for (short i = 0; i < element.Scenarios.Count; i++)
            {
                EA.Scenario currentScenario = (EA.Scenario)element.Scenarios.GetAt(i);
                if (currentScenario.ScenarioGUID == scenarioGUID)
                {
                    name = currentScenario.Name;
                    type = currentScenario.Type;
                    element.Scenarios.DeleteAt(i, false);
                    break;
                }
            }
            element.Scenarios.Refresh();

            BPAddIn.synchronizationWindow.addToList("Deletion of scenario '" + name + "' of type '" + type +
                "' from " + itemTypes.getElementTypeInEnglish(elementType) + " '" + element.Name
                + "' (Location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));
        }
コード例 #23
0
        /// <summary>
        /// method deletes element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="elementGUID">GUID of element that should be deleted</param>
        /// <param name="elementType">type of element that should be deleted</param>
        public void deleteElement(EA.Repository Repository, string elementGUID, int elementType)
        {
            EA.Element elementToDelete = (EA.Element)Repository.GetElementByGuid(elementGUID);
            string name = elementToDelete.Name;
            int packageID = elementToDelete.PackageID;
            int parentID = elementToDelete.ParentID;

            EA.Collection elements;
            if (elementToDelete.ParentID == 0)
            {
                elements = (EA.Collection)Repository.GetPackageByID(elementToDelete.PackageID).Elements;
            }
            else
            {
                elements = (EA.Collection)Repository.GetElementByID(elementToDelete.ParentID).Elements;
            }

            for (short i = 0; i < elements.Count; i++)
            {
                EA.Element actualElement = (EA.Element)elements.GetAt(i);
                if (actualElement.ElementGUID == elementGUID)
                {
                    elements.DeleteAt(i, false);
                    break;
                }
            }
            elements.Refresh();

            BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '"
                + name + "' (Previous location of element: " +
                itemTypes.getLocationOfItem(Repository, packageID, parentID));
        }
コード例 #24
0
        /// <summary>
        /// method deletes diagram object from diagram
        /// </summary>
        /// <param name="Repository"></param>
        /// <param name="elementGUID">GUID of element which diagram object that should be deleted belongs to</param>
        /// <param name="diagramGUID">GUID of diagram owning diagram object that should be deleted</param>
        public void deleteDiagramObject(EA.Repository Repository, string elementGUID, string diagramGUID)
        {
            EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID);
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                EA.DiagramObject diagramObject = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i);
                if (diagramObject.ElementID == element.ElementID)
                {
                    diagram.DiagramObjects.DeleteAt(i, false);
                    break;
                }
            }
            diagram.DiagramObjects.Refresh();

            BPAddIn.synchronizationWindow.addToList("Deletion of element '" + element.Name + "' from diagram '" + diagram.Name +
                "' (Location of diagram: " + itemTypes.getLocationOfItem(Repository, diagram.PackageID, diagram.ParentID));
        }
コード例 #25
0
        public void broadcastEvent(Wrapper.Model model, EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            ping(GUID, Repository);

            if (ot == EA.ObjectType.otElement)
            {
                object element = Repository.GetElementByGuid(GUID);
                foreach (Rule registeredRule in eventWatchers[((EA.Element)element).Type])
                {
                    string rslt = registeredRule.activate(element, model);
                    if (rslt != "")
                    {
                        if (!active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = createRuleEntry(model, rslt, element, registeredRule);

                            if (active.ContainsKey(GUID))
                            {
                                active[GUID].Add(ruleEntry);
                            }
                            else
                            {
                                List<RuleEntry> ruleEntryList = new List<RuleEntry>();
                                ruleEntryList.Add(ruleEntry);
                                active.Add(GUID, ruleEntryList);
                            }

                            showErrorWindow(Repository);
                            addToDefectsList(rslt, ruleEntry);
                        }
                        else
                        {
                            foreach (RuleEntry ruleEntry in active[GUID])
                            {
                                if (ruleEntry.rule == registeredRule)
                                {
                                    addToDefectsList(rslt, ruleEntry);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = active[GUID].Find(x => x.rule == registeredRule);

                            if (ruleEntry != null)
                            {
                                BPAddIn.BPAddIn.defectsWindow.removeFromList(ruleEntry.listBoxObject);
                                BPAddIn.BPAddIn.defectsWindow.removeFromHiddenList(ruleEntry.listBoxObject);
                                active.Remove(GUID);
                            }
                        }
                    }
                }
            }
            else if (ot == EA.ObjectType.otConnector)
            {
                object connector = Repository.GetConnectorByGuid(GUID);
                foreach (Rule registeredRule in eventWatchers[((EA.Connector)connector).Type])
                {
                    string rslt = registeredRule.activate(connector, model);
                    if (rslt != "")
                    {
                        if (!active.ContainsKey(GUID) || active[GUID].Find(x => x.rule == registeredRule) == null)
                        {
                            RuleEntry ruleEntry = createRuleEntry(model, rslt, connector, registeredRule);

                            if (active.ContainsKey(GUID))
                            {
                                active[GUID].Add(ruleEntry);
                            }
                            else
                            {
                                List<RuleEntry> ruleEntryList = new List<RuleEntry>();
                                ruleEntryList.Add(ruleEntry);
                                active.Add(GUID, ruleEntryList);
                            }

                            showErrorWindow(Repository);
                            addToDefectsList(rslt, ruleEntry);
                        }
                        else
                        {
                            foreach (RuleEntry ruleEntry in active[GUID])
                            {
                                if (ruleEntry.rule == registeredRule)
                                {
                                    addToDefectsList(rslt, ruleEntry);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = active[GUID].Find(x => x.rule == registeredRule);

                            if (ruleEntry != null)
                            {
                                BPAddIn.BPAddIn.defectsWindow.removeFromList(ruleEntry.listBoxObject);
                                BPAddIn.BPAddIn.defectsWindow.removeFromHiddenList(ruleEntry.listBoxObject);
                                active.Remove(GUID);
                            }
                        }
                    }
                }
            }
            else if (ot == EA.ObjectType.otDiagram)
            {
                object diagram = Repository.GetDiagramByGuid(GUID);
                foreach (Rule registeredRule in eventWatchers[((EA.Diagram)diagram).Type])
                {
                    string rslt = registeredRule.activate(diagram, model);
                    if (rslt != "")
                    {
                        if (!active.ContainsKey(GUID) || active[GUID].Find(x => x.rule == registeredRule) == null)
                        {
                            RuleEntry ruleEntry = createRuleEntry(model, rslt, diagram, registeredRule);

                            if (active.ContainsKey(GUID))
                            {
                                active[GUID].Add(ruleEntry);
                            }
                            else
                            {
                                List<RuleEntry> ruleEntryList = new List<RuleEntry>();
                                ruleEntryList.Add(ruleEntry);
                                active.Add(GUID, ruleEntryList);
                            }

                            showErrorWindow(Repository);
                            addToDefectsList(rslt, ruleEntry);
                        }
                        else
                        {
                            foreach (RuleEntry ruleEntry in active[GUID])
                            {
                                if (ruleEntry.rule == registeredRule)
                                {
                                    addToDefectsList(rslt, ruleEntry);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = active[GUID].Find(x => x.rule == registeredRule);

                            if (ruleEntry != null)
                            {
                                BPAddIn.BPAddIn.defectsWindow.removeFromList(ruleEntry.listBoxObject);
                                BPAddIn.BPAddIn.defectsWindow.removeFromHiddenList(ruleEntry.listBoxObject);
                                active.Remove(GUID);
                            }
                        }
                    }
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// method sets extension points of element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="elementGUID">GUID of changed element</param>
        /// <param name="extensionPoints">new extension points</param>
        /// <param name="elementType">type of changed element</param>
        public void setExtensionPoints(EA.Repository Repository, string elementGUID, string extensionPoints, int elementType)
        {
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);
            element.ExtensionPoints = extensionPoints;
            element.Update();

            BPAddIn.synchronizationWindow.addToList("Change of extension points of " + itemTypes.getElementTypeInEnglish(elementType)
                + " '" + element.Name + "' (Location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));
        }
コード例 #27
0
        /// <summary>
        /// method moves element into target element
        /// </summary>
        /// <param name="repository">EA repository</param>
        /// <param name="itemGUID">GUID of item that should be moved</param>
        /// <param name="targetElementGUID">GUID of target element</param>
        public void moveElementToElement(EA.Repository repository, string itemGUID, string targetElementGUID)
        {
            EA.Element targetElement = (EA.Element)repository.GetElementByGuid(targetElementGUID);
            EA.Element element = (EA.Element)repository.GetElementByGuid(itemGUID);

            if (element.ParentID != targetElement.ElementID)
            {
                element.ParentID = targetElement.ElementID;
                element.Update();
                targetElement.Elements.Refresh();

                BPAddIn.synchronizationWindow.addToList("Movement of element '" + element.Name + "' to element '" +
                   targetElement.Name + "'");
            }
        }
コード例 #28
0
        /// <summary>
        /// method adds a new diagram object into diagram
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="elementGUID">GUID of element</param>
        /// <param name="diagramGUID">GUID of diagram</param>
        /// <param name="coordinates">coordinates of new diagram object</param>
        public void addDiagramObject(EA.Repository Repository, string elementGUID, string diagramGUID, string coordinates)
        {
            int left, right, top, bottom;

            string[] coordinate;
            string str;
            string[] parts = coordinates.Split(';');

            str = parts[0];
            coordinate = str.Split('=');
            left = Convert.ToInt32(coordinate[1]);

            str = parts[1];
            coordinate = str.Split('=');
            right = Convert.ToInt32(coordinate[1]);

            str = parts[2];
            coordinate = str.Split('=');
            top = Convert.ToInt32(coordinate[1]);

            str = parts[3];
            coordinate = str.Split('=');
            bottom = Convert.ToInt32(coordinate[1]);

            EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID);

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i);
                EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID);
                if (diagramObj.left <= left && diagramObj.right >= right && diagramObj.top >= top && diagramObj.bottom <= bottom)
                {
                    diagramObj.Sequence += 1;
                    diagramObj.Update();
                }
            }
            diagram.DiagramObjects.Refresh();

            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);
            EA.DiagramObject displayElement = (EA.DiagramObject)diagram.DiagramObjects.AddNew(coordinates, "");

            displayElement.ElementID = element.ElementID;
            displayElement.Sequence = 1;
            displayElement.Update();
            diagram.DiagramObjects.Refresh();

            EA.Package parentPackage = (EA.Package)Repository.GetPackageByID(diagram.PackageID);
            if (diagram.ParentID == 0)
            {
                BPAddIn.synchronizationWindow.addToList("Addition of element '" + element.Name + "' to diagram '"
                    + diagram.Name + "' (Location of diagram: package '" + parentPackage.Name + "')");
            }
            else
            {
                EA.Element parentElement = (EA.Element)Repository.GetElementByID(diagram.ParentID);
                BPAddIn.synchronizationWindow.addToList("Addition of element '" + element.Name + "' to diagram '"
                   + diagram.Name + "' (Location of diagram: element '" + parentElement.Name
                   + "' in package '" + parentPackage.Name + "')");
            }
        }
コード例 #29
0
        /// <summary>
        /// method moves diagram object of element in diagram
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="elementGUID">GUID of element which diagram object that should be moved belongs to</param>
        /// <param name="diagramGUID">GUID of diagram</param>
        /// <param name="coordinates">new coordinates of diagram object that should be moved</param>
        public void moveElementInDiagram(EA.Repository Repository, string elementGUID, string diagramGUID, string coordinates)
        {
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);
            EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID);

            int left, right, top, bottom, pocet = 0;

            Wrapper.Diagram diagramWrapper = new Wrapper.Diagram(model, diagram);
            Wrapper.ElementWrapper elWrapper = new Wrapper.ElementWrapper(model, element);
            EA.DiagramObject diagramObject = diagramWrapper.getdiagramObjectForElement(elWrapper);

            string[] coordinate;
            string str;
            string[] parts = coordinates.Split(';');

            str = parts[0];
            coordinate = str.Split('=');
            diagramObject.left = Convert.ToInt32(coordinate[1]);
            left = Convert.ToInt32(coordinate[1]);

            str = parts[1];
            coordinate = str.Split('=');
            diagramObject.right = Convert.ToInt32(coordinate[1]);
            right = Convert.ToInt32(coordinate[1]);

            str = parts[2];
            coordinate = str.Split('=');
            diagramObject.top = Convert.ToInt32(coordinate[1]);
            top = Convert.ToInt32(coordinate[1]);

            str = parts[3];
            coordinate = str.Split('=');
            diagramObject.bottom = Convert.ToInt32(coordinate[1]);
            bottom = Convert.ToInt32(coordinate[1]);

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i);
                EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID);
                if (diagramObj.left >= left && diagramObj.right <= right && diagramObj.top <= top && diagramObj.bottom >= bottom)
                {
                    if (diagramObj.ElementID != diagramObject.ElementID)
                    {
                        pocet++;
                    }
                }
            }

            diagramObject.Sequence = 1 + pocet;
            diagramObject.Update();

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i);
                EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID);
                if (diagramObj.left <= left && diagramObj.right >= right && diagramObj.top >= top && diagramObj.bottom <= bottom)
                {
                    if (diagramObj.ElementID != diagramObject.ElementID)
                    {
                        diagramObj.Sequence += 1;
                        diagramObj.Update();
                    }
                }
            }

            int parentID = diagram.ParentID;
            EA.Package package = (EA.Package)Repository.GetPackageByID(diagram.PackageID);
            if (parentID == 0)
            {
                BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" +
                    diagram.Name + "' (Location of diagram: package '" + package.Name + "')");
            }
            else {
                EA.Element parent = (EA.Element)Repository.GetElementByID(parentID);
                BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" +
                    diagram.Name + "' (Location of diagram: element '" + parent.Name + "' in package '" + package.Name + "')");
            }

            diagram.DiagramObjects.Refresh();
        }
コード例 #30
0
        /// <summary>
        /// method adds a new element into parent element or package
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="parentGUID">GUID of parent element</param>
        /// <param name="packageGUID">GUID of parent package</param>
        /// <param name="coordinates">coordinates of new element</param>
        /// <param name="elementType">type of new element</param>
        /// <param name="name">name of new element</param>
        /// <param name="author">author of new element</param>
        /// <returns>GUID of new element</returns>
        public string addElement(EA.Repository Repository, string parentGUID, string packageGUID, string coordinates, 
            int elementType, string name, string author)
        {
            if (getElementType(elementType) == "" && getElementStereotype(elementType) == "" && getElementSubtype(elementType) == -1)
            {
                return "";
            }

            EA.Collection elements;

            if (parentGUID == "0")
            {
                elements = (EA.Collection)Repository.GetPackageByGuid(packageGUID).Elements;
            }
            else
            {
                elements = (EA.Collection)Repository.GetElementByGuid(parentGUID).Elements;
            }

            if (elementType == 6 || (elementType > 30 && elementType < 45))
            {
                elements = (EA.Collection)Repository.GetPackageByGuid(packageGUID).Elements;
            }

            EA.Element newElement = (EA.Element)elements.AddNew(name, getElementType(elementType));

            if ((elementType >= 7 && elementType <= 10) || (elementType >= 18 && elementType <= 23))
            {
                newElement.Subtype = getElementSubtype(elementType);
            }

            if (elementType == 4 || (elementType >= 15 && elementType <= 17) || (elementType >= 31 && elementType <= 44))
            {
                newElement.Stereotype = getElementStereotype(elementType);
            }

            newElement.Author = author;
            newElement.Update();
            elements.Refresh();

            EA.Package parentPackage = (EA.Package)Repository.GetPackageByGuid(packageGUID);
            if (parentGUID == "0")
            {
                BPAddIn.synchronizationWindow.addToList("Addition of " + itemTypes.getElementTypeInEnglish(elementType) + " '" + name +
                    "' to package '" + parentPackage.Name + "' - author: '" + author + "'");
            }
            else
            {
                EA.Element parentElement = (EA.Element)Repository.GetElementByGuid(parentGUID);
                BPAddIn.synchronizationWindow.addToList("Addition of " + itemTypes.getElementTypeInEnglish(elementType) + " '" + name +
                    "' to element '" + parentElement.Name + "' in package '" + parentPackage.Name + "' - author: '" + author + "'");
            }

            return newElement.ElementGUID;
        }