Added example of how to do statusEndDate for a status date range, plus other little cleanups
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@570035 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -37,7 +37,7 @@ under the License.
|
||||
<!-- 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 @@ under the License.
|
||||
</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 @@ under the License.
|
||||
<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 @@ under the License.
|
||||
|
||||
<!-- 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 @@ under the License.
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user