Permalink
Browse files

pulling in live feeds

  • Loading branch information...
1 parent 5d2ea04 commit 13603379e2c0de447591895f918a466281421241 @sophaz sophaz committed Feb 29, 2012
Showing with 48 additions and 11 deletions.
  1. +27 −8 app/controllers/Application.java
  2. +20 −2 app/controllers/RecommendationEngine.java
  3. +1 −1 conf/application.conf
@@ -123,7 +123,7 @@ public static void facebookLogin() {
User user;
if (userList == null || userList.size() == 0) {
- user = new User(profile.get("name").toString().replaceAll("\"", ""), profile.get("username").toString().replaceAll("\"", ""), profile.get("id").toString().replaceAll("\"", ""));
+ user = new User(profile.get("name").toString().replaceAll("\"", ""), profile.get("name").toString().replaceAll("\"", ""), profile.get("id").toString().replaceAll("\"", ""));
user.save();
} else {
user = userList.get(0);
@@ -200,30 +200,49 @@ public static void getRSSFeeds(String userId){
JsonObject user = FbGraph.getObject(userId, Parameter.with("access_token", "BAAFTZB1ThIZBQBACYExOvxBc569YgOr8YtjiETSbq8BkG6wnqegV2U8wCrEZBihZAGsU2h2wZBogtwTOAH5ZAb8QMY6qi6sHhviEHWHpIWjCxFFpHEdq0XOegD3LCNI4KMqrqwcjmCEwZDZD").parameters());
if (user!=null){
System.out.println("User: "+ user.get("name").toString());
+ String ui = user.get("id").toString().replaceAll("\"", "");
+ User friend = User.find("byUserId", ui).first();
+ if (friend == null) {
+ friend = new User(user.get("name").toString().replaceAll("\"", ""), user.get("name").toString().replaceAll("\"", ""), ui);
+ friend.save();
+ }
+ Session.current().put("user", friend.userId);
}
- else
+ else {
System.out.println("User not being created");
+ return;
+ }
} catch (FbGraphException e) {
System.out.println("There was an error in the getUserInformationMethod");
e.printStackTrace();
}
+
JsonObject obj = new JsonObject();
obj.addProperty("test", "Is Extracting");
//SOmething needs to happen here so that relevant articles are created
JsonObject article = new JsonObject();
- article.addProperty("Heading1", "Microsoft To Replace “Live” Branding With “Microsoft Account” In Windows 8");
- article.addProperty("Content1","The long-running “Live” name Microsoft has placed on its many connected services (Mail, messenger, photos, etc) is coming to an end in Windows 8, as part of their ongoing, major brand rehaul. Zune, of course, has been on its way out for some time, but will receive the coup de grace in Windows 8.Their main services are being rolled into bundled applications with a native Metro look and simpler names — Mail instead of Windows Live Mail, Photos instead of Windows Live Photo Gallery, and so on. The new apps will be tightly integrated, as we’ve seen in demos, and will retain much of the Live cross-service functionality. They’ll be unified by a single “Microsoft Account.”But Live isn’t going away entirely: the name is too strong to take away from Xbox Live and its subsidiary components, and in fact Xbox Live may be coming to Windows as the main entertainment brand — for music, games, and video content. This will replace Zune, which Microsoft has been gradually sweeping under the rug over the past two years. Zune fans mustn’t despair, though: Zune pass functionality will remain intact, and chances are the old desktop player and Zune hardware will continue to be supported in some way. And the fact is that Zune has left an indelible mark on Microsoft’s operations, pioneering the look and feel found in Windows Phone 7 and Windows 8.Smaller services, like Writer and Games for Windows Live, will likely be rolled into existing products. It’s in major brand shakedowns like this that one starts to realize just how many platforms and pieces of software Microsoft actually has and supports. This coalescence of services is probably coming as a huge relief to the company, though the labor involved in repurposing them is, naturally, Herculean. Conspicuously absent from the lineup mentioned is Messenger, which may be seeing some integration with Skype. A multi-service messenger/video-chat app with Skype built in seems likely, though Skype would definitely have to have a discrete presence as well for power users. No doubt they’ll leave behind many irate users who want things to remain the same — and indeed how Microsoft intends to accommodate these legacy users isn’t clear. Their new clean-break approach maroons many people on the old Windows XP/7 mainland, where they’ll likely remain until the launch quakes of Windows 8 clear away and the new land is safe for colonization.");
+ Topic topic1 = RecommendationEngine.fetchTopic(0);
+ Topic topic2 = RecommendationEngine.fetchTopic(1);
+ Topic topic3 = RecommendationEngine.fetchTopic(2);
+ article.addProperty("Heading1", topic1.title);
+ article.addProperty("Content1", topic1.description);
article.addProperty("ImageTag1", "http://tctechcrunch2011.files.wordpress.com/2012/02/winlive.jpg?w=100&h=70&crop=1");
- article.addProperty("Heading2", "Microsoft To Replace “Live” Branding With “Microsoft Account” In Windows 8");
- article.addProperty("Content2","The long-running “Live” name Microsoft has placed on its many connected services (Mail, messenger, photos, etc) is coming to an end in Windows 8, as part of their ongoing, major brand rehaul. Zune, of course, has been on its way out for some time, but will receive the coup de grace in Windows 8.Their main services are being rolled into bundled applications with a native Metro look and simpler names — Mail instead of Windows Live Mail, Photos instead of Windows Live Photo Gallery, and so on. The new apps will be tightly integrated, as we’ve seen in demos, and will retain much of the Live cross-service functionality. They’ll be unified by a single “Microsoft Account.”But Live isn’t going away entirely: the name is too strong to take away from Xbox Live and its subsidiary components, and in fact Xbox Live may be coming to Windows as the main entertainment brand — for music, games, and video content. This will replace Zune, which Microsoft has been gradually sweeping under the rug over the past two years. Zune fans mustn’t despair, though: Zune pass functionality will remain intact, and chances are the old desktop player and Zune hardware will continue to be supported in some way. And the fact is that Zune has left an indelible mark on Microsoft’s operations, pioneering the look and feel found in Windows Phone 7 and Windows 8.Smaller services, like Writer and Games for Windows Live, will likely be rolled into existing products. It’s in major brand shakedowns like this that one starts to realize just how many platforms and pieces of software Microsoft actually has and supports. This coalescence of services is probably coming as a huge relief to the company, though the labor involved in repurposing them is, naturally, Herculean. Conspicuously absent from the lineup mentioned is Messenger, which may be seeing some integration with Skype. A multi-service messenger/video-chat app with Skype built in seems likely, though Skype would definitely have to have a discrete presence as well for power users. No doubt they’ll leave behind many irate users who want things to remain the same — and indeed how Microsoft intends to accommodate these legacy users isn’t clear. Their new clean-break approach maroons many people on the old Windows XP/7 mainland, where they’ll likely remain until the launch quakes of Windows 8 clear away and the new land is safe for colonization.");
+ article.addProperty("Link1", topic1.link);
+
+ article.addProperty("Heading2", topic2.title);
+ article.addProperty("Content2", topic2.description);
article.addProperty("ImageTag2", "http://tctechcrunch2011.files.wordpress.com/2012/02/winlive.jpg?w=100&h=70&crop=1");
- article.addProperty("Heading3", "Microsoft To Replace “Live” Branding With “Microsoft Account” In Windows 8");
- article.addProperty("Content3","The long-running “Live” name Microsoft has placed on its many connected services (Mail, messenger, photos, etc) is coming to an end in Windows 8, as part of their ongoing, major brand rehaul. Zune, of course, has been on its way out for some time, but will receive the coup de grace in Windows 8.Their main services are being rolled into bundled applications with a native Metro look and simpler names — Mail instead of Windows Live Mail, Photos instead of Windows Live Photo Gallery, and so on. The new apps will be tightly integrated, as we’ve seen in demos, and will retain much of the Live cross-service functionality. They’ll be unified by a single “Microsoft Account.”But Live isn’t going away entirely: the name is too strong to take away from Xbox Live and its subsidiary components, and in fact Xbox Live may be coming to Windows as the main entertainment brand — for music, games, and video content. This will replace Zune, which Microsoft has been gradually sweeping under the rug over the past two years. Zune fans mustn’t despair, though: Zune pass functionality will remain intact, and chances are the old desktop player and Zune hardware will continue to be supported in some way. And the fact is that Zune has left an indelible mark on Microsoft’s operations, pioneering the look and feel found in Windows Phone 7 and Windows 8.Smaller services, like Writer and Games for Windows Live, will likely be rolled into existing products. It’s in major brand shakedowns like this that one starts to realize just how many platforms and pieces of software Microsoft actually has and supports. This coalescence of services is probably coming as a huge relief to the company, though the labor involved in repurposing them is, naturally, Herculean. Conspicuously absent from the lineup mentioned is Messenger, which may be seeing some integration with Skype. A multi-service messenger/video-chat app with Skype built in seems likely, though Skype would definitely have to have a discrete presence as well for power users. No doubt they’ll leave behind many irate users who want things to remain the same — and indeed how Microsoft intends to accommodate these legacy users isn’t clear. Their new clean-break approach maroons many people on the old Windows XP/7 mainland, where they’ll likely remain until the launch quakes of Windows 8 clear away and the new land is safe for colonization.");
+ article.addProperty("Link2", topic2.link);
+
+ article.addProperty("Heading3", topic3.title);
+ article.addProperty("Content3", topic3.description);
article.addProperty("ImageTag3", "http://tctechcrunch2011.files.wordpress.com/2012/02/winlive.jpg?w=100&h=70&crop=1");
+ article.addProperty("Link3", topic3.link);
+
renderJSON(article.toString());
}
@@ -18,6 +18,7 @@
import com.sun.cnpi.rss.parser.RssParserFactory;
import models.Choice;
+import models.Feed;
import models.LikeFrequency;
import models.LikeFrequencyComparator;
import models.LikeGroup;
@@ -74,30 +75,47 @@ public static Choice getChoice(int numRecommendations) {
public static Topic fetchTopic(int seed) {
JsonObject profile;
-
- User user = User.find("byUserId", Session.current().get("user")).first();
+
String tag;
if (seed == 0) {
tag = "Technology";
} else {
tag = "Fashion";
}
+ if (LikeGroup.count() == 0) {
+ LikeGroup.generateLikeGroupsFromStaticArray();
+ }
+
+ if (Feed.count() == 0) {
+ Application.generateFeeds();
+ RSSEngine.fetchNews();
+ }
+
+ User user = User.find("byUserId", Session.current().get("user")).first();
+
if (user != null) {
+ if (user.frequencyOfLikes == null || user.frequencyOfLikes.size() == 0) {
+ Application.getUserLikes();
+ }
List<LikeFrequency> likeFrequencies = user.frequencyOfLikes;
Collections.sort(likeFrequencies, new LikeFrequencyComparator());
LikeFrequency lf;
if (likeFrequencies.size() > seed) {
lf = likeFrequencies.get(seed);
tag = LikeGroup.getLikeGroupFromCategory(lf.likeCategory);
}
+ } else {
+ System.out.println("ERROR: Could not find user in session.");
+ return null;
}
System.out.println("The number "+ seed+ " most common liked topic is "+tag);
List<Topic> topics = Topic.find("select t from Topic t join t.tags as tag where tag = ?", tag).fetch();
/* If no topic is found, return a generic result */
if (topics == null || topics.size() == 0) {
+ System.out.println("ERROR: We found no topics! Going to generic search results");
topics = Topic.find("select t from Topic t join t.tags as tag where tag = ?", "Generic").fetch();
}
return topics.get(0);
@@ -82,7 +82,7 @@ date.format=yyyy-MM-dd
# To quickly set up a development database, use either:
# - mem : for a transient in memory database (H2 in memory)
# - fs : for a simple file written database (H2 file stored)
- db=mem
+ db=fs
#
# To connect to a local MySQL5 database, use:
# db=mysql://user:pwd@host/database

0 comments on commit 1360337

Please sign in to comment.