예제 #1
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();
 }
 public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
 {
     EA.Method meth = rep.GetMethodByGuid(GUID);
     if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
     { meth.Notes = _Description; }
     if ((fieldType & FindAndReplaceItem.FieldType.Name) > 0)
     {   meth.Name = _Name; }
     if ((fieldType & FindAndReplaceItem.FieldType.Stereotype) > 0)
     { meth.StereotypeEx = _Stereotype; }
     _isUpdated = true;
     meth.Update();
 }
예제 #3
0
 public void RunMethodRule(EA.Repository Repository, string sRuleID, string MethodGUID, long ObjectID)
 {
     EA.Method method = Repository.GetMethodByGuid(MethodGUID);
     if (method != null)
     {
         switch (LookupMapEx(sRuleID))
         {
             case rule76:
                 DoRule76(Repository, method);
                 break;
             case rule77:
                 DoRule77(Repository, method);
                 break;
             case rule78:
                 DoRule78(Repository, method);
                 break;
             case rule79:
                 DoRule79_to_83(Repository, method, "Create");
                 break;
             case rule80:
                 DoRule79_to_83(Repository, method, "Read");
                 break;
             case rule81:
                 DoRule79_to_83(Repository, method, "Update");
                 break;
             case rule82:
                 DoRule79_to_83(Repository, method, "Delete");
                 break;
             case rule83:
                 DoRule79_to_83(Repository, method, "DeleteAll");
                 break;
             case rule84:
                 DoRule84(Repository, method);
                 break;
             case rule85:
                 DoRule85(Repository, method);
                 break;
             case rule86:
                 DoRule86(Repository, method);
                 break;
             case rule87:
                 DoRule87(Repository, method);
                 break;
             default:
                 break;
         }
     }
 }
        public static EA.Method GetMethodFromMethodName(EA.Repository rep, string methodName)
        {
            EA.Method method = null;
            string query = @"select op.ea_guid AS EA_GUID
                      from t_operation op 
                      where op.name = '" + methodName + "' ";
            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;
                method = rep.GetMethodByGuid(guid);
            }

            return method;
        }
 public  FindAndReplaceItemMethod(EA.Repository rep, string GUID)  :base(rep, GUID)
 {
     this._meth = rep.GetMethodByGuid(GUID);
     this.load(rep);
 }
//        // 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;
        }
        // Find the operation from Activity / State Machine
        // it excludes operations in state machines
        public static Method GetOperationFromBrehavior(EA.Repository rep, EA.Element el)
        {
            Method method = null;
            string query = "";
            string conString = GetConnectionString(rep); // due to shortcuts
            if (conString.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 + "' "+
                            " AND (Type is Null or Type not in ('do','entry','exit'))";
            }
            if (conString.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 + "'" +
                       " AND (Type is Null or Type not in ('do','entry','exit'))";

            }

            if (conString.Contains(".eap"))
                // SQL Server
            {     query = 
                      @"select op.ea_guid AS EA_GUID
                        from t_operation op 
                        where op.Behaviour = '" + el.ElementGUID + "'" +
                       " AND ( Type is Null or Type not in ('do','entry','exit'))";

            }
            if ((! conString.Contains("DBType=1")) &&  // SQL Server, DBType=0 MySQL
               (!  conString.Contains("DBType=3")) &&  // Oracle
               (!  conString.Contains(".eap")))// Access
            {
                query =
                  @"select op.ea_guid AS EA_GUID
                        from t_operation op 
                        where op.Behaviour = '" + el.ElementGUID + "'" +
                       " AND (Type is Null or Type not in ('do','entry','exit'))";

            }

            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;
                method = rep.GetMethodByGuid(guid);
            }
            return method;
        }
        // Find the calling operation from a Call Operation Action
        public static Method GetOperationFromCallAction(EA.Repository rep, EA.Element obj)
        {
            string wildCard = GetWildCard(rep);
            string query = @"SELECT op.ea_guid AS OPERATION from (t_object o inner join t_operation op on (o.classifier_guid = op.ea_guid))
               inner join t_xref x on (x.client = o.ea_guid)
			   where x.name = 'CustomProperties' and
			             x.description like '"+ wildCard + "CallOperation" + wildCard + 
                         "' and o.object_id = " + obj.ElementID;
            string str = rep.SQLQuery(query);
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(str);

            XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//OPERATION");
            if (operationGuidNode != null)
            {
                var guid = operationGuidNode.InnerText;
                return rep.GetMethodByGuid(guid);
            }
            return null;
        }
        // Find the calling operation from a Call Operation Action
        public static Method GetOperationFromAction(EA.Repository rep, EA.Element action)
        {
            Method method = null;
            string query = @"select o.Classifier_guid AS CLASSIFIER_GUID
                      from t_object o 
                      where o.Object_ID = " + action.ElementID;
            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;
                method = rep.GetMethodByGuid(guid);
            }
            return method;
        }