Esempio n. 1
0
        public CmsPageDocumentSource(IEnumerable <ISearchDocumentBuilderExtension> extensions)
        {
            _customFields = new Lazy <IReadOnlyCollection <DocumentField> >(() =>
            {
                var pageDocFields  = DataTypeSearchReflectionHelper.GetDocumentFields(typeof(IPage));
                var metaDataFields = PageMetaDataFacade.GetAllMetaDataTypes()
                                     .SelectMany(dataType => DataTypeSearchReflectionHelper.GetDocumentFields(dataType, false));

                return(pageDocFields
                       .Concat(metaDataFields)
                       .ExcludeDuplicateKeys(f => f.Name)
                       .ToList());
            });

            _docBuilderExtensions = extensions;

            _changesIndexNotifier = new DataChangesIndexNotifier(
                _listeners, typeof(IPage),
                (data, culture) =>
            {
                var page        = (IPage)data;
                var entityToken = GetAdministratedEntityToken(page);
                return(entityToken != null ? FromPage(page, entityToken, null) : null);
            },
                data => GetDocumentId((IPage)data));

            _changesIndexNotifier.Start();
        }
        private void initializeCodeActivity_UpdateBindings_ExecuteCode(object sender, EventArgs e)
        {
            IPageTypeMetaDataTypeLink pageTypeMetaDataTypeLink = DataFacade.BuildNew<IPageTypeMetaDataTypeLink>();
            pageTypeMetaDataTypeLink.Id = Guid.NewGuid();

            Dictionary<string, string> piggybag = PiggybagSerializer.Deserialize(this.ExtraPayload);

            DataEntityToken dataEntityToken = piggybag.GetParentEntityTokens().FindDataEntityToken(typeof(IPageType));
            IPageType parentPageType = (IPageType)dataEntityToken.Data;

            pageTypeMetaDataTypeLink.PageTypeId = parentPageType.Id;

            this.Bindings.Add("CompositionDescriptionName", "");
            this.Bindings.Add("CompositionDescriptionLabel", "");

            this.Bindings.Add("NewMetaDataTypeLink", pageTypeMetaDataTypeLink);

            List<KeyValuePair<Guid, string>> metaDataTypeOptions =
                PageMetaDataFacade.GetAllMetaDataTypes().
                ToList(f => new KeyValuePair<Guid, string>(f.GetImmutableTypeId(), f.GetTypeTitle()));

            this.Bindings.Add("MetaDataTypeOptions", metaDataTypeOptions);

            List<KeyValuePair<Guid, string>> metaDataContainerOptions = PageMetaDataFacade.GetAllMetaDataContainers();

            this.Bindings.Add("MetaDataContainerOptions", metaDataContainerOptions);
            this.Bindings.Add("CompositionContainerId", metaDataContainerOptions.First().Key);

            this.BindingsValidationRules.Add("CompositionDescriptionName", new List<ClientValidationRule> { new NotNullClientValidationRule(), new StringLengthClientValidationRule(1, 128) });
            this.BindingsValidationRules.Add("CompositionDescriptionLabel", new List<ClientValidationRule> { new NotNullClientValidationRule(), new StringLengthClientValidationRule(1, 256) });
        }
        public CmsPageDocumentSource()
        {
            _customFields = new Lazy <ICollection <DocumentField> >(() =>
            {
                var pageDocFields  = DataTypeSearchReflectionHelper.GetDocumentFields(typeof(IPage));
                var metaDataFields = PageMetaDataFacade.GetAllMetaDataTypes()
                                     .SelectMany(dataType => DataTypeSearchReflectionHelper.GetDocumentFields(dataType, false));

                return(pageDocFields
                       .Concat(metaDataFields)
                       .ExcludeDuplicateKeys(f => f.Name)
                       .Evaluate());
            });

            _changesIndexNotifier = new DataChangesIndexNotifier(
                _listeners, typeof(IPage),
                data =>
            {
                var page        = (IPage)data;
                var entityToken = GetAdministratedEntityToken(page);
                return(entityToken != null ? FromPage(page, entityToken) : null);
            },
                data => GetDocumentId((IPage)data));

            _changesIndexNotifier.Start();
        }
Esempio n. 4
0
        public static IEnumerable <KeyValuePair <Type, string> > DataTypesList()
        {
            IEnumerable <Type> generatedInterfaces = DataFacade.GetGeneratedInterfaces().OrderBy(t => t.FullName);

            //all type expept metatypes
            generatedInterfaces = generatedInterfaces.Except(PageMetaDataFacade.GetAllMetaDataTypes());

            generatedInterfaces = generatedInterfaces.OrderBy(t => t.FullName);
            return(generatedInterfaces.Select(type => new KeyValuePair <Type, string>(type, type.FullName)).ToList());
        }
