예제 #1
0
        public Type FindType(QualName typeName)
        {
            Type t = Model.Types.GetByName(typeName.FullName);

            if (t == null)
            {
                t = Model.Types.GetByName(QualName.MakeFullName(Const.EmptyName, typeName.Name));
            }
            if (t == null)
            {
                // Try to find by name
                int typesCount = 0;
                foreach (Type t2 in this)
                {
                    if (t2.Name.Equals(typeName.Name))
                    {
                        t = t2;
                        typesCount++;
                    }
                }
                if (typesCount > 1)
                {
                    throw new GlException("Ambigous type name \"{0}\". You should specify schema", typeName.Name);
                }
            }
            return(t);
        }
예제 #2
0
 public override string ToString()
 {
     return(String.Format("{0} ({1}-{2}): <{3}>--{4}--<{5}>",
                          GetType().Name,
                          Name,
                          Name2,
                          QualName.MakeFullName(schema, entityName),
                          CardinalityToString(cardinality),
                          QualName.MakeFullName(schema2, entityName2)));
 }
예제 #3
0
        private Entity UpdateEntity(string entSchema, string entName)
        {
            Entity result = Model.Entities.GetByName(QualName.MakeFullName(entSchema, entName));

            if (result == null)
            {
                throw new GlException("Specified entity not found: {0}. {1}",
                                      QualName.MakeFullName(entSchema, entName),
                                      this);
            }
            return(result);
        }
예제 #4
0
        public void ImplicitlyCreatedMetaobjectsTest()
        {
            GenieLamp lamp  = InitializationTest.LoadTestProject("TestProject.xml");
            Model     model = lamp.Model;

            Entity storeDoc = model.Entities.GetByName(QualName.MakeFullName(model.DefaultSchema, "StoreDoc"));

            Assert.IsNotNull(storeDoc, "Entity not exists");
            Generator gen = model.Generators.GetByName(QualName.MakeFullName(storeDoc.Schema, Generator.DefaultName(storeDoc)));

            Assert.IsNotNull(gen, "Implicit generator");
            Assert.AreEqual("SEQ_STORE_DOC", gen.Persistence.Name, "Implicit generator persistence name");
            Assert.AreEqual(Int32.MaxValue, gen.MaxValue, "Max value");
        }
예제 #5
0
        public void IndexesTest()
        {
            GenieLamp lamp  = InitializationTest.LoadTestProject("TestProject.xml");
            Model     model = lamp.Model;

            Entity en = model.Entities.GetByName(QualName.MakeFullName(model.DefaultSchema, "StoreDoc"));

            Assert.IsNotNull(en, "Entity not exists");
            int  indexCount        = 0;
            bool hasCompositeIndex = false;

            foreach (Index ix in model.PhysicalModel.Indexes.GetByEntity(en))
            {
                if (ix.DefinedInModel)
                {
                    Assert.IsTrue(ix.Generate, "Index should be generated");
                    indexCount++;
                    if (ix.Columns.Count == 1)
                    {
                        if (ix.Columns[0].Attribute.Name == "RefNum")
                        {
                            Assert.IsTrue(ix.Unique, "Index should be unique");
                            Assert.AreEqual(ColumnOrder.Desc, ix.Columns[0].Order);
                        }
                        else if (ix.Columns[0].Attribute.Name == "Name")
                        {
                            Assert.IsFalse(ix.Unique, "Index should be not unique");
                            Assert.AreEqual(ColumnOrder.Asc, ix.Columns[0].Order);
                        }
                    }
                    else if (ix.Columns.Count > 1)
                    {
                        hasCompositeIndex = true;
                    }
                }
            }
            Assert.AreEqual(3, indexCount, "Invalid index count");
            Assert.IsTrue(hasCompositeIndex, "Composite index absent");
        }
예제 #6
0
        public void ConstraintIndexPersistentNameTest()
        {
            GenieLamp lamp  = InitializationTest.LoadTestProject("TestProject.xml");
            Model     model = lamp.Model;

            Entity en = model.Entities.GetByName(QualName.MakeFullName(model.DefaultSchema, "ProductType"));

            Assert.IsNotNull(en, "ProductType entity not exists");
            UniqueId u = null;

            foreach (UniqueId u2 in en.Constraints.UniqueIds)
            {
                if (u2.Attributes.Count == 1 && u2.Attributes[0].Name == "Code")
                {
                    u = u2;
                    break;
                }
            }
            Assert.IsNotNull(u, "Constraint not found");
            Assert.IsTrue(u.Persistence.NameDefined, "Constraint does not have index name");
            Assert.AreEqual("IX_CUSTOM_PRODUCT_TYPE", u.Persistence.Name, "Constraint index name was changed");
            Assert.IsNotNull(u.Index, "Relation does not have index");
            Assert.AreEqual(u.Persistence.Name, u.Index.Name, "Relation persistent name was changed");
        }
예제 #7
0
 protected override string GetFullName()
 {
     return(QualName.MakeFullName(schema, name));
 }
예제 #8
0
 public string GetClassName_SortOrder(bool fullName)
 {
     return(QualName.MakeFullName(fullName ? this.QueriesNamespace : Const.EmptyName, ClassName_SortOrder));
 }
예제 #9
0
 public string GetClassName_QueryParams(bool fullName)
 {
     return(QualName.MakeFullName(fullName ? this.QueriesNamespace : Const.EmptyName, ClassName_QueryParams));
 }