-
Notifications
You must be signed in to change notification settings - Fork 2
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
Instead of a string as a key to lookup Property and Model values can we enhance it using a Property Identifier type object? #2
Labels
enhancement
New feature or request
Comments
carldea
pushed a commit
that referenced
this issue
Jun 17, 2024
…n. This allows fields to reference a data object instead of just a property name as a string.
carldea
pushed a commit
that referenced
this issue
Jun 17, 2024
…n. This allows fields to reference a data object instead of just a property name as a string. Updated tests.
carldea
pushed a commit
that referenced
this issue
Jun 18, 2024
…n. This allows fields to reference a data object instead of just a property name as a string. Updated tests. Updated string interpolator for property ids
carldea
pushed a commit
that referenced
this issue
Jun 23, 2024
…n. This allows fields to reference a data object instead of just a property name as a string. Updated tests. Updated string interpolator for property ids. Update Javadoc documentation for required warnings
carldea
pushed a commit
that referenced
this issue
Jun 24, 2024
…n. This allows fields to reference a data object instead of just a property name as a string. Updated tests. Updated string interpolator for property ids. Update Javadoc documentation for required warnings
carldea
pushed a commit
that referenced
this issue
Jun 24, 2024
…n. This allows fields to reference a data object instead of just a property name as a string. Add license to files.
carldea
changed the title
Instead of a string as a key to lookup Property and Model values can we enhance using a Property Identifier type object.
Instead of a string as a key to lookup Property and Model values can we enhance using a Property Identifier type object?
Jun 26, 2024
carldea
changed the title
Instead of a string as a key to lookup Property and Model values can we enhance using a Property Identifier type object?
Instead of a string as a key to lookup Property and Model values can we enhance it using a Property Identifier type object?
Jun 26, 2024
carldea
pushed a commit
that referenced
this issue
Jun 28, 2024
…n. This allows fields to reference a data object instead of just a property name as a string. Add license to files. Updated docs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Question: Can properties get looked up other than a property name of type
String
?Answer: No (not yet), the APIs are currently only using a property name of type
String
.Let’s talk about the idea of a
Property Identifier
type object. This will offer another way to lookup property & model values by using a unique id or property name.Current State
The current MVVM capability of Cognitive only looks up property and model values based on a key of type
String
of a property name (used to reference a field in a UI form).Enhancement
An enhancement updates the APIs to allow a Property Identifier type object that represents a unique id, a property name, and an underlying user data type object. The user data type object can be any object that contains a unique value. e.g. Person class may have a getter method returning a unique id.
With this newer
PropertyIdentifier
it allows you to continue using it for property and model value lookup and also validation.Add (create) a property using a
PropertyIdentifier
with validationAbove you'll notice
personVm.getPropertyValue(spId)
is looked up by aPropertyIdentifier
instance. As a convenience the APIs should allow the caller to also lookup properties by using the following (as a key type):UUID.toString()
.Additional example of convenient ways to lookup or set property values on the view model.
When we validate
personVm.validate()
the error message will be returned as follows:First Name first character must be capitalized. Entered as fred
After validation above you'll notice the calls to
setPropertyValue()
to fix the validation error.Now that things are valid a
save()
will move property values into the model values. Below are examples of using the different key types to get model values.Java Classes & Interfaces to create.
The following is a high level list of items to create.
PropertIdentifier
SimplePropertyIdentifier
IdSimpleViewModel
-addProperty(PropertyIdentifier propId, T value)
IdValidationViewModel
-addValidator(PropertyIdentifier propId, String friendlyName, Validator validator)
IdSimpleViewModel
IdValidationViewModel
ValidationManager
)A high-level UML class hierarchy
Some additional notes:
PropertyIdentifier
The following is an interface to allow for custom PropertyIdentifiers:
Here's a possible custom property identifier (concrete implementation):
Adding a new concept oriented property values and validation
Output of error:
The error says the Case significance must be the concept that is a (Capitalize first character concept) value and not the concept (Case insensitive).
To fix the validation error simply set property value to the concept record representing capitalize initial character concept (variable:
caseCapInitialConcept
).Output is the following:
The text was updated successfully, but these errors were encountered: