svn commit: r569120 - in /ofbiz/trunk/applications/product: entitydef/entitymodel.xml script/org/ofbiz/product/subscription/SubscriptionServices.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r569120 - in /ofbiz/trunk/applications/product: entitydef/entitymodel.xml script/org/ofbiz/product/subscription/SubscriptionServices.xml

jaz-3
Author: jaz
Date: Thu Aug 23 12:10:11 2007
New Revision: 569120

URL: http://svn.apache.org/viewvc?rev=569120&view=rev
Log:
now copies subscription resource data to the subscription entity when created

Modified:
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/subscription/SubscriptionServices.xml

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=569120&r1=569119&r2=569120&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Thu Aug 23 12:10:11 2007
@@ -3908,6 +3908,16 @@
         <field name="externalSubscriptionId" type="id"></field>
         <field name="fromDate" type="date-time"></field>
         <field name="thruDate" type="date-time"></field>
+        <!-- this subscription instance resource values -->
+        <field name="purchaseFromDate" type="date-time"></field>
+        <field name="purchaseThruDate" type="date-time"></field>
+        <field name="maxLifeTime" type="numeric"></field>
+        <field name="maxLifeTimeUomId" type="id"></field>
+        <field name="availableTime" type="numeric"></field>
+        <field name="availableTimeUomId" type="id"></field>
+        <field name="useCountLimit" type="numeric"></field>
+        <field name="useTime" type="numeric"></field>
+        <field name="useTimeUomId" type="id"></field>
         <prim-key field="subscriptionId"/>
         <relation type="one" fk-name="SUBSC_SRESRC" rel-entity-name="SubscriptionResource">
             <key-map field-name="subscriptionResourceId"/>
@@ -3917,6 +3927,15 @@
         </relation>
         <relation type="one" fk-name="SUBSC_PARTY" rel-entity-name="Party">
             <key-map field-name="partyId"/>
+        </relation>
+        <relation type="one" fk-name="SUBSC_UTU" title="UseTime" rel-entity-name="Uom">
+            <key-map field-name="useTimeUomId" rel-field-name="uomId"/>
+        </relation>
+        <relation type="one" fk-name="SUBSC_ATU" title="AvailableTime" rel-entity-name="Uom">
+            <key-map field-name="availableTimeUomId" rel-field-name="uomId"/>
+        </relation>
+        <relation type="one" fk-name="SUBSC_MTU" title="MaxLifeTime" rel-entity-name="Uom">
+            <key-map field-name="maxLifeTimeUomId" rel-field-name="uomId"/>
         </relation>
         <relation type="one" fk-name="SUBSC_ROLE_TYPE" rel-entity-name="RoleType">
             <key-map field-name="roleTypeId"/>

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/subscription/SubscriptionServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/subscription/SubscriptionServices.xml?rev=569120&r1=569119&r2=569120&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/subscription/SubscriptionServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/subscription/SubscriptionServices.xml Thu Aug 23 12:10:11 2007
@@ -32,7 +32,23 @@
             </else>
         </if-empty>
         <field-to-result field-name="newEntity.subscriptionId" result-name="subscriptionId"/>
-        <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
+        
+        <!-- lookup the product subscription resource (if exists) -->
+        <if-not-empty field-name="parameters.subscriptionResourceId">
+            <if-not-empty field-name="parameters.productId">
+                <entity-and entity-name="ProductSubscriptionResource" list-name="resourceList" filter-by-date="true">
+                    <field-map field-name="subscriptionResourceId" env-name="parameters.subscriptionResourceId"/>
+                    <field-map field-name="productId" env-name="parameters.productId"/>
+                    <order-by field-name="-fromDate"/>
+                </entity-and>
+                <first-from-list entry-name="resource" list-name="resourceList"/>
+                <if-not-empty field-name="resource">
+                    <set-nonpk-fields value-name="newEntity" map-name="resource"/>
+                </if-not-empty>
+            </if-not-empty>
+        </if-not-empty>
+        
+        <set-nonpk-fields map-name="parameters" value-name="newEntity"/>        
         <create-value value-name="newEntity"/>
     </simple-method>  
     <simple-method method-name="updateSubscription" short-description="Update a Subscription">
@@ -40,6 +56,22 @@
         <check-permission permission="CATALOG" action="${securityAction}"><fail-property resource="ProductUiLabels" property="GeneralCatalogPermissionError"/></check-permission>
         <check-errors/>
         <entity-one entity-name="Subscription" value-name="lookedUpValue"/>
+
+        <!-- lookup the product subscription resource (if exists) -->
+        <if-not-empty field-name="lookedUpValue.subscriptionResourceId">
+            <if-not-empty field-name="lookedUpValue.productId">
+                <entity-and entity-name="ProductSubscriptionResource" list-name="resourceList" filter-by-date="true">
+                    <field-map field-name="subscriptionResourceId" env-name="lookedUpValue.subscriptionResourceId"/>
+                    <field-map field-name="productId" env-name="lookedUpValue.productId"/>
+                    <order-by field-name="-fromDate"/>
+                </entity-and>
+                <first-from-list entry-name="resource" list-name="resourceList"/>
+                <if-not-empty field-name="resource">
+                    <set-nonpk-fields value-name="newEntity" map-name="resource"/>
+                </if-not-empty>
+            </if-not-empty>
+        </if-not-empty>
+        
         <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/>
         <store-value value-name="lookedUpValue"/>
     </simple-method>