Customer Portal

Multi-valued fields

Comments 4

  • Avatar
    jausperger
    0
    Comment actions Permalink
    You can use: <Mapping xpath="concat(foo/bar[1]/text(), '@!@', foo/bar[2]/text())" cloverField="bar"/> if you want to write the values to one Clover field. Both possibilities are right.
  • Avatar
    mhgrove
    0
    Comment actions Permalink
    I was hoping for a solution that didn't require me to do a split on the input...


    String aDataList = aRecord.getField(aFieldName).getValue().toString();
    for (String aData : aDataList.split("@!@")) {
    // do something here
    }


    I'd rather have code like


    List aList = (List) aRecord.getField(aFieldName).getValue();
    for (Object aObj : aList) {
    String aData = (String) aObj;
    // do something;
    }


    Being able to get the data out as a list, rather than having to rely on splitting on a token is a lot safer. While it's unlikely that @!@ would ever be in the input, it *is* possible. It's just a hack that'd I'd rather not have to do.

    I thought about implementing a ListDataField extending from DataField, but I noticed there's a lot of serialization stuff in the DataField that I was not aware of. I'll have to dig into the code more to understand what's going on with that a little better. There's also the issue of not being able to add a new field time to the DataFieldFactory, which makes it difficult to use a ListDataField if I did manage to get it implemented.
  • Avatar
    jausperger
    0
    Comment actions Permalink
    What about sending these 'bar' to another output port? Each record would contain just one 'bar' and a key to 'foo'.
  • Avatar
    mhgrove
    0
    Comment actions Permalink
    I'm not sure. So what if foo looks like:


    <foo>
    <bar>0</bar>
    <bar>1</bar>
    <bar>2</bar>
    <baz>fake</baz>
    <biz>data</biz>
    </foo>


    If i'm routing the record to different n different ports, where n is the number of times a field is repeated, do the other fields, baz and biz in this case, get copied to each port? Also, would you have to know ahead of time what n so you can route things in your graph appropriately?

Please sign in to leave a comment.