1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Refactored "src/dao" source folder to "src/main/java".

This commit is contained in:
2011-08-07 22:36:47 -03:00
parent 074f216ffc
commit 6b28b48ae7
48 changed files with 114 additions and 115 deletions

View File

@@ -0,0 +1,56 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.CharacterFriendDAO;
import com.l2jserver.model.dao.ChatMessageDAO;
import com.l2jserver.model.dao.ClanDAO;
import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.dao.NPCDAO;
import com.l2jserver.model.dao.jdbc.h2.H2CharacterDAO;
import com.l2jserver.model.dao.jdbc.h2.H2CharacterFriendDAO;
import com.l2jserver.model.dao.jdbc.h2.H2ChatMessageDAO;
import com.l2jserver.model.dao.jdbc.h2.H2ClanDAO;
import com.l2jserver.model.dao.jdbc.h2.H2ItemDAO;
import com.l2jserver.model.dao.jdbc.h2.H2NPCDAO;
/**
* Google Guice {@link Module} for H2 DAOs
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class H2DAOModule extends AbstractModule {
@Override
protected void configure() {
bind(CharacterDAO.class).to(H2CharacterDAO.class).in(Scopes.SINGLETON);
bind(CharacterFriendDAO.class).to(H2CharacterFriendDAO.class).in(
Scopes.SINGLETON);
bind(NPCDAO.class).to(H2NPCDAO.class).in(Scopes.SINGLETON);
bind(ItemDAO.class).to(H2ItemDAO.class).in(Scopes.SINGLETON);
bind(ClanDAO.class).to(H2ClanDAO.class).in(Scopes.SINGLETON);
// logs
bind(ChatMessageDAO.class).to(H2ChatMessageDAO.class).in(
Scopes.SINGLETON);
}
}

View File

@@ -0,0 +1,57 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.CharacterFriendDAO;
import com.l2jserver.model.dao.ChatMessageDAO;
import com.l2jserver.model.dao.ClanDAO;
import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.dao.NPCDAO;
import com.l2jserver.model.dao.jdbc.mysql5.MySQL5CharacterDAO;
import com.l2jserver.model.dao.jdbc.mysql5.MySQL5CharacterFriendDAO;
import com.l2jserver.model.dao.jdbc.mysql5.MySQL5ChatMessageDAO;
import com.l2jserver.model.dao.jdbc.mysql5.MySQL5ClanDAO;
import com.l2jserver.model.dao.jdbc.mysql5.MySQL5ItemDAO;
import com.l2jserver.model.dao.jdbc.mysql5.MySQL5NPCDAO;
/**
* Google Guice {@link Module} for MySQL5 DAOs
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class MySQL5DAOModule extends AbstractModule {
@Override
protected void configure() {
bind(CharacterDAO.class).to(MySQL5CharacterDAO.class).in(
Scopes.SINGLETON);
bind(CharacterFriendDAO.class).to(MySQL5CharacterFriendDAO.class).in(
Scopes.SINGLETON);
bind(NPCDAO.class).to(MySQL5NPCDAO.class).in(Scopes.SINGLETON);
bind(ItemDAO.class).to(MySQL5ItemDAO.class).in(Scopes.SINGLETON);
bind(ClanDAO.class).to(MySQL5ClanDAO.class).in(Scopes.SINGLETON);
// logs
bind(ChatMessageDAO.class).to(MySQL5ChatMessageDAO.class).in(
Scopes.SINGLETON);
}
}

View File

@@ -0,0 +1,62 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao;
import java.util.List;
import com.l2jserver.model.id.AccountID;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.world.Clan;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject;
/**
* The {@link CharacterDAO} is can load and save {@link Character character
* instances} .
*
* @author Rogiel
*/
public interface CharacterDAO extends
DataAccessObject<L2Character, CharacterID>, Cacheable {
/**
* Load the members of the given <tt>clan</tt>
*
* @param clan
* the clan
*/
void load(Clan clan);
/**
* Select an character by its name.
*
* @param name
* the character name
* @return the found character. Null if does not exists.
*/
L2Character selectByName(String name);
/**
* Select an character by its name.
*
* @param account
* the account id
* @return the found characters. An empty list if this account has no
* characters.
*/
List<L2Character> selectByAccount(AccountID account);
}

View File

@@ -0,0 +1,64 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao;
import com.l2jserver.model.game.CharacterFriend;
import com.l2jserver.model.id.FriendID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.character.CharacterFriendList;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.cache.IgnoreCaching;
import com.l2jserver.service.database.DataAccessObject;
/**
* The {@link CharacterFriendDAO} is can load and save
* {@link CharacterFriendList character friend list}.
*
* @author Rogiel
*/
public interface CharacterFriendDAO extends
DataAccessObject<CharacterFriend, FriendID>, Cacheable {
/**
* Load the friend list for character represented by <tt>character</tt> from
* the database
*
* @param character
* the character
*/
void load(L2Character character);
/**
* Save the instance to the database. If a new database entry was created
* returns true.
*
* @param friends
* the friend list
* @return true if created a new entry in database (i.e. insert), false if
* not created (i.e. update)
*/
@IgnoreCaching
boolean save(CharacterFriendList friends);
/**
* Delete an entire friend list
*
* @param friends
* the friend list
* @return true if at least 1 item was removed
*/
boolean delete(CharacterFriendList friends);
}

View File

@@ -0,0 +1,32 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao;
import com.l2jserver.model.id.ChatMessageID;
import com.l2jserver.model.server.ChatMessage;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject;
/**
* The {@link ChatMessageDAO} is can load and save {@link ChatMessage chat
* messages}.
*
* @author Rogiel
*/
public interface ChatMessageDAO extends
DataAccessObject<ChatMessage, ChatMessageID>, Cacheable {
}

View File

@@ -0,0 +1,30 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.world.Clan;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject;
/**
* The {@link ClanDAO} is can load and save {@link Clan clan instances}.
*
* @author Rogiel
*/
public interface ClanDAO extends DataAccessObject<Clan, ClanID>, Cacheable {
}

View File

@@ -0,0 +1,40 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao;
import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject;
/**
* The {@link ItemDAO} is can load and save {@link Character character
* instances} .
*
* @author Rogiel
*/
public interface ItemDAO extends DataAccessObject<Item, ItemID>, Cacheable {
/**
* Load the inventory for an {@link L2Character character}.
*
* @param character
* the character
* @return amount of items loaded
*/
int loadInventory(L2Character character);
}

View File

@@ -0,0 +1,49 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao;
import java.util.Collection;
import java.util.List;
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject;
/**
* The {@link NPCDAO} is can load and save {@link NPC NPC instances}.
*
* @author Rogiel
*/
public interface NPCDAO extends DataAccessObject<NPC, NPCID>, Cacheable {
/**
* Load all {@link NPC} instances
*
* @return all NPC instances
*/
Collection<NPC> loadAll();
/**
* Select an {@link NPC} by its template.
*
* @param name
* the npc template id
* @return the found NPC. Null if does not exists.
*/
List<NPC> selectByTemplate(NPCTemplateID templateID);
}

View File

@@ -0,0 +1,30 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao;
import com.l2jserver.model.id.object.PetID;
import com.l2jserver.model.world.Pet;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject;
/**
* The {@link PetDAO} is can load and save {@link Pet pet instances}.
*
* @author Rogiel
*/
public interface PetDAO extends DataAccessObject<Pet, PetID>, Cacheable {
}

View File

@@ -0,0 +1,48 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc;
import com.google.inject.Inject;
import com.l2jserver.model.Model;
import com.l2jserver.model.id.ID;
import com.l2jserver.service.database.AbstractDAO;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.JDBCDatabaseService;
/**
* {@link AbstractDAO} for JDBC DAO implementation
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
* @param <T>
* the object for the DAO
* @param <I>
* the object ID type
*/
public abstract class AbstractJDBCDAO<T extends Model<?>, I extends ID<?>>
extends AbstractDAO<T, I> {
/**
* The JDBC Database Service
*/
protected final JDBCDatabaseService database;
@Inject
protected AbstractJDBCDAO(DatabaseService database) {
super(database);
this.database = (JDBCDatabaseService) database;
}
}

View File

@@ -0,0 +1,421 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.List;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.id.AccountID;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.model.id.provider.AccountIDProvider;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.template.actor.ActorSex;
import com.l2jserver.model.template.character.CharacterClass;
import com.l2jserver.model.template.character.CharacterRace;
import com.l2jserver.model.world.Clan;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.character.CharacterAppearance;
import com.l2jserver.model.world.character.CharacterAppearance.CharacterFace;
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairColor;
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairStyle;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.JDBCDatabaseService.CachedMapper;
import com.l2jserver.service.database.JDBCDatabaseService.InsertUpdateQuery;
import com.l2jserver.service.database.JDBCDatabaseService.Mapper;
import com.l2jserver.service.database.JDBCDatabaseService.SelectListQuery;
import com.l2jserver.service.database.JDBCDatabaseService.SelectSingleQuery;
import com.l2jserver.util.geometry.Point3D;
/**
* {@link CharacterDAO} implementation for JDBC
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class JDBCCharacterDAO extends
AbstractJDBCDAO<L2Character, CharacterID> implements CharacterDAO {
/**
* The {@link CharacterID} factory
*/
private final CharacterIDProvider idFactory;
/**
* The {@link CharacterTemplateID} factory
*/
private final CharacterTemplateIDProvider templateIdFactory;
/**
* The {@link AccountID} factory
*/
private final AccountIDProvider accountIdFactory;
/**
* The {@link ClanID} factory
*/
private final ClanIDProvider clanIdFactory;
/**
* Character table name
*/
public static final String TABLE = "character";
// FIELDS
public static final String CHAR_ID = "character_id";
public static final String ACCOUNT_ID = "account_id";
public static final String CLAN_ID = "clan_id";
public static final String NAME = "name";
public static final String RACE = "race";
public static final String CLASS = "class";
public static final String SEX = "sex";
public static final String LEVEL = "level";
public static final String EXPERIENCE = "experience";
public static final String SP = "sp";
public static final String HP = "hp";
public static final String MP = "mp";
public static final String CP = "cp";
public static final String POINT_X = "point_x";
public static final String POINT_Y = "point_y";
public static final String POINT_Z = "point_z";
public static final String POINT_ANGLE = "point_angle";
public static final String APPEARANCE_HAIR_STYLE = "appearance_hair_style";
public static final String APPEARANCE_HAIR_COLOR = "appearance_hair_color";
public static final String APPEARANCE_FACE = "apperance_face";
@Inject
public JDBCCharacterDAO(DatabaseService database,
final CharacterIDProvider idFactory,
CharacterTemplateIDProvider templateIdFactory,
AccountIDProvider accountIdFactory, ClanIDProvider clanIdFactory) {
super(database);
this.idFactory = idFactory;
this.templateIdFactory = templateIdFactory;
this.accountIdFactory = accountIdFactory;
this.clanIdFactory = clanIdFactory;
}
/**
* The mapper for {@link CharacterID}
*/
private final Mapper<CharacterID> idMapper = new Mapper<CharacterID>() {
@Override
public CharacterID map(ResultSet rs) throws SQLException {
return idFactory.resolveID(rs.getInt(CHAR_ID));
}
};
/**
* The {@link Mapper} for {@link L2Character}
*/
private final Mapper<L2Character> mapper = new CachedMapper<L2Character, CharacterID>(
database, idMapper) {
@Override
protected L2Character map(CharacterID id, ResultSet rs)
throws SQLException {
final CharacterClass charClass = CharacterClass.valueOf(rs
.getString(CLASS));
final CharacterTemplateID templateId = templateIdFactory
.resolveID(charClass.id);
final CharacterTemplate template = templateId.getTemplate();
final L2Character character = template.create();
character.setID(id);
character.setAccountID(accountIdFactory.resolveID(rs
.getString(ACCOUNT_ID)));
if (rs.getString(CLAN_ID) != null)
character
.setClanID(clanIdFactory.resolveID(rs.getInt(CLAN_ID)));
character.setName(rs.getString(NAME));
character.setRace(CharacterRace.valueOf(rs.getString(RACE)));
character.setCharacterClass(CharacterClass.valueOf(rs
.getString(CLASS)));
character.setSex(ActorSex.valueOf(rs.getString(SEX)));
character.setLevel(rs.getInt(LEVEL));
character.setExperience(rs.getLong(EXPERIENCE));
character.setSP(rs.getInt(SP));
character.setHP(rs.getDouble(HP));
character.setMP(rs.getDouble(MP));
character.setCP(rs.getDouble(CP));
character.setPoint(Point3D.fromXYZA(rs.getInt(POINT_X),
rs.getInt(POINT_Y), rs.getInt(POINT_Z),
rs.getDouble(POINT_ANGLE)));
// appearance
character.getAppearance().setHairStyle(
CharacterHairStyle.valueOf(rs
.getString(APPEARANCE_HAIR_STYLE)));
character.getAppearance().setHairColor(
CharacterHairColor.valueOf(rs
.getString(APPEARANCE_HAIR_COLOR)));
character.getAppearance().setFace(
CharacterFace.valueOf(rs.getString(APPEARANCE_FACE)));
return character;
}
};
@Override
public L2Character select(final CharacterID id) {
return database.query(new SelectSingleQuery<L2Character>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + CHAR_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, id.getID());
}
@Override
protected Mapper<L2Character> mapper() {
return mapper;
}
});
}
@Override
public void load(final Clan clan) {
clan.getMembers().load(
database.query(new SelectListQuery<CharacterID>() {
@Override
protected String query() {
return "SELECT `" + CHAR_ID + "` FROM `" + TABLE
+ "` WHERE `" + CLAN_ID + "` = ?";
}
@Override
protected void parametize(PreparedStatement st)
throws SQLException {
st.setInt(1, clan.getID().getID());
}
@Override
protected Mapper<CharacterID> mapper() {
return idMapper;
}
}));
}
@Override
public L2Character selectByName(final String name) {
return database.query(new SelectSingleQuery<L2Character>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + NAME + "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setString(1, name);
}
@Override
protected Mapper<L2Character> mapper() {
return mapper;
}
});
}
@Override
public List<L2Character> selectByAccount(final AccountID account) {
return database.query(new SelectListQuery<L2Character>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + ACCOUNT_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setString(1, account.getID());
}
@Override
protected Mapper<L2Character> mapper() {
return mapper;
}
});
}
@Override
public List<CharacterID> selectIDs() {
return database.query(new SelectListQuery<CharacterID>() {
@Override
protected String query() {
return "SELECT `" + CHAR_ID + "` FROM `" + TABLE + "`";
}
@Override
protected Mapper<CharacterID> mapper() {
return idMapper;
}
});
}
@Override
public boolean insert(L2Character character) {
return database.query(new InsertUpdateQuery<L2Character>(character) {
@Override
protected String query() {
return "INSERT INTO `" + TABLE + "` (`" + CHAR_ID + "`,`"
+ ACCOUNT_ID + "`,`" + CLAN_ID + "`,`" + NAME + "`,`"
+ RACE + "`,`" + CLASS + "`,`" + SEX + "`,`" + LEVEL
+ "`,`" + EXPERIENCE + "`,`" + SP + "`,`" + HP + "`,`"
+ MP + "`,`" + CP + "`,`" + POINT_X + "`,`" + POINT_Y
+ "`,`" + POINT_Z + "`,`" + POINT_ANGLE + "`,`"
+ APPEARANCE_HAIR_STYLE + "`,`" + APPEARANCE_HAIR_COLOR
+ "`,`" + APPEARANCE_FACE
+ "`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
}
@Override
protected void parametize(PreparedStatement st,
L2Character character) throws SQLException {
final CharacterAppearance appearance = character
.getAppearance();
int i = 1;
st.setInt(i++, character.getID().getID());
st.setString(i++, character.getAccountID().getID());
if (character.getClanID() != null)
st.setInt(i++, character.getClanID().getID());
else
st.setNull(i++, Types.INTEGER);
st.setString(i++, character.getName());
st.setString(i++, character.getRace().name());
st.setString(i++, character.getCharacterClass().name());
st.setString(i++, character.getSex().name());
st.setInt(i++, character.getLevel());
st.setLong(i++, character.getExperience());
st.setInt(i++, character.getSP());
st.setDouble(i++, character.getHP());
st.setDouble(i++, character.getMP());
st.setDouble(i++, character.getCP());
st.setInt(i++, character.getPoint().getX());
st.setInt(i++, character.getPoint().getY());
st.setInt(i++, character.getPoint().getZ());
st.setDouble(i++, character.getPoint().getAngle());
// appearance
st.setString(i++, appearance.getHairStyle().name());
st.setString(i++, appearance.getHairColor().name());
st.setString(i++, appearance.getFace().name());
}
}) > 0;
}
@Override
public boolean update(L2Character character) {
return database.query(new InsertUpdateQuery<L2Character>(character) {
@Override
protected String query() {
return "UPDATE `" + TABLE + "` SET `" + ACCOUNT_ID + "` = ?,`"
+ CLAN_ID + "` = ?,`" + NAME + "` = ?,`" + RACE
+ "` = ?,`" + CLASS + "` = ?,`" + SEX + "` = ?,`"
+ LEVEL + "` = ?,`" + EXPERIENCE + "` = ?,`" + SP
+ "` = ?,`" + HP + "` = ?,`" + MP + "` = ?,`" + CP
+ "` = ?,`" + POINT_X + "` = ?,`" + POINT_Y + "` = ?,`"
+ POINT_Z + "` = ?,`" + POINT_ANGLE + "` = ?,`"
+ APPEARANCE_HAIR_STYLE + "` = ?,`"
+ APPEARANCE_HAIR_COLOR + "` = ?,`" + APPEARANCE_FACE
+ "` = ? WHERE `" + CHAR_ID + "` = ?";
}
@Override
protected void parametize(PreparedStatement st,
L2Character character) throws SQLException {
final CharacterAppearance appearance = character
.getAppearance();
int i = 1;
// SET
st.setString(i++, character.getAccountID().getID());
if (character.getClanID() != null)
st.setInt(i++, character.getClanID().getID());
else
st.setNull(i++, Types.INTEGER);
st.setString(i++, character.getName());
st.setString(i++, character.getRace().name());
st.setString(i++, character.getCharacterClass().name());
st.setString(i++, character.getSex().name());
st.setInt(i++, character.getLevel());
st.setLong(i++, character.getExperience());
st.setInt(i++, character.getSP());
st.setDouble(i++, character.getHP());
st.setDouble(i++, character.getMP());
st.setDouble(i++, character.getCP());
// position
st.setInt(i++, character.getPoint().getX());
st.setInt(i++, character.getPoint().getY());
st.setInt(i++, character.getPoint().getZ());
st.setDouble(i++, character.getPoint().getAngle());
// appearance
st.setString(i++, appearance.getHairStyle().name());
st.setString(i++, appearance.getHairColor().name());
st.setString(i++, appearance.getFace().name());
// WHERE
st.setInt(i++, character.getID().getID());
}
}) > 0;
}
@Override
public boolean delete(L2Character character) {
return database.query(new InsertUpdateQuery<L2Character>(character) {
@Override
protected String query() {
return "DELETE FROM `" + TABLE + "` WHERE `" + CHAR_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st,
L2Character character) throws SQLException {
st.setInt(1, character.getID().getID());
}
}) > 0;
}
}

