public IItemSource FillItemSourceGaps(IItemSource userSource)
    {
      bool isNullSource = (null == this.defaultSource);
      bool isNullInput = (null == userSource);

      if (isNullSource && isNullInput)
      {
        return null;
      }
      else if (isNullInput)
      {
        return this.defaultSource.ShallowCopy();
      }
      else if (isNullSource)
      {
        return userSource.ShallowCopy();
      }


      string database = (null != userSource.Database) ? userSource.Database : this.defaultSource.Database;
      string language = (null != userSource.Language) ? userSource.Language : this.defaultSource.Language;
      int? version = (null != userSource.VersionNumber) ? userSource.VersionNumber : this.defaultSource.VersionNumber;


      return new ItemSource(database, language, version);
    }
 public ScheduleIndexJobs(SourceStorageFactory sourceStorageFactory, IScheduler scheduler)
 {
     _sourceStorageFactory = sourceStorageFactory;
     _scheduler = scheduler;
     Sources = new IItemSource[] { };
     Converters = new IConverter[] { };
 }
 private SourceStorage For(IItemSource source)
 {
     return new SourceStorage(_directoryFactory.DirectoryFor(source.Id,
                                                             source.Persistent),
                              _learningRepository,
                              _converterRepository);
 }
 public CreateItemByIdParameters(ISessionConfig sessionSettings, IItemSource itemSource, IQueryParameters queryParameters, CreateItemParameters createParameters, string itemId)
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.ItemId = itemId;
   this.QueryParameters = queryParameters;
   this.CreateParameters = createParameters;
 }
 public UpdateItemByPathParameters(ISessionConfig sessionSettings, IItemSource itemSource, IQueryParameters queryParameters, IDictionary<string, string> fieldsRawValuesByName, string itemPath)
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.ItemPath = itemPath;
   this.QueryParameters = queryParameters;
   this.FieldsRawValuesByName = fieldsRawValuesByName;
 }
    public ItemSourceUrlBuilder(IRestServiceGrammar restGrammar, IWebApiUrlParameters webApiGrammar, IItemSource itemSource)
    {
      this.itemSource = itemSource;
      this.restGrammar = restGrammar;
      this.webApiGrammar = webApiGrammar;

      this.Validate();
    }
        public void DeleteDocumentForObject(IndexWriter writer, IndexReader indexReader, IItemSource source, object item)
        {
            var document = _converterRepository.ToDocument(source, item);

            var id = document.GetDocumentId();
            var documentId = id.GetId();
            PopDocument(writer, indexReader, documentId);
        }
 public ReadRenderingHtmlParameters(ISessionConfig sessionSettings, IItemSource itemSource, IDictionary<string, string> parametersValuesByName, string sourceId, string renderingId)
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.SourceId = sourceId;
   this.RenderingId = renderingId;
   this.ParametersValuesByName = parametersValuesByName;
 }
    public ItemSourceFieldMerger(IItemSource defaultSource)
    {
      if (null == defaultSource)
      {
        return;
      }

      this.defaultSource = defaultSource.ShallowCopy();
    }
    public void TearDown()
    {
      this.builderForId = null;
      this.builderForPath = null;
      this.builderForQuery = null;

      this.sessionConfig = null;
      this.sitecoreShellConfig = null;
      this.defaultSource = null;
    }
 public MediaResourceUploadParameters
 (
   ISessionConfig sessionSettings,
   IItemSource itemSource,
   UploadMediaOptions uploadOptions
 )
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.UploadOptions = uploadOptions;
 }
 public ReadItemByQueryParameters(
   ISessionConfig sessionSettings,
   IItemSource itemSource,
   IQueryParameters queryParameters,
   IPagingParameters pagingSettings,
   string sitecoreQuery)
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.SitecoreQuery = sitecoreQuery;
   this.QueryParameters = queryParameters;
   this.PagingSettings = pagingSettings;
 }
        public void AppendItems(IItemSource source, params object[] items)
        {
            using (var indexWriter = GetIndexWriter())
            using (var indexReader = indexWriter.GetReader())
            {
                foreach (var item in items)
                {
                    UpdateDocumentForObject(indexWriter, indexReader, source, EmptyTag, item);
                }

                indexWriter.Commit();
            }
        }
 public MediaResourceDownloadParameters
 (
   ISessionConfig sessionSettings,
   IItemSource itemSource,
   IDownloadMediaOptions downloadOptions,
   string mediaPath
 )
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.MediaPath = mediaPath;
   this.DownloadOptions = downloadOptions;
 }
 public ReadItemsByIdParameters(
   ISessionConfig sessionSettings, 
   IItemSource itemSource, 
   IQueryParameters queryParameters, 
   IPagingParameters pagingSettings,
   string itemId)
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.ItemId = itemId;
   this.QueryParameters = queryParameters;
   this.PagingSettings = pagingSettings;
 }
    public MediaItemUrlBuilder(
      IRestServiceGrammar restGrammar,
      IWebApiUrlParameters webApiGrammar,
      ISessionConfig sessionConfig,
      IMediaLibrarySettings mediaSettings,
      IItemSource itemSource)
    {
      this.itemSource = itemSource;
      this.restGrammar = restGrammar;
      this.webApiGrammar = webApiGrammar;
      this.mediaSettings = mediaSettings;
      this.sessionConfig = sessionConfig;

      this.Validate();
    }
        public void IndexItems(IItemSource source, IEnumerable<object> items)
        {
            using (var indexWriter = GetIndexWriter())
            using (var indexReader = indexWriter.GetReader())
            {
                var newTag = Guid.NewGuid().ToString();

                foreach (var item in items)
                {
                    UpdateDocumentForObject(indexWriter, indexReader, source, newTag, item);
                }

                DeleteDocumentsForSourceWithoutTag(indexWriter, source, newTag);

                indexWriter.Commit();
            }
        }
 public int GetFrequencyForItemSource(IItemSource source)
 {
     var name = source.GetType().AssemblyQualifiedName;
     if (!IndexingFrequencyForPlugin.ContainsKey(name))
     {
         var alternateName = string.Format("{0}, {1}", source.GetType().FullName,
                                           source.GetType().Assembly.GetName().Name);
         if (!IndexingFrequencyForPlugin.ContainsKey(alternateName))
         {
             IndexingFrequencyForPlugin[name] = DefaultFrequency;
         }
         else
         {
             return IndexingFrequencyForPlugin[alternateName];
         }
     }
     return IndexingFrequencyForPlugin[name];
 }
    public IItemSource FillItemSourceGapsForMediaUpload(IItemSource userSource)
    {
      bool isNullSource = (null == this.defaultSource);
      bool isNullInput = (null == userSource);

      if (isNullSource && isNullInput)
      {
        return null;
      }
      else if (isNullInput)
      {
        return this.defaultSource.ShallowCopy();
      }
      else if (isNullSource)
      {
        return userSource.ShallowCopy();
      }


      string database = (null != userSource.Database) ? userSource.Database : this.defaultSource.Database;

      return new ItemSource(database, null, null);
    }
    public ScItem(
    IItemSource source,
    string displayName,
    bool hasChildren,
    string id,
    string longId,
    string path,
    string template,
    Dictionary<string, IField> fieldsByName)
    {
      this.Source = source;
      this.DisplayName = displayName;
      this.HasChildren = hasChildren;
      this.Id = id;
      this.LongId = longId;
      this.Path = path;
      this.Template = template;
      this.FieldsByName = fieldsByName;

      int fieldsCount = fieldsByName.Count;
      IField[] fields = new IField[fieldsCount];
      fieldsByName.Values.CopyTo(fields, 0);
      this.Fields = fields;
    }
    public void SetUp()
    {
      IRestServiceGrammar restGrammar = RestServiceGrammar.ItemWebApiV2Grammar();
      IWebApiUrlParameters webApiGrammar = WebApiUrlParameters.ItemWebApiV2UrlParameters();

      this.builderForId = new ItemByIdUrlBuilder(restGrammar, webApiGrammar);
      this.builderForPath = new ItemByPathUrlBuilder(restGrammar, webApiGrammar);
      this.builderForQuery = new ItemByQueryUrlBuilder(restGrammar, webApiGrammar);

      this.defaultSource = new ItemSourcePOD(null, null, null);

      SessionConfigPOD mutableSessionConfig = new SessionConfigPOD();
      mutableSessionConfig.ItemWebApiVersion = "v1";
      mutableSessionConfig.InstanceUrl = "tumba.yumba";
      mutableSessionConfig.Site = null;
      this.sessionConfig = mutableSessionConfig;


      mutableSessionConfig = new SessionConfigPOD();
      mutableSessionConfig.ItemWebApiVersion = "v234";
      mutableSessionConfig.InstanceUrl = "trololo.net";
      mutableSessionConfig.Site = "/sitecore/shell";
      this.sitecoreShellConfig = mutableSessionConfig;
    }
