Przeglądaj źródła

added MVC skeleton

Kr Younger 6 lat temu
rodzic
commit
17ffb2b0d7

+ 17
- 0
.project Wyświetl plik

@@ -0,0 +1,17 @@
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 Wyświetl plik

@@ -0,0 +1,4 @@
1
+activeProfiles=
2
+eclipse.preferences.version=1
3
+resolveWorkspaceProjects=true
4
+version=1

+ 44
- 0
Client/.classpath Wyświetl plik

@@ -0,0 +1,44 @@
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 Wyświetl plik

@@ -0,0 +1,23 @@
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 Wyświetl plik

@@ -0,0 +1,2 @@
1
+eclipse.preferences.version=1
2
+org.eclipse.jdt.apt.aptEnabled=false

+ 7
- 0
Client/.settings/org.eclipse.jdt.core.prefs Wyświetl plik

@@ -0,0 +1,7 @@
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 Wyświetl plik

@@ -0,0 +1,4 @@
1
+activeProfiles=
2
+eclipse.preferences.version=1
3
+resolveWorkspaceProjects=true
4
+version=1

BIN
Client/src/main/.DS_Store Wyświetl plik


+ 11
- 2
Client/src/main/java/YouAreEll.java Wyświetl plik

@@ -1,10 +1,19 @@
1
+import controllers.*;
2
+
1 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 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 17
         System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
9 18
         System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
10 19
     }

+ 22
- 0
Client/src/main/java/controllers/IdController.java Wyświetl plik

@@ -0,0 +1,22 @@
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 Wyświetl plik

@@ -0,0 +1,31 @@
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 Wyświetl plik

@@ -0,0 +1,7 @@
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 Wyświetl plik

@@ -0,0 +1,10 @@
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 Wyświetl plik

@@ -0,0 +1,10 @@
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 Wyświetl plik

@@ -0,0 +1,13 @@
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 Wyświetl plik

@@ -0,0 +1,13 @@
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 Wyświetl plik

@@ -1,3 +1,5 @@
1
+package views;
2
+
1 3
 import java.io.BufferedReader;
2 4
 import java.io.IOException;
3 5
 import java.io.InputStream;
@@ -5,6 +7,10 @@ import java.io.InputStreamReader;
5 7
 import java.util.ArrayList;
6 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 14
 public class SimpleShell {
9 15
 
10 16
 
@@ -14,7 +20,8 @@ public class SimpleShell {
14 20
     }
15 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 25
         String commandLine;
19 26
         BufferedReader console = new BufferedReader
20 27
                 (new InputStreamReader(System.in));

+ 5
- 0
README.md Wyświetl plik

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