コード例 #1
0
        public override void Initialize()
        {
            m_CheckConstraints =
                Execute(CheckConstraintsCommandText)
                .Select(o => CheckConstraint.CreateFrom(SqlHelper, o))
                .ToList();
            m_ReferenceConstraintsByName =
                Execute(ReferenceConstraintsCommandText)
                .Select(o => ReferenceConstraint.CreateFrom(SqlHelper, o))
                .ToDictionary(x => x.ConstraintName);
            m_RelationConstraintsByName =
                Execute(RelationConstraintsCommandText)
                .Select(o => RelationConstraint.CreateFrom(SqlHelper, o))
                .ToDictionary(x => x.ConstraintName);

            m_ReferenceConstraintsByNameUq = m_ReferenceConstraintsByName.Values
                                             .ToMultiDictionary(x => x.ConstraintNameUq);
            m_ReferenceConstraintsByRelation = m_ReferenceConstraintsByName.Values
                                               .ToMultiDictionary(x => m_RelationConstraintsByName[x.ConstraintName].RelationName);
            m_RelationConstraintsByIndexName = m_RelationConstraintsByName.Values
                                               .Where(x => x.IndexName != null)
                                               .ToDictionary(x => x.IndexName);

            m_RelationConstraintsByRelation = m_RelationConstraintsByName.Values
                                              .ToMultiDictionary(x => x.RelationName);
        }
コード例 #2
0
        public static void ConstrainReference(this IClass @class, string name, IModelElement value = null)
        {
            var refinedReference = @class.LookupReference(name);

            if (refinedReference == null)
            {
                throw new ArgumentOutOfRangeException();
            }
            var refConst = new ReferenceConstraint()
            {
                Constrains = refinedReference
            };

            if (value != null)
            {
                refConst.References.Add(value);
            }
            @class.ReferenceConstraints.Add(refConst);
        }
コード例 #3
0
        /// <summary>
        /// Indicate the source/target columns for the foreign key connector
        /// </summary>
        public override string GetToolTipText(DiagramItem item)
        {
            ReferenceConstraint constraint = ((ReferenceConstraintTargetsTable)ModelElement).ReferenceConstraint;
            StringBuilder       sb         = new StringBuilder();
            string sourceTableName         = constraint.SourceTable.Name;
            string targetTableName         = constraint.TargetTable.Name;

            foreach (ColumnReference columRef in constraint.ColumnReferenceCollection)
            {
                if (sb.Length != 0)
                {
                    sb.AppendLine();
                }
                sb.Append(sourceTableName);
                sb.Append(".");
                sb.Append(columRef.SourceColumn.Name);
                sb.Append(" -> ");
                sb.Append(targetTableName);
                sb.Append(".");
                sb.Append(columRef.TargetColumn.Name);
            }
            return(sb.ToString());
        }
コード例 #4
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		public static DslModeling::LinkedElementCollection<ColumnReference> GetColumnReferenceCollection(ReferenceConstraint element)
		{
			return new DslModeling::LinkedElementCollection<ColumnReference>(element, ReferenceConstraintDomainRoleId);
		}
コード例 #5
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		public static void SetReferenceConstraint(ColumnReference element, ReferenceConstraint newReferenceConstraint)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ColumnReferenceDomainRoleId, newReferenceConstraint);
		}
コード例 #6
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Constructor
		/// Creates a ReferenceConstraintContainsColumnReference link in the same Partition as the given ReferenceConstraint
		/// </summary>
		/// <param name="source">ReferenceConstraint to use as the source of the relationship.</param>
		/// <param name="target">ColumnReference to use as the target of the relationship.</param>
		public ReferenceConstraintContainsColumnReference(ReferenceConstraint source, ColumnReference target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ReferenceConstraintContainsColumnReference.ReferenceConstraintDomainRoleId, source), new DslModeling::RoleAssignment(ReferenceConstraintContainsColumnReference.ColumnReferenceDomainRoleId, target)}, null)
		{
		}
コード例 #7
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		public static void SetTargetUniquenessConstraint(ReferenceConstraint element, UniquenessConstraint newTargetUniquenessConstraint)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ReferenceConstraintDomainRoleId, newTargetUniquenessConstraint);
		}
