Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attach a cateogry to document using JAVA API's 1

Status
Not open for further replies.

Adilp

Programmer
Mar 15, 2005
2
US
Dear Friends,

First of all i am very new to Livelink Application.

I am trying to attach a category to the document using java API's. I created a document object and an category object but i can not find any methods to attach a category to the document.
any help is appreciated.

Secondly can someone please tell me if there are any good livelink books for programmers in market. i tried to look on net but i could not find any.

Thank you in Advance ,

Adi.
 
the best source for livelink api is opentext knowledge base where you will meet a lot of experienced livelink programmers.I say livelink because the API expects you to know the idiosyncracies of livelink to a good extent.Some other resources are most of the LAPI samples there were written by me.I try to be as informative in my coding as I can.The yahoo group livelinkteam@yahoo.com can be a good source also.Greg is planning a book.Here's a simple code for Adding Document With Category,If you prefer the source file itself plese drop me a mail at appnair at gmail dot com.This code is for
educational purposes only all the stuff is hardcoded.In production you may want to read the documentation itself.
Code:
Listing of ADWC.java
import java.util.*;//for our date manip
import java.io.*;
import com.opentext.api.*;	//import LAPI objects

public class ADWC
{

private static String Server = "localhost"; //livelink host
private static int Port = 2099; //livelink server port see opentext.ini
private static String DFT = ""; //default database file or schema
private static String User = "Admin"; //username
private static String Pass = "Admin"; //passwd
public static void main (String args[])
{

	LLSession session;
    LAPI_DOCUMENTS doc;
	session = new LLSession (Server, Port, DFT, User, Pass);
    doc = new LAPI_DOCUMENTS (session);
    LAPI_ATTRIBUTES attr = new LAPI_ATTRIBUTES(session);
  //Grab some value objects
	LLValue entInfo = (new LLValue()).setAssocNotSet();
	LLValue createInfo = (new LLValue()).setAssocNotSet();
	LLValue objectInfo = (new LLValue()).setAssocNotSet();
	LLValue versionInfo = (new LLValue()).setAssocNotSet();
	//Category stuff
	LLValue catID = (new LLValue()).setAssocNotSet();
	LLValue catVersion = new LLValue();
	LLValue attrValues = new LLValue().setList();
	LLValue	attrValPath = new LLValue();
	LLValue categories = new LLValue().setList();
	LLValue cRequest = new LLValue().setAssoc();
	LLValue extData = new LLValue().setAssoc();
	int volumeID;
	int objectID;
		if(doc.AccessEnterpriseWS(entInfo) != 0)
		{
			System.out.println("AccessEnterpriseWS Failed.");
						return;
		}
		  //Show that we got the volumeID and objectID for the EnterpriseWS

			volumeID = entInfo.toInteger("VolumeID");
			objectID = entInfo.toInteger("ID");
			System.out.println("Volume"+volumeID+"ObjID"+objectID);

			//Setup catID, hardcode the categories objectID
			//19280 is the objID of my category called
			//test and it is at version 1
			//Populate the LLValue Object catID with that
			catID.add("ID", 19280);
	        catID.add("Version", 0);
	       //Use the catID to fetch the category Version
		   	if (doc.FetchCategoryVersion(catID, catVersion) != 0)
		   	{
		   		System.out.println("None of that category mate");
		   			   		return;
		   	}

		   	//Add the values to attrValues to be in the attribute
		   	//I have a text attribute called Test that will take
		   	//clear text trash
		   	//I guess if I had a date i would have to set it with a date
		   	//I cannot get both the attributes updated for some reason

		   Date myDate=new Date();//get system date to update this para

           attrValues.add(myDate);

		  	if (attr.AttrSetValues(catVersion, "Test Date", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
					   	{
					   		System.out.println("AttrSetValues Failed.");

					   		return;
		   	}

	        // attrValues.add("This is a test");
		 //  	if (attr.AttrSetValues(catVersion, "Test", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
		   //	{
		   	//	System.out.println("AttrSetValues Failed.");

		   	//	return;
		   //	}



		   	//Add category Version Assoc to categories List
		   	categories.add( catVersion );

		   	//Fill createInfo to spec (see documentation for the structure)
		   	cRequest.add("Comment", "");
		   	createInfo.add("request", cRequest);
		   	createInfo.add("extendedData", extData);
		   	createInfo.add("Categories", categories);


		   	//Create document in enterpriseWS
		   	if(doc.CreateObjectEx(volumeID, objectID, doc.OBJECTTYPE,
		   			doc.DOCUMENTSUBTYPE, "PSMELLO's Docs", createInfo, objectInfo) != 0)
		   	{
		   		System.out.println("CreateObjectEx Failed.");

		   		return;
		   	}
		   	else
		   		System.out.println("Document created successfully");

		   	//Set objectID to objectID of the new document
		   	objectID = objectInfo.toInteger("ID");

		   	//Now upload version to complete document creation
		   	//if this file is not there io errors will happen
		   	if(doc.CreateVersion(volumeID, objectID, "c:\\development\\test.txt", versionInfo) != 0)
		   	{
		   		System.out.println("CreateVersion Failed.");
		   		return;
		   	}
		   	else
		   	{
		   		System.out.println("Version created successfully");

		   	}


}
}

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Thank you so much ,

It worked at first Shot. Thank you once again.

I was even able to add Values for multiple attributes in a category.

Thank you Once again.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top