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!

createInfo parameter of CreateObjectEx

Status
Not open for further replies.

ceverett99

Programmer
Sep 17, 2003
2
US
Does anyone have a working code snippet that uses CreateObjectEx and CreateVersion to add a document that also contains category data? I'm having real problems with my createInfo parameter. I can't seem to get the category information in there in a way that doesn't cause an error.

Craig
 
Sometime back a user psmello asked for this and I hastily rigged up some code to do this.Hope this helps.Unfortunately you have to read the comments also and it is for lapi java.Replace the category stuff with your correct stuff and re-complile
Code:
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");

		   	}


}
}

Freedom is not worth having if it does not include the freedom to make mistakes.
Mahatma Gandhi

appnair

 
Thanks. It's a little tricky converting this to VB (the functions are not exactly the same). Also, how did you know that the objectID for your "test" category was 19280? Is there a way to query that value?

Craig
 
then you should probably contact psmello
psmello@adelphia.net .I beleive he was doing this in VB.I provided the idea only.finding whether or not it is a category is easy.I did that because I had access to the categories volume since I am the admin.In any case you do this sql
Code:
select * from dtree were subtye=131
.This should give you all the category objects in your database and the dataid is the category object.The two postings below should give you VB code as well as a lot of explanation how it ties all together
The best




Freedom is not worth having if it does not include the freedom to make mistakes.
Mahatma Gandhi

appnair
 
sorry for typo earlier
Code:
select * from dtree were subtype=131

Freedom is not worth having if it does not include the freedom to make mistakes.
Mahatma Gandhi

appnair

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top