View File

@@ -0,0 +1,222 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterFriendDAO;
import com.l2jserver.model.game.CharacterFriend;
import com.l2jserver.model.id.FriendID;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.provider.FriendIDProvider;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.character.CharacterFriendList;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.JDBCDatabaseService.CachedMapper;
import com.l2jserver.service.database.JDBCDatabaseService.InsertUpdateQuery;
import com.l2jserver.service.database.JDBCDatabaseService.Mapper;
import com.l2jserver.service.database.JDBCDatabaseService.SelectListQuery;
import com.l2jserver.service.database.JDBCDatabaseService.SelectSingleQuery;
/**
* {@link CharacterFriendDAO} implementation for JDBC
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class JDBCCharacterFriendDAO extends
AbstractJDBCDAO<CharacterFriend, FriendID> implements
CharacterFriendDAO {
/**
* The {@link FriendID} provider
*/
private final FriendIDProvider idProvider;
/**
* The {@link CharacterID} provider
*/
private final CharacterIDProvider charIdProvider;
/**
* Character table name
*/
public static final String TABLE = "character_friend";
// FIELDS
public static final String CHAR_ID = JDBCCharacterDAO.CHAR_ID;
public static final String CHAR_ID_FRIEND = JDBCCharacterDAO.CHAR_ID
+ "_friend";
@Inject
public JDBCCharacterFriendDAO(DatabaseService database,
final FriendIDProvider idProvider,
CharacterIDProvider charIdProvider) {
super(database);
this.idProvider = idProvider;
this.charIdProvider = charIdProvider;
}
/**
* The {@link Mapper} for {@link FriendID}
*/
private final Mapper<FriendID> idMapper = new Mapper<FriendID>() {
@Override
public FriendID map(ResultSet rs) throws SQLException {
final CharacterID characterId = charIdProvider.resolveID(rs
.getInt(CHAR_ID));
final CharacterID friendId = charIdProvider.resolveID(rs
.getInt(CHAR_ID_FRIEND));
return idProvider.createID(characterId, friendId);
}
};
/**
* The {@link Mapper} for {@link CharacterFriend}
*/
private final Mapper<CharacterFriend> mapper = new CachedMapper<CharacterFriend, FriendID>(
database, idMapper) {
@Override
protected CharacterFriend map(FriendID id, ResultSet rs)
throws SQLException {
return new CharacterFriend(id);
}
};
@Override
public CharacterFriend select(final FriendID id) {
return database.query(new SelectSingleQuery<CharacterFriend>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + CHAR_ID
+ "` = ? AND `" + CHAR_ID_FRIEND + "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, id.getID1().getID());
st.setInt(2, id.getID2().getID());
}
@Override
protected Mapper<CharacterFriend> mapper() {
return mapper;
}
});
}
@Override
public void load(final L2Character character) {
final List<CharacterFriend> list = database
.query(new SelectListQuery<CharacterFriend>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `"
+ CHAR_ID + "` = ?";
}
@Override
protected void parametize(PreparedStatement st)
throws SQLException {
st.setInt(1, character.getID().getID());
}
@Override
protected Mapper<CharacterFriend> mapper() {
return mapper;
}
});
character.getFriendList().load(list);
}
@Override
public List<FriendID> selectIDs() {
return database.query(new SelectListQuery<FriendID>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "`";
}
@Override
protected Mapper<FriendID> mapper() {
return idMapper;
}
});
}
@Override
public boolean insert(CharacterFriend friend) {
return database.query(new InsertUpdateQuery<CharacterFriend>(friend) {
@Override
protected String query() {
return "INSERT INTO `" + TABLE + "` (`" + CHAR_ID + "`,`"
+ CHAR_ID_FRIEND + "`) VALUES(?,?)";
}
@Override
protected void parametize(PreparedStatement st,
CharacterFriend friend) throws SQLException {
st.setInt(1, friend.getCharacterID().getID());
st.setInt(2, friend.getFriendID().getID());
}
}) > 0;
}
@Override
public boolean update(CharacterFriend friend) {
// it is not possible update friend objects, because they are only a ID
// pair and IDs are immutable
return false;
}
@Override
public boolean delete(CharacterFriend friend) {
return database.query(new InsertUpdateQuery<CharacterFriend>(friend) {
@Override
protected String query() {
return "DELETE FROM `" + TABLE + "` WHERE `" + CHAR_ID
+ "` = ?,`" + CHAR_ID_FRIEND + "` = ?";
}
@Override
protected void parametize(PreparedStatement st,
CharacterFriend friend) throws SQLException {
st.setInt(1, friend.getCharacterID().getID());
st.setInt(2, friend.getFriendID().getID());
}
}) > 0;
}
@Override
public boolean save(final CharacterFriendList friends) {
for (final CharacterFriend friend : friends) {
if (!save(friend))
return false;
}
return true;
}
@Override
public boolean delete(final CharacterFriendList friends) {
for (final CharacterFriend friend : friends) {
if (!delete(friend))
return false;
}
return true;
}
}

View File

@@ -0,0 +1,220 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.ChatMessageDAO;
import com.l2jserver.model.id.ChatMessageID;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.provider.ChatMessageIDProvider;
import com.l2jserver.model.server.ChatMessage;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.JDBCDatabaseService.CachedMapper;
import com.l2jserver.service.database.JDBCDatabaseService.InsertUpdateQuery;
import com.l2jserver.service.database.JDBCDatabaseService.Mapper;
import com.l2jserver.service.database.JDBCDatabaseService.SelectListQuery;
import com.l2jserver.service.database.JDBCDatabaseService.SelectSingleQuery;
import com.l2jserver.service.game.chat.ChatMessageType;
/**
* {@link CharacterDAO} implementation for JDBC
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class JDBCChatMessageDAO extends
AbstractJDBCDAO<ChatMessage, ChatMessageID> implements ChatMessageDAO {
/**
* The {@link ChatMessageID} factory
*/
private final ChatMessageIDProvider idFactory;
/**
* The {@link CharacterID} factory
*/
private final CharacterIDProvider charIdFactory;
/**
* Character table name
*/
public static final String TABLE = "log_chat";
// FIELDS
public static final String MESSAGE_ID = "message_id";
public static final String TYPE = "type";
public static final String CHANNEL_ID = "channel_id";
public static final String SENDER = "sender";
public static final String DATE = "date";
public static final String MESSAGE = "message";
@Inject
public JDBCChatMessageDAO(DatabaseService database,
ChatMessageIDProvider idFactory,
final CharacterIDProvider charIdFactory) {
super(database);
this.idFactory = idFactory;
this.charIdFactory = charIdFactory;
}
/**
* The {@link Mapper} for {@link ChatMessageID}
*/
private final Mapper<ChatMessageID> idMapper = new Mapper<ChatMessageID>() {
@Override
public ChatMessageID map(ResultSet rs) throws SQLException {
return idFactory.resolveID(rs.getInt(MESSAGE_ID));
}
};
/**
* The {@link Mapper} for {@link ChatMessageID} as a PRIMARY KEY
*/
private final Mapper<ChatMessageID> primaryKeyMapper = new Mapper<ChatMessageID>() {
@Override
public ChatMessageID map(ResultSet rs) throws SQLException {
return idFactory.resolveID(rs.getInt(1));
}
};
/**
* The {@link Mapper} for {@link ChatMessage}
*/
private final Mapper<ChatMessage> mapper = new CachedMapper<ChatMessage, ChatMessageID>(
database, idMapper) {
@Override
protected ChatMessage map(ChatMessageID id, ResultSet rs)
throws SQLException {
final ChatMessage message = new ChatMessage();
message.setID(id);
message.setType(ChatMessageType.valueOf(rs.getString(TYPE)));
switch (message.getType()) {
case SHOUT:
message.setTarget(charIdFactory.resolveID(rs.getInt(CHANNEL_ID)));
break;
default:
message.setChannelID(rs.getInt(CHANNEL_ID));
break;
}
message.setSender(charIdFactory.resolveID(rs.getInt(SENDER)));
message.setDate(new Date(rs.getTimestamp(DATE).getTime()));
message.setMessage(rs.getString(MESSAGE));
return message;
}
};
@Override
public ChatMessage select(final ChatMessageID id) {
return database.query(new SelectSingleQuery<ChatMessage>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + MESSAGE_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, id.getID());
}
@Override
protected Mapper<ChatMessage> mapper() {
return mapper;
}
});
}
@Override
public List<ChatMessageID> selectIDs() {
return database.query(new SelectListQuery<ChatMessageID>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "`";
}
@Override
protected Mapper<ChatMessageID> mapper() {
return idMapper;
}
});
}
@Override
public boolean insert(ChatMessage message) {
return database.query(new InsertUpdateQuery<ChatMessage>(message) {
@Override
protected String query() {
return "INSERT INTO `" + TABLE + "` (`" + TYPE + "`,`"
+ CHANNEL_ID + "`,`" + SENDER + "`,`" + DATE + "`,`"
+ MESSAGE + "`) VALUES(?,?,?,?,?)";
}
@Override
protected void parametize(PreparedStatement st, ChatMessage message)
throws SQLException {
int i = 1;
st.setString(i++, message.getType().name());
switch (message.getType()) {
case SHOUT:
st.setInt(i++, message.getTarget().getID());
break;
default:
st.setInt(i++, message.getChannelID());
break;
}
st.setInt(i++, message.getSender().getID());
st.setTimestamp(i++, new Timestamp(message.getDate().getTime()));
st.setString(i++, message.getMessage());
}
@Override
protected Mapper<ChatMessageID> keyMapper() {
return primaryKeyMapper;
}
}) > 0;
}
@Override
public boolean update(ChatMessage message) {
// cannot update chat message logs
return false;
}
@Override
public boolean delete(ChatMessage message) {
return database.query(new InsertUpdateQuery<ChatMessage>(message) {
@Override
protected String query() {
return "DELETE FROM `" + TABLE + "` WHERE `" + MESSAGE_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st, ChatMessage message)
throws SQLException {
st.setInt(1, message.getID().getID());
}
}) > 0;
}
}

View File

@@ -0,0 +1,170 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.ClanDAO;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.model.world.Clan;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.JDBCDatabaseService.CachedMapper;
import com.l2jserver.service.database.JDBCDatabaseService.InsertUpdateQuery;
import com.l2jserver.service.database.JDBCDatabaseService.Mapper;
import com.l2jserver.service.database.JDBCDatabaseService.SelectListQuery;
import com.l2jserver.service.database.JDBCDatabaseService.SelectSingleQuery;
/**
* {@link CharacterDAO} implementation for JDBC
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class JDBCClanDAO extends AbstractJDBCDAO<Clan, ClanID>
implements ClanDAO {
/**
* The {@link ClanID} factory
*/
private final ClanIDProvider idFactory;
/**
* The {@link CharacterID} factory
*/
@SuppressWarnings("unused")
private final CharacterIDProvider charIdFactory;
/**
* Character table name
*/
public static final String TABLE = "clan";
// FIELDS
public static final String CLAN_ID = "clan_id";
public static final String CHAR_ID_LEADER = "character_id_leader";
@Inject
public JDBCClanDAO(DatabaseService database, ClanIDProvider clanIdFactory,
final CharacterIDProvider idFactory) {
super(database);
this.idFactory = clanIdFactory;
this.charIdFactory = idFactory;
}
/**
* The {@link Mapper} for {@link ClanID}
*/
private final Mapper<ClanID> idMapper = new Mapper<ClanID>() {
@Override
public ClanID map(ResultSet rs) throws SQLException {
return idFactory.resolveID(rs.getInt(CLAN_ID));
}
};
/**
* The {@link Mapper} for {@link Clan}
*/
private final Mapper<Clan> mapper = new CachedMapper<Clan, ClanID>(
database, idMapper) {
@Override
protected Clan map(ClanID id, ResultSet rs) throws SQLException {
final Clan clan = new Clan();
clan.setID(id);
return clan;
}
};
@Override
public Clan select(final ClanID id) {
return database.query(new SelectSingleQuery<Clan>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + CLAN_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, id.getID());
}
@Override
protected Mapper<Clan> mapper() {
return mapper;
}
});
}
@Override
public List<ClanID> selectIDs() {
return database.query(new SelectListQuery<ClanID>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "`";
}
@Override
protected Mapper<ClanID> mapper() {
return idMapper;
}
});
}
@Override
public boolean insert(Clan clan) {
return database.query(new InsertUpdateQuery<Clan>(clan) {
@Override
protected String query() {
return "INSERT INTO `" + TABLE + "` (`" + CLAN_ID
+ "`) VALUES(?)";
}
@Override
protected void parametize(PreparedStatement st, Clan clan)
throws SQLException {
st.setInt(1, clan.getID().getID());
}
}) > 0;
}
@Override
public boolean update(Clan clan) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean delete(Clan clan) {
return database.query(new InsertUpdateQuery<Clan>(clan) {
@Override
protected String query() {
return "DELETE FROM `" + TABLE + "` WHERE `" + CLAN_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st, Clan clan)
throws SQLException {
st.setInt(1, clan.getID().getID());
}
}) > 0;
}
}

