public void Deploy_ListsViews()
        {
            // Step 1, define lists
            var customerClaims = new ListDefinition
            {
                Title        = "Customer claims",
                Url          = "CustomerClaims",
                Description  = "Stores customer related claims.",
                TemplateType = BuiltInListTemplateTypeId.DocumentLibrary
            };


            var lastTenClaims = new ListViewDefinition
            {
                Title     = "Last 10 claims",
                IsDefault = false,
                RowLimit  = 10,
                Query     = string.Format("<OrderBy><FieldRef Name='{0}' Ascending='FALSE' /></OrderBy>", BuiltInInternalFieldNames.Created),
                Fields    = new System.Collections.ObjectModel.Collection <string>
                {
                    BuiltInInternalFieldNames.ID,
                    BuiltInInternalFieldNames.File_x0020_Type,
                    BuiltInInternalFieldNames.FileLeafRef,
                    BuiltInInternalFieldNames.Created,
                    BuiltInInternalFieldNames.Modified,
                    BuiltInInternalFieldNames.Author,
                }
            };

            var lastTenEditedClaims = new ListViewDefinition
            {
                Title     = "Last 10 edited claims",
                IsDefault = false,
                RowLimit  = 10,
                Query     = string.Format("<OrderBy><FieldRef Name='{0}' Ascending='FALSE' /></OrderBy>", BuiltInInternalFieldNames.Modified),
                Fields    = new System.Collections.ObjectModel.Collection <string>
                {
                    BuiltInInternalFieldNames.ID,
                    BuiltInInternalFieldNames.File_x0020_Type,
                    BuiltInInternalFieldNames.FileLeafRef,
                    BuiltInInternalFieldNames.Created,
                    BuiltInInternalFieldNames.Modified,
                    BuiltInInternalFieldNames.Author,
                }
            };

            // Step 2, define web model and artifact relationships - add feature to the web
            var model = SPMeta2Model
                        .NewWebModel(web =>
            {
                web
                .AddList(customerClaims, list =>
                {
                    list
                    .AddView(lastTenClaims)
                    .AddView(lastTenEditedClaims);
                });
            });

            // Step 3, deploy model
            DeployWebModel(model);
        }
예제 #2
0
        private ContentTypeEnvironment GetContentTypeLinksSandbox(
            Action <SiteModelNode, ContentTypeEnvironment> siteModelConfig,
            Action <WebModelNode, ContentTypeEnvironment> webModelConfig,
            Action <ListModelNode, ContentTypeEnvironment> listModelConfig)
        {
            var result = new ContentTypeEnvironment();

            // site model

            ContentTypeDefinition ctFirst  = null;
            ContentTypeDefinition ctSecond = null;
            ContentTypeDefinition ctThird  = null;

            var siteModel = SPMeta2Model
                            .NewSiteModel(site =>
            {
                site
                .AddRandomContentType(ct => { ctFirst = ct.Value as ContentTypeDefinition; })
                .AddRandomContentType(ct => { ctSecond = ct.Value as ContentTypeDefinition; })
                .AddRandomContentType(ct => { ctThird = ct.Value as ContentTypeDefinition; });
            });

            ctFirst.Name  = "first_" + ctFirst.Name;
            ctSecond.Name = "second_" + ctSecond.Name;
            ctThird.Name  = "third_" + ctThird.Name;

            result.First  = ctFirst;
            result.Second = ctSecond;
            result.Third  = ctThird;

            result.SiteModel = siteModel;

            if (siteModelConfig != null)
            {
                siteModelConfig(result.SiteModel, result);
            }

            // web model
            var webModel = SPMeta2Model
                           .NewWebModel(web =>
            {
                web
                .AddRandomList(list =>
                {
                    list
                    .AddContentTypeLink(ctFirst, link =>
                    {
                        result.FirstLink = link;
                        //link.Options.RequireSelfProcessing = link.Value.RequireSelfProcessing = true;
                        link.Options.RequireSelfProcessing = true;
                    })
                    .AddContentTypeLink(ctSecond, link =>
                    {
                        result.SecondLink = link;
                        //link.Options.RequireSelfProcessing = link.Value.RequireSelfProcessing = true;
                        link.Options.RequireSelfProcessing = true;
                    })
                    .AddContentTypeLink(ctThird, link =>
                    {
                        result.ThirdLink = link;
                        //link.Options.RequireSelfProcessing = link.Value.RequireSelfProcessing = true;
                        link.Options.RequireSelfProcessing = true;
                    });

                    result.List = list.Value as ListDefinition;

                    if (listModelConfig != null)
                    {
                        listModelConfig(list, result);
                    }
                });
            });

            result.WebModel = webModel;

            if (webModelConfig != null)
            {
                webModelConfig(result.WebModel, result);
            }

            return(result);
        }
예제 #3
0
        public void CanDeploy_AllFields_UnderList()
        {
            var fields = GetAllRandomFields();

            fields.OfType <CalculatedFieldDefinition>()
            .ToList()
            .ForEach(f =>
            {
                // clean fomula, that's not gonna work in list
                // there is a separated test for it
                f.Formula = String.Empty;
            });

            var model = SPMeta2Model
                        .NewWebModel(web =>
            {
                web.AddRandomList(list =>
                {
                    foreach (var fieldDef in fields)
                    {
                        // honest regression testing will update Formula
                        // need to reset oit before provision
                        // same-same with ValidationFormula/ValidationMessage

                        if (fieldDef is CalculatedFieldDefinition)
                        {
                            list.AddField(fieldDef, field =>
                            {
                                field.OnProvisioning <object, CalculatedFieldDefinition>(cntx =>
                                {
                                    cntx.ObjectDefinition.ValidationFormula = string.Empty;
                                    cntx.ObjectDefinition.ValidationMessage = string.Empty;

                                    cntx.ObjectDefinition.Formula = "=5*ID";

                                    // SSOM: weird, but we can't pass this test unless turn off toggling or TRUE for ndexed value
                                    cntx.ObjectDefinition.Indexed = false;
                                });
                            });
                        }
                        else
                        {
                            list.AddField(fieldDef, field =>
                            {
                                field.OnProvisioning <object>(cntx =>
                                {
                                    var def = cntx.ObjectDefinition as FieldDefinition;

                                    def.ValidationFormula = string.Empty;
                                    def.ValidationMessage = string.Empty;

                                    // SSOM: weird, but we can't pass this test unless turn off toggling or TRUE for ndexed value
                                    if (def is MultiChoiceFieldDefinition)
                                    {
                                        def.Indexed = false;
                                    }

                                    // CSOM: weird, but we can't pass this test unless turn off toggling or TRUE for ndexed value
                                    if (def is URLFieldDefinition ||
                                        def is ImageFieldDefinition ||
                                        def is LinkFieldDefinition ||
                                        def is ComputedFieldDefinition ||
                                        def is SummaryLinkFieldDefinition ||
                                        def is MediaFieldDefinition ||
                                        def is HTMLFieldDefinition ||
                                        def is GeolocationFieldDefinition
                                        )
                                    {
                                        def.Indexed = false;
                                    }
                                });
                            });
                        }
                    }
                });
            });

            TestModel(model);
        }
        public void CanDeploySimpleBreakRoleInheritance_OnWeb()
        {
            var privateProjectWebDef = new WebDefinition
            {
                Title       = "Private project",
                Url         = "private-project",
                WebTemplate = BuiltInWebTemplates.Collaboration.TeamSite
            };

            var privateProjectWebBreakRoleInheritance = new BreakRoleInheritanceDefinition
            {
                CopyRoleAssignments = false
            };

            var privateSecurityGroupMembers = new SecurityGroupDefinition
            {
                Name = "Private Project Group Members"
            };

            var privateSecurityGroupViewers = new SecurityGroupDefinition
            {
                Name = "Private Project Group Viewers"
            };

            // site model with the groups
            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddSecurityGroup(privateSecurityGroupMembers);
                site.AddSecurityGroup(privateSecurityGroupViewers);
            });

            // web model
            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddWeb(privateProjectWebDef, publicProjectWeb =>
                {
                    publicProjectWeb.AddBreakRoleInheritance(privateProjectWebBreakRoleInheritance, privateProjectResetWeb =>
                    {
                        // privateProjectResetWeb is your web but after breaking role inheritance

                        // link group with roles by SecurityRoleType / SecurityRoleName
                        // use BuiltInSecurityRoleTypes or BuiltInSecurityRoleNames

                        // add group with contributor permission
                        privateProjectResetWeb.AddSecurityGroupLink(privateSecurityGroupMembers, group =>
                        {
                            group.AddSecurityRoleLink(new SecurityRoleLinkDefinition
                            {
                                SecurityRoleType = BuiltInSecurityRoleTypes.Contributor
                            });
                        });

                        // add group with reader permission
                        privateProjectResetWeb.AddSecurityGroupLink(privateSecurityGroupViewers, group =>
                        {
                            group.AddSecurityRoleLink(new SecurityRoleLinkDefinition
                            {
                                SecurityRoleType = BuiltInSecurityRoleTypes.Reader
                            });
                        });
                    });
                });
            });

            // deploy site model with groups, and then web model with the rest
            DeployModel(siteModel);
            DeployModel(webModel);
        }
예제 #5
0
        public void CanDeploy_XsltListViewWebPart_With_ParameterBindings_ID_Filtering()
        {
            var dstList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var sourceList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var sourceListView = ModelGeneratorService.GetRandomDefinition <ListViewDefinition>(def =>
            {
                def.Query  = "<Eq><FieldRef Name=\"ID\" /><Value Type=\"Counter\">{ID}</Value></Eq>";
                def.Hidden = true;
            });

            // this web part would be binded to list view
            // it will also be performing 'filtering' via query string - ID
            var xsltListViewWebpart = ModelGeneratorService.GetRandomDefinition <XsltListViewWebPartDefinition>(def =>
            {
                def.ListId    = Guid.Empty;
                def.ListTitle = sourceList.Title;
                def.ListUrl   = string.Empty;

                def.ViewName = sourceListView.Title;
                def.ViewId   = null;

                def.JSLink = string.Empty;

                def.ParameterBindings.Add(new ParameterBindingValue
                {
                    Name     = "ID",
                    Location = "QueryString(ID)"
                });
            });

            var model = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddList(sourceList, list =>
                {
                    list.AddListView(sourceListView);

                    list
                    .AddRandomListItem()
                    .AddRandomListItem()
                    .AddRandomListItem();
                })
                .AddList(dstList, list =>
                {
                    list
                    .AddRandomListItem()
                    .AddRandomListItem();

                    list.AddHostListView(BuiltInListViewDefinitions.Lists.EditForm, view =>
                    {
                        view.AddXsltListViewWebPart(xsltListViewWebpart);
                    });
                });
            });

            TestModel(model);
        }
        public void CanDeploy_LookupField_As_SiteMaster_And_SubWebChild()
        {
            // https://github.com/SubPointSolutions/spmeta2/issues/694

            // 1 - Installing a generic list (Departments) on Top-Level-Site-Collection and add some data (Just using Title-Field).
            var masterDepartmentsList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;

#pragma warning disable 618
                def.Url = string.Empty;
#pragma warning restore 618
                def.CustomUrl = string.Format("Lists/{0}", Rnd.String());
            });

            var masterDepartmentsRootWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(masterDepartmentsList, list =>
                {
                    list.AddRandomListItem();
                    list.AddRandomListItem();
                    list.AddRandomListItem();
                });
            });

            // 2 - Creating a Site-Column (Department) of type Lookup, Data Comes from previous mentioned List.
            var departmentsFieldLookup = ModelGeneratorService.GetRandomDefinition <LookupFieldDefinition>(def =>
            {
                def.LookupListTitle = masterDepartmentsList.Title;
                def.LookupWebUrl    = "~sitecollection";
            });

            // 3 -  Creating a Site-Content-Type on Top-Level-Site-Collection of type Document (Contract) and add the Site-Column-Lookup-field Department.
            var contractDocumentContentType = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.ParentContentTypeId = BuiltInContentTypeId.Document;
            });

            // the site model for 2-3 containing field and content type (IA -> information architecture :)
            var masterIASiteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddField(departmentsFieldLookup);

                site.AddContentType(contractDocumentContentType, contentType =>
                {
                    contentType.AddContentTypeFieldLink(departmentsFieldLookup);
                });
            });

            // 4 - Now on a Sub-Site of the Top-Level-Site-Collection
            // create a Document-Library (Contracts) and add the previous mentioned Site-Content-Type.

            var subWeb = ModelGeneratorService.GetRandomDefinition <WebDefinition>(def =>
            {
            });

            var contractsDocumentLibrary = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.ContentTypesEnabled = true;
                def.TemplateType        = BuiltInListTemplateTypeId.DocumentLibrary;

#pragma warning disable 618
                def.Url = string.Empty;
#pragma warning restore 618
                def.CustomUrl = string.Format("{0}", Rnd.String());

                // just don't want to go site content -> find a list..
                def.OnQuickLaunch = true;
            });

            var contractsSubWebModel = SPMeta2Model.NewWebModel(rootWeb =>
            {
                rootWeb.AddWeb(subWeb, web =>
                {
                    web.AddList(contractsDocumentLibrary, list =>
                    {
                        list.AddContentTypeLink(contractDocumentContentType);

                        // making the content type defullt
                        list.AddUniqueContentTypeOrder(new UniqueContentTypeOrderDefinition
                        {
                            ContentTypes = new List <ContentTypeLinkValue>
                            {
                                new ContentTypeLinkValue {
                                    ContentTypeName = contractDocumentContentType.Name
                                }
                            }
                        });
                    });
                });
            });

            // deployment
            // 1 - deploy root list
            TestModel(masterDepartmentsRootWebModel);

            // 2 - deploy lookup list pointing a site level (root web) list and content type
            TestModel(masterIASiteModel);

            // 3 - deploy the sunu web, list, attach content type to a list and make it nice
            TestModel(contractsSubWebModel);
        }
예제 #7
0
        public void CanDeploy_CanSetupUniqueContentTypeFieldsOrder_At_List_Scope()
        {
            // Support 'UniqueContentTypeFieldsOrderDefinition' at list level content types #742
            // https://github.com/SubPointSolutions/spmeta2/issues/742

            WithDisabledPropertyUpdateValidation(() =>
            {
                var first  = string.Empty;
                var second = string.Empty;

                var env = GetContentTypeSandbox(
                    (siteModel, e) =>
                {
                },
                    (contentTypeModel, e) =>
                {
                    first  = e.First.InternalName;
                    second = e.Second.InternalName;

                    contentTypeModel
                    .AddUniqueContentTypeFieldsOrder(new UniqueContentTypeFieldsOrderDefinition
                    {
                        Fields = new List <FieldLinkValue>
                        {
                            new FieldLinkValue {
                                InternalName = e.Second.InternalName
                            },
                            new FieldLinkValue {
                                InternalName = e.First.InternalName
                            },
                        }
                    });
                });

                var webModel = SPMeta2Model.NewWebModel(web =>
                {
                    web.AddRandomList(list =>
                    {
                        (list.Value as ListDefinition).ContentTypesEnabled = true;

                        list.AddContentTypeLink(env.ContentType, contenTypeLink =>
                        {
                            contenTypeLink.AddUniqueContentTypeFieldsOrder(new UniqueContentTypeFieldsOrderDefinition
                            {
                                Fields = new List <FieldLinkValue>
                                {
                                    new FieldLinkValue {
                                        InternalName = first
                                    },
                                    new FieldLinkValue {
                                        InternalName = second
                                    },
                                }
                            });
                        });
                    });
                });

                TestModel(env.SiteModel, webModel);
            });
        }
        public void CanDeploy_ContentByQueryWebPart_AsIs_With_Filters()
        {
            var templateTypeId = BuiltInListTemplateTypeId.GenericList;

            var defToday = ModelGeneratorService.GetRandomDefinition <ContentByQueryWebPartDefinition>(def =>
            {
                def.Title = "As is with template type " + templateTypeId + " today";

                //def.WebUrl = "~sitecollection";
                def.ServerTemplate = templateTypeId;

                def.FilterType1             = "DateTime";
                def.FilterField1            = BuiltInFieldId.Created.ToString("B");
                def.FilterDisplayValue1     = "[TODAY]";
                def.Filter1ChainingOperator = "And";
                def.FilterOperator1         = "Eq";
            });

            var defFromLastWeek = ModelGeneratorService.GetRandomDefinition <ContentByQueryWebPartDefinition>(def =>
            {
                def.Title = "As is with template type " + templateTypeId + " from last week";

                //def.WebUrl = "~sitecollection";
                def.ServerTemplate = templateTypeId;

                def.FilterType1             = "DateTime";
                def.FilterField1            = BuiltInFieldId.Created.ToString("B");
                def.FilterDisplayValue1     = "[TODAY]";
                def.Filter1ChainingOperator = "And";
                def.FilterOperator1         = "Leq";

                def.FilterType2             = "DateTime";
                def.FilterField2            = BuiltInFieldId.Created.ToString("B");
                def.FilterDisplayValue2     = "-7";
                def.Filter2ChainingOperator = "And";
                def.FilterOperator2         = "Geq";

                def.Filter2IsCustomValue    = true;
                def.Filter2ChainingOperator = "And";
            });

            var defFromLastWeekContains = ModelGeneratorService.GetRandomDefinition <ContentByQueryWebPartDefinition>(def =>
            {
                def.Title = "As is with template type " + templateTypeId + " from last week contains";

                //def.WebUrl = "~sitecollection";
                def.ServerTemplate = templateTypeId;

                def.FilterType1             = "DateTime";
                def.FilterField1            = BuiltInFieldId.Created.ToString("B");
                def.FilterDisplayValue1     = "[TODAY]";
                def.Filter1ChainingOperator = "And";
                def.FilterOperator1         = "Leq";

                def.FilterType2             = "DateTime";
                def.FilterField2            = BuiltInFieldId.Created.ToString("B");
                def.FilterDisplayValue2     = "-7";
                def.Filter2ChainingOperator = "And";
                def.FilterOperator2         = "Geq";

                def.Filter2IsCustomValue    = true;
                def.Filter2ChainingOperator = "And";

                def.FilterType3         = "Text";
                def.FilterField3        = BuiltInFieldId.Title.ToString("B");
                def.FilterDisplayValue3 = "m2";
                def.FilterOperator3     = "Contains";

                def.Filter3IsCustomValue = false;
            });

            var model = SPMeta2Model.NewWebModel(web =>
            {
                web.AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    list.AddRandomWebPartPage(page =>
                    {
                        page.AddContentByQueryWebPart(defToday);
                        page.AddContentByQueryWebPart(defFromLastWeek);
                        page.AddContentByQueryWebPart(defFromLastWeekContains);
                    });
                });
            });

            TestModel(model);
        }
예제 #9
0
        public void CanDeploy_Default_PublishingPage_With_RequiredFieldValues()
        {
            var siteFeature = BuiltInSiteFeatures.SharePointServerPublishingInfrastructure.Inherit(f => f.Enable());
            var webFeature  = BuiltInWebFeatures.SharePointServerPublishing.Inherit(f => f.Enable());

            var publishingPageLayoutContentType = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.Name   = string.Format("Required - {0}", Environment.TickCount);
                def.Hidden = false;
                def.ParentContentTypeId = BuiltInPublishingContentTypeId.ArticlePage;
            });

            var requiredText = RItemValues.GetRequiredTextField(ModelGeneratorService);

            var text1 = RItemValues.GetRandomTextField(ModelGeneratorService);
            var text2 = RItemValues.GetRandomTextField(ModelGeneratorService);

            var publishingPageLayout = ModelGeneratorService.GetRandomDefinition <PublishingPageLayoutDefinition>(def =>
            {
                def.AssociatedContentTypeId = publishingPageLayoutContentType.GetContentTypeId();
            });

            var page = ModelGeneratorService.GetRandomDefinition <PublishingPageDefinition>(def =>
            {
                def.PageLayoutFileName = publishingPageLayout.FileName;

                def.DefaultValues.Add(new FieldValue()
                {
                    FieldName = requiredText.InternalName,
                    Value     = Rnd.String()
                });

                def.Values.Add(new FieldValue()
                {
                    FieldName = text1.InternalName,
                    Value     = Rnd.String()
                });

                def.Values.Add(new FieldValue()
                {
                    FieldName = text2.InternalName,
                    Value     = Rnd.String()
                });
            });

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddSiteFeature(siteFeature);

                site.AddField(requiredText);
                site.AddField(text1);
                site.AddField(text2);

                site.AddContentType(publishingPageLayoutContentType, contentType =>
                {
                    contentType.AddContentTypeFieldLink(requiredText);

                    contentType.AddContentTypeFieldLink(text1);
                    contentType.AddContentTypeFieldLink(text2);
                });
            });

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddWebFeature(webFeature);

                web.AddHostList(BuiltInListDefinitions.Catalogs.MasterPage, list =>
                {
                    list.AddPublishingPageLayout(publishingPageLayout);
                });

                web.AddHostList(BuiltInListDefinitions.Pages, list =>
                {
                    list.AddContentTypeLink(publishingPageLayoutContentType);

                    list.AddPublishingPage(page);
                });
            });

            TestModels(new ModelNode[] { siteModel, webModel });
        }
예제 #10
0
        public void CanDeploy_WebModel()
        {
            var model = SPMeta2Model.NewWebModel(m => { });

            TestModel(model);
        }
        public void CanDeploy_ContentByQueryWebPart_AsIs_With_Styles()
        {
            var templateTypeId = BuiltInListTemplateTypeId.Posts;

            var defDefault = ModelGeneratorService.GetRandomDefinition <ContentByQueryWebPartDefinition>(def =>
            {
                def.Title = "As is with template type " + templateTypeId + " and item style Default";

                def.ServerTemplate = templateTypeId;

                def.ItemStyle = BuiltInItemStyleNames.Default;
                def.ItemLimit = 3;

                def.SortByFieldType = "DateTime";
                def.SortBy          = BuiltInFieldDefinitions.Created.Id.ToString("B");
                def.SortByDirection = "Desc";
            });


            var defBullets = ModelGeneratorService.GetRandomDefinition <ContentByQueryWebPartDefinition>(def =>
            {
                def.Title = "As is with template type " + templateTypeId + " and item style Bullets";

                def.ServerTemplate = templateTypeId;

                def.ItemStyle = BuiltInItemStyleNames.Bullets;
                def.ItemLimit = 3;

                def.SortByFieldType = "DateTime";
                def.SortBy          = BuiltInFieldDefinitions.Created.Id.ToString("B");
                def.SortByDirection = "Desc";
            });


            var defTitleOnly = ModelGeneratorService.GetRandomDefinition <ContentByQueryWebPartDefinition>(def =>
            {
                def.Title = "As is with template type " + templateTypeId + " and item style TitleOnly";

                def.ServerTemplate = templateTypeId;

                def.ItemStyle = BuiltInItemStyleNames.TitleOnly;
                def.ItemLimit = 3;

                def.SortByFieldType = "DateTime";
                def.SortBy          = BuiltInFieldDefinitions.Created.Id.ToString("B");
                def.SortByDirection = "Desc";
            });

            var defNoImage = ModelGeneratorService.GetRandomDefinition <ContentByQueryWebPartDefinition>(def =>
            {
                def.Title = "As is with template type " + templateTypeId + " and item style NoImage";

                def.ServerTemplate = templateTypeId;

                def.ItemStyle = BuiltInItemStyleNames.NoImage;
                def.ItemLimit = 3;

                def.SortByFieldType = "DateTime";
                def.SortBy          = BuiltInFieldDefinitions.Created.Id.ToString("B");
                def.SortByDirection = "Desc";
            });

            var model = SPMeta2Model.NewWebModel(web =>
            {
                web.AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    list.AddRandomWebPartPage(page =>
                    {
                        page.AddContentByQueryWebPart(defNoImage);
                        page.AddContentByQueryWebPart(defBullets);
                        page.AddContentByQueryWebPart(defDefault);
                        page.AddContentByQueryWebPart(defTitleOnly);
                    });
                });
            });

            TestModel(model);
        }
        //[SampleMetadataTag(Name = BuiltInTagNames.SampleHidden)]
        public void CaDeployHierarchicalQuickLaunchNavigation()
        {
            // top level departments node
            var departments = new QuickLaunchNavigationNodeDefinition
            {
                Title      = "Departments",
                Url        = "departments.aspx",
                IsExternal = true
            };

            var hr = new QuickLaunchNavigationNodeDefinition
            {
                Title      = "HR",
                Url        = "hr.aspx",
                IsExternal = true
            };

            var it = new QuickLaunchNavigationNodeDefinition
            {
                Title      = "IT",
                Url        = "it.aspx",
                IsExternal = true
            };

            // top level clients node
            var clients = new QuickLaunchNavigationNodeDefinition
            {
                Title      = "Clients",
                Url        = "clients.aspx",
                IsExternal = true
            };

            var microsoft = new QuickLaunchNavigationNodeDefinition
            {
                Title      = "Microsoft",
                Url        = "microsfot.aspx",
                IsExternal = true
            };

            var apple = new QuickLaunchNavigationNodeDefinition
            {
                Title      = "Apple",
                Url        = "apple.aspx",
                IsExternal = true
            };

            var model = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddQuickLaunchNavigationNode(departments, node =>
                {
                    node
                    .AddQuickLaunchNavigationNode(hr)
                    .AddQuickLaunchNavigationNode(it);
                })
                .AddQuickLaunchNavigationNode(clients, node =>
                {
                    node
                    .AddQuickLaunchNavigationNode(microsoft)
                    .AddQuickLaunchNavigationNode(apple);
                });
            });

            DeployModel(model);
        }
예제 #13
0
        /**
         *
         * SPWeb model assembly example
         *
         */
        public static WebModelNode WebDemoModel()
        {
            return(SPMeta2Model.NewWebModel(Web =>
            {
                Web
                .AddWelcomePage(new WelcomePageDefinition
                {
                    Url = ListsInfo.Contacts().CustomUrl
                })

                .AddWebFeature(FeaturesInfo.DisableMinimalDownloadStrategy)

                .AddField(FieldsInfo.Email())
                .AddField(FieldsInfo.PhoneNumber())
                .AddField(FieldsInfo.EmployeesCount())
                .AddField(FieldsInfo.Owner())
                .AddField(FieldsInfo.Function())

                .AddContentType(ContentTypesInfo.Contact(), contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(new ContentTypeFieldLinkDefinition
                    {
                        FieldId = BuiltInFieldId.Title,
                        DisplayName = "Name",
                        Required = true
                    })
                    .AddContentTypeFieldLink(FieldsInfo.Email())
                    .AddContentTypeFieldLink(FieldsInfo.PhoneNumber())
                    ;
                })
                .AddContentType(ContentTypesInfo.Function(), contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(FieldsInfo.Owner())
                    .AddContentTypeFieldLink(FieldsInfo.EmployeesCount())
                    ;
                })
                .AddContentType(ContentTypesInfo.SubFunction(), contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(FieldsInfo.Function())
                    .AddContentTypeFieldLink(FieldsInfo.Owner())
                    ;
                })

                .AddList(ListsInfo.Contacts(), List =>
                {
                    List
                    .AddRemoveStandardContentTypes()
                    .AddContentTypeLink(ContentTypesInfo.Contact())
                    .AddListView(ViewsInfo.ContactsView())
                    ;
                })
                .AddList(ListsInfo.Functions(), List =>
                {
                    List
                    .AddRemoveStandardContentTypes()
                    .AddContentTypeLink(ContentTypesInfo.Function())
                    .AddListView(ViewsInfo.FunctionsView())
                    ;
                })
                .AddList(ListsInfo.SubFunctions(), List =>
                {
                    List
                    .AddRemoveStandardContentTypes()
                    .AddContentTypeLink(ContentTypesInfo.SubFunction())
                    .AddListView(ViewsInfo.SubFunctionsView())
                    ;
                })
                ;
            }));
        }
        public void Deploy_FoldersToList()
        {
            // Step 1, define security groups
            var customerIssues = new ListDefinition
            {
                Title        = "Customer KPIs",
                Url          = "CustomerKPI",
                Description  = "Stores customer related KPIs.",
                TemplateType = BuiltInListTemplateTypeId.GenericList
            };

            var Year2010 = new FolderDefinition {
                Name = "2010"
            };
            var Year2011 = new FolderDefinition {
                Name = "2011"
            };
            var Year2012 = new FolderDefinition {
                Name = "2012"
            };

            var Q1 = new FolderDefinition {
                Name = "Q1"
            };
            var Q2 = new FolderDefinition {
                Name = "Q2"
            };
            var Q3 = new FolderDefinition {
                Name = "Q3"
            };
            var Q4 = new FolderDefinition {
                Name = "Q4"
            };

            // deploy web model - list and add content type links to list
            var webModel = SPMeta2Model
                           .NewWebModel(web =>
            {
                web
                .AddList(customerIssues, list =>
                {
                    list
                    .AddFolder(Year2010, folder =>
                    {
                        folder
                        .AddFolder(Q1)
                        .AddFolder(Q2)
                        .AddFolder(Q3)
                        .AddFolder(Q4);
                    })
                    .AddFolder(Year2011, folder =>
                    {
                        folder
                        .AddFolder(Q1)
                        .AddFolder(Q2)
                        .AddFolder(Q3)
                        .AddFolder(Q4);
                    })
                    .AddFolder(Year2012, folder =>
                    {
                        folder
                        .AddFolder(Q1)
                        .AddFolder(Q2)
                        .AddFolder(Q3)
                        .AddFolder(Q4);
                    });
                });
            });

            DeployWebModel(webModel);
        }
예제 #15
0
        public void CanDeploy_ListFieldLink_AsAddToAllContentTypes()
        {
            var field = ModelGeneratorService.GetRandomDefinition <FieldDefinition>();

            field.AddToDefaultView = true;

            var listFieldLink = new ListFieldLinkDefinition
            {
                FieldId          = field.Id,
                AddFieldOptions  = BuiltInAddFieldOptions.AddToAllContentTypes,
                AddToDefaultView = true
            };

            var ct_1 = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.ParentContentTypeId = BuiltInContentTypeId.Item;
            });

            var ct_2 = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.ParentContentTypeId = BuiltInContentTypeId.Item;
            });

            var ct_3 = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.ParentContentTypeId = BuiltInContentTypeId.Item;
            });

            var genericList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.ContentTypesEnabled = true;
                def.TemplateType        = BuiltInListTemplateTypeId.GenericList;
            });

            var siteModel = SPMeta2Model
                            .NewSiteModel(site =>
            {
                site.AddContentType(ct_1);
                site.AddContentType(ct_2);
                site.AddContentType(ct_3);

                site.AddField(field);
            });

            var webModel = SPMeta2Model
                           .NewWebModel(web =>
            {
                web.AddList(genericList, list =>
                {
                    list.AddContentTypeLink(ct_1);
                    list.AddContentTypeLink(ct_2);
                    list.AddContentTypeLink(ct_3);

                    list.AddListFieldLink(listFieldLink);
                });
            });

            // content types are deployed after fields
            // so, to test AddToAllContentTypes, we need to deploy content type first, and then the rest
            //var fieldLinkModel = SPMeta2Model
            //       .NewWebModel(web =>
            //       {
            //           web.AddHostList(genericList, list =>
            //           {

            //           });
            //       });

            TestModels(new  ModelNode[] { siteModel, webModel });
        }
예제 #16
0
        public void CanDeploy_ListViewWebPart_As_Calender_With_DateRangesOverlap()
        {
            // ListViewWebPartDefinition doesn't show calendar view #988
            // https://github.com/SubPointSolutions/spmeta2/issues/988

            var contentTypeDef = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.ParentContentTypeId = BuiltInContentTypeId.DocumentSet_Correct;
            });

            var listDef = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                //def.TemplateName = BuiltInListTemplates.DocumentLibrary.InternalName;
                //def.TemplateType = BuiltInListTemplateTypeId.DocumentLibrary;

                def.TemplateType        = BuiltInListTemplateTypeId.DocumentLibrary;
                def.ContentTypesEnabled = true;
            });

            var listViewDef = ModelGeneratorService.GetRandomDefinition <ListViewDefinition>(def =>
            {
                def.IsDefault = true;
                //def.MobileDefaultView = true;

                def.RowLimit = 2147483647;
                def.Query    = @"<Where>
                                <DateRangesOverlap>
                                    <FieldRef Name=""StartDate"" />
                                    <FieldRef Name=""_EndDate"" />
                                    <FieldRef Name=""RecurrenceID"" />
                                    <Value Type=""DateTime"">
                                        <Month />
                                    </Value>
                                </DateRangesOverlap>
                            </Where>";

                def.ViewData = @"<FieldRef Name=""Title"" Type=""CalendarMonthTitle""/>
<FieldRef Name=""Title"" Type=""CalendarWeekTitle""/>
<FieldRef Name=""Location"" Type=""CalendarWeekLocation""/>
<FieldRef Name=""Title"" Type=""CalendarDayTitle""/>
<FieldRef Name=""Location"" Type=""CalendarDayLocation""/>";

                def.IsPaged   = false;
                def.IsDefault = false;

                def.Fields = new System.Collections.ObjectModel.Collection <string> {
                    BuiltInFieldDefinitions.Title.InternalName,
                    BuiltInFieldDefinitions.StartDate.InternalName,
                    BuiltInFieldDefinitions._EndDate.InternalName,
                    BuiltInFieldDefinitions.Title.InternalName,

                    BuiltInFieldDefinitions.Location.InternalName,
                    BuiltInFieldDefinitions.fAllDayEvent.InternalName,
                    BuiltInFieldDefinitions.fRecurrence.InternalName,
                    BuiltInFieldDefinitions.EventType.InternalName
                };

                def.Type  = @"Html";
                def.Types = new Collection <string> {
                    "Calendar",
                    "Recurrence"
                };
            });


            var webpartPageDef = ModelGeneratorService.GetRandomDefinition <WebPartPageDefinition>(def =>
            {
            });

            var calendarWebPart = ModelGeneratorService.GetRandomDefinition <ListViewWebPartDefinition>(def =>
            {
                def.ListId  = null;
                def.ListUrl = null;

                def.ListTitle  = listDef.Title;
                def.ViewName   = listViewDef.Title;
                def.ChromeType = @"Default";

                //def.ZoneId = @"LeftColumn",
                //ZoneIndex = 0,
            });

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddContentType(contentTypeDef, contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(SPMeta2.BuiltInDefinitions.BuiltInFieldDefinitions.Title)
                    .AddContentTypeFieldLink(SPMeta2.BuiltInDefinitions.BuiltInFieldDefinitions.StartDate)
                    .AddContentTypeFieldLink(SPMeta2.BuiltInDefinitions.BuiltInFieldDefinitions._EndDate);
                });
            });

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddList(listDef, list =>
                {
                    list
                    .AddListFieldLink(BuiltInFieldDefinitions.Location)
                    .AddListFieldLink(BuiltInFieldDefinitions.fAllDayEvent)
                    .AddListFieldLink(BuiltInFieldDefinitions.fRecurrence)
                    .AddListFieldLink(BuiltInFieldDefinitions.EventType)

                    .AddContentTypeLink(contentTypeDef)
                    .AddListView(listViewDef);
                })
                .AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    list
                    .AddWebPartPage(webpartPageDef, page =>
                    {
                        page.AddWebPart(calendarWebPart);
                    });
                });
            });

            TestModel(siteModel, webModel);
        }
        public void CanDeploy_XsltListViewWebPart_As_GridView()
        {
            // CSOM issue to get GridView on the XsltLIstViewWebPart done #725
            // https://github.com/SubPointSolutions/spmeta2/issues/725

            var sourceList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var sourceListView = ModelGeneratorService.GetRandomDefinition <ListViewDefinition>(def =>
            {
                def.Title = Rnd.String();
                def.Type  = BuiltInViewType.Grid;

                def.IsDefault = false;

                def.Fields = new Collection <string>
                {
                    BuiltInInternalFieldNames.ID,
                    BuiltInInternalFieldNames.Title
                };
            });

            var listViewWebpart = ModelGeneratorService.GetRandomDefinition <XsltListViewWebPartDefinition>(def =>
            {
                def.ListId    = Guid.Empty;
                def.ListTitle = sourceList.Title;
                def.ListUrl   = string.Empty;

                def.ViewName = sourceListView.Title;
                def.ViewId   = null;
            });

            var model = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddList(sourceList, list =>
                {
                    list.AddListView(sourceListView);
                })
                .AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    var pageName = string.Empty;

                    list.AddRandomWebPartPage(page =>
                    {
                        pageName = (page.Value as WebPartPageDefinition).FileName;

                        page.AddXsltListViewWebPart(listViewWebpart);
                    });

                    list.AddDefinitionNode(new XsltListViewWebPartGridModePresenceDefinition
                    {
                        PageFileName       = pageName,
                        WebPartDefinitions = new List <WebPartDefinitionBase>(new[] { listViewWebpart })
                    }, def =>
                    {
                        def.RegExcludeFromEventsValidation();
                    });
                });
            });

            TestModel(model);
        }
        public void CanDeploy_ListItem_With_RequiredFieldValues()
        {
            var requiredText = RItemValues.GetRequiredTextField(ModelGeneratorService);

            var text1 = RItemValues.GetRandomTextField(ModelGeneratorService);
            var text2 = RItemValues.GetRandomTextField(ModelGeneratorService);

            var contentTypeDef = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.ParentContentTypeId = BuiltInContentTypeId.Item;
            });

            var itemDef = ModelGeneratorService.GetRandomDefinition <ListItemDefinition>(def =>
            {
                def.ContentTypeName = contentTypeDef.Name;

                def.DefaultValues.Add(new FieldValue()
                {
                    FieldName = requiredText.InternalName,
                    Value     = Rnd.String()
                });

                def.Values.Add(new FieldValue()
                {
                    FieldName = text1.InternalName,
                    Value     = Rnd.String()
                });

                def.Values.Add(new FieldValue()
                {
                    FieldName = text2.InternalName,
                    Value     = Rnd.String()
                });
            });

            var listDef = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.ContentTypesEnabled = true;
                def.TemplateType        = BuiltInListTemplateTypeId.GenericList;
            });

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddField(requiredText);
                site.AddField(text1);
                site.AddField(text2);

                site.AddContentType(contentTypeDef, contentType =>
                {
                    contentType.AddContentTypeFieldLink(requiredText);
                    contentType.AddContentTypeFieldLink(text1);
                    contentType.AddContentTypeFieldLink(text2);
                });
            });

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(listDef, list =>
                {
                    list.AddContentTypeLink(contentTypeDef);
                    list.AddListItem(itemDef);
                });
            });

            TestModel(siteModel, webModel);
        }
예제 #19
0
        public void CanDeploy_CanSetupUniqueContentTypeFieldsOrder_At_OOTB_List_Scope()
        {
            var fieldDef = ModelGeneratorService.GetRandomDefinition <FieldDefinition>(def =>
            {
                def.Hidden = false;

                def.ShowInDisplayForm  = true;
                def.ShowInEditForm     = true;
                def.ShowInListSettings = true;
                def.ShowInNewForm      = true;
                def.ShowInViewForms    = true;

                def.AddFieldOptions = BuiltInAddFieldOptions.AddToAllContentTypes
                                      | BuiltInAddFieldOptions.AddFieldInternalNameHint;
            });

            var listDef = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.ContentTypesEnabled = false;
                def.TemplateType        = BuiltInListTemplateTypeId.GenericList;
            });

            var contentTypeLinkDef = new ContentTypeLinkDefinition
            {
                ContentTypeName = BuiltInContentTypeNames.Item,
                ContentTypeId   = BuiltInContentTypeId.Item
            };

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                // adding field first
                web.AddList(listDef, list =>
                {
                    list.AddField(fieldDef, field =>
                    {
                    });
                });

                // then working with the content type
                web.AddList(listDef.Inherit(), list =>
                {
                    list.AddContentTypeLink(contentTypeLinkDef, contenTypeLink =>
                    {
                        contenTypeLink.RegExcludeFromEventsValidation();

                        contenTypeLink.AddUniqueContentTypeFieldsOrder(new UniqueContentTypeFieldsOrderDefinition
                        {
                            Fields = new List <FieldLinkValue>
                            {
                                new FieldLinkValue {
                                    InternalName = fieldDef.InternalName
                                },
                                new FieldLinkValue {
                                    InternalName = "Title"
                                },
                            }
                        });
                    });
                });
            });

            TestModel(webModel);
        }
예제 #20
0
        public ModelNode GenerateModelTreeForDefinition <TDefinition>(SPObjectModelType objectModelType)
            where TDefinition : DefinitionBase, new()
        {
            ModelNode result = null;

            var rootHostType   = GetRootHostType <TDefinition>(objectModelType);
            var parentHostType = GetParentHostType <TDefinition>(objectModelType);

            var currentDefinition       = GetRandomDefinition <TDefinition>();
            var expectManyInstancesAttr = typeof(TDefinition).GetCustomAttribute <ExpectManyInstances>(false);

            var manyInstances = new List <TDefinition>();

            if (expectManyInstancesAttr != null)
            {
                var maxCount = expectManyInstancesAttr.MinInstancesCount +
                               Rnd.Int(expectManyInstancesAttr.MaxInstancesCount -
                                       expectManyInstancesAttr.MinInstancesCount);

                for (int i = 0; i < maxCount; i++)
                {
                    manyInstances.Add(GetRandomDefinition <TDefinition>());
                }
            }

            CurrentDefinitions.Clear();

            CurrentDefinitions.Add(currentDefinition);
            CurrentDefinitions.AddRange(manyInstances);

            //CurrentDefinition = currentDefinition;

            var defs = new List <GeneratedNodes>();

            LookupModelTree <TDefinition>(rootHostType, defs, objectModelType);

            if (defs.Count > 0)
            {
                defs.Reverse();

                var rootHost = defs[0].ModelNode;
                parentHostType = rootHost.Value.GetType();

                defs.RemoveAt(0);

                ModelNode model = null;

                if (parentHostType == typeof(FarmDefinition))
                {
                    model = SPMeta2Model.NewFarmModel();
                }

                if (parentHostType == typeof(WebApplicationDefinition))
                {
                    model = SPMeta2Model.NewWebApplicationModel();
                }

                if (parentHostType == typeof(SiteDefinition))
                {
                    model = SPMeta2Model.NewSiteModel();
                }

                if (parentHostType == typeof(WebDefinition))
                {
                    model = SPMeta2Model.NewWebModel();
                }

                var _m = model;

                foreach (var def in defs)
                {
                    _m.ChildModels.Add(def.ModelNode);
                    _m = def.ModelNode;
                }

                _m.AddDefinitionNode(currentDefinition);

                foreach (var manyDef in manyInstances)
                {
                    _m.AddDefinitionNode(manyDef);
                }

                result = model;
            }
            else
            {
                ModelNode resultModel = null;

                if (currentDefinition.GetType() == typeof(FarmDefinition))
                {
                    resultModel = SPMeta2Model.NewFarmModel();
                }

                if (currentDefinition.GetType() == typeof(WebApplicationDefinition))
                {
                    resultModel = SPMeta2Model.NewWebApplicationModel();
                }

                if (currentDefinition.GetType() == typeof(SiteDefinition))
                {
                    resultModel = SPMeta2Model.NewSiteModel();
                }

                if (currentDefinition.GetType() == typeof(WebDefinition))
                {
                    resultModel = SPMeta2Model.NewWebModel();
                }

                if (resultModel == null)
                {
                    throw new SPMeta2NotImplementedException(string.Format("Cannot find host model for type:[{0}]. Ensure correct RootHostAttribute/ParentHostAttribute/SPObjectTypeAttribute attributes.", typeof(TDefinition).AssemblyQualifiedName));
                }

                resultModel.Value = currentDefinition;
                result            = resultModel;
            }

            // ProcessAdditionalArtifacts(result, defs);

            return(result);
        }
        public void CanDeploySimpleBreakRoleInheritance_OnList()
        {
            var privateListDef = new ListDefinition
            {
                Title        = "Private records",
                TemplateType = BuiltInListTemplateTypeId.GenericList,
                CustomUrl    = "lists/private-records",
            };

            var privateProjectWebBreakRoleInheritance = new BreakRoleInheritanceDefinition
            {
                CopyRoleAssignments = false
            };

            var privateSecurityGroupMembers = new SecurityGroupDefinition
            {
                Name = "Private Project Group Members"
            };

            var privateSecurityGroupViewers = new SecurityGroupDefinition
            {
                Name = "Private Project Group Viewers"
            };

            // site model with the groups
            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddSecurityGroup(privateSecurityGroupMembers);
                site.AddSecurityGroup(privateSecurityGroupViewers);
            });

            // web model
            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(privateListDef, publicProjectWeb =>
                {
                    publicProjectWeb.AddBreakRoleInheritance(privateProjectWebBreakRoleInheritance, privateResetList =>
                    {
                        // privateResetList is your list but after breaking role inheritance

                        // link group with roles by SecurityRoleType / SecurityRoleName
                        // use BuiltInSecurityRoleTypes or BuiltInSecurityRoleNames

                        // add group with contributor permission
                        privateResetList.AddSecurityGroupLink(privateSecurityGroupMembers, group =>
                        {
                            group.AddSecurityRoleLink(new SecurityRoleLinkDefinition
                            {
                                SecurityRoleType = BuiltInSecurityRoleTypes.Contributor
                            });
                        });

                        // add group with reader permission
                        privateResetList.AddSecurityGroupLink(privateSecurityGroupViewers, group =>
                        {
                            group.AddSecurityRoleLink(new SecurityRoleLinkDefinition
                            {
                                SecurityRoleType = BuiltInSecurityRoleTypes.Reader
                            });
                        });
                    });
                });
            });

            // deploy site model with groups, and then web model with the rest
            DeployModel(siteModel);
            DeployModel(webModel);
        }
예제 #22
0
        public ModelNode GetModel()
        {
            var model = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddWebFeature(M2ProjectPrefixWebFeatures.DisableMinimalDownloadStrategy)
                .AddWebFeature(M2ProjectPrefixWebFeatures.EnableTeamCollabirationLists)
                .AddWebFeature(M2ProjectPrefixWebFeatures.WikiPageHomePage)

                .AddTopNavigationNode(M2ProjectPrefixTopNavigationNodes.CompanyDocuments)
                .AddTopNavigationNode(M2ProjectPrefixTopNavigationNodes.SaleTasks)
                .AddTopNavigationNode(M2ProjectPrefixTopNavigationNodes.SaleEvents)
                .AddTopNavigationNode(M2ProjectPrefixTopNavigationNodes.AboutThisSite)

                .AddQuickLaunchNavigationNode(M2ProjectPrefixQuickNavigationNodes.CompanyDocuments)
                .AddQuickLaunchNavigationNode(M2ProjectPrefixQuickNavigationNodes.Services)
                .AddQuickLaunchNavigationNode(M2ProjectPrefixQuickNavigationNodes.Orders)
                .AddQuickLaunchNavigationNode(M2ProjectPrefixQuickNavigationNodes.SaleTasks)
                .AddQuickLaunchNavigationNode(M2ProjectPrefixQuickNavigationNodes.SaleEvents)
                .AddQuickLaunchNavigationNode(M2ProjectPrefixQuickNavigationNodes.AboutThisSite)

                .AddList(M2ProjectPrefixLists.CompanyDocuments, list =>
                {
                    list
                    .AddContentTypeLink(M2ProjectPrefixContentTypes.CompanyDocument)
                    .AddContentTypeLink(M2ProjectPrefixContentTypes.SalesProposal)
                    .AddContentTypeLink(M2ProjectPrefixContentTypes.ProductDocument)

                    .AddListView(M2ProjectPrefixListViews.LastTenDocuments)
                    .AddListView(M2ProjectPrefixListViews.LastTenDocumentsMainPage)

                    .M2ProjectPrefixSetDefaultListContentType(M2ProjectPrefixContentTypes.CompanyDocument);
                })
                .AddList(M2ProjectPrefixLists.Orders, list =>
                {
                    list
                    .AddContentTypeLink(M2ProjectPrefixContentTypes.OrderDocument)
                    .AddListView(M2ProjectPrefixListViews.Last25Orders)
                    .AddListView(M2ProjectPrefixListViews.Last10OrdersMainPage)

                    .M2ProjectPrefixSetDefaultListContentType(M2ProjectPrefixContentTypes.OrderDocument);
                })
                .AddList(M2ProjectPrefixLists.Services, list =>
                {
                    list
                    .AddContentTypeLink(M2ProjectPrefixContentTypes.ProductOrService)
                    .AddListView(M2ProjectPrefixListViews.AllProducts)
                    .AddListView(M2ProjectPrefixListViews.LastTenServices)

                    .M2ProjectPrefixSetDefaultListContentType(M2ProjectPrefixContentTypes.ProductOrService);
                })
                .AddList(M2ProjectPrefixLists.SalesTasks, list =>
                {
                })
                .AddList(M2ProjectPrefixLists.SalesEvents, list =>
                {
                    list
                    .AddContentTypeLink(M2ProjectPrefixContentTypes.SaleEvents)

                    .M2ProjectPrefixSetDefaultListContentType(M2ProjectPrefixContentTypes.SaleEvents);
                })
                .AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    list.AddWebPartPage(M2ProjectPrefixWebPartPages.LandingPage, page =>
                    {
                        page
                        .AddWebPart(M2ProjectPrefixWebparts.NewServices)
                        .AddWebPart(M2ProjectPrefixWebparts.SalesTasks)
                        .AddWebPart(M2ProjectPrefixWebparts.LastDocuments)
                        .AddWebPart(M2ProjectPrefixWebparts.LastOrders)
                        .AddWebPart(M2ProjectPrefixWebparts.SalesEvents);
                    });

                    list.AddWebPartPage(M2ProjectPrefixWebPartPages.AboutThisSite, page =>
                    {
                        page
                        .AddWebPart(M2ProjectPrefixWebparts.M2YammerFeed)
                        .AddWebPart(M2ProjectPrefixWebparts.AboutThisSite);
                    });
                })

                .AddWelcomePage(M2ProjectPrefixWelcomePages.HomeLandingPage);
            });

            return(model);
        }
        public void Can_Reverse_UniqueContentTypeOrder()
        {
            // only root web
            var options = ReverseOptions.Default
                          .AddDepthOption <WebDefinition>(0);

            var ct1 = Def <ContentTypeDefinition>();
            var ct2 = Def <ContentTypeDefinition>();
            var ct3 = Def <ContentTypeDefinition>();
            var ct4 = Def <ContentTypeDefinition>();

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.RegExcludeFromValidation();

                site.AddContentType(ct1, c => c.RegExcludeFromValidation());
                site.AddContentType(ct2, c => c.RegExcludeFromValidation());
                site.AddContentType(ct3, c => c.RegExcludeFromValidation());
                site.AddContentType(ct4, c => c.RegExcludeFromValidation());
            });

            var listDef = Def <ListDefinition>(def =>
            {
                def.TemplateType        = BuiltInListTemplateTypeId.DocumentLibrary;
                def.Url                 = null;
                def.CustomUrl           = Rnd.String();
                def.ContentTypesEnabled = true;
            });

            var model1 = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(listDef, list =>
                {
                    list.AddContentTypeLink(ct1);
                    list.AddContentTypeLink(ct2);
                    list.AddContentTypeLink(ct3);
                    list.AddContentTypeLink(ct4);

                    list.AddUniqueContentTypeOrder(new UniqueContentTypeOrderDefinition
                    {
                        ContentTypes = new List <ContentTypeLinkValue>
                        {
                            new ContentTypeLinkValue {
                                ContentTypeName = ct2.Name
                            },
                            new ContentTypeLinkValue {
                                ContentTypeName = ct3.Name
                            },
                        }
                    });
                });
            });

            // only giving list, improve the test performance
            var listDefs = GetAllDefinitionOfType <ListDefinition>(model1);

            foreach (var listDefinition in listDefs)
            {
                options.AddFilterOption <ListDefinition>(l => l.Title == listDefinition.Title);
            }

            DeployReverseAndTestModel(new ModelNode[] { siteModel, model1 }, options);
        }
예제 #24
0
        public void CanDeploy_DependentLookupField_OnContentType()
        {
            var lookupField = ModelGeneratorService.GetRandomDefinition <LookupFieldDefinition>(def =>
            {
                def.ShowInNewForm      = true;
                def.ShowInDisplayForm  = true;
                def.ShowInEditForm     = true;
                def.ShowInListSettings = true;
                def.ShowInViewForms    = true;

                def.Hidden              = false;
                def.Required            = false;
                def.AllowMultipleValues = false;
            });

            var contentTypeWithDepLookup = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def =>
            {
                def.Hidden = false;
            });

            var dependentIdLookupField = ModelGeneratorService.GetRandomDefinition <DependentLookupFieldDefinition>(
                def =>
            {
                def.LookupField          = BuiltInInternalFieldNames.ID;
                def.PrimaryLookupFieldId = lookupField.Id;
                def.LookupWebId          = lookupField.LookupWebId;
                def.LookupWebUrl         = lookupField.LookupWebUrl;
                def.LookupList           = lookupField.LookupList;
                def.LookupListTitle      = lookupField.LookupListTitle;
                def.LookupListUrl        = lookupField.LookupListUrl;
            });

            var dependentTitleLookupField = ModelGeneratorService.GetRandomDefinition <DependentLookupFieldDefinition>(
                def =>
            {
                def.LookupField          = BuiltInInternalFieldNames.Title;
                def.PrimaryLookupFieldId = lookupField.Id;
                def.LookupWebId          = lookupField.LookupWebId;
                def.LookupWebUrl         = lookupField.LookupWebUrl;
                def.LookupList           = lookupField.LookupList;
                def.LookupListTitle      = lookupField.LookupListTitle;
                def.LookupListUrl        = lookupField.LookupListUrl;
            });

            var masterList = ModelGeneratorService.GetRandomDefinition <ListDefinition>();
            var childList  = ModelGeneratorService.GetRandomDefinition <ListDefinition>(list =>
            {
                list.ContentTypesEnabled = true;
            });

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddLookupField(lookupField);

                site.AddDependentLookupField(dependentIdLookupField);
                site.AddDependentLookupField(dependentTitleLookupField);

                site.AddContentType(contentTypeWithDepLookup, contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(lookupField)
                    .AddContentTypeFieldLink(dependentIdLookupField)
                    .AddContentTypeFieldLink(dependentTitleLookupField);
                });
            });

            TestModel(siteModel);

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(masterList, list =>
                {
                    for (var i = 0; i < 10; i++)
                    {
                        list.AddListItem(new ListItemDefinition
                        {
                            Title = string.Format("master item {0} - {1}", i, Rnd.String())
                        });
                    }
                });

                web.AddList(childList, list =>
                {
                    // list.AddListFieldLink(lookupField);
                });
            });

            TestModel(webModel);

            // rebind lookup
#pragma warning disable 618
            lookupField.LookupListUrl = masterList.GetListUrl();
