Skip to content
Snippets Groups Projects
Commit b354549d authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Merge branch 'dev/generalFixes' into 'development'

Merge general Fixes

See merge request fst-tuda/projects/nfdi4ing/projects/plot_identifier!7
parents df421227 e16219c0
No related branches found
No related tags found
3 merge requests!13PreRelease_V0.1,!12PreRelease_V0.1,!7Merge general Fixes
......@@ -76,12 +76,17 @@ end
%% Research data handeling
switch options.Method
case 'centralized'
DataFolderName = 'data';
% check if data folder exists
if ~isfolder(fullfile(storPath,'data'))
mkdir(fullfile(storPath,'data'));
if ~isfolder(fullfile(storPath,DataFolderName))
mkdir(fullfile(storPath,DataFolderName));
end
% to get relative Paths
currentPath = fullfile(storPath);
%list all files
fList = dir(fullfile(storPath,'data', '**\*.*')); %get list of files and folders in any subfolder
fList = dir(fullfile(storPath,DataFolderName, '**\*.*'));
%get list of files and folders in any subfolder
fList = fList(~[fList.isdir]); %remove folders from list
fList = struct2table(fList);
......@@ -92,20 +97,26 @@ switch options.Method
[~, idx] = PlotID.fileCompare(DataPaths.rdata{i},fList);
% create Linked HDF5 files for identical files
if any(idx)
sourcePath = fList{idx,'name'}; % If there are multiple copies already, this only picks the last entry
fList.path = fullfile(fList.folder,fList.name);
sourcePath = fList{idx,'path'};
relativeSourcePath = strrep(sourcePath,currentPath,'');
%WIP relative PATh!!
if contains(sourcePath,{'.h5','.hdf5'}) % Linking only for HDF5
PlotID.createLinkedHDF5(sourcePath{1,1},storPath,ID);
PlotID.createLinkedHDF5(relativeSourcePath{1,1},storPath,ID);
end
else % no identical file exists
%Copy the file in data
PlotID.createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'dataCentral');
%Copy the file in data and create the links (if hdf5)
[dataPath] = PlotID.createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'dataCentral');
relativeDataPath = strrep(dataPath,currentPath,'');
%WIP
% if contains(DataPaths.rdata{i},{'.h5','.hdf5'}) % Linking only for HDF5
% % and create linked files in the plot folder
% PlotID.createLinkedHDF5(DataPaths.rdata{i},storPath,ID);
% end %if
if contains(DataPaths.rdata{i},{'.h5','.hdf5'}) % Linking only for HDF5
% and create also linked files in the plot folder
PlotID.createLinkedHDF5(relativeDataPath,storPath,ID);
end %if
end %if
end %for
clear DataFolderName
case 'individual'
% Create a copy of the research data
PlotID.createFileCopy(DataPaths.rdata,folderName,storPath,ID, 'data');
......
function [] = createFileCopy(filePaths,folderName,storPath,ID,type)
function [storagePaths] = createFileCopy(filePaths,folderName,storPath,ID,type)
% Creates a copy of the files (can be used for multiple paths in a cell array)
% folderName is the name of the exporting folder
% returns the storage paths were files were stored
disp(['start to copy ', type]);
if ~iscell(filePaths)
......@@ -9,6 +10,7 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type)
end
try
storagePaths = cell(numel(filePaths,1));
for i = 1:numel(filePaths)
FileNameAndLocation = filePaths{i};
[~,name,ext] = fileparts(filePaths{i}); % get the extension
......@@ -52,6 +54,7 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type)
warning('Filename already exists in data folder');
end
copyfile(FileNameAndLocation,RemotePath);
storagePaths{i} = RemotePath;
end
disp([type, ' sucessfully published']);
catch
......
......@@ -18,7 +18,8 @@ end
fid = H5F.create(fullfile(TargetPath,ID,[filename,ext]));
%create External Link to Sourcefile in the Group linkToExternal
H5L.create_external(['..\data\',SourceFile],'/',fid, SourceFile ,plist_id,plist_id);
H5L.create_external(['..\',SourceFile],'/',fid, SourceFile ,plist_id,plist_id);
%H5L.create_external(['..\data\',SourceFile],'/',fid, SourceFile ,plist_id,plist_id); %original
H5F.close(fid);
disp([fullfile(TargetPath,ID,[filename,ext]),' created']);
status = 1;
......
......@@ -56,12 +56,14 @@ try
path.rdata = {dataset1,dataset2} ; % don't forget the extension
PlotID.Publish(path, ID, figs, 'Location', 'CI-Test')
result = true;
% clean up
delete CI_files/export/* CI_files/*.mat CI_files/*.h5
rmdir('CI_files/export','s');
result = true;
clc; clear;
clear; clc;
catch
result = false;
warning('simple_test failed');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment