moved Opportunity services to Order component where entity definitions are. Added eca to add Account Party when partyId is entered in create opportunity form.

Updated names of artifacts to match entity they deal with.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@778515 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Anil Patel
2009-05-25 21:34:04 +00:00
parent d16e9e2c68
commit 8555fc06e3
9 changed files with 144 additions and 99 deletions
@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="createOpportunity" short-description="Create Opportunity for SFA">
<make-value entity-name="SalesOpportunity" value-field="newEntity"/>
<if-empty field="parameters.salesOpportunityId">
<sequenced-id sequence-name="SalesOpportunity" field="parameters.salesOpportunityId"/>
</if-empty>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set from-field="userLogin.userLoginId" field="newEntity.createdByUserLogin"/>
<field-to-result field="parameters.salesOpportunityId" result-name="salesOpportunityId"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateOpportunity" short-description="Update an opportunity">
<entity-one entity-name="SalesOpportunity" value-field="lookedUpValue"/>
<set-nonpk-fields value-field="lookedUpValue" map="parameters"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
</simple-methods>
@@ -388,22 +388,6 @@ under the License.
<attribute name="altPermission" type="String" mode="IN" optional="true"/>
</service>
<!-- opportunity service -->
<service name="createOpportunity" engine="simple" default-entity-name="SalesOpportunity"
location="component://marketing/script/org/ofbiz/sfa/opportunity/OpportunityServices.xml" invoke="createOpportunity">
<description>Create an opportunity</description>
<auto-attributes mode="INOUT" include="pk" optional="true"/>
<auto-attributes mode="IN" include="nonpk" optional="true">
<exclude field-name="createdByUserLogin"/>
</auto-attributes>
</service>
<service name="updateOpportunity" engine="simple" default-entity-name="SalesOpportunity"
location="component://marketing/script/org/ofbiz/sfa/opportunity/OpportunityServices.xml" invoke="updateOpportunity">
<description>Update an opportnity</description>
<auto-attributes mode="IN" include="pk" optional="false"/>
<auto-attributes mode="IN" include="nonpk" optional="true"/>
</service>
<!-- lead services -->
<service name="createLead" engine="simple" location="component://marketing/script/org/ofbiz/sfa/lead/LeadServices.xml" invoke="createLead">
<description>Create a Lead Person or Group</description>
@@ -30,30 +30,30 @@ under the License.
<security https="true" auth="true"/>
<response name="success" type="view" value="main"/>
</request-map>
<!-- Opportunity Requests -->
<request-map uri="FindOpportunity">
<!-- Sales Opportunity Requests -->
<request-map uri="FindSalesOpportunity">
<security https="true" auth="true"/>
<response name="success" type="view" value="FindOpportunity"/>
<response name="success" type="view" value="FindSalesOpportunity"/>
</request-map>
<request-map uri="ViewOpportunity">
<request-map uri="ViewSalesOpportunity">
<security https="true" auth="true"/>
<response name="success" type="view" value="ViewOpportunity"/>
<response name="success" type="view" value="ViewSalesOpportunity"/>
</request-map>
<request-map uri="EditOpportunity">
<request-map uri="EditSalesOpportunity">
<security https="true" auth="true"/>
<response name="success" type="view" value="EditOpportunity"/>
<response name="success" type="view" value="EditSalesOpportunity"/>
</request-map>
<request-map uri="createOpportunity">
<request-map uri="createSalesOpportunity">
<security https="true" auth="true"/>
<event type="service" invoke="createOpportunity"/>
<response name="success" type="view" value="ViewOpportunity"/>
<response name="error" type="view" value="EditOpportunity"/>
<event type="service" invoke="createSalesOpportunity"/>
<response name="success" type="view" value="ViewSalesOpportunity"/>
<response name="error" type="view" value="EditSalesOpportunity"/>
</request-map>
<request-map uri="updateOpportunity">
<request-map uri="updateSalesOpportunity">
<security https="true" auth="true"/>
<event type="service" invoke="updateOpportunity"/>
<response name="success" type="request" value="ViewOpportunity"/>
<response name="error" type="view" value="EditOpportunity"/>
<event type="service" invoke="updateSalesOpportunity"/>
<response name="success" type="request" value="ViewSalesOpportunity"/>
<response name="error" type="view" value="EditSalesOpportunity"/>
</request-map>
<!-- Account Entry Requests -->
@@ -230,9 +230,9 @@ under the License.
<view-map name="main" type="screen" page="component://marketing/widget/sfa/CommonScreens.xml#main"/>
<view-map name="viewprofile" type="screen" page="component://marketing/widget/sfa/CommonScreens.xml#ViewProfile"/>
<view-map name="FindOpportunity" type="screen" page="component://marketing/widget/sfa/OpportunityScreens.xml#FindOpportunity"/>
<view-map name="ViewOpportunity" type="screen" page="component://marketing/widget/sfa/OpportunityScreens.xml#ViewOpportunity"/>
<view-map name="EditOpportunity" type="screen" page="component://marketing/widget/sfa/OpportunityScreens.xml#EditOpportunity"/>
<view-map name="FindSalesOpportunity" type="screen" page="component://marketing/widget/sfa/OpportunityScreens.xml#FindSalesOpportunity"/>
<view-map name="ViewSalesOpportunity" type="screen" page="component://marketing/widget/sfa/OpportunityScreens.xml#ViewSalesOpportunity"/>
<view-map name="EditSalesOpportunity" type="screen" page="component://marketing/widget/sfa/OpportunityScreens.xml#EditSalesOpportunity"/>
<view-map name="FindAccounts" type="screen" page="component://marketing/widget/sfa/AccountScreens.xml#FindAccounts"/>
<view-map name="NewAccount" type="screen" page="component://marketing/widget/sfa/AccountScreens.xml#NewAccount"/>
@@ -21,7 +21,7 @@ under the License.
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
<screen name="FindOpportunity">
<screen name="FindSalesOpportunity">
<section>
<actions>
<set field="titleProperty" value="SfaFindOpportunities"/>
@@ -39,8 +39,8 @@ under the License.
<container style="screenlet-body">
<section>
<widgets>
<container><link target="EditOpportunity" text="${uiLabelMap.CommonCreateNew}" style="buttontext"/></container>
<include-form name="FindOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
<container><link target="EditSalesOpportunity" text="${uiLabelMap.CommonCreateNew}" style="buttontext"/></container>
<include-form name="FindSalesOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
</widgets>
</section>
</container>
@@ -55,7 +55,7 @@ under the License.
<container>
<section>
<widgets>
<include-form name="ListOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
<include-form name="ListSalesOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
</widgets>
</section>
</container>
@@ -67,13 +67,18 @@ under the License.
</section>
</screen>
<screen name="EditOpportunity">
<screen name="EditSalesOpportunity">
<section>
<actions>
<set field="titleProperty" value="SfaEditOpportunity"/>
<set field="tabButtonItem" value="EditOpportunity"/>
<set field="tabButtonItem" value="EditSalesOpportunity"/>
<set field="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<entity-one entity-name="SalesOpportunity" value-field="salesOpportunity"/>
<service service-name="findPartyInSalesOpportunityRole" result-map="findResult">
<field-map field-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<field-map field-name="roleTypeId" value="ACCOUNT"/>
</service>
<set field="accountPartyId" from-field="findResult.partyId"/>
</actions>
<widgets>
<decorator-screen name="CommonOpportunityDecorator" location="${parameters.mainDecoratorLocation}">
@@ -87,7 +92,7 @@ under the License.
<container style="screenlet-body">
<section>
<widgets>
<include-form name="EditOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
<include-form name="EditSalesOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
</widgets>
</section>
</container>
@@ -98,11 +103,11 @@ under the License.
</section>
</screen>
<screen name="ViewOpportunity">
<screen name="ViewSalesOpportunity">
<section>
<actions>
<set field="titleProperty" value="SfaOpportunityInfo"/>
<set field="tabButtonItem" value="ViewOpportunity"/>
<set field="tabButtonItem" value="ViewSalesOpportunity"/>
<set field="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<entity-one entity-name="SalesOpportunity" value-field="salesOpportunity"/>
</actions>
@@ -118,7 +123,7 @@ under the License.
<container style="screenlet-body">
<section>
<widgets>
<include-form name="ViewOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
<include-form name="ViewSalesOpportunity" location="component://marketing/widget/sfa/forms/OpportunityForms.xml"/>
</widgets>
</section>
</container>
@@ -26,17 +26,17 @@ under the License.
<menu-item name="Events" title="${uiLabelMap.SfaEvents}" widget-style="disabled"><link target="#" url-mode="plain"/></menu-item>
<menu-item name="Documents" title="${uiLabelMap.SfaDocuments}" widget-style="disabled"><link target="#" url-mode="plain"/></menu-item>
<menu-item name="Forecast" title="${uiLabelMap.SfaForecasts}"><link target="FindSalesForecast"/></menu-item>
<menu-item name="Opportunities" title="${uiLabelMap.SfaOpportunities}"><link target="FindOpportunity"/></menu-item>
<menu-item name="Opportunities" title="${uiLabelMap.SfaOpportunities}"><link target="FindSalesOpportunity"/></menu-item>
</menu>
<menu name="OpportunityTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
<menu-item name="ViewOpportunity" title="${uiLabelMap.SfaOpportunitySummary}">
<link target="ViewOpportunity">
<menu-item name="ViewSalesOpportunity" title="${uiLabelMap.SfaOpportunitySummary}">
<link target="ViewSalesOpportunity">
<parameter param-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
</link>
</menu-item>
<menu-item name="EditOpportunity" title="${uiLabelMap.SfaEditOpportunity}">
<link target="EditOpportunity">
<menu-item name="EditSalesOpportunity" title="${uiLabelMap.SfaEditOpportunity}">
<link target="EditSalesOpportunity">
<parameter param-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
</link>
</menu-item>
@@ -21,7 +21,7 @@ under the License.
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
<form name="FindOpportunity" type="single" target="FindOpportunity"
<form name="FindSalesOpportunity" type="single" target="FindSalesOpportunity"
header-row-style="header-row" default-table-style="basic-table">
<field name="salesOpportunityId"><hidden/></field>
<field name="opportunityName" title="${uiLabelMap.SfaFindOpportunities}"><text-find size="25" default-option="contains"></text-find></field>
@@ -42,7 +42,7 @@ under the License.
<field name="searchButton" widget-style="smallSubmit"><submit/></field>
</form>
<form name="ListOpportunity" type="list" list-name="listIt" paginate-target="FindOpportunity" view-size="20"
<form name="ListSalesOpportunity" type="list" list-name="listIt" paginate-target="FindSalesOpportunity" view-size="20"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar" separate-columns="true">
<actions>
<set field="parameters.noConditionFind" value="Y"/>
@@ -54,7 +54,7 @@ under the License.
</actions>
<field name="salesOpportunityId"><hidden/></field>
<field name="opportunityName" title="${uiLabelMap.SfaOpportunityName}">
<hyperlink target="ViewOpportunity" description="${opportunityName}">
<hyperlink target="ViewSalesOpportunity" description="${opportunityName}">
<parameter param-name="salesOpportunityId"/>
</hyperlink>
</field>
@@ -62,25 +62,25 @@ under the License.
<field name="estimatedAmount" title="${uiLabelMap.SfaEstimatedAmount}"><display/></field>
<field name="estimatedCloseDate" title="${uiLabelMap.SfaCloseDate}"><display/></field>
<field name="editButton" title="${uiLabelMap.CommonEdit}" widget-style="buttontext">
<hyperlink target="EditOpportunity" description="${uiLabelMap.CommonEdit}">
<hyperlink target="EditSalesOpportunity" description="${uiLabelMap.CommonEdit}">
<parameter param-name="salesOpportunityId"/>
</hyperlink>
</field>
</form>
<form name="EditOpportunity" type="single" target="updateOpportunity" default-map-name="salesOpportunity"
<form name="EditSalesOpportunity" type="single" target="updateSalesOpportunity" default-map-name="salesOpportunity"
header-row-style="header-row" default-table-style="basic-table">
<alt-target use-when="salesOpportunity==null" target="createOpportunity"/>
<auto-fields-service service-name="createOpportunity"/>
<alt-target use-when="salesOpportunity==null" target="createSalesOpportunity"/>
<auto-fields-service service-name="createSalesOpportunity"/>
<field use-when="salesOpportunity!=null" name="salesOpportunityId" tooltip="${uiLabelMap.CommonNotModifRecreat}"><display/></field>
<field use-when="salesOpportunity==null&amp;&amp;salesOpportunityId==null" name="salesOpportunityId"><text/></field>
<field use-when="salesOpportunity==null&amp;&amp;salesOpportunityId!=null" name="salesOpportunityId" tooltip="${uiLabelMap.CommonCannotBeFound}: [${salesOpportunityId}]"><display/></field>
<field name="opportunityName" title="${uiLabelMap.SfaOpportunityName}" widget-style="required"><text size="30"/></field>
<field name="initialAccount" title="${uiLabelMap.SfaInitialAccount}" widget-style="required"><lookup target-form-name="LookupPartyName"/></field>
<field name="accountPartyId" title="${uiLabelMap.SfaInitialAccount}" widget-style="required"><lookup target-form-name="LookupPartyName"/></field>
<field name="typeEnumId" title="${uiLabelMap.SfaType}"></field>
<field name="opportunityName" title="${uiLabelMap.SfaOpportunityName}" widget-style="required"><text size="25"></text></field>
<field name="initialAccount" position="1" title="${uiLabelMap.SfaInitialAccount}" widget-style="required"><lookup target-form-name="LookupPartyName"/></field>
<field name="typeEnumId" position="1" title="${uiLabelMap.SfaType}">
<drop-down allow-empty="true">
<entity-options key-field-name="enumId" description="${description}" entity-name="Enumeration">
@@ -125,7 +125,7 @@ under the License.
<field name="submitButton" title="${uiLabelMap.CommonUpdate}" use-when="salesOpportunity!=null"><submit button-type="button"/></field>
</form>
<form name="ViewOpportunity" type="single" default-map-name="salesOpportunity"
<form name="ViewSalesOpportunity" type="single" default-map-name="salesOpportunity"
header-row-style="header-row" default-table-style="basic-table">
<field name="salesOpportunityId"><hidden/></field>
<field name="opportunityName" position="1" title="${uiLabelMap.SfaOpportunityName}"><display/></field>
@@ -100,4 +100,54 @@ This file contains basic services for SalesOpportunity and SalesForecast.
<entity-one entity-name="SalesForecastDetail" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="createSalesOpportunity" short-description="Create Sales Opportunity">
<make-value entity-name="SalesOpportunity" value-field="newEntity"/>
<if-empty field="parameters.salesOpportunityId">
<sequenced-id sequence-name="SalesOpportunity" field="parameters.salesOpportunityId"/>
</if-empty>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set from-field="userLogin.userLoginId" field="newEntity.createdByUserLogin"/>
<field-to-result field="parameters.salesOpportunityId" result-name="salesOpportunityId"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateSalesOpportunity" short-description="Update an Sales opportunity">
<entity-one entity-name="SalesOpportunity" value-field="lookedUpValue"/>
<set-nonpk-fields value-field="lookedUpValue" map="parameters"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="createSalesOpportunityRole" short-description="Create Sales Opportunity Role">
<make-value value-field="newEntity" entity-name="SalesOpportunityRole"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="createSalesOpportunityAccountRole" short-description="Create Sales Opportunity Account Role">
<entity-and list="salesOpportunityRoles" entity-name="SalesOpportunityRole">
<field-map field-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<field-map field-name="roleTypeId" value="ACCOUNT"/>
</entity-and>
<first-from-list entry="lookedUpValue" list="salesOpportunityRoles"/>
<if-compare-field operator="not-equals" field="lookedUpValue.partyId" to-field="parameters.accountPartyId">
<if-not-empty field="lookedUpValue">
<remove-value value-field="lookedUpValue"/>
</if-not-empty>
<set field="salesOpportunityRole.roleTypeId" value="ACCOUNT"/>
<set field="salesOpportunityRole.salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<set field="salesOpportunityRole.partyId" from-field="parameters.accountPartyId"/>
<call-service service-name="createSalesOpportunityRole" in-map-name="salesOpportunityRole"/>
</if-compare-field>
</simple-method>
<simple-method method-name="findPartyInSalesOpportunityRole" short-description="find party in role specified by in parameter">
<entity-and list="salesOpportunityRoles" entity-name="SalesOpportunityRole">
<field-map field-name="roleTypeId" from-field="parameters.roleTypeId"/>
<field-map field-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
</entity-and>
<first-from-list entry="lookedUpValue" list="salesOpportunityRoles"/>
<log level="info" message="Some good message ${lookedUpValue.partyId}"></log>
<field-to-result field="lookedUpValue.partyId" result-name="partyId"/>
</simple-method>
</simple-methods>
+8
View File
@@ -360,4 +360,12 @@ under the License.
<set field-name="emailTemplateSettingId" value="CUST_REQ_COMPLETED"/>
<action service="sendMailFromTemplateSetting" mode="sync"/>
</eca>
<eca service="createSalesOpportunity" event="commit">
<condition field-name="accountPartyId" operator="is-not-empty"/>
<action service="createSalesOpportunityAccountRole" mode="sync"/>
</eca>
<eca service="updateSalesOpportunity" event="commit">
<condition field-name="accountPartyId" operator="is-not-empty"/>
<action service="createSalesOpportunityAccountRole" mode="sync"/>
</eca>
</service-eca>
@@ -67,4 +67,42 @@ under the License.
<description>Delete a Sales Forecast Detail</description>
<auto-attributes mode="IN" include="pk" optional="false"/>
</service>
<!-- opportunity service -->
<service name="createSalesOpportunity" engine="simple" default-entity-name="SalesOpportunity"
location="component://order/script/org/ofbiz/order/opportunity/OpportunityServices.xml" invoke="createSalesOpportunity">
<description>Create an sales opportunity</description>
<auto-attributes mode="INOUT" include="pk" optional="true"/>
<auto-attributes mode="IN" include="nonpk" optional="true">
<exclude field-name="createdByUserLogin"/>
</auto-attributes>
<attribute name="accountPartyId" mode="IN" type="String" optional="true"/>
</service>
<service name="updateSalesOpportunity" engine="simple" default-entity-name="SalesOpportunity"
location="component://order/script/org/ofbiz/order/opportunity/OpportunityServices.xml" invoke="updateSalesOpportunity">
<description>Update an sales opportunity</description>
<auto-attributes mode="IN" include="pk" optional="false"/>
<auto-attributes mode="IN" include="nonpk" optional="true"/>
<attribute name="accountPartyId" mode="IN" type="String" optional="true"/>
</service>
<service name="createSalesOpportunityRole" engine="simple" default-entity-name="SalesOpportunityRole"
location="component://order/script/org/ofbiz/order/opportunity/OpportunityServices.xml" invoke="createSalesOpportunityRole">
<description>Create sales opportunity role</description>
<auto-attributes mode="INOUT" include="pk" optional="true"/>
</service>
<service name="createSalesOpportunityAccountRole" engine="simple" default-entity-name="SalesOpportunityRole"
location="component://order/script/org/ofbiz/order/opportunity/OpportunityServices.xml" invoke="createSalesOpportunityAccountRole">
<description>Create sales opportunity account role</description>
<attribute name="accountPartyId" mode="IN" type="String"/>
<attribute name="salesOpportunityId" mode="IN" type="String"/>
</service>
<service name="findPartyInSalesOpportunityRole" engine="simple" default-entity-name="SalesOpportunityRole"
location="component://order/script/org/ofbiz/order/opportunity/OpportunityServices.xml" invoke="findPartyInSalesOpportunityRole">
<description>find sales opportunity role party</description>
<attribute name="roleTypeId" mode="IN" type="String"/>
<attribute name="salesOpportunityId" mode="IN" type="String"/>
<attribute name="partyId" mode="OUT" type="String" optional="true"/>
</service>
</services>