Exemplo n.º 1
0
 /// <summary>
 /// CTOR of Compass.
 /// </summary>
 public Compass()
 {
     InitializeComponent();
     MetadataModel.CreateModel();
     this.vm          = new MetadataViewModel(MetadataModel.Instance);
     this.DataContext = this.vm;
 }
        /// <summary>
        /// Metadata page.
        /// </summary>
        /// <param name="uuid"></param>
        /// <param name="organization"></param>
        /// <param name="title"></param>
        /// <param name="orderby"></param>
        /// <returns>/metadata/{organization}/{title}/{uuid}</returns>
        public ActionResult Index(string uuid, string organization = null, string title = null, string orderby = "title")
        {
            MetadataViewModel model = null;

            //try
            //{
            model = _metadataService.GetMetadataViewModelByUuid(uuid);
            model = Sort(model, orderby);
            //}
            //catch (InvalidOperationException exception)
            //{
            //    Log.Error("Metadata with uuid: " + uuid + " not found in Geonetwork.", exception);
            //    //throw new Exception("Metadata with uuid: " + uuid + " not found in Geonetwork.");
            //}
            if (model == null)
            {
                Log.Error("Metadata with uuid: " + uuid + " not found.");
                return(new HttpNotFoundResult("Metadata with uuid: " + uuid + " not found in Geonetwork."));
            }

            SeoUrl url = model.CreateSeoUrl();

            if (!url.Matches(organization, title) && !string.IsNullOrWhiteSpace(organization))
            {
                return(RedirectToActionPermanent("Index", new { organization = url.Organization, title = url.Title, uuid = uuid }));
            }

            return(View(model));
        }
Exemplo n.º 3
0
        private void model_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            MetadataViewModel model = sender as MetadataViewModel;

            DataGridRow changedRow = GetDataGridRowByDataContext(NodeMetadataDataGrid, model);

            if (e.PropertyName == "MetadataName")
            {
                bool nameChanged = HasNameChanged(model.MetadataName);

                if (nameChanged)
                {
                    MarkChanged(model, changedRow, true);
                }
                else
                {
                    MarkChanged(model, changedRow, false);
                }
            }
            else
            {
                if (IsEqualToOriginal(model))
                {
                    MarkChanged(model, changedRow, false);
                    _changes[model.OriginalMetadataName.ToLower()] = false;
                }
                else
                {
                    MarkChanged(model, changedRow, true);
                    _changes[model.OriginalMetadataName.ToLower()] = true;
                }
            }
        }
Exemplo n.º 4
0
        private bool IsEqualToOriginal(MetadataViewModel metadata)
        {
            bool result = false;

            foreach (KeyValuePair <MetadataContext, MetadataViewModel> pair in _original)
            {
                MetadataContext   context = pair.Key;
                MetadataViewModel model   = pair.Value;
                if (context.NodeUid.Value == metadata.NodeUid && model.MetadataName == metadata.OriginalMetadataName)
                {
                    if (context.DescriptorTypeUid.HasValue && context.DescriptorTypeUid.Value != metadata.DescriptorTypeUid)
                    {
                        continue;
                    }
                    if (context.RelationshipUid.HasValue && context.RelationshipUid.Value != metadata.RelationshipUid)
                    {
                        continue;
                    }

                    //the context is the same so compare the items
                    if (model.Equals(metadata))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public void delete_after_failed_delete()
        {
            // ARRANGE
            var metadata = new Metadata(new Uri("http://localhost/test/1"), true);

            _restClient.Setup(x => x.DeleteAsync(It.IsAny <Uri>())).Throws(new Exception("Foo"));

            var viewModel = new MetadataViewModel(metadata, _modifyResourceFactory, _exceptionFactory, _restClient.Object, _messageService.Object, SchedulerService);

            TestScheduler.AdvanceBy(TimeSpan.FromMilliseconds(100));

            var deleted = 0;

            viewModel.Deleted.Subscribe(x => deleted++);

            // ACT
            viewModel.DeleteCommand.Execute(null);

            TestScheduler.AdvanceBy(TimeSpan.FromMilliseconds(100));

            var result = new Mock <IRestResponse>();
            var task   = Task.FromResult(result.Object);

            _restClient.Setup(x => x.DeleteAsync(It.IsAny <Uri>())).Returns(() => task).Verifiable();

            viewModel.DeleteCommand.Execute(null);

            TestScheduler.AdvanceBy(TimeSpan.FromMilliseconds(100));

            // ASSERT
            Assert.That(deleted, Is.EqualTo(1));

            _restClient.VerifyAll();
        }
Exemplo n.º 6
0
        public async Task <MetadataViewModel> CreateMetaData(MetadataViewModel model)
        {
            database.Add(model);

            // Returned rescourse presumably with the newy-inserted id
            return(await Task.Run(() => model));
        }
Exemplo n.º 7
0
        private void MapDatasetToMetadataViewModel(Dataset dataset, MetadataViewModel model,
                                                   OpenMetadataEndpoint openMetadataEndpoint)
        {
            model.Title = dataset.title;
            DateTime modified;

            if (DateTime.TryParse(dataset.modified.ToString(), out modified))
            {
                model.DateUpdated = modified;
            }

            DateTime issued;

            if (DateTime.TryParse(dataset.issued, out issued))
            {
                model.DatePublished = issued;
            }

            model.ContactMetadata.Organization =
                !string.IsNullOrEmpty(openMetadataEndpoint.OrganizationName)
                    ? openMetadataEndpoint.OrganizationName
                    : dataset.publisher.name;
            model.ContactMetadata.Email = dataset.contactPoint.hasEmail.Replace("mailto:", "");
            model.ContactMetadata.Name  = dataset.contactPoint.fn;

            model.ContactPublisher.Organization = model.ContactMetadata.Organization;
            model.ContactPublisher.Email        = model.ContactMetadata.Email;
            model.ContactPublisher.Name         = model.ContactMetadata.Name;

            model.ContactOwner.Organization = model.ContactMetadata.Organization;
            model.ContactOwner.Email        = model.ContactMetadata.Email;
            model.ContactOwner.Name         = model.ContactMetadata.Name;

            model.Abstract = dataset.description;

            if (dataset.keyword != null && dataset.keyword.Length > 0)
            {
                model.KeywordsOther = dataset.keyword.ToList();
            }

            model.DistributionsFormats =
                GetDistributionsFormats(dataset.distribution, model.ContactMetadata.Organization);

            if (string.IsNullOrEmpty(model.MaintenanceFrequency))
            {
                model.MaintenanceFrequency = "unknown";
            }

            var spatial = dataset.spatial.Split(',');

            if (spatial.Length == 4)
            {
                model.BoundingBoxWest  = spatial[0];
                model.BoundingBoxSouth = spatial[1];
                model.BoundingBoxEast  = spatial[2];
                model.BoundingBoxNorth = spatial[3];
            }

            model.AccessConstraints = "no restrictions";
        }
Exemplo n.º 8
0
 private void ResetOriginals()
 {
     lock (_original)
     {
         _original.Clear();
         foreach (MetadataContext context in NodeProxy.Metadata.Keys)
         {
             /* The 'Note' property has it's own editor panel intended for more text
              * The 'XPosition' and 'YPosition' are control via the map positioning
              * The 'Name' is the node text and editing is done via the node directly
              * The 'Created' and 'Modified' timestamps should not be able to be changed.
              * TODO: Decide if the CreatedBy and ModifiedBy properties should be editable.
              ***/
             if (context.MetadataName != "Note" && context.MetadataName != "XPosition" &&
                 context.MetadataName != "YPosition" && context.MetadataName != "Name" &&
                 context.MetadataName != "Created" && context.MetadataName != "Modified" &&
                 context.MetadataName != "CollapseState" && context.MetadataName != "Visibility")
             {
                 MetadataViewModel model = new MetadataViewModel(context, NodeProxy.Metadata[context]);
                 if (!ContainsOriginal(context))
                 {
                     _original.Add(context, model.Clone());
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            var locator = Application.Current.FindResource("Locator") as ViewModelLocator;

            this._settingsViewModel     = locator.Settings;
            this._mainViewModel         = locator.Main;
            this._h264SettingsViewModel = locator.H264Settings;
            this._metadataViewModel     = locator.Metadata;
            this._recorderViewModel     = locator.RecorderSettings;

            this._mainViewModel.FFmpegStarting    += this.MainViewModelFFmpegStarting;
            this._mainViewModel.DispatchEvent     += this.MainViewModelDispatchEvent;
            this._recorderViewModel.DispatchEvent += this.MainViewModelDispatchEvent;

            if (App.Args == null)
            {
                return;
            }

            if (App.Args.Contains("-debug"))
            {
                this.DebugCheckBox.Visibility = Visibility.Visible;
            }
        }
        public MetadataWindow(MetadataViewModel viewModel)
        {
            ViewModel = viewModel;
            ViewModel.DialogCloseRequested += ViewModel_DialogCloseRequested;

            InitializeComponent();
        }
Exemplo n.º 11
0
        public ActionResult CreateMetadataForLayers(string uuid, string wmsUrl, String[] selectedLayers, string[] keywords)
        {
            MetadataViewModel metadata = _metadataService.GetMetadataModel(uuid);

            WmsServiceViewModel serviceModel = _wmsServiceParser.GetLayers(wmsUrl);

            List <WmsLayerViewModel> createMetadataForLayers = new List <WmsLayerViewModel>();

            if (selectedLayers != null)
            {
                foreach (var layer in serviceModel.Layers)
                {
                    if (selectedLayers.Contains(layer.Name))
                    {
                        createMetadataForLayers.Add(layer);
                    }
                }
            }
            string username = GetUsername();
            List <WmsLayerViewModel> newlyCreatedLayerMetadata = _metadataService.CreateMetadataForLayers(uuid, createMetadataForLayers, keywords, username);

            ServiceLayerViewModel model = new ServiceLayerViewModel
            {
                Metadata = metadata,
                Layers   = newlyCreatedLayerMetadata,
                WmsUrl   = wmsUrl,
            };

            return(View("LayersCreated", model));
        }
Exemplo n.º 12
0
        public ActionResult Index(string uuid, string wmsUrl)
        {
            if (string.IsNullOrWhiteSpace(uuid))
            {
                return(HttpNotFound());
            }

            MetadataViewModel metadata = _metadataService.GetMetadataModel(uuid);

            if (string.IsNullOrWhiteSpace(wmsUrl))
            {
                wmsUrl = metadata.DistributionUrl;
            }

            WmsServiceViewModel serviceModel = null;

            try
            {
                serviceModel = _wmsServiceParser.GetLayers(wmsUrl);
            }
            catch (Exception e)
            {
                ViewBag.Message = "Feil ved henting av GetCapabilities: " + e.Message;
            }

            ServiceLayerViewModel model = new ServiceLayerViewModel
            {
                Metadata = metadata,
                Layers   = serviceModel != null ? serviceModel.Layers : new List <WmsLayerViewModel>(),
                WmsUrl   = wmsUrl,
            };

            return(View(model));
        }
Exemplo n.º 13
0
        public Dictionary <string, string> GetRegister(string registername, MetadataViewModel model)
        {
            string role = GetSecurityClaim("role");

            MemoryCacher memCacher = new MemoryCacher();

            var cache = memCacher.GetValue("registeritem-" + registername);

            List <RegisterItem> RegisterItems = new List <RegisterItem>();

            if (cache != null)
            {
                RegisterItems = cache as List <RegisterItem>;
            }

            if (RegisterItems.Count < 1)
            {
                System.Net.WebClient c = new System.Net.WebClient();
                c.Encoding = System.Text.Encoding.UTF8;
                var data     = c.DownloadString(System.Web.Configuration.WebConfigurationManager.AppSettings["RegistryUrl"] + "api/register/" + registername);
                var response = Newtonsoft.Json.Linq.JObject.Parse(data);

                var items = response["containeditems"];

                foreach (var item in items)
                {
                    var    id           = item["id"].ToString();
                    var    owner        = item["owner"].ToString();
                    string organization = item["owner"].ToString();

                    var registerItem = new RegisterItem {
                        Id = id, Label = item["label"].ToString(), Organization = organization
                    };

                    if (!RegisterItems.Contains(registerItem))
                    {
                        RegisterItems.Add(registerItem);
                    }
                }

                var logLines = RegisterItems.Select(l => l.Id + ": " + l.Label);
                Log.Info(string.Format("Setting cache for registername: {0}, items: " + Environment.NewLine + " {1}", registername, string.Join(Environment.NewLine, logLines)));
                memCacher.Set("registeritem-" + registername, RegisterItems, new DateTimeOffset(DateTime.Now.AddYears(1)));
            }

            Dictionary <string, string> RegisterItemsForUser = new Dictionary <string, string>();

            foreach (var item in RegisterItems)
            {
                if (!string.IsNullOrWhiteSpace(role) && role.Equals("nd.metadata_admin") || model.HasAccess(item.Organization))
                {
                    RegisterItemsForUser.Add(item.Id, item.Label);
                }
            }

            RegisterItemsForUser = RegisterItemsForUser.OrderBy(o => o.Value).ToDictionary(o => o.Key, o => o.Value);

            return(RegisterItemsForUser);
        }
Exemplo n.º 14
0
        public MainViewModel(PhotoService photoService, Viewport viewport, MusicLoader musicLoader)
        {
            this.photoService = photoService;
            this.viewport     = viewport;
            this.musicLoader  = musicLoader;

            Metadata = new MetadataViewModel();
        }
Exemplo n.º 15
0
        private bool HasAccessToMetadata(MetadataViewModel model)
        {
            string organization = GetSecurityClaim("organization");
            string role         = GetSecurityClaim("role");
            bool   isAdmin      = !string.IsNullOrWhiteSpace(role) && role.Equals("nd.metadata_admin");

            return(isAdmin || model.HasAccess(organization));
        }
Exemplo n.º 16
0
        public ActionResult Index(string uuid, string type = "default")
        {
            try
            {
                MetadataViewModel model = _metadataService.GetMetadataViewModelByUuid(uuid);

                if (model.Thumbnails != null && model.Thumbnails.Any())
                {
                    Thumbnail thumbnail       = model.Thumbnails[0];
                    Thumbnail thumbnailSmall  = null;
                    Thumbnail thumbnailMedium = null;
                    Thumbnail thumbnailLarge  = null;

                    foreach (var thumb in model.Thumbnails)
                    {
                        if (thumb.Type == "thumbnail" || thumb.Type == "miniatyrbilde")
                        {
                            thumbnailSmall = thumb;
                        }
                        else if (thumb.Type == "medium")
                        {
                            thumbnailMedium = thumb;
                        }
                        else if (thumb.Type == "large_thumbnail")
                        {
                            thumbnailLarge = thumb;
                        }
                    }

                    if (thumbnailSmall != null && type != null && string.Equals(type, "small", StringComparison.InvariantCultureIgnoreCase))
                    {
                        thumbnail = thumbnailSmall;
                    }
                    else if (thumbnailMedium != null && type != null && string.Equals(type, "medium", StringComparison.InvariantCultureIgnoreCase))
                    {
                        thumbnail = thumbnailMedium;
                    }
                    else if (thumbnailSmall != null && type != null && string.Equals(type, "medium", StringComparison.InvariantCultureIgnoreCase))
                    {
                        thumbnail = thumbnailSmall;
                    }
                    else if (thumbnailLarge != null && type != null && string.Equals(type, "large", StringComparison.InvariantCultureIgnoreCase))
                    {
                        thumbnail = thumbnailLarge;
                    }
                    string url      = thumbnail.URL;
                    string mimeType = GetMimeTypeFromUrl(url);
                    Stream stream   = DownloadImage(url);
                    return(new FileStreamResult(stream, mimeType));
                }
            }
            catch (Exception exception)
            {
                Log.Error("Metadata with uuid: " + uuid + " not found in Geonetwork.", exception);
            }
            return(HttpNotFound());
        }
Exemplo n.º 17
0
        public async Task <ActionResult> Edit(string uuid, bool displayLog = false, bool displayLogLatest = false, int limitNumberOfEntries = 50, string operation = "")
        {
            if (string.IsNullOrWhiteSpace(uuid))
            {
                return(HttpNotFound());
            }

            try
            {
                ViewBag.DisplayLog           = displayLog; ViewBag.DisplayLogLatest = displayLogLatest;
                ViewBag.limitNumberOfEntries = limitNumberOfEntries;
                ViewBag.operation            = operation;
                if (displayLogLatest)
                {
                    ViewBag.LogEntries = await _metadataService.GetLogEntriesLatest(limitNumberOfEntries, operation);
                }
                else if (displayLog)
                {
                    ViewBag.LogEntries = await _metadataService.GetLogEntries(uuid);
                }

                MetadataViewModel model = _metadataService.GetMetadataModel(uuid);
                string            role  = GetSecurityClaim("role");
                if (!string.IsNullOrWhiteSpace(role) && role.Equals("nd.metadata_admin"))
                {
                    model.ValidateAllRequirements = true;
                }

                if (HasAccessToMetadata(model))
                {
                    if (model.MetadataStandard == "ISO19115:Norsk versjon" && Request.QueryString["editor"] == null)
                    {
                        return(RedirectToAction("Edit", "SimpleMetadata", new { uuid = uuid }));
                    }

                    PrepareViewBagForEditing(model);
                    if (Request.QueryString["metadatacreated"] == null)
                    {
                        TryValidateModel(model);
                        ValidateModel(model);
                    }
                    return(View(model));
                }
                else
                {
                    TempData["failure"] = "Du har ikke tilgang til å redigere disse metadataene";
                    return(View("Error"));
                }
            }
            catch (Exception e)
            {
                //Log.Error("Error while getting metadata with uuid = " + uuid, e);
                throw new Exception("Error while getting metadata with uuid = " + uuid, e);
                //TempData["failure"] = "Feilmelding: " + e.Message;
                //return View("Error");
            }
        }
Exemplo n.º 18
0
 /* ----------------------------------------------------------------- */
 ///
 /// Set
 ///
 /// <summary>
 /// ViewModel に設定内容を反映させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 private void Set(MetadataViewModel vm, Metadata src)
 {
     vm.Title    = src.Title;
     vm.Author   = src.Author;
     vm.Subject  = src.Subject;
     vm.Keywords = src.Keywords;
     vm.Creator  = src.Creator;
     vm.Options  = src.Options;
 }
Exemplo n.º 19
0
        public MetadataView()
        {
            _currentView = this;
            _vm          = new MetadataViewModel(this);
            DataContext  = _vm;
            InitializeComponent();

            var mw = MainWindow.GetMainWindow();

            mw.SelectedPrimaryItemValueChanged += Mw_SelectedPrimaryItemValueChanged;
        }
Exemplo n.º 20
0
        /// <summary>
        /// Method to get the metadata view model
        /// </summary>
        /// <param name="currentPage">The current page</param>
        /// <returns>Metadata view model</returns>
        public MetadataViewModel GetMetadata(IPublishedContent currentPage)
        {
            var model = new MetadataViewModel
            {
                AbsoluteUrl = currentPage.UrlAbsolute()
            };

            Mapper.Map(currentPage, model);

            return(model);
        }
Exemplo n.º 21
0
        private void ValidateModel(MetadataViewModel model)
        {
            ViewBag.thumbnailMissingCSS = "";
            var thumb = model.Thumbnails.Where(t => t.Type == "thumbnail" || t.Type == "miniatyrbilde");

            if (thumb.Count() == 0)
            {
                ModelState.AddModelError("thumbnailMissing", UI.ImageRequired);
                ViewBag.thumbnailMissingCSS = "input-validation-error";
            }
        }
Exemplo n.º 22
0
 private void SaveMetadataToCswServer(MetadataViewModel model)
 {
     try
     {
         _metadataService.SaveMetadataModel(model, GetUsername());
         TempData["success"] = UI.Metadata_Edit_Saved_Success;
     }
     catch (Exception e)
     {
         Log.Error("Error while editing metadata with uuid = " + model.Uuid, e);
         TempData["failure"] = String.Format(UI.Metadata_Edit_Saved_Failure, e.Message);
     }
 }
Exemplo n.º 23
0
        private void EditMetadataButton_Click(object sender, RoutedEventArgs e)
        {
            MetadataViewModel selectedMetadata = NodeMetadataDataGrid.SelectedItem as MetadataViewModel;

            if (selectedMetadata != null)
            {
                EditMetadataDialog editMetadataDialog = new EditMetadataDialog();
                editMetadataDialog.Closed         += new EventHandler(EditMetadataDialog_Closed);
                editMetadataDialog.MetadataTypeUid = selectedMetadata.MetadataTypeUid;
                editMetadataDialog.Value           = selectedMetadata.MetadataValue;
                editMetadataDialog.MetadataName    = selectedMetadata.MetadataName;
                editMetadataDialog.Show();
            }
        }
Exemplo n.º 24
0
        public PropertiesWindow()
        {
            InitializeComponent();

            var loc = App.Current.FindResource("Locator") as ViewModelLocator;

            this._genSettings      = loc.Settings;
            this._h264Settins      = loc.H264Settings;
            this._recorderSettings = loc.RecorderSettings;
            this._metadataSettings = loc.Metadata;
            this._secureSettings   = loc.Security;

            this.SetSecureData();
        }
Exemplo n.º 25
0
        private void EditMetadataDialog_Closed(object sender, EventArgs e)
        {
            MetadataViewModel  selectedMetadata = NodeMetadataDataGrid.SelectedItem as MetadataViewModel;
            EditMetadataDialog dialog           = sender as EditMetadataDialog;

            if (dialog != null && dialog.DialogResult.Value == true)
            {
                selectedMetadata.MetadataValue   = dialog.Value;
                selectedMetadata.MetadataTypeUid = dialog.MetadataTypeUid;
                if (!IsEqualToOriginal(selectedMetadata))
                {
                    _changes[selectedMetadata.OriginalMetadataName.ToLower()] = true;
                }
            }
        }
Exemplo n.º 26
0
        private void NodeMetadataDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MetadataViewModel selectedMetadata = NodeMetadataDataGrid.SelectedItem as MetadataViewModel;

            if (selectedMetadata != null)
            {
                EditMetadataButton.IsEnabled   = true;
                DeleteMetadataButton.IsEnabled = true;
            }
            else
            {
                EditMetadataButton.IsEnabled   = false;
                DeleteMetadataButton.IsEnabled = false;
            }
        }
Exemplo n.º 27
0
 private void MarkChanged(MetadataViewModel model, DataGridRow changedRow, bool changed)
 {
     if (changed)
     {
         SaveButton.IsEnabled  = true;
         changedRow.Foreground = new SolidColorBrush(Colors.Red);
     }
     else
     {
         if (!HasChanges)                  //checks if there are any other changes before resetting the Save button
         {
             SaveButton.IsEnabled = false; //if there are no other changes
         }
         changedRow.Foreground = new SolidColorBrush(Colors.Black);
     }
 }
Exemplo n.º 28
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (MetadataViewModel metadata in _metadata.Where(md => md.OriginalMetadataName != md.MetadataName))
            {
                NodeProxy.RenameNodeMetadata(metadata.GetContext(), metadata.MetadataName);
                _metadataNames.Remove(metadata.OriginalMetadataName);
                _metadataNames.Add(metadata.MetadataName);
                metadata.UpdateName();
            }

            if (HasChanges)
            {
                TypeManager          typeManager   = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>();
                IMetadataTypeProxy[] metaDataTypes = typeManager.GetAllMetadataTypes();

                foreach (KeyValuePair <string, bool> changedMetadata in _changes.Where(changed => changed.Value == true))
                {
                    //only update the changed items
                    try
                    {
                        MetadataViewModel metadata = _metadata.Single(m => m.MetadataName.ToLower() == changedMetadata.Key.ToLower());
                        if (metadata != null)
                        {
                            NodeProxy.SetNodeMetadata(metadata.GetContext(), metadata.MetadataValue, metaDataTypes.Single(md => md.Id == metadata.MetadataTypeUid));
                        }
                    }
                    catch (Exception)
                    {
                        //ignore any errors if the changed metadata isn't found
                    }
                }

                _changes.Clear();

                foreach (MetadataViewModel deletedItem in _deletedItems)
                {
                    NodeProxy.DeleteNodeMetadata(deletedItem.GetContext());
                }

                _deletedItems.Clear();
            }

            SaveButton.IsEnabled = false;
            ResetOriginals();
            ClearChangeIndicator();
        }
Exemplo n.º 29
0
        public void modify()
        {
            // ARRANGE
            var metadata = new Metadata(new Uri("http://localhost/test/1"), true);

            var viewModel = new MetadataViewModel(metadata, _modifyResourceFactory, _exceptionFactory, _restClient.Object, _messageService.Object, SchedulerService);

            TestScheduler.AdvanceBy(TimeSpan.FromMilliseconds(100));

            // ACT
            viewModel.ModifyCommand.Execute(null);

            TestScheduler.AdvanceBy(TimeSpan.FromMilliseconds(100));

            // ASSERT
            _messageService.VerifyAll();
        }
Exemplo n.º 30
0
        public ActionResult Delete(string uuid)
        {
            MetadataViewModel model = _metadataService.GetMetadataModel(uuid);

            string role = GetSecurityClaim("role");

            if (HasAccessToMetadata(model))
            {
                _metadataService.DeleteMetadata(model, GetUsername());

                TempData["Message"] = "Metadata med uuid " + uuid + " ble slettet.";
                return(RedirectToAction("Index"));
            }
            else
            {
                return(new HttpUnauthorizedResult());
            }
        }
        private void LoadData()
        {
            _reader = new PackageReader();
               _reader.Read(PathToFile);

            PackageViewModel = new PackageViewModel(_reader);
            MetadataViewModel = new MetadataViewModel(_reader);
            ManifestViewModel = new ManifestViewModel(_reader);
            RequiresViewModel = new RequiresViewModel(_reader);
            DefineViewModel = new DefineViewModel(_reader);
            SigningViewModel = new SigningViewModel(_reader);
            LicenseViewModel = new LicenseViewModel(_reader);
            CompatibilityPolicy = new CompatibilityPolicyViewModel(_reader);
            ApplicationRoleViewModel = new ApplicationRoleViewModel(_reader);
            AssemblyRoleViewModel = new AssemblyRoleViewModel(_reader);
            FilesViewModel = new FilesViewModel(_reader);
            //PackageCompositionViewModel = new PackageCompositionViewModel(_reader);
            //_allViewModels.Add(PackageViewModel);
        }
        private void CreateModels(PackageReader reader)
        {
            string package = "package";
            _packageViewModel = new PackageViewModel()

            {
                Name = reader.GetRulesPropertyValueByName(package, "name"),
                DisplayName = reader.GetRulesPropertyValueByName(package, "display-name"),
                Architecture = reader.GetRulesPropertyValueByName(package, "arch"),
                Feed = reader.GetRulesPropertyValueByName(package, "feed"),
                Location = reader.GetRulesPropertyValueByName(package, "location"),
                Publisher = reader.GetRulesPropertyValueByName(package, "publisher"),
                Version = reader.GetRulesPropertyValueByName(package, "version")
            };

            string metadata = "metadata";
            _metadataViewModel = new MetadataViewModel()
            {
                Summary = reader.GetRulesPropertyValueByName(metadata, "summary"),
                Description = reader.GetRulesPropertyValueByName(metadata, "description"),
                AuthorVersion = reader.GetRulesPropertyValueByName(metadata, "author-version"),
                BugTracker = reader.GetRulesPropertyValueByName(metadata, "bug-tracker"),
                Stability = reader.GetRulesPropertyValueByName(metadata, "stability"),
                Licenses = reader.GetRulesPropertyValueByName(metadata, "licenses"),
            };

            //_requiresViewModel = new RequiresViewModel()
            //{

            //    RequiredPackages = new ObservableCollection<Package>()
            //};

            _packageCompositionViewModel = new PackageCompositionViewModel()
            {
                Symlinks = reader.GetRulesPropertyValueByName("package-composition", "symlinks")

            };

            _packageCompositionViewModel = new PackageCompositionViewModel()
            {
                Symlinks = reader.GetRulesPropertyValueByName("package-composition", "symlinks")

            };

            _filesCollection = new ObservableCollection<FilesViewModel>();

            foreach (string parameter in reader.ReadFilesParameters())
            {

                ObservableCollection<string> collection = new ObservableCollection<string>(reader.GetFilesIncludeList(parameter));

                FilesViewModel model = new FilesViewModel(parameter)
                                      {
                                          Root = reader.GetFilesRulesPropertyValueByParameterAndName(parameter,"root"),
                                          TrimPath = reader.GetFilesRulesPropertyValueByParameterAndName(parameter, "trim-path"),
                                          Include = collection
                                      };
                _filesCollection.Add(model);
            }
        }