Persistence fix and PATCH endpoints for submodel elements#551
Open
tamasf1 wants to merge 3 commits into
Open
Conversation
update_from() only mutated the in-memory object; the next GET re-read the unchanged file from disk and overwrote the in-memory state, silently discarding the update. Add LocalFileIdentifiableStore.commit() to write an identifiable back to its storage file, and call it from put_submodel and put_submodel_submodel_elements_id_short_path after update_from().
Six routes were previously returning 501 Not Implemented:
- PATCH /submodels/{smId}
- PATCH /submodels/{smId}/$metadata
- PATCH /submodels/{smId}/$value
- PATCH /submodels/{smId}/submodel-elements/{path}
- PATCH /submodels/{smId}/submodel-elements/{path}/$metadata
- PATCH /submodels/{smId}/submodel-elements/{path}/$value
The plain and $metadata variants decode the full/stripped body and
call update_from. The $value variants use a new _apply_value_only
helper that applies a ValueOnly patch to the in-memory element tree.
All handlers call commit() to persist changes to disk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mutations applied via PUT and PATCH endpoints were silently discarded.
The LocalFileIdentifiableStore reads objects from disk on every GET request and calls update_from() to refresh the in-memory cache. Because update_from() only mutates the in-memory object without writing back to disk, any changes made via PUT were silently overwritten on the next GET. As a result, PUT requests appeared to succeed (HTTP 204) but the repository state was never actually updated.
A new commit() method on LocalFileIdentifiableStore writes an Identifiable back to its storage file after mutation. The PUT and PATCH handlers in the repository interface now call commit() on the parent submodel after update_from() or value-only patching.
Additionally, six PATCH endpoints that previously returned 501 are now implemented:
The $value PATCH handler covers Property, MultiLanguageProperty, Range, Blob, File, SubmodelElementCollection and SubmodelElementList. Complex element types (ReferenceElement, RelationshipElement) are not yet supported and return 400.