Conversation
licehammer
left a comment
There was a problem hiding this comment.
In addition to inline comments, we should address the following:
- Many methods have optional parameters or have different parameters (e.g. fing by OID or find by name). Wouldn't be better to not have new row for each variant and rather group them together somehow? At lease in some cases?
- Make room for examples. Even when we don't have them now, we need to add them.
- Eventually we need to figure out how to group the methods. Some of them are easy to use and other require deep understanding (e.g. references prism objects)
| = MidPoint standard functions | ||
| :page-nav-title: Standard functions | ||
|
|
||
| The `MidpointFunctions` interface defines the built‑in functions that are automatically available to every midPoint expression, script, and mapping. |
There was a problem hiding this comment.
It's available only in scripts. Technically, scripts are one option for defining expression. Mappings can contain many types of expression where you can use scripts.
| All functions are public members of the interface; | ||
| they can be invoked directly from an expression code (e.g., Groovy, JavaScript, etc.) without importing any additional classes. | ||
|
|
||
| *The functions are available in link:https://github.com/Evolveum/midpoint/blob/master/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java[MidpointFunctions.java]* |
There was a problem hiding this comment.
We should put a note that people should select proper code version in GitHub or figure out a way to modify the link automatically based on a version.
| |resolveReference | ||
| |ObjectReferenceType reference | ||
| |T | ||
| |Resolves a reference to an object. Throws an exception if the reference is not found. |
There was a problem hiding this comment.
It's ObjectNotFoundException
| |addObject | ||
| |PrismObject<T> newObject, ModelExecuteOptions options | ||
| |String | ||
| |Adds a new object (prism) using the supplied options; returns the created object's OID. |
There was a problem hiding this comment.
I don't like the ambiguity of "add" and "create". Any idea how to fix it?
| |recompute | ||
| |Class<F> type, String oid | ||
| |void | ||
| |Recomputes a focal object (focus) identified by OID, applying all relevant policies and mappings. |
There was a problem hiding this comment.
Is "applying all relevant policies and mappings." necessary here?
| |Retrieves an organization object by its name. | ||
| |getParentOrgs | ||
| |ObjectType object, String relation, String orgType | ||
| |Collection<OrgType> | ||
| |Returns parent orgs of the specified object that have a specific relation and orgType. |
There was a problem hiding this comment.
Consistency would be nice. Why use once "retrieves" and then "returns"? Unless there is a reason, it's just harder to read.
| |isDirectlyAssigned | ||
| |ObjectType target | ||
| |boolean | ||
| |Returns `true` if objbect is directly assigned to the supplied target object. |
| |isDirectlyAssigned | ||
| |FocusType focus, String targetOid | ||
| |boolean | ||
| |Returns `true` if `focus` has a `assignment` with `targetRef.OID` being equal to `targetOid`. No other conditions are checked (e.g. validity, assignment condition, lifecycle states, etc.) |
There was a problem hiding this comment.
The fact that no other conditions are checked are true for other variants of this method.
| |isEvaluateNew | ||
| | | ||
| |Boolean | ||
| |A stateful flag that tells a script whether it is currently handling a new value—one that will be written to the target object (e.g., values from the add/replace sections of an `ObjectDelta` or recomputed values slated for persistence)—or an old value—one that is being removed or read from the existing object (e.g., values from the delete section). It returns `true` for new, `false` for old, and `null` when the framework cannot determine the distinction or the context does not apply. The method never throws; it reflects the evaluation mode of the active script execution, and can be used in mapping or provisioning scripts to branch logic based on whether the processed data will become part of the target or be discarded. A usage may be: `if (midpoint.isEvaluateNew()) { /* prepare new value */ } else { /* handle old value */ }`. |
There was a problem hiding this comment.
"The method never throws" - you probably want to say it never throws an exception
| |queryFor | ||
| |Class<T> type, String query | ||
| |TypedQuery<T> | ||
| |Creates a typed query object for the given JPQL‑like query string. |
There was a problem hiding this comment.
Are you sure it's not midPoint query language?
This PR adds the list of midPoint functions. Please kindly review and fact-check, especially the following:
Checking the descriptions of the functions could unravel some misunderstandings as well but I realize it's a lot of functions…
There are some functions without documentation strings, here's the bug for that: https://support.evolveum.com/wp/11091
Note 1: I put there a link to the .java file on GH. It makes sense to me to link the head of the particular branch (in this case, master). The other option I see is to permalink the particular point in time
Note 2: After we clear for publish this one, I will cherry-pick it into the other branches, 4.10 equals master, 4.9 is mostly the same as well, 4.8 has more differences but still manageable, I think.
Thanks