Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1c12c97
added recipient as a component to the message system
yen-tt Feb 24, 2019
4d6ed3b
completed the last few steps of the Direct Messages feature
yen-tt Feb 24, 2019
edecce0
new branch
pranathil Feb 25, 2019
d00b9d2
new servlet
pranathil Feb 25, 2019
a03c6ee
datastore
pranathil Feb 25, 2019
20b9d7d
servlet logic
pranathil Feb 25, 2019
f7fe57f
Add basic Java templates for gitignore
nsallembiencodeu Feb 28, 2019
ad6de47
Merge branch 'gitignore' into PranathiDevelopment
nsallembiencodeu Feb 28, 2019
0b19389
gitignore fix
nsallembiencodeu Feb 28, 2019
736fb0f
final
pranathil Mar 3, 2019
93f633c
final
pranathil Mar 3, 2019
e28203f
fixed travis errors
pranathil Mar 3, 2019
154cf9d
changed helper name
pranathil Mar 11, 2019
cf81cc4
removed target files
pranathil Mar 11, 2019
710c3b5
fixed errors
pranathil Mar 11, 2019
c6eecba
complete guided project MAP part 1
yen-tt Mar 15, 2019
c7b59ed
Merge branch 'master' into YenDevelopment
nsallembiencodeu Mar 15, 2019
fc1ff3c
Merge pull request #3 from yen1027/YenDevelopment
nsallembiencodeu Mar 15, 2019
b7e11ea
Merge branch 'master' into PranathiDevelopment
nsallembiencodeu Mar 15, 2019
09b732f
Merge pull request #11 from yen1027/PranathiDevelopment
nsallembiencodeu Mar 15, 2019
0c98ec4
Deleting files from .gitignore
nsallembiencodeu Mar 15, 2019
3c5f592
fix build merge issue and apply linter
nsallembiencodeu Mar 15, 2019
151a420
Fixing more build errors
nsallembiencodeu Mar 15, 2019
b3c4276
Merge pull request #14 from yen1027/remove_ignored
nsallembiencodeu Mar 15, 2019
35b5fb7
added a csv file containing data that will be fetch be UfoDataServlet…
yen-tt Mar 25, 2019
7c71702
minor change to the csv file
yen-tt Mar 25, 2019
007a331
complete guided project MAP part 1
yen-tt Mar 15, 2019
0b95df9
added a csv file containing data that will be fetch be UfoDataServlet…
yen-tt Mar 25, 2019
921a12e
minor change to the csv file
yen-tt Mar 25, 2019
9ea2901
Merge branch 'Map' of https://github.com/yen1027/CodeBusters into Map
yen-tt Mar 25, 2019
6246ca4
fixed ufo csv file! Map part 2 is completed
yen-tt Mar 25, 2019
e7b0d8c
started on Map part 3, added functions to user-map html to allow user…
yen-tt Mar 25, 2019
bcb0d4b
style changes
yen-tt Mar 25, 2019
fc2d8d3
Completed Maps Part 3: User can create markers and and info, in which…
yen-tt Mar 31, 2019
ac0501e
fixed format violations on the code
yen-tt Mar 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# DS_Store files from MacOS
.*DS_Store

# IntelliJ, Eclipse and Maven files
/BIN/
/target/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try to rebase this branch on top of the new master? This will make sure you have all the latest goodies in terms of .gitignore, etc.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah! will do

.project
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>codeu-starter-project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8
5 changes: 5 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
135 changes: 97 additions & 38 deletions src/main/java/com/google/codeu/data/Datastore.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,70 +42,129 @@ public void storeMessage(Message message) {
messageEntity.setProperty("user", message.getUser());
messageEntity.setProperty("text", message.getText());
messageEntity.setProperty("timestamp", message.getTimestamp());
messageEntity.setProperty("recipient", message.getRecipient());

datastore.put(messageEntity);
}

