> For anyone interested (part 2 of 2)...
> 
> Secondary response from support (it doesn't error as before):
> 
> Sample API program that works for me.. customer will need to change
> the details marked with a " <------" for his test..
> 
> import com.bmc.arsys.api.*;
> import java.util.*;
> 
> public class JavaAPITest {
> private ARServerUser server;
> private String formName= "Roles";     <------
> 
> public JavaAPITest() {
>    server = new ARServerUser();
>    server.setServer("atlwin01");                <------
>    server.setPort(0);                           <------
>    server.setUser("Demo");                       <------
>    server.setPassword("");                         <------
>    }
> 
> public static void main(String[] args) {
>    JavaAPITest test = new JavaAPITest();
>    test.connect();
>    test.queryEntrysByQual("( \'Create Date\' > \"1/1/2009\" )");
>    test.queryEntrysByQual("( \'1702\' = -1210 )");
> <------
>    test.cleanup();
>    }
> 
> //
> // Connect the current user to the server.
> //
> void connect() {
>    System.out.println();
>    System.out.println("Connecting to AR Server...");
>    try {
>       server.verifyUser();
>       }
>    catch (ARException e) {
>       //
>       //This exception is triggered by a bad server, password or,
>       //if guest access is turned off, by an unknown username.
>       //
>       ARExceptionHandler(e, "Cannot verify user " + server.getUser() +
> ".");
>       System.exit(1);
>       }
>    System.out.println("Connected to AR Server " +
>    server.getServer());
>    }
> 
> //
> // Retrieve entries from the form using the given qualification. With
> // the returned entry set, print out the ID of each entry and the //
> contents in its shortDescription field.
> //
> void queryEntrysByQual(String qualStr) {
>    System.out.println();
>    System.out.println ("Retrieving entryies with qualification " +
> qualStr);
> 
>    try {
>       // Retrieve the detail info of all fields from the form.
>       List <Field> fields = server.getListFieldObjects(formName);
> 
>       // Create the search qualifier.
>       QualifierInfo qual = server.parseQualification(qualStr, fields,
> null, Constants.AR_QUALCONTEXT_DEFAULT);
>       int[] fieldIds = {2, 7, 8};
>       OutputInteger nMatches = new OutputInteger();
>       List<SortInfo> sortOrder = new ArrayList<SortInfo>();
>       sortOrder.add(new SortInfo(2, Constants.AR_SORT_DESCENDING));
> 
>       // Retrieve entries from the form using the given
>       // qualification.
>       List<Entry> entryList = server.getListEntryObjects(formName,
> qual, 0, Constants.AR_NO_MAX_LIST_RETRIEVE, sortOrder, fieldIds, true,
> nMatches);
>       System.out.println ("Query returned " + nMatches + " matches.");
>       
>       if( nMatches.intValue() > 0){
>          // Print out the matches.
>          System.out.println("Request Id " + "Short Description" );
>          for( int i = 0; i < entryList.size(); i++ ){
>             System.out.println (entryList.get(i).getEntryId() + " " +
> entryList.get(i).get(Constants.AR_CORE_SHORT_DESCRIPTION));
>             }
>          }
>       } 
>    
>    catch( ARException e ) {
>       ARExceptionHandler(e, "Problem while querying by qualifier. ");
>       }
>    }
> 
> public void ARExceptionHandler(ARException e, String errMessage){
> System.out.println(errMessage);
> printStatusList(server.getLastStatus());
> System.out.print("Stack Trace:");
> e.printStackTrace();
> }
> 
> public void printStatusList(List<StatusInfo> statusList) { if
> (statusList == null || statusList.size()==0) {
> System.out.println("Status List is empty."); return; }
> 
> System.out.print("Message type: ");
> switch(statusList.get(0).getMessageType())
> {
> case Constants.AR_RETURN_OK:
> System.out.println("Note");
> break;
> case Constants.AR_RETURN_WARNING:
> System.out.println("Warning");
> break;
> case Constants.AR_RETURN_ERROR:
> System.out.println("Error");
> break;
> case Constants.AR_RETURN_FATAL:
> System.out.println("Fatal Error");
> break;
> default:
> System.out.println("Unknown (" +
> statusList.get(0).getMessageType() + ")"); break; }
> System.out.println("Status List:"); for (int i=0; i <
> statusList.size(); i++) {
> System.out.println(statusList.get(i).getMessageText());
> System.out.println(statusList.get(i).getAppendedText());
> }
> }
> 
> 
> public void cleanup() {
> // Logout the user from the server. This releases the resource //
> allocated on the server for the user.
> server.logout();
> System.out.println();
> System.out.println("User logged out.");
> }
> }
> 

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
Platinum Sponsor:[email protected] ARSlist: "Where the Answers Are"

Reply via email to