[Windup-users] XML Rule with otherwise action

Lincoln Baxter, III lincolnbaxter at gmail.com
Wed May 27 12:24:50 EDT 2015


Actually, on further thought, I bet that the negated rule *is* created, but
the system doesn't really know how to handle this situation.

You should see a second rule in the output:

addRule()
.when(Not.any(And.all(FileContent.matches(release).inFilesNamed(
{*}Tag.java).as(default))))
.perform(Hint.message("C7.1 : No release in Tag"))
.withId("TagLib release")

However, with the way our system currently works, the otherwise will never
fire because there probably ARE matches in teh system the have that
filecontent. This is something we need to address.

~Lincoln

On Wed, May 27, 2015 at 12:20 PM, Lincoln Baxter, III <
lincolnbaxter at gmail.com> wrote:

> The rule should be formatted as he originally posted:
>
> <rule id="TagLib release">
>        <when>
>             <filecontent matches="{*}" filename="{*}Tag.java"/>
>        </when>
>         <otherwise>
>                       <hint message="C7.1 : No release in Tag" effort="4"
> />
>         </otherwise>
>   </rule>
>
> It sounds like there might be a bug here if the "otherwise" clause is not
> being picked up. We'll have to look into this! I created an issue for it:
> https://issues.jboss.org/browse/WINDUP-613
>
> Thanks,
> Lincoln
>
> On Wed, May 27, 2015 at 7:07 AM, Ondrej Zizka <ozizka at redhat.com> wrote:
>
>> I am no expert on <otherwise>, but I think that it has no context of
>> what was found.
>> In other words, you are trying to apply <hint>, but Windup doesn't know
>> what to apply it to. The file is only "known" in the scope of nested
>> <when> and in <perform> .
>> Again, that's my guess, someone more knowledgable may confirm or not.
>>
>> If I am right, then you could either do a nested <perform><iteration>:
>> The first would find {*}Tag.java, the nested <when> would find the
>> pattern, or not:
>>
>> <rule id="TagLib release">
>>        <when>
>>             <filename pathPattern="{*}Tag.java" as="file"/>
>>        </when>
>>        <perform><iteration>
>>               <when>
>>                   <filecontent pattern="release" fileref="file" />
>>               </when>
>>               <otherwise>
>>                       <hint message="C7.1 : No release in Tag" effort="4"
>> />
>>               </otherwise>
>>        </iteration></perform>
>>   </rule>
>>
>> This won't work, we don't have <filename> and <filecontent> doesn't have
>> fileref.
>> A chance for you to submit a Jira :)
>>
>> HTH,
>>
>> Ondra
>>
>>
>> On 22.5.2015 12:14, Gilles Bardouillet wrote:
>> >
>> > Hi,
>> >
>> > I wrote an XML rule with an action specified in "otherwise" part, but
>> > the action is not launched when the condition is false :-(
>> >
>> > Here is my rule :
>> > <rule id="TagLib release">
>> >               <when>
>> >                   <filecontent pattern="release" filename="{*}Tag.java"
>> />
>> >               </when>
>> >               <otherwise>
>> >                       <hint message="C7.1 : No release in Tag"
>> effort="4" />
>> >               </otherwise>
>> > </rule>
>> >
>> > In overview panel, this xml rule is converted in
>> > addRule()
>> >
>> .when(And.all(FileContent.matches(release).inFilesNamed({*}Tag.java).as(default))
>> > )
>> >       .perform(new NoOp()
>> > )
>> > withId("TagLib release")
>> >
>> > It seems that "otherwise" action disappeared !
>> >
>> > Any tip ?
>> >
>> >
>> > Gilles.
>> >
>> > _______________________________________________
>> > Windup-users mailing list
>> > Windup-users at lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/windup-users
>>
>> _______________________________________________
>> Windup-users mailing list
>> Windup-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/windup-users
>>
>
>
>
> --
> Lincoln Baxter, III
> http://ocpsoft.org
> "Simpler is better."
>



-- 
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/windup-users/attachments/20150527/0334a208/attachment.html 


More information about the Windup-users mailing list