Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...You have made an incredible site which is truly a great help to me in solving problems. A tip of my hat to you!..."

Geography

Where in the world do Tek-Tips members come from?
ahaboub (TechnicalUser)
11 May 12 9:08

i need to know if there is anything wrong with this function, the variable "results" is always { } whatever is the searchstring...

CODE

public static void search(String wordName)
{
String searchString="";
searchString="(OTName : '*')";
LAPI_SEARCH search= new LAPI_SEARCH(session);
LLValue brokers= new LLValue();
LLValue broker= new LLValue();
LLValue selectList= new LLValue();
LLValue results= new LLValue();
LLValue result=new LLValue();
int brokerID=0;
int status= search.GetSearchBrokers(brokers);
if (status!=0)
{

}
else
{
for(int i=0; i<brokers.size(); i++)
{
broker=brokers.toValue(i);
//System.out.println(broker.toString());
if ((broker.toString("NodeName")).equals("Enterprise"))
{
brokerID=broker.toInteger("NodeID");
break;
}
}
if (brokerID > 0)
{
selectList.setList();
selectList.setSize(2);
selectList.setString(0,"OTName");
selectList.setString(1,"OTDataID");
if (search.ApplyQuery(brokerID, selectList, searchString, LAPI_SEARCH.SORTBYDEFAULT, "", 0, 100, "LivelinkQueryLanguage", results) !=0)
{
System.out.println("ApplyQuery Failed");
}
else
{
System.out.println("results: " + results.toString()); //always { }
for(int j=0;j<results.size();j++)
{
result=results.toValue(j);
System.out.println(result.toString("OTDataID") + " " + result.toString("OTName"));
}
}
}
}
}

Helpful Member!  appnair (Programmer)
11 May 12 12:35

YOU DO NOT HAVE OTOBJECT IN YOUR CODE I BELEIVE
//Set up the list of fields for ApplyQuery to return
//Note: OTObject must be in this list for ApplyQuery to work
vSelectList.add( "OTName" ); //Object Name
//vSelectList.add( "OTDataID" ); //The objects ID
vSelectList.add( "OTObject" );
vSelectList.add( "OTOwnerID" );
vSelectList.add("Attr_152278_35");

working code from my work

CODE

//Java Sample using ApplyQuery import com.opentext.api.*; public class ApplyQuery { //For Connection private static String Server = "localhost"; private static int Port = 2099; private static String DFT = ""; private static String User = "Admin"; private static String Pass = "Admin"; public static void main( String[] args ) { try { //variables LLSession session; LAPI_DOCUMENTS doc; LAPI_SEARCH search; int brokerID; //Constructors for session and search objects session = new LLSession (Server, Port, DFT, User, Pass); search = new LAPI_SEARCH (session); brokerID = GetSearchBroker(search, session); LLValue vListBrokers=new LLValue(); search.GetDisplayableFields(brokerID,vListBrokers); Search(brokerID, session, search); } catch ( Throwable e ) { System.err.println( e.getMessage() ); e.printStackTrace( System.err ); } } public static int GetSearchBroker(LAPI_SEARCH search, LLSession session) { //Returns the BrokerID for the Enterprise Slice LLValue vListBrokers, tmpAssoc; int length, brokerID; String nodeName, broker; broker = "Enterprise"; brokerID = -1; //Define the value objects vListBrokers = new LLValue(); //List of available brokers tmpAssoc = new LLValue(); //Temp Assoc // Retrieve the Search Brokers if (search.GetSearchBrokers(vListBrokers) != 0) { System.out.println("Failed to get Search Brokers"); sError(session); } else { //Find the Enterpise BrokerID length = vListBrokers.size(); for (int i=0; i<length; i++) { tmpAssoc = vListBrokers.toValue(i); nodeName = tmpAssoc.toString("NodeName"); System.out.println("Got this Broker"+nodeName ); if (nodeName.equals(broker)) { brokerID = tmpAssoc.toInteger("NodeID"); } } } return (brokerID); } public static void Search(int brokerID, LLSession session, LAPI_SEARCH search) { //Use Apply query to Search for a specified term //Variables LLValue vSelectList, vQueryResults, value; String where, fName; int length; //Define value objects vSelectList = new LLValue().setList(); vQueryResults = new LLValue(); value = new LLValue(); //Set up the list of fields for ApplyQuery to return //Note: OTObject must be in this list for ApplyQuery to work vSelectList.add( "OTName" ); //Object Name //vSelectList.add( "OTDataID" ); //The objects ID vSelectList.add( "OTObject" ); vSelectList.add( "OTOwnerID" ); vSelectList.add("Attr_152278_35"); //The objects VolumeID //Where clause which searches on the OTName region for the word "Livelink" //where = "(OTData :\"Livelink\")"; where = "(Attr_152278_35 :\"CUST DUMMY DOC #1\")"; //Search Livelink if ( search.ApplyQuery( brokerID, vSelectList, where, search.SORTBYDEFAULT, "OTName", 0, 100, "LivelinkQueryLanguage", vQueryResults) != 0) { System.out.println("Apply query failed"); sError(session); } else { //Displays the results of the search length = vQueryResults.size(); if (length > 0) { System.out.println("The query returned "+ length+" results"); for (int i=0; i<length; i++) { value = vQueryResults.toValue(i); fName = value.toString("OTName"); System.out.println(fName); } } } } private static void sError(LLSession session) { //Error Checking System.out.println("Status Code: " + session.getStatus()); System.out.println("Api Error: " + session.getApiError()); System.out.println("Error Message: " + session.getErrMsg()); System.out.println("Status Message: " + session.getStatusMessage()); } }

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
http://www.tek-tips.com/faqs.cfm?fid=2884
http://www.linkedin.com/in/appunair

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close