streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject svn commit: r1556893 [17/25] - in /incubator/streams/branches/sblackmon: ./ streams-config-graph/ streams-config-graph/src/ streams-config-graph/src/main/ streams-config-graph/src/main/java/ streams-config-graph/src/main/java/org/ streams-config-graph/...
Date Thu, 09 Jan 2014 17:27:58 GMT
Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/java/org/apache/streams/data/util/MoreoverUtils.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/java/org/apache/streams/data/util/MoreoverUtils.java?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/java/org/apache/streams/data/util/MoreoverUtils.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/java/org/apache/streams/data/util/MoreoverUtils.java
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,136 @@
+package org.apache.streams.data.util;
+
+import com.moreover.api.*;
+import org.apache.streams.pojo.json.Activity;
+import org.apache.streams.pojo.json.ActivityObject;
+import org.apache.streams.pojo.json.Actor;
+import org.apache.streams.pojo.json.Provider;
+import org.joda.time.DateTime;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static org.apache.streams.data.util.ActivityUtil.*;
+
+/**
+ * Provides utilities for Moroever data
+ */
+public class MoreoverUtils {
+    private MoreoverUtils() {
+    }
+
+    public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+    public static Activity convert(Article article) {
+        Activity activity = new Activity();
+        Source source = article.getSource();
+        activity.setActor(convert(article.getAuthor(), source.getName()));
+        activity.setProvider(convert(source));
+        activity.setTarget(convertTarget(source));
+        activity.setObject(convertObject(article));
+        activity.setPublished(DateTime.parse(article.getPublishedDate()).toDate());
+        activity.setContent(article.getContent());
+        activity.setTitle(article.getTitle());
+        activity.setVerb("posted");
+        fixActivityId(activity);
+        addLocationExtension(activity, source);
+        addLanguageExtension(activity, article);
+        activity.setLinks(convertLinks(article));
+        return activity;
+    }
+
+    private static void fixActivityId(Activity activity) {
+        if (activity.getId().matches("\\{[a-z]*\\}")) {
+            activity.setId(null);
+        }
+    }
+
+    private static List convertLinks(Article article) {
+        List list = new LinkedList();
+        Article.OutboundUrls outboundUrls = article.getOutboundUrls();
+        if (outboundUrls != null) {
+            for (String url : outboundUrls.getOutboundUrl()) {
+                list.add(url);
+            }
+        }
+        return list;
+    }
+
+    public static ActivityObject convertTarget(Source source) {
+        ActivityObject object = new ActivityObject();
+        object.setUrl(source.getHomeUrl());
+        object.setDisplayName(source.getName());
+        return object;
+    }
+
+    public static ActivityObject convertObject(Article article) {
+        ActivityObject object = new ActivityObject();
+        object.setContent(article.getContent());
+        object.setSummary(article.getTitle());
+        object.setUrl(article.getOriginalUrl());
+        object.setObjectType(article.getDataFormat());
+        String type = article.getDataFormat().equals("text") ? "article" : article.getDataFormat();
+        object.setId(getObjectId(getProviderID(article.getSource().getFeed()), type, article.getId()));
+        object.setPublished(DateTime.parse(article.getPublishedDate()).toDate());
+        return object;
+    }
+
+    public static Provider convert(Source source) {
+        Provider provider = new Provider();
+        Feed feed = source.getFeed();
+        String display = getProviderID(feed);
+        provider.setId(getProviderId(display.trim().toLowerCase().replace(" ", "_")));
+        provider.setDisplayName(display);
+        provider.setUrl(feed.getUrl());
+        return provider;
+    }
+
+    public static Actor convert(Author author, String platformName) {
+        Actor actor = new Actor();
+        AuthorPublishingPlatform platform = author.getPublishingPlatform();
+        String userId = platform.getUserId();
+        if (userId != null) actor.setId(getPersonId(getProviderID(platformName), userId));
+        actor.setDisplayName(author.getName());
+        actor.setUrl(author.getHomeUrl());
+        actor.setSummary(author.getDescription());
+        actor.setAdditionalProperty("email", author.getEmail());
+        return actor;
+    }
+
+    public static void addLocationExtension(Activity activity, Source value) {
+        Map<String, Object> extensions = ensureExtensions(activity);
+        String country = value.getLocation().getCountryCode() == null ? value.getLocation().getCountry()
: value.getLocation().getCountryCode();
+        if (country != null) {
+            Map<String, Object> location = new HashMap<String, Object>();
+            location.put(LOCATION_EXTENSION_COUNTRY, country);
+            extensions.put(LOCATION_EXTENSION, location);
+        }
+    }
+
+    public static void addLanguageExtension(Activity activity, Article value) {
+        Map<String, Object> extensions = ensureExtensions(activity);
+        String language = value.getLanguage();
+        if (language != null) {
+            extensions.put(LANGUAGE_EXTENSION, language);
+        }
+    }
+
+    public static Date parse(String str) {
+        DateFormat fmt = new SimpleDateFormat(DATE_FORMAT);
+        try {
+            return fmt.parse(str);
+        } catch (ParseException e) {
+            throw new IllegalArgumentException("Invalid date format", e);
+        }
+    }
+
+    private static String getProviderID(Feed feed) {
+        return getProviderID(feed.getPublishingPlatform() == null ? feed.getMediaType() :
feed.getPublishingPlatform());
+    }
+
+    private static String getProviderID(String feed) {
+        return feed.toLowerCase().replace(" ", "_").trim();
+    }
+}

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/Moreover.json
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/Moreover.json?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/Moreover.json
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/Moreover.json
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,333 @@
+{
+    "type": "object",
+    "$schema": "http://json-schema.org/draft-03/schema",
+    "javaType": "com.moreover.Moreover",
+    "id": "#",
+    "properties": {
+        "tags": {
+            "type": "string"
+        },
+        "publishingPlatform": {
+            "properties": {
+                "totalViews": {
+                    "type": "string"
+                },
+                "itemId": {
+                    "type": "string"
+                }
+            }
+        },
+        "loginStatus": {
+            "type": "string"
+        },
+        "duplicateGroupId": {
+            "type": "string"
+        },
+        "companies": {
+            "properties": {
+                "symbol": {
+                    "type": "string"
+                },
+                "primary": {
+                    "type": "string"
+                },
+                "name": {
+                    "type": "string"
+                },
+                "contentCount": {
+                    "type": "string"
+                },
+                "exchange": {
+                    "type": "string"
+                },
+                "titleCount": {
+                    "type": "string"
+                },
+                "isin": {
+                    "type": "string"
+                }
+            }
+        },
+        "copyright": {
+            "type": "string"
+        },
+        "url": {
+            "type": "string"
+        },
+        "content": {
+            "type": "string"
+        },
+        "id": {
+            "type": "string"
+        },
+        "author": {
+            "properties": {
+                "publishingPlatform": {
+                    "properties": {
+                        "userId": {
+                            "type": "string"
+                        },
+                        "totalViews": {
+                            "type": "string"
+                        }
+                    }
+                },
+                "dateLastActive": {
+                    "type": "string"
+                },
+                "description": {
+                    "type": "string"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "topics": {
+            "properties": {
+                "name": {
+                    "type": "string"
+                },
+                "group": {
+                    "type": "string"
+                }
+            }
+        },
+        "title": {
+            "type": "string"
+        },
+        "source": {
+            "properties": {
+                "category": {
+                    "type": "string"
+                },
+                "location": {
+                    "properties": {
+                        "region": {
+                            "type": "string"
+                        },
+                        "subregion": {
+                            "type": "string"
+                        },
+                        "zipCode": {
+                            "type": "string"
+                        },
+                        "state": {
+                            "type": "string"
+                        },
+                        "countryCode": {
+                            "type": "string"
+                        },
+                        "zipArea": {
+                            "type": "string"
+                        },
+                        "country": {
+                            "type": "string"
+                        }
+                    }
+                },
+                "editorialRank": {
+                    "type": "string"
+                },
+                "name": {
+                    "type": "string"
+                },
+                "feed": {
+                    "properties": {
+                        "tags": {
+                            "type": "string"
+                        },
+                        "genre": {
+                            "type": "string"
+                        },
+                        "publishingPlatform": {
+                            "type": "string"
+                        },
+                        "inWhiteList": {
+                            "type": "string"
+                        },
+                        "imageUrl": {
+                            "type": "string"
+                        },
+                        "copyright": {
+                            "type": "string"
+                        },
+                        "mediaType": {
+                            "type": "string"
+                        },
+                        "id": {
+                            "type": "string"
+                        },
+                        "rank": {
+                            "properties": {
+                                "autoRankOrder": {
+                                    "type": "string"
+                                },
+                                "inboundLinkCount": {
+                                    "type": "string"
+                                },
+                                "autoRank": {
+                                    "type": "string"
+                                }
+                            }
+                        },
+                        "description": {
+                            "type": "string"
+                        },
+                        "idFromPublisher": {
+                            "type": "string"
+                        },
+                        "name": {
+                            "type": "string"
+                        },
+                        "dataFormat": {
+                            "type": "string"
+                        },
+                        "generator": {
+                            "type": "string"
+                        },
+                        "autoTopics": {
+                            "type": "string"
+                        },
+                        "language": {
+                            "type": "string"
+                        },
+                        "editorialTopics": {
+                            "type": "string"
+                        }
+                    }
+                },
+                "homeUrl": {
+                    "type": "string"
+                },
+                "publisher": {
+                    "type": "string"
+                }
+            }
+        },
+        "locations": {
+            "properties": {
+                "region": {
+                    "type": "string"
+                },
+                "subregion": {
+                    "type": "string"
+                },
+                "name": {
+                    "type": "string"
+                },
+                "state": {
+                    "properties": {
+                        "name": {
+                            "type": "string"
+                        },
+                        "fipsCode": {
+                            "type": "string"
+                        },
+                        "confidence": {
+                            "type": "string"
+                        }
+                    }
+                },
+                "longitude": {
+                    "type": "string"
+                },
+                "latitude": {
+                    "type": "string"
+                },
+                "confidence": {
+                    "type": "string"
+                },
+                "type": {
+                    "type": "string"
+                },
+                "mentions": {
+                    "type": "string"
+                },
+                "country": {
+                    "properties": {
+                        "name": {
+                            "type": "string"
+                        },
+                        "fipsCode": {
+                            "type": "string"
+                        },
+                        "isoCode": {
+                            "type": "string"
+                        },
+                        "confidence": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
+        "commentsUrl": {
+            "type": "string"
+        },
+        "dataFormat": {
+            "type": "string"
+        },
+        "outboundUrls": {
+            "type": "string"
+        },
+        "sequenceId": {
+            "type": "string"
+        },
+        "publishedDate": {
+            "type": "string"
+        },
+        "language": {
+            "type": "string"
+        },
+        "adultLanguage": {
+            "type": "string"
+        },
+        "harvestDate": {
+            "type": "string"
+        },
+        "media": {
+            "properties": {
+                "duration": {
+                    "type": "string"
+                },
+                "audio": {
+                    "properties": {
+                        "url": {
+                            "type": "string"
+                        },
+                        "mimeType": {
+                            "type": "string"
+                        }
+                    }
+                },
+                "image": {
+                    "properties": {
+                        "url": {
+                            "type": "string"
+                        }
+                    }
+                },
+                "caption": {
+                    "type": "string"
+                },
+                "video": {
+                    "properties": {
+                        "url": {
+                            "type": "string"
+                        },
+                        "mimeType": {
+                            "type": "string"
+                        }
+                    }
+                },
+                "url": {
+                    "type": "string"
+                },
+                "mimeType": {
+                    "type": "string"
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/MoreoverConfiguration.json
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/MoreoverConfiguration.json?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/MoreoverConfiguration.json
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/jsonschema/com/moreover/MoreoverConfiguration.json
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,34 @@
+{
+    "type": "object",
+    "$schema": "http://json-schema.org/draft-03/schema",
+    "id": "#",
+    "javaType" : "org.apache.streams.moreover.MoreoverConfiguration",
+    "properties": {
+        "apiKeys": {
+            "type": "array",
+            "minItems": 1,
+            "items": {
+                "type": "object",
+                "javaType" : "org.apache.streams.moreover.MoreoverKeyData",
+                "javaInterfaces": ["java.io.Serializable"],
+                "properties": {
+                    "id": {
+                        "type": "string"
+                    },
+                    "key": {
+                        "type": "string"
+                    },
+                    "startingSequence": {
+                        "type": "string"
+                    }
+                }
+            }
+        },
+        "maxBatchSize": {
+            "type": "long"
+        },
+        "minDelaySeconds": {
+            "type": "long"
+        }
+    }
+}
\ No newline at end of file

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/articles10.xsd
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/articles10.xsd?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/articles10.xsd
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/articles10.xsd
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,366 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+    <xs:element name="response" type="articlesResponse"/>
+
+    <xs:complexType name="articlesResponse">
+        <xs:sequence>
+            <xs:element name="status" type="xs:string" minOccurs="0"/>
+            <xs:element name="messageCode" type="xs:string" minOccurs="0"/>
+            <xs:element name="userMessage" type="xs:string" minOccurs="0"/>
+            <xs:element name="developerMessage" type="xs:string" minOccurs="0"/>
+            <xs:element name="articles" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="article" type="article" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="article">
+        <xs:sequence>
+            <xs:element name="sequenceId" type="xs:string" minOccurs="0"/>
+            <xs:element name="id" type="xs:string"/>
+            <xs:element name="language" type="xs:string"/>
+            <xs:element name="title" type="xs:string"/>
+            <xs:element name="subTitle" type="xs:string" minOccurs="0"/>
+            <xs:element name="content" type="xs:string" minOccurs="0"/>
+            <xs:element name="contentWithMarkup" type="xs:string" minOccurs="0"/>
+            <xs:element name="tags" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="tag" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="publishedDate" type="xs:string"/>
+            <xs:element name="harvestDate" type="xs:string"/>
+            <xs:element name="embargoDate" type="xs:string" minOccurs="0"/>
+            <xs:element name="licenseEndDate" type="xs:string"/>
+            <xs:element name="url" type="xs:string"/>
+            <xs:element name="originalUrl" type="xs:string" minOccurs="0"/>
+            <xs:element name="commentsUrl" type="xs:string"/>
+            <xs:element name="outboundUrls" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="outboundUrl" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="wordCount" type="xs:string" minOccurs="0"/>
+            <xs:element name="dataFormat" type="xs:string"/>
+            <xs:element name="copyright" type="xs:string"/>
+            <xs:element name="loginStatus" type="xs:string"/>
+            <xs:element name="duplicateGroupId" type="xs:string"/>
+            <xs:element name="contentGroupIds" type="xs:string" minOccurs="0"/>
+            <xs:element name="harvest" type="harvest" minOccurs="0"/>
+            <xs:element name="media" type="media"/>
+            <xs:element name="publishingPlatform" type="articlePublishingPlatform"/>
+            <xs:element name="adultLanguage" type="xs:string"/>
+            <xs:element name="topics" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="topic" type="topic" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="companies" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="company" type="company" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="locations" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="location" type="articleLocation" minOccurs="0"
maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="semantics" type="semantics" minOccurs="0"/>
+            <xs:element name="print" type="print" minOccurs="0"/>
+            <xs:element name="broadcast" type="broadcast" minOccurs="0"/>
+            <xs:element name="author" type="author"/>
+            <xs:element name="source" type="source"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="harvest">
+        <xs:sequence>
+            <xs:element name="headlineVia" type="xs:string"/>
+            <xs:element name="contentVia" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="media">
+        <xs:sequence>
+            <xs:element name="audio" type="audioOrVideo" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="image" type="image" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="video" type="audioOrVideo" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="audioOrVideo">
+        <xs:sequence>
+            <xs:element name="url" type="xs:string"/>
+            <xs:element name="mimeType" type="xs:string"/>
+            <xs:element name="caption" type="xs:string"/>
+            <xs:element name="duration" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="image">
+        <xs:sequence>
+            <xs:element name="url" type="xs:string"/>
+            <xs:element name="mimeType" type="xs:string"/>
+            <xs:element name="caption" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="articlePublishingPlatform">
+        <xs:sequence>
+            <xs:element name="itemId" type="xs:string"/>
+            <xs:element name="statusId" type="xs:string"/>
+            <xs:element name="inReplyToUserId" type="xs:string"/>
+            <xs:element name="inReplyToStatusId" type="xs:string"/>
+            <xs:element name="totalViews" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="topic">
+        <xs:sequence>
+            <xs:element name="name" type="xs:string" minOccurs="0"/>
+            <xs:element name="group" type="xs:string" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="company">
+        <xs:sequence>
+            <xs:element name="name" type="xs:string"/>
+            <xs:element name="symbol" type="xs:string"/>
+            <xs:element name="exchange" type="xs:string"/>
+            <xs:element name="isin" type="xs:string"/>
+            <xs:element name="cusip" type="xs:string" minOccurs="0"/>
+            <xs:element name="titleCount" type="xs:int"/>
+            <xs:element name="contentCount" type="xs:int"/>
+            <xs:element name="primary" type="xs:boolean"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="articleLocation">
+        <xs:sequence>
+            <xs:element name="name" type="xs:string"/>
+            <xs:element name="type" type="xs:string"/>
+            <xs:element name="class" type="xs:string"/>
+            <xs:element name="mentions" type="xs:string"/>
+            <xs:element name="confidence" type="xs:string"/>
+            <xs:element name="country" type="country"/>
+            <xs:element name="region" type="xs:string"/>
+            <xs:element name="subregion" type="xs:string"/>
+            <xs:element name="state" type="state"/>
+            <xs:element name="latitude" type="xs:string"/>
+            <xs:element name="longitude" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="country">
+        <xs:sequence>
+            <xs:element name="confidence" type="xs:string" minOccurs="0"/>
+            <xs:element name="fipsCode" type="xs:string" minOccurs="0"/>
+            <xs:element name="isoCode" type="xs:string" minOccurs="0"/>
+            <xs:element name="name" type="xs:string" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="state">
+        <xs:sequence>
+            <xs:element name="confidence" type="xs:string" minOccurs="0"/>
+            <xs:element name="fipsCode" type="xs:string" minOccurs="0"/>
+            <xs:element name="name" type="xs:string" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="semantics">
+        <xs:sequence>
+            <xs:element name="events" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="event" type="semanticsItem" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="entities" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="entity" type="semanticsItem" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="semanticsItem">
+        <xs:sequence>
+            <xs:element name="properties" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="property">
+        <xs:sequence>
+            <xs:element name="name" type="xs:string" minOccurs="0"/>
+            <xs:element name="value" type="xs:string" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="print">
+        <xs:sequence>
+            <xs:element name="supplement" type="xs:string"/>
+            <xs:element name="publicationEdition" type="xs:string"/>
+            <xs:element name="regionalEdition" type="xs:string"/>
+            <xs:element name="section" type="xs:string"/>
+            <xs:element name="pageNumber" type="xs:string"/>
+            <xs:element name="sizeCm" type="xs:string"/>
+            <xs:element name="sizePercentage" type="xs:string"/>
+            <xs:element name="originLeft" type="xs:string"/>
+            <xs:element name="originTop" type="xs:string"/>
+            <xs:element name="width" type="xs:string"/>
+            <xs:element name="height" type="xs:string"/>
+            <xs:element name="byLine" type="xs:string"/>
+            <xs:element name="photo" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="broadcast">
+        <xs:sequence>
+            <xs:element name="marketName" type="xs:string"/>
+            <xs:element name="nationalNetwork" type="xs:string"/>
+            <xs:element name="title" type="xs:string"/>
+            <xs:element name="lines" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="line" type="line" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="line">
+        <xs:sequence>
+            <xs:element name="date" type="xs:string" minOccurs="0"/>
+            <xs:element name="text" type="xs:string" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="author">
+        <xs:sequence>
+            <xs:element name="name" type="xs:string"/>
+            <xs:element name="homeUrl" type="xs:string"/>
+            <xs:element name="email" type="xs:string"/>
+            <xs:element name="description" type="xs:string"/>
+            <xs:element name="dateLastActive" type="xs:string"/>
+            <xs:element name="publishingPlatform" type="authorPublishingPlatform"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="authorPublishingPlatform">
+        <xs:sequence>
+            <xs:element name="userName" type="xs:string"/>
+            <xs:element name="userId" type="xs:string"/>
+            <xs:element name="statusesCount" type="xs:string"/>
+            <xs:element name="totalViews" type="xs:string"/>
+            <xs:element name="followingCount" type="xs:string"/>
+            <xs:element name="followersCount" type="xs:string"/>
+            <xs:element name="kloutScore" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="source">
+        <xs:sequence>
+            <xs:element name="id" type="xs:string" minOccurs="0"/>
+            <xs:element name="name" type="xs:string"/>
+            <xs:element name="homeUrl" type="xs:string"/>
+            <xs:element name="publisher" type="xs:string"/>
+            <xs:element name="primaryLanguage" type="xs:string"/>
+            <xs:element name="primaryMediaType" type="xs:string"/>
+            <xs:element name="category" type="xs:string"/>
+            <xs:element name="editorialRank" type="xs:string"/>
+            <xs:element name="publicationId" type="xs:string" minOccurs="0"/>
+            <xs:element name="channelCode" type="xs:string" minOccurs="0"/>
+            <xs:element name="location" type="sourceLocation"/>
+            <xs:element name="feedSource" type="xs:string" minOccurs="0"/>
+            <xs:element name="feed" type="feed"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="sourceLocation">
+        <xs:sequence>
+            <xs:element name="country" type="xs:string"/>
+            <xs:element name="countryCode" type="xs:string"/>
+            <xs:element name="region" type="xs:string"/>
+            <xs:element name="subregion" type="xs:string"/>
+            <xs:element name="state" type="xs:string"/>
+            <xs:element name="zipArea" type="xs:string"/>
+            <xs:element name="zipCode" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="feed">
+        <xs:sequence>
+            <xs:element name="id" type="xs:string"/>
+            <xs:element name="name" type="xs:string"/>
+            <xs:element name="url" type="xs:string" minOccurs="0"/>
+            <xs:element name="mediaType" type="xs:string"/>
+            <xs:element name="publishingPlatform" type="xs:string"/>
+            <xs:element name="idFromPublisher" type="xs:string"/>
+            <xs:element name="generator" type="xs:string"/>
+            <xs:element name="description" type="xs:string"/>
+            <xs:element name="tags" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="tag" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="imageUrl" type="xs:string"/>
+            <xs:element name="copyright" type="xs:string"/>
+            <xs:element name="language" type="xs:string"/>
+            <xs:element name="dataFormat" type="xs:string"/>
+            <xs:element name="rank" type="rank"/>
+            <xs:element name="inWhiteList" type="xs:string"/>
+            <xs:element name="autoTopics" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="autoTopic" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="editorialTopics" minOccurs="0">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="editorialTopic" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="genre" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="rank">
+        <xs:sequence>
+            <xs:element name="autoRank" type="xs:string"/>
+            <xs:element name="autoRankOrder" type="xs:string"/>
+            <xs:element name="inboundLinkCount" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+</xs:schema>
+

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/binding.xjb
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/binding.xjb?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/binding.xjb
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/main/xmlschema/com/moreover/binding.xjb
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+               xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+               xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
+               version="2.1">
+    <jaxb:globalBindings>
+        <!-- Use java.util.Calendar instead of javax.xml.datatype.XMLGregorianCalendar
for xs:dateTime -->
+        <jaxb:javaType name="java.util.Calendar" xmlType="xs:dateTime"
+                       parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime"
+                       printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
+
+        <!-- Force all classes implements Serializable -->
+        <xjc:serializable uid="1" />
+    </jaxb:globalBindings>
+
+</jaxb:bindings>
\ No newline at end of file

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerTest.java?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerTest.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerTest.java
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,71 @@
+/*
+ * 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
+ *
+ *   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.
+ */
+package org.apache.streams.data;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.streams.data.util.JsonUtil;
+import org.apache.streams.pojo.json.Activity;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.regex.Pattern;
+
+import static java.util.regex.Pattern.matches;
+import static org.apache.streams.data.util.MoreoverTestUtil.test;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class MoreoverJsonActivitySerializerTest {
+    JsonNode json;
+    ActivitySerializer serializer = new MoreoverJsonActivitySerializer();
+    ObjectMapper mapper;
+
+    @Before
+    public void setup() throws IOException {
+        json = JsonUtil.getFromFile("classpath:org/apache/streams/data/moreover.json");
+
+        mapper = new ObjectMapper();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
+        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+        mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+    }
+
+    @Test
+    public void loadData() throws Exception {
+        for (JsonNode item : json) {
+            test(serializer.deserialize(getString(item)));
+        }
+    }
+
+
+    private String getString(JsonNode jsonNode)  {
+        try {
+            return new ObjectMapper().writeValueAsString(jsonNode);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerTest.java?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerTest.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerTest.java
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,45 @@
+package org.apache.streams.data;
+
+
+import org.apache.commons.io.IOUtils;
+import org.apache.streams.pojo.json.Activity;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.util.List;
+
+import static java.util.regex.Pattern.matches;
+import static org.apache.streams.data.util.MoreoverTestUtil.test;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class MoreoverXmlActivitySerializerTest {
+    ActivitySerializer serializer;
+    private String xml;
+
+    @Before
+    public void setup() throws IOException {
+        serializer = new MoreoverXmlActivitySerializer();
+        xml = loadXml();
+    }
+
+    @Test
+    public void loadData() throws Exception {
+        List<Activity> activities = serializer.deserializeAll(xml);
+        for (Activity activity : activities) {
+            test(activity);
+        }
+    }
+
+    private String loadXml() throws IOException {
+        StringWriter writer = new StringWriter();
+        InputStream resourceAsStream = this.getClass().getResourceAsStream("moreover.xml");
+        IOUtils.copy(resourceAsStream, writer, Charset.forName("UTF-8"));
+        return writer.toString();
+    }
+
+}

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,23 @@
+package org.apache.streams.data.util;
+
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.streams.pojo.json.Activity;
+
+import static java.util.regex.Pattern.matches;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class MoreoverTestUtil {
+
+    public static void test(Activity activity) {
+        assertThat(activity, is(not(nullValue())));
+        assertThat(activity.getActor(), is(not(nullValue())));
+        assertThat(activity.getObject(), is(not(nullValue())));
+        if(activity.getObject().getId() != null) {
+            assertThat(matches("id:.*:[a-z]*s:[a-zA-Z0-9]*", activity.getObject().getId()),
is(true));
+        }
+        assertThat(activity.getObject().getObjectType(), is(not(nullValue())));
+        System.out.println(activity.getPublished());
+    }
+}



Mime
View raw message