コード例 #8
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		public static UniquenessConstraint GetTargetUniquenessConstraint(ReferenceConstraint element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, ReferenceConstraintDomainRoleId) as UniquenessConstraint;
		}
コード例 #9
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Constructor
		/// Creates a ReferenceConstraintTargetsUniquenessConstraint link in the same Partition as the given ReferenceConstraint
		/// </summary>
		/// <param name="source">ReferenceConstraint to use as the source of the relationship.</param>
		/// <param name="target">UniquenessConstraint to use as the target of the relationship.</param>
		public ReferenceConstraintTargetsUniquenessConstraint(ReferenceConstraint source, UniquenessConstraint target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ReferenceConstraintTargetsUniquenessConstraint.ReferenceConstraintDomainRoleId, source), new DslModeling::RoleAssignment(ReferenceConstraintTargetsUniquenessConstraint.TargetUniquenessConstraintDomainRoleId, target)}, null)
		{
		}
コード例 #10
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		public static void SetTargetTable(ReferenceConstraint element, Table newTargetTable)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ReferenceConstraintDomainRoleId, newTargetTable);
		}
コード例 #11
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		public static Table GetTargetTable(ReferenceConstraint element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, ReferenceConstraintDomainRoleId) as Table;
		}
コード例 #12
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Constructor
		/// Creates a ReferenceConstraintTargetsTable link in the same Partition as the given ReferenceConstraint
		/// </summary>
		/// <param name="source">ReferenceConstraint to use as the source of the relationship.</param>
		/// <param name="target">Table to use as the target of the relationship.</param>
		public ReferenceConstraintTargetsTable(ReferenceConstraint source, Table target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ReferenceConstraintTargetsTable.ReferenceConstraintDomainRoleId, source), new DslModeling::RoleAssignment(ReferenceConstraintTargetsTable.TargetTableDomainRoleId, target)}, null)
		{
		}
コード例 #13
0
ファイル: DomainRelationships.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Constructor
		/// Creates a TableContainsReferenceConstraint link in the same Partition as the given Table
		/// </summary>
		/// <param name="source">Table to use as the source of the relationship.</param>
		/// <param name="target">ReferenceConstraint to use as the target of the relationship.</param>
		public TableContainsReferenceConstraint(Table source, ReferenceConstraint target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(TableContainsReferenceConstraint.TableDomainRoleId, source), new DslModeling::RoleAssignment(TableContainsReferenceConstraint.ReferenceConstraintDomainRoleId, target)}, null)
		{
		}
