cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving attributevalues from a taxonomy table of a specific record

Former Member
0 Kudos

Hello MDM Gurus,

I'm having a problem using the Java API for retrieving the attributevalues of a taxonomy table for a specific record. Can anyone tell me how to do it?

With kind regards,

Gerwin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Gerwin,

Can you be more specific? Do you mean to retrieve the linked attributes for a specific record in the main table, or do you wish to retrieve all available attributes for a specific node in a taxonomy table?

Walter

Former Member
0 Kudos

Hi Walter,

Retrieving all available attributes for a specific node is not the problem. The problem is retrieving the values for linked attributes.

So, for instance, if I have a record with Product information, and my Taxonomy-table contains an attribute called "Material Type" and I select the attributevalue "Finished Product", then I would like to be able to retrieve the value "Finished Product".

Hope this clarifies the issue a little bit more.

With kind regards,

Gerwin

Former Member
0 Kudos

OK, let's start. If I am off-track, please let me know :-).

Firstly, there are two ways to get the linked attributes for a specific record:

<u>1. Get the attributes with the ResultSetDefinition</u>

Include the taxonomy field in the ResultSetDefinition and use <b>resultSetDefinition.SetIncludeAttributes(true)</b>. Then, when you have your result set, you can call the function <b>GetAttributes</b>

The AttributeValueExArray is an array of, you guessed it, <b>AttributeValueEx</b>.

Have a look at the API Javadoc, and the official API documentation. Hopefully the above will be enough to get you on your way.

Regards,

Walter

Example:


ResultSetDefinition rsd = new ResultSetDefinition("Products);
rsd.AddField("MyTaxonomyField");
rsd.SetIncludeAttributes(true);
rsd.SetCutoffPriority(100);  // or whatever cutoff priority you desire
// add some more fields...

// get the ResultSet
A2iResultSet rs = catalogData.GetResultSet(....;

// Now loop through the result set and read the attributes for each record
for(i = 0; i < rs.GetRecordCount(); i++)
{
    AttributeValueExArray avx = rs.GetAttributes(i, "MyTaxonomyField");
    // do something with the attributes
}

<u>2. Use the GetLinkedAttributes functions</u>

Using this method can be more efficient than the first method if you do not necessarily want to retrieve the attributes for <i>every</i> record in a ResultSet.

Having got hold of a record ID, you can retrieve its linked attributes at any time by calling the function <b>CatalogData.GetLinkedAttributes</b>.

Example:


AttributeValueExArray avx = myCatalogDataObject.GetLinkedAttributes ("Products", "MyTaxonomyField", 123, 100);
/*
 * 123 = recordId
 * 100 = cutoff priority
 */

The AttributeValueExArray holds an array of <b>AttributeValueEx</b> objects. Have a look at the MDM API documentation as well as the Javadoc for more information.

Regards,

Walter

Former Member
0 Kudos

Hi Walter,

I already discovered lots of the code you sent me, but anyway thanks for that, because know I know that I am going at least in the right direction. Unfortunately I get stuck at the point where I have to "dismantle" the AttributeValueEx. If I cast it to an AttributeInfo-object, then I'm able to retrieve the attributename, but there's not method for retrieving the value for that attribute. SO, do you know how to proceed and to which object must I cast it in order to get the value?

I thank you in advance,

Gerwin

Former Member
0 Kudos

OK - this is where it starts getting tricky.

The AttributeInfoEx object holds two pieces of information - one with the attribute metadata, and one with the the actual attribute values. The metadata is obtained via the function <b>GetAttributeInfo()</b> which returns an <b>AttributeInfo</b> object. The AttributeInfo object includes, amongst other things, the attribute name and the the attribute type.

An attribute can be one of three types:

  • Feature (string)

  • Characteristic (numeric)

  • Coupled (numeric coupled attribute)

You determine the attribute type by inspecting the value of <b>AttributeInfo.GetType()</b> and comparing it to <b>CMRatingType</b> constants.

Attribute is a FEATURE if

type == CMRatingType.FeatureRating

Attribute is a CHARACTERISTIC if

type == CMRatingType.MinimumRating ||

type == CMRatingType.MaximumRating ||

type == CMRatingType.TypicalRating ||

type == CMRatingType.NominalRating ||

type == CMRatingType.AverageRating

Attribute is a COUPLED NUMERIC if

type > 16

From the Javadoc:


a2i.generated.CMRatingType
public static final byte 	AverageRating 	16
public static final byte 	FeatureRating 	0
public static final byte 	InvalidRating 	-1
public static final byte 	MaximumRating 	2
public static final byte 	MinimumRating 	1
public static final byte 	NominalRating 	8
public static final byte 	TypicalRating 	4

Depending on the attribute type, you can now retrieve the attribute values via one of three functions:

FeatureDomain <b>attributeInfoEx.GetFeatures()</b>

AttributeValueArray <b>attributeInfoExGetCharacteristics()</b>

CoupledAttributeValueArray <b>attributeInfoExGetCoupledNumerics()</b>

You can inspect these three objects (FeatureDomain, AttributeValueArray and CoupledAttributeValueArray)in the Javadocs for more info.

Regards,

Walter

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Walter,

Thanks for your reply. It solved my problem. I've been trying to reward your last reply, but I keep getting errors. As soon as it works again I'll update the rewards,

Gerwin