示例#1
0
        public void SchEd_WriterCalling_CreateNodeType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            ed1.CreatePropertyType("PT1", DataType.String);
            SetSchemaItemId(ed1.PropertyTypes["PT1"], 1);
            //-- create current
            ed2.CreatePropertyType("PT1", DataType.String);
            SetSchemaItemId(ed2.PropertyTypes["PT1"], 1);

            //-- edit
            ed2.CreateNodeType(null, "NT1");
            ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT1"]);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string expectedLog = @"
				Open();
				CreateNodeType(parent=<[null]>, name=<NT1>, className=<>);
				AddPropertyTypeToPropertySet(propertyType=<PT1>, owner=<NT1>, isDeclared=<True>);
				Close();
				"                .Replace("\r\n", "").Replace("\t", "");
            string log         = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == expectedLog);
        }
示例#2
0
        public void SchEd_WriterCalling_ReCreatePermissionType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            ed1.CreatePermissionType("P1");
            SetSchemaItemId(ed1.PermissionTypes["P1"], 1);
            //-- create current
            ed2.CreatePermissionType("P1");
            SetSchemaItemId(ed2.PermissionTypes["P1"], 1);

            //-- edit
            ed2.DeletePermissionType(ed2.PermissionTypes["P1"]);
            ed2.CreatePermissionType("P1");

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string log = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == "Open();DeletePermissionType(permissionType=<P1>);CreatePermissionType(name=<P1>);Close();");
        }
示例#3
0
        public void SchEd_WriterCalling_ModifyNodeType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            ed1.CreatePropertyType("PT1", DataType.String);
            SetSchemaItemId(ed1.PropertyTypes["PT1"], 1);
            ed1.CreateNodeType(null, "NT1");
            SetSchemaItemId(ed1.NodeTypes["NT1"], 1);
            ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT1"], ed1.NodeTypes["NT1"]);
            //-- create current
            ed2.CreatePropertyType("PT1", DataType.String);
            SetSchemaItemId(ed2.PropertyTypes["PT1"], 1);
            ed2.CreateNodeType(null, "NT1");
            SetSchemaItemId(ed2.NodeTypes["NT1"], 1);
            ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT1"]);

            //-- edit
            ed2.ModifyNodeType(ed2.NodeTypes["NT1"], "ClassName2");

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string log = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == "Open();ModifyNodeType(nodeType=<NT1>, parent=<[null]>, className=<ClassName2>);Close();");
        }
示例#4
0
        public void SchEd_WriterCalling_CreateContentListType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            ed1.CreateContentListPropertyType(DataType.String, 0);
            SetSchemaItemId(ed1.PropertyTypes["#String_0"], 1);
            //-- create current
            ed2.CreateContentListPropertyType(DataType.String, 0);
            SetSchemaItemId(ed2.PropertyTypes["#String_0"], 1);

            //-- edit
            ed2.CreateContentListType("LT1");
            ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["#String_0"], ed2.ContentListTypes["LT1"]);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string expectedLog = @"
				Open();
				CreateContentListType(name=<LT1>);
				AddPropertyTypeToPropertySet(propertyType=<#String_0>, owner=<LT1>, isDeclared=<True>);
				Close();
				"                .Replace("\r\n", "").Replace("\t", "");
            string log         = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == expectedLog);
        }
示例#5
0
        public void SchEd_WriterCalling_RemoveOverriddenPropertyFromNodeType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            PropertyType pt1 = CreatePropertyType(ed1, "PT1", DataType.String, 1);
            NodeType     nt1 = CreateNodeType(ed1, null, "NT1", "NT1", 1);
            NodeType     nt2 = CreateNodeType(ed1, nt1, "NT2", "NT2", 2);
            NodeType     nt3 = CreateNodeType(ed1, nt2, "NT3", "NT3", 3);
            NodeType     nt4 = CreateNodeType(ed1, nt3, "NT4", "NT4", 4);
            NodeType     nt5 = CreateNodeType(ed1, nt4, "NT5", "NT5", 5);

            ed1.AddPropertyTypeToPropertySet(pt1, nt4);
            ed1.AddPropertyTypeToPropertySet(pt1, nt2);

            //-- create current
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(ed1.ToXml());
            ed2.Load(xd);

            //-- edit
            ed2.RemovePropertyTypeFromPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT4"]);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string log = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == "Open();UpdatePropertyTypeDeclarationState(propType=<PT1>, newSet=<NT4>, isDeclared=<False>);Close();");
        }
示例#6
0
        public void SchEd_WriterCalling_ReCreatePropertyType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            ed1.CreatePropertyType("PT1", DataType.String);
            SetSchemaItemId(ed1.PropertyTypes["PT1"], 1);
            //-- create current
            ed2.CreatePropertyType("PT1", DataType.String);
            SetSchemaItemId(ed2.PropertyTypes["PT1"], 1);

            //-- edit
            ed2.DeletePropertyType(ed2.PropertyTypes["PT1"]);
            ed2.CreatePropertyType("PT1", DataType.String);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string log = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == "Open();CreatePropertyType(name=<PT1>, dataType=<String>, mapping=<0>, isContentListProperty=<False>);DeletePropertyType(propertyType=<PT1>);Close();");
        }
示例#7
0
        //================================================= Tools =================================================

        private string InstallContentType(string contentTypeDefInstall, string contentTypeDefModify)
        {
            SchemaEditor ed1 = new SchemaEditor();
            SchemaEditor ed2 = new SchemaEditor();

            ContentTypeManagerAccessor ctmAcc = new ContentTypeManagerAccessor(ContentTypeManager.Current);
            ContentType cts = ctmAcc.LoadOrCreateNew(contentTypeDefInstall);

            if (contentTypeDefModify != null)
            {
                cts.Save(false);
                var parent = ContentType.GetByName(cts.ParentName);
                ContentTypeManager.Current.AddContentType(cts);
            }

            ctmAcc.ApplyChangesInEditor(cts, ed2);

            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            ed2Acc.RegisterSchema(ed1, wr);

            if (contentTypeDefModify != null)
            {
                //-- Id-k beallitasa es klonozas
                SchemaEditor         ed3    = new SchemaEditor();
                SchemaEditorAccessor ed3Acc = new SchemaEditorAccessor(ed3);
                SchemaItemAccessor   schItemAcc;
                int id = 1;
                foreach (PropertyType pt in ed2.PropertyTypes)
                {
                    PropertyType clone = ed3.CreatePropertyType(pt.Name, pt.DataType, pt.Mapping);
                    schItemAcc    = new SchemaItemAccessor(pt);
                    schItemAcc.Id = id++;
                    schItemAcc    = new SchemaItemAccessor(clone);
                    schItemAcc.Id = pt.Id;
                }
                id = 1;
                foreach (NodeType nt in ed2.NodeTypes)
                {
                    NodeType clone = ed3.CreateNodeType(nt.Parent, nt.Name, nt.ClassName);
                    foreach (PropertyType pt in nt.PropertyTypes)
                    {
                        ed3.AddPropertyTypeToPropertySet(ed3.PropertyTypes[pt.Name], clone);
                    }
                    schItemAcc    = new SchemaItemAccessor(nt);
                    schItemAcc.Id = id++;
                    schItemAcc    = new SchemaItemAccessor(clone);
                    schItemAcc.Id = nt.Id;
                }

                cts = ctmAcc.LoadOrCreateNew(contentTypeDefModify);
                ctmAcc.ApplyChangesInEditor(cts, ed3);
                wr = new TestSchemaWriter();
                ed3Acc.RegisterSchema(ed2, wr);
            }

            return(wr.Log);
        }
示例#8
0
        public void SchEd_WriterCalling_ModifyNodeType_ChangeParent()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            ed1.CreatePropertyType("PT1", DataType.String); SetSchemaItemId(ed1.PropertyTypes["PT1"], 1);
            ed1.CreatePropertyType("PT2", DataType.String); SetSchemaItemId(ed1.PropertyTypes["PT1"], 2);
            ed1.CreatePropertyType("PT3", DataType.String); SetSchemaItemId(ed1.PropertyTypes["PT1"], 3);
            NodeType nt1 = ed1.CreateNodeType(null, "NT1"); SetSchemaItemId(ed1.NodeTypes["NT1"], 1);
            NodeType nt2 = ed1.CreateNodeType(null, "NT2"); SetSchemaItemId(ed1.NodeTypes["NT2"], 2);
            NodeType nt3 = ed1.CreateNodeType(nt1, "NT3"); SetSchemaItemId(ed1.NodeTypes["NT3"], 3);

            ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT1"], ed1.NodeTypes["NT1"]);
            ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT2"], ed1.NodeTypes["NT2"]);
            ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT3"], ed1.NodeTypes["NT3"]);

            //-- create current
            ed2.CreatePropertyType("PT1", DataType.String); SetSchemaItemId(ed2.PropertyTypes["PT1"], 1);
            ed2.CreatePropertyType("PT2", DataType.String); SetSchemaItemId(ed2.PropertyTypes["PT1"], 2);
            ed2.CreatePropertyType("PT3", DataType.String); SetSchemaItemId(ed2.PropertyTypes["PT1"], 3);
            nt1 = ed2.CreateNodeType(null, "NT1"); SetSchemaItemId(ed2.NodeTypes["NT1"], 1);
            nt2 = ed2.CreateNodeType(null, "NT2"); SetSchemaItemId(ed2.NodeTypes["NT2"], 2);
            nt3 = ed2.CreateNodeType(nt1, "NT3"); SetSchemaItemId(ed2.NodeTypes["NT3"], 3);
            ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT1"]);
            ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT2"], ed2.NodeTypes["NT2"]);
            ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT3"], ed2.NodeTypes["NT3"]);

            //-- edit
            ed2.ModifyNodeType(ed2.NodeTypes["NT3"], ed2.NodeTypes["NT2"]);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string expectedLog = @"
				Open();
				ModifyNodeType(nodeType=<NT3>, parent=<NT2>, className=<>);
				RemovePropertyTypeFromPropertySet(propertyType=<PT1>, owner=<NT3>);
				AddPropertyTypeToPropertySet(propertyType=<PT2>, owner=<NT3>, isDeclared=<True>);
				Close();
				"                .Replace("\r\n", "").Replace("\t", "").Replace(" ", "");
            string log         = wr.Log.Replace("\r\n", "").Replace(" ", "");

            Assert.IsTrue(log == expectedLog, "#1");
            Assert.IsNull(nt1.Parent, "#2");
            Assert.IsNull(nt2.Parent, "#3");
            Assert.IsTrue(nt3.Parent == nt2, "#4");
            Assert.IsTrue(nt1.PropertyTypes.Count == 1, "#5");
            Assert.IsTrue(nt2.PropertyTypes.Count == 1, "#6");
            Assert.IsTrue(nt3.PropertyTypes.Count == 2, "#7");
            Assert.IsNotNull(nt1.PropertyTypes["PT1"], "#8");
            Assert.IsNotNull(nt2.PropertyTypes["PT2"], "#9");
            Assert.IsNotNull(nt3.PropertyTypes["PT3"], "#10");
            Assert.IsNull(nt3.PropertyTypes["PT1"], "#11");
            Assert.IsNotNull(nt3.PropertyTypes["PT2"], "#12");
        }
示例#9
0
        public void SchEd_WriterCalling_CreatePropertyType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- edit
            ed2.CreatePropertyType("PT1", DataType.String);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string log = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == "Open();CreatePropertyType(name=<PT1>, dataType=<String>, isContentListProperty=<False>);Close();");
        }
示例#10
0
        public void SchEd_WriterCalling_Complex_01()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            PropertyType ptX = CreatePropertyType(ed1, "X", DataType.String, 1);
            PropertyType ptY = CreatePropertyType(ed1, "Y", DataType.String, 2);
            PropertyType ptZ = CreatePropertyType(ed1, "Z", DataType.String, 3);
            NodeType     ntA = CreateNodeType(ed1, null, "A", null, 1);
            NodeType     ntB = CreateNodeType(ed1, ntA, "B", null, 2);
            NodeType     ntC = CreateNodeType(ed1, ntB, "C", null, 3);

            ed1.AddPropertyTypeToPropertySet(ptX, ntB);
            ed1.AddPropertyTypeToPropertySet(ptY, ntC);
            ed1.AddPropertyTypeToPropertySet(ptX, ntA);

            //-- create current
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(ed1.ToXml());
            ed2.Load(xd);
            ptX = ed2.PropertyTypes["X"];
            ptY = ed2.PropertyTypes["Y"];
            ptZ = ed2.PropertyTypes["Z"];
            ntA = ed2.NodeTypes["A"];
            ntB = ed2.NodeTypes["B"];
            ntC = ed2.NodeTypes["C"];

            //-- edit
            ed2.RemovePropertyTypeFromPropertySet(ptX, ntA);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string log = wr.Log.Replace("\r\n", "");

            Assert.IsTrue(log == "Open();RemovePropertyTypeFromPropertySet(propertyType=<X>, owner=<A>);Close();");
        }
示例#11
0
        public void SchEd_WriterCalling_AddPropertyToAncestorNodeType()
        {
            SchemaEditor         ed1    = new SchemaEditor();
            SchemaEditor         ed2    = new SchemaEditor();
            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            //-- create original
            PropertyType pt1 = CreatePropertyType(ed1, "PT1", DataType.String, 1);
            NodeType     nt1 = CreateNodeType(ed1, null, "NT1", "NT1", 1);
            NodeType     nt2 = CreateNodeType(ed1, nt1, "NT2", "NT2", 2);
            NodeType     nt3 = CreateNodeType(ed1, nt2, "NT3", "NT3", 3);
            NodeType     nt4 = CreateNodeType(ed1, nt3, "NT4", "NT4", 4);
            NodeType     nt5 = CreateNodeType(ed1, nt4, "NT5", "NT5", 5);

            ed1.AddPropertyTypeToPropertySet(pt1, nt4);

            //-- create current
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(ed1.ToXml());
            ed2.Load(xd);

            //-- edit
            ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT2"]);

            //-- register
            ed2Acc.RegisterSchema(ed1, wr);

            //-- test
            string expectedLog = @"
				Open();
				AddPropertyTypeToPropertySet(propertyType=<PT1>, owner=<NT2>, isDeclared=<True>);
				AddPropertyTypeToPropertySet(propertyType=<PT1>, owner=<NT3>, isDeclared=<False>);
				Close();
				"                .Replace("\r\n", "").Replace("\t", "").Replace(" ", "");
            string log         = wr.Log.Replace("\r\n", "").Replace(" ", "");

            Assert.IsTrue(log == expectedLog);
        }
示例#12
0
		public void SchEd_WriterCalling_ModifyNodeType_ChangeParent()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			ed1.CreatePropertyType("PT1", DataType.String); SetSchemaItemId(ed1.PropertyTypes["PT1"], 1);
			ed1.CreatePropertyType("PT2", DataType.String); SetSchemaItemId(ed1.PropertyTypes["PT1"], 2);
			ed1.CreatePropertyType("PT3", DataType.String); SetSchemaItemId(ed1.PropertyTypes["PT1"], 3);
			NodeType nt1 = ed1.CreateNodeType(null, "NT1"); SetSchemaItemId(ed1.NodeTypes["NT1"], 1);
			NodeType nt2 = ed1.CreateNodeType(null, "NT2"); SetSchemaItemId(ed1.NodeTypes["NT2"], 2);
			NodeType nt3 = ed1.CreateNodeType(nt1, "NT3"); SetSchemaItemId(ed1.NodeTypes["NT3"], 3);
			ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT1"], ed1.NodeTypes["NT1"]);
			ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT2"], ed1.NodeTypes["NT2"]);
			ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT3"], ed1.NodeTypes["NT3"]);

			//-- create current
			ed2.CreatePropertyType("PT1", DataType.String); SetSchemaItemId(ed2.PropertyTypes["PT1"], 1);
			ed2.CreatePropertyType("PT2", DataType.String); SetSchemaItemId(ed2.PropertyTypes["PT1"], 2);
			ed2.CreatePropertyType("PT3", DataType.String); SetSchemaItemId(ed2.PropertyTypes["PT1"], 3);
			nt1 = ed2.CreateNodeType(null, "NT1"); SetSchemaItemId(ed2.NodeTypes["NT1"], 1);
			nt2 = ed2.CreateNodeType(null, "NT2"); SetSchemaItemId(ed2.NodeTypes["NT2"], 2);
			nt3 = ed2.CreateNodeType(nt1, "NT3"); SetSchemaItemId(ed2.NodeTypes["NT3"], 3);
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT1"]);
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT2"], ed2.NodeTypes["NT2"]);
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT3"], ed2.NodeTypes["NT3"]);

			//-- edit
			ed2.ModifyNodeType(ed2.NodeTypes["NT3"], ed2.NodeTypes["NT2"]);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string expectedLog = @"
				Open();
				ModifyNodeType(nodeType=<NT3>, parent=<NT2>, className=<>);
				RemovePropertyTypeFromPropertySet(propertyType=<PT1>, owner=<NT3>);
				AddPropertyTypeToPropertySet(propertyType=<PT2>, owner=<NT3>, isDeclared=<True>);
				Close();
				".Replace("\r\n", "").Replace("\t", "").Replace(" ", "");
			string log = wr.Log.Replace("\r\n", "").Replace(" ", "");
			Assert.IsTrue(log == expectedLog, "#1");
			Assert.IsNull(nt1.Parent, "#2");
			Assert.IsNull(nt2.Parent, "#3");
			Assert.IsTrue(nt3.Parent == nt2, "#4");
			Assert.IsTrue(nt1.PropertyTypes.Count == 1, "#5");
			Assert.IsTrue(nt2.PropertyTypes.Count == 1, "#6");
			Assert.IsTrue(nt3.PropertyTypes.Count == 2, "#7");
			Assert.IsNotNull(nt1.PropertyTypes["PT1"], "#8");
			Assert.IsNotNull(nt2.PropertyTypes["PT2"], "#9");
			Assert.IsNotNull(nt3.PropertyTypes["PT3"], "#10");
			Assert.IsNull(nt3.PropertyTypes["PT1"], "#11");
			Assert.IsNotNull(nt3.PropertyTypes["PT2"], "#12");
		}
示例#13
0
        public void SchEd_WriterCalling_DeleteContentListType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			ed1.CreateContentListPropertyType(DataType.String, 0);
			SetSchemaItemId(ed1.PropertyTypes["#String_0"], 1);
			ed1.CreateContentListType("LT1");
			SetSchemaItemId(ed1.ContentListTypes["LT1"], 1);
			ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["#String_0"], ed1.ContentListTypes["LT1"]);
			//-- create current
			ed2.CreateContentListPropertyType(DataType.String, 0);
			SetSchemaItemId(ed2.PropertyTypes["#String_0"], 1);
			ed2.CreateContentListType("LT1");
			SetSchemaItemId(ed2.ContentListTypes["LT1"], 1);
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["#String_0"], ed2.ContentListTypes["LT1"]);

			//-- edit
			ed2.DeleteContentListType(ed2.ContentListTypes["LT1"]);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string expectedLog = @"
				Open();
				DeleteContentListType(contentListType=<LT1>);
				Close();
				".Replace("\r\n", "").Replace("\t", "").Replace(" ", "");
			string log = wr.Log.Replace("\r\n", "").Replace(" ", "");
			Assert.IsTrue(log == expectedLog);
		}
示例#14
0
		public void SchEd_WriterCalling_ReCreateNodeType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			ed1.CreatePropertyType("PT1", DataType.String);
			SetSchemaItemId(ed1.PropertyTypes["PT1"], 1);
			ed1.CreateNodeType(null, "NT1");
			SetSchemaItemId(ed1.NodeTypes["NT1"], 1);
			ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT1"], ed1.NodeTypes["NT1"]);
			//-- create current
			ed2.CreatePropertyType("PT1", DataType.String);
			SetSchemaItemId(ed2.PropertyTypes["PT1"], 1);
			ed2.CreateNodeType(null, "NT1");
			SetSchemaItemId(ed2.NodeTypes["NT1"], 1);
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT1"]);

			//-- edit
			ed2.DeleteNodeType(ed2.NodeTypes["NT1"]);
			ed2.CreateNodeType(null, "NT1");
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT1"]);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string expectedLog = @"
				Open();
				DeleteNodeType(nodeType=<NT1>);
				CreateNodeType(parent=<[null]>, name=<NT1>, className=<>);
				AddPropertyTypeToPropertySet(propertyType=<PT1>, owner=<NT1>, isDeclared=<True>);
				Close();
				".Replace("\r\n", "").Replace("\t", "").Replace(" ", "");
			string log = wr.Log.Replace("\r\n", "").Replace(" ", "");
			Assert.IsTrue(log == expectedLog);
		}