コード例 #14
0
        private static Namespace CreateCoreNamespace()
        {
            var classClass     = MetaRepository.Instance.ResolveClass(typeof(Class)) as IClass;
            var namespaceClass = MetaRepository.Instance.ResolveClass(typeof(Namespace)) as IClass;
            var referenceClass = MetaRepository.Instance.ResolveClass(typeof(Reference)) as IClass;
            var stringType     = MetaRepository.Instance.Resolve("http://nmf.codeplex.com/nmeta/#//String/") as IPrimitiveType;

            var core = new Namespace()
            {
                Name   = "DeepADL",
                Uri    = new Uri("http://github.com/georghinkel/DeepADL/1.0"),
                Prefix = "core"
            };

            var coreModel = new Model()
            {
                ModelUri = core.Uri
            };

            coreModel.RootElements.Add(core);

            var componentType = new Class()
            {
                Name       = "ComponentType",
                IsAbstract = false
            };

            componentType.BaseTypes.Add(classClass);
            core.Types.Add(componentType);

            var requiredInterface = new Class()
            {
                Name       = "RequiredInterface",
                IsAbstract = false
            };

            requiredInterface.BaseTypes.Add(referenceClass);
            core.Types.Add(requiredInterface);

            var signature = new Class()
            {
                Name       = "Signature",
                IsAbstract = false
            };
            var signatureName = new NMF.Models.Meta.Attribute()
            {
                Name = "Name",
                Type = stringType
            };

            signature.Attributes.Add(signatureName);
            signature.Identifier = signatureName;
            core.Types.Add(signature);

            var service = new Class()
            {
                Name       = "Service",
                IsAbstract = false
            };
            var serviceName = new NMF.Models.Meta.Attribute()
            {
                Name = "Name",
                Type = stringType
            };

            service.Attributes.Add(serviceName);
            service.Identifier = serviceName;
            service.References.Add(new Reference()
            {
                Name          = "Implements",
                ReferenceType = signature,
            });
            core.Types.Add(service);


            var assemblyContext = new Class()
            {
                Name       = "AssemblyContext",
                IsAbstract = true
            };

            assemblyContext.BaseTypes.Add(referenceClass);
            ApplyReferenceConstraints(assemblyContext, false);
            assemblyContext.ConstrainReference("Refines");

            var interfaceDecl = new Class()
            {
                Name       = "Interface",
                IsAbstract = false
            };

            interfaceDecl.BaseTypes.Add(classClass);
            core.Types.Add(interfaceDecl);
            interfaceDecl.References.Add(new Reference()
            {
                Name          = "Signatures",
                UpperBound    = -1,
                ReferenceType = signature,
                IsContainment = true
            });
            interfaceDecl.ConstrainReference("References");
            interfaceDecl.ConstrainReference("ReferenceConstraints");
            interfaceDecl.ConstrainReference("Attributes");
            interfaceDecl.ConstrainReference("AttributeConstraints");
            interfaceDecl.ConstrainReference("InstanceOf");
            interfaceDecl.ConstrainReference("Events");
            interfaceDecl.ConstrainReference("Operations");
            interfaceDecl.ConstrainReference("Identifier");
            interfaceDecl.ConstrainAttribute("IdentifierScope", nameof(IdentifierScope.Local));
            interfaceDecl.ConstrainAttribute("IsAbstract", "False");
            interfaceDecl.ConstrainReference("BaseTypes", assemblyContext);

            core.Types.Add(assemblyContext);

            var delegateType = new Class()
            {
                Name       = "Delegate",
                IsAbstract = false
            };

            delegateType.BaseTypes.Add(classClass);
            delegateType.ConstrainReference("References");
            delegateType.ConstrainReference("ReferenceConstraints");
            delegateType.ConstrainReference("Attributes");
            delegateType.ConstrainReference("AttributeConstraints");
            delegateType.ConstrainReference("InstanceOf");
            delegateType.ConstrainReference("Events");
            delegateType.ConstrainReference("Operations");
            delegateType.ConstrainReference("Identifier");
            delegateType.ConstrainAttribute("IdentifierScope", nameof(IdentifierScope.Local));
            delegateType.ConstrainAttribute("IsAbstract", "False");

            core.Types.Add(delegateType);

            var system = new Class()
            {
                Name       = "SystemArchitecture",
                IsAbstract = false
            };

            system.BaseTypes.Add(classClass);
            system.ConstrainReference("ReferenceConstraints");
            system.ConstrainReference("Attributes");
            system.ConstrainReference("AttributeConstraints");
            system.ConstrainReference("Events");
            system.ConstrainReference("Operations");
            system.ConstrainReference("Identifier");
            system.ConstrainReference("InstanceOf");
            system.ConstrainAttribute("IdentifierScope", nameof(IdentifierScope.Local));
            system.ConstrainAttribute("IsAbstract", "False");
            core.Types.Add(system);

            componentType.References.Add(new Reference()
            {
                Name          = "RequiredInterfaces",
                ReferenceType = requiredInterface,
                UpperBound    = -1,
                Refines       = classClass.LookupReference("References"),
                IsContainment = true
            });
            componentType.References.Add(new Reference()
            {
                Name          = "ProvidedInterfaces",
                UpperBound    = -1,
                ReferenceType = interfaceDecl,
                Refines       = classClass.LookupReference("BaseTypes")
            });
            componentType.References.Add(new Reference()
            {
                Name          = "Services",
                UpperBound    = -1,
                ReferenceType = service,
                IsContainment = true
            });
            componentType.ConstrainReference("ReferenceConstraints");
            componentType.ConstrainReference("Attributes");
            componentType.ConstrainReference("AttributeConstraints");
            componentType.ConstrainReference("Events");
            componentType.ConstrainReference("Identifier");
            componentType.ConstrainAttribute("IdentifierScope", nameof(IdentifierScope.Local));
            componentType.ConstrainAttribute("IsAbstract", "False");
            componentType.ConstrainReference("Operations");
            componentType.ConstrainReference("InstanceOf");
            assemblyContext.InstanceOf = componentType;

            var baseTypeAssemblyContext = new ReferenceConstraint()
            {
                Constrains = classClass.LookupReference("BaseTypes")
            };

            baseTypeAssemblyContext.References.Add(assemblyContext);
            componentType.ReferenceConstraints.Add(baseTypeAssemblyContext);

            requiredInterface.References.Add(new Reference()
            {
                Name          = "Interface",
                ReferenceType = interfaceDecl,
                Refines       = referenceClass.LookupReference("ReferenceType")
            });
            ApplyReferenceConstraints(requiredInterface, false);

            var resourceContainer = new Class()
            {
                Name = "ResourceContainer"
            };
            var resourceContainerName = new NMF.Models.Meta.Attribute()
            {
                Name = "Name",
                Type = stringType,
            };

            core.Types.Add(resourceContainer);
            resourceContainer.Attributes.Add(resourceContainerName);
            resourceContainer.Identifier = resourceContainerName;

            var resourceEnvironment = new Class()
            {
                IsAbstract = false,
                Name       = "ResourceEnvironment"
            };

            core.Types.Add(resourceEnvironment);
            var resourceContainerContainer = new Reference()
            {
                Name          = "Environment",
                ReferenceType = resourceEnvironment,
                UpperBound    = 1,
                LowerBound    = 1
            };

            resourceContainer.References.Add(resourceContainerContainer);
            resourceEnvironment.References.Add(new Reference()
            {
                Name          = "Container",
                IsContainment = true,
                ReferenceType = resourceContainer,
                UpperBound    = -1,
                Opposite      = resourceContainerContainer
            });

            var resourceLink = new Class()
            {
                IsAbstract = false,
                Name       = "ResourceLink"
            };

            core.Types.Add(resourceLink);
            var resourceLinkContainer = new Reference()
            {
                Name          = "Links",
                ReferenceType = resourceLink,
                IsContainment = true,
                UpperBound    = -1
            };

            resourceEnvironment.References.Add(resourceLinkContainer);
            resourceLink.References.Add(new Reference()
            {
                Name          = "Environment",
                ReferenceType = resourceEnvironment,
                IsContainment = false,
                UpperBound    = 1,
                LowerBound    = 1,
                Opposite      = resourceLinkContainer
            });
            resourceLink.References.Add(new Reference()
            {
                Name          = "Connects",
                ReferenceType = resourceContainer,
                IsContainment = false,
                UpperBound    = -1
            });

            assemblyContext.ConstrainReference("ReferenceType", resourceContainer);

            system.References.Add(new Reference()
            {
                Name          = "AssemblyContexts",
                ReferenceType = assemblyContext,
                UpperBound    = -1,
                IsContainment = true,
                Refines       = classClass.LookupReference("References")
            });

            var systemSpec = new Class()
            {
                Name       = "SystemSpecification",
                IsAbstract = false
            };

            core.Types.Add(systemSpec);
            systemSpec.BaseTypes.Add(classClass);
            systemSpec.ConstrainReference("BaseTypes", system);
            systemSpec.References.Add(new Reference()
            {
                Name          = "PublicInterfaces",
                ReferenceType = requiredInterface,
                IsContainment = true,
                UpperBound    = -1,
                Refines       = classClass.LookupReference("References")
            });
            systemSpec.ConstrainReference("ReferenceConstraints");
            systemSpec.ConstrainReference("Attributes");
            systemSpec.ConstrainReference("AttributeConstraints");
            systemSpec.ConstrainReference("Events");
            systemSpec.ConstrainReference("Operations");
            systemSpec.ConstrainReference("Identifier");
            systemSpec.ConstrainAttribute("IdentifierScope", nameof(IdentifierScope.Local));
            systemSpec.ConstrainAttribute("IsAbstract", "False");
            systemSpec.ConstrainReference("InstanceOf");

            var allocation = new Class()
            {
                Name       = "SystemAllocation",
                IsAbstract = true,
                InstanceOf = system
            };

            core.Types.Add(allocation);
            allocation.References.Add(new Reference()
            {
                Name          = "Environment",
                ReferenceType = resourceEnvironment
            });

            system.ConstrainReference("BaseTypes", allocation);

            var repository = new Class()
            {
                Name       = "Repository",
                IsAbstract = false
            };

            repository.BaseTypes.Add(namespaceClass);
            var repositoryTypes = new Reference()
            {
                Name          = "ComponentTypes",
                ReferenceType = componentType,
                UpperBound    = -1,
                IsContainment = true,
                Refines       = namespaceClass.LookupReference("Types")
            };

            repository.References.Add(repositoryTypes);
            var repositoryInterfaces = new Reference()
            {
                Name          = "Interfaces",
                ReferenceType = interfaceDecl,
                UpperBound    = -1,
                IsContainment = true,
                Refines       = namespaceClass.LookupReference("Types")
            };

            repository.References.Add(repositoryInterfaces);
            var repositorySystemSpecs = new Reference()
            {
                Name          = "SystemSpecifications",
                ReferenceType = systemSpec,
                UpperBound    = -1,
                IsContainment = true,
                Refines       = namespaceClass.LookupReference("Types")
            };

            repository.References.Add(repositorySystemSpecs);
            var repositoryDelegates = new Reference()
            {
                Name          = "Delegates",
                ReferenceType = delegateType,
                UpperBound    = -1,
                IsContainment = true,
                Refines       = namespaceClass.LookupReference("Types")
            };

            repository.References.Add(repositoryDelegates);
            repository.ConstrainReference("ChildNamespaces");
            core.Types.Add(repository);

            componentType.References.Add(new Reference()
            {
                Name          = "Repository",
                ReferenceType = repository,
                UpperBound    = 1,
                LowerBound    = 1,
                IsContainment = false,
                Refines       = classClass.LookupReference("Namespace"),
                Opposite      = repositoryTypes
            });
            interfaceDecl.References.Add(new Reference()
            {
                Name          = "Repository",
                ReferenceType = repository,
                UpperBound    = 1,
                LowerBound    = 1,
                IsContainment = false,
                Refines       = classClass.LookupReference("Namespace"),
                Opposite      = repositoryInterfaces
            });
            systemSpec.References.Add(new Reference()
            {
                Name          = "Repository",
                ReferenceType = repository,
                UpperBound    = 1,
                LowerBound    = 1,
                IsContainment = false,
                Refines       = classClass.LookupReference("Namespace"),
                Opposite      = repositorySystemSpecs
            });

            var delegationConnector = new Class()
            {
                Name       = "DelegationConnector",
                IsAbstract = true
            };

            delegateType.References.Add(new Reference()
            {
                Name          = "Repository",
                UpperBound    = 1,
                LowerBound    = 1,
                IsContainment = false,
                ReferenceType = repository,
                Refines       = classClass.LookupReference("Namespace"),
                Opposite      = repositoryDelegates
            });
            delegateType.ConstrainReference("BaseTypes", delegationConnector);
            delegateType.References.Add(new Reference()
            {
                Name          = "Type",
                UpperBound    = 1,
                LowerBound    = 1,
                IsContainment = false,
                ReferenceType = interfaceDecl,
                Refines       = classClass.LookupReference("BaseTypes")
            });
            delegationConnector.InstanceOf = delegateType;
            delegationConnector.References.Add(new Reference()
            {
                Name          = "Port",
                LowerBound    = 1,
                UpperBound    = 1,
                ReferenceType = requiredInterface,
                IsContainment = false
            });

            core.Types.Add(delegationConnector);

            var compositeComponentType = new Class()
            {
                Name       = "CompositeComponent",
                IsAbstract = false
            };

            compositeComponentType.BaseTypes.Add(componentType);
            compositeComponentType.References.Add(new Reference()
            {
                Name          = "Assemblies",
                LowerBound    = 1,
                UpperBound    = -1,
                IsContainment = true,
                ReferenceType = assemblyContext
            });
            compositeComponentType.References.Add(new Reference()
            {
                Name          = "ExposedAssemblies",
                LowerBound    = 1,
                UpperBound    = -1,
                IsContainment = false,
                ReferenceType = assemblyContext
            });
            compositeComponentType.References.Add(new Reference()
            {
                Name          = "Delegations",
                LowerBound    = 0,
                UpperBound    = -1,
                IsContainment = true,
                ReferenceType = delegationConnector
            });

            return(core);
        }