Hi,

If you would see my Route pasted below,I am using simple language in when
condition (e.g.<when>
          <simple>${body.entity.subject} == 'Advertising'</simple>).
Instead of above statement I want something like:
          <simple>${body.entity.subject} ==
InquiryTypeEnum.ADVERTISING.nameValue()</simple>).

I don't to achieve above whether simple language is okay or not. I was
trying with javaScript but no luck.

Thank you in advance for the help.

Here is my route:
<route id="other.inquiry.mailer"  >
      <from uri="direct:goToOther"/>
      <unmarshal ref="xstream" />
      <convertBodyTo type="com.ebates.domain.inquiry.Message" />
          <transacted ref="required" />
      
      <choice>
        <when>
          <simple>${body.entity.email} != null</simple>
      <setHeader
headerName="X-Email-Type"><simple>${body.emailType}</simple></setHeader>
      <setHeader
headerName="X-autologin"><simple>${body.loginHeader}</simple></setHeader>
      <to uri="bean:debugProcessor"/>
      <choice>
      <when>
          <simple>${body.entity.subject} == 'Advertising'</simple>
        <setHeader
headerName="to"><simple>${properties:cs.inquiry.advertising.emailaddress}</simple></setHeader>
      </when>
      <when>
          <simple>${body.entity.subject} == 'Affiliate Program'</simple>
          <setHeader
headerName="to"><simple>${properties:cs.inquiry.affiliate_program.emailaddress}</simple></setHeader>
      </when>
      <otherwise>
          <setHeader
headerName="to"><simple>${properties:cs.inquiry.default.emailaddress}</simple></setHeader>
      </otherwise>
      </choice>
    <setHeader
headerName="subject"><simple>${body.entity.subject}</simple></setHeader>
    <setHeader
headerName="from"><simple>${body.entity.email}</simple></setHeader>
      <to ref="otherInquiryVelocity" />
      <to uri="direct:toConsumer"/>
     
    </when>
</choice>
 </route>

Here is my Java enum:

public enum InquiryTypeEnum implements Serializable, BaseEnum {
    
    ADVERTISING(2L, "Advertising"),
   
    AFFILIATE_PROGRAM(3L, "Affiliate Program"),
   
    BECOME_AN_EBATES_MERCHANT(6L, "Become an Ebates Merchant"),
  
    CASH_BACK_CHECK(10L, "Cash Back Check"),
 
    private final String name;
    private final Long value;

    private InquiryTypeEnum(final Long v, final String n) {
        this.value = v;
        this.name = n;
    }

    public static InquiryTypeEnum fromValue(final Long v) {
        for (final InquiryTypeEnum c : InquiryTypeEnum.values()) {
            if (c.value.equals(v)) {
                return c;
            }
        }

        return null;
    }

    public static InquiryTypeEnum fromValue(final String n) {
        for (final InquiryTypeEnum c : InquiryTypeEnum.values()) {
            if (c.name.equalsIgnoreCase(n)) {
                return c;
            }
        }

        return null;
    }
}



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-do-I-use-Java-Enum-instead-of-a-string-into-my-route-in-spring-xml-tp5726445.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to