Skip to content

Docs/master/add/midpoint functions list#499

Open
edison23 wants to merge 2 commits intomasterfrom
docs/master/add/midpoint-functions-list
Open

Docs/master/add/midpoint functions list#499
edison23 wants to merge 2 commits intomasterfrom
docs/master/add/midpoint-functions-list

Conversation

@edison23
Copy link
Copy Markdown
Contributor

This PR adds the list of midPoint functions. Please kindly review and fact-check, especially the following:

  • The placement in the Docs hierarchy.
  • Intro parahraphs & info.

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

Copy link
Copy Markdown
Contributor

@licehammer licehammer left a comment

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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]*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is "applying all relevant policies and mappings." necessary here?

Comment on lines +210 to +214
|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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo "objbect"

|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.)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 */ }`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you sure it's not midPoint query language?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants