classdef UpdateVerificationResultBaselineAction < fxptui.internal.action.Action
    %UPDATEVERIFICATIONRESULTBASELINEACTION Action of updating the baseline
    %for a given verification node in DesignStore. Assumes that the
    %baseline run exists in design store.
    
    %   Copyright 2019 The MathWorks, Inc.
    
    
    methods(Access = {?fxptui.internal.action.Action, ?WorkflowTestCase})
        
        function executeLocal(~, ~, workflowSetting)
            
            % extract the TopModel information from the DesignSetting
            designSettings = workflowSetting.getSettingValue('DesignSetting');
            topModel = designSettings.TopModel;
            
            % extract the VerificationRunName information from the
            % VerificationSetting
            baselineSettings = workflowSetting.getSettingValue('CollectionSetting');
            baselineRunName = baselineSettings.RunName;
            
            % extract the run name used for Verification from the
            % VerificationSetting
            verificationSettings = workflowSetting.getSettingValue('VerificationSetting');
            verificationRunName = verificationSettings.RunName;
            
            % convert the baseline and verification run names into run IDs
            dataLayer = fxptds.DataLayerInterface.getInstance();
            [~, baselineFPTRunID] = dataLayer.getIdFromRunName(topModel, baselineRunName);
            [~, verificationFPTRunID] = dataLayer.getIdFromRunName(topModel, verificationRunName);
            
            % create the context
            context = fxptds.WorkflowTopology.WorkflowContextFactory.getContext(fxptds.UserIntent.CollectionVerification, ...
                'TopModel', topModel, ...
                'BaselineFPTRunID', baselineFPTRunID, ...
                'FPTRunID', verificationFPTRunID, ...
                'Settings', baselineSettings);
            
            % get the facade
            facade = dataLayer.getWorkflowTopologyFacade(topModel);
            
            % register the intent
            facade.register(context);
            
        end
        
    end
    
end

% LocalWords:  FPT
