on 10-15-2008 9:58 PM
Hi Friends,
I am trying to get the field value of type measurement. I am able to get the value but unable to get the actual unit of measurement. To use the Dimensions object i need to know the Dimensiond Id, which i think can be possible by using the object of MeasurementFieldProperties.
Can anyone of you please let me know if there is way to get this?
Thanks,
Raags
Has anyone knows solution for this issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the sample code to get the Unit value for measurement field:
MeasurementFieldProperties meaProps =(MeasurementFieldProperties)getRepositorySchema().getField(TABLE_ID, FIELD_ID);
DimensionId dimensionId = meaProps.getDimensionId();
Dimensions dimensions = new Dimensions();
measurementValue = ((MeasurementValue) mdmValue).getMagnitude();
UnitId unitId = ((MeasurementValue) mdmValue).getUnitId();
UnitProperties unitProps = dimensions.getUnit(dimensionId, unitId);
String unitName = unitProps.getName(Locale.US);
Hope that helps!
Yes, Dimensions has been deprecated with new release. Instead of Dimensions you can use the DimensionsManager.
Here is the sample code with DimensionsManager:
DimensionsManager dimensionsManager = getDimensionsManager();
DimensionId dimensionId = meaProps.getDimensionId();
measurementValue = ((MeasurementValue) mdmValue).getMagnitude();
UnitId unitId = ((MeasurementValue) mdmValue).getUnitId();
UnitProperties unitProps = dimensionsManager.getUnit(dimensionId, unitId);
String unitName = unitProps.getSuffix();
String value = measurementValue + unitName;
//Getting Dimensions Manager
public static DimensionsManager getDimensionsManager() {
String sessionTag = null;
GetRepositoryDimensionsCommand cmd =
new GetRepositoryDimensionsCommand(connectionAccessor);
sessionTag = getAuthenticatedUserSession(connectionAccessor);
cmd.setSession(sessionTag);
cmd.execute();
dimensionsManager = cmd.getRepositoryDimensions();
return dimensionsManager;
}
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
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.