function runNames = getRunsWithProposalForSystem(system)
% GETRUNSWITHPROPOSALSFORSYSTEM Returns the run names containing data type
% proposals for a given system

% Copyright 2016-2017 The MathWorks, Inc.

dataLayer = fxptds.DataLayerInterface.getInstance();    
runNames = {};
datasetArray = fxptds.getAllDatasetsForModel(system);
for i = 1:numel(datasetArray)
    allRuns = dataLayer.getAllRunNamesWithResults(datasetArray{i});
    for kk = 1:numel(allRuns)
        if datasetArray{i}.getRun(allRuns{kk}).hasApplicableProposals
            runNames = [runNames, allRuns(kk)];  %#ok<AGROW
        end
    end
end

% Unique on empty cell array of runNames returns a 0x1 cell array which
% causes test failures. 
if ~isempty(runNames)
    % Filter out empty runNames from the output list of runNames
    % Remove Duplicate run names across model names
    runNames = unique(runNames);
    runNames = sort(runNames);
    idx = ~cellfun('isempty',runNames);
    if any(idx)
        runNames = runNames(idx);
    else
        runNames = {};
    end
end
