-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow modifying arrays more specifically #129
Comments
Makes sense indeed. It may not be super easy to implement though, as we have different types of arrays (explicit RDF lists, multiple predicate values). |
Having had a look, arrays definitely seem quite feasible. The elements get concatenated immediately through the One issue will potentially be the verbosity when there are several steps that you want to take. E.g., remove element A, insert element B before X, and replace another field of the same object with something else. Preferably 1 Override could do all this at once, so users don't have to create 2-3 Overrides to change 1 object, with these Overrides then also targeting each other as only 1 can target the main resource. Will look into that. |
I've had a look at how this could look in practice, taking the above considerations into account. Below is what I'm currently thinking of. As this would introduce several variations of what you can do with an Override, I'm thinking of deprecating the These objects would make use of the parameters
This could result in, for example, the following Override: {
"@id": "ex:myObjectOverride",
"@type": "Override",
"overrideInstance": { "@id": "ex:myClassInstance" },
"overrideSteps": [
{
"@type": "OverrideMapEntry"
"overrideParameter": { "@id": "MyClass:_mapParameter" },
"overrideTarget": "mapKey"
"overrideValue": "newMapValue"
},
{
"@type": "OverrideListInsertBefore",
"overrideParameter": { "@id": "MyClass:_listParameter" },
"overrideTarget": { "@id": "idOfElementAlreadyInList" },
"overrideValue": { "@id": "idOfNewElementToPutInListBeforeTheOtherOne" }
}
]
} Object This seems like a good way to extend Overrides with these new features while minimizing verbosity and also not introducing too many new keywords. It also allows for easily adding new Override types in the future. One big disadvantage is that you can't use type scoping for the parameters in As mentioned, I would deprecate the {
"@id": "ex:myObjectOverride",
"@type": "Override",
"overrideInstance": { "@id": "ex:myHelloWorldWithOverride" },
"overrideParameters": {
"@type": "ex:GreetingsWorld",
"greetings:say": "GREETINGS WORLD!"
}
} would become {
"@id": "ex:myObjectOverride",
"@type": "Override",
"overrideInstance": { "@id": "ex:myHelloWorldWithOverride" },
"overrideSteps": [
{
"@type": "OverrideParameters",
"overrideValue": {
"@type": "ex:GreetingsWorld",
"greetings:say": "GREETINGS WORLD!"
}
}
]
} All of this assuming that it is feasible to support this, but my experience with the initial Override implementation and the feasibility check I did above makes me think this would work. I'm also not sure if |
Your approach sounds very reasonable to me! Some minor thoughts:
But I certainly like the fact that we can define different types of overriding with this approach. |
I was planning to just note in the documentation that this still works, but is not really recommended, just because it's a bit inconsistent to have 1 separate solution for this specific type of override. And perhaps even log a warning. Could also not do that, but I thought it might be confusing if there are 2 ways to do this. |
Issue type:
Description:
The idea is to extend the override functionality to somehow allow more flexibility when extending arrays from different configurations. I was thinking of adding another field to an
Override
object that indicates how array elements should be added to an existing array. Features I was thinking of:Not sure yet how feasible it would be to add these as I haven't looked at the array code yet. I will probably look soon at a potential implementation (or decide to give up if the complexity would be too high).
The text was updated successfully, but these errors were encountered: