[ 
https://issues.apache.org/jira/browse/OFBIZ-1208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545587
 ] 

Al Byers commented on OFBIZ-1208:
---------------------------------

Here are some more code snippets.


My controller.xml file has these:

    <!--handler name="wfs" type="view" 
class="org.ofbiz.webapp.view.WfsViewHandler"/-->
    <handler name="rome" type="request" 
class="org.ofbiz.webapp.event.RomeEventHandler"/>
...   
    <request-map uri="ViewCustomRssFeed">
        <security https="false" auth="false"/>
        <event type="rome" invoke="generateCustomRssFeed"/>
        <response name="success" type="none"/>
        <response name="error" type="view" value="error"/>
    </request-map>

Here is the code for generateCustomRssFeed:


       public static Map generateCustomRssFeed(DispatchContext dctx, Map 
context) {
           Debug.logInfo("generateWellCustomRssFeed(0) context:" + context, 
module);
           GenericValue userLogin = (GenericValue) context.get("userLogin");
           String entryLink = (String) context.get("entryLink");
           String feedType = (String) context.get("feedType");
           Locale locale = (Locale) context.get("locale");

           // create the main link
           String mainLink = (String) context.get("mainLink");

           LocalDispatcher dispatcher = dctx.getDispatcher();
           GenericDelegator delegator = dctx.getDelegator();

           // get the main blog content
           GenericValue content = null;
             // create the feed
           SyndFeed feed = new SyndFeedImpl();
           feed.setFeedType(feedType);
           feed.setLink(mainLink);

           feed.setTitle("Granite Well RSS Feed");
           feed.setDescription("Granite Well RSS Feed");
           Debug.logInfo("generateCustomRssFeed(1) feed:" + feed, module);
           feed.setEntries(generateEntryList(dispatcher, delegator, entryLink, 
locale, userLogin));

           Map resp = ServiceUtil.returnSuccess();
           resp.put("wireFeed", feed.createWireFeed());
           return resp;
       }

       public static List generateEntryList(LocalDispatcher dispatcher, 
GenericDelegator delegator, String entryLink, Locale locale, GenericValue 
userLogin) {
           List entries = FastList.newInstance();
           List customList = null;
           Map nullMap = null;
           try {
               wellList = delegator.findByAnd("CustomEntity", nullMap);
           } catch (GenericEntityException e) {
               Debug.logError(e, module);
           }

           if (UtilValidate.isEmpty(customList)) {
               return entries;
           }


               Iterator i = wellList.iterator();
               while (i.hasNext()) {
                   GenericValue v = (GenericValue) i.next();
           Debug.logInfo("generateEntryList(1) v:" + v, module);
                   String sub = v.getString("customName");
                   if (sub != null) {
                       String thisLink = entryLink + "?customId=" + 
v.getString("customId");
                       SyndContent desc = new SyndContentImpl();
                       desc.setType("text/plain");
                       desc.setValue(sub);

                       SyndEntry entry = new SyndEntryImpl();
                       entry.setTitle(v.getString("customName"));
                       entry.setPublishedDate(v.getTimestamp("createdStamp"));
                       entry.setDescription(desc);
                       entry.setLink(thisLink);
                       //entry.setAuthor((v.getString("createdByUserLogin")));  
                 
                       GeoRSSModule geoRSSModule = new W3CGeoModuleImpl();
                       Double lon = v.getDouble("longitude");
                       Double lat = v.getDouble("latitude");
                       //GeoRSSModule geoRSSModule = new SimpleModuleImpl();
                       if (lon != null && lat != null) {
                           Position pos = new Position( lat.doubleValue(), 
lon.doubleValue());
                           geoRSSModule.setPosition(pos);
                           entry.getModules().add(geoRSSModule);
                           Debug.logInfo("generateEntryList(2) entry:" + entry, 
module);
                           entries.add(entry);
                       }
                   }
               }

           return entries;
       }

I should mention that this work was sponsored by HotWax.

> Adding GeoRSS functionality
> ---------------------------
>
>                 Key: OFBIZ-1208
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1208
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: content
>    Affects Versions: SVN trunk
>            Reporter: Al Byers
>            Priority: Minor
>
> I did some work to add a GeoRSS interface to OFBiz, but there is no clean 
> place to put an example right now, so I am starting this issue to document 
> the work that I did. GeoRSS is a standard that will let you point-of-interest 
> markers in Google, Yahoo or Microsoft maps (see 
> http://docs.codehaus.org/display/GEOSDOC/GeoRSS)
> I basically just took Andrew Z's generateBlogRssFeed service and add:
>                        GeoRSSModule geoRSSModule = new W3CGeoModuleImpl();
>                        Double lon = v.getDouble("longitude");
>                        Double lat = v.getDouble("latitude");
>                        //GeoRSSModule geoRSSModule = new SimpleModuleImpl();
>                        if (lon != null && lat != null) {
>                                      Position pos = new Position( 
> lat.doubleValue(), lon.doubleValue());
>                            geoRSSModule.setPosition(pos);
>                            entry.getModules().add(geoRSSModule);
>                              Debug.logInfo("generateEntryList(2) entry:" + 
> entry, module);
>                            entries.add(entry);
>                        }
> in the generateEntryList
> The "v" object comes from an app specific entity, so there is no place to put 
> an example in OFBiz right now. I imagine that one will occur to me.
> The other thing to do is include the GeoRSSModule and related code from the 
> http://georss.geonames.org/ site.
> When I downloaded the georss-rome-0.9.8.jar file, the modules were not found. 
> I ended up downloading the source jar and building it.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to