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!

Retrieving category value

Status
Not open for further replies.

matasa

Programmer
Jan 29, 2009
13
US
Hi everybody,
I'm trying to retrieve category values from a livelink object and I'm affraid I don't get the correct result, so I'm asking you a bit of help.

I get the results from GetObjectAttributesEx, then I list each category field with AttrListNames.
At this point all look fine, I'm able to see the list of keys from the category. But when I try to retrieve the values matching the keys I do not get the correct data: this final step is done using AttrGetValues.

I've past the corresponding code below just in case. Thanks in advance for your help.


Code:
   // input as integer:  oid and vcategoryid
   int status;

    LLValue attrValuePath = (new LLValue()).setAssocNotSet();
    LLValue attrValues = (new LLValue()).setList();
    LLValue attrValues2= (new LLValue()).setList();  
    LLValue objID = (new LLValue()).setAssocNotSet();
    LLValue catVersion2 = (new LLValue()).setAssocNotSet(); 
    LLValue catID= (new LLValue()).setAssocNotSet();
    LLValue catVersion = new LLValue();
    LAPI_ATTRIBUTES attr= new LAPI_ATTRIBUTES(session);
  
    objID.add("ID", oid);

    catID.add("ID", vcategoryid ); 
    catID.add("Version", 0);
 
    if (doc.FetchCategoryVersion(catID, catVersion) != 0)
    { 
      // display error 
      return 0;
    }

    status = doc.GetObjectAttributesEx(objID,catID,catVersion2);
    // test status ... 
    status = attr.AttrListNames(catVersion,attrValuePath,attrValues2);
    // test status ...
   
   for(int k = 0; k < attrValues2.size(); k++) 
   {
     String currfield = attrValues2.toValue(k).toString();
     status = attr.AttrGetValues(catVersion, currfield, attr.ATTR_DATAVALUES, attrValuePath, attrValues);
     System.out.println(currfield + "=" +  attrValues.toValue(0).toString());
   }

...
 
I am not sure about this but the documentation says that the AttrListNames should be used only if there is a "set" category in your category definition.Is that the case here.

Also to look at the values use the function called PrintTypeTree which is actually a very good way to understand the datatsructure.I rarely use the for loop method.
Code:
Code was written by Glenn Heyin,Sprint

private static void printTypeTree(LLValue inVal, String szSep, String szName) {
			System.out.println(szSep + szName + " - " + printLLValueType(inVal.type()) + "\t" + printLLValue(inVal));
			if(inVal.type() == LLValue.LL_ASSOC ||
					inVal.type() == LLValue.LL_RECORD ||
					inVal.type() == LLValue.LL_TABLE) {
				LLNameEnumeration enumValue;
				enumValue = inVal.enumerateNames();
				while(enumValue.hasMoreElements()) {
					String elValue = enumValue.nextElement().toString();
					printTypeTree(inVal.toValue(elValue), "\t" + szSep, elValue);
				}
			}
			else {
				if(inVal.type() == LLValue.LL_LIST) {
					for(int i = 0; i < inVal.size(); i++) {
						printTypeTree(inVal.toValue(i), "\t" + szSep, "" + i);
					}
				}
			}
		}

		private static String printLLValue(LLValue llVal)
		{
			String returnString = "";

			switch (llVal.type()) {
			case LLValue.LL_BOOLEAN :
				returnString = "" + llVal.toBoolean();
				break;
			case LLValue.LL_DATE :
				returnString = llVal.toDate().toString();
				break;
			case LLValue.LL_DOUBLE :
				returnString = "" + llVal.toDouble();
				break;
			case LLValue.LL_INTEGER :
				returnString = "" + llVal.toInteger();
				break;
			case LLValue.LL_STRING :
				returnString = llVal.toString();
				break;
			default :
				break;
			}
			return returnString;
		}

		private static String printLLValueType(int iType) {
			String returnString = " ";
			switch (iType) {
			case LLValue.LL_ASSOC :
				returnString = "Type is ASSOC";
				break;
			case LLValue.LL_BOOLEAN :
				returnString = "Type is BOOLEAN";
				break;
			case LLValue.LL_DATE :
				returnString = "Type is DATE";
				break;
			case LLValue.LL_DOUBLE :
				returnString = "Type is DOUBLE";
				break;
			case LLValue.LL_ERROR :
				returnString = "Type is ERROR";
				break;
			case LLValue.LL_INTEGER :
				returnString = "Type is INTEGER";
				break;
			case LLValue.LL_LIST :
				returnString = "Type is LIST";
				break;
			case LLValue.LL_NOTSET :
				returnString = "Type is NOTSET";
				break;
			case LLValue.LL_RECORD :
				returnString = "Type is RECORD";
				break;
			case LLValue.LL_STRING :
				returnString = "Type is STRING";
				break;
			case LLValue.LL_TABLE :
				returnString = "Type is TABLE";
				break;
			case LLValue.LL_UNDEFINED :
				returnString = "Type is UNDEFINED";
				break;
			default :
				returnString = "Type is Unknown";
				break;
			}
			return returnString;
		}//helper method ends

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
 
Thanks Appu,
Actually, AttrListNames give the correct list of category "keys" and I can replace this loop by a specific existing key e.g I have a field "version" in my category, so I try the following but did not get the expected string back in attrValues.

Code:
status = attr.AttrGetValues(catVersion, "version", attr.ATTR_DATAVALUES, attrValuePath, attrValues);

I tried this very useful code, thanks for the tip and I can see the whole content of GetObjectAttributesEx resulting data, so I have to figure how to find my own data in there :)

A.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top