Hello guys I am using BeanIO to write to CSV file.
I have a complex class structure that I want to output in one column. And here are the classes I am using. "Main" class is GprsEvent:
public class GprsEvent
{
private ListOfServiceData listOfServiceData;
// setters and getters omitted
}
public class ListOfServiceData implements Serializable
{
private List<ChangeOfServiceCondition> seqOf = null;
// setters and getters omitted
}
public class ChangeOfServiceCondition implements Serializable
{
private RatingGroupId ratingGroup = null;
private ChargingRuleBaseName chargingRuleBaseName = null;
private ResultCode resultCode = null;
private LocalSequenceNumber localSequenceNumber = null;
private TimeStamp timeOfFirstUsage = null;
private TimeStamp timeOfLastUsage = null;
private CallDuration timeUsage = null;
private ServiceConditionChange serviceConditionChange = null;
**private EPCQoSInformation qoSInformationNeg = null;** // Complex Type
private GSNAddress servingNodeAddress = null;
private DataVolumeGPRS datavolumeFBCUplink = null;
private DataVolumeGPRS datavolumeFBCDownlink = null;
private TimeStamp timeOfReport = null;
private FailureHandlingContinue failureHandlingContinue = null;
private ServiceIdentifier serviceIdentifier = null;
private BerOctetString userLocationInformation = null;
// setters and getters omitted
}
public class EPCQoSInformation implements Serializable
{
public byte[] code = null;
private BerInteger qCI = null;
private BerInteger maxRequestedBandwithUL = null;
private BerInteger maxRequestedBandwithDL = null;
private BerInteger guaranteedBitrateUL = null;
private BerInteger guaranteedBitrateDL = null;
private BerInteger aRP = null;
// setters and getters omitted
}
I have read through BeanIO documentation and found how to do what I intend: http://beanio.org/2.1/docs/reference/index.html#AdvancedTopics - 5.8.2. Wrapped Segments
So this is part of my beanio XML file:
<record class="net.atos.tools.radiation.convert.event.gprs.GprsEvent"
name="sGWRecord" maxOccurs="unbounded" minOccurs="0" order="1">
<segment name="listOfServiceData">
<segment name="listOfServiceData" class="net.atos.open.muc.generated.datatypes.ListOfServiceData">
<segment name="changeOfServiceCondition">
<segment name="changeOfServiceCondition" class="net.atos.open.muc.generated.datatypes.ChangeOfServiceCondition" collection="list" minOccurs="0" maxOccurs="unbounded">
<field name="ratingGroup" type="net.atos.open.muc.generated.datatypes.RatingGroupId" />
<field name="chargingRuleBaseName" type="net.atos.open.muc.generated.datatypes.ChargingRuleBaseName" />
<field name="resultCode" type="net.atos.open.muc.generated.datatypes.ResultCode" />
<field name="localSequenceNumber" type="net.atos.open.muc.generated.datatypes.localSequenceNumberp"/>
<field name="timeOfFirstUsage" type="net.atos.open.muc.generated.datatypes.TimeStamp"/>
<field name="timeOfLastUsage" type="net.atos.open.muc.generated.datatypes.TimeStamp"/>
<field name="timeUsage" type="net.atos.open.muc.generated.datatypes.CallDuration"/>
<segment name="qoSInformationNeg">
<segment name="qoSInformationNeg" class="net.atos.open.muc.generated.datatypes.EPCQoSInformation" occursRef="timeUsage">
<field name="qCI" type="org.openmuc.jasn1.ber.types.BerInteger"/>
<field name="maxRequestedBandwithUL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
<field name="maxRequestedBandwithDL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
<field name="guaranteedBitrateUL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
<field name="guaranteedBitrateDL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
<field name="aRP" type="org.openmuc.jasn1.ber.types.BerInteger"/>
</segment>
</segment>
</segment>
</segment>
</segment>
</segment>
</record>
I am receving the following error: org.beanio.BeanIOConfigurationException: Invalid segment 'qoSInformationNeg', in segment 'qoSInformationNeg', in segment 'changeOfServiceCondition', in segment 'changeOfServiceCondition', in segment 'listOfServiceData', in segment 'listOfServiceData', in record 'sGWRecord', in stream 'gprs': Collection required when maxOccurs is greater than 1 and class is set
Okay found solution myself, problem occurs when more than one
collection="list"
are present. For example in my XML file, first list occurrence is:Where next list occurs after that:
In the field where first list occourance is present, you have to add: occursRef keyword. In my case first list name is sgsnAddresses and I had to add
occursRef="sgsnAddressLength"
, since sgsnAddressLength is the field that precedes first list occourance.