Skip to content
Permalink
Browse files

Implemented: Convert Picklist related CRUD services from simple to en…

…tity-auto

(OFBIZ-10636)

services converted: 
 * createPicklist
 * updatePicklist
 * deletePicklist
 * createPicklistBin
 * deletePicklistBin
 * createPicklistItem
 * updatePicklistItem
 * updatePicklistItem
 * deletePicklistItem
 * createPicklistRole
 * deletePicklistRole

Entity Picklist received to new field createdDate and lastModifiedDate
that needed to support automatic setting of createdByUserLogin natevily
by entity auto engine 

Thanks to Pallavi Goyal for this issue and Suraj Khurana for the remind.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866561 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
nmalin committed Sep 7, 2019
1 parent 4a697dc commit c16dad812f971cb71175834e2b2736b6a2d1d0ed
@@ -159,8 +159,10 @@ under the License.
<field name="shipmentMethodTypeId" type="id"></field>
<field name="statusId" type="id"></field>
<field name="picklistDate" type="date-time"></field>
<field name="createdByUserLogin" type="id-vlong"></field>
<field name="lastModifiedByUserLogin" type="id-vlong"></field>
<field name="createdDate" type="date-time"/>
<field name="createdByUserLogin" type="id-vlong"/>
<field name="lastModifiedDate" type="date-time"/>
<field name="lastModifiedByUserLogin" type="id-vlong"/>
<prim-key field="picklistId"/>
<relation type="one" fk-name="PICKLST_FLTY" rel-entity-name="Facility">
<key-map field-name="facilityId"/>
@@ -761,139 +761,6 @@ under the License.
<field-to-result field="pickMoveInfoList"/>
</simple-method>

<!-- Picklist -->
<simple-method method-name="createPicklist" short-description="Create Picklist">
<make-value entity-name="Picklist" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>

<sequenced-id sequence-name="Picklist" field="newEntity.picklistId"/>
<field-to-result field="newEntity.picklistId" result-name="picklistId"/>

<if-empty field="newEntity.statusId">
<set value="PICKLIST_INPUT" field="newEntity.statusId"/>
</if-empty>

<!-- auto-set the picklistDate, this is not user-changeable -->
<now-timestamp field="newEntity.picklistDate"/>

<!-- set the created and lastModified info -->
<set from-field="userLogin.userLoginId" field="newEntity.createdByUserLogin"/>
<set from-field="userLogin.userLoginId" field="newEntity.lastModifiedByUserLogin"/>

<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updatePicklist" short-description="Update Picklist">
<make-value entity-name="Picklist" value-field="lookupPKMap"/>
<set-pk-fields map="parameters" value-field="lookupPKMap"/>
<find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>

<if-not-empty field="parameters.statusId">
<if-compare-field field="parameters.statusId" to-field="lookedUpValue.statusId" operator="not-equals">
<!-- make sure a StatusValidChange record exists, if not return error -->
<entity-one entity-name="StatusValidChange" value-field="checkStatusValidChange" auto-field-map="false">
<field-map field-name="statusId" from-field="lookedUpValue.statusId"/>
<field-map field-name="statusIdTo" from-field="parameters.statusId"/>
</entity-one>
<if-empty field="checkStatusValidChange">
<set value="ERROR: Changing the status from ${lookedUpValue.statusId} to ${parameters.statusId} is not allowed." field="error_list[]"/>
</if-empty>
<check-errors/>

<make-value entity-name="PicklistStatus" value-field="newStatusValue"/>
<set from-field="parameters.picklistId" field="newStatusValue.picklistId"/>
<set from-field="lookedUpValue.statusId" field="newStatusValue.statusId"/>
<set from-field="parameters.statusId" field="newStatusValue.statusIdTo"/>
<now-timestamp field="newStatusValue.statusDate"/>
<set from-field="userLogin.userLoginId" field="newStatusValue.changeByUserLoginId"/>
<create-value value-field="newStatusValue"/>
</if-compare-field>
</if-not-empty>

<!-- now finally check for errors -->
<check-errors/>

<!-- finally before setting nonpk fields, set the oldStatusId -->
<field-to-result field="lookedUpValue.statusId" result-name="oldStatusId"/>

<!-- now that all changes have been checked, set the nonpks -->
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<set from-field="userLogin.userLoginId" field="lookedUpValue.lastModifiedByUserLogin"/>

<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="deletePicklist" short-description="Delete Picklist">
<make-value entity-name="Picklist" value-field="lookupPKMap"/>
<set-pk-fields map="parameters" value-field="lookupPKMap"/>
<find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>

