Update() public method

Updates the non workflow related details of from another resource model.
public Update ( IResourceModel resourceModel ) : void
resourceModel IResourceModel The resource model to update from.
return void
        protected void ReloadResource(IEnvironmentModel environmentModel, Guid resourceId, ResourceType resourceType)
        {
            if(environmentModel == null || environmentModel.ResourceRepository == null)
            {
                return;
            }

            var getWorksurfaceItemRepo = WorkspaceItemRepository.Instance;

            CheckForServerMessages(environmentModel, resourceId, getWorksurfaceItemRepo);
            var effectedResources = environmentModel.ResourceRepository.ReloadResource(resourceId, resourceType, ResourceModelEqualityComparer.Current, true);
            if(effectedResources != null)
            {
                foreach(var resource in effectedResources)
                {
                    var resourceWithContext = new ResourceModel(environmentModel);
                    resourceWithContext.Update(resource);
                    Dev2Logger.Log.Info("Publish message of type - " + typeof(UpdateResourceMessage));
                    EventPublisher.Publish(new UpdateResourceMessage(resourceWithContext));
                }
            }
        }
Exemplo n.º 2
0
 public void ResourceModel_Update_WhenWorkflowXamlChanged_ExpectUpdatedResourceModelWithNewXaml()
 {
     //------------Setup for test--------------------------
     // Setup();
     var environmentModel = CreateMockEnvironment(new EventPublisher());
     var resourceModel = new ResourceModel(environmentModel.Object);
     const string category = "TestCat";
     const string comment = "TestComment";
     const string displayName = "DisplayName";
     const string resourceName = "TestResourceName";
     var id = Guid.NewGuid();
     const string tags = "TestTags";
     resourceModel.Category = category;
     resourceModel.Comment = comment;
     resourceModel.DisplayName = displayName;
     resourceModel.ID = id;
     resourceModel.ResourceName = resourceName;
     resourceModel.Tags = tags;
     resourceModel.WorkflowXaml = new StringBuilder("new xaml");
     //------------Execute Test---------------------------
     var updateResourceModel = new ResourceModel(environmentModel.Object) { WorkflowXaml = new StringBuilder("old xaml") };
     updateResourceModel.Update(resourceModel);
     //------------Assert Results-------------------------
     Assert.AreEqual("new xaml", updateResourceModel.WorkflowXaml.ToString());
 }
Exemplo n.º 3
0
 public void ResourceModel_UpdateResourceModelExpectPropertiesUpdated()
 {
     //------------Setup for test--------------------------
     Setup();
     var environmentModel = CreateMockEnvironment(new EventPublisher());
     var resourceModel = new ResourceModel(environmentModel.Object);
     const Permissions UserPermissions = Permissions.Contribute;
     const string category = "TestCat";
     const string comment = "TestComment";
     const string displayName = "DisplayName";
     const string resourceName = "TestResourceName";
     const string inputs = "this is the inputs";
     const string outputs = "this is the outputs";
     var id = Guid.NewGuid();
     const string tags = "TestTags";
     resourceModel.Category = category;
     resourceModel.Comment = comment;
     resourceModel.DisplayName = displayName;
     resourceModel.ID = id;
     resourceModel.ResourceName = resourceName;
     resourceModel.Tags = tags;
     resourceModel.UserPermissions = UserPermissions;
     resourceModel.Inputs = inputs;
     resourceModel.Outputs = outputs;
     //------------Execute Test---------------------------
     var updateResourceModel = new ResourceModel(environmentModel.Object);
     updateResourceModel.Update(resourceModel);
     //------------Assert Results-------------------------
     Assert.AreEqual(category, updateResourceModel.Category);
     Assert.AreEqual(comment, updateResourceModel.Comment);
     Assert.AreEqual(displayName, updateResourceModel.DisplayName);
     Assert.AreEqual(id, updateResourceModel.ID);
     Assert.AreEqual(tags, updateResourceModel.Tags);
     Assert.AreEqual(UserPermissions, updateResourceModel.UserPermissions);
     Assert.AreEqual(inputs, updateResourceModel.Inputs);
     Assert.AreEqual(outputs, updateResourceModel.Outputs);
 }
        protected void CheckForServerMessages(IEnvironmentModel environmentModel, Guid resourceId, IWorkspaceItemRepository workspace)
        {
            var resourceModel = environmentModel.ResourceRepository.FindSingle(model => model.ID == resourceId);
            if(resourceModel != null)
            {
                var resource = new ResourceModel(environmentModel);
                resource.Update(resourceModel);
                var compileMessageList = new StudioCompileMessageRepo().GetCompileMessagesFromServer(resource);

                if(compileMessageList == null || compileMessageList.Count == 0)
                {
                    return;
                }

                var numberOfDependants = compileMessageList.Dependants.Count;
                //2013.07.29: Ashley Lewis for bug 9640 - If only dependancy is open right now, don't notify of change
                if(numberOfDependants == 1)
                {
                    if(
                        compileMessageList.Dependants.Any(
                            dep =>
                                workspace.WorkspaceItems != null &&
                                workspace.WorkspaceItems.Any(c => c.ServiceName == dep)))
                    {
                        return;
                    }
                }
                //2013.07.29: Ashley Lewis for bug 10199 - Don't show dependancy viewer dialog on source type callback
                if(resource.ResourceType != ResourceType.Source)
                {
                    ShowDependencyProvider.ShowDependencyViewer(resource, compileMessageList.Dependants);
                }
            }
        }