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 |
|