Hi,

We are looking for a way to map a Quantity object, instead of numeric  
values inside our persistent classes, because lots of convertions are  
needed when quantities are added, substracted compared etc so we came up  
with the following solution, which we don't really know how to map and any  
help would be great:

We have the classes:

Um = measurement unit
UmType = measurement unit type
Quantity = quantity
OrderItem - a line on an order

If we have more measurements units and we need to transform from one  
another in order to add, substract compare etc, so we grouped the  
measurement units on measurement unit types, each type like this having a  
default unit. For instance we have the following type:

|name|default unit|
|length|meter|
|weight|kg|

and the following units, where we define the factor to trasform into the  
default unit of the type:

|unit name| type| type default unit|factor to transform to default|
|km|length|meter|1000|
|hm|length|meter|100|
|cm|length|meter|0.01|

so now if we add:

|type |default|qty1|um1|qty2|um2|operation|total|um result|
|length|m|  1| m|3   | m|+|   4     |m|
|length|m|  1| m|5   |km|+|5001     |m|
|length|m|  1| m|0.25|cm|+|   1.0025|m|
|length|m|107|cm|0.4 |km|+| 401.07  |m|

The classes are:

     [ActiveRecord("UmTypes")]
     public class OrderItem
     {
        id
        product
        order

        [Nested]
       public Quantity Quantity
       ...

...

     public class Quantity
     {
         [Property]
         public decimal Amount
         {
             ...
         }

         [BelongsTo("UmID")]
         public Um Um
         {
             ...
         }


        [ActiveRecord("MeasurementUnits")]
        public class Um:Lookup,IDeletable
        {
         id...
         name...

         [BelongsTo("UmTypeID")]
          public UmType UmType...

         [OneToOne]
         public UmType DefaultInUmType...

         [Property]
          public decimal Factor...


     [ActiveRecord("UmTypes")]
     public class UmType:Lookup
     {
         private Um defaultUm;
         private IList ums = new ArrayList();

         public UmType(string typeName,Um defaultUm)
         {
                ...
         }


         [OneToOne]
         public Um DefaultUm...

         [HasMany(typeof(Um))]
         public IList Ums...



Can anyone help? It doesn't seem to want to work because there are some  
OneToOne relations (Um-UmType for deualy unit) and also some relations  
that are not inverse (Quantity - Um)?

Thanks in advance,

-- 

Dan Bunea
http://danbunea.blogspot.com

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
CastleProject-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/castleproject-users

Reply via email to