Inheritance: Element, TSF.UmlToolingFramework.UML.Classes.Kernel.Property
        protected override void saveMe()
        {
            //create the _wrapped attribute if needed
            if (_wrappedattribute == null)
            {
                if (this._ownerTable._wrappedClass == null)
                {
                    this.ownerTable.save();
                }
                //now the wrappedClass should exist. if not then we have a problem
                this._wrappedattribute = this.factory.modelFactory.createNewElement <TSF_EA.Attribute>(this._ownerTable._wrappedClass, this.name);

                if (this.isNotNullable &&
                    this.ownerTable.primaryKey != null &&
                    this.ownerTable.primaryKey.involvedColumns.Contains(this))
                {
                    //not nullable columns that are not part of a Primary key get "DEFAULT" as default value, which results in "WITH DEFAULT" in the DDL
                    this.initialValue = "DEFAULT";                     //TODO: find a better way to define "DEFAULT" instead of hardcoding.
                }
            }
            if (_wrappedattribute != null)
            {
                //set steretotype
                this._wrappedattribute.setStereotype("column");
                //set datatype;
                _wrappedattribute.type = this.factory.modelFactory.createPrimitiveType(this.type.name);
                if (this.type.type.hasPrecision)
                {
                    _wrappedattribute.precision = this.type.length;
                    _wrappedattribute.scale     = this.type.precision;
                }
                else
                {
                    _wrappedattribute.length = this.type.length;
                }
                //is not nullable
                this.isNotNullable = this.isNotNullable;
                //set position
                this.position = this.position;
                // InitialValue
                this.initialValue = this.initialValue;
                //save
                _wrappedattribute.save();
                //following properties are saved as tagged values so need to be set after saving the wrapped atttribute
                //set isOverridden
                this.isOverridden = this.isOverridden;
                //set renamed
                this.isRenamed = this.isRenamed;
                //logical attribute tag value
                if (traceTaggedValue == null)
                {
                    createTraceTaggedValue();
                }
            }
            //save the columnn name in the alias
            if (logicalAttribute != null)
            {
                logicalAttribute.save();
            }
        }
        protected override Column transformLogicalAttribute(UTF_EA.Attribute attribute)
        {
            var columnTransformer = new DB2ColumnTransformer(this._table, this._nameTranslator);

            this._columnTransformers.Add(columnTransformer);
            return((Column)columnTransformer.transformLogicalProperty(attribute));
        }
