cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Allowed Values of a property in Property Metadata?

Former Member
0 Kudos
68

Hi, SDN fellows.

I am having problem retrieve the allowed values of a property in property metadata.

I went through the KM example - Implementing a Metadata Extension for KMC Properties. I get some hints on what class that I should use to do this. But I still don't get the solution I want it.

I tried to use the DefaultMetadataExtension (which implements IDynamicValues) to call the method getAllowedValues(IMetaName metaName).

But when I need to pass in the IMetaName, I don't know how shoould I get it.

Here is my code:


com.sapportals.wcm.service.propertyconfig.IMetaModel mm = null;
		IPropertyConfigurationService configService;
		try {
			configService =
				(IPropertyConfigurationService) ResourceFactory
					.getInstance()
					.getServiceFactory()
					.getService("PropertyConfigurationService");
			mm = configService.getMetaModel();
		} catch (ResourceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (PropertyConfigurationServiceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		DefaultMetadataExtension mext = new DefaultMetadataExtension(mm);
		IMetaName mname = ???? //where do I get this IMetaName?
		mext.getAllowedValues(mname);


Said I what to get the property with this information:

1) Namespace = xyz

2) PropertyName = abc

3) Property Type is String

How should I get the IMetaName out of this?

Thanks for advices.

Kent

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kent,

I have a similar related query : how to get the alowed values of a property in an XML form project's preview?

Please share with me if you have any solution for the same.

Thanks in Advance,

Jasmine.

Former Member
0 Kudos

Here is the solution to get the allowed values of a property:

com.sapportals.wcm.service.propertyconfig.IMetaModel mm = null;
		IPropertyConfigurationService configService=null;
		try {
			configService =
				(IPropertyConfigurationService) ResourceFactory
					.getInstance()
					.getServiceFactory()
					.getService("PropertyConfigurationService");
			mm = configService.getMetaModel();
		} catch (ResourceException e) {
			// TODO Auto-generated catch block
						e.printStackTrace();
		} catch (PropertyConfigurationServiceException e) {
			// TODO Auto-generated catch block
						e.printStackTrace();
		}
		
				
		IPropertyName propertyName =null;
		try {
			
			propertyName=new PropertyName("namespace", "property");
		} catch (ResourceException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
					}
			
		IMetaName metaName=null;
		try {
			metaName =
				configService.getMetaModel().searchByPropertyName(propertyName);
		} catch (PropertyConfigurationServiceException e2) {
			// TODO Auto-generated catch block
						e2.printStackTrace();
		}
		
		try {
			
			IMetaValueListIterator metaValueListIterator=  metaName.allowedValueIterator();
			
			while(metaValueListIterator.hasNext())
			{
				IMetaValue metaValue = metaValueListIterator.next();
//Print the Allowed Values of the Property
				writeln(res, "MetaValue= " + metaValue.getValue());
			}
			
		} catch (PropertyConfigurationServiceException e3) {
			// TODO Auto-generated catch block
						e3.printStackTrace();
		}

Message was edited by: Kent C.