Skip to content

Commit

Permalink
Improved: Convert OrderServices.xml mini-lang to groovyDSL (OFBIZ-998…
Browse files Browse the repository at this point in the history
…4) (#870)



Fix error in ensureRouteSegPackage
Migration of the services:

    recreateOrderAdjustments
    getOrderItemShipGroupEstimatedShipDate
    updateOrderNote
    getOrderStatus
    orderSequence_enforced
    createOrderHeader
    updateOrderHeader
    updateOrderItemShipGroup
    updateOrderContactMech
    addPaymentMethodToOrder
    checkOrderIsOnBackOrder
    createOrderItemChange
    createUpdateShippingAddress
    createUpdateBillingAddress
    createUpdateCreditCard
    setUnitPriceAsLastPrice
    cancelAllBackOrders
    updateShippingMethodAndCharges
    productAvailabilityByFacility
    createOrderPaymentApplication
    moveItemBetweenShipGroups

Thanks to Julien NICOLAS, Gil PORTENSEIGNE, Sebastian Berg and Leila MEKIKA for work on it

---------

Co-authored-by: Leila <leila.mekika@nereide.fr>
  • Loading branch information
nmalin and Leila authored Jan 3, 2025
1 parent e925d4e commit 57bf0ce
Show file tree
Hide file tree
Showing 9 changed files with 971 additions and 1,138 deletions.
90 changes: 0 additions & 90 deletions applications/order/minilang/customer/CheckoutMapProcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,96 +48,6 @@ under the License.
</process>
</simple-map-processor>

<simple-map-processor name="shipToAddress">
<process field="shipToContactMechId">
<copy to-field="contactMechId" set-if-null="false"/>
</process>
<process field="shipToName">
<copy to-field="toName" set-if-null="false"/>
</process>
<process field="shipToAttnName">
<copy to-field="attnName" set-if-null="false"/>
</process>
<process field="shipToAddress1">
<copy to-field="address1"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyAddressLine1MissingError"/>
</not-empty>
</process>
<process field="shipToAddress2">
<copy to-field="address2"/>
</process>
<process field="shipToCity">
<copy to-field="city"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyCityMissing"/>
</not-empty>
</process>
<process field="shipToStateProvinceGeoId">
<copy to-field="stateProvinceGeoId"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyStateMissingError"/>
</not-empty>
</process>
<process field="shipToPostalCode">
<copy to-field="postalCode"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyPostalInformationNotFound"/>
</not-empty>
</process>
<process field="shipToCountryGeoId">
<copy to-field="countryGeoId"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyCountryMissing"/>
</not-empty>
</process>
</simple-map-processor>

<simple-map-processor name="billToAddress">
<process field="billToContactMechId">
<copy to-field="contactMechId" set-if-null="false"/>
</process>
<process field="billToName">
<copy to-field="toName" set-if-null="false"/>
</process>
<process field="billToAttnName">
<copy to-field="attnName" set-if-null="false"/>
</process>
<process field="billToAddress1">
<copy to-field="address1"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyAddressLine1MissingError"/>
</not-empty>
</process>
<process field="billToAddress2">
<copy to-field="address2"/>
</process>
<process field="billToCity">
<copy to-field="city"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyCityMissing"/>
</not-empty>
</process>
<process field="billToStateProvinceGeoId">
<copy to-field="stateProvinceGeoId"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyStateMissingError"/>
</not-empty>
</process>
<process field="billToPostalCode">
<copy to-field="postalCode"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyPostalInformationNotFound"/>
</not-empty>
</process>
<process field="billToCountryGeoId">
<copy to-field="countryGeoId"/>
<not-empty>
<fail-property resource="PartyUiLabels" property="PartyCountryMissing"/>
</not-empty>
</process>
</simple-map-processor>

<simple-map-processor name="shipToPhone">
<process field="shipToCountryCode">
<copy to-field="countryCode"/>
Expand Down
978 changes: 0 additions & 978 deletions applications/order/minilang/order/OrderServices.xml

This file was deleted.

91 changes: 48 additions & 43 deletions applications/order/servicedef/services.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.ofbiz.order.customer

static Map shipToAddress(Map parameters) {
Map processedMap = [:]
if (parameters.shipToContactMechId) {
processedMap.contactMechId = parameters.shipToContactMechId
}
if (parameters.shipToName) {
processedMap.toName = parameters.shipToName
}
if (parameters.shipToAttnName) {
processedMap.attnName = parameters.shipToAttnName
}
if (parameters.shipToAddress1) {
processedMap.address1 = parameters.shipToAddress1
} else {
return error(label('PartyUiLabels', 'PartyAddressLine1MissingError'))
}
if (parameters.shipToAddress2) {
processedMap.address2 = parameters.shipToAddress2
}
if (parameters.shipToCity) {
processedMap.city = parameters.shipToCity
} else {
return error(label('PartyUiLabels', 'PartyCityMissing'))
}
if (parameters.shipToStateProvinceGeoId) {
processedMap.stateProvinceGeoId = parameters.shipToStateProvinceGeoId
} else {
return error(label('PartyUiLabels', 'PartyStateMissingError'))
}
if (parameters.shipToPostalCode) {
processedMap.postalCode = parameters.shipToPostalCode
} else {
return error(label('PartyUiLabels', 'PartyPostalInformationNotFound'))
}
if (parameters.shipToCountryGeoId) {
processedMap.countryGeoId = parameters.shipToCountryGeoId
} else {
return error(label('PartyUiLabels', 'PartyCountryMissing'))
}
return processedMap
}

static Map billToAddress(Map parameters) {
Map processedMap = [:]
if (parameters.billToContactMechId) {
processedMap.contactMechId = parameters.billToContactMechId
}
if (parameters.billToName) {
processedMap.toName = parameters.billToName
}
if (parameters.billToAttnName) {
processedMap.attnName = parameters.billToAttnName
}
if (parameters.billToAddress1) {
processedMap.address1 = parameters.billToAddress1
} else {
return error(label('PartyUiLabels', 'PartyAddressLine1MissingError'))
}
if (parameters.billToAddress2) {
processedMap.address2 = parameters.billToAddress2
}
if (parameters.billToCity) {
processedMap.city = parameters.billToCity
} else {
return error(label('PartyUiLabels', 'PartyCityMissing'))
}
if (parameters.billToStateProvinceGeoId) {
processedMap.stateProvinceGeoId = parameters.billToStateProvinceGeoId
} else {
return error(label('PartyUiLabels', 'PartyStateMissingError'))
}
if (parameters.billToPostalCode) {
processedMap.postalCode = parameters.billToPostalCode
} else {
return error(label('PartyUiLabels', 'PartyPostalInformationNotFound'))
}
if (parameters.billToCountryGeoId) {
processedMap.countryGeoId = parameters.billToCountryGeoId
} else {
return error(label('PartyUiLabels', 'PartyCountryMissing'))
}
return processedMap
}
Loading

0 comments on commit 57bf0ce

Please sign in to comment.