on 01-16-2008 12:10 AM
Hi All,
Main table: products
taxonomy field: cateogry
taxonomy table: cateogries table
I get all the attributes of the cateogry field by using
AttributeValueExArray aex = rs.GetAttributes(n,"Category"); where rs is my resultset, n is the corresponding row.
Now I want to display all the values of attributes along with the units, for instance for a numeric field, I get it by using
for(int k=0; k < aex.GetSize(); k++)
out.println (aex.GetAttributeValueExAt(k).GetCharacteristics().GetAttributeValueAt(0).GetValue() );
}
it is just displaying just the value, but the measurement field is not associated with it. I see a method getUnitID() which returns bytes.. but how could i use that to display my measurement field.
I have seen a blog which shows how to get measurement units for fields at /people/walter.kahn/blog/2005/10/27/mdm-55-api-tips-and-tricks--measurement-fields, but i am not able to find the API to get the measurement unit of the attribute of a particular taxonomy field.
please help
This code should get you the units of measurement:
if (mdmVal.getType() == MdmValue.Type.MEASUREMENT) {
AttributeProperties attProps =retrieveAttributesCommand(conn, session, aid);
String value =getValue(repository,(NumericAttributeProperties) attProps,(MeasurementValue) mdmVal);
}
********************************************************
public static AttributeProperties retrieveAttributesCommand(
ConnectionAccessor conn,
String session,
AttributeId aid) {
AttributeId id = aid;
RetrieveAttributeCommand retAtt = new RetrieveAttributeCommand(conn);
retAtt.setAttributeId(id);
retAtt.setSession(session);
retAtt.setTaxonomyTableId(new TableId("T5"));
try {
retAtt.execute();
} catch (CommandException e) {
e.printStackTrace();
}
return retAtt.getAttribute();
}
***********************************************************************************
private static String getValue(Repository repository,NumericAttributeProperties attribute,
MeasurementValue value) {
return value.getMagnitude()+ " "+ getUnit(attribute.getMeasurement().getDimensionId(),
value.getUnitId()).getName(repository.locale);
}
***********************************************************************************
static public UnitProperties getUnit(DimensionId dimensionID, UnitId unitID) {
Map m = (Map)idDimensionUnitMap.get(dimensionID);
UnitProperties unit = (UnitProperties)m.get(unitID);
return unit;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.