I presume you mean recursive rather than iterative.  All recursion can be
expressed as iteration but sometimes (and this is an example) it is simpler
to be recursive.
 
I forward an email on the subject originally in reply to LJ Longwing.  Note
that this "code" is NOT java!
 
From: Action Request System discussion list(ARSList) [mailto:
<mailto:arslist@ARSLIST.ORG> arsl...@arslist.org] On Behalf Of Ben Chernys
Sent: Friday, January 25, 2008 1:38 PM
To:  <mailto:arslist@ARSLIST.ORG> arslist@ARSLIST.ORG
Subject: Re: Java 7.1 API Assistance
 
This is non-trivial.  I have described my function on the list in the past
but cannot find that post (perhaps in an archive?).  I use it in a binary
that "dumps" an ARS server's workflow and table structures into an ASCII
file that I can then search in an editor.
 
>From the function pre-amble:
 
// builds a text string from an AR Qualifier Struct
ArdUtErr
ArdQualDecode (                   // decodes a qualifier structure
  ArdSch              * pS,       // a loaded schema
  ArdSch              * pSc,      // the "current" schema
  ARQualifierStruct   * pQ,       // returned string must be freed
  char              * * vTgt      //   by caller and can be used
              )                   //   in ARLoadARQualifierStruct()
  // this is pretty recursive.
  // first, the structure of pQ:
  //        op
  //          left, right       (two new, same structs)
  //          not               (one more same struct)
  //          relopstruct       (a simpler field / value struct)
  // so how do we do it?
  //   we will always produce a string something like
  //     ( ?? AND ?? )  or
  //     ( ?? OR ?? )   or
  //     ( NOT ?? )     or
  //     ( A <= B )
  // the ?? is returned by a recursive call to this routine
 
 
The gist of the main switch in the function
...
  switch (pQ->operation) {
    case AR_COND_OP_AND:
    case AR_COND_OP_OR:
      ArdQualDecode(pS, pSc, pQ->u.andor.operandLeft,  & wP1);
      ArdQualDecode(pS, pSc, pQ->u.andor.operandRight, & wP2);
      // combine "( wP1 and/or wP2 )"
    case AR_COND_OP_NOT:
      ArdQualDecode(pS, pSc, pQ->u.not, & wP1);
      // combine "( not wP1 )"
    case AR_COND_OP_REL_OP:
      // make "( a relop b )"
    }
...
 

  _____  

From: Action Request System discussion list(ARSList)
[mailto:arsl...@arslist.org] On Behalf Of LJ Longwing
Sent: October 27, 2009 4:15 PM
To: arslist@ARSLIST.ORG
Subject: Re: Java API for ARS - How to obtain a Run-If line from an Active
Link (for example)


** 
Wow...ask a tough one....ok....took me FOREVER to figure out
Qualifiers....but here is basically what you need to do.  
 
A QualifierInfo object has three main parts, LeftOperand, Operation, and
RightOperand.  To explain these parts I will give you an example
 
('Status' = "Fixed") AND ('Create Date' < $DATE$)
 
Ok, if that is your QualifierInfo object, here are your pieces
 
LeftOperand = ('Status' = "Fixed")
Operation = AND
RightOperand = ('Create Date' < $DATE$)
 
So, what I have done in several programs now is to write an iterative
subroutine, if you check the operation to determine if it is a relational
operation (< > = != etc).  If it's not, I throw RightOperand back into the
sub till it is, If it is then you know you are down to a single operand, and
then you can parse the field/value on left and right for what you want to
check/test for.
Please let me know if this helps any....it's still a bit fuzzy in my head,
but I understand it well enough as it is to do what I need to do.

  _____  

From: Action Request System discussion list(ARSList)
[mailto:arsl...@arslist.org] On Behalf Of David Morgan
Sent: Tuesday, October 27, 2009 8:33 AM
To: arslist@ARSLIST.ORG
Subject: Java API for ARS - How to obtain a Run-If line from an Active Link
(for example)


** 

Hi ARSListers, 

 

I have been looking at the Java API but am stumped by Qualifiers. 

 

String name1 = "Demo";

String swd = "etno";

String sname = "dclha002";

Integer tcpport = 8001;

Integer rpcnum = 0;

 

 

ARServerUser context=new ARServerUser(name1,swd,"",sname, tcpport);

// Check and verify user login:

 try {

       // If User Pass/Acct name is wrong, this gens an error.

       context.login();

 

     } catch( ARException e ) {

       System.out.println( "Login Error : " + " Possible Bad password or
acct name. " );

       //This return ends all further processing and exits...

        return;

     }

List<ActiveLink> aLinkObjs=context.getListActiveLinkObjects("AST:WorkLog");

int x = 0;

for (int i = 0; i < aLinkObjs.size(); i++) {

    System.out.format("\n%20s%60s\n\n", i, aLinkObjs.get(i).getName());

    //ActiveLink alink = aLinkObjs.get(x);

    

            try{

                QualifierInfo encryptedQual =
aLinkObjs.get(i).getQualifier();

                System.out.println(encryptedQual.toString() );

                RelationalOperationInfo qualEnglish =
encryptedQual.getRelationalOperationInfo();

                

                System.out.println("Qual : "+ qualEnglish.toString());

            } catch (Exception e){

                System.out.println("no Qualification\n");

            }

 

    

    if (aLinkObjs.get(i).toString().contentEquals("ASI:AWL:Close_100") ) {

        x = i ;

       // System.out.println(x);

    }

}

context.logout();

}

 

I can get the names of the Active links associated with the named form (in
this example I used AST:WorkLog)

But I cannot seem to decode the Qualifier. All I get from the output is :-

 

                   1
SHR:SHR:Help_003_CheckOnlineHelpInstall_E

 

[Operation=4,Operand Left=[Operation=2,Operand Left=[Operand
Type=[type=2],Operand=$LASTCOUNT$],Operand Right=[Operand
Type=[type=2],Operand=0]],Operand Right=<null>]

Qual : [Operation=2,Operand Left=[Operand
Type=[type=2],Operand=$LASTCOUNT$],Operand Right=[Operand
Type=[type=2],Operand=0]]

I just need some help in decoding the Qualifier. Anyone got any ideas?
Thanks in advance!!

 

David Morgan

Senior Technical Consultant

 

Tiberone Technologies Limited

Golden Cross House

8 Duncannon Street

London WC2N 4JF

Ph: +44 (0) 207 484 5069

Fax: +44 (0) 870 8310 381

Mob: +44 (0) 7876 450102

 <http://www.tiberone.com/> www.tiberone.com

 

_Platinum Sponsor: rmisoluti...@verizon.net ARSlist: "Where the Answers
Are"_ _Platinum Sponsor: rmisoluti...@verizon.net ARSlist: "Where the
Answers Are"_ 

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
Platinum Sponsor:rmisoluti...@verizon.net ARSlist: "Where the Answers Are"

Reply via email to