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;
        }
Example #2
0
        public virtual void Process(GetFacetMemberValuesArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNullOrEmpty(args.FacetName, "args.FacetName");

            var type = ContactFacetHelper.GetContractTypeForFacet(args.FacetName);

            if (type == null ||
                !typeof(IDemandbaseData).IsAssignableFrom(type))
            {
                return;
            }

            var taxonomy = Factory.CreateObject("demandbaseTaxonomy", true) as DemandbaseTaxonomy;

            if (taxonomy == null ||
                (!taxonomy.MemberValues.ContainsKey(args.MemberName)))
            {
                return;
            }

            taxonomy
            .MemberValues[args.MemberName]
            .ForEach(m => args.Values.Add(m.Description, m.Value));
        }
        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 = IDTableHelper.GenerateIdForFacetMember(member, parentId, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberTemplate);
                    AddContactFacetMemberValues(facetName, member.Name, memberId);
                }
            }
        }
Example #4
0
        protected virtual void AddChildIDsForContactFacetItem(IDList ids, ItemDefinition itemDefinition, CallContext context)
        {
            var facetName    = IDTableHelper.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 = IDTableHelper.GenerateIdForFacetMember(member, itemDefinition.ID, Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberTemplate);
                    ids.Add(id);
                }
            }
        }
Example #5
0
        public virtual void Process(GetFacetMemberValuesArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNullOrEmpty(args.FacetName, "args.FacetName");
            var type = ContactFacetHelper.GetContractTypeForFacet(args.FacetName);

            if (type == null)
            {
                return;
            }
            if (!typeof(IEmployeeData).IsAssignableFrom(type))
            {
                return;
            }
            if (args.MemberName == "Location")
            {
                args.Values.Add("NA", "North America");
                args.Values.Add("SA", "South America");
                args.Values.Add("EU", "Europe");
                args.Values.Add("APAC", "Asia-Pacific");
            }
        }