Browse Source

added MVC skeleton

Kr Younger 6 years ago
parent
commit
17ffb2b0d7

+ 17
- 0
.project View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>YouAreEll</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.eclipse.m2e.core.maven2Builder</name>
10
+			<arguments>
11
+			</arguments>
12
+		</buildCommand>
13
+	</buildSpec>
14
+	<natures>
15
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
16
+	</natures>
17
+</projectDescription>

+ 4
- 0
.settings/org.eclipse.m2e.core.prefs View File

1
+activeProfiles=
2
+eclipse.preferences.version=1
3
+resolveWorkspaceProjects=true
4
+version=1

+ 44
- 0
Client/.classpath View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<classpath>
3
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
4
+		<attributes>
5
+			<attribute name="optional" value="true"/>
6
+			<attribute name="maven.pomderived" value="true"/>
7
+		</attributes>
8
+	</classpathentry>
9
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10
+		<attributes>
11
+			<attribute name="optional" value="true"/>
12
+			<attribute name="maven.pomderived" value="true"/>
13
+			<attribute name="test" value="true"/>
14
+		</attributes>
15
+	</classpathentry>
16
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
17
+		<attributes>
18
+			<attribute name="maven.pomderived" value="true"/>
19
+		</attributes>
20
+	</classpathentry>
21
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22
+		<attributes>
23
+			<attribute name="maven.pomderived" value="true"/>
24
+		</attributes>
25
+	</classpathentry>
26
+	<classpathentry kind="src" path="target/generated-sources/annotations">
27
+		<attributes>
28
+			<attribute name="optional" value="true"/>
29
+			<attribute name="maven.pomderived" value="true"/>
30
+			<attribute name="ignore_optional_problems" value="true"/>
31
+			<attribute name="m2e-apt" value="true"/>
32
+		</attributes>
33
+	</classpathentry>
34
+	<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
35
+		<attributes>
36
+			<attribute name="optional" value="true"/>
37
+			<attribute name="maven.pomderived" value="true"/>
38
+			<attribute name="ignore_optional_problems" value="true"/>
39
+			<attribute name="m2e-apt" value="true"/>
40
+			<attribute name="test" value="true"/>
41
+		</attributes>
42
+	</classpathentry>
43
+	<classpathentry kind="output" path="target/classes"/>
44
+</classpath>

+ 23
- 0
Client/.project View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>Client</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.eclipse.jdt.core.javabuilder</name>
10
+			<arguments>
11
+			</arguments>
12
+		</buildCommand>
13
+		<buildCommand>
14
+			<name>org.eclipse.m2e.core.maven2Builder</name>
15
+			<arguments>
16
+			</arguments>
17
+		</buildCommand>
18
+	</buildSpec>
19
+	<natures>
20
+		<nature>org.eclipse.jdt.core.javanature</nature>
21
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
22
+	</natures>
23
+</projectDescription>

+ 2
- 0
Client/.settings/org.eclipse.jdt.apt.core.prefs View File

1
+eclipse.preferences.version=1
2
+org.eclipse.jdt.apt.aptEnabled=false

+ 7
- 0
Client/.settings/org.eclipse.jdt.core.prefs View File

1
+eclipse.preferences.version=1
2
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3
+org.eclipse.jdt.core.compiler.compliance=1.5
4
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
6
+org.eclipse.jdt.core.compiler.release=disabled
7
+org.eclipse.jdt.core.compiler.source=1.5

+ 4
- 0
Client/.settings/org.eclipse.m2e.core.prefs View File

1
+activeProfiles=
2
+eclipse.preferences.version=1
3
+resolveWorkspaceProjects=true
4
+version=1

BIN
Client/src/main/.DS_Store View File


+ 11
- 2
Client/src/main/java/YouAreEll.java View File

