use of com.alessiodp.parties.common.storage.sql.dao.parties.PartiesDao in project Parties by AlessioDP.
the class PartiesSQLDispatcher method getListParties.
@Override
public LinkedHashSet<PartyImpl> getListParties(PartiesDatabaseManager.ListOrder order, int limit, int offset) {
LinkedHashSet<PartyImpl> ret;
List<String> blacklist = ConfigParties.ADDITIONAL_LIST_HIDDENPARTIES;
if (order == PartiesDatabaseManager.ListOrder.NAME)
ret = this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(partiesDao).getListByName(blacklist, limit, offset));
else if (order == PartiesDatabaseManager.ListOrder.MEMBERS)
ret = this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(partiesDao).getListByMembers(blacklist, limit, offset));
else if (order == PartiesDatabaseManager.ListOrder.KILLS)
ret = this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(partiesDao).getListByKills(blacklist, limit, offset));
else if (order == PartiesDatabaseManager.ListOrder.EXPERIENCE)
ret = this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(partiesDao).getListByExperience(blacklist, limit, offset));
else
throw new IllegalStateException("Cannot get the list of parties with the order " + order.name());
// Load members
for (PartyImpl party : ret) {
party.setAccessible(true);
party.setMembers(this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(playersDao).getInParty(party.getId().toString())));
party.setAccessible(false);
}
return ret;
}
Aggregations