/**
* Gets messages posted by a specific user.
*
* @return a list of messages posted by the user, or empty list if user has never posted a
* message. List is sorted by time descending.
*/
public List<Message> getMessages(String user) {
public List<Message> messageConverter(PreparedQuery results) {
List<Message> messages = new ArrayList<>();

Query query =
new Query("Message")
.setFilter(new Query.FilterPredicate("user", FilterOperator.EQUAL, user))
.addSort("timestamp", SortDirection.DESCENDING);
PreparedQuery results = datastore.prepare(query);

for (Entity entity : results.asIterable()) {

try {
String idString = entity.getKey().getName();
UUID id = UUID.fromString(idString);
String user = (String) entity.getProperty("user");
String recipient = (String) entity.getProperty("recipient");
String text = (String) entity.getProperty("text");
long timestamp = (long) entity.getProperty("timestamp");

Message message = new Message(id, user, text, timestamp);
Message message = new Message(id, user, text, timestamp, recipient);
messages.add(message);
} catch (Exception e) {
System.err.println("Error reading message.");
System.err.println(entity.toString());
e.printStackTrace();
}
}
return messages;
}

/**
* Gets messages posted by a specific user.
*
* @return a list of messages posted by the user, or empty list if user has never posted a
* message. List is sorted by time descending.
*/
public List<Message> getMessages(String user) {

Query query =
new Query("Message")
.setFilter(new Query.FilterPredicate("user", FilterOperator.EQUAL, user))
.addSort("timestamp", SortDirection.DESCENDING);
PreparedQuery results = datastore.prepare(query);

List<Message> messages = messageConverter(results);
return messages;
}

/** Stores the User in Datastore. */
public void storeUser(User user) {
Entity userEntity = new Entity("User", user.getEmail());
userEntity.setProperty("email", user.getEmail());
userEntity.setProperty("aboutMe", user.getAboutMe());
datastore.put(userEntity);

public List<Message> getAllMessages() {
Query query = new Query("Message").addSort("timestamp", SortDirection.DESCENDING);
PreparedQuery results = datastore.prepare(query);
List<Message> messages = messageConverter(results);
return messages;
}

/**
* Returns the User owned by the email address, or
* null if no matching User was found.
* Gets messages posted to a specific user.
*
* @return a list of messages posted to the user, or empty list if user has never received a
* message. List is sorted by time descending.
*/
public List<Message> getMessagesForRecipient(String recipient) {
Query query =
new Query("Message")
.setFilter(new Query.FilterPredicate("recipient", FilterOperator.EQUAL, recipient))
.addSort("timestamp", SortDirection.DESCENDING);
PreparedQuery results = datastore.prepare(query);
List<Message> messages = messageConverter(results);
return messages;
}

/** Stores the User in Datastore. */
public void storeUser(User user) {
Entity userEntity = new Entity("User", user.getEmail());
userEntity.setProperty("email", user.getEmail());
userEntity.setProperty("aboutMe", user.getAboutMe());
datastore.put(userEntity);
}

/** Returns the User owned by the email address, or null if no matching User was found. */
public User getUser(String email) {

Query query = new Query("User")
.setFilter(new Query.FilterPredicate("email", FilterOperator.EQUAL, email));
PreparedQuery results = datastore.prepare(query);
Entity userEntity = results.asSingleEntity();
if(userEntity == null) {
return null;
}

String aboutMe = (String) userEntity.getProperty("aboutMe");
User user = new User(email, aboutMe);

return user;

Query query =
new Query("User")
.setFilter(new Query.FilterPredicate("email", FilterOperator.EQUAL, email));
PreparedQuery results = datastore.prepare(query);
Entity userEntity = results.asSingleEntity();
if (userEntity == null) {
return null;
}

String aboutMe = (String) userEntity.getProperty("aboutMe");
User user = new User(email, aboutMe);

return user;
}

public List<UserMarker> getMarkers() {
List<UserMarker> markers = new ArrayList<>();

Query query = new Query("UserMarker");
PreparedQuery results = datastore.prepare(query);

for (Entity entity : results.asIterable()) {
try {
double lat = (double) entity.getProperty("lat");
double lng = (double) entity.getProperty("lng");
String content = (String) entity.getProperty("content");

UserMarker marker = new UserMarker(lat, lng, content);
markers.add(marker);
} catch (Exception e) {
System.err.println("Error reading marker.");
System.err.println(entity.toString());
e.printStackTrace();
}
}
return markers;
}

public void storeMarker(UserMarker marker) {
Entity markerEntity = new Entity("UserMarker");
markerEntity.setProperty("lat", marker.getLat());
markerEntity.setProperty("lng", marker.getLng());
markerEntity.setProperty("content", marker.getContent());
datastore.put(markerEntity);
}
}
16 changes: 11 additions & 5 deletions src/main/java/com/google/codeu/data/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ public class Message {
private String user;
private String text;
private long timestamp;
private String recipient;

/**
* Constructs a new {@link Message} posted by {@code user} with {@code text} content. Generates a
* random ID and uses the current system time for the creation time.
* Constructs a new {@link Message} posted by {@code user} with {@code text} content to a {@code
* recipient}. Generates a random ID and uses the current system time for the creation time.
*/
public Message(String user, String text) {
this(UUID.randomUUID(), user, text, System.currentTimeMillis());
public Message(String user, String text, String recipient) {
this(UUID.randomUUID(), user, text, System.currentTimeMillis(), recipient);
}

public Message(UUID id, String user, String text, long timestamp) {
public Message(UUID id, String user, String text, long timestamp, String recipient) {
this.id = id;
this.user = user;
this.text = text;
this.timestamp = timestamp;
this.recipient = recipient;
}

public UUID getId() {
Expand All @@ -56,4 +58,8 @@ public String getText() {
public long getTimestamp() {
return timestamp;
}

public String getRecipient() {
return recipient;
}
}
40 changes: 20 additions & 20 deletions src/main/java/com/google/codeu/data/User.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.google.codeu.data;
public class User {
private String email;
private String aboutMe;
public User(String email, String aboutMe) {
this.email = email;
this.aboutMe = aboutMe;
}
public String getEmail(){
return email;
}
public String getAboutMe() {
return aboutMe;
}
}
package com.google.codeu.data;

public class User {

private String email;
private String aboutMe;

public User(String email, String aboutMe) {
this.email = email;
this.aboutMe = aboutMe;
}

public String getEmail() {
return email;
}

public String getAboutMe() {
return aboutMe;
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/google/codeu/data/UserMarker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.google.codeu.data;

public class UserMarker {

private double lat;
private double lng;
private String content;

public UserMarker(double lat, double lng, String content) {
this.lat = lat;
this.lng = lng;
this.content = content;
}

public double getLat() {
return lat;
}

public double getLng() {
return lng;
}

public String getContent() {
return content;
}
}
Loading