Author: ashish
Date: Mon Jan 3 12:53:29 2011
New Revision: 1054599
URL: http://svn.apache.org/viewvc?rev=1054599&view=rev
Log:
First pass, adding new entity ReturnContactMech that will help us to store and
fetch the correct values for email, phone & address for the new exchange order.
Providing service definition and its implementation.
Adding conditional check for adding "ORDER_EMAIL" for the newly created party
from the ecommerce store. This check is added because you couldn't see the
party's email that has been provided at the time of checkout if you update
party's email from Order View page. It may happen that you wanted to use the
same email address again if that email wouldn't get expired.
Work done by me & Amit.
Modified:
ofbiz/trunk/applications/order/entitydef/entitymodel.xml
ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml
ofbiz/trunk/applications/order/servicedef/services_return.xml
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
Modified: ofbiz/trunk/applications/order/entitydef/entitymodel.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel.xml?rev=1054599&r1=1054598&r2=1054599&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/order/entitydef/entitymodel.xml Mon Jan 3
12:53:29 2011
@@ -2661,6 +2661,27 @@ under the License.
</relation>
</entity>
+ <entity entity-name="ReturnContactMech"
+ package-name="org.ofbiz.order.return"
+ never-cache="true"
+ title="Retrun Contact Mechanism Entity">
+ <field name="returnId" type="id-ne"></field>
+ <field name="contactMechPurposeTypeId" type="id-ne"></field>
+ <field name="contactMechId" type="id-ne"></field>
+ <prim-key field="returnId"/>
+ <prim-key field="contactMechPurposeTypeId"/>
+ <prim-key field="contactMechId"/>
+ <relation type="one" fk-name="RETURN_CMECH_HDR"
rel-entity-name="ReturnHeader">
+ <key-map field-name="returnId"/>
+ </relation>
+ <relation type="one" fk-name="RETURN_CMECH_CM"
rel-entity-name="ContactMech">
+ <key-map field-name="contactMechId"/>
+ </relation>
+ <relation type="one" fk-name="RETURN_CMECH_CMPT"
rel-entity-name="ContactMechPurposeType">
+ <key-map field-name="contactMechPurposeTypeId"/>
+ </relation>
+ </entity>
+
<!-- ========================================================= -->
<!-- org.ofbiz.order.shoppingcart -->
<!-- ========================================================= -->
Modified:
ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml?rev=1054599&r1=1054598&r2=1054599&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml
(original)
+++
ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml
Mon Jan 3 12:53:29 2011
@@ -1106,4 +1106,34 @@ under the License.
<now-timestamp field="newEntity.statusDatetime"/>
<create-value value-field="newEntity"/>
</simple-method>
+
+ <simple-method method-name="updateReturnContactMech"
short-description="Update ReturnContactMech">
+ <check-permission permission="ORDERMGR" action="_UPDATE">
+ <fail-property resource="OrderErrorUiLabels"
property="OrderSecurityErrorToRunUpdateOrderContactMech"/>
+ </check-permission>
+ <check-errors/>
+
+ <make-value value-field="returnContactMechMap"
entity-name="ReturnContactMech"/>
+
+ <set-pk-fields map="parameters" value-field="returnContactMechMap"/>
+ <entity-one value-field="returnHeader" entity-name="ReturnHeader"/>
+ <set from-field="parameters.returnId"
field="createReturnContactMechMap.returnId"/>
+ <set from-field="parameters.contactMechPurposeTypeId"
field="createReturnContactMechMap.contactMechPurposeTypeId"/>
+ <set from-field="parameters.contactMechId"
field="createReturnContactMechMap.contactMechId"/>
+
+ <find-by-and entity-name="ReturnContactMech"
map="createReturnContactMechMap" list="returnContactMechList"/>
+ <!-- If returnContactMechList value is null then create new entry in
ReturnContactMech entity-->
+ <if-empty field="returnContactMechList">
+ <if-compare value="SHIPPING_LOCATION"
field="parameters.contactMechPurposeTypeId" operator="equals">
+ <set field="returnHeader.originContactMechId"
from-field="createReturnContactMechMap.contactMechId"/>
+ <store-value value-field="returnHeader"/>
+ </if-compare>
+ <call-service service-name="createReturnContactMech"
in-map-name="createReturnContactMechMap" include-user-login="true"/>
+ <set from-field="parameters.returnId"
field="deleteReturnContactMechMap.returnId"/>
+ <set from-field="parameters.oldContactMechId"
field="deleteReturnContactMechMap.contactMechId"/>
+ <set from-field="parameters.contactMechPurposeTypeId"
field="deleteReturnContactMechMap.contactMechPurposeTypeId"/>
+ <call-service service-name="deleteReturnContactMech"
in-map-name="deleteReturnContactMechMap" include-user-login="true"/>
+ </if-empty>
+ <store-value value-field="returnContactMechMap"/>
+ </simple-method>
</simple-methods>
Modified: ofbiz/trunk/applications/order/servicedef/services_return.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_return.xml?rev=1054599&r1=1054598&r2=1054599&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services_return.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services_return.xml Mon Jan 3
12:53:29 2011
@@ -349,4 +349,21 @@ under the License.
<attribute name="returnId" type="String" mode="IN" optional="false"/>
<attribute name="returnItemSeqId" type="String" mode="IN"
optional="true"/>
</service>
+
+ <!-- Return ContactMech Services -->
+ <service name="createReturnContactMech"
default-entity-name="ReturnContactMech" engine="entity-auto" invoke="create"
auth="true">
+ <description>Create a ReturnContactMech</description>
+ <auto-attributes include="pk" mode="IN" optional="false"/>
+ <auto-attributes include="nonpk" mode="IN" optional="true"/>
+ </service>
+ <service name="updateReturnContactMech" engine="simple"
+
location="component://order/script/org/ofbiz/order/order/OrderReturnServices.xml"
invoke="updateReturnContactMech" auth="true"
default-entity-name="ReturnContactMech">
+ <description>Update Return Contact Mech</description>
+ <auto-attributes include="pk" mode="IN" optional="false"/>
+ <attribute name="oldContactMechId" type="String" mode="IN"
optional="true"/>
+ </service>
+ <service name="deleteReturnContactMech"
default-entity-name="ReturnContactMech" engine="entity-auto" invoke="delete"
auth="true">
+ <description>Delete a ReturnContactMech</description>
+ <auto-attributes include="pk" mode="IN" optional="false"/>
+ </service>
</services>
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=1054599&r1=1054598&r2=1054599&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
Mon Jan 3 12:53:29 2011
@@ -718,6 +718,11 @@ public class CheckOutHelper {
GenericValue orderContactMech =
this.delegator.makeValue("OrderContactMech",
UtilMisc.toMap("orderId", orderId, "contactMechId",
email.getString("contactMechId"), "contactMechPurposeTypeId", "ORDER_EMAIL"));
toBeStored.add(orderContactMech);
+ if
(UtilValidate.isEmpty(ContactHelper.getContactMechByPurpose(party,
"ORDER_EMAIL", false))) {
+ GenericValue partyContactMechPurpose =
this.delegator.makeValue("PartyContactMechPurpose",
+ UtilMisc.toMap("partyId",
party.getString("partyId"), "contactMechId", email.getString("contactMechId"),
"contactMechPurposeTypeId", "ORDER_EMAIL", "fromDate",
UtilDateTime.nowTimestamp()));
+ toBeStored.add(partyContactMechPurpose);
+ }
}
}