Announcement Announcement Module
Collapse
No announcement yet.
Fieldextractor: I need some assistance! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fieldextractor: I need some assistance!

    I created a processor that will create a List of item and eventually pass it to FieldExtractor in order to convert the fields on the item into an array. Since I passing a List of Item, I iterate the value of List of Items then add it into variable values(List). The problem with my approach was, it treats the values as one row/record when the variable values converted into Object[]. (see below code fragment)

    values in the object array:
    {"001","test01","001","test1"}

    What want is something like this. Thus, when the item writes into a file it will be two rows instead of one.
    {"001","test01"}
    {"002","test02"}


    Is there any way or work around? Thanks in Advance


    public class OrderFieldExtractor implements FieldExtractor<MainOrder> {
    private static Logger log = Logger.getLogger(OrderFieldExtractor.class);

    @Override
    public Object[] extract(MainOrder item) {
    List<Object> values = new ArrayList<Object>();

    List<OrderSystemB> list = item.getOrderB();

    for (OrderSystemB element : list) {
    values.add(element.getOrder_id());
    values.add(element.getDescription());
    log.info("Element: "+list);
    }

    return values.toArray();
    }

    }

  • #2
    Originally posted by linoyabut View Post
    I created a processor that will create a List of item and eventually pass it to FieldExtractor in order to convert the fields on the item into an array. Since I passing a List of Item, I iterate the value of List of Items then add it into variable values(List). The problem with my approach was, it treats the values as one row/record when the variable values converted into Object[]. (see below code fragment)

    values in the object array:
    {"001","test01","001","test1"}

    What want is something like this. Thus, when the item writes into a file it will be two rows instead of one.
    {"001","test01"}
    {"002","test02"}


    Is there any way or work around? Thanks in Advance


    public class OrderFieldExtractor implements FieldExtractor<MainOrder> {
    private static Logger log = Logger.getLogger(OrderFieldExtractor.class);

    @Override
    public Object[] extract(MainOrder item) {
    List<Object> values = new ArrayList<Object>();

    List<OrderSystemB> list = item.getOrderB();

    for (OrderSystemB element : list) {
    values.add(element.getOrder_id());
    values.add(element.getDescription());
    log.info("Element: "+list);
    }

    return values.toArray();
    }

    }

    I tried to revisit this RecursiveCollectionLineAggregator class and I got my answer. I just simply added a new line charter "/n" and a little string manipulation and that's it. Thanks!

    Comment

    Working...
    X