Esempio n. 5
0
        public void Pack(PackageCreator creator)
        {
            if (Id == _pagesName)
            {
                #region All Pages
                HashSet <Guid> pages;
                using (var scope = new DataScope(DataScopeIdentifier.Administrated))
                {
                    pages = DataFacade.GetData <IPage>().Select(p => p.Id).ToHashSet();
                }

                creator.AddData(typeof(IPage), DataScopeIdentifier.Public, d => pages.Contains((d as IPage).Id));
                creator.AddData(typeof(IPage), DataScopeIdentifier.Administrated, d => pages.Contains((d as IPage).Id));
                creator.AddData(typeof(IPagePlaceholderContent), DataScopeIdentifier.Public, d => pages.Contains((d as IPagePlaceholderContent).PageId));
                creator.AddData(typeof(IPagePlaceholderContent), DataScopeIdentifier.Administrated, d => pages.Contains((d as IPagePlaceholderContent).PageId));
                creator.AddData(typeof(IPageStructure), DataScopeIdentifier.Public, d => pages.Contains((d as IPageStructure).Id));
                #endregion
            }
            else if (Id == _mediasName)
            {
                creator.AddData(typeof(IMediaFileData));
                creator.AddData(typeof(IMediaFolderData));
                creator.AddFilesInDirectory(@"App_Data\Media\");
            }
            else if (Id == _datatypesName)
            {
                IEnumerable <Type> pageDataTypeInterfaces = PageFolderFacade.GetAllFolderTypes();
                IEnumerable <Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

                foreach (var pageDataType in pageDataTypeInterfaces)
                {
                    creator.AddDataTypeData(pageDataType);
                }
                foreach (var pageMetaType in pageMetaTypeInterfaces)
                {
                    creator.AddDataTypeData(pageMetaType);
                }
            }
            else if (Id == _applicationsName)
            {
                creator.AddData <IDataItemTreeAttachmentPoint>();
            }
            else if (Id == _metatypesName)
            {
                IEnumerable <Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

                foreach (var pageMetaType in pageMetaTypeInterfaces)
                {
                    creator.AddDataTypeData(pageMetaType);
                }
            }
            return;
        }
Esempio n. 6
0
        private List <IData> GetMetaData(Guid pageId, Guid versionId, PublicationScope publicationScope, CultureInfo culture)
        {
            var result = new List <IData>();

            using (var conn = new DataConnection(publicationScope, culture))
            {
                conn.DisableServices();

                foreach (var metaDataType in PageMetaDataFacade.GetAllMetaDataTypes()
                         .Where(type => typeof(IPageMetaData).IsAssignableFrom(type)))
                {
                    result.AddRange(DataFacade.GetData(metaDataType).OfType <IPageMetaData>()
                                    .Where(md => md.PageId == pageId && md.VersionId == versionId));
                }
            }

            return(result);
        }
Esempio n. 7
0
        private Dictionary <Tuple <Guid, Guid>, List <IData> > GetAllMetaData(PublicationScope publicationScope, CultureInfo culture)
        {
            var result = new Dictionary <Tuple <Guid, Guid>, List <IData> >();

            using (var conn = new DataConnection(publicationScope, culture))
            {
                conn.DisableServices();

                foreach (var metaDataType in PageMetaDataFacade.GetAllMetaDataTypes()
                         .Where(type => typeof(IPageMetaData).IsAssignableFrom(type)))
                {
                    foreach (var dataItem in DataFacade.GetData(metaDataType).OfType <IPageMetaData>())
                    {
                        var key  = new Tuple <Guid, Guid>(dataItem.PageId, dataItem.VersionId);
                        var list = result.GetOrAdd(key, () => new List <IData>());
                        list.Add(dataItem);
                    }
                }
            }

            return(result);
        }
Esempio n. 8
0
        internal void AddDataTypeData(Type type)
        {
            IEnumerable <Type> globalDataTypeInterfaces = DataFacade
                                                          .GetAllInterfaces(UserType.Developer)
                                                          .Where(interfaceType => interfaceType.Assembly != typeof(IData).Assembly)
                                                          .OrderBy(t => t.FullName)
                                                          .Except(PageFolderFacade.GetAllFolderTypes())
                                                          .Except(PageMetaDataFacade.GetAllMetaDataTypes());

            IEnumerable <Type> pageDataTypeInterfaces = PageFolderFacade.GetAllFolderTypes();
            IEnumerable <Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

            DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(type);

            var resolvedType = dataTypeDescriptor.GetInterfaceType();

            // TODO: make by association
            if (globalDataTypeInterfaces.Contains(resolvedType))
            {
                AddData(type);
            }
            else if (pageDataTypeInterfaces.Contains(resolvedType))
            {
                AddData <IPageFolderDefinition>(d => d.FolderTypeId == dataTypeDescriptor.DataTypeId);
                AddData(type);
            }
            else if (pageMetaTypeInterfaces.Contains(resolvedType))
            {
                foreach (var j in DataFacade.GetData <IPageMetaDataDefinition>(d => d.MetaDataTypeId == dataTypeDescriptor.DataTypeId))
                {
                    //Add only one MetaTypeTab
                    AddData <ICompositionContainer>(d => d.Id == j.MetaDataContainerId);
                }
                AddData <IPageMetaDataDefinition>(d => d.MetaDataTypeId == dataTypeDescriptor.DataTypeId);
                AddData(type);
            }
        }
    private IEnumerable <Type> GetGlobalDataTypes()
    {
        Func <Type, bool> typePredicate = f => (f != typeof(IPage)) && (PageFolderFacade.GetAllFolderTypes().Contains(f) == false) && (PageMetaDataFacade.GetAllMetaDataTypes().Contains(f) == false);

        return(DataFacade.GetGeneratedInterfaces().Where(typePredicate).OrderBy(t => t.FullName));
    }
        private IEnumerable <Type> GetAddebleTypes()
        {
            IEnumerable <Type> accociationTypes = PageMetaDataFacade.GetAllMetaDataTypes();

            return(accociationTypes);
        }