Author: jleroux
Date: Sat Oct 27 05:12:49 2007
New Revision: 589084
URL: http://svn.apache.org/viewvc?rev=589084&view=rev
Log:
A patch from Skip Dever "Entering a noteId in the AddPartyNote screen causes a
foreign key error" (https://issues.apache.org/jira/browse/OFBIZ-1357) -
OFBIZ-1357
Modified:
ofbiz/trunk/applications/party/config/PartyUiLabels.properties
ofbiz/trunk/applications/party/servicedef/services.xml
ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
Modified: ofbiz/trunk/applications/party/config/PartyUiLabels.properties
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/config/PartyUiLabels.properties?rev=589084&r1=589083&r2=589084&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/config/PartyUiLabels.properties (original)
+++ ofbiz/trunk/applications/party/config/PartyUiLabels.properties Sat Oct 27
05:12:49 2007
@@ -126,6 +126,7 @@
ParentGroupId=Parent Id
Parties=Parties
PartyAccount=Account
+PartyOptional=Optional
PartyActive=Active
PartyAddChildListsToCart=Add Child List To Cart
PartyAddCommContent=Add Communication Content
Modified: ofbiz/trunk/applications/party/servicedef/services.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/services.xml?rev=589084&r1=589083&r2=589084&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/party/servicedef/services.xml Sat Oct 27 05:12:49
2007
@@ -166,6 +166,7 @@
location="org.ofbiz.party.party.PartyServices"
invoke="createPartyNote" auth="true">
<description>Create a note item and associate with a party. If a
noteId is passed, creates an assoication to that note instead.</description>
<attribute name="partyId" type="String" mode="IN" optional="false"/>
+ <attribute name="noteName" type="String" mode="IN" optional="true"/>
<attribute name="noteId" type="String" mode="INOUT" optional="true"/>
<attribute name="note" type="String" mode="IN" optional="true"/>
</service>
Modified:
ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=589084&r1=589083&r2=589084&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
(original)
+++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
Sat Oct 27 05:12:49 2007
@@ -600,15 +600,32 @@
String noteString = (String) context.get("note");
String partyId = (String) context.get("partyId");
String noteId = (String) context.get("noteId");
+ String noteName = (String) context.get("noteName");
+
String errMsg = null;
Locale locale = (Locale) context.get("locale");
//Map noteCtx = UtilMisc.toMap("note", noteString, "userLogin",
userLogin);
+ //Make sure the note Id actually exists if one is passed to avoid a
foreign key error below
+ if(noteId != null) {
+ try {
+ GenericValue value = delegator.findByPrimaryKey("NoteData",
UtilMisc.toMap("noteId", noteId));
+ if(value == null) {
+ Debug.logError("ERROR: Note id does not exist for : " +
noteId + ", autogenerating." , module);
+ noteId = null;
+ }
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "ERROR: Note id does not exist for : " +
noteId + ", autogenerating." , module);
+ noteId = null;
+ }
+ }
+
// if no noteId is specified, then create and associate the note with
the userLogin
if (noteId == null) {
Map noteRes = null;
try {
- noteRes = dispatcher.runSync("createNote",
UtilMisc.toMap("partyId", userLogin.getString("partyId"), "note", noteString,
"userLogin", userLogin, "locale", locale));
+ noteRes = dispatcher.runSync("createNote",
UtilMisc.toMap("partyId", userLogin.getString("partyId"),
+ "note", noteString, "userLogin", userLogin, "locale",
locale, "noteName", noteName));
} catch (GenericServiceException e) {
Debug.logError(e, e.getMessage(), module);
return ServiceUtil.returnError("Unable to create Note: " +
e.getMessage());
Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml?rev=589084&r1=589083&r2=589084&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
(original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml Sat Oct
27 05:12:49 2007
@@ -244,6 +244,8 @@
focus-field-name="noteId">
<auto-fields-service service-name="createPartyNote"/>
<field name="partyId"><hidden/></field>
+ <field name="noteId"
tooltip="${uiLabelMap.PartyOptional}"><hidden/></field>
+ <field name="noteName" tooltip="${uiLabelMap.PartyOptional}"> </field>
<field name="note"><textarea cols="70" rows="10"/></field>
<field name="submitButton" title="${uiLabelMap.CommonSave}"
widget-style="smallSubmit"><submit button-type="text-link"/></field>
<field name="cancelLink" title="${uiLabelMap.CommonEmptyHeader}"
widget-style="smallSubmit"><hyperlink target="${donePage}?partyId=${partyId}"
also-hidden="false" description="${uiLabelMap.CommonCancelDone}"/></field>