Author: nmalin
Date: Fri Apr 27 07:21:47 2018
New Revision: 1830301
URL: http://svn.apache.org/viewvc?rev=1830301&view=rev
Log:
Fixed: ConfigXMLReader - Events are not executed in the order defined
(OFBIZ-10369)
The events contained in the controller configuration for first-visit, pre-post
processor and before-after login are executed in arbitrary order rather than
the defined order.
If we define an event configuration as follow:
<after-login>
<event name=keepCartUpdated type=java
path=org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents
invoke=keepCartUpdated/>
<event name=restoreAutoSaveList type=java
path=org.apache.ofbiz.order.shoppinglist.ShoppingListEvents
invoke=restoreAutoSaveList/>
<event name=saveCartToAutoSaveList type=java
path=org.apache.ofbiz.order.shoppinglist.ShoppingListEvents
invoke=saveCartToAutoSaveList/>
</after-login>
We wait that OFBIz run keepCartUpdated, restoreAutoSaveList and after
saveCartToAutoSaveList event but the HashMap who organise them return arbitrary
order and can return saveCartToAutoSaveList, keepCartUpdated and
restoreAutoSaveList. Convert the HashMap to LinkedHashMap help to keep the
loaded order.
Thanks to Vikas Mayur for solve this issue
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/invoice/EditInvoice.groovy
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
ofbiz/ofbiz-framework/trunk/applications/accounting/template/invoice/InvoiceReportContactMechs.fo.ftl
ofbiz/ofbiz-framework/trunk/applications/accounting/widget/AccountingPrintScreens.xml
ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/accounting-entitymodel.xml
ofbiz/ofbiz-framework/trunk/applications/order/template/order/CompanyHeader.fo.ftl
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java
ofbiz/ofbiz-framework/trunk/framework/common/ofbiz-component.xml
ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/invoice/EditInvoice.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/invoice/EditInvoice.groovy?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/invoice/EditInvoice.groovy
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/invoice/EditInvoice.groovy
Fri Apr 27 07:21:47 2018
@@ -20,6 +20,8 @@
import org.apache.ofbiz.accounting.invoice.InvoiceWorker
import org.apache.ofbiz.base.util.UtilNumber
+import org.apache.ofbiz.party.party.PartyHelper
+import org.apache.ofbiz.party.party.PartyWorker
import java.text.DateFormat
@@ -49,7 +51,12 @@ if (invoice) {
context.billToParty = billToParty
sendingParty = InvoiceWorker.getSendFromParty(invoice)
context.sendingParty = sendingParty
+ shippingAddress = InvoiceWorker.getShippingAddress(invoice)
+ context.shippingAddress = shippingAddress
+ if (sendingParty) {
+ List fiscalIdentifications =
PartyHelper.getPartyIdentificationByType(sendingParty, "LEGAL_IDENTIFICATION")
+ }
if (currency && !invoice.getString("currencyUomId").equals(currency)) {
conversionRate =
InvoiceWorker.getInvoiceCurrencyConversionRate(invoice)
invoice.currencyUomId = currency
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
Fri Apr 27 07:21:47 2018
@@ -316,6 +316,31 @@ public final class InvoiceWorker {
}
/**
+ * Method to obtain the shipping address from an invoice
+ * first resolve from InvoiceContactMech and if not found try from
Shipment if present
+ * @param invoice GenericValue object of the Invoice
+ * @return GenericValue object of the PostalAddress
+ */
+ public static GenericValue getShippingAddress(GenericValue invoice) {
+ GenericValue postalAddress = getInvoiceAddressByType(invoice,
"SHIPPING_LOCATION", false);
+ Delegator delegator = invoice.getDelegator();
+ if (postalAddress == null) {
+ try {
+ GenericValue shipmentView =
EntityQuery.use(delegator).from("InvoiceItemAndShipmentView")
+ .where("invoiceId",
invoice.get("invoiceId")).queryFirst();
+ if (shipmentView != null) {
+ GenericValue shipment =
EntityQuery.use(delegator).from("Shipment")
+ .where("shipmentId",
shipmentView.get("shipmentId")).queryOne();
+ postalAddress =
shipment.getRelatedOne("DestinationPostalAddress");
+ }
+ } catch (GenericEntityException e) {
+ Debug.logError("Touble getting ContactMech entity from OISG",
module);
+ }
+ }
+ return postalAddress;
+ }
+
+ /**
* Method to obtain the billing address for an invoice
* @param invoice GenericValue object of the Invoice
* @return GenericValue object of the PostalAddress
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/template/invoice/InvoiceReportContactMechs.fo.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/template/invoice/InvoiceReportContactMechs.fo.ftl?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/accounting/template/invoice/InvoiceReportContactMechs.fo.ftl
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/accounting/template/invoice/InvoiceReportContactMechs.fo.ftl
Fri Apr 27 07:21:47 2018
@@ -19,26 +19,24 @@ under the License.
<#escape x as x?xml>
<fo:table table-layout="fixed" width="100%" space-after="0.3in">
<fo:table-column column-width="3.5in"/>
+ <fo:table-column column-width="3.5in"/>
<fo:table-body>
<fo:table-row >
<fo:table-cell>
<fo:block>_______________________________</fo:block>
</fo:table-cell>
+ <fo:table-cell>
+ <fo:block>_______________________________</fo:block>
+ </fo:table-cell>
</fo:table-row>
<fo:table-row >
<fo:table-cell>
<fo:block>${uiLabelMap.CommonTo}: </fo:block>
- <#if billingAddress?has_content>
+ <#if billingAddress??>
<#assign billToPartyNameResult =
dispatcher.runSync("getPartyNameForDate",
Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("partyId",
billToParty.partyId, "compareDate", invoice.invoiceDate, "userLogin",
userLogin))/>
<fo:block>${billToPartyNameResult.fullName?default(billingAddress.toName)?default("Billing
Name Not Found")}</fo:block>
- <#if billingAddress.attnName??>
- <fo:block>${billingAddress.attnName}</fo:block>
- </#if>
- <fo:block>${billingAddress.address1!}</fo:block>
- <#if billingAddress.address2??>
- <fo:block>${billingAddress.address2}</fo:block>
- </#if>
- <fo:block>${billingAddress.city!}
${billingAddress.stateProvinceGeoId!} ${billingAddress.postalCode!}</fo:block>
+ ${setContextField("postalAddress", billingAddress)}
+
${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddressPdfFormatter")}
<#if billToPartyTaxId?has_content>
<fo:block>${uiLabelMap.PartyTaxId}:
${billToPartyTaxId}</fo:block>
</#if>
@@ -46,6 +44,16 @@ under the License.
<fo:block>${uiLabelMap.AccountingNoGenBilAddressFound}${billToParty.partyId}</fo:block>
</#if>
</fo:table-cell>
+ <fo:table-cell>
+ <#if shippingAddress??>
+ <fo:block>${uiLabelMap.OrderShipTo}: </fo:block>
+ ${setContextField("postalAddress", shippingAddress)}
+
${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddressPdfFormatter")}
+ <#else>
+ <fo:block/>
+ </#if>
+ </fo:table-cell>
+
</fo:table-row>
</fo:table-body>
</fo:table>
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/widget/AccountingPrintScreens.xml
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/widget/AccountingPrintScreens.xml?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/accounting/widget/AccountingPrintScreens.xml
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/accounting/widget/AccountingPrintScreens.xml
Fri Apr 27 07:21:47 2018
@@ -30,6 +30,7 @@ under the License.
<property-map resource="AccountingUiLabels"
map-name="uiLabelMap" global="true"/>
<property-map resource="ProductUiLabels" map-name="uiLabelMap"
global="true"/>
<property-map resource="PartyUiLabels" map-name="uiLabelMap"
global="true"/>
+ <property-map resource="OrderUiLabels" map-name="uiLabelMap"
global="true"/>
<property-map resource="CommonUiLabels" map-name="uiLabelMap"
global="true"/>
<set field="titleProperty" value="AccountingInvoice"/>
<script
location="component://accounting/groovyScripts/invoice/EditInvoice.groovy"/>
Modified:
ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/accounting-entitymodel.xml
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/accounting-entitymodel.xml?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/accounting-entitymodel.xml
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/accounting-entitymodel.xml
Fri Apr 27 07:21:47 2018
@@ -1707,6 +1707,24 @@ under the License.
<key-map field-name="invoiceItemSeqId"/>
</view-link>
</view-entity>
+ <view-entity entity-name="InvoiceItemAndShipmentView"
package-name="org.apache.ofbiz.accounting.invoice">
+ <member-entity entity-alias="INVITM" entity-name="InvoiceItem"/>
+ <member-entity entity-alias="ORDBIL" entity-name="OrderItemBilling"/>
+ <member-entity entity-alias="ITMISS" entity-name="ItemIssuance"/>
+ <member-entity entity-alias="SHIP" entity-name="Shipment"/>
+ <alias-all entity-alias="INVITM"/>
+ <alias-all entity-alias="SHIP"/>
+ <view-link entity-alias="INVITM" rel-entity-alias="ORDBIL">
+ <key-map field-name="invoiceId"/>
+ <key-map field-name="invoiceItemSeqId"/>
+ </view-link>
+ <view-link entity-alias="ORDBIL" rel-entity-alias="ITMISS">
+ <key-map field-name="itemIssuanceId"/>
+ </view-link>
+ <view-link entity-alias="ITMISS" rel-entity-alias="SHIP">
+ <key-map field-name="shipmentId"/>
+ </view-link>
+ </view-entity>
<view-entity entity-name="InvoiceContentAndInfo"
package-name="org.apache.ofbiz.accounting.invoice"
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/template/order/CompanyHeader.fo.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/template/order/CompanyHeader.fo.ftl?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/template/order/CompanyHeader.fo.ftl
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/template/order/CompanyHeader.fo.ftl
Fri Apr 27 07:21:47 2018
@@ -34,7 +34,7 @@ under the License.
<fo:block>${uiLabelMap.CommonFor}: ${companyName}</fo:block>
</#if>
- <#if sendingPartyTaxId?? || phone?? || email?? || website?? ||
eftAccount??>
+ <#if sendingPartyTaxId?? || phone?? || email?? || website?? ||
eftAccount?? || fiscalIdentifications??>
<fo:list-block provisional-distance-between-starts=".5in">
<#if sendingPartyTaxId??>
<fo:list-item>
@@ -102,6 +102,18 @@ under the License.
</fo:list-item-body>
</fo:list-item>
</#if>
+ <#if fiscalIdentifications??>
+ <#list fiscalIdentifications as fiscalIdentification>
+ <fo:list-item>
+ <fo:list-item-label>
+ <fo:block>${fiscalIdentification.get('description',
locale)}:</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>${fiscalIdentification.idValue!}</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </#list>
+ </#if>
</fo:list-block>
</#if>
</fo:block>
Modified:
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java
Fri Apr 27 07:21:47 2018
@@ -19,13 +19,21 @@
package org.apache.ofbiz.party.party;
+import java.util.List;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.UtilFormatOut;
+import org.apache.ofbiz.base.util.UtilMisc;
+import org.apache.ofbiz.base.util.UtilValidate;
import org.apache.ofbiz.entity.Delegator;
import org.apache.ofbiz.entity.GenericEntityException;
import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.condition.EntityCondition;
+import org.apache.ofbiz.entity.condition.EntityExpr;
+import org.apache.ofbiz.entity.condition.EntityJoinOperator;
import org.apache.ofbiz.entity.model.ModelEntity;
import org.apache.ofbiz.entity.util.EntityQuery;
+import org.apache.ofbiz.entity.util.EntityTypeUtil;
+import org.apache.ofbiz.entity.util.EntityUtil;
/**
* PartyHelper
@@ -100,4 +108,35 @@ public class PartyHelper {
}
return result.toString();
}
+
+
+ public static List<GenericValue> getPartyIdentificationByType(GenericValue
party, String partyIdentificationTypeId) {
+ Delegator delegator = party.getDelegator();
+
+ GenericValue partyIdentificationType = null;
+ try {
+ partyIdentificationType =
EntityQuery.use(delegator).from("PartyIdentificationType")
+ .where("partyIdentificationTypeId",
partyIdentificationTypeId).cache().queryOne();
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error finding PartyIdentificationType in
getPartyIdentificationByType", module);
+ }
+ List<GenericValue> childPartyIdentificationTypes =
EntityTypeUtil.getDescendantTypes(partyIdentificationType);
+ List<String> childPartyIdentificationTypeIds = null;
+ if (UtilValidate.isNotEmpty(childPartyIdentificationTypes)) {
+ childPartyIdentificationTypeIds =
EntityUtil.getFieldListFromEntityList(childPartyIdentificationTypes,
"partyIdentificationTypeId", true);
+ } else {
+ childPartyIdentificationTypeIds =
UtilMisc.toList(partyIdentificationTypeId);
+ }
+ EntityCondition condition =
EntityCondition.makeCondition(UtilMisc.toList(
+ EntityExpr.makeCondition("partyId", party.get("partyId")),
+ EntityExpr.makeCondition("partyIdentificationTypeId",
EntityJoinOperator.IN, childPartyIdentificationTypeIds)
+ ));
+ List<GenericValue> partyIdentifications = null;
+ try {
+ partyIdentifications =
EntityQuery.use(delegator).from("PartyIdentification").where(condition).cache().queryList();
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error finding PartyIdentification in
getPartyIdentificationByType", module);
+ }
+ return partyIdentifications;
+ }
}
Modified: ofbiz/ofbiz-framework/trunk/framework/common/ofbiz-component.xml
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/ofbiz-component.xml?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/ofbiz-component.xml (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/ofbiz-component.xml Fri Apr 27
07:21:47 2018
@@ -25,37 +25,7 @@ under the License.
<classpath type="dir" location="config"/>
<entity-resource type="model" reader-name="main" loader="main"
location="entitydef/entitymodel.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/CommonSecurityPermissionSeedData.xml"/>
- <entity-resource type="data" reader-name="demo" loader="main"
location="data/CommonSecurityGroupDemoData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/CommonSystemPropertyData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/CommonTypeData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/CurrencyData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/CountryCodeData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_AU.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_BG.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_BR.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_CA.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_CH.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_CN.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_CO.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_DE.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_ES.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_FR.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_IE.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_IL.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_IN.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_IT.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_JP.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_MX.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_MY.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_NL.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_NZ.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_PL.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_TH.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_UK.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/GeoData_US.xml"/>
<entity-resource type="data" reader-name="seed" loader="main"
location="data/LanguageData.xml"/>
Modified:
ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java?rev=1830301&r1=1830300&r2=1830301&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
(original)
+++
ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
Fri Apr 27 07:21:47 2018
@@ -25,6 +25,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -183,11 +184,11 @@ public class ConfigXMLReader {
private String defaultRequest;
private String statusCode;
private List<URL> includes = new ArrayList<URL>();
- private Map<String, Event> firstVisitEventList = new HashMap<String,
Event>();
- private Map<String, Event> preprocessorEventList = new HashMap<String,
Event>();
- private Map<String, Event> postprocessorEventList = new
HashMap<String, Event>();
- private Map<String, Event> afterLoginEventList = new HashMap<String,
Event>();
- private Map<String, Event> beforeLogoutEventList = new HashMap<String,
Event>();
+ private Map<String, Event> firstVisitEventList = new
LinkedHashMap<String, Event>();
+ private Map<String, Event> preprocessorEventList = new
LinkedHashMap<String, Event>();
+ private Map<String, Event> postprocessorEventList = new
LinkedHashMap<String, Event>();
+ private Map<String, Event> afterLoginEventList = new
LinkedHashMap<String, Event>();
+ private Map<String, Event> beforeLogoutEventList = new
LinkedHashMap<String, Event>();
private Map<String, String> eventHandlerMap = new HashMap<String,
String>();
private Map<String, String> viewHandlerMap = new HashMap<String,
String>();
private Map<String, RequestMap> requestMapMap = new HashMap<String,
RequestMap>();