přejmenována třída ObjectType na DeviceType
parent
648bb5da70
commit
25ed18b735
|
|
@ -68,11 +68,11 @@ public final class Database {
|
|||
/// -------- ObjectType --------
|
||||
///
|
||||
|
||||
public static ArrayList<ObjectType> getObjectType() {
|
||||
public static ArrayList<DeviceType> getObjectType() {
|
||||
return new ArrayList<>(objectTypeDao.getObjectTypes());
|
||||
}
|
||||
|
||||
public static int addObjectType(ObjectType ot) {
|
||||
public static int addObjectType(DeviceType ot) {
|
||||
return objectTypeDao.addObjectType(ot);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import org.apache.commons.configuration2.Configuration;
|
|||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
import jnet.lib.BuilddDate;
|
||||
import jnet.lib.LogFile;
|
||||
import jnet.lib.object.DeviceType;
|
||||
import jnet.lib.object.Event;
|
||||
import jnet.lib.object.ObjectType;
|
||||
import jnet.lib.object.OnlineClients;
|
||||
import jnet.lib.object.Site;
|
||||
import jnet.lib.object.SnmpProfile;
|
||||
|
|
@ -37,7 +37,7 @@ public class Server {
|
|||
|
||||
public static List<OnlineClients> onlineClients = new ArrayList<>();
|
||||
public static List<Site> site = new ArrayList<>();
|
||||
public static List<ObjectType> objectType = new ArrayList<>();
|
||||
public static List<DeviceType> devicType = new ArrayList<>();
|
||||
public static List<SnmpProfile> snmpProfile = new ArrayList<>();
|
||||
public static List<User> users = new ArrayList<>();
|
||||
public static List<Event> events = new ArrayList<>();
|
||||
|
|
@ -101,8 +101,8 @@ public class Server {
|
|||
|
||||
// nacteni node icon
|
||||
LogFile.printInfo("Loading node icon ...");
|
||||
objectType = Database.getObjectType();
|
||||
LogFile.printInfo(" load " + objectType.size() + " icon(s)");
|
||||
devicType = Database.getObjectType();
|
||||
LogFile.printInfo(" load " + devicType.size() + " icon(s)");
|
||||
|
||||
// nacteni map a objektu z databaze
|
||||
LogFile.printInfo("Loading map and object list ...");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package jnet.server.dao;
|
||||
|
||||
import jnet.lib.object.ObjectType;
|
||||
import jnet.lib.object.DeviceType;
|
||||
import java.util.List;
|
||||
import jnet.lib.LogFile;
|
||||
|
||||
|
|
@ -8,16 +8,16 @@ public class ObjectTypeDao extends AbstractDao {
|
|||
|
||||
public static final String TABLE = "objectType";
|
||||
|
||||
public List<ObjectType> getObjectTypes() {
|
||||
public List<DeviceType> getObjectTypes() {
|
||||
String sql = "SELECT * FROM " + TABLE;
|
||||
return queryList(sql, rs -> new ObjectType(
|
||||
return queryList(sql, rs -> new DeviceType(
|
||||
rs.getInt("id"),
|
||||
rs.getString("name"),
|
||||
rs.getString("image")
|
||||
));
|
||||
}
|
||||
|
||||
public int addObjectType(ObjectType ot) {
|
||||
public int addObjectType(DeviceType ot) {
|
||||
String sql = "INSERT INTO " + TABLE + " (name, image) VALUES (?, ?)";
|
||||
return insertAndGetId(sql, ot.getName(), ot.getImgStr());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package jnet.server.message;
|
||||
|
||||
import com.mysql.cj.xdevapi.Client;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import java.net.InetSocketAddress;
|
||||
import jnet.lib.LogFile;
|
||||
import jnet.lib.Message;
|
||||
import jnet.lib.object.ObjectType;
|
||||
import jnet.lib.object.OnlineClients;
|
||||
import jnet.lib.object.ServerConfig;
|
||||
import jnet.server.Database;
|
||||
|
|
@ -48,7 +46,7 @@ public class RegisterClientAuth implements Register {
|
|||
// odeslat seznam uzivatelu
|
||||
ctx.writeAndFlush(new Message(Message.USER_LIST, Server.users));
|
||||
// odeslat seznam icon
|
||||
ctx.writeAndFlush(new Message(Message.NODE_ICON_LIST, Server.objectType));
|
||||
ctx.writeAndFlush(new Message(Message.NODE_ICON_LIST, Server.devicType));
|
||||
// odeslat seznam udalosti
|
||||
ctx.writeAndFlush(new Message(Message.EVENT_LIST, Server.events));
|
||||
// odeslat seznam site
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class RegisterDeviceTypeDelete implements Register{
|
|||
Database.deleteDeviceType(id);
|
||||
|
||||
// odebere ze seznamu
|
||||
Server.objectType.removeIf(obj -> obj.getId() == id);
|
||||
Server.devicType.removeIf(obj -> obj.getId() == id);
|
||||
|
||||
ServerHandler.sendAll(Message.DEVICE_TYPE_DELETE_RESULT, id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package jnet.server.message;
|
|||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import jnet.lib.Message;
|
||||
import jnet.lib.object.ObjectType;
|
||||
import jnet.lib.object.DeviceType;
|
||||
import jnet.server.Database;
|
||||
import jnet.server.Server;
|
||||
import jnet.server.networkserver.ServerHandler;
|
||||
|
|
@ -15,14 +15,14 @@ public class RegisterNodeIconNew implements Register {
|
|||
|
||||
@Override
|
||||
public void processing(ChannelHandlerContext ctx, Message msg) {
|
||||
ObjectType not = (ObjectType) msg.getMsg();
|
||||
DeviceType not = (DeviceType) msg.getMsg();
|
||||
// ulozit do databaze
|
||||
int id = Database.addObjectType(not);
|
||||
// pridat do seznamu
|
||||
not.setId(id);
|
||||
Server.objectType.add(not);
|
||||
Server.devicType.add(not);
|
||||
// odeslat vsem novy seznam
|
||||
ServerHandler.sendAll(new Message(Message.NODE_ICON_LIST, Server.objectType));
|
||||
ServerHandler.sendAll(new Message(Message.NODE_ICON_LIST, Server.devicType));
|
||||
// klientovi odeslat pokyn k aktualizaci tabulky
|
||||
ctx.writeAndFlush(new Message(Message.NODE_ICON_REFRESH, null));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue