On Tue, Dec 20, 2005 at 11:13:04AM -0500, Stephen Bash wrote:

> The method I've been using more is nested class mappings.  Basically you 
> take your class mapping for org.exolab.castor.mapping.MapItem (from your 
> first e-mail), and place it inside your bind-xml element like so:
> 
>    <field name="myHashMap" collection="map">
>      <bind-xml name="hash-item">
>        <class name="org.exolab.castor.mapping.MapItem">
>          <field name="key" type="string">
>            <bind-xml name="key" node="attribute" />
>          </field>
>          <field name="value" type="insert class here">
>            <bind-xml name="value" />
>          </field>
>        </class>
>      </bind-xml>
>    </field>

Ahhh yes, this makes sense (sorry Werner, I couldn't get this far on my 
own :)

However of course things still break. Marshalling gives me:

[...]
    <hash-item key="_testPricingSub4">
        <value>
            <costItems>
                <costItem>
                    <currency>GBP</currency>
                    <amount>10.00</amount>
                    <exchangeRate>1</exchangeRate>
                    <type>price</type>
                </costItem>
                <costItem>
                    <currency>GBP</currency>
                    <amount>1.75</amount>
                    <exchangeRate>1</exchangeRate>
                    <type>tax</type>
                </costItem>
            </costItems>
            <preTaxAmount>10.00</preTaxAmount>
            <postTaxAmount>11.75</postTaxAmount>
            <taxRate>0.175</taxRate>
        </value>
    </hash-item>
[...]

but passing that back to unmarshalling gives me:

1) 
testQuotation(com.ingenta.ics.ecommerce.api.item.QuotationMarshallingTest)java.lang.NullPointerException
        at 
org.exolab.castor.xml.util.XMLFieldDescriptorImpl.hashCode(XMLFieldDescriptorImpl.java:416)
        at java.util.HashMap.hash(HashMap.java:261)

I seem to see this hashCode error a fair amount; the last time I managed 
to get a test case for it and reported it as a bug, but then found a 
workaround. I'll try to do the same this time, but so far this time I've 
been failing miserably at making my test cases break!

I'll attach the description file in case anyone can eyeball that and tell 
where the problem might be. I'm rapidly losing patience with trying to 
figure out where in this enormous system we have set things up poorly, so 
that Castor breaks, but I don't seem to have any option but to keep 
banging my head against it :P

Jessica


<?xml version="1.0" encoding="UTF-8"?>

<!-- ===========================================
        CASTOR configuration for ICS REST API
           Subscription objects
     ============================================ -->

<mapping xmlns="http://castor.exolab.org/";
         xmlns:cst="http://castor.exolab.org/";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:type="mapping">

  <description>ICS API Mapping: Subscription objects</description>

   <include href="include/common.xml" />
   <include href="include/chargeable-common.xml" />

   <class name="com.ingenta.ics.ecommerce.api.item.Quotation">
     <description>Mapping for Quotation</description>
     <map-to xml="quotation"/>
     <field name="id" type="com.ingenta.ics.item.Id" />
     <field name="identityId" type="com.ingenta.ics.item.Id">
       <bind-xml name="identityId"/>
     </field>
     <field name="productId" type="com.ingenta.ics.item.Id">
       <bind-xml name="productId"/>
     </field>
     <!-- FIXME: move field handler up a level? -->
     <field name="currency" type="string" 
handler="com.ingenta.ics.api.rest.product.CurrencyFieldHandler"/>
     <field name="preTaxTotal" type="big-decimal">
       <bind-xml name="preTaxTotal"/>
     </field>
     <field name="postTaxTotal" type="big-decimal">
       <bind-xml name="postTaxTotal"/>
     </field>
     <field name="options" type="int" collection="array"/>
   <field name="costs" collection="map">
     <bind-xml name="hash-item">
       <class name="org.exolab.castor.mapping.MapItem">
         <field name="key" type="string">
           <bind-xml name="key" node="attribute" />
         </field>
         <field name="value" type="com.ingenta.ics.ecommerce.api.item.Cost">
           <bind-xml name="value" />
         </field>
       </class>
     </bind-xml>
   </field>
   </class>

   <class name="com.ingenta.ics.ecommerce.api.item.Cost">
     <description>Mapping for Cost</description>
     <field name="costItems" collection="set" container="false">
       <bind-xml name="costItems"/>
     </field>
     <field name="preTaxAmount" type="big-decimal">
       <bind-xml name="preTaxAmount"/>
     </field>
     <field name="postTaxAmount" type="big-decimal">
       <bind-xml name="postTaxAmount"/>
     </field>
     <field name="taxRate" type="big-decimal">
       <bind-xml name="taxRate"/>
     </field>
   </class>

   <class name="com.ingenta.ics.ecommerce.api.item.CostItem">
     <map-to xml="costItem"/>
     <field name="currency" type="string" 
handler="com.ingenta.ics.api.rest.product.CurrencyFieldHandler"/>
     <field name="amount" type="big-decimal"/>
     <field name="exchangeRate" type="big-decimal">
       <bind-xml name="exchangeRate"/>
     </field>
     <field name="type" 
type="com.ingenta.ics.ecommerce.api.constants.CostType"/>
   </class>

   <class name="com.ingenta.ics.ecommerce.api.constants.CostType" 
verify-constructable="false">
     <map-to xml="costType" />
   </class>
 </mapping>


-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to