diff --git a/code/+openminds/@Collection/Collection.m b/code/+openminds/@Collection/Collection.m index e7d3616a..ebcb86ef 100644 --- a/code/+openminds/@Collection/Collection.m +++ b/code/+openminds/@Collection/Collection.m @@ -66,8 +66,6 @@ end properties (SetAccess = protected) - LinkResolver - % MetadataStore - Optional metadata store for saving/loading MetadataStore openminds.interface.MetadataStore = openminds.internal.FileMetadataStore.empty end @@ -114,7 +112,6 @@ arguments options.Name (1,1) string = "" options.Description (1,1) string = "" - options.LinkResolver (1,:) = [] options.MetadataStore openminds.interface.MetadataStore = openminds.internal.FileMetadataStore.empty end @@ -385,7 +382,7 @@ function updateLinks(obj) outputPaths = tempStore.save(instances); elseif ~isempty(options.MetadataStore) - outputPaths = obj.MetadataStore.save(instances); + outputPaths = options.MetadataStore.save(instances); elseif ~isempty(obj.MetadataStore) % Use configured store diff --git a/tools/tests/unitTests/CollectionTest.m b/tools/tests/unitTests/CollectionTest.m index e4c82691..790cd1c8 100644 --- a/tools/tests/unitTests/CollectionTest.m +++ b/tools/tests/unitTests/CollectionTest.m @@ -269,6 +269,23 @@ function testSaveAndLoad(testCase) testCase.verifyTrue(newCollection.isKey(org.id)); end + function testSaveWithMetadataStoreOption(testCase) + % A store passed to save by name-value must be the store used. + % This went through obj.MetadataStore instead, which is empty + % unless the collection was constructed with one. + + personInstance = openminds.core.Person('givenName', "Store"); + collection = openminds.Collection(personInstance); + + filePath = fullfile(pwd, "via-option.jsonld"); % WorkingFolderFixture cwd + fileStore = openminds.internal.FileMetadataStore(filePath); + + collection.save("", "MetadataStore", fileStore); + + testCase.verifyTrue(isfile(filePath), ... + 'The store passed by name-value should have been used to save.') + end + function testSaveToMultipleFiles(testCase) % Test saving a collection to multiple files collection = openminds.Collection();