Exemplo n.º 1
0
        public virtual void Process(GetChildIDsArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.ItemDefinition, "args.ItemDefinition");
            Assert.ArgumentNotNull(args.Context, "args.Context");
            //TODO: finish
            var ids = args.IDList;

            var itemId = args.ItemDefinition.ID;

            if (itemId == Sitecore.Strategy.Contacts.DataProviders.ItemIDs.SettingsRoot)
            {
                ids.Add(Sitecore.Strategy.Contacts.DataProviders.ItemIDs.ContactsFolder);
            }
            else if (itemId == Sitecore.Strategy.Contacts.DataProviders.ItemIDs.ContactsFolder)
            {
                ids.Add(Sitecore.Strategy.Contacts.DataProviders.ItemIDs.ContactFacetsFolder);
            }
            else if (itemId == Sitecore.Strategy.Contacts.DataProviders.ItemIDs.ContactFacetsFolder)
            {
                AddChildIDsForContactFacetsRootItem(ids, args.ItemDefinition, args.Context);
            }
            else if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetItem(itemId))
            {
                AddChildIDsForContactFacetItem(ids, args.ItemDefinition, args.Context);
            }
            else if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberItem(itemId))
            {
                AddChildIDsForContactFacetMemberItem(ids, args.ItemDefinition, args.Context);
            }
        }
        public virtual void Process(GetItemFieldsArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.ItemDefinition, "args.ItemDefinition");
            Assert.ArgumentNotNull(args.Context, "args.Context");

            var itemId = args.ItemDefinition.ID;
            var fields = new FieldList();
            var owner  = typeof(ContactFacetDataProvider).Name;

            fields.Add(Sitecore.FieldIDs.CreatedBy, owner);
            fields.Add(Sitecore.FieldIDs.Owner, owner);
            if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetItem(itemId))
            {
                var facetName = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetName(itemId);
                fields.Add(Sitecore.FieldIDs.DisplayName, facetName);
                fields.Add(Sitecore.Strategy.Contacts.DataProviders.FieldIDs.ContactFacetName, facetName);
                var contractType = ContactFacetHelper.GetContractTypeForFacet(facetName);
                if (contractType != null)
                {
                    fields.Add(Sitecore.Strategy.Contacts.DataProviders.FieldIDs.ContactFacetContract, contractType.AssemblyQualifiedName);
                    if (ContactFacetHelper.ContactFacetImplementations.ContainsKey(contractType))
                    {
                        var implType = ContactFacetHelper.ContactFacetImplementations[contractType];
                        if (implType != null)
                        {
                            fields.Add(Sitecore.Strategy.Contacts.DataProviders.FieldIDs.ContactFacetImplementation, implType.AssemblyQualifiedName);
                        }
                    }
                }
            }
            if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberItem(itemId))
            {
                var memberName = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberName(itemId);
                fields.Add(Sitecore.FieldIDs.DisplayName, memberName);
                fields.Add(Sitecore.Strategy.Contacts.DataProviders.FieldIDs.ContactFacetMemberName, memberName);
                var facetId    = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberParentId(itemId);
                var facetName  = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetName(facetId);
                var memberType = ContactFacetHelper.GetFacetMemberType(facetName, memberName);
                if (memberType != null)
                {
                    fields.Add(Sitecore.Strategy.Contacts.DataProviders.FieldIDs.ContactFacetMemberType, memberType.AssemblyQualifiedName);
                }
            }
            if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberValueItem(itemId))
            {
                var value = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberValue(itemId);
                if (!string.IsNullOrEmpty(value))
                {
                    fields.Add(Sitecore.Strategy.Contacts.DataProviders.FieldIDs.ContactFacetMemberValueValue, value);
                }
                var description = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberValueDescription(itemId);
                if (!string.IsNullOrEmpty(description))
                {
                    fields.Add(Sitecore.FieldIDs.DisplayName, description);
                    fields.Add(Sitecore.Strategy.Contacts.DataProviders.FieldIDs.ContactFacetMemberValueDescription, description);
                }
            }
            args.FieldList = fields;
        }
        public virtual void Process(GetParentIDArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.ItemDefinition, "args.ItemDefinition");
            Assert.ArgumentNotNull(args.Context, "args.Context");

            var itemId = args.ItemDefinition.ID;

            if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetItem(itemId))
            {
                args.ParentId = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetParentId(itemId);
            }
            else if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberItem(itemId))
            {
                args.ParentId = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberParentId(itemId);
            }
            else if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberValueItem(itemId))
            {
                args.ParentId = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberValueParentId(itemId);
            }
            else
            {
                base.Process(args);
            }
        }
        public virtual void Process(IsHandledArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.ItemId, "args.ItemId");

            List <ID> ids = null;

            if (args.IncludeAllIds)
            {
                ids = AllHandledIds;
            }
            else
            {
                ids = FullyHandledIds;
            }
            if (ids.Contains(args.ItemId))
            {
                args.IsHandled = true;
                return;
            }
            //
            //ensure the root node has been loaded
            var database = args.Context.DataManager.Database;

            if (database != null)
            {
                if (!rootIsLoaded)
                {
                    lock (lockObject)
                    {
                        if (!rootIsLoaded)
                        {
                            database.GetItem(Sitecore.Strategy.Contacts.DataProviders.ItemIDs.ContactsFolder);
                            //item.GetChildren();
                            rootIsLoaded = true;
                        }
                    }
                }
            }

            if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetItem(args.ItemId))
            {
                args.IsHandled = true;
                return;
            }
            if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberItem(args.ItemId))
            {
                args.IsHandled = true;
                return;
            }
            if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberValueItem(args.ItemId))
            {
                args.IsHandled = true;
                return;
            }

            //TODO: check dynamically generated item ids
        }
        protected virtual void AddFacets(ID parentId)
        {
            var facetNames = ContactFacetHelper.GetFacetNames();

            foreach (var name in facetNames)
            {
                var facetId = ContactFacetIdFactory.GetContactFacetIDProvider().GenerateIdForFacet(name, parentId, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetTemplate);
                AddContactFacetMember(name, facetId);
            }
        }