View File

@@ -0,0 +1,223 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import com.google.inject.Inject;
import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ItemIDProvider;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.model.template.ItemTemplate;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.character.CharacterInventory;
import com.l2jserver.model.world.character.CharacterInventory.InventoryLocation;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.JDBCDatabaseService.CachedMapper;
import com.l2jserver.service.database.JDBCDatabaseService.InsertUpdateQuery;
import com.l2jserver.service.database.JDBCDatabaseService.Mapper;
import com.l2jserver.service.database.JDBCDatabaseService.SelectListQuery;
import com.l2jserver.service.database.JDBCDatabaseService.SelectSingleQuery;
import com.l2jserver.util.geometry.Coordinate;
/**
* {@link ItemDAO} implementation for JDBC
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class JDBCItemDAO extends AbstractJDBCDAO<Item, ItemID>
implements ItemDAO {
/**
* The {@link ItemID} factory
*/
private final ItemIDProvider idFactory;
/**
* The {@link ItemTemplateID} factory
*/
private final ItemTemplateIDProvider templateIdFactory;
/**
* The {@link CharacterID} factory
*/
private final CharacterIDProvider charIdFactory;
/**
* Character table name
*/
public static final String TABLE = "item";
// FIELDS
public static final String ITEM_ID = "item_id";
public static final String TEMPLATE_ID = "template_id";
public static final String CHAR_ID = JDBCCharacterDAO.CHAR_ID;
public static final String LOCATION = "location";
public static final String PAPERDOLL = "paperdoll";
public static final String COUNT = "count";
public static final String COORD_X = "coord_x";
public static final String COORD_Y = "coord_y";
public static final String COORD_Z = "coord_z";
@Inject
public JDBCItemDAO(DatabaseService database,
final ItemIDProvider idFactory,
ItemTemplateIDProvider templateIdFactory,
CharacterIDProvider charIdFactory) {
super(database);
this.idFactory = idFactory;
this.templateIdFactory = templateIdFactory;
this.charIdFactory = charIdFactory;
}
/**
* The {@link Mapper} for {@link ItemID}
*/
private final Mapper<ItemID> idMapper = new Mapper<ItemID>() {
@Override
public ItemID map(ResultSet rs) throws SQLException {
return idFactory.resolveID(rs.getInt(ITEM_ID));
}
};
/**
* The {@link Mapper} instance
*/
private final Mapper<Item> mapper = new CachedMapper<Item, ItemID>(
database, idMapper) {
@Override
public Item map(ItemID id, ResultSet rs) throws SQLException {
final ItemTemplateID templateId = templateIdFactory.resolveID(rs
.getInt(TEMPLATE_ID));
final ItemTemplate template = templateId.getTemplate();
final Item item = template.create();
item.setID(id);
if (rs.getObject(CHAR_ID) != null)
item.setOwnerID(charIdFactory.resolveID(rs.getInt(CHAR_ID)));
if (rs.getObject(LOCATION) != null)
item.setLocation(InventoryLocation.valueOf(rs
.getString(LOCATION)));
if (rs.getObject(PAPERDOLL) != null)
item.setPaperdoll(InventoryPaperdoll.valueOf(rs
.getString(PAPERDOLL)));
item.setCount(rs.getInt(COUNT));
if (rs.getObject(COORD_X) != null && rs.getObject(COORD_Y) != null
&& rs.getObject(COORD_Z) != null)
item.setPosition(Coordinate.fromXYZ(rs.getInt(COORD_X),
rs.getInt(COORD_Y), rs.getInt(COORD_Z)));
return item;
}
};
@Override
public Item select(final ItemID id) {
return database.query(new SelectSingleQuery<Item>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + ITEM_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, id.getID());
}
@Override
protected Mapper<Item> mapper() {
return mapper;
}
});
}
@Override
public int loadInventory(final L2Character character) {
final CharacterInventory inventory = character.getInventory();
final List<Item> items = database.query(new SelectListQuery<Item>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + CHAR_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, character.getID().getID());
}
@Override
protected Mapper<Item> mapper() {
return mapper;
}
});
inventory.load(items);
return items.size();
}
@Override
public List<ItemID> selectIDs() {
return database.query(new SelectListQuery<ItemID>() {
@Override
protected String query() {
return "SELECT `" + ITEM_ID + "` FROM `" + TABLE + "`";
}
@Override
protected Mapper<ItemID> mapper() {
return idMapper;
}
});
}
@Override
public boolean insert(Item item) {
throw new UnsupportedOperationException(
"Saving items is not yet implemented!");
}
@Override
public boolean update(Item item) {
return false;
}
@Override
public boolean delete(Item item) {
return database.query(new InsertUpdateQuery<Item>(item) {
@Override
protected String query() {
return "DELETE FROM `" + TABLE + "` WHERE `" + ITEM_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st, Item item)
throws SQLException {
st.setInt(1, item.getID().getID());
}
}) > 0;
}
}

View File

