streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [28/47] git commit: Created DatasiftTwitterUser object
Date Mon, 21 Jul 2014 15:45:14 GMT
Created DatasiftTwitterUser object


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/b7bf172a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/b7bf172a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/b7bf172a

Branch: refs/heads/STREAMS-46
Commit: b7bf172a623fa484e8068abe46ca0d39ed693593
Parents: c50ce91
Author: rebanks <rebanks@w2odigital.com>
Authored: Tue Jul 8 14:33:25 2014 -0500
Committer: rebanks <rebanks@w2odigital.com>
Committed: Tue Jul 8 14:33:25 2014 -0500

----------------------------------------------------------------------
 .../DatasiftTweetActivitySerializer.java        |  92 +++++-----
 .../main/jsonschema/com/datasift/Datasift.json  | 179 +------------------
 .../com/datasift/DatasiftTwitterUser.json       |  61 +++++++
 3 files changed, 113 insertions(+), 219 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b7bf172a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
b/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
index 3406eb4..269f12a 100644
--- a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
+++ b/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
@@ -25,7 +25,7 @@ import com.google.common.collect.Maps;
 import org.apache.streams.data.util.RFC3339Utils;
 import org.apache.streams.datasift.Datasift;
 import org.apache.streams.datasift.interaction.Interaction;
-import org.apache.streams.datasift.interaction.User;
+import org.apache.streams.datasift.twitter.DatasiftTwitterUser;
 import org.apache.streams.datasift.twitter.Retweet;
 import org.apache.streams.datasift.twitter.Twitter;
 import org.apache.streams.pojo.json.Activity;
@@ -80,10 +80,10 @@ public class DatasiftTweetActivitySerializer extends DatasiftDefaultActivitySeri
     }
 
     public Actor buildActor(Datasift event, Twitter twitter) {
-        User user = twitter.getUser();
+        DatasiftTwitterUser user = twitter.getUser();
         Actor actor = super.buildActor(event.getInteraction());
         if(user == null) {
-            return retweetBuildActor(actor, twitter.getRetweet().getUser());
+            user = twitter.getRetweet().getUser();
         }
 
         actor.setDisplayName(user.getName());
@@ -130,49 +130,49 @@ public class DatasiftTweetActivitySerializer extends DatasiftDefaultActivitySeri
     }
 
     //Need to make retweet user and tweet user the same object.