#pragma warning restore 618

            TestModel(siteModel);

            // add dep field
            var depWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(childList, list =>
                {
                    list.AddContentTypeLink(contentTypeWithDepLookup);
                    list.AddUniqueContentTypeOrder(new UniqueContentTypeOrderDefinition
                    {
                        ContentTypes = new List <ContentTypeLinkValue>
                        {
                            new ContentTypeLinkValue {
                                ContentTypeName = contentTypeWithDepLookup.Name
                            }
                        }
                    });

                    //list.AddListFieldLink(dependentIdLookupField);
                    //list.AddListFieldLink(dependentTitleLookupField);

                    list.AddListView(new ListViewDefinition
                    {
                        Title  = "Test View",
                        Fields = new Collection <string>
                        {
                            BuiltInInternalFieldNames.Edit,
                            BuiltInInternalFieldNames.ID,
                            BuiltInInternalFieldNames.Title,
                            lookupField.InternalName,
                            dependentIdLookupField.InternalName,
                            dependentTitleLookupField.InternalName
                        },
                        IsDefault = true
                    });
                });
            });

            TestModel(depWebModel);
        }
예제 #25
0
        public void CanDeploy_XsltListViewWebPart_On_WikiPage()
        {
            WithDisabledPropertyUpdateValidation(() =>
            {
                var library  = ModelGeneratorService.GetRandomDefinition <ListDefinition>();
                var wikiPage = ModelGeneratorService.GetRandomDefinition <WikiPageDefinition>(def =>
                {
                    def.NeedOverride = true;
                });

                var ceWebPart = ModelGeneratorService.GetRandomDefinition <ContentEditorWebPartDefinition>(def =>
                {
                    def.ChromeType = BuiltInPartChromeType.TitleOnly;

                    def.ZoneId    = "wpz";
                    def.ZoneIndex = 1;
                });

                var xsltWebPart = ModelGeneratorService.GetRandomDefinition <XsltListViewWebPartDefinition>(def =>
                {
                    def.ChromeType = BuiltInPartChromeType.TitleOnly;

                    def.ZoneId    = "wpz";
                    def.ZoneIndex = 1;

                    def.ListTitle        = library.Title;
                    def.AddToPageContent = true;
                });


                var model = SPMeta2Model.NewWebModel(web =>
                {
                    web
                    .AddList(library)
                    .AddHostList(BuiltInListDefinitions.SitePages, list =>
                    {
                        var id_1 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
                        var id_2 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');

                        ceWebPart.Id   = id_1;
                        xsltWebPart.Id = id_2;

                        list.AddWikiPage(wikiPage, page =>
                        {
                            // content is changed for CSOM
                            // validation won't pass it, so turn off
                            page.RegExcludeFromValidation();

                            var wpId11 = id_1.Replace("g_", string.Empty).Replace("_", "-");
                            var wpId22 = id_2.Replace("g_", string.Empty).Replace("_", "-");

                            var pageTemplate = new StringBuilder();

                            pageTemplate.AppendFormat("​​​​​​​​​​​​​​​​​​​​​​<div class='ms-rtestate-read ms-rte-wpbox' contentEditable='false'>");
                            pageTemplate.AppendFormat("     <div class='ms-rtestate-read {0}' id='div_{0}'>", wpId11);
                            pageTemplate.AppendFormat("     </div>");
                            pageTemplate.AppendFormat("</div>");

                            pageTemplate.AppendFormat("<div>");
                            pageTemplate.AppendFormat(" SPMeta2 wiki page.");
                            pageTemplate.AppendFormat("</div>");

                            pageTemplate.AppendFormat("​​​​​​​​​​​​​​​​​​​​​​<div class='ms-rtestate-read ms-rte-wpbox' contentEditable='false'>");
                            pageTemplate.AppendFormat("     <div class='ms-rtestate-read {0}' id='div_{0}'>", wpId22);
                            pageTemplate.AppendFormat("     </div>");
                            pageTemplate.AppendFormat("</div>");

                            (page.Value as WikiPageDefinition).Content = pageTemplate.ToString();


                            page
                            .AddWebPart(ceWebPart)
                            .AddXsltListViewWebPart(xsltWebPart);
                        })
                        // we need to ensure that mentioned web part are on the target page, literally
                        .AddDefinitionNode(new WebpartPresenceOnPageDefinition
                        {
                            PageFileName       = wikiPage.FileName,
                            WebPartDefinitions = new List <WebPartDefinitionBase>(new WebPartDefinition[]
                            {
                                ceWebPart,
                                xsltWebPart
                            })
                        }, def =>
                        {
                            def.RegExcludeFromEventsValidation();
                        });
                    });
                });

                TestModel(model);
            });
        }
예제 #26
0
        public void CanDeploy_DependentLookupField_OnList()
        {
            var masterList = ModelGeneratorService.GetRandomDefinition <ListDefinition>();
            var childList  = ModelGeneratorService.GetRandomDefinition <ListDefinition>();

            var lookupField = ModelGeneratorService.GetRandomDefinition <LookupFieldDefinition>(def =>
            {
                def.ShowInNewForm      = true;
                def.ShowInDisplayForm  = true;
                def.ShowInEditForm     = true;
                def.ShowInListSettings = true;
                def.ShowInViewForms    = true;

                def.Hidden              = false;
                def.Required            = false;
                def.AllowMultipleValues = false;

#pragma warning disable 618
                def.LookupListUrl = masterList.GetListUrl();
#pragma warning restore 618
            });

            var dependentIdLookupField = ModelGeneratorService.GetRandomDefinition <DependentLookupFieldDefinition>(
                def =>
            {
                def.LookupField          = BuiltInInternalFieldNames.ID;
                def.PrimaryLookupFieldId = lookupField.Id;
            });

            var dependentTitleLookupField = ModelGeneratorService.GetRandomDefinition <DependentLookupFieldDefinition>(
                def =>
            {
                def.LookupField          = BuiltInInternalFieldNames.Title;
                def.PrimaryLookupFieldId = lookupField.Id;
            });

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(masterList, list =>
                {
                    for (var i = 0; i < 10; i++)
                    {
                        list.AddListItem(new ListItemDefinition
                        {
                            Title = string.Format("master item {0} - {1}", i, Rnd.String())
                        });
                    }
                });

                web.AddList(childList, list =>
                {
                    list.AddField(lookupField);
                });
            });

            TestModel(webModel);

            // add dep field
            var depWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(childList, list =>
                {
                    list.AddField(dependentIdLookupField);
                    list.AddField(dependentTitleLookupField);

                    list.AddListView(new ListViewDefinition
                    {
                        Title  = "Test View",
                        Fields = new Collection <string>
                        {
                            BuiltInInternalFieldNames.Edit,
                            BuiltInInternalFieldNames.ID,
                            BuiltInInternalFieldNames.Title,
                            lookupField.InternalName,
                            dependentIdLookupField.InternalName,
                            dependentTitleLookupField.InternalName
                        },
                        IsDefault = true
                    });
                });
            });

            TestModel(depWebModel);
        }
예제 #27
0
        public void CanDeploy_WebpartToWikiPageContent()
        {
            var webModel = SPMeta2Model
                           .NewWebModel(web =>
            {
                web
                .AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    list
                    .AddRandomWikiPage(page =>
                    {
                        var id_1 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
                        var id_2 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');

                        var id_3 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');

                        var wpId11 = id_1
                                     .Replace("g_", string.Empty)
                                     .Replace("_", "-");

                        var wpId22 = id_2
                                     .Replace("g_", string.Empty)
                                     .Replace("_", "-");

                        var pageTemplate = new StringBuilder();

                        pageTemplate.AppendFormat("​​​​​​​​​​​​​​​​​​​​​​<div class='ms-rtestate-read ms-rte-wpbox' contentEditable='false'>");
                        pageTemplate.AppendFormat("     <div class='ms-rtestate-read {0}' id='div_{0}'>", wpId11);
                        pageTemplate.AppendFormat("     </div>");
                        pageTemplate.AppendFormat("</div>");

                        pageTemplate.AppendFormat("<div>");
                        pageTemplate.AppendFormat(" SPMeta2 wiki page.");
                        pageTemplate.AppendFormat("</div>");

                        pageTemplate.AppendFormat("​​​​​​​​​​​​​​​​​​​​​​<div class='ms-rtestate-read ms-rte-wpbox' contentEditable='false'>");
                        pageTemplate.AppendFormat("     <div class='ms-rtestate-read {0}' id='div_{0}'>", wpId22);
                        pageTemplate.AppendFormat("     </div>");
                        pageTemplate.AppendFormat("</div>");

                        (page.Value as WikiPageDefinition).Content = pageTemplate.ToString();

                        page
                        .AddRandomWebpart(wpNode =>
                        {
                            var wp = wpNode.Value as WebPartDefinition;

                            wp.ZoneId           = "wpz";
                            wp.Id               = id_1;
                            wp.AddToPageContent = true;
                        })
                        .AddRandomWebpart(wpNode =>
                        {
                            var wp = wpNode.Value as WebPartDefinition;

                            wp.ZoneId           = "wpz";
                            wp.Id               = id_2;
                            wp.AddToPageContent = true;
                        })
                        .AddRandomWebpart(wpNode =>
                        {
                            var wp = wpNode.Value as WebPartDefinition;

                            wp.ZoneId           = "wpz";
                            wp.Id               = id_3;
                            wp.AddToPageContent = true;
                        });
                    });
                });
            });

            TestModel(webModel);
        }
        public void CanDeploy_WebNavigationSettings_As_TaxonomyProvider()
        {
            var globalTerm   = Rnd.String();
            var currentlTerm = Rnd.String();

            var currentNavigationGroup = new TaxonomyTermGroupDefinition
            {
                Name = string.Format("{0}", globalTerm)
            };

            var currentNavigationTermSet = new TaxonomyTermSetDefinition
            {
                Name = string.Format("{0}", globalTerm)
            };

            var globalNavigationGroup = new TaxonomyTermGroupDefinition
            {
                Name = string.Format("{0}", currentlTerm)
            };

            var globalNavigationTermSet = new TaxonomyTermSetDefinition
            {
                Name = string.Format("{0}", currentlTerm)
            };

            var taxWeb = ModelGeneratorService.GetRandomDefinition <WebDefinition>(def =>
            {
            });

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddSiteFeature(BuiltInSiteFeatures.SharePointServerPublishingInfrastructure.Inherit(def =>
                {
                    def.Enable = true;
                }));

                site.AddTaxonomyTermStore(new TaxonomyTermStoreDefinition
                {
                    UseDefaultSiteCollectionTermStore = true
                },
                                          store =>
                {
                    store.AddTaxonomyTermGroup(currentNavigationGroup, group =>
                    {
                        group.AddTaxonomyTermSet(currentNavigationTermSet, termSet =>
                        {
                            termSet.AddRandomTerm();
                            termSet.AddRandomTerm();
                            termSet.AddRandomTerm();
                        });
                    });

                    store.AddTaxonomyTermGroup(globalNavigationGroup, group =>
                    {
                        group.AddTaxonomyTermSet(globalNavigationTermSet, termSet =>
                        {
                            termSet.AddRandomTerm();
                            termSet.AddRandomTerm();
                            termSet.AddRandomTerm();
                        });
                    });
                });
            });

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddWeb(taxWeb, subWeb =>
                {
                    subWeb.AddWebFeature(BuiltInWebFeatures.SharePointServerPublishing.Inherit(def =>
                    {
                        def.Enable = true;
                    }));

                    subWeb.AddWebNavigationSettings(new WebNavigationSettingsDefinition()
                    {
                        CurrentNavigationSource = BuiltInStandardNavigationSources.TaxonomyProvider,

                        CurrentNavigationUseDefaultSiteCollectionTermStore = true,
                        CurrentNavigationTermSetName = currentNavigationGroup.Name,

                        GlobalNavigationSource = BuiltInStandardNavigationSources.TaxonomyProvider,

                        GlobalNavigationUseDefaultSiteCollectionTermStore = true,
                        GlobalNavigationTermSetName = globalNavigationGroup.Name,

                        DisplayShowHideRibbonAction = true
                    });
                });
            });

            TestModel(siteModel, webModel);
        }