<!-- PicklistBin -->
<simple-method method-name="createPicklistBin" short-description="Create PicklistBin">
<make-value entity-name="PicklistBin" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>

<sequenced-id sequence-name="PicklistBin" field="newEntity.picklistBinId"/>
<field-to-result field="newEntity.picklistBinId" result-name="picklistBinId"/>

<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="deletePicklistBin" short-description="Delete PicklistBin">
<make-value entity-name="PicklistBin" value-field="lookupPKMap"/>
<set-pk-fields map="parameters" value-field="lookupPKMap"/>
<find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>

<!-- PicklistItem -->
<simple-method method-name="createPicklistItem" short-description="Create PicklistItem">
<make-value entity-name="PicklistItem" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>

<if-empty field="newEntity.itemStatusId">
<set value="PICKITEM_PENDING" field="newEntity.itemStatusId"/>
</if-empty>

<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updatePicklistItem" short-description="Update PicklistItem">
<make-value entity-name="PicklistItem" value-field="lookupPKMap"/>
<set-pk-fields map="parameters" value-field="lookupPKMap"/>
<find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>

<if-not-empty field="parameters.itemStatusId">
<if-compare-field field="parameters.itemStatusId" to-field="lookedUpValue.itemStatusId" operator="not-equals">
<!-- make sure a StatusValidChange record exists, if not return error -->
<entity-one entity-name="StatusValidChange" value-field="checkStatusValidChange" auto-field-map="false">
<field-map field-name="statusId" from-field="lookedUpValue.itemStatusId"/>
<field-map field-name="statusIdTo" from-field="parameters.itemStatusId"/>
</entity-one>
<if-empty field="checkStatusValidChange">
<set value="ERROR: Changing the status from ${lookedUpValue.itemStatusId} to ${parameters.itemStatusId} is not allowed." field="error_list[]"/>
</if-empty>
</if-compare-field>
</if-not-empty>

<!-- now finally check for errors -->
<check-errors/>

<!-- finally before setting nonpk fields, set the oldItemStatusId -->
<field-to-result field="lookedUpValue.itemStatusId" result-name="oldItemStatusId"/>

<!-- now that all changes have been checked, set the nonpks -->
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>

<!-- store the changes -->
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="deletePicklistItem" short-description="Delete PicklistItem">
<make-value entity-name="PicklistItem" value-field="lookupPKMap"/>
<set-pk-fields map="parameters" value-field="lookupPKMap"/>
<find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>

<!-- Service which edit a PicklistItem when a preparator choose a specified lot for one line order
This service is called by the request :
- editPicklistItem
@@ -1100,25 +967,6 @@ under the License.
<call-service service-name="updatePicklistItem" in-map-name="serviceCtx" include-user-login="true"/>
</simple-method>

<!-- PicklistRole -->
<simple-method method-name="createPicklistRole" short-description="Create PicklistRole">
<make-value entity-name="PicklistRole" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>

<if-empty field="newEntity.fromDate">
<now-timestamp field="newEntity.fromDate"/>
</if-empty>

<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="deletePicklistRole" short-description="Delete PicklistRole">
<make-value entity-name="PicklistRole" value-field="lookupPKMap"/>
<set-pk-fields map="parameters" value-field="lookupPKMap"/>
<find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>

<!-- ========================================================= -->
<!-- =========== Picklist Report/Display Services ============ -->
<!-- ========================================================= -->
@@ -164,6 +164,11 @@ under the License.
</eca>

<!-- picking ecas -->
<eca service="updatePicklist" event="commit">
<set field-name="statusIdTo" env-name="statusId"/>
<set field-name="statusId" env-name="oldStatusId"/>
<action service="createPicklistStatus" mode="sync"/>
</eca>
<eca service="updatePicklistItem" event="commit">
<condition-field field-name="itemStatusId" operator="not-equals" to-field-name="oldItemStatusId"/>
<action service="checkPicklistBinItemStatuses" mode="sync"/>
@@ -101,31 +101,24 @@ under the License.
</service>