示例#15
0
		public void SchEd_WriterCalling_Complex_01()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			PropertyType ptX = CreatePropertyType(ed1, "X", DataType.String, 1);
			PropertyType ptY = CreatePropertyType(ed1, "Y", DataType.String, 2);
			PropertyType ptZ = CreatePropertyType(ed1, "Z", DataType.String, 3);
			NodeType ntA = CreateNodeType(ed1, null, "A", null, 1);
			NodeType ntB = CreateNodeType(ed1, ntA, "B", null, 2);
			NodeType ntC = CreateNodeType(ed1, ntB, "C", null, 3);
			ed1.AddPropertyTypeToPropertySet(ptX, ntB);
			ed1.AddPropertyTypeToPropertySet(ptY, ntC);
			ed1.AddPropertyTypeToPropertySet(ptX, ntA);

			//-- create current
			XmlDocument xd = new XmlDocument();
			xd.LoadXml(ed1.ToXml());
			ed2.Load(xd);
			ptX = ed2.PropertyTypes["X"];
			ptY = ed2.PropertyTypes["Y"];
			ptZ = ed2.PropertyTypes["Z"];
			ntA = ed2.NodeTypes["A"];
			ntB = ed2.NodeTypes["B"];
			ntC = ed2.NodeTypes["C"];

			//-- edit
			ed2.RemovePropertyTypeFromPropertySet(ptX, ntA);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string log = wr.Log.Replace("\r\n", "");
			Assert.IsTrue(log == "Open();RemovePropertyTypeFromPropertySet(propertyType=<X>, owner=<A>);Close();");

		}
示例#16
0
		public void SchEd_WriterCalling_OverridePropertyOnNodeType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			PropertyType pt1 = CreatePropertyType(ed1, "PT1", DataType.String, 1);
			NodeType nt1 = CreateNodeType(ed1, null, "NT1", "NT1", 1);
			NodeType nt2 = CreateNodeType(ed1, nt1, "NT2", "NT2", 2);
			NodeType nt3 = CreateNodeType(ed1, nt2, "NT3", "NT3", 3);
			NodeType nt4 = CreateNodeType(ed1, nt3, "NT4", "NT4", 4);
			NodeType nt5 = CreateNodeType(ed1, nt4, "NT5", "NT5", 5);
			ed1.AddPropertyTypeToPropertySet(pt1, nt2);

			//-- create current
			XmlDocument xd = new XmlDocument();
			xd.LoadXml(ed1.ToXml());
			ed2.Load(xd);

			//-- edit
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT4"]);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string log = wr.Log.Replace("\r\n", "");
			Assert.IsTrue(log == "Open();UpdatePropertyTypeDeclarationState(propType=<PT1>, newSet=<NT4>, isDeclared=<True>);Close();");
		}
示例#17
0
		public void SchEd_WriterCalling_ModifyNodeType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			ed1.CreatePropertyType("PT1", DataType.String);
			SetSchemaItemId(ed1.PropertyTypes["PT1"], 1);
			ed1.CreateNodeType(null, "NT1");
			SetSchemaItemId(ed1.NodeTypes["NT1"], 1);
			ed1.AddPropertyTypeToPropertySet(ed1.PropertyTypes["PT1"], ed1.NodeTypes["NT1"]);
			//-- create current
			ed2.CreatePropertyType("PT1", DataType.String);
			SetSchemaItemId(ed2.PropertyTypes["PT1"], 1);
			ed2.CreateNodeType(null, "NT1");
			SetSchemaItemId(ed2.NodeTypes["NT1"], 1);
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT1"]);

			//-- edit
			ed2.ModifyNodeType(ed2.NodeTypes["NT1"], "ClassName2");

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string log = wr.Log.Replace("\r\n", "");
			Assert.IsTrue(log == "Open();ModifyNodeType(nodeType=<NT1>, parent=<[null]>, className=<ClassName2>);Close();");

		}
示例#18
0
		public void SchEd_WriterCalling_RemoveAncestorOfOverriddenPropertyFromNodeType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			PropertyType pt1 = CreatePropertyType(ed1, "PT1", DataType.String, 1);
			NodeType nt1 = CreateNodeType(ed1, null, "NT1", "NT1", 1);
			NodeType nt2 = CreateNodeType(ed1, nt1, "NT2", "NT2", 2);
			NodeType nt3 = CreateNodeType(ed1, nt2, "NT3", "NT3", 3);
			NodeType nt4 = CreateNodeType(ed1, nt3, "NT4", "NT4", 4);
			NodeType nt5 = CreateNodeType(ed1, nt4, "NT5", "NT5", 5);
			ed1.AddPropertyTypeToPropertySet(pt1, nt4);
			ed1.AddPropertyTypeToPropertySet(pt1, nt2);

			//-- create current
			XmlDocument xd = new XmlDocument();
			xd.LoadXml(ed1.ToXml());
			ed2.Load(xd);

			//-- edit
			ed2.RemovePropertyTypeFromPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT2"]);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string expectedLog = @"
				Open();
				RemovePropertyTypeFromPropertySet(propertyType=<PT1>, owner=<NT2>);
				RemovePropertyTypeFromPropertySet(propertyType=<PT1>, owner=<NT3>);
				Close();".Replace("\r\n", "").Replace("\t", "").Replace(" ", "");
			string log = wr.Log.Replace("\r\n", "").Replace(" ", "");
			Assert.IsTrue(log == expectedLog);
		}
示例#19
0
		public void SchEd_WriterCalling_CreatePropertyType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- edit
			ed2.CreatePropertyType("PT1", DataType.String);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string log = wr.Log.Replace("\r\n", "");
			Assert.IsTrue(log == "Open();CreatePropertyType(name=<PT1>, dataType=<String>, mapping=<0>, isContentListProperty=<False>);Close();");
		}
