Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 231085

Re: Action sets with conditionalProperty or filters

$
0
0

Hi All,

 

Please try following sample code for filtering action. Here i take Add Datastore action which only available if isDataStore value is true otherwise Add Datastore action will be hidden for datastore context.  For this i taken custom property as isDataStore which i register in PropertyProviderAdapter class.

 

// property for checking the context is datastore in web client which filter the action

private static final String ISDATASTORE="isDataStore";

 

//constructor

public SampleDatastoreDataImpl(

  UserSessionService userSessionService,

  VimObjectReferenceService vimObjectReferenceService,

  DataServiceExtensionRegistry registry) {

  _vimObjectReferenceService = vimObjectReferenceService;

  // register the  dsTypeInfo

  registry.registerDataAdapter(this, getProvidedTypeInfos());

  }

 

/**

  * @return the types and properties handled by this adapter.

*/

private TypeInfo[] getProvidedTypeInfos() {

  TypeInfo dsTypeInfo = new TypeInfo();

  dsTypeInfo.type = DS_TYPE;// for datastore context only

  dsTypeInfo.properties = new String[] {ISDATASTORE} ;

  return new TypeInfo[] { dsTypeInfo };

}

 

// assign the value for ISDATASTORE property

PropertyValue isDataStorePv = new PropertyValue();

isDataStorePv.resourceObject = dsRef;

isDataStorePv.propertyName = ISDATASTORE;

isDataStorePv.value = dsstoreInfo!=null?true:false; //logic for assign the value for ISDATASTORE property

//add isDataStorePv to resultItem's property array as shown

ri.properties = new PropertyValue[] {isDataStorePv };

 

 

Plugin.xml:----

  <extension id="com.vmware.samples.actions.datastore.addVMStoreAction">

      <extendedPoint>vise.actions.sets</extendedPoint>

      <object>

         <actions>

            <com.vmware.actionsfw.ActionSpec>

               <uid>com.mypro.vcplugin.server.vm.mypro.addvmstore</uid>

               <label>Add Datastore</label>

               <acceptsMultipleTargets>false</acceptsMultipleTargets>

               <command className="com.mypro.vcplugin.client.views.actionmenu.AddVMStoreActionsCommand"/>

            </com.vmware.actionsfw.ActionSpec>

          </actions>

      </object>

      <metadata>

          <objectType>Datastore</objectType>

        <propertyConditions>

             <com.vmware.data.query.CompositeConstraint>

                <nestedConstraints>

                    <com.vmware.data.query.PropertyConstraint>

                      <propertyName>isDataStore</propertyName>

                      <comparator>EQUALS</comparator>

                      <comparableValue>

                         <Boolean>true</Boolean>

                      </comparableValue>

                    </com.vmware.data.query.PropertyConstraint>

                </nestedConstraints>

                <conjoiner>AND</conjoiner>

             </com.vmware.data.query.CompositeConstraint>

          </propertyConditions>

       </metadata>     

   </extension>

 

 

Also this code will be useful for hiding/filtering the other extensions points in web client.

 

This code is tested at my end and working fine please let me know for any questions/queries.

 

Thanks,

Vaibhav Parkhi


Viewing all articles
Browse latest Browse all 231085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>