classdef DeclareWorkflowStrategy < fxptds.WorkflowTopology.Strategy
    %% DECLAREWORKFLOWSTRATEGY class
    % This strategy when a user has declared which workflow to begin
    
    % Copyright 2019 The MathWorks, Inc.
    
    
    % Access is protected and extended to Facade and to the test class
    methods (Access = {?fxptds.WorkflowTopology.Strategy, ?fxptds.WorkflowTopology.Facade, ?WorkflowTopologyTestCase})
        
        function execute(this)
            
            rootName = this.TopModel;
            
            query = this.createDefaultQuery();
            query.Type = "Setup";
            query.Limit = 1;
            query.ContainerID = this.WorkflowContext.ContainerID;
            setupName = this.executeQuery(rootName, query);
            setupName = this.processQueryData(setupName);
            
            % if no setup already exists for the given container
            if isempty(setupName)
                % create a new setup node
                type = fxptds.WorkflowTopology.element.NodeType.SetupAction;
                setupNode = this.createAndAddNodeByType(type);
                setupName = setupNode.Name;

                % connect the Root Design to the Setup Node
                this.verifyAndConnect(rootName, setupName);
            end
            
        end
    end
    
end

