Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: ConstrainedLangStringSets #113

Conversation

jkhsjdhjs
Copy link
Contributor

@jkhsjdhjs jkhsjdhjs commented Aug 22, 2023

This adds the abstract base class ConstrainedLangStringSet and the
following subclasses:

  • MultiLanguageNameType
  • MultiLanguageTextType
  • DefinitionTypeIEC61360
  • PreferredNameTypeIEC61360
  • ShortNameTypeIEC61360

ConstrainedLangStringSet is implemented as an abstract subclass of
LangStringSet, which uses a given function to check the constraints
of all stored values, similar to ConstrainedList. This function is
called for every key-value pair on initialization and whenever a new
key-value pair is added. Additionally, functions such as __init__()
and __setitem__() of the base class LangStringSet are called where
appropriate, such that all constraints for language tags are also
checked here.

Each of the concrete subclasses consist of just an __init__()
function, that passes a constraint-check function to
ConstrainedLangStringSet.__init__().

Furthermore, a few basic tests for LangStringSet and its subclasses
are added, e.g. whether language-tag constraints are checked correctly,
whether LangStringSet checks for emptiness and whether basic functionality
such as string-representation, length-calculation and key-values
iteration works as expected.

Additionally, a basic test for value-constraints in
ConstrainedLangStringSets is added.

Close #77 #89

@jkhsjdhjs jkhsjdhjs marked this pull request as draft August 22, 2023 19:50
@jkhsjdhjs jkhsjdhjs mentioned this pull request Aug 22, 2023
26 tasks
This will be used for the constrained `MultiLanguageNameType` constrained
`LangStringSet`.
This function returns a new constraint-check function for strings
that aren't of a specific type. This will be used by the constrained
lang string sets `MultiLanguageTextType`, `DefinitionTypeIEC61360`,
`PreferredNameTypeIEC61360` and `ShortNameTypeIEC61360`, where values
aren't of a basic constrained string type, but are still constrained in
minimum and maximum length.
This adds the abstract base class `ConstrainedLangStringSet` and the
following subclasses:
- `MultiLanguageNameType`
- `MultiLanguageTextType`
- `DefinitionTypeIEC61360`
- `PreferredNameTypeIEC61360`
- `ShortNameTypeIEC61360`

`ConstrainedLangStringSet` is implemented as an abstract subclass of
`LangStringSet`, which uses a given function to check the constraints
of all stored values, similar to `ConstrainedList`. This function is
called for every key-value pair on initialization and whenever a new
key-value pair is added. Additionally, functions such as `__init__()`
and `__setitem__()` of the base class `LangStringSet` are called where
appropriate, such that all constraints for language tags are also
checked here.

Each of the concrete subclasses consist of just an `__init__()`
function, that passes a constraint-check function to
`ConstrainedLangStringSet.__init__()`.
This adds a few basic tests for `LangStringSet` and its subclasses, e.g.
whether language-tag constraints are checked correctly, whether
`LangStringSet` checks for emptiness and whether basic functionality
such as string-representation, length-calculation and key-values
iteration works as expected.

Additionally, a basic test for value-constraints in
`ConstrainedLangStringSet`s is added.
`LangStringSet` still remains concrete but may be made abstract in the
future.
This commit changes the XML/JSON (de-)serialization adapter and
corresponding schemata such that they are compatible with the new
`ConstrainedLangStringSet` types.
@jkhsjdhjs jkhsjdhjs force-pushed the feature/constrained_lang_string_sets branch from 42d0ef2 to c4f5178 Compare August 24, 2023 15:53
@jkhsjdhjs jkhsjdhjs marked this pull request as ready for review August 24, 2023 15:55
@s-heppner
Copy link
Contributor

Looks good to me. I'd rebase this, if you have nothing against that?

@s-heppner s-heppner merged commit 2d68291 into eclipse-basyx:improve/V30 Aug 31, 2023
5 checks passed
@s-heppner s-heppner deleted the feature/constrained_lang_string_sets branch August 31, 2023 13:36
@s-heppner s-heppner added BlockingRelease This issue needs to be solved before the pending release v3.0 and removed BlockingRelease This issue needs to be solved before the pending release labels Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants