You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/07/18 10:07:01 UTC

svn commit: r1147774 - in /ofbiz/trunk/applications/party: script/org/ofbiz/party/party/ webapp/partymgr/WEB-INF/ webapp/partymgr/WEB-INF/actions/party/ webapp/partymgr/party/ widget/partymgr/

Author: hansbak
Date: Mon Jul 18 08:07:00 2011
New Revision: 1147774

URL: http://svn.apache.org/viewvc?rev=1147774&view=rev
Log:
screens and services to be able to add/update a geolocation of a party

Added:
    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy   (with props)
    ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl   (with props)
Modified:
    ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml
    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml

Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml?rev=1147774&r1=1147773&r2=1147774&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml (original)
+++ ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml Mon Jul 18 08:07:00 2011
@@ -127,4 +127,30 @@ under the License.
         <field-to-request field="contentId" request-name="contentId"/>
     </simple-method>
 
+    <!-- GeoLocation services -->
+    <simple-method method-name="editGeoLocation" short-description="Edit GeoLocation">
+        <if-empty field="parameters.geoPointId">
+            <set field="createGeoPointMap.dataSourceId" value="GEOPT_GOOGLE"/>
+            <set field="createGeoPointMap.latitude" from-field="parameters.lat"/>
+            <set field="createGeoPointMap.longitude" from-field="parameters.lng"/>
+            <call-service service-name="createGeoPoint" in-map-name="createGeoPointMap">
+                <result-to-field result-name="geoPointId" field="geoPointId"/>
+            </call-service>
+
+            <now-timestamp field="nowTimestamp"/>
+            <make-value value-field="partyGeoPoint" entity-name="PartyGeoPoint"/>
+            <set field="partyGeoPoint.partyId" from-field="parameters.partyId"/>
+            <set field="partyGeoPoint.geoPointId" from-field="geoPointId"/>
+            <set field="partyGeoPoint.fromDate" from-field="nowTimestamp"/>
+            <create-value value-field="partyGeoPoint"/>
+        <else>
+            <set field="updateGeoPointMap.geoPointId" from-field="parameters.geoPointId"/>
+            <set field="updateGeoPointMap.dataSourceId" value="GEOPT_GOOGLE"/>
+            <set field="updateGeoPointMap.latitude" from-field="parameters.lat"/>
+            <set field="updateGeoPointMap.longitude" from-field="parameters.lng"/>
+            <call-service service-name="updateGeoPoint" in-map-name="updateGeoPointMap"/>
+        </else>
+        </if-empty>
+    </simple-method>
+
 </simple-methods>

Added: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy?rev=1147774&view=auto
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy (added)
+++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy Mon Jul 18 08:07:00 2011
@@ -0,0 +1,18 @@
+import org.ofbiz.entity.*;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.base.util.*;
+import org.ofbiz.base.util.string.*;
+import org.ofbiz.party.contact.ContactHelper;
+import org.ofbiz.common.geo.*;
+
+if (partyId) {
+    latestGeoPoint = GeoWorker.findLatestGeoPoint(delegator, "PartyAndGeoPoint", "partyId", partyId, null, null);
+    if (latestGeoPoint) {
+        context.geoPointId = latestGeoPoint.geoPointId;
+        context.latitude = latestGeoPoint.latitude;
+        context.longitude = latestGeoPoint.longitude;
+    } else {
+        context.latitude = 0;
+        context.longitude = 0;
+    }
+}

Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml?rev=1147774&r1=1147773&r2=1147774&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml Mon Jul 18 08:07:00 2011
@@ -1150,6 +1150,17 @@ under the License.
         <response name="success" type="view" value="PartyGeoLocation"/>
         <response name="error" type="view" value="viewprofile"/>
     </request-map>
+    <request-map uri="addGeoLocation">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="addGeoLocation"/>
+        <response name="error" type="view" value="PartyGeoLocation"/>
+    </request-map>
+    <request-map uri="editGeoLocation">
+        <security https="true" auth="true"/>
+        <event type="simple" path="component://party/script/org/ofbiz/party/party/PartySimpleEvents.xml" invoke="editGeoLocation"/>
+        <response name="success" type="view" value="PartyGeoLocation"/>
+        <response name="error" type="view" value="PartyGeoLocation"/>
+    </request-map>
     
     <!-- ProductStoreRole -->
     <request-map uri="ViewProductStoreRoles">
@@ -1356,10 +1367,14 @@ under the License.
 
     <view-map name="UpdateCommOrders" type="screen" page="component://party/widget/partymgr/CommunicationEventScreens.xml#UpdateCommOrders"/>
     <view-map name="UpdateCommProducts" type="screen" page="component://party/widget/partymgr/CommunicationEventScreens.xml#UpdateCommProducts"/>
-    
+ 
     <view-map name="ViewProductStoreRoles" type="screen" page="component://party/widget/partymgr/PartyScreens.xml#ViewProductStoreRoles"/>
-    
+
     <!-- Billing Account-->
     <view-map name="EditBillingAccount" type="screen" page="component://party/widget/partymgr/PaymentMethodScreens.xml#EditBillingAccount"/>
+
+    <!-- GeoLocation-->
+    <view-map name="addGeoLocation" type="screen" page="component://party/widget/partymgr/PartyScreens.xml#EditGeoLocation"/>
+
     <!-- end of view mappings -->
 </site-conf>

Added: ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl?rev=1147774&view=auto
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl (added)
+++ ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl Mon Jul 18 08:07:00 2011
@@ -0,0 +1,123 @@
+<#--
+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.
+-->
+
+<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAgrj58PbXr2YriiRDqbnL1RSqrCjdkglBijPNIIYrqkVvD1R4QxRl47Yh2D_0C1l5KXQJGrbkSDvXFA" type="text/javascript"></script>
+<script type="text/javascript">
+    function load() {
+        if (GBrowserIsCompatible()) {
+            var map = new GMap2(document.getElementById("map"));
+            map.addControl(new GSmallMapControl());
+            map.addControl(new GMapTypeControl());
+            var center = new GLatLng(${latitude?if_exists}, ${longitude?if_exists});
+            map.setCenter(center, 15);
+            geocoder = new GClientGeocoder();
+            var marker = new GMarker(center, {draggable: true});  
+            map.addOverlay(marker);
+            document.getElementById("lat").value = center.lat().toFixed(5);
+            document.getElementById("lng").value = center.lng().toFixed(5);
+
+            GEvent.addListener(marker, "dragend", function() {
+                var point = marker.getPoint();
+                map.panTo(point);
+                document.getElementById("lat").value = point.lat().toFixed(5);
+                document.getElementById("lng").value = point.lng().toFixed(5);
+            });
+
+            GEvent.addListener(map, "moveend", function() {
+                map.clearOverlays();
+                var center = map.getCenter();
+                var marker = new GMarker(center, {draggable: true});
+                map.addOverlay(marker);
+                document.getElementById("lat").value = center.lat().toFixed(5);
+                document.getElementById("lng").value = center.lng().toFixed(5);
+    
+            GEvent.addListener(marker, "dragend", function() {
+                var point =marker.getPoint();
+                map.panTo(point);
+                document.getElementById("lat").value = point.lat().toFixed(5);
+                document.getElementById("lng").value = point.lng().toFixed(5);
+            });
+            });
+        }
+    }
+
+    function showAddress(address) {
+        var map = new GMap2(document.getElementById("map"));
+        map.addControl(new GSmallMapControl());
+        map.addControl(new GMapTypeControl());
+        if (geocoder) {
+            geocoder.getLatLng(
+            address,
+            function(point) {
+                if (!point) {
+                    alert(address + " not found");
+                } else {
+                    document.getElementById("lat").value = point.lat().toFixed(5);
+                    document.getElementById("lng").value = point.lng().toFixed(5);
+                    map.clearOverlays()
+                    map.setCenter(point, 14);
+                    var marker = new GMarker(point, {draggable: true});  
+                    map.addOverlay(marker);
+
+                    GEvent.addListener(marker, "dragend", function() {
+                        var pt = marker.getPoint();
+                        map.panTo(pt);
+                        document.getElementById("lat").value = pt.lat().toFixed(5);
+                        document.getElementById("lng").value = pt.lng().toFixed(5);
+                    });
+
+                    GEvent.addListener(map, "moveend", function() {
+                        map.clearOverlays();
+                        var center = map.getCenter();
+                        var marker = new GMarker(center, {draggable: true});
+                        map.addOverlay(marker);
+                        document.getElementById("lat").value = center.lat().toFixed(5);
+                        document.getElementById("lng").value = center.lng().toFixed(5);
+
+                    GEvent.addListener(marker, "dragend", function() {
+                        var pt = marker.getPoint();
+                        map.panTo(pt);
+                        document.getElementById("lat").value = pt.lat().toFixed(5);
+                        document.getElementById("lng").value = pt.lng().toFixed(5);
+                    });
+                    });
+                }
+            });
+        }
+    }
+</script>
+
+<body onload="load()" onunload="GUnload()" >
+    <center>
+        <div align="center" id="map" style="border:1px solid #979797; background-color:#e5e3df; width:500px; height:450px; margin:2em auto;"><br/></div>
+        <form action="#" onsubmit="showAddress(this.address.value); return false">
+            <input type="text" size="50" name="address"/>
+            <input type="submit" value="Search"/>
+        </form>
+        <br/><br/>
+        <form id="updateMapForm" method="post" action="<@o...@ofbizUrl>">
+            <input type="hidden" name="partyId" value="${parameters.partyId?if_exists}"/>
+            <input type="hidden" name="geoPointId" value="${parameters.geoPointId?if_exists}"/>
+            <input type="hidden"  name="lat" id="lat"/>
+            <input type="hidden" name="lng" id="lng"/>
+            <input type="submit" id="createMapButton" class="smallSubmit" value="${uiLabelMap.CommonSubmit}">
+        </form>
+        <br/><br/><br/>
+    </center>
+</body>

Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/editGeoLocation.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=1147774&r1=1147773&r2=1147774&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml (original)
+++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Mon Jul 18 08:07:00 2011
@@ -1124,10 +1124,49 @@ under the License.
             <widgets>
                 <decorator-screen name="CommonPartyDecorator" location="${parameters.mainDecoratorLocation}">
                     <decorator-section name="body">
-                        <label>${uiLabelMap.CommonLatitude} ${latestGeoPoint.latitude}</label>
-                        <label>${uiLabelMap.CommonLongitude} ${latestGeoPoint.longitude}</label>
-                        <label>${uiLabelMap.CommonElevation} ${latestGeoPoint.elevation} ${elevationUomAbbr}</label>
-                        <include-screen name="geoChart" location="component://common/widget/CommonScreens.xml"/>
+                        <section>
+                            <condition>
+                                <not><if-empty field="geoChart"/></not>
+                            </condition>
+                            <widgets>
+                                <container style="button-bar">
+                                    <link target="addGeoLocation" text="${uiLabelMap.CommonUpdate}" style="buttontext">
+                                        <parameter param-name="partyId" from-field="parameters.partyId"/>
+                                    </link>
+                                </container>
+                                <label>${uiLabelMap.CommonLatitude} ${latestGeoPoint.latitude}</label>
+                                <label>${uiLabelMap.CommonLongitude} ${latestGeoPoint.longitude}</label>
+                                <label>${uiLabelMap.CommonElevation} ${latestGeoPoint.elevation} ${elevationUomAbbr}</label>
+                                <include-screen name="geoChart" location="component://common/widget/CommonScreens.xml"/>
+                            </widgets>
+                            <fail-widgets>
+                                <container style="button-bar">
+                                    <link target="addGeoLocation" text="${uiLabelMap.CommonCreateNew}" style="buttontext create">
+                                        <parameter param-name="partyId" from-field="parameters.partyId"/>
+                                    </link>
+                                </container>
+                                <include-screen name="geoChart" location="component://common/widget/CommonScreens.xml"/>
+                            </fail-widgets>
+                        </section>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
+    <screen name="EditGeoLocation">
+        <section>
+            <actions>
+                <set field="titleProperty" value="PageTitlePartyGeoLocation"/>
+                <set field="tabButtonItem" value="PartyGeoLocation"/>
+                <set field="partyId" from-field="parameters.partyId"/>
+                <script location="component://party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonPartyDecorator" location="${parameters.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <platform-specific>
+                            <html><html-template location="component://party/webapp/partymgr/party/editGeoLocation.ftl"/></html>
+                        </platform-specific>
                     </decorator-section>
                 </decorator-screen>
             </widgets>



