how to use logical operators in OOZIE workflow

大兔子大兔子 提交于 2019-12-04 09:22:40

I will explain this with an example.

Let's assume that we have a Java action (we will call this action as getAgeInfo), which outputs age of a person:

'person.age': Age of the person

The action:

<action name='getAgeInfo'> 
    <!--Outputs 1 property: person.age: returns age of the person--> 
    <java> 
        ..........
    </java> 
    <ok to="makeClassification" /> 
    <error to="fail" /> 
</action>

The next action is makeClassification. In makeClassification action, we classify a person into "child", "teenager", "mid-aged" or "senior-citizen", based on the person's age.

For e.g. if a person's age is greater than or equal to (ge) 12 (and) less than (lt) 20, we classify that person as a teenager and the workflow transitions to teenager action.

Following is the switch statement, which illustrates use of "and":

<decision name="makeClassification"> 
    <switch> 
        <case to="child"> 
            ${wf:actionData('getAgeInfo')['person.age'] gt 0 &&
              wf:actionData('getAgeInfo')['person.age'] lt 12} 
        </case> 
        <case to="teenager"> 
            ${wf:actionData('getAgeInfo')['person.age'] ge 12 && 
              wf:actionData('getAgeInfo')['person.age'] lt 20} 
        </case> 
        <case to="mid-aged"> 
            ${wf:actionData('getAgeInfo')['person.age'] ge 20 && 
              wf:actionData('getAgeInfo')['person.age'] lt 50} 
        </case> 
        <case to="senior-citizen"> 
            ${wf:actionData('getAgeInfo')['person.age'] ge 50} 
        </case> 
        <default to="error"/> 
    </switch> 
</decision>

You can see another example here: Oozie by Example, which illustrates the use of gt (greater than), lt (less than), logical or (||), logical and (&&).

oozie EL functions/expression are using JSP Expression Language syntax. from oozie's doc

You can check the JSP 2.0 specification to get the syntax.

Specifically for your question, the answer is:

<decision name="comboDecision">
    <switch>
        <case to="alpha">${(condition1) and (condition2)}</case>
        <default to="end"/>
    </switch>
</decision>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!