Skip to content

closes #14 offer different strategies for model constraint violations#27

Open
Noah1891 wants to merge 23 commits intomainfrom
14-offer-different-strategies-for-model-constraint-violations
Open

closes #14 offer different strategies for model constraint violations#27
Noah1891 wants to merge 23 commits intomainfrom
14-offer-different-strategies-for-model-constraint-violations

Conversation

@Noah1891
Copy link
Copy Markdown
Collaborator

-added deletion modes RELAXED and CASCADE
-added argument mode to remove and deletion methods
-cascade deletes in mode CASCADE even on non-containment relationships, if the deleted reference was flagged as isRequired
-do not cascade deletes in mode RELAXED even on containment relationships and just let children exist without parents

@Noah1891 Noah1891 requested a review from SusieGoebel March 17, 2026 13:51
@Noah1891 Noah1891 linked an issue Mar 17, 2026 that may be closed by this pull request
…traint-violations

# Conflicts:
#	projects/emfular/src/lib/referencing/referencable/container/link/re-link-container.ts
#	projects/emfular/src/lib/referencing/referencable/container/link/re-link-list-container.spec.ts
#	projects/emfular/src/lib/referencing/referencable/container/link/re-link-list-container.ts
#	projects/emfular/src/lib/referencing/referencable/container/link/re-link-single-container.ts
#	projects/emfular/src/lib/referencing/referencable/container/re-container.ts
#	projects/emfular/src/lib/referencing/referencable/container/shallow/re-tree-parent-container.spec.ts
#	projects/emfular/src/lib/referencing/referencable/container/shallow/re-tree-parent-container.ts
#	projects/emfular/src/lib/referencing/referencable/container/tree/re-tree-children-container.ts
#	projects/emfular/src/lib/referencing/referencable/container/tree/re-tree-list-container.spec.ts
#	projects/emfular/src/lib/referencing/referencable/container/tree/re-tree-list-container.ts
#	projects/emfular/src/lib/referencing/referencable/container/tree/re-tree-single-container.spec.ts
#	projects/emfular/src/lib/referencing/referencable/container/tree/re-tree-single-container.ts
#	projects/emfular/src/lib/referencing/referencable/referenceable.ts
#	projects/emfular/src/lib/referencing/test/re-containers-with-single-child.ts
#	projects/emfular/src/lib/referencing/test/referencables-with-children.ts

constructor(parent: P, name: string, refMeta: ReferenceMeta) {
super(parent, name, refMeta);
constructor(parent: P, name: string, refMeta: ReferenceMeta, isRequired: boolean) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please use the refMeta and take the min value ffrom it? if min is 1, then it is reuired - this way, we avoid many actually unnecessary changes. You can still have the private isRequired property and set it inside the constructor - if you want it

}

override remove(item: T): boolean {
override remove(item: T, mode: DeletionMode): boolean {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this way, thisis a big breaking change. can you default it?

}]
}
expect(r1.toJson()).toEqual(r1json)
const json: RootWithChildrenJson = r1.toJson()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not remove tests

expect(r1.$otherReferences.length).toBe(1)
})

it('should allow swapping elements in a ModelList created via decorators', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not remove tests

});


it('should allow flatMap on ModelList proxies (shows proxy behaves like array)', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not remove tests

@Noah1891 Noah1891 requested a review from SusieGoebel March 23, 2026 14:53
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those were the tests that saved the last change we merged, why would you delete them now? is the former mode not available any more? If yes, then we missed sth

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The incompatability stems from the fact that converstation-example.ts uses the old constructors of the containers without refMeta. The plan was to fix this by employing new tests without leveraging KEML, since the EMFular KEML code snippets I copied from the keml.web repo don't use refMeta objects either

-added missing behavior when calling ReTreeListContainer remove with deletion mode
-fixed bug where calling destruct with CASCADE and the newly added behavior led to an infinite loop
-added ReChild4 as an object with required link for testing
-added more exhaustive tests for both deletion modes
@Noah1891 Noah1891 requested a review from SusieGoebel March 31, 2026 00:29
@Noah1891
Copy link
Copy Markdown
Collaborator Author

I originally intended to also add tests for the single versions for tree and link containers but there are no proxy methods available when trying to test on the classes from re-containers-with-single-child.ts that access the deletion functions for said the corresponding containers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offer different strategies for model constraint violations

2 participants