0
votes

I am using Anypoint Studio 6.1 with Mule 3.8.1 and I have a csv file that I have converted to java using Dataweave. Later in the workflow I have to perform a new mapping to the output JSON object using Dataweave.

I have a number of fields to map so wanted to find out if there is there a way of showing the fields in the Java input in the left side input panel so I can use the graphical GUI to map?

The code I am using to convert the csv to java in Dataweave is:

%dw 1.0
%input payload application/csv
%output application/java
---
payload

Thanks

2

2 Answers

0
votes

You have to define metadata in configuration of transform component.

Follow the sequence

  1. Click on define metdata

    Click on define metadata

  2. Add type id (any name)

    Add type id any name

  3. Select type.

    Select type

  4. Select java object type.

    Select java object type

  5. Type qualified name of class.

    Find your class

0
votes

To add to Beacon's response..after you follow those instructions you can right click on the payload -> Edit Sample Data and then add your sample/mock up java object info following

The input java class (follows TheBeacon's instructions):

package org.example;
    public class Name {
       String first;
       String last;

    public Name() {};

    public void setFirst(String first){
       this.first = first;
    }
    public void getFirst(){
       return first;
    }
    public setLast(String last){
       this.last = last;
    }

    public getLast() {
      return last;
    }
    }

Then your DW input side example would look like:

%dw 1.0
%output application/java
---
{
    first: 'Jane',
    last: 'Doe'    
} as :object {
    class : "org.example.Name"
}