classdef UpdateContainerAction < fxptui.internal.action.Action
    %UPDATECONTAINERACTION Action of overwriting the container ID for
    %all unaccounted for runs
    
    %   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 ProposalSettings information from the
            % ProposalSetting
            collectionSettings = workflowSetting.getSettingValue('CollectionSetting');
            baselineRunName = collectionSettings.RunName;
            verificationSettings = workflowSetting.getSettingValue('VerificationSetting');
            verificationRunName = verificationSettings.RunName;
            
            % get the DataLayer instance
            dataLayer = fxptds.DataLayerInterface.getInstance();
            
            % get the current Workflow ID
            currentWorkflow = dataLayer.getCurrentWorkflow(topModel);
            currentWorkflowID = currentWorkflow.ID;
            
            % convert the fxpopt Baseline run into a FPTRunID
            [~, baselineFPTRunID] = dataLayer.getIdFromRunName(topModel, baselineRunName);
            [~, verificationFPTRunID] = dataLayer.getIdFromRunName(topModel, verificationRunName);
            
            % get the facade
            facade = dataLayer.getWorkflowTopologyFacade(topModel);
            
            % create the context
            context = fxptds.WorkflowTopology.WorkflowContextFactory.getContext(fxptds.UserIntent.UpdateContainer, ...
                'TopModel', topModel, ...
                'BaselineFPTRunID', baselineFPTRunID, ...
                'VerificationFPTRunID', verificationFPTRunID, ...
                'ContainerID', currentWorkflowID);
            
            % register the intent
            facade.register(context);
            
        end
        
    end
    
end

% LocalWords:  FPT