Beispiel #22
0
 /// <summary>
 /// Populates the document from the converter
 /// </summary>
 /// <param name="itemSource">item from which this document was retrieved</param>
 /// <param name="converter">converter identifier</param>
 /// <param name="id">item identifier</param>
 /// <param name="name">item name that is used to be indexed</param>
 /// <param name="type">Type name used in the indexer and later on in the searcher to allow the user to filter by type
 /// Search would be something like "process firefox"</param>
 /// <returns></returns>
 public CoreDocument(IItemSource itemSource, IConverter converter, string id, string name, string type)
 {
     _document = new Document();
     PopulateDocument(itemSource.Id, converter.GetId(), id, name, type);
 }
Beispiel #23
0
 public virtual void NotifyItemRangeChanged(IItemSource source, int startRange, int endRange)
 {
 }
Beispiel #24
0
 public virtual void NotifyItemRangeRemoved(IItemSource source, int startIndex, int count)
 {
 }
Beispiel #25
0
 public virtual void NotifyItemRemoved(IItemSource source, int startIndex)
 {
 }
        public void RemoveItems(IItemSource source, params object[] items)
        {
            using (var indexWriter = GetIndexWriter())
            using (var indexReader = indexWriter.GetReader())
            {
                foreach (var item in items)
                {
                    DeleteDocumentForObject(indexWriter, indexReader, source, item);
                }

                indexWriter.Commit();
            }
        }
