streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [06/15] git commit: user mention detection working v0 bean to help configure managed sources via API
Date Thu, 28 Aug 2014 19:26:51 GMT
user mention detection working
v0 bean to help configure managed sources via API


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

Branch: refs/heads/master
Commit: 6381dc978b1a9794cd31dec909574015f820bd77
Parents: 9acc2f0
Author: sblackmon <sblackmon@w2odigital.com>
Authored: Fri Aug 8 11:47:55 2014 -0500
Committer: sblackmon <sblackmon@apache.org>
Committed: Tue Aug 12 18:04:23 2014 -0500

----------------------------------------------------------------------
 .../regex/AbstractRegexExtensionExtractor.java  |  13 ++-
 .../com/datasift/DatasiftConfiguration.json     | 115 ++++++++++++++++++-
 2 files changed, 123 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6381dc97/streams-contrib/streams-processor-regex/src/main/java/org/apache/streams/regex/AbstractRegexExtensionExtractor.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-processor-regex/src/main/java/org/apache/streams/regex/AbstractRegexExtensionExtractor.java
b/streams-contrib/streams-processor-regex/src/main/java/org/apache/streams/regex/AbstractRegexExtensionExtractor.java
index afd4972..ef31cdf 100644
--- a/streams-contrib/streams-processor-regex/src/main/java/org/apache/streams/regex/AbstractRegexExtensionExtractor.java
+++ b/streams-contrib/streams-processor-regex/src/main/java/org/apache/streams/regex/AbstractRegexExtensionExtractor.java
@@ -19,11 +19,14 @@
 
 package org.apache.streams.regex;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import org.apache.streams.core.StreamsDatum;
 import org.apache.streams.core.StreamsProcessor;
+import org.apache.streams.jackson.StreamsJacksonMapper;
 import org.apache.streams.pojo.json.Activity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,6 +49,7 @@ public abstract class AbstractRegexExtensionExtractor<T> implements
StreamsProce
 
     private final static Logger LOGGER = LoggerFactory.getLogger(AbstractRegexExtensionExtractor.class);
 
+    private final static ObjectMapper mapper = StreamsJacksonMapper.getInstance();
 
     private String pattern;
 
@@ -61,18 +65,23 @@ public abstract class AbstractRegexExtensionExtractor<T> implements
StreamsProce
 
     @Override
     public List<StreamsDatum> process(StreamsDatum entry) {
-        if (!(entry.getDocument() instanceof Activity)) {
+        Activity activity;
+        if (entry.getDocument() instanceof Activity) {
+            activity = (Activity) entry.getDocument();
+        } else if (entry.getDocument() instanceof ObjectNode) {
+            activity = mapper.convertValue(entry.getDocument(), Activity.class);
+        } else {
             return Lists.newArrayList();
         }
         if (Strings.isNullOrEmpty(pattern)) {
             prepare(null);
         }
-        Activity activity = (Activity) entry.getDocument();
         Map<String, List<Integer>> matches = RegexUtils.extractMatches(pattern,
activity.getContent());
         Collection<T> entities = ensureTargetObject(activity);
         for (String key : matches.keySet()) {
             entities.add(prepareObject(key));
         }
+        entry.setDocument(activity);
         return Lists.newArrayList(entry);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6381dc97/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftConfiguration.json
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftConfiguration.json
b/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftConfiguration.json
index f9a3574..ae9daa6 100644
--- a/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftConfiguration.json
+++ b/streams-contrib/streams-provider-datasift/src/main/jsonschema/com/datasift/DatasiftConfiguration.json
@@ -2,8 +2,10 @@
     "type": "object",
     "$schema": "http://json-schema.org/draft-03/schema",
     "id": "#",
-    "javaType" : "org.apache.streams.datasift.DatasiftConfiguration",
-    "javaInterfaces": ["java.io.Serializable"],
+    "javaType": "org.apache.streams.datasift.DatasiftConfiguration",
+    "javaInterfaces": [
+        "java.io.Serializable"
+    ],
     "properties": {
         "apiKey": {
             "type": "string"
@@ -13,10 +15,117 @@
         },
         "streamHash": {
             "type": "array",
-            "minItems": 1,
+            "minItems": 0,
             "items": {
                 "type": "string"
             }
+        },
+        "streamCsdl": {
+            "type": "array",
+            "minItems": 0,
+            "items": {
+                "type": "string"
+            }
+        },
+        "managedSources": {
+            "type": "array",
+            "minItems": 0,
+            "items": {
+                "javaType": "org.apache.streams.datasift.managed.ManagedSource",
+                "type": "object",
+                "properties": {
+                    "auth": {
+                        "type": "array",
+                        "items": {
+                            "javaType": "org.apache.streams.datasift.managed.ManagedSourceAuth",
+                            "type": "object",
+                            "properties": {
+                                "identity_id": {
+                                    "type": "string"
+                                },
+                                "parameters": {
+                                    "type": "object",
+                                    "properties": {
+                                        "value": {
+                                            "type": "string"
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "created_at": {
+                        "type": "number"
+                    },
+                    "id": {
+                        "type": "string"
+                    },
+                    "name": {
+                        "type": "string"
+                    },
+                    "parameters": {
+                        "javaType": "org.apache.streams.datasift.managed.ManagedSourceParameters",
+                        "type": "object",
+                        "properties": {
+                            "comments": {
+                                "type": "boolean"
+                            },
+                            "likes": {
+                                "type": "boolean"
+                            }
+                        }
+                    },
+                    "resources": {
+                        "type": "array",
+                        "items": [
+                            {
+                                "javaType": "org.apache.streams.datasift.managed.ManagedSourceResource",
+                                "type": "object",
+                                "properties": {
+                                    "parameters": {
+                                        "type": "object",
+                                        "properties": {
+                                            "distance": {
+                                                "type": "string"
+                                            },
+                                            "exact_match": {
+                                                "type": "string"
+                                            },
+                                            "foursq": {
+                                                "type": "string"
+                                            },
+                                            "lat": {
+                                                "type": "string"
+                                            },
+                                            "lng": {
+                                                "type": "string"
+                                            },
+                                            "type": {
+                                                "type": "string"
+                                            },
+                                            "usermeta": {
+                                                "type": "string"
+                                            },
+                                            "value": {
+                                                "type": "number"
+                                            }
+                                        }
+                                    },
+                                    "resource_id": {
+                                        "type": "string"
+                                    }
+                                }
+                            }
+                        ]
+                    },
+                    "source_type": {
+                        "type": "string"
+                    },
+                    "status": {
+                        "type": "string"
+                    }
+                }
+            }
         }
     }
 }
\ No newline at end of file


Mime
View raw message