示例#20
0
		//TODO: Change structure: not implemented
		//[TestMethod()]
		//public void ContentType_FullInstall_InheritedClass_ChangeParent()
		//{
		//    Assembly asm = SchemaTestTools.DynamicAssembly;

		//    //-- Step 1: Install content types: TestType1, TestType2 and TestType1/TestType3
		//    string contentTypeDef1 = @"<?xml version='1.0' encoding='utf-8'?>
		//		<ContentType name='TestType1' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
		//			<Fields>
		//				<Field name='TestField' type='ShortText'>
		//					<DisplayName>TestField1</DisplayName>
		//				</Field>
		//			</Fields>
		//		</ContentType>";
		//    string contentTypeDef2 = @"<?xml version='1.0' encoding='utf-8'?>
		//		<ContentType name='TestType2' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
		//			<Fields>
		//				<Field name='TestField' type='ShortText'>
		//					<DisplayName>TestField2</DisplayName>
		//				</Field>
		//			</Fields>
		//		</ContentType>";
		//    string contentTypeDef3 = @"<?xml version='1.0' encoding='utf-8'?>
		//		<ContentType name='TestType3' parentType='TestType1' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
		//			<Fields>
		//				<Field name='TestField' type='ShortText'></Field>
		//			</Fields>
		//		</ContentType>";

		//    ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();
		//    installer.AddContentType(contentTypeDef1);
		//    installer.AddContentType(contentTypeDef2);
		//    installer.AddContentType(contentTypeDef3);
		//    installer.ExecuteBatch();

		//    //-- Step 2: Reinstall TestType3 under TestType2
		//    contentTypeDef3 = @"<?xml version='1.0' encoding='utf-8'?>
		//		<ContentType name='TestType3' parentType='TestType2' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'></ContentType>";

		//    ContentTypeInstaller.InstallContentType(contentTypeDef3);

		//    NodeType nt1 = ActiveSchema.NodeTypes["TestType1"];
		//    NodeType nt2 = ActiveSchema.NodeTypes["TestType2"];
		//    NodeType nt3 = ActiveSchema.NodeTypes["TestType3"];
		//    ContentType ct1 = ContentTypeManager.Current.GetContentTypeByName(nt1.Name);
		//    ContentType ct2 = ContentTypeManager.Current.GetContentTypeByName(nt2.Name);
		//    ContentType ct3 = ContentTypeManager.Current.GetContentTypeByName(nt3.Name);

		//    SNC.Content c3 = SNC.Content.CreateNew("TestType3", this.TestRoot, "ChangeParentTest3");

		//    Assert.IsTrue(ct3.Path == Path.Combine(ct2.Path, ct3.Name));
		//    Assert.IsTrue(c3.Fields["TestField"].Title == "TestField2");
		//}


		//================================================= Tools =================================================

		private string InstallContentType(string contentTypeDefInstall, string contentTypeDefModify)
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();

			ContentTypeManagerAccessor ctmAcc = new ContentTypeManagerAccessor(ContentTypeManager.Current);
			ContentType cts = ctmAcc.LoadOrCreateNew(contentTypeDefInstall);
            if (contentTypeDefModify != null)
            {
                cts.Save(false);
                var parent = ContentType.GetByName(cts.ParentName);
                ContentTypeManager.Current.AddContentType(cts);
            }

			ctmAcc.ApplyChangesInEditor(cts, ed2);

			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();
			ed2Acc.RegisterSchema(ed1, wr);

			if (contentTypeDefModify != null)
			{
				//-- Id-k beallitasa es klonozas
				SchemaEditor ed3 = new SchemaEditor();
				SchemaEditorAccessor ed3Acc = new SchemaEditorAccessor(ed3);
				SchemaItemAccessor schItemAcc;
				int id = 1;
				foreach (PropertyType pt in ed2.PropertyTypes)
				{
					PropertyType clone = ed3.CreatePropertyType(pt.Name, pt.DataType, pt.Mapping);
					schItemAcc = new SchemaItemAccessor(pt);
					schItemAcc.Id = id++;
					schItemAcc = new SchemaItemAccessor(clone);
					schItemAcc.Id = pt.Id;
				}
				id = 1;
				foreach (NodeType nt in ed2.NodeTypes)
				{
					NodeType clone = ed3.CreateNodeType(nt.Parent, nt.Name, nt.ClassName);
					foreach (PropertyType pt in nt.PropertyTypes)
						ed3.AddPropertyTypeToPropertySet(ed3.PropertyTypes[pt.Name], clone);
					schItemAcc = new SchemaItemAccessor(nt);
					schItemAcc.Id = id++;
					schItemAcc = new SchemaItemAccessor(clone);
					schItemAcc.Id = nt.Id;
				}

				cts = ctmAcc.LoadOrCreateNew(contentTypeDefModify);
				ctmAcc.ApplyChangesInEditor(cts, ed3);
				wr = new TestSchemaWriter();
				ed3Acc.RegisterSchema(ed2, wr);
			}

			return wr.Log;
		}
