From bb34b8d672dcd91ab2cc8544fcd46085576ed341 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Mon, 31 Aug 2026 11:25:17 +0200 Subject: [PATCH] fix: use the store passed to Collection.save and drop the dead resolver option Passing a metadata store to save by name-value failed on any collection that was not constructed with one. The branch checked options.MetadataStore but called save on obj.MetadataStore, which defaults to an empty store, so the call errored on the empty object instead of using the store it was given. Found while verifying that an external database integration can work purely through the MetadataStore interface. The constructor also accepted a LinkResolver option that was never stored and a LinkResolver property that nothing read. Resolvers are registered through openminds.registerLinkResolver and selected per reference from the registry, so a collection-level resolver has no role. Both are removed. Co-Authored-By: Claude Opus 5 --- code/+openminds/@Collection/Collection.m | 5 +---- tools/tests/unitTests/CollectionTest.m | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/code/+openminds/@Collection/Collection.m b/code/+openminds/@Collection/Collection.m index e7d3616af..ebcb86ef5 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 e4c82691a..790cd1c89 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();