public ArticlesCategoryViewModelMapper(IUmbracoContextProvider umbracoConextProvider, IContentMapper <Article> contentMapper,
                                        IMapperProvider mapperProvider, IArticlesSerivce articlesService) : base(umbracoConextProvider)
 {
     _contentMapper   = contentMapper;
     _mapperProvider  = mapperProvider;
     _articlesService = articlesService;
 }
Exemplo n.º 2
0
        private string GetExportIds(PropertyType propType, XElement value)
        {
            // (need to strip cdata from value)
            var val = GetImportXml(value);

            if (!string.IsNullOrWhiteSpace(val))
            {
                var mapping = uSyncCoreContext.Instance.Configuration.Settings.ContentMappings
                              .SingleOrDefault(x => x.EditorAlias == propType.PropertyEditorAlias);


                if (mapping != null)
                {
                    LogHelper.Debug <Events>("Mapping Content Export: {0} {1}", () => mapping.EditorAlias, () => mapping.MappingType);

                    IContentMapper mapper = ContentMapperFactory.GetMapper(mapping);

                    if (mapper != null)
                    {
                        return(mapper.GetExportValue(propType.DataTypeDefinitionId, val));
                    }
                }
            }
            return(GetInnerXml(value));
        }
Exemplo n.º 3
0
 public GalleryCategoryViewModelMapper(IUmbracoContextProvider umbracoConextProvider, IGalleryService gelleryService,
                                       IMapperProvider mapperProvieder, IContentMapper <Gallery> contentMapper)
     : base(umbracoConextProvider)
 {
     _galleryService  = gelleryService;
     _mapperProvieder = mapperProvieder;
     _contentMapper   = contentMapper;
 }
Exemplo n.º 4
0
 public NewsCategoryViewModelMapper(IUmbracoContextProvider umbracoConextProvider, IContentMapper <News> contentMapper,
                                    IMapperProvider mapperProvider, INewsService newsService)
     : base(umbracoConextProvider)
 {
     _contentMapper  = contentMapper;
     _mapperProvider = mapperProvider;
     _newsService    = newsService;
 }
Exemplo n.º 5
0
        public void Load(ContentLoaderConfiguration configuration, bool hasSchema = true)
        {
            using (var package = ExcelPackage.Open(configuration.FilePath))
            {
                foreach (var worksheet in package.Workbook.Worksheets)
                {
                    var type = GetType(worksheet.Name);
                    if (type == ContentLoadType.None)
                    {
                        continue;
                    }

                    var descriptor  = GetTableDescriptor(worksheet, hasSchema, type);
                    var searcher    = new Searcher(_tables, descriptor, type, hasSchema);
                    var columnNames = OpenXmlManager.ReadColumnsNames(package, descriptor);

                    IContentMapper <TTableContent> tableContentMapper = null;
                    if (type.HasFlag(ContentLoadType.Table))
                    {
                        tableContentMapper = new ContentMapper <TTableContent>(columnNames);
                    }
                    IContentMapper <TColumnContent> columnContentMapper = null;
                    if (type.HasFlag(ContentLoadType.Column))
                    {
                        columnContentMapper = new ContentMapper <TColumnContent>(columnNames);
                    }

                    var currentRow = descriptor.BeginRow;
                    foreach (var data in OpenXmlManager.Read(package, descriptor))
                    {
                        currentRow++;

                        TTable  table;
                        TColumn column;
                        searcher.Search(data, out table, out column);

                        if (column != null && columnContentMapper != null)
                        {
                            columnContentMapper.Map(column.Content, data);
                            continue;
                        }
                        if (!type.HasFlag(ContentLoadType.Table))
                        {
                            //TODO: Log not found column if type is Column
                            continue;
                        }
                        if (table != null && tableContentMapper != null)
                        {
                            tableContentMapper.Map(table.Content, data);
                            // ReSharper disable once RedundantJumpStatement
                            continue;
                        }
                        //TODO: Log not found table
                    }
                }
            }
        }
