public MockMetaModel() { this.ProductSaleEntity = new ProductSaleMetaEntity(); // You could have many different Entities (tables), here we have just one var allEntities = new [] { this.ProductSaleEntity }; base.AddAllEntities(allEntities); }
public IMetaEntity InitializeMetaEntity(IMetaEntity metaMetaEntity) { var metaEntity = ModelFactory.CreateMetaEntity(); EntityService.SetEntityDefaultValues(metaEntity, metaMetaEntity); var now = DateTime.Now; var user = MetaModelRepository.GetMdUser(DEFAULT_USER_LOGIN); metaEntity.CreationDate = now; metaEntity.CreationUser = user; metaEntity.LastUpdateDate = now; metaEntity.LastUpdateUser = user; return(metaEntity); }
public IStringMetaField InitializeStringMetaFieldTemplate(IMetaEntity metaMetaField) { var stringMetaField = ModelFactory.CreateStringMetaField(); EntityService.SetEntityDefaultValues(stringMetaField, metaMetaField); var now = DateTime.Now; var user = MetaModelRepository.GetMdUser(DEFAULT_USER_LOGIN); stringMetaField.CreationDate = now; stringMetaField.CreationUser = user; stringMetaField.LastUpdateDate = now; stringMetaField.LastUpdateUser = user; return(stringMetaField); }
public override void Initialize(IDateTimeMetaField metaField, IMetaEntity metaEntity = null) { var metaDateTimeMetaField = EntityService.GetMetaEntity(nameof(IDateTimeMetaField)); EntityValidator = EntityService.GetEntityValidator(metaDateTimeMetaField); if (metaField == null) { metaField = MetaDataService.InitializeDateTimeMetaField(metaDateTimeMetaField, metaEntity); } Caption = EntityValidator.MetaEntity.Label; Entity = metaField; InitializeFieldValidators(metaField); }
public IRegularExpression InitializeRegularExpression(IMetaEntity metaRegularExpression) { var regularExpression = ModelFactory.CreateRegularExpression(); EntityService.SetEntityDefaultValues(regularExpression, metaRegularExpression); var now = DateTime.Now; var user = MetaModelRepository.GetMdUser(DEFAULT_USER_LOGIN); regularExpression.CreationDate = now; regularExpression.CreationUser = user; regularExpression.LastUpdateDate = now; regularExpression.LastUpdateUser = user; return(regularExpression); }
public IEntityMetaField InitializeEntityMetaField(IMetaEntity metaMetaField, IMetaEntity metaEntity) { var entityMetaField = ModelFactory.CreateEntityMetaField(); EntityService.SetEntityDefaultValues(entityMetaField, metaMetaField); var now = DateTime.Now; var user = MetaModelRepository.GetMdUser(DEFAULT_USER_LOGIN); entityMetaField.MetaEntity = metaEntity; entityMetaField.CreationDate = now; entityMetaField.CreationUser = user; entityMetaField.LastUpdateDate = now; entityMetaField.LastUpdateUser = user; return(entityMetaField); }
private void Initialize() { Caption = MdManagerLabels.MetaFieldTemplateLabels; CreateModelLabel = MdManagerLabels.CreateTemplateLabel; MetaFieldTemplateLabel = MdManagerLabels.MetaFieldTemplateLabel; MetaBooleanMetaField = EntityService.GetMetaEntity(nameof(IBooleanMetaField)); CreateBooleanMetaFieldTemplateLabel = MetaBooleanMetaField.Label; MetaIntegerMetaField = EntityService.GetMetaEntity(nameof(IIntegerMetaField)); CreateIntegerMetaFieldTemplateLabel = MetaIntegerMetaField.Label; MetaDecimalMetaField = EntityService.GetMetaEntity(nameof(IDecimalMetaField)); CreateDecimalMetaFieldTemplateLabel = MetaDecimalMetaField.Label; MetaDateTimeMetaField = EntityService.GetMetaEntity(nameof(IDateTimeMetaField)); CreateDateTimeMetaFieldTemplateLabel = MetaDateTimeMetaField.Label; MetaStringMetaField = EntityService.GetMetaEntity(nameof(IStringMetaField)); CreateStringMetaFieldTemplateLabel = MetaStringMetaField.Label; MetaEntityMetaField = EntityService.GetMetaEntity(nameof(IEntityMetaField)); CreateEntityMetaFieldTemplateLabel = MetaEntityMetaField.Label; }
public void Initialize(IMetaEntity metaEntity) { MetaFieldTemplate = EntityService.GetMetaEntity(nameof(IMetaFieldTemplate)); EntityValidator = EntityService.GetEntityValidator(MetaFieldTemplate); var metaMetaField = EntityService.GetMetaEntity(nameof(IMetaField)); if (metaEntity == null) { metaEntity = MetaDataService.InitializeMetaEntity(MetaFieldTemplate); } else { metaEntity = EntityService.GetMetaEntity(metaEntity.Id); } Caption = MdManagerLabels.MetaFieldTemplateLabel; Entity = metaEntity; }
private IMetaField CreateMetaField(IMetaEntity metaEntity) { var metaField = ModelFactory.CreateStringMetaField( STRING_META_FIELD_NAME, "New label", "New Description...", true, false, true, null, false, 1, null, 1, STRING_DEFAULT_VALUE ); metaField.MetaEntity = metaEntity; return(metaField); }
public MainViewModel() { MetaMetaEntity = EntityService.GetMetaEntity(nameof(IMetaEntity)); var entityValidator = EntityService.GetEntityValidator(MetaMetaEntity); ListOfMetaEntityLabel = string.Format(ApplicationLabels.MenuListOfLabel, entityValidator.MetaEntity.PlurialLabel); AddMetaEntityLabel = string.Format(ApplicationLabels.MenuAddFLabel, entityValidator.MetaEntity.Label); MetaRegularExpression = EntityService.GetMetaEntity(nameof(IRegularExpression)); var regularExpressionValidator = EntityService.GetEntityValidator(MetaRegularExpression); ListOfRegularExpressionLabel = string.Format(ApplicationLabels.MenuListOfLabel, regularExpressionValidator.MetaEntity.PlurialLabel); AddRegularExpressionLabel = string.Format(ApplicationLabels.MenuAddFLabel, regularExpressionValidator.MetaEntity.Label); MetaEntityTemplate = EntityService.GetMetaEntity(nameof(IMetaField)); ListOfTemplateLabel = string.Format(ApplicationLabels.MenuListOfTemplateLabel, MdManagerLabels.MetaFieldTemplateLabels); OpenMetaEntityList(); }
public void Add(string entityTypeName, IMetaEntity metaEntity) { while (true) { var o = this._MetaEntityByName; var n = new Dictionary <string, IMetaEntity>(o); if (entityTypeName is null) { if (!(metaEntity.EntityTypeName is null)) { n.Add(metaEntity.EntityTypeName, metaEntity); } } else { n.Add(entityTypeName, metaEntity); } if (ReferenceEquals(System.Threading.Interlocked.CompareExchange(ref this._MetaEntityByName, n, o), o)) { break; } } }
public void Initialize(IMetaEntity metaEntity) { var metaMetaEntity = EntityService.GetMetaEntity(nameof(IMetaEntity)); EntityValidator = EntityService.GetEntityValidator(metaMetaEntity); var metaMetaField = EntityService.GetMetaEntity(nameof(IMetaField)); var metaFieldValidator = EntityService.GetEntityValidator(metaMetaField); if (metaEntity == null) { metaEntity = MetaDataService.InitializeMetaEntity(metaMetaEntity); } else { metaEntity = EntityService.GetMetaEntity(metaEntity.Id); } Caption = EntityValidator.MetaEntity.Label; Entity = metaEntity; MetaFieldListPanelViewModel = EntityListPanelViewModel.Create(RefreshMetaFields, null, OpenMetaFieldEdition, DeleteMetaField, metaFieldValidator); MetaBooleanMetaField = EntityService.GetMetaEntity(nameof(IBooleanMetaField)); CreateBooleanMetaFieldLabel = string.Format(MdManagerLabels.CreateEntityLabel, MetaBooleanMetaField.Label); MetaIntegerMetaField = EntityService.GetMetaEntity(nameof(IIntegerMetaField)); CreateIntegerMetaFieldLabel = string.Format(MdManagerLabels.CreateEntityLabel, MetaIntegerMetaField.Label); MetaDecimalMetaField = EntityService.GetMetaEntity(nameof(IDecimalMetaField)); CreateDecimalMetaFieldLabel = string.Format(MdManagerLabels.CreateEntityLabel, MetaDecimalMetaField.Label); MetaDateTimeMetaField = EntityService.GetMetaEntity(nameof(IDateTimeMetaField)); CreateDateTimeMetaFieldLabel = string.Format(MdManagerLabels.CreateEntityLabel, MetaDateTimeMetaField.Label); MetaStringMetaField = EntityService.GetMetaEntity(nameof(IStringMetaField)); CreateStringMetaFieldLabel = string.Format(MdManagerLabels.CreateEntityLabel, MetaStringMetaField.Label); MetaEntityMetaField = EntityService.GetMetaEntity(nameof(IEntityMetaField)); CreateEntityMetaFieldLabel = string.Format(MdManagerLabels.CreateEntityLabel, MetaEntityMetaField.Label); InitializeFieldValidators(metaEntity); }
private void InitializeFieldValidators(IMetaEntity metaEntity) { IFieldValidator fieldValidator = GetFieldValidator <string>(nameof(IMetaEntity.InterfaceName)); InterfaceNameFieldItemViewModel = TextBoxFieldItemViewModel.Create(fieldValidator, Entity, metaEntity.InterfaceName); EditableItemsFields.Add(InterfaceNameFieldItemViewModel); fieldValidator = GetFieldValidator <string>(nameof(IMetaEntity.Label)); LabelFieldItemViewModel = TextBoxFieldItemViewModel.Create(fieldValidator, Entity, metaEntity.Label); EditableItemsFields.Add(LabelFieldItemViewModel); fieldValidator = GetFieldValidator <string>(nameof(IMetaEntity.PlurialLabel)); PlurialLabelFieldItemViewModel = TextBoxFieldItemViewModel.Create(fieldValidator, Entity, metaEntity.PlurialLabel); EditableItemsFields.Add(PlurialLabelFieldItemViewModel); fieldValidator = GetFieldValidator <bool?>(nameof(IMetaEntity.IsMasculine)); IsMasculineFieldItemViewModel = CheckBoxFieldItemViewModel.Create(fieldValidator, Entity, metaEntity.IsMasculine); EditableItemsFields.Add(IsMasculineFieldItemViewModel); fieldValidator = GetFieldValidator <string>(nameof(IMetaEntity.Description)); DescriptionFieldItemViewModel = TextBoxFieldItemViewModel.Create(fieldValidator, Entity, metaEntity.Description); EditableItemsFields.Add(DescriptionFieldItemViewModel); var metaField = ModelFactory.CreateMetaField( "MetaFieldTemplate", "Ajouter un méta-champ", "Choisissez un model de méta champ"); var metaFieldTemplates = MetaDataService.GetMetaFieldTemplates().OrderBy(me => me.Label).ToList(); var metaFieldTemplateViewModels = metaFieldTemplates.Select(MetaFieldItemTemplateViewModel.Create); fieldValidator = ModelFactory.CreateFieldValidator <IEntity>(metaField); EntityService.CreateFieldValidator(fieldValidator); MetaFieldTemplateItemViewModel = EntityFieldItemViewModel.Create(fieldValidator, Entity, metaFieldTemplateViewModels, metaField); EditableItemsFields.Add(MetaFieldTemplateItemViewModel); }
private void InitializeFieldValidators(IMetaEntity metaEntity) { IFieldValidator fieldValidator = GetFieldValidator <string>(nameof(IMetaEntity.InterfaceName)); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { IEntity result = null; IMetaEntity metaEntity = null; string entityTypeName = null; if (reader.TokenType == JsonToken.StartObject) { if (reader.Read()) { if (reader.TokenType == JsonToken.PropertyName && string.Equals((reader.Value as string), PropertyName__metadata, StringComparison.Ordinal)) { if (reader.Read()) { if (reader.TokenType == JsonToken.StartObject) { if (reader.Read()) { if (reader.TokenType == JsonToken.PropertyName && string.Equals((reader.Value as string), PropertyName_type, StringComparison.Ordinal)) { entityTypeName = reader.ReadAsString(); if (reader.Read()) { if (reader.TokenType == JsonToken.EndObject) { if (reader.Read()) { //OK result = this.EntitySchema?.CreateEntity(entityTypeName); metaEntity = result?.MetaData; } } } } } } } } } if (result is null || metaEntity is null) { throw new NotImplementedException("thinkof"); } while (reader.TokenType == JsonToken.PropertyName) { var propertyName = reader.Value as string; if (reader.Read()) { var metaProperty = metaEntity.GetProperty(propertyName); var propertyValue = serializer.Deserialize(reader, metaProperty.PropertyType); metaProperty.GetAccessor(result).Value = propertyValue; reader.Read(); } } if (reader.TokenType == JsonToken.EndObject) { return(result); } } throw new NotImplementedException($"Unexpected {reader.TokenType} {reader.Path}"); }
protected MetaEntityItemViewModel(IMetaEntity metaEntity) => Value = metaEntity;
public IList <ValueCheckingResult> SaveMetaEntity(IEntityValidator entityValidator, IMetaEntity metaEntity) { var results = EntityService.CheckEntity(entityValidator, metaEntity); if (results.All(r => r.IsValid)) { var user = MetaModelRepository.GetMdUser(DEFAULT_USER_LOGIN); var now = DateTime.Now; metaEntity.LastUpdateDate = now; metaEntity.LastUpdateUser = user; if (EntityService.IsEntityNew(metaEntity)) { metaEntity.CreationDate = now; metaEntity.CreationUser = user; MetaModelRepository.CreateMetaEntity(metaEntity); } else { MetaModelRepository.UpdateMetaEntity(metaEntity); } } return(results); }