|
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 |
2 | 15 | cloudDatasetIdQuery = ndi.query('','isa','dataset_remote'); |
3 | 16 | 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) |
5 | 22 | cloudDatasetId = cloudDatasetIdDocument{1}.document_properties.dataset_remote.dataset_id; |
6 | 23 | 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 = ''; |
10 | 25 | end |
11 | | - % Todo: Add suggestion what to do |
12 | 26 | end |
0 commit comments