You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by mf...@apache.org on 2014/06/20 19:25:16 UTC
[3/5] git commit: STREAMS-107 | Added in license header and broke out
method to create a new StreamsDatum object. This way,
any classes that extend TwitterProfileProcessor can override how their
individual StreamsDatum objects get created (with a differe
STREAMS-107 | Added in license header and broke out method to create a new StreamsDatum object. This way, any classes that extend TwitterProfileProcessor can override how their individual StreamsDatum objects get created (with a different ID, for example)
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/ae740c8d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/ae740c8d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/ae740c8d
Branch: refs/heads/master
Commit: ae740c8d31f11fbe807a8fb1dcfc41b2646390fe
Parents: 829f805
Author: Robert Douglas <rd...@w2odigital.com>
Authored: Thu Jun 5 11:08:09 2014 -0500
Committer: Robert Douglas <rd...@w2odigital.com>
Committed: Thu Jun 5 11:08:09 2014 -0500
----------------------------------------------------------------------
.../processor/TwitterProfileProcessor.java | 29 ++++++++++++++++----
1 file changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/ae740c8d/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterProfileProcessor.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterProfileProcessor.java b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterProfileProcessor.java
index c42943f..5d09a84 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterProfileProcessor.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterProfileProcessor.java
@@ -1,3 +1,19 @@
+/*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.*/
package org.apache.streams.twitter.processor;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -17,9 +33,6 @@ import java.util.List;
import java.util.Queue;
import java.util.Random;
-/**
- * Created by sblackmon on 12/10/13.
- */
public class TwitterProfileProcessor implements StreamsProcessor, Runnable {
private final static Logger LOGGER = LoggerFactory.getLogger(TwitterProfileProcessor.class);
@@ -57,6 +70,10 @@ public class TwitterProfileProcessor implements StreamsProcessor, Runnable {
}
}
+ public StreamsDatum createStreamsDatum(User user) {
+ return new StreamsDatum(user, user.getIdStr());
+ }
+
@Override
public List<StreamsDatum> process(StreamsDatum entry) {
@@ -79,17 +96,17 @@ public class TwitterProfileProcessor implements StreamsProcessor, Runnable {
LOGGER.debug("TWEET");
Tweet tweet = mapper.readValue(item, Tweet.class);
user = tweet.getUser();
- result.add(new StreamsDatum(user, user.getIdStr()));
+ result.add(createStreamsDatum(user));
}
else if ( inClass.equals( Retweet.class )) {
LOGGER.debug("RETWEET");
Retweet retweet = mapper.readValue(item, Retweet.class);
user = retweet.getRetweetedStatus().getUser();
- result.add(new StreamsDatum(user, user.getIdStr()));
+ result.add(createStreamsDatum(user));
} else if ( inClass.equals( User.class )) {
LOGGER.debug("USER");
user = mapper.readValue(item, User.class);
- result.add(new StreamsDatum(user, user.getIdStr()));
+ result.add(createStreamsDatum(user));
} else {
return Lists.newArrayList();
}