Skip to content

Commit ac3107d

Browse files
authored
Merge pull request #1 from Leejjon/develop
Develop
2 parents 739049f + 1dd7510 commit ac3107d

File tree

15 files changed

+231
-58
lines changed

15 files changed

+231
-58
lines changed

pom.xml

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,23 @@
1010
<version>1.0-SNAPSHOT</version>
1111
<properties>
1212
<appengine.app.version>1</appengine.app.version>
13-
<appengine.target.version>1.9.46</appengine.target.version>
13+
<appengine.sdk.version>1.9.54</appengine.sdk.version>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<maven.compiler.source>1.8</maven.compiler.source>
1616
<maven.compiler.target>1.8</maven.compiler.target>
1717
<jetty.maven.plugin>9.3.8.v20160314</jetty.maven.plugin>
1818
</properties>
1919
<dependencies>
2020
<!-- Compile/runtime dependencies -->
21+
<dependency>
22+
<groupId>org.hashids</groupId>
23+
<artifactId>hashids</artifactId>
24+
<version>1.0.1</version>
25+
</dependency>
2126
<dependency>
2227
<groupId>com.google.appengine</groupId>
2328
<artifactId>appengine-api-1.0-sdk</artifactId>
24-
<version>${appengine.target.version}</version>
29+
<version>${appengine.sdk.version}</version>
2530
</dependency>
2631
<dependency>
2732
<groupId>javax.servlet</groupId>
@@ -34,6 +39,13 @@
3439
<artifactId>jstl</artifactId>
3540
<version>1.2</version>
3641
</dependency>
42+
<dependency>
43+
<groupId>javax</groupId>
44+
<artifactId>javaee-web-api</artifactId>
45+
<version>7.0</version>
46+
<type>jar</type>
47+
<scope>provided</scope>
48+
</dependency>
3749

3850
<!-- Test Dependencies -->
3951
<dependency>
@@ -51,50 +63,30 @@
5163
<dependency>
5264
<groupId>com.google.appengine</groupId>
5365
<artifactId>appengine-testing</artifactId>
54-
<version>${appengine.target.version}</version>
66+
<version>${appengine.sdk.version}</version>
5567
<scope>test</scope>
5668
</dependency>
5769
<dependency>
5870
<groupId>com.google.appengine</groupId>
5971
<artifactId>appengine-api-stubs</artifactId>
60-
<version>${appengine.target.version}</version>
72+
<version>${appengine.sdk.version}</version>
73+
<scope>test</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>com.google.appengine</groupId>
77+
<artifactId>appengine-tools-sdk</artifactId>
78+
<version>${appengine.sdk.version}</version>
6179
<scope>test</scope>
6280
</dependency>
6381
</dependencies>
6482

6583
<build>
66-
<outputDirectory>target/${project.artifactId}/WEB-INF/classes</outputDirectory>
6784
<plugins>
6885
<plugin>
69-
<groupId>org.apache.maven.plugins</groupId>
70-
<artifactId>maven-war-plugin</artifactId>
71-
<version>2.3</version>
72-
<configuration>
73-
<archiveClasses>true</archiveClasses>
74-
<webResources>
75-
in order to interpolate version from pom into appengine-web.xml
76-
<resource>
77-
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
78-
<filtering>true</filtering>
79-
<targetPath>WEB-INF</targetPath>
80-
</resource>
81-
</webResources>
82-
</configuration>
83-
</plugin>
84-
85-
<plugin>
86-
<groupId>com.google.appengine</groupId>
86+
<groupId>com.google.cloud.tools</groupId>
8787
<artifactId>appengine-maven-plugin</artifactId>
88-
<version>${appengine.target.version}</version>
89-
<configuration>
90-
91-
</configuration>
92-
</plugin>
93-
<plugin>
94-
<groupId>org.eclipse.jetty</groupId>
95-
<artifactId>jetty-maven-plugin</artifactId>
96-
<version>${jetty.maven.plugin}</version>
88+
<version>1.0.0</version>
9789
</plugin>
9890
</plugins>
9991
</build>
100-
</project>
92+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
package net.leejjon.blindpool.model;
3+
4+
public class Participant {
5+
private String firstName;
6+
private String lastName;
7+
private boolean oath;
8+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package net.leejjon.blindpool.model;
2+
3+
/**
4+
* <p>In French, a 'Poule' is some sort of competition where the participants
5+
* predict scores from sport matches. Poule isn't really an English word, so I
6+
* was kind of wondering what word to use for the English name. Even on
7+
* Wikipedia there doesn't really seem to be a word for it.</p>
8+
*
9+
* <p>However, in some cases the word "Pool" is being used. The phrase "prize pool"
10+
* is commonly used in lotteries. But it wasn't until I realized that Deadpool
11+
* is also a reference to the meaning of "Poule". In the Deadpool movie they
12+
* have a competition where they predict who is going to die first, and they
13+
* call it the dead pool. Later Wade Willson decides that it will become his
14+
* superhero name.</p>
15+
*
16+
* TLDR:
17+
*
18+
* @author Leejjon
19+
*/
20+
public class Pool {
21+
22+
private String key;
23+
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
package net.leejjon.blindpool.storage;
3+
4+
public enum Kind {
5+
/**
6+
* This is the kind used by Google App Engine to store session objects.
7+
*/
8+
AH_SESSION("_ah_SESSION"),
9+
/**
10+
* The pool object.
11+
*/
12+
POOL("pool");
13+
14+
private final String kind;
15+
private Kind(String kind) {
16+
this.kind = kind;
17+
}
18+
19+
@Override
20+
public String toString() {
21+
return kind;
22+
}
23+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package net.leejjon.blindpool.storage;
2+
3+
import com.google.appengine.api.datastore.DatastoreService;
4+
import com.google.appengine.api.datastore.DatastoreServiceFactory;
5+
import com.google.appengine.api.datastore.FetchOptions;
6+
import com.google.appengine.api.datastore.Query;
7+
import net.leejjon.blindpool.model.Pool;
8+
9+
/**
10+
* Simple class to do stuff with the pools in the datastore. Could not be
11+
* bothered to create an entire DAO layer.
12+
*
13+
* @author Leejjon
14+
*/
15+
public class PoolDataStore {
16+
17+
private final DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
18+
19+
public void createPool() {
20+
throw new UnsupportedOperationException("Not supported yet.");
21+
}
22+
23+
public Pool getPool(String key) {
24+
throw new UnsupportedOperationException("Not supported yet.");
25+
}
26+
27+
public void deletePool() {
28+
throw new UnsupportedOperationException("Not supported yet.");
29+
}
30+
31+
public long countPools() {
32+
Query countPools = new Query(Kind.POOL.toString());
33+
34+
/* TODO: If my app ever has more than 1000 pools I'll have to fix this.
35+
* Read:
36+
* https://cloud.google.com/appengine/articles/sharding_counters
37+
* Use something like this:
38+
* https://github.com/instacount/appengine-counter
39+
*/
40+
FetchOptions fo = FetchOptions.Builder.withLimit(1000);
41+
return datastore.prepare(countPools).countEntities(fo);
42+
}
43+
44+
/**
45+
*
46+
* @return The number of pools from the database.
47+
*/
48+
public static long getPoolCount() {
49+
return new PoolDataStore().countPools();
50+
}
51+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
package net.leejjon.blindpool.tags;
3+
4+
import java.io.IOException;
5+
import javax.servlet.jsp.JspException;
6+
import javax.servlet.jsp.JspWriter;
7+
import javax.servlet.jsp.tagext.SimpleTagSupport;
8+
import net.leejjon.blindpool.storage.PoolDataStore;
9+
10+
public class PoolDataTagSupport extends SimpleTagSupport {
11+
@Override
12+
public void doTag() throws JspException, IOException {
13+
final JspWriter out = getJspContext().getOut();
14+
out.print(new PoolDataStore().countPools());
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package net.leejjon.blindpool.utils;
2+
3+
import org.hashids.Hashids;
4+
5+
public class HashIdsGenerator {
6+
7+
public static void main(String[] args) {
8+
Hashids hashIds = new Hashids();
9+
for (int i = 0; i < 100; i++) {
10+
String encode = hashIds.encode(i);
11+
System.out.println(encode);
12+
}
13+
}
14+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
title=Blindpool
2-
language=Language
2+
language=Language:
3+
number.of.pools=Pools created: {0,number,integer}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
title=Blindepoule
2-
language=Taal
2+
language=Taal:
3+
number.of.pools=Aantal gemaakte Poules: {0,number,integer}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Context path="/blindpool"/>
2+
<Context path=""/>

0 commit comments

Comments
 (0)