-    public Actor retweetBuildActor(Actor actor, org.apache.streams.datasift.twitter.User
user) {
-
-        actor.setDisplayName(user.getName());
-        actor.setId(formatId(Optional.fromNullable(
-                user.getIdStr())
-                .or(Optional.of(user.getId().toString()))
-                .orNull()));
-        actor.setSummary(user.getDescription());
-        try {
-            actor.setPublished(RFC3339Utils.parseToUTC(user.getCreatedAt()));
-        } catch (Exception e) {
-            LOGGER.warn("Exception trying to parse date : {}", e);
-        }
-
-        if(user.getUrl() != null) {
-            actor.setUrl(user.getUrl());
-        }
-
-        Map<String, Object> extensions = new HashMap<String,Object>();
-        extensions.put("location", user.getLocation());
-        extensions.put("posts", user.getStatusesCount());
-        extensions.put("followers", user.getFollowersCount());
-        extensions.put("screenName", user.getScreenName());
-        if(user.getAdditionalProperties() != null) {
-            extensions.put("favorites", user.getAdditionalProperties().get("favourites_count"));
-        }
-
-        Image profileImage = new Image();
-        String profileUrl = null;
-        if(actor.getImage() == null && user.getAdditionalProperties() != null) {
-            Object url = user.getAdditionalProperties().get("profile_image_url_https");
-            if(url instanceof String)
-                profileUrl = (String) url;
-        }
-        if(actor.getImage() == null && profileUrl == null) {
-            profileUrl = user.getProfileImageUrl();
-        }
-        profileImage.setUrl(profileUrl);
-        actor.setImage(profileImage);
-
-        actor.setAdditionalProperty("extensions", extensions);
-        return actor;
-    }
+//    public Actor retweetBuildActor(Actor actor, org.apache.streams.datasift.twitter.User
user) {
+//
+//        actor.setDisplayName(user.getName());
+//        actor.setId(formatId(Optional.fromNullable(
+//                user.getIdStr())
+//                .or(Optional.of(user.getId().toString()))
+//                .orNull()));
+//        actor.setSummary(user.getDescription());
+//        try {
+//            actor.setPublished(RFC3339Utils.parseToUTC(user.getCreatedAt()));
+//        } catch (Exception e) {
+//            LOGGER.warn("Exception trying to parse date : {}", e);
+//        }
+//
+//        if(user.getUrl() != null) {
+//            actor.setUrl(user.getUrl());
+//        }
+//
+//        Map<String, Object> extensions = new HashMap<String,Object>();
+//        extensions.put("location", user.getLocation());
+//        extensions.put("posts", user.getStatusesCount());
+//        extensions.put("followers", user.getFollowersCount());
+//        extensions.put("screenName", user.getScreenName());
+//        if(user.getAdditionalProperties() != null) {
+//            extensions.put("favorites", user.getAdditionalProperties().get("favourites_count"));
+//        }
+//
+//        Image profileImage = new Image();
+//        String profileUrl = null;
+//        if(actor.getImage() == null && user.getAdditionalProperties() != null)
{
+//            Object url = user.getAdditionalProperties().get("profile_image_url_https");
+//            if(url instanceof String)
+//                profileUrl = (String) url;
+//        }
+//        if(actor.getImage() == null && profileUrl == null) {
+//            profileUrl = user.getProfileImageUrl();
+//        }
+//        profileImage.setUrl(profileUrl);
+//        actor.setImage(profileImage);
+//
+//        actor.setAdditionalProperty("extensions", extensions);
+//        return actor;
+//    }
 
     public void addLocationExtension(Activity activity, Twitter twitter) {
         Map<String, Object> extensions = ensureExtensions(activity);

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b7bf172a/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/Datasift.json
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/Datasift.json
b/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/Datasift.json
index e7b664a..8d7ff3a 100644
--- a/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/Datasift.json
+++ b/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/Datasift.json
@@ -947,62 +947,8 @@
                             "type": "string"
                         },
                         "user": {
-                            "javaType": "org.apache.streams.datasift.twitter.User",
-                            "type": "object",
-                            "dynamic": "true",
-                            "properties": {
-                                "created_at": {
-                                    "type": "string"
-                                },
-                                "description": {
-                                    "type": "string"
-                                },
-                                "followers_count": {
-                                    "type": "integer"
-                                },
-                                "friends_count": {
-                                    "type": "integer"
-                                },
-                                "geo_enabled": {
-                                    "type": "boolean"
-                                },
-                                "id": {
-                                    "type": "integer"
-                                },
-                                "id_str": {
-                                    "type": "string"
-                                },
-                                "lang": {
-                                    "type": "string"
-                                },
-                                "listed_count": {
-                                    "type": "integer"
-                                },
-                                "location": {
-                                    "type": "string"
-                                },
-                                "name": {
-                                    "type": "string"
-                                },
-                                "profile_image_url": {
-                                    "type": "string"
-                                },
-                                "screen_name": {
-                                    "type": "string"
-                                },
-                                "statuses_count": {
-                                    "type": "integer"
-                                },
-                                "time_zone": {
-                                    "type": "string"
-                                },
-                                "url": {
-                                    "type": "string"
-                                },
-                                "utc_offset": {
-                                    "type": "integer"
-                                }
-                            }
+                            "type": "DatasiftTwitterUser",
+                            "$ref": "./DatasiftTwitterUser.json"
                         }
                     }
                 },
@@ -1062,64 +1008,8 @@
                             "type": "string"
                         },
                         "user": {
-                            "javaType": "org.apache.streams.datasift.twitter.User",
-                            "dynamic": "true",
-                            "properties": {
-                                "created_at": {
-                                    "type": "string"
-                                },
-                                "description": {
-                                    "type": "string"
-                                },
-                                "followers_count": {
-                                    "type": "integer"
-                                },
-                                "friends_count": {
-                                    "type": "integer"
-                                },
-                                "geo_enabled": {
-                                    "type": "boolean"
-                                },
-                                "id": {
-                                    "type": "integer"
-                                },
-                                "id_str": {
-                                    "type": "string"
-                                },
-                                "lang": {
-                                    "type": "string"
-                                },
-                                "listed_count": {
-                                    "type": "integer"
-                                },
-                                "location": {
-                                    "type": "string"
-                                },
-                                "name": {
-                                    "type": "string"
-                                },
-                                "profile_image_url": {
-                                    "type": "string"
-                                },
-                                "screen_name": {
-                                    "type": "string"
-                                },
-                                "statuses_count": {
-                                    "type": "integer"
-                                },
-                                "time_zone": {
-                                    "type": "string"
-                                },
-                                "url": {
-                                    "type": "string"
-                                },
-                                "utc_offset": {
-                                    "type": "integer"
-                                },
-                                "verified": {
-                                    "type": "boolean"
-                                }
-                            }
+                            "type": "DatasiftTwitterUser",
+                            "$ref": "./DatasiftTwitterUser.json"
                         }
                     }
                 },
@@ -1130,65 +1020,8 @@
                     "type": "string"
                 },
                 "user": {
-                    "javaType": "org.apache.streams.datasift.interaction.User",
-                    "type": "object",
-                    "dynamic": "true",
-                    "properties": {
-                        "created_at": {
-                            "type": "string"
-                        },
-                        "description": {
-                            "type": "string"
-                        },
-                        "followers_count": {
-                            "type": "integer"
-                        },
-                        "friends_count": {
-                            "type": "integer"
-                        },
-                        "geo_enabled": {
-                            "type": "boolean"
-                        },
-                        "id": {
-                            "type": "integer"
-                        },
-                        "id_str": {
-                            "type": "string"
-                        },
-                        "lang": {
-                            "type": "string"
-                        },
-                        "listed_count": {
-                            "type": "integer"
-                        },
-                        "location": {
-                            "type": "string"
-                        },
-                        "name": {
-                            "type": "string"
-                        },
-                        "profile_image_url": {
-                            "type": "string"
-                        },
-                        "screen_name": {
-                            "type": "string"
-                        },
-                        "statuses_count": {
-                            "type": "integer"
-                        },
-                        "time_zone": {
-                            "type": "string"
-                        },
-                        "url": {
-                            "type": "string"
-                        },
-                        "utc_offset": {
-                            "type": "integer"
-                        },
-                        "verified": {
-                            "type": "boolean"
-                        }
-                    }
+                    "type": "DatasiftTwitterUser",
+                    "$ref": "./DatasiftTwitterUser.json"
                 }
             }
         },

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b7bf172a/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftTwitterUser.json
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftTwitterUser.json
b/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftTwitterUser.json
new file mode 100644
index 0000000..97d93fe
--- /dev/null
+++ b/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftTwitterUser.json
@@ -0,0 +1,61 @@
+{
+    "type": "object",
+    "$schema": "http://json-schema.org/draft-03/schema",
+    "javaType": "org.apache.streams.datasift.twitter.DatasiftTwitterUser",
+    "properties": {
+        "created_at": {
+            "type": "string"
+        },
+        "description": {
+            "type": "string"
+        },
+        "followers_count": {
+            "type": "integer"
+        },
+        "friends_count": {
+            "type": "integer"
+        },
+        "geo_enabled": {
+            "type": "boolean"
+        },
+        "id": {
+            "type": "integer"
+        },
+        "id_str": {
+            "type": "string"
+        },
+        "lang": {
+            "type": "string"
+        },
+        "listed_count": {
+            "type": "integer"
+        },
+        "location": {
+            "type": "string"
+        },
+        "name": {
+            "type": "string"
+        },
+        "profile_image_url": {
+            "type": "string"
+        },
+        "screen_name": {
+            "type": "string"
+        },
+        "statuses_count": {
+            "type": "integer"
+        },
+        "time_zone": {
+            "type": "string"
+        },
+        "url": {
+            "type": "string"
+        },
+        "utc_offset": {
+            "type": "integer"
+        },
+        "verified": {
+            "type": "boolean"
+        }
+    }
+}
\ No newline at end of file


Mime
View raw message