From e317e3324570863de0014c54cf5f0aa2a5b89d28 Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Sun, 7 Feb 2016 21:06:41 -0500 Subject: [PATCH] Add skeleton implementation to all models --- .../frozenorb/apiv3/collections/AuditLog.java | 37 +++++++++++++++++++ .../apiv3/collections/EmailTemplate.java | 37 +++++++++++++++++++ .../frozenorb/apiv3/collections/Grant.java | 37 +++++++++++++++++++ .../frozenorb/apiv3/collections/IPBan.java | 37 +++++++++++++++++++ .../frozenorb/apiv3/collections/IPLog.java | 37 +++++++++++++++++++ .../apiv3/collections/MaxMindCache.java | 37 +++++++++++++++++++ .../apiv3/collections/NotificationLog.java | 37 +++++++++++++++++++ .../apiv3/collections/Punishment.java | 37 +++++++++++++++++++ .../frozenorb/apiv3/collections/Server.java | 5 ++- .../apiv3/collections/ServerGroup.java | 37 +++++++++++++++++++ .../net/frozenorb/apiv3/collections/User.java | 37 +++++++++++++++++++ 11 files changed, 373 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java b/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java index 7ad21bd..9a358c6 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java +++ b/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class AuditLog implements LiteFullJson { public static final String COLLECTION_NAME = "auditLog"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), AuditLog::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), AuditLog::new, callback); + } + + private AuditLog(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java b/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java index cbae10f..d6c2223 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java +++ b/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class EmailTemplate implements LiteFullJson { public static final String COLLECTION_NAME = "emailTemplate"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), EmailTemplate::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), EmailTemplate::new, callback); + } + + private EmailTemplate(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/Grant.java b/src/main/java/net/frozenorb/apiv3/collections/Grant.java index 9382ebd..eae67dd 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/Grant.java +++ b/src/main/java/net/frozenorb/apiv3/collections/Grant.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class Grant implements LiteFullJson { public static final String COLLECTION_NAME = "grant"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), Grant::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), Grant::new, callback); + } + + private Grant(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/IPBan.java b/src/main/java/net/frozenorb/apiv3/collections/IPBan.java index e7e6d33..cc67e82 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/IPBan.java +++ b/src/main/java/net/frozenorb/apiv3/collections/IPBan.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class IPBan implements LiteFullJson { public static final String COLLECTION_NAME = "ipBan"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), IPBan::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), IPBan::new, callback); + } + + private IPBan(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/IPLog.java b/src/main/java/net/frozenorb/apiv3/collections/IPLog.java index c5ae051..4bcbd0e 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/IPLog.java +++ b/src/main/java/net/frozenorb/apiv3/collections/IPLog.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class IPLog implements LiteFullJson { public static final String COLLECTION_NAME = "ipLog"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), IPLog::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), IPLog::new, callback); + } + + private IPLog(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java b/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java index 8ae51ff..3ce2cd1 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java +++ b/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class MaxMindCache implements LiteFullJson { public static final String COLLECTION_NAME = "maxMindCache"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), MaxMindCache::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), MaxMindCache::new, callback); + } + + private MaxMindCache(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java b/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java index 238a78c..186c6ab 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java +++ b/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class NotificationLog implements LiteFullJson { public static final String COLLECTION_NAME = "notificationLog"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), NotificationLog::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), NotificationLog::new, callback); + } + + private NotificationLog(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/Punishment.java b/src/main/java/net/frozenorb/apiv3/collections/Punishment.java index 11f9500..5b46c8c 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/Punishment.java +++ b/src/main/java/net/frozenorb/apiv3/collections/Punishment.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class Punishment implements LiteFullJson { public static final String COLLECTION_NAME = "punishment"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), Punishment::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), Punishment::new, callback); + } + + private Punishment(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/Server.java b/src/main/java/net/frozenorb/apiv3/collections/Server.java index 91488c5..f3fefca 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/Server.java +++ b/src/main/java/net/frozenorb/apiv3/collections/Server.java @@ -6,12 +6,13 @@ import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import lombok.Getter; import lombok.ToString; -import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.LiteFullJson; import net.frozenorb.apiv3.utils.MongoUtils; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; @ToString(exclude={ "secret" }) public final class Server implements LiteFullJson { diff --git a/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java b/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java index fe6e035..6e605b4 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java +++ b/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class ServerGroup implements LiteFullJson { public static final String COLLECTION_NAME = "serverGroup"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), ServerGroup::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), ServerGroup::new, callback); + } + + private ServerGroup(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/User.java b/src/main/java/net/frozenorb/apiv3/collections/User.java index d7f7e7c..491b829 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/User.java +++ b/src/main/java/net/frozenorb/apiv3/collections/User.java @@ -1,11 +1,48 @@ package net.frozenorb.apiv3.collections; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; +import net.frozenorb.apiv3.utils.MongoUtils; + +import java.util.List; @ToString public final class User implements LiteFullJson { public static final String COLLECTION_NAME = "user"; + @Getter private String id; + + public static void findAll(Handler>> callback) { + MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), User::new, callback); + } + + public static void findById(String id, Handler> callback) { + MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), User::new, callback); + } + + private User(JsonObject json) { + this.id = json.getString("_id"); + } + + public JsonObject toLiteJson() { + JsonObject json = new JsonObject(); + + json.put("_id", id); + + return json; + } + + public JsonObject toFullJson() { + JsonObject json = toLiteJson(); + + + + return json; + } + } \ No newline at end of file