/// <summary> /// transform the selected package to the JSON profile /// </summary> private void transform() { //let the user select a class to be the root class MessageBox.Show("Please select the root element"); var rootObject = this.model.getUserSelectedElement(new List <string> { "Class" }) as UML.Classes.Kernel.Class; var selectedPackage = this.model.selectedElement as UML.Classes.Kernel.Package; if (selectedPackage != null) { //inform user EAOutputLogger.clearLog(this.model, outputName); EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Starting transform of package '{selectedPackage.name}'" , ((TSF_EA.ElementWrapper)selectedPackage).id , LogTypeEnum.log); //perform the actual transformation EAJSONSchema.transformPackage(selectedPackage, rootObject); //inform user EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Finished transform of package '{selectedPackage.name}'" , ((TSF_EA.ElementWrapper)selectedPackage).id , LogTypeEnum.log); } }
/// <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> /// Generate a new JSON Schema from the selected File /// </summary> private void generateJSONSchema() { //inform user EAOutputLogger.clearLog(this.model, outputName); var selectedPackage = this.model.selectedElement as TSF_EA.Package; if (selectedPackage != null) { //generate for package generateJSONSchemas(selectedPackage); } else { var selectedElement = this.model.selectedElement as TSF_EA.ElementWrapper; if (selectedElement != null) { this.generateJSONSchema(selectedElement); } } //inform user EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Finished generating Schema(s)" , 0 , LogTypeEnum.log); }
/// <summary> /// Creates a new message subset from the given schema in the given targetPackage /// </summary> /// <param name="schema">the Schema to generate a message subset from</param> /// <param name="targetPackage">the Package to create the new Message subset in</param> private void createNewMessageSubset(Schema schema, UML.Classes.Kernel.Package targetPackage) { //log progress EAOutputLogger.clearLog(this.EAModel, this.settings.outputName); EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Starting creation of new subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((TSF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); if (targetPackage != null) { //Logger.log("before ECDMMessageComposerAddin::schema.createSubsetModel"); //Todo create global setting bool copyDataType = this.settings.copyDataTypes; List <String> datatypesToCopy = null; if (copyDataType && this.settings.limitDataTypes) { datatypesToCopy = this.settings.dataTypesToCopy; } schema.createSubsetModel(targetPackage, schema.elements); this.createNewSubsetDiagram(schema, targetPackage); } //log progress EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Finished creation of new subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((TSF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); }
// support for logging to the EA log window internal void clearLog() { if (this.model == null) { return; } EAOutputLogger.clearLog(this.model, this.settings.outputName); }
/// <summary> /// updates an existing message subset for a schema /// </summary> /// <param name="schema">the schema to use as basis</param> /// <param name="messageElement">the root element of the subset</param> private void updateMessageSubset(Schema schema, UML.Classes.Kernel.Package targetPackage) { //log progress var startTime = DateTime.Now; EAOutputLogger.clearLog(this.EAModel, this.settings.outputName); EAOutputLogger.log(this.EAModel, this.settings.outputName , $"{startTime.ToLongTimeString()} Starting update of existing subset for schema '{schema.name}' in package '{targetPackage.name}'" , ((TSF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); bool copyDataType = this.settings.copyDataTypes; List <String> datatypesToCopy = null; if (copyDataType && this.settings.limitDataTypes) { datatypesToCopy = this.settings.dataTypesToCopy; } bool useMessage = false; if (!this.settings.usePackageSchemasOnly) { //check if we have a message element to folow var messageElement = targetPackage.ownedElements.OfType <UML.Classes.Kernel.Classifier>().FirstOrDefault(); if (messageElement != null) { useMessage = true; schema.updateSubsetModel(messageElement); } } if (this.settings.usePackageSchemasOnly || !useMessage) { schema.updateSubsetModel(targetPackage); } if (this.settings.generateDiagram) { var subsetDiagrams = targetPackage.ownedDiagrams; if (subsetDiagrams.Count > 0) { //if there are existing diagram then we update the existing diagrams this.updateExistingDiagrams(schema, subsetDiagrams); } else { //if not we create a new diagram this.createNewSubsetDiagram(schema, targetPackage); } } //log progress var endTime = DateTime.Now; var processingTime = (endTime - startTime).TotalSeconds; EAOutputLogger.log(this.EAModel, this.settings.outputName , $"{endTime.ToLongTimeString()} Finished update of existing subset for schema '{schema.name}' in package '{targetPackage.name}' in {processingTime.ToString("N0")} seconds" , ((TSF_EA.Package)targetPackage).id , LogTypeEnum.log); }
/// <summary> /// updates an existing message subset for a schema /// </summary> /// <param name="schema">the schema to use as basis</param> /// <param name="messageElement">the root element of the subset</param> private void updateMessageSubset(Schema schema, UML.Classes.Kernel.Package targetPackage) { //log progress EAOutputLogger.clearLog(this.EAModel, this.settings.outputName); EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Starting update of existing subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((UTF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); bool copyDataType = this.settings.copyDataTypes; List <String> datatypesToCopy = null; if (copyDataType && this.settings.limitDataTypes) { datatypesToCopy = this.settings.dataTypesToCopy; } bool useMessage = false; if (!settings.usePackageSchemasOnly) { //check if we have a message element to folow var messageElement = targetPackage.ownedElements.OfType <UML.Classes.Kernel.Classifier>().FirstOrDefault(); if (messageElement != null) { useMessage = true; schema.updateSubsetModel(messageElement); } } if (settings.usePackageSchemasOnly || !useMessage) { schema.updateSubsetModel(targetPackage); } var subsetDiagrams = targetPackage.ownedDiagrams; if (subsetDiagrams.Count > 0) { //if there are existing diagram then we update the existing diagrams updateExistingDiagrams(schema, subsetDiagrams); } else { //if not we create a new diagram createNewSubsetDiagram(schema, targetPackage); } //log progress EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Finished update of existing subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((UTF_EA.Package)targetPackage).id , LogTypeEnum.log); }
public void complete(Database database, DDL withDDL) { EAOutputLogger.clearLog(this._model, this.outputName); this.log(string.Format( "completing {0} statements (parsed with {1} errors)", withDDL.statements.Count, withDDL.errors.Count )); // perform several fixes to complete the schema according to the DDL this.fixUniqueIndexes(database, withDDL); this.fixClusteredIndexes(database, withDDL); this.fixOnDeleteRestrictForeignKeys(database, withDDL); this.fixWithDefaultFields(database, withDDL); this.fixIncludedFieldsInIndex(database, withDDL); this.fixCheckConstraints(database, withDDL); }
public void startCorrections(string mdzipPath, List <MagicDrawCorrector> correctionsToStart) { //clear the log EAOutputLogger.clearLog(this.model, this.outputName); //tell the user what is happening EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting corrections for Magicdraw import" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //start correcting foreach (var corrector in correctionsToStart) { corrector.correct(); } //tell the user what is happening EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished corrections for Magicdraw import" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
private void clearOutput() { EAOutputLogger.clearLog(this.model, this.settings.outputName); }
public void clearEAOutput() { EAOutputLogger.clearLog(this.model, this.outputName); }