Fix two syntax errors
This commit is contained in:
parent
0234cf0f74
commit
ea276c5120
|
@ -141,7 +141,10 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
|||
|
||||
_loadedCommunities = new ConcurrentHashMap<>();
|
||||
|
||||
runAsync(() -> _repo.loadBrowserCommunities(_browserIds));
|
||||
runAsync(() -> {
|
||||
_repo.loadBrowserCommunities(_browserIds);
|
||||
log("Loaded " + _browserIds.size() + " communities to show in browser");
|
||||
});
|
||||
|
||||
_clientManager = require(CoreClientManager.class);
|
||||
_clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor()
|
||||
|
|
|
@ -37,12 +37,7 @@ public class CommunityRepository extends RepositoryBase
|
|||
private static final String GET_COMMUNITY_MEMBERS = "SELECT cm.communityId, cm.accountId, cm.communityRole, ac.name, ac.uuid, ac.lastLogin, cm.readingChat FROM communityMembers cm INNER JOIN accounts ac ON ac.id=cm.accountId";
|
||||
private static final String GET_COMMUNITY_JOIN_REQUESTS = "SELECT cjr.communityId, cjr.accountId, ac.name, ac.uuid FROM communityJoinRequests cjr INNER JOIN accounts ac ON ac.id=cjr.accountId WHERE cjr.accountId=?;";
|
||||
private static final String GET_COMMUNITY_SETTINGS = "SELECT communityId, settingId, settingValue FROM communitySettings";
|
||||
private static final String GET_PUBLIC_COMMUNITIES = "SELECT communityId FROM communities WHERE settingId=8 AND settingValue='true';";
|
||||
|
||||
// Old queries
|
||||
private static final String GET_ALL_COMMUNITIES = "SELECT * FROM communities WHERE region=?;";
|
||||
private static final String GET_COMMUNITY_BY_ID = "SELECT * FROM communities WHERE id=?;";
|
||||
private static final String GET_COMMUNITY_BY_NAME = "SELECT * FROM communities WHERE name=? AND region=?;";
|
||||
private static final String GET_PUBLIC_COMMUNITIES = "SELECT communityId FROM communitySettings WHERE settingId=8 AND settingValue='true';";
|
||||
|
||||
private static final String REMOVE_FROM_COMMUNITY = "DELETE FROM communityMembers WHERE accountId=? AND communityId=?;";
|
||||
private static final String UPDATE_COMMUNITY_ROLE = "UPDATE communityMembers SET communityRole=? WHERE accountId=? AND communityId=?;";
|
||||
|
@ -112,16 +107,6 @@ public class CommunityRepository extends RepositoryBase
|
|||
public void handlePlayerJoin(final Map<Integer, Community> store, final List<Integer> load, final int accountId)
|
||||
{
|
||||
loadInternal(store, load, accountId);
|
||||
|
||||
for (int id : load)
|
||||
{
|
||||
Community com = store.get(id);
|
||||
if (com != null && !com.isBrowserFlagSet())
|
||||
{
|
||||
updateBrowserStatus(com, com.getPrivacySetting() != Community.PrivacySetting.PRIVATE
|
||||
&& com.getMembers().size() >= 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBrowserStatus(Community community, boolean flag)
|
||||
|
@ -137,6 +122,8 @@ public class CommunityRepository extends RepositoryBase
|
|||
private void loadInternal(final Map<Integer, Community> store, final List<Integer> load, final int accountId)
|
||||
{
|
||||
try (Connection connection = getConnection())
|
||||
{
|
||||
if (!load.isEmpty())
|
||||
{
|
||||
// Only load the info for communities with the given IDs
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -190,6 +177,41 @@ public class CommunityRepository extends RepositoryBase
|
|||
}
|
||||
}, idColumns);
|
||||
|
||||
idColumns = genIdColumns("communityId", load);
|
||||
executeQuery(connection, GET_COMMUNITY_SETTINGS + inClause.replace("%col", "communityId"), settingSet ->
|
||||
{
|
||||
while (settingSet.next())
|
||||
{
|
||||
final int communityId = settingSet.getInt("communityId");
|
||||
final int settingId = settingSet.getInt("settingId");
|
||||
final String value = settingSet.getString("settingValue");
|
||||
|
||||
Community community = store.get(communityId);
|
||||
CommunitySetting setting = CommunitySetting.getSetting(settingId);
|
||||
if (community != null && setting != null)
|
||||
{
|
||||
setting.parseValueInto(value, community);
|
||||
}
|
||||
}
|
||||
}, idColumns);
|
||||
|
||||
// Ensure the browser flag is set
|
||||
for (int id : load)
|
||||
{
|
||||
Community com = store.get(id);
|
||||
if (com == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!com.isBrowserFlagSet())
|
||||
{
|
||||
updateBrowserStatus(com, com.getPrivacySetting() != Community.PrivacySetting.PRIVATE &&
|
||||
com.getMembers().size() >= 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (accountId != -1)
|
||||
{
|
||||
executeQuery(connection, GET_COMMUNITY_JOIN_REQUESTS, requestSet ->
|
||||
|
@ -209,24 +231,6 @@ public class CommunityRepository extends RepositoryBase
|
|||
}
|
||||
}, new ColumnInt("cjr.accountId", accountId));
|
||||
}
|
||||
|
||||
idColumns = genIdColumns("communityId", load);
|
||||
executeQuery(connection, GET_COMMUNITY_SETTINGS + inClause.replace("%col", "communityId"), settingSet ->
|
||||
{
|
||||
while (settingSet.next())
|
||||
{
|
||||
final int communityId = settingSet.getInt("communityId");
|
||||
final int settingId = settingSet.getInt("settingId");
|
||||
final String value = settingSet.getString("settingValue");
|
||||
|
||||
Community community = store.get(communityId);
|
||||
CommunitySetting setting = CommunitySetting.getSetting(settingId);
|
||||
if (community != null && setting != null)
|
||||
{
|
||||
setting.parseValueInto(value, community);
|
||||
}
|
||||
}
|
||||
}, idColumns);
|
||||
} catch (SQLException ex)
|
||||
{
|
||||
System.err.println("Encountered an SQL exception loading communities " + load);
|
||||
|
@ -234,89 +238,6 @@ public class CommunityRepository extends RepositoryBase
|
|||
}
|
||||
}
|
||||
|
||||
/* public void loadCommunities(final Map<Integer, Community> communityMap)
|
||||
{
|
||||
try (Connection connection = getConnection())
|
||||
{
|
||||
executeQuery(connection, GET_ALL_COMMUNITIES, resultSet ->
|
||||
{
|
||||
Map<Integer, Community> resultant = new HashMap<>();
|
||||
while (resultSet.next())
|
||||
{
|
||||
final int id = resultSet.getInt("id");
|
||||
final String cName = resultSet.getString("name");
|
||||
final Community community = new Community(id, cName);
|
||||
|
||||
resultant.put(community.getId(), community);
|
||||
}
|
||||
|
||||
communityMap.clear();
|
||||
communityMap.putAll(resultant);
|
||||
}, new ColumnVarChar("region", 5, _us ? "US" : "EU"));
|
||||
|
||||
executeQuery(connection, GET_COMMUNITY_MEMBERS, memberSet ->
|
||||
{
|
||||
while (memberSet.next())
|
||||
{
|
||||
final int communityId = memberSet.getInt("communityId");
|
||||
final int accountId = memberSet.getInt("accountId");
|
||||
final String name = memberSet.getString("name");
|
||||
final UUID uuid = UUID.fromString(memberSet.getString("uuid"));
|
||||
final CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole"));
|
||||
final long lastLogin = memberSet.getTimestamp("lastLogin").getTime();
|
||||
boolean readingChat = memberSet.getBoolean("readingChat");
|
||||
|
||||
CommunityMemberInfo info = new CommunityMemberInfo(name, uuid, accountId, role, lastLogin);
|
||||
info.ReadingChat = readingChat;
|
||||
|
||||
Community community = communityMap.get(communityId);
|
||||
if (community != null)
|
||||
{
|
||||
community.getMembers().put(info.UUID, info);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
executeQuery(connection, GET_COMMUNITY_JOIN_REQUESTS, requestSet ->
|
||||
{
|
||||
while (requestSet.next())
|
||||
{
|
||||
final int communityId = requestSet.getInt("communityId");
|
||||
final int accountId = requestSet.getInt("accountId");
|
||||
final UUID uuid = UUID.fromString(requestSet.getString("uuid"));
|
||||
final String name = requestSet.getString("name");
|
||||
|
||||
Community community = communityMap.get(communityId);
|
||||
if (community != null)
|
||||
{
|
||||
community.getJoinRequests().put(uuid, new CommunityJoinRequestInfo(name, uuid, accountId));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
executeQuery(connection, GET_COMMUNITY_SETTINGS, settingSet ->
|
||||
{
|
||||
while (settingSet.next())
|
||||
{
|
||||
final int communityId = settingSet.getInt("communityId");
|
||||
final int settingId = settingSet.getInt("settingId");
|
||||
final String value = settingSet.getString("settingValue");
|
||||
|
||||
Community community = communityMap.get(communityId);
|
||||
CommunitySetting setting = CommunitySetting.getSetting(settingId);
|
||||
if (community != null && setting != null)
|
||||
{
|
||||
setting.parseValueInto(value, community);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
} */
|
||||
|
||||
public void updateMembersAndJoinRequests(List<Community> communities)
|
||||
{
|
||||
if (communities.isEmpty())
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.sql.Statement;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
|
@ -176,10 +178,6 @@ public abstract class RepositoryBase
|
|||
{
|
||||
affectedRows = executeInsert(connection, query, callable, null, columns);
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
|
@ -256,9 +254,10 @@ public abstract class RepositoryBase
|
|||
{
|
||||
executeQuery(preparedStatement, callable, columns);
|
||||
}
|
||||
catch (SQLException exception)
|
||||
catch (MySQLSyntaxErrorException syntaxException)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
System.err.println("Query \"" + query + "\" contained a syntax error:");
|
||||
syntaxException.printStackTrace();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue