Author: jonesde
Date: Mon Aug 27 01:35:45 2007 New Revision: 570035 URL: http://svn.apache.org/viewvc?rev=570035&view=rev Log: Added example of how to do statusEndDate for a status date range, plus other little cleanups Modified: ofbiz/trunk/framework/example/entitydef/entitymodel.xml ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml ofbiz/trunk/framework/example/servicedef/services.xml Modified: ofbiz/trunk/framework/example/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/entitydef/entitymodel.xml?rev=570035&r1=570034&r2=570035&view=diff ============================================================================== --- ofbiz/trunk/framework/example/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/framework/example/entitydef/entitymodel.xml Mon Aug 27 01:35:45 2007 @@ -75,6 +75,7 @@ <entity entity-name="ExampleStatus" package-name="org.ofbiz.example.example" title="Example Status Entity"> <field name="exampleId" type="id-ne"></field> <field name="statusDate" type="date-time"></field> + <field name="statusEndDate" type="date-time"></field> <field name="statusId" type="id-ne"></field> <prim-key field="exampleId"/> <prim-key field="statusDate"/> Modified: ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml?rev=570035&r1=570034&r2=570035&view=diff ============================================================================== --- ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml (original) +++ ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml Mon Aug 27 01:35:45 2007 @@ -37,7 +37,7 @@ <!-- handle statusId change stuff; first put the current statusId in the oldStatusId result --> <field-to-result field-name="lookedUpValue.statusId" result-name="oldStatusId"/> <if-compare-field field-name="lookedUpValue.statusId" operator="not-equals" to-field-name="parameters.statusId"> - <!-- if the Example record exists there should be a statusId, but just in case make it so it won't blow up --> + <!-- if the record exists there should be a statusId, but just in case make it so it won't blow up --> <if-not-empty field-name="lookedUpValue.statusId"> <!-- if statusId change is not in the StatusValidChange list, complain... --> <entity-one entity-name="StatusValidChange" value-name="statusValidChange" auto-field-map="false"> @@ -51,7 +51,7 @@ </if-empty> </if-not-empty> - <!-- before we set the nonpk fields, if the statusId is different save a ExampleStatus history record --> + <!-- before we set the nonpk fields, if the statusId is different save a status history record --> <set-service-fields service-name="createExampleStatus" map-name="parameters" to-map-name="createExampleStatusMap"/> <call-service service-name="createExampleStatus" in-map-name="createExampleStatusMap"/> </if-compare-field> @@ -64,10 +64,23 @@ <remove-value value-name="lookedUpValue"/> </simple-method> <simple-method method-name="createExampleStatus" short-description="create a ExampleItem"> + <now-timestamp-to-env env-name="nowTimestamp"/> + + <!-- find the most recent status record and set the statusEndDate --> + <entity-and entity-name="ExampleStatus" list-name="oldExampleStatusList"> + <field-map field-name="exampleId" env-name="parameters.exampleId"/> + <order-by field-name="-statusDate"/> + </entity-and> + <first-from-list entry-name="oldExampleStatus" list-name="oldExampleStatusList"/> + <if-not-empty field-name="oldExampleStatus"> + <set field="oldExampleStatus.statusEndDate" from-field="nowTimestamp"/> + <store-value value-name="oldExampleStatus"/> + </if-not-empty> + <make-value entity-name="ExampleStatus" value-name="newEntity"/> <set-pk-fields map-name="parameters" value-name="newEntity"/> <set-nonpk-fields map-name="parameters" value-name="newEntity"/> - <now-timestamp-to-env env-name="newEntity.statusDate"/> + <set field="newEntity.statusDate" from-field="nowTimestamp"/> <create-value value-name="newEntity"/> </simple-method> @@ -92,7 +105,6 @@ <!-- Example ServiceTest Service --> <simple-method method-name="testCreateExampleService" short-description="test the create example service" login-required="false"> - <set field="createExampleMap.exampleTypeId" value="CONTRIVED"/> <set field="createExampleMap.exampleName" value="Test Example"/> <set field="createExampleMap.statusId" value="EXST_IN_DESIGN"/> @@ -102,32 +114,18 @@ </entity-one> <call-service service-name="createExample" in-map-name="createExampleMap"> - <result-to-field result-name="exampleId" field-name="lookupMap.exampleId"/> + <result-to-field result-name="exampleId" field-name="exampleId"/> </call-service> - <check-errors/> - <find-by-primary-key entity-name="Example" map-name="lookupMap" value-name="example"/> + <entity-one entity-name="Example" value-name="example"/> <assert> <not><if-empty field-name="example"/></not> - </assert> - <check-errors/> - - <assert> <if-compare-field field-name="example.exampleTypeId" to-field-name="createExampleMap.exampleTypeId" operator="equals"/> - </assert> - <check-errors/> - - <assert> <if-compare-field field-name="example.exampleName" to-field-name="createExampleMap.exampleName" operator="equals"/> - </assert> - <check-errors/> - - <assert> <if-compare-field field-name="example.statusId" to-field-name="createExampleMap.statusId" operator="equals"/> </assert> + <check-errors/> - </simple-method> - </simple-methods> Modified: ofbiz/trunk/framework/example/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/servicedef/services.xml?rev=570035&r1=570034&r2=570035&view=diff ============================================================================== --- ofbiz/trunk/framework/example/servicedef/services.xml (original) +++ ofbiz/trunk/framework/example/servicedef/services.xml Mon Aug 27 01:35:45 2007 @@ -55,6 +55,7 @@ <permission-service service-name="exampleGenericPermission" main-action="CREATE"/> <auto-attributes include="all" mode="IN" optional="false"> <exclude field-name="statusDate"/> + <exclude field-name="statusEndDate"/> </auto-attributes> </service> |
Free forum by Nabble | Edit this page |