Skip to content

Commit 765b873

Browse files
Merge pull request #491 from VH-Lab/feature-add-arguments-block
Enhance `getCloudDatasetIdForLocalDataset` function
2 parents 90edd25 + 1d257a8 commit 765b873

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1-
function cloudDatasetId = getCloudDatasetIdForLocalDataset(ndiDataset)
1+
function [cloudDatasetId, cloudDatasetIdDocument] = getCloudDatasetIdForLocalDataset(ndiDataset)
2+
% GETCLOUDDATASETIDFORLOCALDATASET - a companion to ndi.cloud.internal.createRemoteDatasetDoc
3+
%
4+
% [CLOUDDATASETID, CLOUDDATASETIDDOCUMENT] = GETCLOUDDATASETIDFORLOCALDATASET(NDIDATASET)
5+
%
6+
% Reads the remotedataset doc and returns the remote cloud id.
7+
% If there is no cloudDatasetId, it returns an empty string.
8+
% If there is more than one dataset_remote document, it errors.
9+
%
10+
% The second output argument returns the cloudDatasetIdDocument itself.
11+
%
12+
arguments
13+
ndiDataset ndi.dataset
14+
end
215
cloudDatasetIdQuery = ndi.query('','isa','dataset_remote');
316
cloudDatasetIdDocument = ndiDataset.database_search(cloudDatasetIdQuery);
4-
if ~isempty(cloudDatasetIdDocument)
17+
if numel(cloudDatasetIdDocument) > 1
18+
error('NDICloud:Sync:MultipleCloudDatasetId', ...
19+
['Found more than one remote cloudDatasetId for the local ', ...
20+
'dataset: %s.'], ndiDataset.path);
21+
elseif ~isempty(cloudDatasetIdDocument)
522
cloudDatasetId = cloudDatasetIdDocument{1}.document_properties.dataset_remote.dataset_id;
623
else
7-
error('NDICloud:Sync:MissingCloudDatasetId', ...
8-
['Could not resolve the remote cloudDatasetId for the local ', ...
9-
'dataset: %s. Ensure it is linked.'], ndiDataset.path);
24+
cloudDatasetId = '';
1025
end
11-
% Todo: Add suggestion what to do
1226
end

0 commit comments

Comments
 (0)