aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/juick/server/ChatQueries.java86
-rw-r--r--src/com/juick/server/GroupsQueries.java149
-rw-r--r--src/com/juick/server/MessagesQueries.java8
-rw-r--r--src/com/juick/server/PlacesQueries.java55
4 files changed, 4 insertions, 294 deletions
diff --git a/src/com/juick/server/ChatQueries.java b/src/com/juick/server/ChatQueries.java
deleted file mode 100644
index 19f95637..00000000
--- a/src/com/juick/server/ChatQueries.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.juick.server;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class ChatQueries {
-
- public static boolean subscribeTag(Connection sql, int uid, int tagid) {
- boolean ret = false;
- PreparedStatement stmt = null;
- try {
- stmt = sql.prepareStatement("INSERT INTO chat_subscr_tags(tag_id,user_id) VALUES (?,?)");
- stmt.setInt(1, tagid);
- stmt.setInt(2, uid);
- if (stmt.executeUpdate() > 0) {
- ret = true;
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(null, stmt);
- }
-
- return ret;
- }
-
- public static boolean unsubscribeTag(Connection sql, int uid, int tagid) {
- boolean ret = false;
- PreparedStatement stmt = null;
- try {
- stmt = sql.prepareStatement("DELETE FROM chat_subscr_tags WHERE tag_id=? AND user_id=?");
- stmt.setInt(1, tagid);
- stmt.setInt(2, uid);
- if (stmt.executeUpdate() > 0) {
- ret = true;
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(null, stmt);
- }
-
- return ret;
- }
-
- public static boolean setSubscriptionsActive(Connection sql, int uid, boolean enabled) {
- boolean ret = false;
- PreparedStatement stmt = null;
- try {
- stmt = sql.prepareStatement("UPDATE chat_subscr_tags SET active=? WHERE user_id=?");
- stmt.setInt(1, enabled ? 1 : 0);
- stmt.setInt(2, uid);
- if (stmt.executeUpdate() > 0) {
- ret = true;
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(null, stmt);
- }
-
- return ret;
- }
-}
diff --git a/src/com/juick/server/GroupsQueries.java b/src/com/juick/server/GroupsQueries.java
deleted file mode 100644
index 45a4942d..00000000
--- a/src/com/juick/server/GroupsQueries.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2013, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.juick.server;
-
-import com.juick.Group;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class GroupsQueries {
-
- public static ArrayList<com.juick.Group> getGroups(Connection sql, int uid) {
- ArrayList<com.juick.Group> groups = new ArrayList<Group>();
-
- PreparedStatement stmt = null;
- ResultSet rs = null;
- try {
- stmt = sql.prepareStatement("SELECT groups.group_id,groups.name,COUNT(groups_users.user_id) FROM groups LEFT JOIN groups_users USING(group_id) WHERE groups.user_id=? GROUP BY group_id");
- stmt.setInt(1, uid);
- rs = stmt.executeQuery();
- rs.beforeFirst();
- while (rs.next()) {
- com.juick.Group g = new com.juick.Group();
- g.GID = rs.getInt(1);
- g.Name = rs.getString(2);
- g.UsersCnt = rs.getInt(3);
- groups.add(g);
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(rs, stmt);
- }
-
- return groups;
- }
-
- public static int getGroupID(Connection sql, int uid, String name) {
- int gid = 0;
-
- PreparedStatement stmt = null;
- ResultSet rs = null;
- try {
- stmt = sql.prepareStatement("SELECT group_id FROM groups WHERE user_id=? AND name=?");
- stmt.setInt(1, uid);
- stmt.setString(2, name);
- rs = stmt.executeQuery();
- if (rs.first()) {
- gid = rs.getInt(1);
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(rs, stmt);
- }
-
- if (gid == 0) {
- try {
- stmt = sql.prepareStatement("INSERT INTO groups(user_id,name) VALUES (?)", Statement.RETURN_GENERATED_KEYS);
- stmt.setString(1, name);
- stmt.executeUpdate();
- rs = stmt.getGeneratedKeys();
- if (rs.first()) {
- gid = rs.getInt(1);
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(rs, stmt);
- }
- }
-
- return gid;
- }
-
- public static boolean removeGroupUser(Connection sql, int gid, int uid) {
- boolean ret = false;
- PreparedStatement stmt = null;
- try {
- stmt = sql.prepareStatement("DELETE FROM groups_users WHERE group_id=? AND user_id=?");
- stmt.setInt(1, gid);
- stmt.setInt(2, uid);
- if (stmt.executeUpdate() > 0) {
- ret = true;
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(null, stmt);
- }
-
- if (ret) {
- int cnt = SQLHelpers.getInt(sql, "SELECT COUNT(*) FROM groups_users WHERE group_id=?", gid, -1);
- if (cnt == 0) {
- try {
- stmt = sql.prepareStatement("DELETE FROM groups WHERE group_id=?");
- stmt.setInt(1, gid);
- stmt.executeUpdate();
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(null, stmt);
- }
- }
- }
-
- return ret;
- }
-
- public static boolean addGroupUser(Connection sql, int gid, int uid) {
- boolean ret = false;
- PreparedStatement stmt = null;
- try {
- stmt = sql.prepareStatement("INSERT INTO groups_users(group_id,user_id) VALUES (?,?)");
- stmt.setInt(1, gid);
- stmt.setInt(2, uid);
- if (stmt.executeUpdate() > 0) {
- ret = true;
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(null, stmt);
- }
- return ret;
- }
-}
diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java
index 613b09f1..017c3350 100644
--- a/src/com/juick/server/MessagesQueries.java
+++ b/src/com/juick/server/MessagesQueries.java
@@ -144,9 +144,9 @@ public class MessagesQueries {
msg.Privacy = rs.getInt(6);
msg.Replies = rs.getInt(7);
msg.AttachmentType = rs.getString(8);
- if (rs.getInt(9) > 0) {
- msg.Place = PlacesQueries.getPlace(sql, rs.getInt(9));
- }
+ //if (rs.getInt(9) > 0) {
+ // msg.Place = PlacesQueries.getPlace(sql, rs.getInt(9));
+ //}
if (rs.getDouble(10) != 0) {
msg.Place = new com.juick.Place();
msg.Place.lat = rs.getDouble(10);
@@ -319,7 +319,7 @@ public class MessagesQueries {
return mids;
}
- public static ArrayList<Integer> getTag(Connection sql, int tid, int visitor_uid, int before,int cnt) {
+ public static ArrayList<Integer> getTag(Connection sql, int tid, int visitor_uid, int before, int cnt) {
ArrayList<Integer> mids = new ArrayList<Integer>(20);
PreparedStatement stmt = null;
diff --git a/src/com/juick/server/PlacesQueries.java b/src/com/juick/server/PlacesQueries.java
deleted file mode 100644
index d61c89c3..00000000
--- a/src/com/juick/server/PlacesQueries.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.juick.server;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class PlacesQueries {
-
- public static com.juick.Place getPlace(Connection sql, int pid) {
- com.juick.Place place = null;
-
- PreparedStatement stmt = null;
- ResultSet rs = null;
- try {
- stmt = sql.prepareStatement("SELECT lat,lon,name FROM places WHERE place_id=?");
- stmt.setInt(1, pid);
- rs = stmt.executeQuery();
- if (rs.first()) {
- place = new com.juick.Place();
- place.pid = pid;
- place.lat = rs.getDouble(1);
- place.lon = rs.getDouble(2);
- place.name = rs.getString(3);
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(rs, stmt);
- }
-
- return place;
- }
-}