on 03-30-2006 9:45 PM
Hi,
I created a custom property and have like 5 or 6 values assigned to it.
From the API, as mentioned below, I could only find a way to get these values if they are set to a resource and if the property is a multi-valued.
String namespace = "http://com.sap.netweaver.bc.rf.sample/xmlns/sample";
String name = "property";
IPropertyName propertyName = new PropertyName(namespace, name);
IProperty property = resource.getProperty(propertyName);
if( property.isMultivalued() ) {
// property is multi valued
List values = property.getValues();
...........................
If the property is not Multi-Valued and not set to a resource, is there any way to retrieve all the "Allowed Values" for that particular property.
I appreciate if anyone can throw some light on it.
Thanks,
Ravi.
You might not need all this code (depending on what you are doing, and what items you may already have),
the part relevant to fething the allowed values is at the bottom:
IResource fileresource=//however you're getting it.
IPropertyConfigurationService propConfigService = (IPropertyConfigurationService) ResourceFactory.getInstance().getServiceFactory().getService(
"PropertyConfigurationService");
IMetaModel mm = propConfigService.getMetaModel();
metaContext = mm.createEmptyMetaContext();
metaContext.setResource(fileresource);
metaContext.setResourceContext(fileresource.getContext());
IMutablePropertyMap propertymap = fileresource.getProperties().getMutable();
metaContext.setPropertyMap(propertymap);
propName = new PropertyName("yourNamespace", "yourPropertyName");
IMetaName metaname = propConfigService.getMetaModel().searchByPropertyName(propName);
IMetaValueListIterator iml = metaname.allowedValueIterator( metaContext );
while (iml.hasNext()) {
IMetaValue vl = iml.next();
String myvalue = vl.getValue();
//... do something with it
}
randall@rkdataservices.com
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You might not need all this code (depending on what you are doing, and what items you may already have), the part relevant to fething the allowed values is at the bottom:
IResource fileresource=//however you're getting it.
IPropertyConfigurationService propConfigService = (IPropertyConfigurationService) ResourceFactory.getInstance().getServiceFactory().getService(
"PropertyConfigurationService");
IMetaModel mm = propConfigService.getMetaModel();
metaContext = mm.createEmptyMetaContext();
metaContext.setResource(fileresource);
metaContext.setResourceContext(fileresource.getContext());
IMutablePropertyMap propertymap = fileresource.getProperties().getMutable();
metaContext.setPropertyMap(propertymap);
propName = new PropertyName("yourNamespace", "yourPropertyName");
IMetaName metaname = propConfigService.getMetaModel().searchByPropertyName(propName);
IMetaValueListIterator iml = metaname.allowedValueIterator( metaContext );
IMetaContext metaContext=
while (iml.hasNext()) {
IMetaValue vl = iml.next();
String myvalue = vl.getValue();
//... do something with it
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.