Ejemplo n.º 3
0
        private bool notInSync(TSF_EA.Attribute column, TSF_EA.Class clazz)
        {
            //DataItem di = GlossaryItemFactory<DataItem>.FromClass(clazz);
            DataItem di = null;

            if (di == null)
            {
                return(true);
            }                          // ???
            if (column.name != di.Label)
            {
                return(true);
            }
            // TODO DataType
            if (column.length != di.Size)
            {
                return(true);
            }
            // TODO Format
            if (column.defaultValue.ToString() != di.InitialValue)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static List <Mapping> createNewMappings(TSF.UmlToolingFramework.Wrappers.EA.Attribute attribute, string basepath, ElementWrapper targetRootElement)
        {
            List <Mapping> returnedMappings = new List <Mapping>();

            //connectors from owned attributes
            foreach (ConnectorWrapper mappedConnector in attribute.relationships.OfType <ConnectorWrapper>())
            {
                if (!mappedConnector.taggedValues.Any(x => x.name == mappingSourcePathName && x.tagValue.ToString() != basepath))
                {
                    //get the target base path
                    ConnectorMapping connectorMapping;
                    var    targetTV       = mappedConnector.taggedValues.FirstOrDefault(x => x.name == mappingTargetPathName);
                    string targetBasePath = string.Empty;
                    if (targetTV != null)
                    {
                        targetBasePath = targetTV.tagValue.ToString();
                    }
                    if (!string.IsNullOrEmpty(targetBasePath))
                    {
                        //connectorMapping = new ConnectorMapping(mappedConnector,basepath,targetBasePath);
                    }
                    else
                    {
                        //connectorMapping = new ConnectorMapping(mappedConnector,basepath,targetRootElement);
                    }
                    //returnedMappings.Add(connectorMapping);
                }
            }
            //tagged value references from owned attributes
            foreach (TaggedValue mappedTaggedValue in attribute.taggedValues.Where(x => x.tagValue is Element))
            {
                string mappingSourcePath = KeyValuePairsHelper.getValueForKey(mappingSourcePathName, mappedTaggedValue.comment);
                string targetBasePath    = KeyValuePairsHelper.getValueForKey(mappingTargetPathName, mappedTaggedValue.comment);

                //if not filled in or corresponds to the attributeBasePath or the attributeBasePath + the name of the attribute
                if (string.IsNullOrEmpty(mappingSourcePath) || mappingSourcePath == basepath ||
                    mappingSourcePath == basepath + "." + attribute.name)
                {
                    TaggedValueMapping tagMapping;
                    if (!string.IsNullOrEmpty(targetBasePath))
                    {
                        //tagMapping = new TaggedValueMapping(mappedTaggedValue,basepath,targetBasePath);
                    }
                    else
                    {
                        //tagMapping = new TaggedValueMapping(mappedTaggedValue,basepath,targetRootElement);
                    }
                    //returnedMappings.Add(tagMapping);
                }
            }
            //add the mappings for the type of the attribute
            var attributeType = attribute.type as ElementWrapper;

            if (attributeType != null)
            {
                returnedMappings.AddRange(createOwnedMappings(attributeType, basepath + "." + attribute.name, false));
            }
            return(returnedMappings);
        }
        protected override void updateDetails(DB.DatabaseItem newDatabaseItem)
        {
            var newColumn = (Column)newDatabaseItem;

            this._isNotNullable    = newColumn.isNotNullable;
            this._logicalAttribute = newColumn.logicalAttribute;
            this._type             = newColumn._type;
            this.isOverridden      = newColumn.isOverridden;
        }
Ejemplo n.º 6
0
        private Column transformLogicalAttribute(UTF_EA.Attribute attribute)
        {
            bool isEqualDirty = false;

            //first translate the columname if needed
            if (string.IsNullOrEmpty(attribute.alias))
            {
                attribute.alias = this._nameTranslator.translate(attribute.name, attribute.owner.name);
                isEqualDirty    = true;
                //should we save here?
            }
            this.column = new Column(this._table, attribute.alias);
            this.column.isEqualDirty = isEqualDirty;
            //get base type
            var attributeType = attribute.type as UTF_EA.ElementWrapper;

            if (attributeType == null)
            {
                Logger.logError(string.Format("Attribute {0}.{1} does not have a element as datatype"
                                              , attribute.owner.name, attribute.name));
            }
            else
            {
                DataType datatype = _table._owner._factory.createDataType(attributeType.alias);
                if (datatype == null)
                {
                    Logger.logError(string.Format("Could not find {0} as Datatype for attribute {1}.{2}"
                                                  , attributeType.alias, attribute.owner.name, attribute.name));
                }
                else
                {
                    column.type = datatype;
                }
            }
            //set not null property
            if (attribute.lower == 0)
            {
                column.isNotNullable = false;
            }
            else
            {
                column.isNotNullable = true;
            }
            //set inital value
            if (attribute.defaultValue != null &&
                !string.IsNullOrEmpty(attribute.defaultValue.ToString()))
            {
                this.column.initialValue = attribute.defaultValue.ToString();
            }

            //set position
            this.column.position = attribute.position;
            return(this._column);
        }
 // adds an empty column and selects it. user can now select a Data Item.
 // because of magic values in de new empty column, validation will not only
 // validate, but also immediately perform a sync
 private void addEmptyColumn()
 {
     TSF_EA.Attribute attribute =
         this.ui.Addin.Model.factory.createNewElement <TSF_EA.Attribute>(
             this.context, "<new>"
             );
     attribute.AddStereotype("column");
     attribute.save();
     this.context.save();
     this.refreshTree();
     this.selectNewColumn();
 }
        protected override void updateDetails(DB.DatabaseItem newDatabaseItem)
        {
            var newColumn = (Column)newDatabaseItem;

            this._isNotNullable    = newColumn.isNotNullable;
            this._logicalAttribute = newColumn.logicalAttribute;
            this._type             = newColumn._type;
            this.isOverridden      = newColumn.isOverridden;
            this.isRenamed         = newColumn.isRenamed;
            this.position          = newColumn.position;
            this.initialValue      = newColumn.initialValue;
        }
Ejemplo n.º 9
0
 public override void save()
 {
     //create the _wrapped attribute if needed
     if (_wrappedattribute == null)
     {
         if (this._ownerTable._wrappedClass == null)
         {
             this.ownerTable.save();
         }
         //now the wrappedClass should exist. if not then we have a problem
         this._wrappedattribute = this.factory.modelFactory.createNewElement <TSF_EA.Attribute>(this._ownerTable._wrappedClass, this.name);
     }
     if (_wrappedattribute != null)
     {
         //set steretotype
         this._wrappedattribute.setStereotype("column");
         //set datatype;
         _wrappedattribute.type = this.factory.modelFactory.createPrimitiveType(this.type.name);
         if (this.type.type.hasPrecision)
         {
             _wrappedattribute.precision = this.type.length;
             _wrappedattribute.scale     = this.type.precision;
         }
         else
         {
             _wrappedattribute.length = this.type.length;
         }
         //is not nullable
         this.isNotNullable = this.isNotNullable;
         //set position
         this.position = this.position;
         // InitialValue
         this.initialValue = this.initialValue;
         //save
         _wrappedattribute.save();
         //following properties are saved as tagged values so need to be set after saving the wrapped atttribute
         //set isOverridden
         this.isOverridden = this.isOverridden;
         //set renamed
         this.isRenamed = this.isRenamed;
         //logical attribute tag value
         if (traceTaggedValue == null)
         {
             createTraceTaggedValue();
         }
     }
     //save the columnn name in the alias
     if (logicalAttribute != null)
     {
         logicalAttribute.save();
     }
 }
        private TreeNode createColumnNode(TSF_EA.Attribute attribute,
                                          TreeNodeCollection parent)
        {
            TreeNode node = new TreeNode(attribute.name)
            {
                Tag              = attribute,
                ImageKey         = "column",
                SelectedImageKey = "column"
            };

            parent.Add(node);
            return(node);
        }
 private DataItem getDataItem(TSF_EA.Attribute attribute)
 {
     if (attribute == null)
     {
         return(null);
     }
     TSF_EA.TaggedValue tv = attribute.getTaggedValue("EDD::dataitem");
     if (tv == null || tv.tagValue == null)
     {
         return(null);
     }
     return(GlossaryItemFactory <DataItem> .FromClass(tv.tagValue as TSF_EA.Class));
 }
Ejemplo n.º 12
0
        public static DB_EA.Column createColumn(TSF_EA.Attribute attribute)
        {
            //create the table
            var tableElement = attribute.owner as Class;

            if (tableElement == null)
            {
                return(null);
            }
            var table = createTable(tableElement);

            if (table == null)
            {
                return(null);
            }
            //create the column
            return(new Column(table, attribute));
        }
        private void sync(TSF_EA.Attribute column)
        {
            DataItem di = this.getDataItem(column);

            column.name = di.Label;
            // TODO DataType
            column.length = di.Size;
            // TODO Format
            // TODO ValueSpecification
            column.defaultValue =
                this.ui.Addin.Model.factory.createValueSpecificationFromString(
                    di.InitialValue
                    );
            var context = this.context;

            column.save();
            this.ui.Addin.SelectedItem = context;
            this.refreshTree();
        }
        /// <summary>
        /// finds the corresponding Schema property for the given attribut
        /// </summary>
        /// <param name="attribute">attribute</param>
        /// <returns>the corresponding Schema property if one is found. Else null</returns>
        public EASchemaProperty getMatchingSchemaProperty(UTF_EA.Attribute attribute)
        {
            EASchemaProperty result = null;
            var sourceAttributeTag  = attribute.getTaggedValue(this.owner.settings.sourceAttributeTagName);

            if (sourceAttributeTag != null)
            {
                string tagReference = sourceAttributeTag.eaStringValue;

                foreach (EASchemaProperty property in this.schemaProperties)
                {
                    //we have the same attribute if the given attribute has a tagged value
                    //called sourceAttribute that refences the source attribute of the schema Property
                    if (((UTF_EA.Attribute)property.sourceProperty).guid == tagReference)
                    {
                        result = property;
                        break;
                    }
                }
            }
            return(result);
        }
        private void linkColumnToDataItem()
        {
            // TODO: this allows for selecting/creating a new table anywhere
            //       currently the TreeView will only be populated with tables
            //       that are within the managed (gloaasry) package.

            // select a table (or create a new one)
            TSF_EA.Class table =
                (TSF_EA.Class) this.ui.Addin.Model.getUserSelectedElement(
                    new List <string>()
            {
                "Class"
            }
                    );
            if (!table.HasStereotype("table"))
            {
                return;
            }

            // create new column on table
            TSF_EA.Attribute attribute =
                this.ui.Addin.Model.factory.createNewElement <TSF_EA.Attribute>(
                    table, "<new>"
                    );
            attribute.AddStereotype("column");
            var context = this.context;

            attribute.save();

            // link the column to the DataItem
            attribute.addTaggedValue("EDD::dataitem", context.guid);
            attribute.save();

            // sync
            this.sync(attribute);

            this.ui.Addin.SelectedItem = context;
        }
 public override void save()
 {
     //create the _wrapped attribute if needed
     if (_wrappedattribute == null)
     {
         if (this._owner._wrappedClass == null)
         {
             this.ownerTable.save();
         }
         //now the wrappedClass should exist. if not then we have a problem
         this._wrappedattribute = this.factory.modelFactory.createNewElement <TSF_EA.Attribute>(this._owner._wrappedClass, this.name);
     }
     if (_wrappedattribute != null)
     {
         //set steretotype
         this._wrappedattribute.setStereotype("column");
         //set datatype;
         _wrappedattribute.type      = this.factory.modelFactory.createPrimitiveType(this.type.name);
         _wrappedattribute.length    = this.type.length;
         _wrappedattribute.precision = this.type.precision;
         //is not nullable
         this.isNotNullable = _isNotNullable;
         //save
         _wrappedattribute.save();
         //set isOverridden
         this.isOverridden = this.isOverridden;
         //logical attribute tag value
         if (traceTaggedValue == null)
         {
             createTraceTaggedValue();
         }
     }
     //save the columnn name in the alias
     if (logicalAttribute != null)
     {
         logicalAttribute.save();
     }
 }
        private void refreshTree()
        {
            this.prevSelection = this.Current;

            this.tree.SuspendLayout();

            this.tree.Nodes.Clear();

            if (this.ContextIsDataItem)
            {
                this.populateTreeForDataItem();
            }
            else if (this.ContextIsTable)
            {
                this.populateTreeForTable();
            }

            this.tree.ExpandAll();

            this.tree.ResumeLayout(false);

            this.prevSelection = null;
        }
Ejemplo n.º 18
0
 public AttributeMappingNode(TSF_EA.Attribute sourceAttribute, MappingSettings settings, MP.ModelStructure structure) : this(sourceAttribute, null, settings, structure)
 {
 }
        protected override void saveMe()
        {
            //create the _wrapped attribute if needed
            if (_wrappedattribute == null)
            {
                if (this._ownerTable.wrappedClass == null)
                {
                    this.ownerTable.save();
                }
                //now the wrappedClass should exist. if not then we have a problem
                this._wrappedattribute = this.factory.modelFactory.createNewElement <TSF_EA.Attribute>(this._ownerTable.wrappedClass, this.name);

                if (this.logicalAttribute != null)
                {
                    var attributeType = logicalAttribute.type as TSF_EA.ElementWrapper;
                    if (attributeType != null)
                    {
                        //check if attributeType as any constraints
                        var typeConstraint = attributeType.constraints.OfType <TSF_EA.Constraint>().FirstOrDefault();
                        if (typeConstraint != null)
                        {
                            //add a check constraint
                            var checkConstraint = new CheckConstraint(this.name, this, typeConstraint.convertFromEANotes("TXT").Replace("<Column>", this.name));
                            //save?
                            checkConstraint.save();
                        }
                    }
                }
            }
            if (_wrappedattribute != null)
            {
                //set steretotype
                this._wrappedattribute.setStereotype("column");
                //set datatype;
                _wrappedattribute.type = this.factory.modelFactory.createPrimitiveType(this.type.name);
                if (this.type.type != null && this.type.type.hasPrecision)
                {
                    _wrappedattribute.precision = this.type.length;
                    _wrappedattribute.scale     = this.type.precision;
                }
                else
                {
                    _wrappedattribute.length = this.type.length;
                }
                //is not nullable
                this.isNotNullable = this.isNotNullable;
                //set position
                this.position = this.position;
                // InitialValue
                this.initialValue = this.initialValue;
                //save
                _wrappedattribute.save();
                //following properties are saved as tagged values so need to be set after saving the wrapped atttribute
                //set isOverridden
                this.isOverridden = this.isOverridden;
                //set renamed
                this.isRenamed = this.isRenamed;
                //logical attribute tag value
                if (traceTaggedValue == null)
                {
                    createTraceTaggedValue();
                }
            }
            //save the columnn name in the alias
            if (logicalAttribute != null)
            {
                logicalAttribute.save();
            }
        }
Ejemplo n.º 20
0
 public AttributeMappingNode(TSF_EA.Attribute sourceAttribute, ClassifierMappingNode parent, MappingSettings settings, MP.ModelStructure structure) : base(sourceAttribute, parent, settings, structure)
 {
 }
Ejemplo n.º 21
0
 protected abstract void createColumn(UTF_EA.Attribute attribute);
 public Column(Table owner, TSF_EA.Attribute attribute)
 {
     this._owner            = owner;
     this._wrappedattribute = attribute;
 }
 protected override void updateDetails(DB.DatabaseItem newDatabaseItem)
 {
     var newColumn = (Column)newDatabaseItem;
     this._isNotNullable = newColumn.isNotNullable;
     this._logicalAttribute = newColumn.logicalAttribute;
     this._type = newColumn._type;
     this.isOverridden = newColumn.isOverridden;
     this.isRenamed = newColumn.isRenamed;
     this.position = newColumn.position;
 }
        public override void save()
        {
            //create the _wrapped attribute if needed
            if (_wrappedattribute == null)
            {
                if (this._ownerTable._wrappedClass == null)
                {
                    this.ownerTable.save();
                }
                //now the wrappedClass should exist. if not then we have a problem
                this._wrappedattribute = this.factory.modelFactory.createNewElement<TSF_EA.Attribute>(this._ownerTable._wrappedClass,this.name);
            }
            if (_wrappedattribute != null)
            {
                //set steretotype
                this._wrappedattribute.setStereotype("column");
                //set datatype;
                _wrappedattribute.type = this.factory.modelFactory.createPrimitiveType(this.type.name);
                if (this.type.type.hasPrecision)
                {
                    _wrappedattribute.precision = this.type.length;
                    _wrappedattribute.scale = this.type.precision;
                }
                else
                {
                    _wrappedattribute.length = this.type.length;
                }
                //is not nullable
                this.isNotNullable = _isNotNullable;
                //set position
                _wrappedattribute.position = _position;
                //save
                _wrappedattribute.save();
                //set isOverridden
                this.isOverridden = this.isOverridden;
                //set renamed
                this.isRenamed = this.isRenamed;
                //logical attribute tag value
                if (traceTaggedValue == null) createTraceTaggedValue();

            }
            //save the columnn name in the alias
            if (logicalAttribute != null) logicalAttribute.save();
        }
 public Column(Table owner, TSF_EA.Attribute attribute)
 {
     this._ownerTable = owner;
     this._wrappedattribute = attribute;
 }
 public DB2ColumnTransformer(Table table, Column column, UTF_EA.Attribute attribute, NameTranslator nameTranslator) : this(table, nameTranslator)
 {
     this.logicalProperty = attribute;
     this.column          = column;
 }
 public Column(Table owner, TSF_EA.Attribute attribute) : base(owner.strategy.getStrategy <Column>())
 {
     this._ownerTable       = owner;
     this._wrappedattribute = attribute;
 }
 protected override void createColumn(UTF_EA.Attribute attribute)
 {
     this.logicalProperty = attribute;
     this.column          = transformLogicalAttribute(attribute);
 }
Ejemplo n.º 29
0
 protected override void createColumn(UTF_EA.Attribute attribute)
 {
     //TODO: translate name to alias
     this.logicalProperty = attribute;
     this.column          = transformLogicalAttribute(attribute);
 }
Ejemplo n.º 30
0
 protected abstract Column transformLogicalAttribute(UTF_EA.Attribute attribute);
        public override void correct()
        {
            //Log start
            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Starting converting embedded properties to attributes'"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);

            //Start converting
            List <TSF_EA.ElementWrapper> properties = this.model.getElementWrappersByQuery(@"select o1.[Object_ID] from [t_object] o1 where o1.[Object_Type] = 'Part'");

            foreach (TSF_EA.Property property in properties)
            {
                //Tell the user which property we are dealing  with
                EAOutputLogger.log(this.model, this.outputName
                                   , string.Format("{0} Correcting property '{1}' with GUID '{2}'"
                                                   , DateTime.Now.ToLongTimeString()
                                                   , property.name
                                                   , property.guid)
                                   , 0
                                   , LogTypeEnum.log);



                if (!string.IsNullOrEmpty(property.name))
                {
                    //Create attribute with the name of the property
                    TSF_EA.Attribute newAttribute = this.model.factory.createNewElement <TSF_EA.Attribute>(property.owner, property.name);

                    if (property.classifier != null)
                    {
                        newAttribute.type = property.classifier;
                    }
                    newAttribute.multiplicity = property.multiplicity;
                    newAttribute.save();


                    //Tell the user which attribute we created
                    EAOutputLogger.log(this.model, this.outputName
                                       , string.Format("{0} Create attribute '{1}' with type '{2}'"
                                                       , DateTime.Now.ToLongTimeString()
                                                       , newAttribute.name
                                                       , newAttribute.type)
                                       , 0
                                       , LogTypeEnum.log);
                }
                else if (property.classifier != null)
                {
                    //Create attribute with the name of the classifier
                    TSF_EA.Attribute newAttribute = this.model.factory.createNewElement <TSF_EA.Attribute>(property.owner, property.classifier.name);

                    newAttribute.type         = property.classifier;
                    newAttribute.multiplicity = property.multiplicity;
                    newAttribute.save();

                    //Tell the user which attribute we created
                    EAOutputLogger.log(this.model, this.outputName
                                       , string.Format("{0} Create attribute '{1}' with type '{2}'"
                                                       , DateTime.Now.ToLongTimeString()
                                                       , newAttribute.name
                                                       , newAttribute.type)
                                       , 0
                                       , LogTypeEnum.log);
                }
                else
                {
                    //Alert the user that we couldn't create the attribute
                    EAOutputLogger.log(this.model, this.outputName
                                       , string.Format("{0} Could not create attribute for property with id '{1}'"
                                                       , DateTime.Now.ToLongTimeString()
                                                       , property.guid
                                                       )
                                       , property.id
                                       , LogTypeEnum.error);
                    //stop processing
                    break;
                }
                //Delete property
                property.delete();
            }



            //Log Finished
            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Finished converting embedded properties to attributes'"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);
        }