Re: svn commit: r1147774 - in /ofbiz/trunk/applications/party: script/org/ofbiz/party/party/ webapp/partymgr/WEB-INF/ webapp/partymgr/WEB-INF/actions/party/ webapp/partymgr/party/ widget/partymgr/

Posted by BJ Freeman <bj...@free-man.net>.
there are a few opensource ones I have used long before google and Yahoo
http://www.openstreetmap.org/copyright
 git.openstreetmap.org and svn.openstreetmap.org


http://www.maptools.org/
which has many project related to mapping.


Scott Gray sent the following on 7/18/2011 4:48 PM:
> Just a reminder to everyone about the Google Maps API, while it is a nice tool it isn't free for non-public facing usage and I'd hate to see us getting carried away with our dependencies on it.
> 
> Regards
> Scott
> 
> On 19/07/2011, at 7:22 AM, Erwan de FERRIERES wrote:
> 
>> Le 18/07/2011 10:07, hansbak@apache.org a écrit :
>>> +-->
>>> +
>>> +<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAgrj58PbXr2YriiRDqbnL1RSqrCjdkglBijPNIIYrqkVvD1R4QxRl47Yh2D_0C1l5KXQJGrbkSDvXFA"  type="text/javascript"></script>
>>> +<script type="text/javascript">
>>> +    function load() {
>>> +        if (GBrowserIsCompatible()) {
>>
>> Hans,
>>
>> shouldn't you be using the key which is in general.properties ?
>>
>> Regards,
>>
>> -- 
>> Erwan de FERRIERES
>> www.nereide.biz
> 

Re: svn commit: r1147774 - in /ofbiz/trunk/applications/party: script/org/ofbiz/party/party/ webapp/partymgr/WEB-INF/ webapp/partymgr/WEB-INF/actions/party/ webapp/partymgr/party/ widget/partymgr/

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Just a reminder to everyone about the Google Maps API, while it is a nice tool it isn't free for non-public facing usage and I'd hate to see us getting carried away with our dependencies on it.

Regards
Scott

On 19/07/2011, at 7:22 AM, Erwan de FERRIERES wrote:

> Le 18/07/2011 10:07, hansbak@apache.org a écrit :
>> +-->
>> +
>> +<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAgrj58PbXr2YriiRDqbnL1RSqrCjdkglBijPNIIYrqkVvD1R4QxRl47Yh2D_0C1l5KXQJGrbkSDvXFA"  type="text/javascript"></script>
>> +<script type="text/javascript">
>> +    function load() {
>> +        if (GBrowserIsCompatible()) {
> 
> Hans,
> 
> shouldn't you be using the key which is in general.properties ?
> 
> Regards,
> 
> -- 
> Erwan de FERRIERES
> www.nereide.biz


Re: svn commit: r1147774 - in /ofbiz/trunk/applications/party: script/org/ofbiz/party/party/ webapp/partymgr/WEB-INF/ webapp/partymgr/WEB-INF/actions/party/ webapp/partymgr/party/ widget/partymgr/

Posted by Erwan de FERRIERES <er...@nereide.fr>.
Le 18/07/2011 10:07, hansbak@apache.org a écrit :
> +-->
> +
> +<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAgrj58PbXr2YriiRDqbnL1RSqrCjdkglBijPNIIYrqkVvD1R4QxRl47Yh2D_0C1l5KXQJGrbkSDvXFA"  type="text/javascript"></script>
> +<script type="text/javascript">
> +    function load() {
> +        if (GBrowserIsCompatible()) {

Hans,

shouldn't you be using the key which is in general.properties ?

Regards,

-- 
Erwan de FERRIERES
www.nereide.biz