Author: jleroux
Date: Thu Sep 23 12:47:14 2010 New Revision: 1000434 URL: http://svn.apache.org/viewvc?rev=1000434&view=rev Log: Fixes the linkGeos service. It was able not remove, it was only creating. Introduce a new getRelatedGeos service which will be used soon in the Webtools/Geo mnagement. It comes from the jQuery branch and I have still not rewritten the jQuery to Prototype part. This should make smoother next merge from trunk in jQuery branch Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml ofbiz/trunk/framework/common/servicedef/services.xml ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml?rev=1000434&r1=1000433&r2=1000434&view=diff ============================================================================== --- ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml (original) +++ ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml Thu Sep 23 12:47:14 2010 @@ -263,21 +263,65 @@ under the License. <field-to-list list="stateList" field="stateName"/> </iterate> <if-empty field="stateList"> - <property-to-field resource="CommonUiLabels" property="CommonNoStatesProvinces" field="noOption"/> - <field-to-list list="stateList" field="noOption"/> + <property-to-field resource="CommonUiLabels" property="CommonNoStatesProvinces" field="noOptions"/> + <field-to-list list="stateList" field="noOptions"/> </if-empty> <field-to-result field="stateList"/> </simple-method> <simple-method method-name="linkGeos" short-description="Link Geos to another Geo"> - <iterate list="parameters.geoIds" entry="geoId"> - <make-value value-field="newGeoAssoc" entity-name="GeoAssoc"/> - <set field="newGeoAssoc.geoId" from-field="geoId"/> - <set field="newGeoAssoc.geoIdTo" from-field="parameters.geoId"/> - <set field="newGeoAssoc.geoAssocTypeId" from-field="parameters.geoAssocTypeId"/> - <create-value value-field="newGeoAssoc"/> - <check-errors/> + <entity-and entity-name="GeoAssoc" list="geoAssocs"> + <field-map field-name="geoIdTo" from-field="parameters.geoId"/> + </entity-and> + <!-- Current list contains old values? --> + <iterate list="geoAssocs" entry="geoAssoc"> + <if-compare-field field="parameters.geoIds" operator="contains" to-field="geoAssoc.geoId"> + <!-- Yes, nothing to do, it already exists and we keep it --> + <else><!-- Remove --> + <entity-one entity-name="GeoAssoc" value-field="oldGeoAssoc"> + <field-map field-name="geoId" from-field="geoAssoc.geoId"/> + <field-map field-name="geoIdTo" from-field="parameters.geoId"/> + </entity-one> + <remove-value value-field="oldGeoAssoc"/> + </else> + </if-compare-field> </iterate> + <!-- Old list contains current values --> + <iterate list="parameters.geoIds" entry="geoId"> + <if-compare-field field="oldGeoIds" operator="contains" to-field="geoId"> + <!-- Yes, nothing to do, it already exists and we keep it --> + <else> + <entity-one entity-name="GeoAssoc" value-field="oldGeoAssoc"> + <field-map field-name="geoId" from-field="geoId"/> + <field-map field-name="geoIdTo" from-field="parameters.geoId"/> + </entity-one> + <if-empty field="oldGeoAssoc"> + <!-- Add as it does not exist --> + <make-value value-field="newGeoAssoc" entity-name="GeoAssoc"/> + <set field="newGeoAssoc.geoId" from-field="geoId"/> + <set field="newGeoAssoc.geoIdTo" from-field="parameters.geoId"/> + <set field="newGeoAssoc.geoAssocTypeId" from-field="parameters.geoAssocTypeId"/> + <create-value value-field="newGeoAssoc"/> + </if-empty> + </else> + </if-compare-field> + </iterate> + <check-errors/> </simple-method> + + <simple-method method-name="getRelatedGeos" short-description="get related geos to a geo through a geoAssoc" login-required="false"> + <entity-and entity-name="GeoAssoc" list="geoAssoc"> + <field-map field-name="geoIdTo" from-field="parameters.geoId"/> + <field-map field-name="geoAssocTypeId" from-field="parameters.geoAssocTypeId"/> + </entity-and> + <iterate list="geoAssoc" entry="geo"> + <field-to-list list="geoList" field="geo.geoId"/> + </iterate> + <if-empty field="geoList"> + <property-to-field resource="CommonUiLabels" property="CommonNoOptions" field="noOptions"/> + <field-to-list list="geoList" field="noOptions"/> + </if-empty> + <field-to-result field="geoList"/> + </simple-method> </simple-methods> Modified: ofbiz/trunk/framework/common/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?rev=1000434&r1=1000433&r2=1000434&view=diff ============================================================================== --- ofbiz/trunk/framework/common/servicedef/services.xml (original) +++ ofbiz/trunk/framework/common/servicedef/services.xml Thu Sep 23 12:47:14 2010 @@ -711,9 +711,9 @@ under the License. location="component://common/script/org/ofbiz/common/CommonServices.xml" invoke="linkGeos"> <description>Link Geos to another Geo</description> <permission-service service-name="commonGenericPermission" main-action="CREATE"/> - <attribute name="geoIds" type="List" mode="IN"></attribute> - <attribute name="geoId" type="String" mode="IN"></attribute> - <attribute name="geoAssocTypeId" type="String" mode="IN"></attribute> + <attribute name="geoIds" type="List" mode="IN" optional="true"/> + <attribute name="geoId" type="String" mode="IN"/> + <attribute name="geoAssocTypeId" type="String" mode="IN"/> </service> <!-- GeoPoint services --> @@ -753,4 +753,12 @@ under the License. <attribute name="listOrderBy" mode="IN" type="String" optional="true"/> <attribute name="stateList" mode="OUT" type="java.util.List"/> </service> + + <service name="getRelatedGeos" engine="simple" auth="false" + location="component://common/script/org/ofbiz/common/CommonServices.xml" invoke="getRelatedGeos"> + <attribute name="geoId" mode="IN" type="String"/> + <attribute name="geoAssocTypeId" mode="IN" type="String"/> + <attribute name="geoList" mode="OUT" type="java.util.List"/> + </service> + </services> Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml?rev=1000434&r1=1000433&r2=1000434&view=diff ============================================================================== --- ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml (original) +++ ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml Thu Sep 23 12:47:14 2010 @@ -211,6 +211,13 @@ under the License. <response name="success" type="request" value="json"/> <response name="error" type="request" value="json"/> </request-map> + + <request-map uri="getRelatedGeos"> + <security https="true" auth="true"/> + <event type="service" invoke="getRelatedGeos"/> + <response name="success" type="request" value="json"/> + <response name="error" type="request" value="json"/> + </request-map> <!--========================== AJAX events =====================--> |
Free forum by Nabble | Edit this page |