Beispiel #27
0
 public void AssertItemSourcesAreEqual(IItemSource expected, IItemSource actual)
 {
     Assert.AreEqual(expected.Database, actual.Database);
     Assert.AreEqual(expected.Language, actual.Language);
     Assert.AreEqual(expected.VersionNumber, actual.VersionNumber);
 }
Beispiel #28
0
 public virtual void NotifyItemChanged(IItemSource source, int startIndex)
 {
 }
Beispiel #29
0
 public virtual void NotifyItemInserted(IItemSource source, int startIndex)
 {
 }
Beispiel #30
0
 public virtual void NotifyItemMoved(IItemSource source, int fromPosition, int toPosition)
 {
 }
        private void UpdateDocumentForObject(IndexWriter writer, IndexReader reader, IItemSource source, string tag, object item)
        {
            var document = _converterRepository.ToDocument(source, item);

            var id = document.GetDocumentId();
            var documentId = id.GetId();
            var learningId = id.GetLearningId();

            PopDocument(writer, reader, documentId); //deleting the old version of the doc

            document.SetLearnings(_learningRepository.LearningsFor(learningId));
            if (tag != null)
            {
                document.Tag(tag);
            }

            writer.AddDocument(document);
        }
Beispiel #32
0
 public virtual void NotifyItemRangeMoved(IItemSource source, int fromPosition, int toPosition, int count)
 {
 }
 public UserRequestMerger(ISessionConfig defaultSessionConfig, IItemSource defaultSource)
 {
   this.ItemSourceMerger = new ItemSourceFieldMerger(defaultSource);
   this.SessionConfigMerger = new SessionConfigMerger(defaultSessionConfig);
 }
        public void RemoveItemsById(IItemSource source, params DocumentId[] itemIds)
        {
            using (var indexWriter = GetIndexWriter())
            using (var indexReader = indexWriter.GetReader())
            {
                foreach (var item in itemIds)
                {
                    PopDocument(indexWriter, indexReader, item.GetId());
                }

                indexWriter.Commit();
            }
        }
 private void DeleteDocumentsForSourceWithoutTag(IndexWriter indexWriter, IItemSource source, string tag)
 {
     var query = new BooleanQuery();
     query.Add(new BooleanClause(new TermQuery(new Term(SpecialFields.SourceId, source.Id)),
                                 Occur.MUST));
     query.Add(new BooleanClause(new TermQuery(new Term(SpecialFields.Tag, EmptyTag)),
                                 Occur.MUST_NOT));
     query.Add(new BooleanClause(new TermQuery(new Term(SpecialFields.Tag, tag)),
                                 Occur.MUST_NOT));
     indexWriter.DeleteDocuments(query);
 }
 public void AssertItemSourcesAreEqual(IItemSource expected, IItemSource actual)
 {
   Assert.AreEqual(expected.Database, actual.Database);
   Assert.AreEqual(expected.Language, actual.Language);
   Assert.AreEqual(expected.VersionNumber, actual.VersionNumber);
 }