/// <summary>
        /// start the transformation from the logical model to the database model
        /// </summary>
        void compareDatabase()
        {
            //make sure the log is empty
            EAOutputLogger.clearLog(this.model, this.settings.outputName);
            //make sure the cache is flushed
            this.model.flushCache();
            var selectedPackage = this.model.selectedElement as UTF_EA.Package;

            //TODO: allow the user to select either database or logical package if not already linked, or if multiple are linked
            if (selectedPackage != null)
            {
                var nameTranslator = new DB_EA.Transformation.NameTranslator(this.settings.abbreviationsPath, "_");
                if (selectedPackage.stereotypes.Any(x => x.name.Equals("database", StringComparison.InvariantCultureIgnoreCase)))
                {
                    var existingDatabase = DB2DatabaseTransformer.getFactory(this.model, DB2StrategyFactory.getInstance()).createDataBase(selectedPackage, true);
                    _databaseTransformer = new DB2DatabaseTransformer(this.model, nameTranslator, DB2StrategyFactory.getInstance(), true);
                    _databaseTransformer.existingDatabase = existingDatabase;
                }
                else
                {
                    _databaseTransformer = new DB2DatabaseTransformer((UTF_EA.Package)selectedPackage, nameTranslator, DB2StrategyFactory.getInstance(), true);
                }

                refreshCompare(true);
            }
        }
        /// <summary>
        /// gets the current database and completes it with the user selected ddl file
        /// </summary>
        void completeDBwithDLL()
        {
            // initialize database
            var selectedPackage  = this.model.selectedElement as UTF_EA.Package;
            var selectedDatabase = DB2DatabaseTransformer.getFactory(this.model, DB2StrategyFactory.getInstance()).createDataBase(selectedPackage);

            // get user selected DDL file
            var browseDDLFileDialog = new OpenFileDialog();

            browseDDLFileDialog.Filter      = "DDL File |*.sql;*.txt";
            browseDDLFileDialog.FilterIndex = 1;
            browseDDLFileDialog.Multiselect = false;
            var dialogResult = browseDDLFileDialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                var ddlFileName = browseDDLFileDialog.FileName;
                //read the file contents
                //workaround to make sure it also works when the file is open
                var    fileStream = new FileStream(ddlFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                var    reader     = new StreamReader(fileStream);
                string source     = reader.ReadToEnd();

                var ddl = new DDL();
                ddl.Parse(source);

                new DB2DatabaseTransformer(this.model, null, DB2StrategyFactory.getInstance())
                .complete(selectedDatabase, ddl);
            }
        }
 public override void EA_FileOpen(EA.Repository Repository)
 {
     // initialize the model
     this.model = new UTF_EA.Model(Repository, true);
     // preload the database factory
     DB2DatabaseTransformer.getFactory(this.model, DB2StrategyFactory.getInstance());
     // indicate that we are now fully loaded
     this.fullyLoaded = true;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// start the transformation from the logical model to the database model
        /// </summary>
        void compareDatabase()
        {
            var selectedPackage = this.model.selectedElement as UTF_EA.Package;

            //TODO: allow the user to select either database or logical package if not already linked, or if multiple are linked
            if (selectedPackage != null)
            {
                var nameTranslator = new DB_EA.Transformation.NameTranslator(this.settings.abbreviationsPath, "_");
                if (selectedPackage.stereotypes.Any(x => x.name.Equals("database", StringComparison.InvariantCultureIgnoreCase)))
                {
                    var existingDatabase = DB2DatabaseTransformer.getFactory(this.model).createDataBase(selectedPackage);
                    _databaseTransformer = new DB2DatabaseTransformer(this.model, nameTranslator);
                    _databaseTransformer.existingDatabase = existingDatabase;
                }
                else
                {
                    _databaseTransformer = new DB2DatabaseTransformer((UTF_EA.Package)selectedPackage, nameTranslator);
                }

                refreshCompare(true);
            }
        }
 public override void EA_FileOpen(EA.Repository Repository)
 {
     base.EA_FileOpen(Repository);
     // preload the database factory
     DB2DatabaseTransformer.getFactory(this.model, DB2StrategyFactory.getInstance());
 }