예제 #29
0
        protected LookupFieldEnvironment GetLookupFieldEnvironment(Action <LookupFieldEnvironment> action)
        {
            var result = new LookupFieldEnvironment();

            var dataList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var masterList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var lookupField = GetSingleSelectLookupDefinition(def =>
            {
                def.Indexed = false;
                //def.LookupListTitle = dataList.Title;
            });

            ModelNode childListNode = null;

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddField(lookupField);
            });

            var childWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(dataList, list =>
                {
                    childListNode = list;

                    list
                    .AddRandomListItem()
                    .AddRandomListItem()
                    .AddRandomListItem();
                });
            });

            var masterWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddList(masterList, list =>
                {
                    list.AddListFieldLink(lookupField);
                });
            });

            result.LookupField = lookupField;

            result.ChildList      = dataList;
            result.ChildListNode  = childListNode;
            result.ChildListModel = childWebModel;


            result.MasterList      = masterList;
            result.MasterListModel = masterWebModel;

            result.SiteModel = siteModel;

            if (action != null)
            {
                action(result);
            }

            return(result);
        }
예제 #30
0
        public void CanPassTypedSyntax_WebLevel()
        {
            var model = SPMeta2Model.NewWebModel(web =>
            {
                web.AddClearRecycleBin(new ClearRecycleBinDefinition());

                web
                .AddAnonymousAccessSettings(new AnonymousAccessSettingsDefinition())
                .AddAnonymousAccessSettings(new AnonymousAccessSettingsDefinition());

                web.AddAuditSettings(new AuditSettingsDefinition());
                web.AddWebNavigationSettings(new WebNavigationSettingsDefinition());
                web.AddPageLayoutAndSiteTemplateSettings(new PageLayoutAndSiteTemplateSettingsDefinition());

                web.AddRootWeb(new RootWebDefinition());

                web.AddComposedLookItemLink(new ComposedLookItemLinkDefinition());

                web.AddTreeViewSettings(new TreeViewSettingsDefinition());

                web.AddTopNavigationNode(new TopNavigationNodeDefinition());
                web.AddQuickLaunchNavigationNode(new QuickLaunchNavigationNodeDefinition());

                web.AddMasterPageSettings(new MasterPageSettingsDefinition());
                web.AddRegionalSettings(new RegionalSettingsDefinition());

                web.AddSP2013Workflow(new SP2013WorkflowDefinition());
                web.AddWelcomePage(new WelcomePageDefinition());

                web.AddEventReceiver(new EventReceiverDefinition());

                web
                .AddProperty(new PropertyDefinition())
                .AddProperty(new PropertyDefinition());

                web.AddFeature(new FeatureDefinition());
                web.AddWebFeature(new FeatureDefinition());

                //web.AddSecurityGroup(new SecurityGroupDefinition());
                //web.AddSecurityRole(new SecurityRoleDefinition());

                web.AddWeb(new WebDefinition());

                web.AddField(new FieldDefinition());
                web.AddContentType(new ContentTypeDefinition());

                web.AddUserCustomAction(new UserCustomActionDefinition());

                web.AddList(new ListDefinition(), list =>
                {
                    list.AddDiscussionItem(new DiscussionItemDefinition(), item =>
                    {
                        item.AddDiscussionReplyItem(new DiscussionReplyItemDefinition());
                    });

                    list.AddDocumentSet(new DocumentSetDefinition());

                    list.AddAuditSettings(new AuditSettingsDefinition());

                    list.AddMasterPage(new MasterPageDefinition());
                    list.AddHtmlMasterPage(new HtmlMasterPageDefinition());

                    list
                    .AddProperty(new PropertyDefinition())
                    .AddProperty(new PropertyDefinition());


                    list.AddUniqueContentTypeOrder(new UniqueContentTypeOrderDefinition());
                    list.AddHideContentTypeLinks(new HideContentTypeLinksDefinition());
                    list.AddRemoveContentTypeLinks(new RemoveContentTypeLinksDefinition());

                    list.AddModuleFile(new ModuleFileDefinition(), moduleFile =>
                    {
                        moduleFile.AddSecurityGroupLink(new SecurityGroupDefinition(), group =>
                        {
                            group
                            .AddSecurityRoleLink(BuiltInSecurityRoleNames.Edit)
                            .AddSecurityRoleLink(BuiltInSecurityRoleNames.Design)
                            .AddSecurityRoleLink(BuiltInSecurityRoleNames.Approve);
                        });
                    });

                    list.AddUserCustomAction(new UserCustomActionDefinition());

                    list.AddReusableHTMLItem(new ReusableHTMLItemDefinition());
                    list.AddReusableTextItem(new ReusableTextItemDefinition());

                    list.AddPublishingPage(new PublishingPageDefinition());
                    list.AddPublishingPageLayout(new PublishingPageLayoutDefinition());

                    list.AddComposedLookItem(new ComposedLookItemDefinition());

                    list.AddWelcomePage(new WelcomePageDefinition());

                    list.AddEventReceiver(new EventReceiverDefinition());

                    list.AddField(new FieldDefinition());
                    list.AddContentTypeLink(new ContentTypeLinkDefinition());

                    list.AddListView(new ListViewDefinition(), listView =>
                    {
                        // Enhance 'WebPartDefinition' provision - enabne privision under list views #590
                        // https://github.com/SubPointSolutions/spmeta2/issues/590

                        listView.AddDeleteWebParts(new DeleteWebPartsDefinition());
                        listView.AddWebPart(new WebPartDefinition());
                    });

                    list.AddListItem(new ListItemDefinition(), listItem =>
                    {
                        listItem
                        .AddListItemFieldValue(new ListItemFieldValueDefinition())
                        .AddListItemFieldValues(new ListItemFieldValuesDefinition());
                    });

                    list.AddFolder(new FolderDefinition(), folder =>
                    {
                        folder
                        .AddProperty(new PropertyDefinition())
                        .AddProperty(new PropertyDefinition())

                        .AddDocumentSet(new DocumentSetDefinition())

                        .AddWelcomePage(new WelcomePageDefinition())
                        .AddFolder(new FolderDefinition())
                        .AddListItem(new ListItemDefinition());
                    });

                    list.AddWebPartPage(new WebPartPageDefinition(), page =>
                    {
                        page.AddDeleteWebParts(new DeleteWebPartsDefinition());
                        page.AddWebPart(new WebPartDefinition());
                    });

                    list.AddWikiPage(new WikiPageDefinition(), page =>
                    {
                        page.AddDeleteWebParts(new DeleteWebPartsDefinition());
                        page.AddWebPart(new WebPartDefinition());
                    });

                    list.AddPublishingPage(new PublishingPageDefinition(), page =>
                    {
                        page.AddDeleteWebParts(new DeleteWebPartsDefinition());
                        page.AddWebPart(new WebPartDefinition());
                    });
                });
            });
        }