Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: Convert OrderServices.xml mini-lang to groovyDSL (OFBIZ-9984) #870

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading