%mandatory -->  dataSource;
%optional  -->  figureName , dimentions , groupsCol;

function plotDVPMatrixPlot( dataSource , figureName , dimentions , groupsCol) 

if nargin < 1
    error('not enough parameters');
end

if ~ischar(dataSource) 
    
if ~isnumeric(dataSource)
    error('data cannot non numeric');
end
    
    alreadyAdded = false;
    
    r = sendDataToDVP(struct('requestType','select','operation','getDataSources',...
    'config','STUB'));
    dataSourcesNames = loadjson(char(r.data));
    
    if(ismember(inputname(1) , dataSourcesNames))
        alreadyAdded = true; 
    end

if(alreadyAdded == false)
    dsName = inputname(1);
    createDVPDataSource(dataSource,dsName); 
else
   dsName = inputname(1);
end
else 
    
if isempty(dataSource)
    error('Invalid dataSourceName');
    
else
        dsName = dataSource;
end   
end

if ~exist('figureName','var')
    ctr = getappdata(0,'counter');
    figName = strcat('Matrix',int2str(++ctr));
    
    else
        figName = figureName;
end

if ~exist('features','var') || isempty(dimentions)
    featuresList = 'All-Features';
    
else
    
    if ~isnumeric(dimentions)
        error('Invalid dimentions');
    end
        featuresList = dimentions;
end

if ~exist('groupsCol','var') || isempty(groupsCol)|| isnumeric(groupsCol)
    groups = 'invalid-groups-col';
    
else
        groups = groupsCol;
end

data = struct('requestType', 'create', 'operation', 'figure',...
    'config', struct('figureType', 'ScatterPlotMatrix', 'id',figName,...
    'dataSourceID', dsName,...
    'figureProperties', struct('features',featuresList  , 'groups' , groups)));

sendDataToDVP(data);

end
