Home

Results 1 to 7 of 7

Thread: Local Variable as a Verb (or java api)?

Hybrid View

  1. #1
    Tobias Ljunggren NNTP User

    Local Variable as a Verb (or java api)?

    I need to access local variables as Verb and not a Noun. Is there any java api available that can do that?

    One good question to ask is; why on earth do you need that?

    If you have a GCV and expand the GCV using ~gcv~ (the Text noun). It will automatically expand all local variables inside that
    gcv as long as they are surrounded by $.

    When you work with a structured GCV that's not possible (not what I know). Instead I iterate the instances and store the GCV as
    a local variable using xpath. The noun Local Variable will not resolve other local variables inside that lv and $lv$ with Text
    noun won't either.

    My idea is to feed a verb with a noun (or use a java api) that will resolve those local variables but I haven't found any way to
    do that...


    Best regards,
    Tobias

  2. #2
    Join Date
    Jan 2009
    Location
    Stavanger, Norway
    Posts
    1,729

    Re: Local Variable as a Verb (or java api)?

    Tobias Ljunggren wrote:

    > If you have a GCV and expand the GCV using ~gcv~ (the Text noun). It will automatically expand all local variables inside that gcv as long as they are surrounded by $.


    Doesn't this happen only at driver startup? So the local variables also have to be available at that point? Sounds somewhat "chicken and the egg" to me. Do you have a trace of an example?

    > When you work with a structured GCV that's not possible (not what I know). Instead I iterate the instances and store the GCV as a local variable using xpath. The noun Local Variable will not resolve other local variables inside that lv and $lv$ with Text noun won't either.


    If I recall correctly, structured GCVs differ in their resolution by the engine depending on context. Ie if the caller expects the response as a node-set or as plain text. When you expand them as ~gcv~ I believe you just get the text and not the structure.

    > My idea is to feed a verb with a noun (or use a java api) that will resolve those local variables but I haven't found any way to do that...


    I'm sure such a java API exists, but it is almost certianly private and thus not recommended for use by us mere mortals.

  3. #3
    Tobias Ljunggren NNTP User

    Re: Local Variable as a Verb (or java api)?

    On 2015-06-30 12:12, Alex McHugh wrote:
    > Tobias Ljunggren wrote:
    >
    >> If you have a GCV and expand the GCV using ~gcv~ (the Text noun). It will automatically expand all local variables inside that gcv as long as they are surrounded by $.

    >
    > Doesn't this happen only at driver startup? So the local variables also have to be available at that point? Sounds somewhat "chicken and the egg" to me. Do you have a trace of an example?

    It happens run time, that's why it can be useful to have configurable expression (for instance describing parts of a naming
    convention or how displayName/fullName should be created):

    [06/30/15 13:19:38.188]:Account Services ST:Applying policy: %+C%14Cttt%-C.
    [06/30/15 13:19:38.188]:Account Services ST: Applying to sync #1.
    [06/30/15 13:19:38.188]:Account Services ST: Evaluating selection criteria for rule 'GCV & LV resolve test'.
    [06/30/15 13:19:38.189]:Account Services ST: Rule selected.
    [06/30/15 13:19:38.189]:Account Services ST: Applying rule 'GCV & LV resolve test'.
    [06/30/15 13:19:38.189]:Account Services ST: Action: do-set-local-variable("testLV",scope="policy","A test local variable").
    [06/30/15 13:19:38.189]:Account Services ST: arg-string("A test local variable")
    [06/30/15 13:19:38.189]:Account Services ST: token-text("A test local variable")
    [06/30/15 13:19:38.189]:Account Services ST: Arg Value: "A test local variable".
    [06/30/15 13:19:38.189]:Account Services ST: Action: do-trace-message("$testLV$").
    [06/30/15 13:19:38.189]:Account Services ST: arg-string("$testLV$")
    [06/30/15 13:19:38.189]:Account Services ST: token-text("$testLV$")
    [06/30/15 13:19:38.190]:Account Services ST: Expanded variable reference '$testLV$' to 'A test local variable'.
    [06/30/15 13:19:38.190]:Account Services ST: Arg Value: "A test local variable".
    [06/30/15 13:19:38.190]:Account Services ST:A test local variable
    [06/30/15 13:19:38.190]:Account Services ST:Policy returned:
    [06/30/15 13:19:38.190]:Account Services ST:

    and the rule for this is:
    <rule>
    <description>GCV &amp; LV resolve test</description>
    <conditions>
    <and/>
    </conditions>
    <actions>
    <do-set-local-variable name="testLV" scope="policy">
    <arg-string>
    <token-text xml:space="preserve">A test local variable</token-text>
    </arg-string>
    </do-set-local-variable>
    <do-trace-message>
    <arg-string>
    <token-text xml:space="preserve">~testGCV~</token-text>
    </arg-string>
    </do-trace-message>
    </actions>
    </rule>


    >
    >> When you work with a structured GCV that's not possible (not what I know). Instead I iterate the instances and store the GCV as a local variable using xpath. The noun Local Variable will not resolve other local variables inside that lv and $lv$ with Text noun won't either.

    >
    > If I recall correctly, structured GCVs differ in their resolution by the engine depending on context. Ie if the caller expects the response as a node-set or as plain text. When you expand them as ~gcv~ I believe you just get the text and not the structure.


    Exactly so if I want one specific instance of a structured GCV I have to use XPath to get it and store that in a local variable.

    >
    >> My idea is to feed a verb with a noun (or use a java api) that will resolve those local variables but I haven't found any way to do that...

    >
    > I'm sure such a java API exists, but it is almost certianly private and thus not recommended for use by us mere mortals.


    Yes, hypothetically I think that the noun for local variable is using the name to access the element within the policy where it
    is defined and then uses the arguments for that local variable. But that's only a rumor I heard...

    Best regards,
    Tobias


  4. #4
    Join Date
    Dec 2007
    Location
    Brooklyn, NY
    Posts
    6,213

    Re: Local Variable as a Verb (or java api)?

    >> If I recall correctly, structured GCVs differ in their resolution by
    >> the engine depending on context. Ie if the caller expects the response
    >> as a node-set or as plain text. When you expand them as ~gcv~ I
    >> believe you just get the text and not the structure.


    Values as text, separated by the specified separator. Which you would
    then have to substring to get what you want.

    > Exactly so if I want one specific instance of a structured GCV I have to
    > use XPath to get it and store that in a local variable.


    If you get the nodeset version, you have better control with XPATH.

    >>> My idea is to feed a verb with a noun (or use a java api) that will
    >>> resolve those local variables but I haven't found any way to do that...

    >>
    >> I'm sure such a java API exists, but it is almost certianly private
    >> and thus not recommended for use by us mere mortals.


    You can use the Text() token, with $Varname$ as a value to build you new
    variable value and use that later?


    > Yes, hypothetically I think that the noun for local variable is using
    > the name to access the element within the policy where it is defined and
    > then uses the arguments for that local variable. But that's only a rumor
    > I heard...


    Can you give an example of what you are trying to do with this replacement?




  5. #5
    Tobias Ljunggren NNTP User

    Re: Local Variable as a Verb (or java api)?

    On 2015-06-30 14:23, Geoffrey Carman wrote:
    >
    > Can you give an example of what you are trying to do with this replacement?


    One example is building fullName. Assume that you always have the local variables givenName, sn and middleName available in the
    policy. If you use a GCV as expression that GCV can vary from one implementation to another but the policy stays the same.
    Exmaple of that GCV can be:
    $lastName$, $sn$
    $lastName$, $middleName$ $sn$
    $firstName$ $lastName$
    ....

    The reason for having that as a structured GCV is have different expressions for different kind of users and you don't want to
    limit that by the GCV's itself. Just create a new instance that defines how you can distinguish the users and the different
    options/expressions that applies to those users.

    Best regards,
    Tobias


  6. #6
    Tobias Ljunggren NNTP User

    Re: Local Variable as a Verb (or java api)?

    On 2015-06-30 14:23, Geoffrey Carman wrote:
    >>> If I recall correctly, structured GCVs differ in their resolution by
    >>> the engine depending on context. Ie if the caller expects the response
    >>> as a node-set or as plain text. When you expand them as ~gcv~ I
    >>> believe you just get the text and not the structure.

    >
    > Values as text, separated by the specified separator. Which you would then have to substring to get what you want.
    >
    >> Exactly so if I want one specific instance of a structured GCV I have to
    >> use XPath to get it and store that in a local variable.

    >
    > If you get the nodeset version, you have better control with XPATH.
    >
    >>>> My idea is to feed a verb with a noun (or use a java api) that will
    >>>> resolve those local variables but I haven't found any way to do that...
    >>>
    >>> I'm sure such a java API exists, but it is almost certianly private
    >>> and thus not recommended for use by us mere mortals.

    >
    > You can use the Text() token, with $Varname$ as a value to build you new variable value and use that later?


    If you have a GCV that contains local variables the only way to expand those is to use Text(~GCV~). With structured GCV's there
    are two options; either iterate the instances and set a local variable for each value (gcv within the instance). Once you have
    done that there is no way to expand local variables.
    The other option is to iterate and keep track of a instance counter and use the GCV as is (the GCV for the whole structure) and
    use regex to extract the right part depending on what you want and the instance counter. This works but will create a more
    static policy that will only work for the number of instances you have created regex for and only as long as the structured GCV
    doesn't change.

    I'm looking for a way to solve this in a more configurable and dynamic way :-)

    Best regards,
    Tobias


  7. #7

    Re: Local Variable as a Verb (or java api)?

    Tobias Ljunggren wrote:

    Your trace and the rule to not match: "$testLV$" != "~testGCV~"

    > It happens run time

    ....
    > [06/30/15 13:19:38.189]:Account Services ST: Action:

    do-trace-message("$testLV$").
    > [06/30/15 13:19:38.189]:Account Services ST: arg-string("$testLV$")
    > [06/30/15 13:19:38.189]:Account Services ST: token-text("$testLV$")
    > [06/30/15 13:19:38.190]:Account Services ST: Expanded variable

    reference '$testLV$' to 'A test local variable'.
    ....
    > <do-trace-message>
    > <arg-string>
    > <token-text xml:space="preserve">~testGCV~</token-text>


    ~GCV~ is resolved only once at driver start time in a textual search/replace
    manner. $var$ (in supported tokens) and $var (in xpath) are resolved at
    runtime. $GCV$ is resolved at runtime as well, though I cannot see what it's
    good for except wasting CPU cycles and adding useless lines to trace...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •