tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1104231 - in /tuscany/collaboration/GSoC-2011-Eranda: ./ twitapp/ twitapp/.settings/ twitapp/src/ twitapp/src/main/ twitapp/src/main/java/ twitapp/src/main/java/twitapp/ twitapp/src/main/java/twitapp/services/ twitapp/src/main/java/twitapp...
Date Tue, 17 May 2011 13:21:30 GMT
Author: antelder
Date: Tue May 17 13:21:30 2011
New Revision: 1104231

URL: http://svn.apache.org/viewvc?rev=1104231&view=rev
Log:
TUSCANY-3522: Commit the twitapp program Eranda Sooriyabandara has attached as part of the
GSoC project Develop a 'NoSQL' Datastore component for Apache Cassandra, CouchDB, Hadoop/Hbase

Added:
    tuscany/collaboration/GSoC-2011-Eranda/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/.classpath
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/.project
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/.settings/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/.settings/org.eclipse.jdt.core.prefs
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/AppManager.java
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/Twit.java
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/User.java
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserBase.java
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserManager.java
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/test/
    tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/test/TwitAppTest.java

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/.classpath
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/.classpath?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/.classpath (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/.classpath Tue May 17 13:21:30 2011
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/.project
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/.project?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/.project (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/.project Tue May 17 13:21:30 2011
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>twitapp</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/.settings/org.eclipse.jdt.core.prefs?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/.settings/org.eclipse.jdt.core.prefs (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/.settings/org.eclipse.jdt.core.prefs Tue
May 17 13:21:30 2011
@@ -0,0 +1,12 @@
+#Fri May 13 10:53:56 IST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/AppManager.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/AppManager.java?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/AppManager.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/AppManager.java
Tue May 17 13:21:30 2011
@@ -0,0 +1,39 @@
+package main.java.twitapp.services;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class AppManager {
+	
+	private User user;
+	private UserBase userBase;
+	
+	public AppManager(String userId){
+		userBase = UserBase.getInstance();
+		user = userBase.get(userId);
+	}
+	
+	public void twit(String twit){
+		user.setTwit(new Twit(twit));
+	}
+	
+	public void follow(String followId){
+		user.setFollower(userBase.get(followId));
+	}
+	
+	public Iterator<User> getFollowers(){
+		ArrayList<User> users = user.getFollowers();
+		return users.iterator();
+	}
+	
+	public Iterator<Twit> getTwits(){
+		ArrayList<Twit> twits = user.getTwits();
+		return twits.iterator();
+	}
+	
+	public Iterator<Twit> getFollowerTwits(String followeId){
+		ArrayList<Twit> followerTwits= userBase.get(followeId).getTwits();
+		return followerTwits.iterator();
+	}
+	
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/Twit.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/Twit.java?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/Twit.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/Twit.java
Tue May 17 13:21:30 2011
@@ -0,0 +1,23 @@
+package main.java.twitapp.services;
+
+import java.util.Date;
+
+public class Twit {
+	
+	private String twit;
+	private final Date timestamp;
+	
+	public Twit(String twit){
+		this.twit = twit;
+		timestamp = new Date();
+	}
+	
+	public String toString(){
+		return  twit;
+	}
+	
+	public Date getTimestamp(){
+		return timestamp;
+	}
+
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/User.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/User.java?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/User.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/User.java
Tue May 17 13:21:30 2011
@@ -0,0 +1,49 @@
+package main.java.twitapp.services;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+
+public class User {
+	
+	private String name;
+	private ArrayList<User> followers = new ArrayList<User>();
+	private ArrayList<Twit> twits = new ArrayList<Twit>();
+	
+	public User(String name){
+		this.name = name;
+	}
+	
+	public String getName() {
+		return name;
+	}
+
+	public void setFollower(User follower){
+		followers.add(follower);
+	}
+	
+	public ArrayList<User> getFollowers(){
+		return followers;
+	}
+	
+	public void setTwit(Twit twit){
+		twits.add(twit);
+	}
+	
+	public ArrayList<Twit> getTwits(){
+		return twits;
+	}
+	
+	public ArrayList<Twit> getTwits(Date date){
+		Iterator<Twit> t = twits.iterator();
+		ArrayList<Twit> newer = new ArrayList<Twit>(); 
+		Twit tt;
+		while((tt = t.next())!=null){
+			if(tt.getTimestamp().after(date)){
+				newer.add(tt);
+			}
+		}
+		return newer;
+	}		
+	
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserBase.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserBase.java?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserBase.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserBase.java
Tue May 17 13:21:30 2011
@@ -0,0 +1,21 @@
+package main.java.twitapp.services;
+
+import java.util.HashMap;
+
+public class UserBase extends HashMap<String, User> {
+	
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private static UserBase userBase = new UserBase();
+	
+	private UserBase(){
+	}
+	
+	public static UserBase getInstance(){
+		return userBase;
+	}
+	
+	
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserManager.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserManager.java?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserManager.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/services/UserManager.java
Tue May 17 13:21:30 2011
@@ -0,0 +1,18 @@
+package main.java.twitapp.services;
+
+public class UserManager {
+	
+	UserBase userBase;
+	
+	public UserManager(){
+		userBase = UserBase.getInstance();
+	}
+	
+	public void addUser(String userId,String name){
+		userBase.put(userId, new User(name));
+	}
+	
+	public void removeUser(String userId){
+		userBase.remove(userId);
+	}
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/test/TwitAppTest.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/test/TwitAppTest.java?rev=1104231&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/test/TwitAppTest.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/twitapp/src/main/java/twitapp/test/TwitAppTest.java
Tue May 17 13:21:30 2011
@@ -0,0 +1,32 @@
+package main.java.twitapp.test;
+
+import java.util.Iterator;
+
+import main.java.twitapp.services.AppManager;
+import main.java.twitapp.services.Twit;
+import main.java.twitapp.services.UserManager;
+
+public class TwitAppTest {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		UserManager userManager = new UserManager();	
+		userManager.addUser("eranda", "Eranda Sooriyabandara");
+		userManager.addUser("ishara", "Ishara Karunarathne");
+		
+		AppManager manager1 = new AppManager("eranda");
+		manager1.twit("Won the world cup 2011");
+		
+		AppManager manager2 = new AppManager("ishara");
+		manager2.follow("eranda");
+		
+		Iterator<Twit> twits = manager2.getFollowerTwits("eranda");
+		while(twits.hasNext()){
+			System.out.println(twits.next().toString());
+		}
+
+	}
+
+}



Mime
View raw message