Beispiel #1
0
        public override async Task OnAddButtonClick(CancellationToken token)
        {
            var result = await AttributeService.AddAttribute(Entity);

            if (result.Error.Any())
            {
                RunOnUiThread(() =>
                {
                    AddButton.Enabled = true;
                });

                return;
            }

            RunOnUiThread(() =>
            {
                NavigationManager.GoToAttributes();
            });
        }
 public IActionResult AddAttribute(string env, string attribute, string name)
 {
     return(_attributeService.AddAttribute(env, attribute, name).Result.GetStatusResult());
 }
Beispiel #3
0
 public void AddAttribute(DocumentAttribute DocumentAttribute)
 {
     AttributeService.AddAttribute(DocumentAttribute);
 }
Beispiel #4
0
        public EmptyResponseModel Process(ModifyArchivePreservationConfigurationRequestModel request)
        {
            _logger.Info($"Process -> Edit preservation configuration for archive {request.IdArchive}");
            DocumentArchive archive = ArchiveService.GetArchive(request.IdArchive);

            if (archive == null)
            {
                _logger.Error($"Archive with id {request.IdArchive} not found");
                throw new Exception($"Archive with id {request.IdArchive} not found");
            }

            ICollection <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(request.IdArchive);

            if (attributes == null || attributes.Count == 0)
            {
                _logger.Error($"There aren't attributes for archive with id {request.IdArchive}");
                throw new Exception($"There aren't attributes for archive with id {request.IdArchive}");
            }

            if (archive.PathPreservation != request.PathPreservation)
            {
                _logger.Debug($"Update archive preservation path from '{archive.PathPreservation}' to '{request.PathPreservation}'");
                archive.PathPreservation = request.PathPreservation;
                ArchiveService.UpdateArchive(archive, false);
            }

            foreach (DocumentAttribute attribute in attributes)
            {
                attribute.IsMainDate = ((attribute.IdAttribute == request.MainDateAttribute) ||
                                        (request.MainDateAttribute == Guid.Empty && attribute.Name == DEFAULT_MAIN_DATE_ATTRIBUTE_NAME && attribute.AttributeType == DATE_TIME_ATTRIBUTE_TYPE));
                attribute.KeyOrder = null;
                if (request.OrderedPrimaryKeyAttributes.ContainsKey(attribute.IdAttribute))
                {
                    attribute.KeyOrder = request.OrderedPrimaryKeyAttributes[attribute.IdAttribute];
                    if (string.IsNullOrEmpty(attribute.KeyFormat) &&
                        attribute.KeyOrder < request.OrderedPrimaryKeyAttributes.Max(x => x.Value))
                    {
                        attribute.KeyFormat = "{0}|";
                    }
                }
                _logger.Debug($"Update attribute {attribute.IdAttribute}: IsMainDate = {attribute.IsMainDate}; KeyOrder = {attribute.KeyOrder}");
                AttributeService.UpdateAttribute(attribute);
            }

            if (request.MainDateAttribute == Guid.Empty &&
                !attributes.Any(x => x.Name == DEFAULT_MAIN_DATE_ATTRIBUTE_NAME && x.AttributeType == DATE_TIME_ATTRIBUTE_TYPE))
            {
                DocumentAttribute dateMainAttribute = new DocumentAttribute
                {
                    Name                 = "Date",
                    AttributeType        = "System.DateTime",
                    IsMainDate           = true,
                    IsRequired           = true,
                    Archive              = archive,
                    ConservationPosition = Convert.ToInt16(request.OrderedPrimaryKeyAttributes.Max(x => x.Value) + 1),
                    Mode                 = new DocumentAttributeMode(0),
                    AttributeGroup       = AttributeService.GetAttributeGroup(archive.IdArchive).SingleOrDefault(s => s.GroupType == AttributeGroupType.Undefined)
                };
                _logger.Debug($"Create new MainDate attribute 'Date' for archive {archive.IdArchive}");
                AttributeService.AddAttribute(dateMainAttribute);
            }
            return(new EmptyResponseModel());
        }