示例#21
0
        private string InstallContentType(string contentTypeDefInstall, string contentTypeDefModify)
        {
            XmlDocument schema = new XmlDocument();

            schema.LoadXml(@"<?xml version='1.0' encoding='utf-8' ?>
<StorageSchema xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/Storage/Schema'>
	<UsedPropertyTypes>
		<PropertyType itemID='1' name='Binary' dataType='Binary' mapping='0' />
		<PropertyType itemID='2' name='VersioningMode' dataType='Int' mapping='0' />
		<PropertyType itemID='3' name='Make' dataType='String' mapping='0' />
		<PropertyType itemID='4' name='Model' dataType='String' mapping='1' />
		<PropertyType itemID='5' name='Style' dataType='String' mapping='2' />
		<PropertyType itemID='6' name='Color' dataType='String' mapping='3' />
		<PropertyType itemID='7' name='EngineSize' dataType='String' mapping='4' />
		<PropertyType itemID='8' name='Power' dataType='String' mapping='5' />
		<PropertyType itemID='9' name='Price' dataType='String' mapping='6' />
		<PropertyType itemID='10' name='Description' dataType='Text' mapping='0' />
		<PropertyType itemID='11' name='Enabled' dataType='Int' mapping='1' />
		<PropertyType itemID='12' name='Domain' dataType='String' mapping='7' />
		<PropertyType itemID='13' name='Email' dataType='String' mapping='8' />
		<PropertyType itemID='14' name='FullName' dataType='String' mapping='9' />
		<PropertyType itemID='15' name='PasswordHash' dataType='String' mapping='10' />
		<PropertyType itemID='16' name='Memberships' dataType='Binary' mapping='1' />
		<PropertyType itemID='17' name='PendingUserLang' dataType='String' mapping='11' />
		<PropertyType itemID='18' name='Language' dataType='Int' mapping='2' />
		<PropertyType itemID='19' name='Url' dataType='String' mapping='12' />
		<PropertyType itemID='20' name='AuthenticationType' dataType='String' mapping='13' />
		<PropertyType itemID='21' name='StartPage' dataType='String' mapping='14' />
		<PropertyType itemID='22' name='LoginPage' dataType='String' mapping='15' />
		<PropertyType itemID='23' name='StatisticalLog' dataType='Int' mapping='3' />
		<PropertyType itemID='24' name='AuditLog' dataType='Int' mapping='4' />
		<PropertyType itemID='26' name='PageNameInMenu' dataType='String' mapping='16' />
		<PropertyType itemID='27' name='Hidden' dataType='Int' mapping='6' />
		<PropertyType itemID='28' name='Keywords' dataType='String' mapping='17' />
		<PropertyType itemID='29' name='MetaDescription' dataType='String' mapping='18' />
		<PropertyType itemID='30' name='MetaTitle' dataType='String' mapping='19' />
		<PropertyType itemID='31' name='PageTemplateNode' dataType='Reference' mapping='0' />
		<PropertyType itemID='32' name='DefaultPortletSkin' dataType='String' mapping='20' />
		<PropertyType itemID='33' name='HiddenPageFrom' dataType='String' mapping='21' />
		<PropertyType itemID='34' name='Authors' dataType='String' mapping='22' />
		<PropertyType itemID='35' name='CustomMeta' dataType='String' mapping='23' />
		<PropertyType itemID='36' name='Comment' dataType='String' mapping='24' />
		<PropertyType itemID='37' name='PersonalizationSettings' dataType='Binary' mapping='2' />
		<PropertyType itemID='38' name='Title' dataType='String' mapping='25' />
		<PropertyType itemID='39' name='Subtitle' dataType='String' mapping='26' />
		<PropertyType itemID='40' name='Header' dataType='Text' mapping='1' />
		<PropertyType itemID='41' name='Body' dataType='Text' mapping='2' />
		<PropertyType itemID='42' name='Links' dataType='Text' mapping='3' />
		<PropertyType itemID='43' name='ContentLanguage' dataType='String' mapping='27' />
		<PropertyType itemID='44' name='Author' dataType='String' mapping='28' />
		<PropertyType itemID='45' name='ContractId' dataType='String' mapping='29' />
		<PropertyType itemID='46' name='Project' dataType='String' mapping='30' />
		<PropertyType itemID='47' name='Responsee' dataType='String' mapping='31' />
		<PropertyType itemID='48' name='Lawyer' dataType='String' mapping='32' />
		<PropertyType itemID='49' name='MasterPageNode' dataType='Reference' mapping='1' />
		<PropertyType itemID='50' name='Members' dataType='Reference' mapping='2' />
		<PropertyType itemID='51' name='Manufacturer' dataType='String' mapping='33' />
		<PropertyType itemID='52' name='Driver' dataType='String' mapping='34' />
		<PropertyType itemID='53' name='InheritableVersioningMode' dataType='Int' mapping='35' />
		<PropertyType itemID='54' name='HasApproving' dataType='Int' mapping='36' />
	</UsedPropertyTypes>
	<NodeTypeHierarchy>
		<NodeType itemID='7' name='PersonalizationFile' className='SenseNet.ContentRepository.PersonalizationFile'>
			<PropertyType name='Binary' />
			<PropertyType name='VersioningMode' />
			<PropertyType name='InheritableVersioningMode' />
			<PropertyType name='HasApproving' />
		</NodeType>
		<NodeType itemID='5' name='GenericContent' className='SenseNet.ContentRepository.GenericContent'>
			<PropertyType name='VersioningMode' />
			<PropertyType name='InheritableVersioningMode' />
			<PropertyType name='HasApproving' />
			<NodeType itemID='3' name='User' className='SenseNet.ContentRepository.User'>
				<PropertyType name='VersioningMode' />
				<PropertyType name='Enabled' />
				<PropertyType name='Domain' />
				<PropertyType name='Email' />
				<PropertyType name='FullName' />
				<PropertyType name='PasswordHash' />
				<PropertyType name='Memberships' />
			</NodeType>
			<NodeType itemID='1' name='Folder' className='SenseNet.ContentRepository.Folder'>
				<PropertyType name='VersioningMode' />
				<NodeType itemID='16' name='Page' className='SenseNet.Portal.Page'>
					<PropertyType name='Binary' />
					<PropertyType name='PageNameInMenu' />
					<PropertyType name='Hidden' />
					<PropertyType name='Keywords' />
					<PropertyType name='MetaDescription' />
					<PropertyType name='MetaTitle' />
					<PropertyType name='PageTemplateNode' />
					<PropertyType name='DefaultPortletSkin' />
					<PropertyType name='HiddenPageFrom' />
					<PropertyType name='Authors' />
					<PropertyType name='CustomMeta' />
					<PropertyType name='Comment' />
					<PropertyType name='PersonalizationSettings' />
				</NodeType>
				<NodeType itemID='15' name='OrganizationalUnit' className='SenseNet.ContentRepository.OrganizationalUnit'>
				</NodeType>
				<NodeType itemID='14' name='Site' className='SenseNet.Portal.Site'>
					<PropertyType name='Description' />
					<PropertyType name='PendingUserLang' />
					<PropertyType name='Language' />
					<PropertyType name='Url' />
					<PropertyType name='AuthenticationType' />
					<PropertyType name='StartPage' />
					<PropertyType name='LoginPage' />
					<PropertyType name='StatisticalLog' />
					<PropertyType name='AuditLog' />
				</NodeType>
			</NodeType>
			<NodeType itemID='10' name='WebContentDemo' className='SenseNet.ContentRepository.GenericContent'>
				<PropertyType name='Keywords' />
				<PropertyType name='Title' />
				<PropertyType name='Subtitle' />
				<PropertyType name='Header' />
				<PropertyType name='Body' />
				<PropertyType name='Links' />
				<PropertyType name='ContentLanguage' />
				<PropertyType name='Author' />
			</NodeType>
			<NodeType itemID='9' name='File' className='SenseNet.ContentRepository.File'>
				<PropertyType name='Binary' />
				<NodeType itemID='13' name='PageTemplate' className='SenseNet.Portal.PageTemplate'>
					<PropertyType name='MasterPageNode' />
				</NodeType>
				<NodeType itemID='12' name='Contract' className='SenseNet.ContentRepository.File'>
					<PropertyType name='Description' />
					<PropertyType name='Language' />
					<PropertyType name='Keywords' />
					<PropertyType name='ContractId' />
					<PropertyType name='Project' />
					<PropertyType name='Responsee' />
					<PropertyType name='Lawyer' />
				</NodeType>
				<NodeType itemID='11' name='MasterPage' className='SenseNet.Portal.MasterPage' />
			</NodeType>
			<NodeType itemID='8' name='Car' className='SenseNet.ContentRepository.GenericContent'>
				<PropertyType name='Make' />
				<PropertyType name='Model' />
				<PropertyType name='Style' />
				<PropertyType name='Color' />
				<PropertyType name='EngineSize' />
				<PropertyType name='Power' />
				<PropertyType name='Price' />
				<PropertyType name='Description' />
			</NodeType>
		</NodeType>
		<NodeType itemID='4' name='ContentType' className='SenseNet.ContentRepository.Schema.ContentType'>
			<PropertyType name='Binary' />
		</NodeType>
		<NodeType itemID='2' name='Group' className='SenseNet.ContentRepository.Group'>
			<PropertyType name='VersioningMode' />
			<PropertyType name='Members' />
		</NodeType>
	</NodeTypeHierarchy>
	<PermissionTypes>
		<PermissionType itemID='1' name='See' />
		<PermissionType itemID='2' name='Open' />
		<PermissionType itemID='3' name='OpenMinor' />
		<PermissionType itemID='4' name='Save' />
		<PermissionType itemID='5' name='Publish' />
		<PermissionType itemID='6' name='ForceCheckin' />
		<PermissionType itemID='7' name='AddNew' />
		<PermissionType itemID='8' name='Approve' />
		<PermissionType itemID='9' name='Delete' />
		<PermissionType itemID='10' name='RecallOldVersion' />
		<PermissionType itemID='11' name='DeleteOldVersion' />
		<PermissionType itemID='12' name='SeePermissions' />
		<PermissionType itemID='13' name='SetPermissions' />
		<PermissionType itemID='14' name='RunApplication' />
	</PermissionTypes>
</StorageSchema>
");

            SchemaEditor ed1 = new SchemaEditor();
            SchemaEditor ed2 = new SchemaEditor();

            ed1.Load(schema);
            ed2.Load(schema);

            ContentTypeManagerAccessor ctmAcc = new ContentTypeManagerAccessor(ContentTypeManager.Current);
            ContentType cts = ctmAcc.LoadOrCreateNew(contentTypeDefInstall);

            ctmAcc.ApplyChangesInEditor(cts, ed2);

            SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
            TestSchemaWriter     wr     = new TestSchemaWriter();

            ed2Acc.RegisterSchema(ed1, wr);

            if (contentTypeDefModify != null)
            {
                XmlDocument schema2 = new XmlDocument();
                schema2.LoadXml(ed2.ToXml());
                SchemaEditor ed3 = new SchemaEditor();
                ed3.Load(schema2);
                SchemaEditorAccessor ed3Acc = new SchemaEditorAccessor(ed3);


                cts = ctmAcc.LoadOrCreateNew(contentTypeDefModify);
                ctmAcc.ApplyChangesInEditor(cts, ed3);
                wr = new TestSchemaWriter();
                ed3Acc.RegisterSchema(ed2, wr);
            }

            return(wr.Log);
        }
示例#22
0
		private string InstallContentType(string contentTypeDefInstall, string contentTypeDefModify)
		{
			XmlDocument schema = new XmlDocument();
			schema.LoadXml(@"<?xml version='1.0' encoding='utf-8' ?>
<StorageSchema xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/Storage/Schema'>
	<UsedPropertyTypes>
		<PropertyType itemID='1' name='Binary' dataType='Binary' mapping='0' />
		<PropertyType itemID='2' name='VersioningMode' dataType='Int' mapping='0' />
		<PropertyType itemID='3' name='Make' dataType='String' mapping='0' />
		<PropertyType itemID='4' name='Model' dataType='String' mapping='1' />
		<PropertyType itemID='5' name='Style' dataType='String' mapping='2' />
		<PropertyType itemID='6' name='Color' dataType='String' mapping='3' />
		<PropertyType itemID='7' name='EngineSize' dataType='String' mapping='4' />
		<PropertyType itemID='8' name='Power' dataType='String' mapping='5' />
		<PropertyType itemID='9' name='Price' dataType='String' mapping='6' />
		<PropertyType itemID='10' name='Description' dataType='Text' mapping='0' />
		<PropertyType itemID='11' name='Enabled' dataType='Int' mapping='1' />
		<PropertyType itemID='12' name='Domain' dataType='String' mapping='7' />
		<PropertyType itemID='13' name='Email' dataType='String' mapping='8' />
		<PropertyType itemID='14' name='FullName' dataType='String' mapping='9' />
		<PropertyType itemID='15' name='PasswordHash' dataType='String' mapping='10' />
		<PropertyType itemID='16' name='Memberships' dataType='Binary' mapping='1' />
		<PropertyType itemID='17' name='PendingUserLang' dataType='String' mapping='11' />
		<PropertyType itemID='18' name='Language' dataType='Int' mapping='2' />
		<PropertyType itemID='19' name='Url' dataType='String' mapping='12' />
		<PropertyType itemID='20' name='AuthenticationType' dataType='String' mapping='13' />
		<PropertyType itemID='21' name='StartPage' dataType='String' mapping='14' />
		<PropertyType itemID='22' name='LoginPage' dataType='String' mapping='15' />
		<PropertyType itemID='23' name='StatisticalLog' dataType='Int' mapping='3' />
		<PropertyType itemID='24' name='AuditLog' dataType='Int' mapping='4' />
		<PropertyType itemID='26' name='PageNameInMenu' dataType='String' mapping='16' />
		<PropertyType itemID='27' name='Hidden' dataType='Int' mapping='6' />
		<PropertyType itemID='28' name='Keywords' dataType='String' mapping='17' />
		<PropertyType itemID='29' name='MetaDescription' dataType='String' mapping='18' />
		<PropertyType itemID='30' name='MetaTitle' dataType='String' mapping='19' />
		<PropertyType itemID='31' name='PageTemplateNode' dataType='Reference' mapping='0' />
		<PropertyType itemID='32' name='DefaultPortletSkin' dataType='String' mapping='20' />
		<PropertyType itemID='33' name='HiddenPageFrom' dataType='String' mapping='21' />
		<PropertyType itemID='34' name='Authors' dataType='String' mapping='22' />
		<PropertyType itemID='35' name='CustomMeta' dataType='String' mapping='23' />
		<PropertyType itemID='36' name='Comment' dataType='String' mapping='24' />
		<PropertyType itemID='37' name='PersonalizationSettings' dataType='Binary' mapping='2' />
		<PropertyType itemID='38' name='Title' dataType='String' mapping='25' />
		<PropertyType itemID='39' name='Subtitle' dataType='String' mapping='26' />
		<PropertyType itemID='40' name='Header' dataType='Text' mapping='1' />
		<PropertyType itemID='41' name='Body' dataType='Text' mapping='2' />
		<PropertyType itemID='42' name='Links' dataType='Text' mapping='3' />
		<PropertyType itemID='43' name='ContentLanguage' dataType='String' mapping='27' />
		<PropertyType itemID='44' name='Author' dataType='String' mapping='28' />
		<PropertyType itemID='45' name='ContractId' dataType='String' mapping='29' />
		<PropertyType itemID='46' name='Project' dataType='String' mapping='30' />
		<PropertyType itemID='47' name='Responsee' dataType='String' mapping='31' />
		<PropertyType itemID='48' name='Lawyer' dataType='String' mapping='32' />
		<PropertyType itemID='49' name='MasterPageNode' dataType='Reference' mapping='1' />
		<PropertyType itemID='50' name='Members' dataType='Reference' mapping='2' />
		<PropertyType itemID='51' name='Manufacturer' dataType='String' mapping='33' />
		<PropertyType itemID='52' name='Driver' dataType='String' mapping='34' />
		<PropertyType itemID='53' name='InheritableVersioningMode' dataType='Int' mapping='35' />
		<PropertyType itemID='54' name='HasApproving' dataType='Int' mapping='36' />
	</UsedPropertyTypes>
	<NodeTypeHierarchy>
		<NodeType itemID='7' name='PersonalizationFile' className='SenseNet.ContentRepository.PersonalizationFile'>
			<PropertyType name='Binary' />
			<PropertyType name='VersioningMode' />
			<PropertyType name='InheritableVersioningMode' />
			<PropertyType name='HasApproving' />
		</NodeType>
		<NodeType itemID='5' name='GenericContent' className='SenseNet.ContentRepository.GenericContent'>
			<PropertyType name='VersioningMode' />
			<PropertyType name='InheritableVersioningMode' />
			<PropertyType name='HasApproving' />
			<NodeType itemID='3' name='User' className='SenseNet.ContentRepository.User'>
				<PropertyType name='VersioningMode' />
				<PropertyType name='Enabled' />
				<PropertyType name='Domain' />
				<PropertyType name='Email' />
				<PropertyType name='FullName' />
				<PropertyType name='PasswordHash' />
				<PropertyType name='Memberships' />
			</NodeType>
			<NodeType itemID='1' name='Folder' className='SenseNet.ContentRepository.Folder'>
				<PropertyType name='VersioningMode' />
				<NodeType itemID='16' name='Page' className='SenseNet.Portal.Page'>
					<PropertyType name='Binary' />
					<PropertyType name='PageNameInMenu' />
					<PropertyType name='Hidden' />
					<PropertyType name='Keywords' />
					<PropertyType name='MetaDescription' />
					<PropertyType name='MetaTitle' />
					<PropertyType name='PageTemplateNode' />
					<PropertyType name='DefaultPortletSkin' />
					<PropertyType name='HiddenPageFrom' />
					<PropertyType name='Authors' />
					<PropertyType name='CustomMeta' />
					<PropertyType name='Comment' />
					<PropertyType name='PersonalizationSettings' />
				</NodeType>
				<NodeType itemID='15' name='OrganizationalUnit' className='SenseNet.ContentRepository.OrganizationalUnit'>
				</NodeType>
				<NodeType itemID='14' name='Site' className='SenseNet.Portal.Site'>
					<PropertyType name='Description' />
					<PropertyType name='PendingUserLang' />
					<PropertyType name='Language' />
					<PropertyType name='Url' />
					<PropertyType name='AuthenticationType' />
					<PropertyType name='StartPage' />
					<PropertyType name='LoginPage' />
					<PropertyType name='StatisticalLog' />
					<PropertyType name='AuditLog' />
				</NodeType>
			</NodeType>
			<NodeType itemID='10' name='WebContentDemo' className='SenseNet.ContentRepository.GenericContent'>
				<PropertyType name='Keywords' />
				<PropertyType name='Title' />
				<PropertyType name='Subtitle' />
				<PropertyType name='Header' />
				<PropertyType name='Body' />
				<PropertyType name='Links' />
				<PropertyType name='ContentLanguage' />
				<PropertyType name='Author' />
			</NodeType>
			<NodeType itemID='9' name='File' className='SenseNet.ContentRepository.File'>
				<PropertyType name='Binary' />
				<NodeType itemID='13' name='PageTemplate' className='SenseNet.Portal.PageTemplate'>
					<PropertyType name='MasterPageNode' />
				</NodeType>
				<NodeType itemID='12' name='Contract' className='SenseNet.ContentRepository.File'>
					<PropertyType name='Description' />
					<PropertyType name='Language' />
					<PropertyType name='Keywords' />
					<PropertyType name='ContractId' />
					<PropertyType name='Project' />
					<PropertyType name='Responsee' />
					<PropertyType name='Lawyer' />
				</NodeType>
				<NodeType itemID='11' name='MasterPage' className='SenseNet.Portal.MasterPage' />
			</NodeType>
			<NodeType itemID='8' name='Car' className='SenseNet.ContentRepository.GenericContent'>
				<PropertyType name='Make' />
				<PropertyType name='Model' />
				<PropertyType name='Style' />
				<PropertyType name='Color' />
				<PropertyType name='EngineSize' />
				<PropertyType name='Power' />
				<PropertyType name='Price' />
				<PropertyType name='Description' />
			</NodeType>
		</NodeType>
		<NodeType itemID='4' name='ContentType' className='SenseNet.ContentRepository.Schema.ContentType'>
			<PropertyType name='Binary' />
		</NodeType>
		<NodeType itemID='2' name='Group' className='SenseNet.ContentRepository.Group'>
			<PropertyType name='VersioningMode' />
			<PropertyType name='Members' />
		</NodeType>
	</NodeTypeHierarchy>
	<PermissionTypes>
		<PermissionType itemID='1' name='See' />
		<PermissionType itemID='2' name='Open' />
		<PermissionType itemID='3' name='OpenMinor' />
		<PermissionType itemID='4' name='Save' />
		<PermissionType itemID='5' name='Publish' />
		<PermissionType itemID='6' name='ForceCheckin' />
		<PermissionType itemID='7' name='AddNew' />
		<PermissionType itemID='8' name='Approve' />
		<PermissionType itemID='9' name='Delete' />
		<PermissionType itemID='10' name='RecallOldVersion' />
		<PermissionType itemID='11' name='DeleteOldVersion' />
		<PermissionType itemID='12' name='SeePermissions' />
		<PermissionType itemID='13' name='SetPermissions' />
		<PermissionType itemID='14' name='RunApplication' />
	</PermissionTypes>
</StorageSchema>
");

			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			ed1.Load(schema);
			ed2.Load(schema);

			ContentTypeManagerAccessor ctmAcc = new ContentTypeManagerAccessor(ContentTypeManager.Current);
			ContentType cts = ctmAcc.LoadOrCreateNew(contentTypeDefInstall);
			ctmAcc.ApplyChangesInEditor(cts, ed2);

			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();
			ed2Acc.RegisterSchema(ed1, wr);

			if (contentTypeDefModify != null)
			{
				XmlDocument schema2 = new XmlDocument();
				schema2.LoadXml(ed2.ToXml());
				SchemaEditor ed3 = new SchemaEditor();
				ed3.Load(schema2);
				SchemaEditorAccessor ed3Acc = new SchemaEditorAccessor(ed3);


				cts = ctmAcc.LoadOrCreateNew(contentTypeDefModify);
				ctmAcc.ApplyChangesInEditor(cts, ed3);
				wr = new TestSchemaWriter();
				ed3Acc.RegisterSchema(ed2, wr);
			}

			return wr.Log;
		}
示例#23
0
		public void SchEd_WriterCalling_ReCreatePermissionType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			ed1.CreatePermissionType("P1");
			SetSchemaItemId(ed1.PermissionTypes["P1"], 1);
			//-- create current
			ed2.CreatePermissionType("P1");
			SetSchemaItemId(ed2.PermissionTypes["P1"], 1);

			//-- edit
			ed2.DeletePermissionType(ed2.PermissionTypes["P1"]);
			ed2.CreatePermissionType("P1");

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string log = wr.Log.Replace("\r\n", "");
			Assert.IsTrue(log == "Open();DeletePermissionType(permissionType=<P1>);CreatePermissionType(name=<P1>);Close();");
		}