Пример #1
0
 /// <summary>
 /// Loads the scalar property collection.
 /// </summary>
 /// <param name="scalarProperties">The scalar properties.</param>
 /// <param name="xScalarProperties">The xml node list with scalar properties information.</param>
 private static void LoadScalarPropertyCollection(ScalarPropertyCollection scalarProperties, XmlNodeList xScalarProperties)
 {
     foreach (XmlNode xScalarProperty in xScalarProperties)
     {
         ScalarProperty scalarProperty = new ScalarProperty();
         scalarProperties.Add(scalarProperty);
         LoadScalarProperty(scalarProperty, xScalarProperty);
     }
 }
Пример #2
0
        /// <summary>
        /// Adds the scalar property.
        /// </summary>
        /// <param name="domainTriple">The domain triple.</param>
        /// <param name="rangeTriple">The range triple.</param>
        /// <param name="dataModelModule">The data model module.</param>
        private void AddScalarProperty(Triple domainTriple, Triple rangeTriple, DataModelModule dataModelModule)
        {
            //Get property name.
            string propertyName =
                GetLocalName(domainTriple.TripleSubject as RDFUriReference);
            //Get resource type.
            ResourceType domainResType = dataModelModule.ResourceTypes[
                GetLocalName(domainTriple.TripleObject as RDFUriReference)];
            XsdDataType dataType = Context.XsdDataTypeCollection.
                                   Where(tuple => tuple.Name == rangeTriple.TripleObject).First();

            //Create scalar property and add to resource type.
            ScalarProperty property = new ScalarProperty(propertyName, dataType.BaseType);

            property.MaxLength = dataType.MaxLength;
            property.Precision = dataType.Precision;
            property.Scale     = dataType.Scale;

            domainResType.ScalarProperties.Add(property);
        }
Пример #3
0
            /// <summary>
            /// Loads the scalar property.
            /// </summary>
            /// <param name="scalarProperty">The scalar property.</param>
            /// <param name="xScalarProperty">The xml node with scalar property information.</param>
            private static void LoadScalarProperty(ScalarProperty scalarProperty, XmlNode xScalarProperty)
            {
                XmlElement eScalarProperty = xScalarProperty as XmlElement;

                // Assign Id.
                scalarProperty.Id = new Guid(eScalarProperty.Attributes[DataModellingResources.Id].Value);

                // Assign Name.
                scalarProperty.Name = eScalarProperty.Attributes[DataModellingResources.Name].Value;

                // Assign Nullable.
                scalarProperty.Nullable =
                    Convert.ToInt32(eScalarProperty.Attributes[DataModellingResources.Nullable].Value,
                                    CultureInfo.InvariantCulture) == 1 ? true : false;

                // Assign Uri.
                if (eScalarProperty.HasAttribute(DataModellingResources.Uri))
                {
                    scalarProperty.Uri = eScalarProperty.Attributes[DataModellingResources.Uri].Value;
                }

                // Assign Description.
                if (eScalarProperty.HasAttribute(DataModellingResources.Description))
                {
                    scalarProperty.Description = eScalarProperty.Attributes[DataModellingResources.Description].Value;
                }

                // Assign DataType.
                string dataType = eScalarProperty.Attributes[DataModellingResources.DataType].Value;

                scalarProperty.DataType = (DataTypes)Enum.Parse(typeof(DataTypes), dataType);

                // Assign MaxLength.
                if (eScalarProperty.HasAttribute(DataModellingResources.MaxLength))
                {
                    scalarProperty.MaxLength = Convert.ToInt32(eScalarProperty.
                                                               Attributes[DataModellingResources.MaxLength].Value, CultureInfo.InvariantCulture);
                }

                // Assign Scale.
                if (eScalarProperty.HasAttribute(DataModellingResources.Scale))
                {
                    scalarProperty.Scale = Convert.ToInt32(eScalarProperty.
                                                           Attributes[DataModellingResources.Scale].Value, CultureInfo.InvariantCulture);
                }

                // Assign Precision.
                if (eScalarProperty.HasAttribute(DataModellingResources.Precision))
                {
                    scalarProperty.Precision = Convert.ToInt32(eScalarProperty.
                                                               Attributes[DataModellingResources.Precision].Value, CultureInfo.InvariantCulture);
                }

                // Assign TableName.
                scalarProperty.TableName = eScalarProperty.Attributes[DataModellingResources.TableName].Value;

                // Assign ColumnName.
                scalarProperty.ColumnName = eScalarProperty.Attributes[DataModellingResources.ColumnName].Value;

                // Assign IsFullTextIndexed.
                scalarProperty.IsFullTextIndexed = Convert.ToInt32(eScalarProperty.
                                                                   Attributes[DataModellingResources.IsFullTextIndexed].Value,
                                                                   CultureInfo.InvariantCulture) == 1 ? true : false;
            }
        private static void CompareScalarProperties(ModuleCollectionChange changes, DataModelModuleCollection originalModules, DataModelModuleCollection targetModules)
        {
            List <ScalarProperty> sourceScalarProperties = originalModules.
                                                           SelectMany(tuple => tuple.ResourceTypes).
                                                           SelectMany(tuple => tuple.ScalarProperties).ToList();

            List <ScalarProperty> targetScalarProperties = targetModules.
                                                           SelectMany(tuple => tuple.ResourceTypes).
                                                           SelectMany(tuple => tuple.ScalarProperties).ToList();

            // Compute added scalar properties.
            List <Guid> addedGuids = new List <Guid>();

            addedGuids.AddRange(targetScalarProperties.Select(tuple => tuple.Id).
                                Except(sourceScalarProperties.Select(tuple => tuple.Id)));

            changes.AddedScalarProperties.AddRange(targetScalarProperties.
                                                   Where(tuple => addedGuids.Contains(tuple.Id)));

            // Compute deleted scalar properties.
            List <Guid> removedGuids = new List <Guid>();

            removedGuids.AddRange(originalModules.SelectMany(tuple => tuple.ResourceTypes).
                                  SelectMany(tuple => tuple.ScalarProperties).Select(tuple => tuple.Id).
                                  Except
                                      (targetModules.SelectMany(tuple => tuple.ResourceTypes).
                                      SelectMany(tuple => tuple.ScalarProperties).Select(tuple => tuple.Id)));

            changes.DeletedScalarProperties.AddRange(originalModules.
                                                     SelectMany(tuple => tuple.ResourceTypes).
                                                     SelectMany(tuple => tuple.ScalarProperties).
                                                     Where(tuple => removedGuids.Contains(tuple.Id)));

            // Compute updated scalar properties. Parent for the scalar property can change.
            foreach (ScalarProperty property in originalModules.
                     SelectMany(tuple => tuple.ResourceTypes).
                     SelectMany(tuple => tuple.ScalarProperties))
            {
                ScalarProperty newProperty = targetModules.
                                             SelectMany(tuple => tuple.ResourceTypes).
                                             SelectMany(tuple => tuple.ScalarProperties).
                                             Where(tuple => tuple.Id == property.Id).FirstOrDefault();
                if (newProperty != null)
                {
                    if (
                        property.DataType != newProperty.DataType ||
                        property.Description != newProperty.Description ||
                        property.MaxLength != newProperty.MaxLength ||
                        property.Name != newProperty.Name ||
                        property.Nullable != newProperty.Nullable ||
                        property.Parent.Id != newProperty.Parent.Id ||
                        property.Precision != newProperty.Precision ||
                        property.Scale != newProperty.Scale ||
                        property.Uri != newProperty.Uri
                        )
                    {
                        changes.UpdatedScalarProperties.Add(property, newProperty);
                    }
                }
            }
        }