<!-- Picklist -->
<service name="createPicklist" default-entity-name="Picklist" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="createPicklist" auth="true">
<service name="createPicklist" default-entity-name="Picklist" engine="entity-auto" invoke="create" auth="true">
<description>Create Picklist</description>
<permission-service service-name="facilityPermissionCheck" main-action="CREATE"/>
<auto-attributes include="pk" mode="OUT" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true">
<exclude field-name="picklistDate"/>
<exclude field-name="createdByUserLogin"/>
<exclude field-name="lastModifiedByUserLogin"/>
</auto-attributes>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<override name="statusId" default-value="PICKLIST_INPUT"/>
<override name="picklistDate" default-value="${date:nowTimestamp()}"/>
</service>
<service name="updatePicklist" default-entity-name="Picklist" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="updatePicklist" auth="true">
<service name="updatePicklist" default-entity-name="Picklist" engine="entity-auto" invoke="update" auth="true">
<description>Update Picklist</description>
<permission-service service-name="facilityPermissionCheck" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true">
<exclude field-name="picklistDate"/>
<exclude field-name="createdByUserLogin"/>
<exclude field-name="lastModifiedByUserLogin"/>
</auto-attributes>
<attribute name="oldStatusId" type="String" mode="OUT" optional="true"/>
</service>
<service name="deletePicklist" default-entity-name="Picklist" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="deletePicklist" auth="true">
<service name="deletePicklist" default-entity-name="Picklist" engine="entity-auto" invoke="delete" auth="true">
<description>Delete Picklist</description>
<permission-service service-name="facilityPermissionCheck" main-action="DELETE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
@@ -141,8 +134,7 @@ under the License.
</service>

<!-- PicklistBin -->
<service name="createPicklistBin" default-entity-name="PicklistBin" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="createPicklistBin" auth="true">
<service name="createPicklistBin" default-entity-name="PicklistBin" engine="entity-auto" invoke="create" auth="true">
<description>Create PicklistBin</description>
<permission-service service-name="facilityPermissionCheck" main-action="CREATE"/>
<auto-attributes include="pk" mode="OUT" optional="false"/>
@@ -154,8 +146,7 @@ under the License.
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
<service name="deletePicklistBin" default-entity-name="PicklistBin" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="deletePicklistBin" auth="true">
<service name="deletePicklistBin" default-entity-name="PicklistBin" engine="entity-auto" invoke="delete" auth="true">
<description>Delete PicklistBin</description>
<permission-service service-name="facilityPermissionCheck" main-action="DELETE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
@@ -168,24 +159,21 @@ under the License.
</service>

<!-- PicklistItem -->
<service name="createPicklistItem" default-entity-name="PicklistItem" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="createPicklistItem" auth="true">
<service name="createPicklistItem" default-entity-name="PicklistItem" engine="entity-auto" invoke="create" auth="true">
<description>Create PicklistItem</description>
<permission-service service-name="facilityPermissionCheck" main-action="CREATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="false"/>
<override name="itemStatusId" optional="true"/>
<override name="itemStatusId" optional="true" default-value="PICKITEM_PENDING"/>
</service>
<service name="updatePicklistItem" default-entity-name="PicklistItem" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="updatePicklistItem" auth="true">
<service name="updatePicklistItem" default-entity-name="PicklistItem" engine="entity-auto" invoke="update" auth="true">
<description>Update PicklistItem</description>
<permission-service service-name="facilityPermissionCheck" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<attribute name="oldItemStatusId" type="String" mode="OUT" optional="true"/>
</service>
<service name="deletePicklistItem" default-entity-name="PicklistItem" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="deletePicklistItem" auth="true">
<service name="deletePicklistItem" default-entity-name="PicklistItem" engine="entity-auto" invoke="delete" auth="true">
<description>Delete PicklistItem</description>
<permission-service service-name="facilityPermissionCheck" main-action="DELETE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
@@ -214,8 +202,7 @@ under the License.
</service>

<!-- PicklistRole -->
<service name="createPicklistRole" default-entity-name="PicklistRole" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="createPicklistRole" auth="true">
<service name="createPicklistRole" default-entity-name="PicklistRole" engine="entity-auto" invoke="create" auth="true">
<description>Create PicklistRole</description>
<permission-service service-name="facilityPermissionCheck" main-action="CREATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
@@ -234,10 +221,10 @@ under the License.
<exclude field-name="lastModifiedByUserLogin"/>
</auto-attributes>
</service>
<service name="deletePicklistRole" default-entity-name="PicklistRole" engine="simple"
location="component://product/minilang/shipment/picklist/PicklistServices.xml" invoke="deletePicklistRole" auth="true">
<service name="deletePicklistRole" default-entity-name="PicklistRole" engine="entity-auto" invoke="delete" auth="true">
<description>Delete PicklistRole</description>
<permission-service service-name="facilityPermissionCheck" main-action="DELETE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
</service>

</services>

0 comments on commit c16dad8

Please sign in to comment.
You can’t perform that action at this time.