Exemplo n.º 1
0
        private string GetRegex(string regex, string dataType)
        {
            if (string.IsNullOrEmpty(regex))
            {
                var dt = DataTypeBuilder.Create(dataType) as RegexDataType;
                if (dt == null)
                {
                    return(null);
                }
                return(dt.Regex);
            }

            return(regex);
        }
        private string ValidateResource(MetadataDefinitionResource resource)
        {
            var sb = new StringBuilder();

            if (DataTypeBuilder.Create(resource.DataType) != null)
            {
                return(sb.ToString());
            }

            sb.AppendLine("Invalid DataType");
            sb.AppendLine("Valid data type included");

            foreach (var dataType in DataTypeBuilder.GetDataTypes())
            {
                sb.Append(dataType.Value.Tag + ",");
            }

            return(sb.ToString());
        }
Exemplo n.º 3
0
        public void Create(Guid identity, Guid metadataDefinitionGroupIdentity, string name, IEnumerable <ValueSet> values)
        {
            var aggregate = new Entity(identity, metadataDefinitionGroupIdentity, new EntityName(name));

            if (values != null && values.Any())
            {
                values.Each(x => aggregate.AddMetadataDefinitionValue(x.MetadataDefinitionIdentity, new MetadataDefinitionName(x.Name), DataTypeBuilder.Create(x.DataType), x.Regex, GetValue(x.Values)));
            }

            _repository.Save(aggregate.ToMaybe());
        }
        public void Handle(CreateMetadataDefinitionCommand command)
        {
            var definition = new MetadataDefinition(command.Identity, new MetadataDefinitionName(command.Name), new MetadataDefinitionDescription(command.Description), DataTypeBuilder.Create(command.DataType), command.Regex);

            if (command.Values != null && command.Values.Any())
            {
                command.Values.Each(x => definition.AddAllowableValue(new AllowableValue(x)));
            }

            _repository.Save(definition.ToMaybe());
        }
Exemplo n.º 5
0
        public virtual void SynchronizeValues(IEnumerable <EntityValueBag> definitionValues)
        {
            var defns = definitionValues as EntityValueBag[] ?? definitionValues.ToArray();

            if (!defns.Any())
            {
                Clear();
                return;
            }

            var removed = State.GetSelectedDefintionIds().Where(defn => !defns.Select(x => x.MetadataDefinitionId).Contains(defn)).ToArray();
            var updated = defns.Where(x => State.GetSelectedDefintionIds().Contains(x.MetadataDefinitionId)).ToArray();
            var added   = defns.Except(updated);


            foreach (var defn in removed)
            {
                ApplyChange(new EntityMetadataDefinitionRemovedEvent(GetIdentity(), defn));
            }

            foreach (var defn in updated)
            {
                ApplyChange(new UpdatedEntityMetadataDefinitionValueEvent(GetIdentity(), defn.MetadataDefinitionId, new EntityName(defn.Name), DataTypeBuilder.Create(defn.DataType),
                                                                          defn.Regex, defn.Selection.ToValue()));
            }

            foreach (var defn in added)
            {
                AddMetadataDefinitionValue(defn.MetadataDefinitionId, new MetadataDefinitionName(defn.Name), DataTypeBuilder.Create(defn.DataType), defn.Regex, defn.Selection.ToValue());
            }
        }