@@ -0,0 +1,292 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.NPCDAO;
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.object.provider.NPCIDProvider;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.JDBCDatabaseService.CachedMapper;
import com.l2jserver.service.database.JDBCDatabaseService.InsertUpdateQuery;
import com.l2jserver.service.database.JDBCDatabaseService.Mapper;
import com.l2jserver.service.database.JDBCDatabaseService.SelectListQuery;
import com.l2jserver.service.database.JDBCDatabaseService.SelectSingleQuery;
import com.l2jserver.util.geometry.Point3D;
/**
* {@link CharacterDAO} implementation for JDBC
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class JDBCNPCDAO extends AbstractJDBCDAO<NPC, NPCID> implements
NPCDAO {
private final Logger log = LoggerFactory.getLogger(this.getClass());
/**
* The {@link NPCID} provider
*/
private final NPCIDProvider idProvider;
/**
* The {@link NPCTemplateID} provider
*/
private final NPCTemplateIDProvider templateIdProvider;
/**
* Character table name
*/
public static final String TABLE = "npc";
// FIELDS
public static final String NPC_ID = "npc_id";
public static final String NPC_TEMPLATE_ID = "npc_template_id";
public static final String HP = "hp";
public static final String MP = "mp";
public static final String POINT_X = "point_x";
public static final String POINT_Y = "point_y";
public static final String POINT_Z = "point_z";
public static final String POINT_ANGLE = "point_angle";
public static final String RESPAWN_TIME = "respawn_time";
@Inject
public JDBCNPCDAO(DatabaseService database, final NPCIDProvider idProvider,
NPCTemplateIDProvider templateIdProvider) {
super(database);
this.idProvider = idProvider;
this.templateIdProvider = templateIdProvider;
}
/**
* The {@link Mapper} for {@link NPCID}
*/
private final Mapper<NPCID> idMapper = new Mapper<NPCID>() {
@Override
public NPCID map(ResultSet rs) throws SQLException {
if (rs.getString(NPC_ID) == null)
return null;
return idProvider.resolveID(rs.getInt(NPC_ID));
}
};
/**
* The {@link Mapper} for {@link NPC}
*/
private final Mapper<NPC> mapper = new CachedMapper<NPC, NPCID>(database,
idMapper) {
@Override
protected NPC map(NPCID id, ResultSet rs) throws SQLException {
NPCTemplateID templateId = templateIdProvider.resolveID(rs
.getInt(NPC_TEMPLATE_ID));
NPCTemplate template = templateId.getTemplate();
if (template == null) {
// set default npc instance, for now!
// RoxxyGatekeeperTemplate - 30006
log.warn("No template found for {}", templateId);
return null;
}
final NPC npc = template.create();
npc.setID(id);
if (rs.getString(HP) != null)
npc.setHP(rs.getDouble(HP));
if (rs.getString(MP) != null)
npc.setMP(rs.getDouble(MP));
npc.setPoint(Point3D.fromXYZA(rs.getInt(POINT_X),
rs.getInt(POINT_Y), rs.getInt(POINT_Z),
rs.getDouble(POINT_ANGLE)));
npc.setRespawnInterval(rs.getLong(RESPAWN_TIME));
return npc;
}
};
@Override
public NPC select(final NPCID id) {
return database.query(new SelectSingleQuery<NPC>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + NPC_ID
+ "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, id.getID());
}
@Override
protected Mapper<NPC> mapper() {
return mapper;
}
});
}
@Override
public List<NPC> loadAll() {
return database.query(new SelectListQuery<NPC>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "`";
}
@Override
protected Mapper<NPC> mapper() {
return mapper;
}
});
}
@Override
public List<NPC> selectByTemplate(final NPCTemplateID template) {
return database.query(new SelectListQuery<NPC>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `"
+ NPC_TEMPLATE_ID + "` = ?";
}
@Override
protected void parametize(PreparedStatement st) throws SQLException {
st.setInt(1, template.getID());
}
@Override
protected Mapper<NPC> mapper() {
return mapper;
}
});
}
@Override
public List<NPCID> selectIDs() {
return database.query(new SelectListQuery<NPCID>() {
@Override
protected String query() {
return "SELECT `" + NPC_ID + "` FROM `" + TABLE + "`";
}
@Override
protected Mapper<NPCID> mapper() {
return idMapper;
}
});
}
@Override
public boolean insert(NPC npc) {
return database.query(new InsertUpdateQuery<NPC>(npc) {
@Override
protected String query() {
return "INSERT INTO `" + TABLE + "` (`" + NPC_ID + "`,`"
+ NPC_TEMPLATE_ID + "`,`" + HP + "`, `" + MP + "`,`"
+ POINT_X + "`,`" + POINT_Y + "`,`" + POINT_Z + "`,`"
+ POINT_ANGLE + "`,`" + RESPAWN_TIME
+ "`) VALUES(?,?,?,?,?,?,?,?,?)";
}
@Override
protected void parametize(PreparedStatement st, NPC npc)
throws SQLException {
int i = 1;
st.setInt(i++, npc.getID().getID());
st.setInt(i++, npc.getTemplateID().getID());
st.setDouble(i++, npc.getHP());
st.setDouble(i++, npc.getMP());
st.setInt(i++, npc.getPoint().getX());
st.setInt(i++, npc.getPoint().getY());
st.setInt(i++, npc.getPoint().getZ());
st.setDouble(i++, npc.getPoint().getAngle());
st.setLong(i++, npc.getRespawnInterval());
}
}) > 0;
}
@Override
public boolean update(NPC npc) {
return database.query(new InsertUpdateQuery<NPC>(npc) {
@Override
protected String query() {
return "UPDATE `" + TABLE + "` SET `" + NPC_TEMPLATE_ID
+ "` = ?,`" + HP + "` = ?, `" + MP + "` = ?,`"
+ POINT_X + "` = ?,`" + POINT_Y + "` = ?,`" + POINT_Z
+ "` = ?,`" + POINT_ANGLE + "` = ?, `" + RESPAWN_TIME
+ "` = ? WHERE `" + NPC_ID + "` = ?";
}
@Override
protected void parametize(PreparedStatement st, NPC npc)
throws SQLException {
int i = 1;
// SET
st.setInt(i++, npc.getTemplateID().getID());
st.setDouble(i++, npc.getHP());
st.setDouble(i++, npc.getMP());
st.setInt(i++, npc.getPoint().getX());
st.setInt(i++, npc.getPoint().getY());
st.setInt(i++, npc.getPoint().getZ());
st.setDouble(i++, npc.getPoint().getAngle());
st.setLong(i++, npc.getRespawnInterval());
// WHERE
st.setInt(i++, npc.getID().getID());
}
}) > 0;
}
@Override
public boolean delete(NPC npc) {
return database.query(new InsertUpdateQuery<NPC>(npc) {
@Override
protected String query() {
return "DELETE FROM `" + TABLE + "` WHERE `" + NPC_ID + "` = ?";
}
@Override
protected void parametize(PreparedStatement st, NPC npc)
throws SQLException {
st.setInt(1, npc.getID().getID());
}
}) > 0;
}
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.h2;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.jdbc.JDBCCharacterDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.model.id.provider.AccountIDProvider;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class H2CharacterDAO extends JDBCCharacterDAO implements CharacterDAO {
@Inject
public H2CharacterDAO(DatabaseService database,
CharacterIDProvider idFactory,
CharacterTemplateIDProvider templateIdFactory,
AccountIDProvider accountIdFactory, ClanIDProvider clanIdFactory) {
super(database, idFactory, templateIdFactory, accountIdFactory,
clanIdFactory);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.h2;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterFriendDAO;
import com.l2jserver.model.dao.jdbc.JDBCCharacterFriendDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.provider.FriendIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterFriendDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class H2CharacterFriendDAO extends JDBCCharacterFriendDAO implements
CharacterFriendDAO {
@Inject
public H2CharacterFriendDAO(DatabaseService database,
FriendIDProvider idProvider, CharacterIDProvider charIdProvider) {
super(database, idProvider, charIdProvider);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.h2;
import com.google.inject.Inject;
import com.l2jserver.model.dao.ChatMessageDAO;
import com.l2jserver.model.dao.jdbc.JDBCChatMessageDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.provider.ChatMessageIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link ChatMessageDAO} implementation for H2 database
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class H2ChatMessageDAO extends JDBCChatMessageDAO implements
ChatMessageDAO {
@Inject
public H2ChatMessageDAO(DatabaseService database,
ChatMessageIDProvider idFactory, CharacterIDProvider charIdFactory) {
super(database, idFactory, charIdFactory);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.h2;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.ClanDAO;
import com.l2jserver.model.dao.jdbc.JDBCClanDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class H2ClanDAO extends JDBCClanDAO implements ClanDAO {
@Inject
public H2ClanDAO(DatabaseService database, ClanIDProvider clanIdFactory,
CharacterIDProvider idFactory) {
super(database, clanIdFactory, idFactory);
}
}

View File

@@ -0,0 +1,39 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.h2;
import com.google.inject.Inject;
import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.dao.jdbc.JDBCItemDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ItemIDProvider;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link ItemDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class H2ItemDAO extends JDBCItemDAO implements ItemDAO {
@Inject
public H2ItemDAO(DatabaseService database, ItemIDProvider idFactory,
ItemTemplateIDProvider templateIdFactory,
CharacterIDProvider charIdFactory) {
super(database, idFactory, templateIdFactory, charIdFactory);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.h2;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.NPCDAO;
import com.l2jserver.model.dao.jdbc.JDBCNPCDAO;
import com.l2jserver.model.id.object.provider.NPCIDProvider;
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class H2NPCDAO extends JDBCNPCDAO implements NPCDAO {
@Inject
public H2NPCDAO(DatabaseService database, NPCIDProvider idProvider,
NPCTemplateIDProvider templateIdProvider) {
super(database, idProvider, templateIdProvider);
}
}

View File

@@ -0,0 +1,43 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.mysql5;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.jdbc.JDBCCharacterDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.model.id.provider.AccountIDProvider;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class MySQL5CharacterDAO extends JDBCCharacterDAO implements
CharacterDAO {
@Inject
public MySQL5CharacterDAO(DatabaseService database,
CharacterIDProvider idFactory,
CharacterTemplateIDProvider templateIdFactory,
AccountIDProvider accountIdFactory, ClanIDProvider clanIdFactory) {
super(database, idFactory, templateIdFactory, accountIdFactory,
clanIdFactory);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.mysql5;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterFriendDAO;
import com.l2jserver.model.dao.jdbc.JDBCCharacterFriendDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.provider.FriendIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterFriendDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class MySQL5CharacterFriendDAO extends JDBCCharacterFriendDAO implements
CharacterFriendDAO {
@Inject
public MySQL5CharacterFriendDAO(DatabaseService database,
FriendIDProvider idProvider, CharacterIDProvider charIdProvider) {
super(database, idProvider, charIdProvider);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.mysql5;
import com.google.inject.Inject;
import com.l2jserver.model.dao.ChatMessageDAO;
import com.l2jserver.model.dao.jdbc.JDBCChatMessageDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.provider.ChatMessageIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link ChatMessageDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class MySQL5ChatMessageDAO extends JDBCChatMessageDAO implements
ChatMessageDAO {
@Inject
public MySQL5ChatMessageDAO(DatabaseService database,
ChatMessageIDProvider idFactory, CharacterIDProvider charIdFactory) {
super(database, idFactory, charIdFactory);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.mysql5;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.ClanDAO;
import com.l2jserver.model.dao.jdbc.JDBCClanDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class MySQL5ClanDAO extends JDBCClanDAO implements ClanDAO {
@Inject
public MySQL5ClanDAO(DatabaseService database,
ClanIDProvider clanIdFactory, CharacterIDProvider idFactory) {
super(database, clanIdFactory, idFactory);
}
}

View File

@@ -0,0 +1,39 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.mysql5;
import com.google.inject.Inject;
import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.dao.jdbc.JDBCItemDAO;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.ItemIDProvider;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link ItemDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class MySQL5ItemDAO extends JDBCItemDAO implements ItemDAO {
@Inject
public MySQL5ItemDAO(DatabaseService database, ItemIDProvider idFactory,
ItemTemplateIDProvider templateIdFactory,
CharacterIDProvider charIdFactory) {
super(database, idFactory, templateIdFactory, charIdFactory);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.dao.jdbc.mysql5;
import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.NPCDAO;
import com.l2jserver.model.dao.jdbc.JDBCNPCDAO;
import com.l2jserver.model.id.object.provider.NPCIDProvider;
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
import com.l2jserver.service.database.DatabaseService;
/**
* {@link CharacterDAO} implementation for MySQL5
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class MySQL5NPCDAO extends JDBCNPCDAO implements NPCDAO {
@Inject
public MySQL5NPCDAO(DatabaseService database, NPCIDProvider idProvider,
NPCTemplateIDProvider templateIdProvider) {
super(database, idProvider, templateIdProvider);
}
}

View File

@@ -18,7 +18,7 @@ package com.l2jserver.model.id.object;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.db.dao.CharacterDAO;
import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.model.world.L2Character;

View File

@@ -18,7 +18,7 @@ package com.l2jserver.model.id.object;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.db.dao.ClanDAO;
import com.l2jserver.model.dao.ClanDAO;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.model.world.Clan;

View File

@@ -18,7 +18,7 @@ package com.l2jserver.model.id.object;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.db.dao.ItemDAO;
import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.model.world.Item;

View File

@@ -17,7 +17,7 @@
package com.l2jserver.model.id.object;
import com.google.inject.Inject;
import com.l2jserver.db.dao.PetDAO;
import com.l2jserver.model.dao.PetDAO;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.model.world.Pet;