1
+import controllers.*;
2
+
1
 public class YouAreEll {
3
 public class YouAreEll {
2
 
4
 
3
-    YouAreEll() {
5
+    private MessageController msgCtrl;
6
+    private IdController idCtrl;
7
+
8
+    public YouAreEll (MessageController m, IdController j) {
9
+        // used j because i seems awkward
10
+        this.msgCtrl = m;
11
+        this.idCtrl = j;
4
     }
12
     }
5
 
13
 
6
     public static void main(String[] args) {
14
     public static void main(String[] args) {
7
-        YouAreEll urlhandler = new YouAreEll();
15
+        // hmm: is this Dependency Injection?
16
+        YouAreEll urlhandler = new YouAreEll(new MessageController(), new IdController());
8
         System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
17
         System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
9
         System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
18
         System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
10
     }
19
     }

+ 22
- 0
Client/src/main/java/controllers/IdController.java View File

1
+package controllers;
2
+
3
+import java.util.ArrayList;
4
+
5
+import models.Id;
6
+
7
+public class IdController {
8
+    Id myId;
9
+
10
+    public ArrayList<Id> getIds() {
11
+        return null;
12
+    }
13
+
14
+    public Id postId(Id id) {
15
+        return null;
16
+    }
17
+
18
+    public Id putId(Id id) {
19
+        return null;
20
+    }
21
+ 
22
+}

+ 31
- 0
Client/src/main/java/controllers/MessageController.java View File

1
+package controllers;
2
+
3
+import java.util.ArrayList;
4
+import java.util.HashSet;
5
+
6
+import models.Id;
7
+import models.Message;
8
+
9
+public class MessageController {
10
+
11
+    private HashSet<Message> messagesSeen;
12
+    // why a HashSet??
13
+
14
+    public ArrayList<Message> getMessages() {
15
+        return null;
16
+    }
17
+    public ArrayList<Message> getMessagesForId(Id Id) {
18
+        return null;
19
+    }
20
+    public Message getMessageForSequence(String seq) {
21
+        return null;
22
+    }
23
+    public ArrayList<Message> getMessagesFromFriend(Id myId, Id friendId) {
24
+        return null;
25
+    }
26
+
27
+    public Message postMessage(Id myId, Id toId, Message msg) {
28
+        return null;
29
+    }
30
+ 
31
+}

+ 7
- 0
Client/src/main/java/controllers/TransactionController.java View File

1
+package controllers;
2
+
3
+public class TransactionController {
4
+    private String rootURL = "http://zipcode.rocks:8085";
5
+
6
+    public TransactionController() {}
7
+}

+ 10
- 0
Client/src/main/java/models/Id.java View File

1
+package models;
2
+
3
+/* 
4
+ * POJO for an Id object
5
+ */
6
+public class Id {
7
+    
8
+    public Id (String name, String githubId) {}
9
+
10
+}

+ 10
- 0
Client/src/main/java/models/Message.java View File

1
+package models;
2
+
3
+/* 
4
+ * POJO for an Message object
5
+ */
6
+public class Message {
7
+
8
+    public Message (String message, String fromId, String toId) {}
9
+
10
+}

+ 13
- 0
Client/src/main/java/views/IdTextView.java View File

1
+package views;
2
+
3
+import models.Id;
4
+
5
+public class IdTextView {
6
+
7
+    public IdTextView(Id idToDisplay) {
8
+
9
+    }
10
+    @Override public String toString() {
11
+        return null;
12
+    } 
13
+}

+ 13
- 0
Client/src/main/java/views/MessageTextView.java View File

1
+package views;
2
+
3
+import models.Message;
4
+
5
+public class MessageTextView {
6
+
7
+    public MessageTextView(Message msgToDisplay) {
8
+
9
+    }
10
+    @Override public String toString() {
11
+        return null;
12
+    } 
13
+}

Client/src/main/java/SimpleShell.java → Client/src/main/java/views/SimpleShell.java View File

1
+package views;
2
+
1
 import java.io.BufferedReader;
3
 import java.io.BufferedReader;
2
 import java.io.IOException;
4
 import java.io.IOException;
3
 import java.io.InputStream;
5
 import java.io.InputStream;
5
 import java.util.ArrayList;
7
 import java.util.ArrayList;
6
 import java.util.List;
8
 import java.util.List;
7
 
9
 
10
+import controllers.IdController;
11
+import controllers.MessageController;
12
+
13
+// Simple Shell is a Console view for YouAreEll.
8
 public class SimpleShell {
14
 public class SimpleShell {
9
 
15
 
10
 
16
 
14
     }
20
     }
15
     public static void main(String[] args) throws java.io.IOException {
21
     public static void main(String[] args) throws java.io.IOException {
16
 
22
 
17
-        YouAreEll webber = new YouAreEll();
23
+        YouAreEll webber = new YouAreEll(new MessageController(), new IdController());
24
+        
18
         String commandLine;
25
         String commandLine;
19
         BufferedReader console = new BufferedReader
26
         BufferedReader console = new BufferedReader
20
                 (new InputStreamReader(System.in));
27
                 (new InputStreamReader(System.in));

+ 5
- 0
README.md View File

2
 
2
 
3
 ## Client HTTP/REST API for UnderARock
3
 ## Client HTTP/REST API for UnderARock
4
 
4
 
5
+You'll write a Client to exchange JSON data over HTTP with a Server, in this case, the UnderARock(TM) server.
5
 
6
 
6
 ### The Point
7
 ### The Point
8
+
7
 * You are to write a command interpreter using the provided `SimpleShell` class.
9
 * You are to write a command interpreter using the provided `SimpleShell` class.
8
 * You're going to create a way
10
 * You're going to create a way
9
 	* for commands to be typed into your shell,
11
 	* for commands to be typed into your shell,
58
 ## IDs
60
 ## IDs
59
 
61
 
60
 #### ID commands in shell
62
 #### ID commands in shell
63
+
61
 * In the shell, `ids` should return a formatted list of the IDs available to you.
64
 * In the shell, `ids` should return a formatted list of the IDs available to you.
62
 * `ids your_name your_github_id` command should post your Name and your GithubId to the server.
65
 * `ids your_name your_github_id` command should post your Name and your GithubId to the server.
63
 * If you do this twice with two different Names, but the name GithubId, the name on the server gets changed.
66
 * If you do this twice with two different Names, but the name GithubId, the name on the server gets changed.
66
 ### The IDs API is:
69
 ### The IDs API is:
67
 
70
 
68
 #### URL: /ids/
71
 #### URL: /ids/
72
+
69
 * `GET` : Get all github ids registered
73
 * `GET` : Get all github ids registered
70
 * `POST` : add your github id / name to be registered
74
 * `POST` : add your github id / name to be registered
71
 * `PUT` : change the name linked to your github id
75
 * `PUT` : change the name linked to your github id
81
 ```
85
 ```
82
  
86
  
83
 #### Example: 
87
 #### Example: 
88
+
84
 If I type `cmd? ids Kris xt0fer` into the shell, your command processor creates a JSON object which looks like:
89
 If I type `cmd? ids Kris xt0fer` into the shell, your command processor creates a JSON object which looks like:
85
 
90
 
86
  ```json
91
  ```json