Exemplo n.º 6
0
        protected virtual void AddChildIDsForContactFacetsRootItem(IDList ids, ItemDefinition itemDefinition, CallContext context)
        {
            var facetNames = ContactFacetHelper.GetFacetNames();

            foreach (var name in facetNames)
            {
                var id = ContactFacetIdFactory.GetContactFacetIDProvider().GenerateIdForFacet(name, itemDefinition.ID, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetTemplate);
                ids.Add(id);
            }
        }
        protected virtual void AddContactFacetMemberValues(string facetName, string memberName, ID parentId)
        {
            var args = new GetFacetMemberValuesArgs(facetName, memberName);

            CorePipeline.Run("getFacetMemberValues", args);
            if (!args.Values.Any())
            {
                return;
            }
            foreach (var pair in args.Values)
            {
                ContactFacetIdFactory.GetContactFacetIDProvider().GenerateIdForFacetMemberValue(pair.Key, pair.Value, parentId, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberValueTemplate);
            }
        }
Exemplo n.º 8
0
        public virtual void Process(GetItemDefinitionArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.ItemId, "args.ItemId");
            Assert.ArgumentNotNull(args.Context, "args.Context");

            //TODO: finish
            if (args.ItemId == Sitecore.Strategy.Contacts.DataProviders.ItemIDs.ContactsFolder)
            {
                args.ItemDefinition = new ItemDefinition(args.ItemId, "Contacts", Sitecore.TemplateIDs.Folder, ID.Null);
                return;
            }
            else if (args.ItemId == Sitecore.Strategy.Contacts.DataProviders.ItemIDs.ContactFacetsFolder)
            {
                args.ItemDefinition = new ItemDefinition(args.ItemId, "Facets", Sitecore.TemplateIDs.Folder, ID.Null);
                return;
            }
            else if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetItem(args.ItemId))
            {
                var key = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetName(args.ItemId);
                if (!string.IsNullOrEmpty(key))
                {
                    args.ItemDefinition = new ItemDefinition(args.ItemId, ItemUtil.ProposeValidItemName(key), Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetTemplate, ID.Null);
                    return;
                }
            }
            else if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberItem(args.ItemId))
            {
                var key = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberName(args.ItemId);
                if (!string.IsNullOrEmpty(key))
                {
                    args.ItemDefinition = new ItemDefinition(args.ItemId, ItemUtil.ProposeValidItemName(key), Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberTemplate, ID.Null);
                    return;
                }
            }
            else if (ContactFacetIdFactory.GetContactFacetIDProvider().IsFacetMemberValueItem(args.ItemId))
            {
                var key = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberValue(args.ItemId);
                if (!string.IsNullOrEmpty(key))
                {
                    args.ItemDefinition = new ItemDefinition(args.ItemId, ItemUtil.ProposeValidItemName(key), Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberValueTemplate, ID.Null);
                    return;
                }
            }
        }
Exemplo n.º 9
0
        protected virtual void AddChildIDsForContactFacetMemberItem(IDList ids, ItemDefinition itemDefinition, CallContext context)
        {
            var itemId     = itemDefinition.ID;
            var facetName  = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberFacetName(itemId);
            var memberName = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetMemberName(itemId);
            var args       = new GetFacetMemberValuesArgs(facetName, memberName);

            CorePipeline.Run("getFacetMemberValues", args);
            if (!args.Values.Any())
            {
                return;
            }
            foreach (var pair in args.Values)
            {
                var id = ContactFacetIdFactory.GetContactFacetIDProvider().GenerateIdForFacetMemberValue(pair.Key, pair.Value, itemId, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberValueTemplate);
                ids.Add(id);
            }
        }
        protected virtual void AddContactFacetMember(string facetName, ID parentId)
        {
            var contractType = ContactFacetHelper.GetContractTypeForFacet(facetName);

            if (contractType == null)
            {
                return;
            }
            var members = contractType.GetMembers();

            foreach (var member in members)
            {
                if (member.MemberType == MemberTypes.Field || member.MemberType == MemberTypes.Property)
                {
                    var memberId = ContactFacetIdFactory.GetContactFacetIDProvider().GenerateIdForFacetMember(member, parentId, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberTemplate);
                    AddContactFacetMemberValues(facetName, member.Name, memberId);
                }
            }
        }
Exemplo n.º 11
0
        protected virtual void AddChildIDsForContactFacetItem(IDList ids, ItemDefinition itemDefinition, CallContext context)
        {
            var facetName    = ContactFacetIdFactory.GetContactFacetIDProvider().GetFacetName(itemDefinition.ID);
            var contractType = ContactFacetHelper.GetContractTypeForFacet(facetName);

            if (contractType == null)
            {
                return;
            }
            var members = contractType.GetMembers();

            foreach (var member in members)
            {
                if (member.MemberType == MemberTypes.Field || member.MemberType == MemberTypes.Property)
                {
                    var id = ContactFacetIdFactory.GetContactFacetIDProvider().GenerateIdForFacetMember(member, itemDefinition.ID, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberTemplate);
                    ids.Add(id);
                }
            }
        }