public static MetadataDefinitionSelectResource ToMetadataDefinitionSelectResource(
     this MetadataDefinitionProjection projection)
 {
     return(new MetadataDefinitionSelectResource
     {
         Id = projection.Identity,
         Text = projection.Name
     });
 }
 public static MetadataDefinitionResource ToMetadataDefinitionResource(this MetadataDefinitionProjection projection)
 {
     return(new MetadataDefinitionResource
     {
         DataType = projection.DataType,
         Identity = projection.Identity,
         Name = projection.Name, Description = projection.Description,
         Regex = projection.Regex, Tracking = projection.Tracking
     });
 }
Ejemplo n.º 3
0
        private static IEnumerable <IFieldable> ToFields(MetadataDefinitionProjection definition)
        {
            yield return(new Field(FIELD_ID, definition.Identity.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));

            yield return(new Field(FIELD_NAME, definition.Name, Field.Store.YES, Field.Index.ANALYZED));

            yield return(new Field(FIELD_DESCRIPTION, definition.Description, Field.Store.YES, Field.Index.ANALYZED));

            yield return(new Field(FIELD_DATA_TYPE, definition.DataType, Field.Store.YES, Field.Index.NOT_ANALYZED));
        }
Ejemplo n.º 4
0
        private Document ToDocument(MetadataDefinitionProjection definition)
        {
            var doc = new Document();

            foreach (var field in ToFields(definition))
            {
                doc.Add(field);
            }
            return(doc);
        }
Ejemplo n.º 5
0
        public void SaveIndex(MetadataDefinitionProjection definition)
        {
            var doc  = ToDocument(definition);
            var term = new Term(FIELD_ID, definition.Identity.ToString());

            using (var writer = OpenWriter())
            {
                writer.UpdateDocument(term, doc);
                writer.Optimize();
                writer.Commit();
            }
        }
        public void Handle(MetadataDefinitionCreatedEvent @event)
        {
            var projection = new MetadataDefinitionProjection
            {
                Identity    = @event.AggregateIdentity,
                Name        = @event.Name.Name,
                Description = @event.Description.Description,
                DataType    = @event.DataType,
                Regex       = @event.Regex,
                Tracking    = new TrackingBase()
            };

            _repository.Save(projection.ToMaybe());
        }
Ejemplo n.º 7
0
        public void Handle(MetadataDefinitionCreatedEvent @event)
        {
            if (_repository.Exists(@event.AggregateIdentity))
            {
                throw new DuplicateReadModelException();
            }

            var projection = new MetadataDefinitionProjection
            {
                Identity    = @event.AggregateIdentity,
                Name        = @event.Name.Name,
                Description = @event.Description.Description,
                DataType    = @event.DataType,
                Regex       = @event.Regex
            };

            _repository.Update(projection.ToMaybe());
        }