Exemplo n.º 6
0
 public SubCategoryGamesViewModelMapper(IUmbracoContextProvider umbracoConextProvider, IBaseCategoriesService <SubCategoryGames> categoryService,
                                        IContentMapper <Game> gameMapper, IMapperProvider mapperProvider, IBaseCategoriesService <CategoriesGames> categoriesService)
     : base(umbracoConextProvider)
 {
     _categoryService   = categoryService;
     _gameMapper        = gameMapper;
     _mapperProvider    = mapperProvider;
     _categoriesService = categoriesService;
 }
 public CategoriesMoviesViewModelMapper(IUmbracoContextProvider umbracoConextProvider,
                                        IContentMapper <SubCategoryMovies> subCategoryMoviesMapper,
                                        IMapperProvider mapperProvider, IContentMapper <Movie> moviesMapper, IBaseCategoriesService <CategoriesMovies> categoriesService
                                        ) : base(umbracoConextProvider)
 {
     _subCategoryMoviesMapper = subCategoryMoviesMapper;
     _mapperProvider          = mapperProvider;
     _moviesMapper            = moviesMapper;
     _categoriesService       = categoriesService;
 }
 public DataMappingController(IPageManager _pagemanager, IGenericGetter <UserGroup> _groupsGetter,
                              IPrimaryDBGetters _dsStatusGetter, IGenericGetter <DataSource> _dataSourceGetter,
                              IContentMapper <DataSourceStudyStatus, LocalStudyStatus> _mapManager,
                              IGenericGetter <StudyStatusMapping> _statusMap)
 {
     this.pagemanager      = _pagemanager;
     this.groupsGetter     = _groupsGetter;
     this.dsStatusGetter   = _dsStatusGetter;
     this.dataSourceGetter = _dataSourceGetter;
     this.mapManager       = _mapManager;
     this.statusMap        = _statusMap;
 }
        private string GetValue(string value, bool exporting)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }

            var items = JsonConvert.DeserializeObject <EmbeddedContentItem[]>(value);

            foreach (EmbeddedContentItem item in items)
            {
                IContentType contentType = _contentTypeService.GetContentType(item.ContentTypeAlias);
                if (contentType == null)
                {
                    continue;
                }

                foreach (KeyValuePair <string, object> property in item.Properties.ToList())
                {
                    PropertyType propertyType = contentType.CompositionPropertyTypes.FirstOrDefault(_ => _.Alias == property.Key);
                    if (propertyType == null)
                    {
                        continue;
                    }
                    IDataTypeDefinition dataType = _dataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId);

                    IContentMapper mapper = ContentMapperFactory.GetMapper(new uSyncContentMapping {
                        EditorAlias = dataType.PropertyEditorAlias
                    });
                    if (mapper != null)
                    {
                        string newValue;
                        if (exporting)
                        {
                            newValue = mapper.GetExportValue(dataType.Id, property.Value.ToString());
                        }
                        else
                        {
                            newValue = mapper.GetImportValue(dataType.Id, property.Value.ToString());
                        }
                        item.Properties[property.Key] = newValue;
                    }
                }
            }

            return(JsonConvert.SerializeObject(items, Formatting.Indented));
        }
Exemplo n.º 10
0
        internal string GetImportIds(PropertyType propType, string content)
        {
            var mapping = uSyncCoreContext.Instance.Configuration.Settings.ContentMappings
                          .SingleOrDefault(x => x.EditorAlias == propType.PropertyEditorAlias);

            if (mapping != null)
            {
                LogHelper.Debug <Events>("Mapping Content Import: {0} {1}", () => mapping.EditorAlias, () => mapping.MappingType);

                IContentMapper mapper = ContentMapperFactory.GetMapper(mapping);

                if (mapper != null)
                {
                    return(mapper.GetImportValue(propType.DataTypeDefinitionId, content));
                }
            }

            return(content);
        }
Exemplo n.º 11
0
        public string GetImportValue(int dataTypeDefinitionId, string content)
        {
            // We need to retrieve the datatype associated with the property so that we can parse the fieldset
            // then we will go through each item in the fieldset and if there is a mapper associated with that item's datatype
            // we should pull out the property value and map it

            string archetypeConfig = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinitionId).PreValuesAsDictionary["archetypeConfig"].Value;

            var config = JsonConvert.DeserializeObject <ArchetypePreValue>(archetypeConfig);

            var typedContent = JsonConvert.DeserializeObject <ArchetypeModel>(content);

            foreach (ArchetypePreValueFieldset fieldSet in config.Fieldsets)
            {
                foreach (ArchetypePreValueProperty property in fieldSet.Properties)
                {
                    IDataTypeDefinition dataType = _dataTypeService.GetDataTypeDefinitionById(property.DataTypeGuid);

                    uSyncContentMapping mapping =
                        uSyncCoreContext.Instance.Configuration.Settings.ContentMappings.SingleOrDefault(x => x.EditorAlias == dataType.PropertyEditorAlias);

                    if (mapping != null)
                    {
                        IContentMapper mapper = ContentMapperFactory.GetMapper(mapping);

                        if (mapper != null)
                        {
                            typedContent.Fieldsets.AsQueryable()
                            .SelectMany(fs => fs.Properties)
                            .Where(p => p.Alias == property.Alias)
                            .ForEach(pm => pm.Value = mapper.GetImportValue(dataType.Id, pm.Value.ToString()));
                        }
                    }
                }
            }

            return(typedContent.SerializeForPersistence());
        }
Exemplo n.º 12
0
 public CategoriesGamesService(IContentService contentService, IContentMapper <CategoriesGames> contentMapper, IUmbracoContextProvider umbracoConextProvider)
 {
     _contentService = contentService;
     _contentMapper  = contentMapper;
     _umbraco        = new UmbracoHelper(umbracoConextProvider.GetUmbracoContext());
 }
 public ApiStockQuoteRetriever(IHttpClientWrapper httpClient, IContentMapper contentMapper)
 {
     this.httpClient    = httpClient;
     this.contentMapper = contentMapper;
 }
 public CsvFileStockQuoteRetriever(IFileWrapper fileWrapper, IContentMapper contentMapper)
 {
     this.fileWrapper   = fileWrapper;
     this.contentMapper = contentMapper;
 }
 public VoiceReceiverController(IContentManager manager, IContentMapper mapper, ILog logger)
 {
     _manager = manager;
     _mapper = mapper;
     _logger = logger;
 }
Exemplo n.º 16
0
 public void AddContentMap(IContentMapper mapper)
 {
     maps.Add(mapper);
 }
Exemplo n.º 17
0
 public void AddContentMap(IContentMapper mapper)
 {
     maps.Add(mapper);
 }
Exemplo n.º 18
0
 public void SetUp()
 {
     sut = new DelimiterListContentMapper();
 }
 public void SetUp()
 {
     sut = new JsonContentMapper();
 }