cancel
Showing results for 
Search instead for 
Did you mean: 

How to expose attribute of a Taxonomy lookup using WDJava(MDM SP05 JavaAPI)

Former Member
0 Kudos

Hi All,

As of now I am able to expose the hierarchy part of the taxonomy lookup using WD JAVA with MDM Sp05 Java API. But now i am stuck at how to expose the attribute part of the taxonomy lookup in my application.

TIA.

Regards

Rajat Jain

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Hi Minaz,

Thanks for your reply. I have already gone through the links you have mentioned and that you can find out , by checking on the thread you have referred that I have asked a question in that thread also.

My problem is that when I am trying to setaattribute then it is asking for textvalueattribute whereas we are passing the measurement type value.

Now the bottleneck is I do not know how to pass measurement type value in textvalueattribute.

Can anyone help.

Regards.

Rajat

Former Member
0 Kudos

Hi,

I am using this:


UnitId unitId = new UnitId(0) ;			
mdmValue =
	new MeasurementValue(11,unitId);
	mdmRecord.setAttributeValue(taxFieldId,newAttributeId,mdmValue);
	

But it is giving me illegalarguement exception.

can any one please help me.

Regards.

Rajat

Edited by: Rajat Jain on Mar 6, 2009 9:54 AM

Former Member
0 Kudos

Hi Rajat,

Refer /people/walter.kahn/blog/2005/10/27/mdm-55-api-tips-and-tricks--measurement-fields

Hope it helps.

Thanks,

Minaz

Edited by: Minaz Kathawala on Mar 6, 2009 6:40 AM

Former Member
0 Kudos

Hi, I am stuck at this point:

TextAttributeValue value; // attribute value (for text attribute), depends on attribute type

Now if the attribute type is of measurement

then how to insert the same in the MDM repository.

Can any one provide the sample code.

Thanks In Advance.

Regards.

Rajat

Former Member
0 Kudos

Hi, Rajat!

I guess in case of measurement attribute you should use com.sap.mdm.valuetypes.MeasurementValue class for value. Then code will look like this:


UnitId unitId = ...;  // ID of unit of measure
double measValue = ...;  // numeric value of attribute
MeasurementValue  value = new MeasurementValue(measValue, unitId);
// process attribute value - store into record, update and so on

In fact I never work with measurement attributes, then previous code is a mere supposition.

Former Member
0 Kudos

Thanks.

Former Member
0 Kudos

Hi,

Much of trouble is now resolved but now I am stuck as how to get the input from user for the attributes of the taxonomy?

Now I need to insert the attribute values provided by user into the MDM DB. the attributes can be of text, numeric, lookup or measurement type.

Any suggestions are welcomed.....

Thanks in advance.

Regards.

Rajat Jain

Former Member
0 Kudos

Hi, Rajat!

Taxonomy attribute value belongs to taxonomy lookup field value. Let's consider you have:


Record record; // Record which has taxonomy lookup field
FieldId taxonomyLookupFieldId; // ID of taxonomy lookup field whose attributes value you want to set
AttributeId attrId; // ID of attribute which value you want to set
TextAttributeValue value; // attribute value (for text attribute), depends on attribute type

Then storing the attribute value into record will look like this:


// taxonomy lookup field must point to right taxonomy record
record.setAttributeValue(
  taxonomyLookupFieldId,
  attrId,
  value);

Of course, you also need Modify/Create RecordCommand to update your MDM repository.

Former Member
0 Kudos

Hi Pavel,

I am new to this MDM JAVA API and could not understand what type of object is attrProps.

Can you please post the code in some more detail? Sorry, for the trouble.

Thanks.

Regards.

Rajat

Former Member
0 Kudos

Hi, Rajat!

The type of attrProps variable is AttributeProperties and this variable keeps decription of one taxnomy attribute.

To fill attrProps variable with appropriate value you should:

1. execute RetrieveAttributeLinksCommand with:

- setTaxonomyTableId(yourTaxonomyTableId)

- setRecordId(theTaxonomyRecordId); // Id of the record whose attributes you want to work with

2. take execution result of the command:

 final AttributeLink[] attrLinks = command.getAttributeLinks()

This array will contain ids of taxonomy attributes bound to specified taxonomy record

3. now you need AttributeProperties objects for these attributes. Just execute RetrieveAttributeCommand for every AttributeLink:


for (int i=0; i<attrLinks.length; i++) {
  final AttributeId attrId = attrLinks<i>.getId();
  final RetrieveAttributeCommand cmd = new RetrieveAttributeCommand(...);
  cmd.setTaxonomyTableId(yourTaxonomyTableId);
  cmd.setAttributeId(attrId);
  cmd.execute();
  final AttributeProperties attrProps = cmd.getAttribute();
  if (attrProps.getType() == AttributeProperties.TEXT_TYPE) {
    // Process the attribute as text attribute
  }
}

The given code and sequence of actions are quite simplified. For example it's better to retrieve all attributes first (with single RetrieveAttributesCommand) than retrieve properties for every attribute.

Former Member
0 Kudos

Hi Pavel,

My requirement is to expose the following types of attributes on the EP using Webdynpro Java Application:

Text : single

Numeric :single, with dimestions / unit of measures

The functionality required is:

The taxonomy's hierarchy is already exposed, now depending upon the selected element, its attributes should be exposed on portal(the attribute may be exposed as an input field or dropdown) so that user can enter the value for the attributes too.

Here the input fields and drop downs will need to be created dynamically depending upon the no. and type of attributes for that particular taxonomy element.

This is the specific functional specs. If you can help to any extent that would be really great for us.

Thanks.

Regards.

Rajat Jain

Former Member
0 Kudos

Hi, Rajat.

Let's consider text attributes.

You can access to attribute properties through AttributeProperties interface, for a text attribute getType() method must return AttributeProperties.TEXT_TYPE value. In this case you can cast attribute properties object to TextAttributeProperties class.


final TextAttributeProperties textAttrProps = (TextAttributeProperties) attrProps;
final TextAttributeValueProperties[] values = textAttrProps.getTextAttributeValues();

Now, values array contains all possible values for the attribute. In WD, you can use:

a) attribute with value set populated with <id string - name> pairs

b) node (possible model) with at least one string attribute for value display name

In the case a you should use DropDownByKey, in the case b - DropDownByIndex UI element for representing possible values.

Storing selected attribute value:


final TextAttributeValueProperties selectedAttr = ...; // for case b
final TextAttributeValueId valueId = selectedAttr.getId();
// or
final TextAttributeValueId valueId = new TextAttributeValueId(idString); // for case a

record.setAttributeValue(
  taxonomyLookupFieldId,
  textAttrProps.getId(),
  new TextAttributeValue(valueId));

Former Member
0 Kudos

Hi All,

Any idea how the attribute of Taxonomy lookup be exposed in Web dynpro application using MDM SP05 JAVA APIs?

TIA.

Regards.

Rajat Jain

Former Member
0 Kudos

Hi, Rajat!

As you know, there are a lot of types of taxonomy attributes:

- Text

-- single / multi -valued

-- with / without image

- Numeric

-- single / multi -valued

-- with dimestions / unit of measures

-- with a set of raiting

- Coupled numeric

What kind of atributes is in your interest? What aspects of funtionality you need?