Beispiel #1
0
        public static Schema Dispatch(SchemaCreated @event, FieldRegistry registry)
        {
            var schema = Schema.Create(@event.Name, @event.Properties);

            if (@event.Fields != null)
            {
                var fieldId = 1;

                foreach (var eventField in @event.Fields)
                {
                    var partitioning =
                        string.Equals(eventField.Partitioning, Partitioning.Language.Key, StringComparison.OrdinalIgnoreCase) ?
                        Partitioning.Language :
                        Partitioning.Invariant;

                    var field = registry.CreateField(fieldId, eventField.Name, partitioning, eventField.Properties);

                    if (eventField.IsHidden)
                    {
                        field = field.Hide();
                    }

                    if (eventField.IsDisabled)
                    {
                        field = field.Disable();
                    }

                    schema = schema.AddOrUpdateField(field);

                    fieldId++;
                }
            }

            return(schema);
        }
Beispiel #2
0
        protected void On(SchemaCreated @event)
        {
            SchemaDef         = @event.Schema;
            SchemaFieldsTotal = @event.Schema.MaxId();

            AppId = @event.AppId;
        }
Beispiel #3
0
 protected Task On(SchemaCreated @event, EnvelopeHeaders headers)
 {
     return(ForSchemaIdAsync(@event.SchemaId.Id, async collection =>
     {
         await collection.Indexes.CreateOneAsync(IndexKeys.Ascending(x => x.IsPublished));
         await collection.Indexes.CreateOneAsync(IndexKeys.Text(x => x.Text));
     }));
 }
        protected Task On(SchemaCreated @event, EnvelopeHeaders headers)
        {
            return(Collection.CreateAsync(@event, headers, s =>
            {
                s.SchemaDef = SchemaEventDispatcher.Create(@event, registry);

                SimpleMapper.Map(@event, s);
            }));
        }
Beispiel #5
0
 protected Task On(SchemaCreated @event, EnvelopeHeaders headers)
 {
     return(ForAppIdAsync(@event.AppId.Id, async collection =>
     {
         await collection.Indexes.CreateOneAsync(Index.Ascending(x => x.ReferencedIds));
         await collection.Indexes.CreateOneAsync(Index.Ascending(x => x.IsPublished));
         await collection.Indexes.CreateOneAsync(Index.Text(x => x.DataText));
     }));
 }
Beispiel #6
0
        public void Should_trigger_precheck_if_event_type_correct()
        {
            TestForCondition(string.Empty, ctx =>
            {
                var @event = new SchemaCreated();

                var result = sut.Trigger(Envelope.Create <AppEvent>(@event), ctx);

                Assert.True(result);
            });
        }
Beispiel #7
0
        public void On(SchemaCreated @event, EnvelopeHeaders headers)
        {
            var id = @event.SchemaId.Id;

            Schemas = Schemas.SetItem(id, EntityMapper.Create <JsonSchemaEntity>(@event, headers, s =>
            {
                s.SchemaDef = SchemaEventDispatcher.Create(@event, registry);

                SimpleMapper.Map(@event, s);
            }));
        }
Beispiel #8
0
        protected void On(SchemaCreated @event, FieldRegistry registry)
        {
            Name = @event.Name;

            var schema = new Schema(@event.Name);

            if (@event.Properties != null)
            {
                schema = schema.Update(@event.Properties);
            }

            if (@event.Publish)
            {
                schema = schema.Publish();
            }

            if (@event.Fields != null)
            {
                foreach (var eventField in @event.Fields)
                {
                    TotalFields++;

                    var partitioning =
                        string.Equals(eventField.Partitioning, Partitioning.Language.Key, StringComparison.OrdinalIgnoreCase) ?
                        Partitioning.Language :
                        Partitioning.Invariant;

                    var field = registry.CreateField(TotalFields, eventField.Name, partitioning, eventField.Properties);

                    if (eventField.IsHidden)
                    {
                        field = field.Hide();
                    }

                    if (eventField.IsDisabled)
                    {
                        field = field.Disable();
                    }

                    if (eventField.IsLocked)
                    {
                        field = field.Lock();
                    }

                    schema = schema.AddField(field);
                }
            }

            SchemaDef = schema;

            AppId = @event.AppId;
        }
        protected Task On(SchemaCreated @event, EnvelopeHeaders headers)
        {
            var schema = SchemaEventDispatcher.Dispatch(@event, registry);

            return(Collection.CreateAsync(@event, headers, s => { UpdateSchema(s, schema); SimpleMapper.Map(@event, s); }));
        }
Beispiel #10
0
        protected void On(SchemaCreated @event, FieldRegistry registry)
        {
            Name = @event.Name;

            var schema = new Schema(@event.Name);

            if (@event.Properties != null)
            {
                schema = schema.Update(@event.Properties);
            }

            if (@event.Publish)
            {
                schema = schema.Publish();
            }

            if (@event.Fields != null)
            {
                foreach (var eventField in @event.Fields)
                {
                    TotalFields++;

                    var partitioning = Partitioning.FromString(eventField.Partitioning);

                    var field = registry.CreateRootField(TotalFields, eventField.Name, partitioning, eventField.Properties);

                    if (field is ArrayField arrayField && eventField.Nested?.Count > 0)
                    {
                        foreach (var nestedEventField in eventField.Nested)
                        {
                            TotalFields++;

                            var nestedField = registry.CreateNestedField(TotalFields, nestedEventField.Name, nestedEventField.Properties);

                            if (nestedEventField.IsHidden)
                            {
                                nestedField = nestedField.Hide();
                            }

                            if (nestedEventField.IsDisabled)
                            {
                                nestedField = nestedField.Disable();
                            }

                            arrayField = arrayField.AddField(nestedField);
                        }

                        field = arrayField;
                    }

                    if (eventField.IsHidden)
                    {
                        field = field.Hide();
                    }

                    if (eventField.IsDisabled)
                    {
                        field = field.Disable();
                    }

                    if (eventField.IsLocked)
                    {
                        field = field.Lock();
                    }

                    schema = schema.AddField(field);
                }
            }

            SchemaDef = schema;

            AppId = @event.AppId;
        }
        protected void On(SchemaCreated @event)
        {
            totalFields += @event.Fields?.Count ?? 0;

            schema = SchemaEventDispatcher.Dispatch(@event, registry);
        }
 protected void On(SchemaCreated @event)
 {
     schema = SchemaEventDispatcher.Dispatch(@event, registry);
 }
 public static Schema Dispatch(SchemaCreated @event)
 {
     return(Schema.Create(@event.Name, @event.Properties));
 }