cancel
Showing results for 
Search instead for 
Did you mean: 

How to use evaluator='aspect' to check for (parent) aspect

mathias_lin
Star Contributor
Star Contributor
I have one aspect which is the parent aspect of two other aspects.


            <aspect name="my:parentAspect">
       </aspect>

       <aspect name="my:subAspect1">
           <parent>my:parentAspect</parent>
           </aspect>

       <aspect name="my:subAspect2">
           <parent>my:parentAspect</parent>
           </aspect>


Now I want to use the "aspect"-evaluator in my share-config-custom to apply some customization if a node directly has the aspect "mySmiley TonguearentAspect" <strong>or if the node has an aspect that has inherited from "mySmiley TonguearentAspect" by having it as a parent</strong>.


<config evaluator="aspect" condition="my:subAspect1">…</config>
<config evaluator="aspect" condition="my:subAspect2">…</config>


works, but I would prefer to use


<config evaluator="aspect" condition="my:parentAspect">…</config>


However, this does not work for nodes that don't have the mySmiley TonguearentAspect attached, i.e. when they have my:subAspect1 attached.

What's the best practice to check for an aspect regardless whether it's directly applied or inherited somewhere down the hierarchy?

1 REPLY 1

scouil
Star Contributor
Star Contributor
Hi,

To my knowledge, the parent check is not available out of the box.
What I'd recommend would be to define your own evaluator(s) extending from the default *aspect*evaluator.java (depending if it's a component evaluator or an action evaluator) to include the "checkParentAspect" property
If false then just super(), otherwise you'll have a bit more work Smiley Happy